summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2019-04-26 20:17:00 +0900
committerTomaž Vajngerl <quikee@gmail.com>2019-04-26 17:11:16 +0200
commit615202cab983f1f13407f6515aeb047e4e09f6ed (patch)
tree010025df813e8f69541b5ee0223e7c63725dd50c /vcl
parentc973fb47ef5692069a72211405f3716fade1763e (diff)
tdf#118977 support PDF documents as a clipboard format
On macOS it is possible to copy from a PDF a subset of a document, which will be transported as a new PDF document containing the subset. LibreOffice didn't support PDF as a valid clipboard format and previously it also didn't support showing PDFs inside the document, so in such cases it copy-pasted a low resolution bitmap. The result wasn't good. As we are now able to display PDF documents as Graphic in LO, we can also support this use-case. This adds support for the PDF documents as a clipboard format in general and to the macOS backend. This commit only adds support for Writer. Change-Id: Ib982b55391b390ae06974b4ad836e376dd722a4c Reviewed-on: https://gerrit.libreoffice.org/71364 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/osx/DataFlavorMapping.cxx1
-rw-r--r--vcl/source/treelist/transfer.cxx14
2 files changed, 15 insertions, 0 deletions
diff --git a/vcl/osx/DataFlavorMapping.cxx b/vcl/osx/DataFlavorMapping.cxx
index 2390e797ad4e..48dc56a3037c 100644
--- a/vcl/osx/DataFlavorMapping.cxx
+++ b/vcl/osx/DataFlavorMapping.cxx
@@ -113,6 +113,7 @@ namespace
{
{ NSPasteboardTypeString, "text/plain;charset=utf-16", "Unicode Text (UTF-16)", true },
{ NSPasteboardTypeRTF, "text/rtf", "Rich Text Format", false },
+ { NSPasteboardTypePDF, "application/pdf", "PDF File", false },
{ NSPasteboardTypeTIFF, "image/png", "Portable Network Graphics", false },
{ NSPasteboardTypeHTML, "text/html", "Plain Html", false },
SAL_WNODEPRECATED_DECLARATIONS_PUSH
diff --git a/vcl/source/treelist/transfer.cxx b/vcl/source/treelist/transfer.cxx
index 41c41bf71a08..9f538cfef5b9 100644
--- a/vcl/source/treelist/transfer.cxx
+++ b/vcl/source/treelist/transfer.cxx
@@ -1685,6 +1685,20 @@ bool TransferableDataHelper::GetGraphic( const css::datatransfer::DataFlavor& rF
if( bRet )
rGraphic = aBmpEx;
}
+ else if(SotExchange::GetFormatDataFlavor(SotClipboardFormatId::PDF, aFlavor) &&
+ TransferableDataHelper::IsEqual(aFlavor, rFlavor))
+ {
+ Graphic aGraphic;
+ tools::SvRef<SotStorageStream> xStm;
+ if (GetSotStorageStream(rFlavor, xStm))
+ {
+ if (GraphicConverter::Import(*xStm, aGraphic) == ERRCODE_NONE)
+ {
+ rGraphic = aGraphic;
+ bRet = true;
+ }
+ }
+ }
else if (SotExchange::GetFormatDataFlavor(SotClipboardFormatId::JPEG, aFlavor) && TransferableDataHelper::IsEqual(aFlavor, rFlavor))
{
BitmapEx aBitmapEx;