diff options
-rw-r--r-- | src/corelib/gdi/fpg_gdi.pas | 3 | ||||
-rw-r--r-- | src/corelib/gdi/fpg_oledragdrop.pas | 25 |
2 files changed, 21 insertions, 7 deletions
diff --git a/src/corelib/gdi/fpg_gdi.pas b/src/corelib/gdi/fpg_gdi.pas index 14422af3..bda2be25 100644 --- a/src/corelib/gdi/fpg_gdi.pas +++ b/src/corelib/gdi/fpg_gdi.pas @@ -1443,6 +1443,7 @@ var data: pchar; wg: TfpgWidget; CF: DWORD; + lIsTranslated: Boolean; begin if not FUserAcceptDrag then exit; @@ -1453,7 +1454,7 @@ begin wg := self as TfpgWidget; { construct a FORMATETC object } - CF := WindowsClipboardLoopup(FUserMimeSelection); + CF := WindowsClipboardLookup(FUserMimeSelection, lIsTranslated); FE := GetFormatEtc(CF); if DataObj.QueryGetData(FE) = S_OK then diff --git a/src/corelib/gdi/fpg_oledragdrop.pas b/src/corelib/gdi/fpg_oledragdrop.pas index 2a3cefa9..6c7dc4e9 100644 --- a/src/corelib/gdi/fpg_oledragdrop.pas +++ b/src/corelib/gdi/fpg_oledragdrop.pas @@ -191,7 +191,7 @@ type function WindowsMimeLookup(const CFFormat: string): string;
-function WindowsClipboardLoopup(const AMime: string): DWORD;
+function WindowsClipboardLookup(const AMime: string; var IsTranslated: Boolean): DWORD;
function EnumDataToStringList(DataObj: IDataObject): TStringList;
function GetFormatEtc(const CFFormat: DWORD): FORMATETC;
@@ -223,13 +223,26 @@ begin Result := CFFormat;
end;
-function WindowsClipboardLoopup(const AMime: string): DWORD;
+function WindowsClipboardLookup(const AMime: string; var IsTranslated: Boolean): DWORD;
begin
- { TODO: We need to implement this correctly }
- if AMime = 'text/plain' then
- Result := CF_TEXT
- else
+ { TODO: We need to improve this implementation }
+ if AMime = 'text/html' then
+ begin
+ { We don't want duplicate CF_TEXT in DataObject, so register some of our
+ known convenience types (from TfpgMimeData) as-is }
+ IsTranslated := False;
+ Result := RegisterClipboardFormat('text/html');
+ end
+ else if Pos('text/', AMime) = 1 then
+ begin
+ IsTranslated := True;
Result := CF_TEXT; // fallback result
+ end
+ else
+ begin
+ IsTranslated := False;
+ Result := RegisterClipboardFormat(PChar(AMime));
+ end;
end;
function WindowsClipboardFormatToString(const CFFormat: integer): string;
|