From 615202cab983f1f13407f6515aeb047e4e09f6ed Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Fri, 26 Apr 2019 20:17:00 +0900 Subject: tdf#118977 support PDF documents as a clipboard format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- vcl/osx/DataFlavorMapping.cxx | 1 + vcl/source/treelist/transfer.cxx | 14 ++++++++++++++ 2 files changed, 15 insertions(+) (limited to 'vcl') 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 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; -- cgit