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 --- sot/source/base/exchange.cxx | 3 ++- sot/source/base/formats.cxx | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) (limited to 'sot') diff --git a/sot/source/base/exchange.cxx b/sot/source/base/exchange.cxx index 146114b8b238..f6d5ee8ca633 100644 --- a/sot/source/base/exchange.cxx +++ b/sot/source/base/exchange.cxx @@ -204,7 +204,8 @@ namespace /*143 SotClipboardFormatId::MATHML*/ { "application/mathml+xml", "MathML", &::cppu::UnoType>::get() }, /*144 SotClipboardFormatId::JPEG*/ { "image/jpeg", "JPEG Bitmap", &cppu::UnoType>::get() }, /*145 SotClipboardFormatId::RICHTEXT*/ { "text/richtext", "Richtext Format", &cppu::UnoType>::get() }, - /*146 SotClipboardFormatId::STRING_TSVC*/ { "application/x-libreoffice-tsvc", "Text TSV-Calc", &cppu::UnoType::get() } + /*146 SotClipboardFormatId::STRING_TSVC*/ { "application/x-libreoffice-tsvc", "Text TSV-Calc", &cppu::UnoType::get() }, + /*147 SotClipboardFormatId::PDF*/ { "application/pdf", "PDF Document", &cppu::UnoType>::get() }, }; return &aInstance[0]; } diff --git a/sot/source/base/formats.cxx b/sot/source/base/formats.cxx index 16b7bd3a87ce..bb5ea3dcae16 100644 --- a/sot/source/base/formats.cxx +++ b/sot/source/base/formats.cxx @@ -18,6 +18,7 @@ */ #include +#include #include #include @@ -335,6 +336,9 @@ SotAction_Impl const aEXCHG_DEST_DOC_GRAPHOBJ_Def[] = { { SotClipboardFormatId::GDIMETAFILE, EXCHG_IN_ACTION_COPY }, { SotClipboardFormatId::DRAWING, EXCHG_IN_ACTION_COPY }, +#if HAVE_FEATURE_PDFIUM + { SotClipboardFormatId::PDF, EXCHG_IN_ACTION_COPY }, +#endif { SotClipboardFormatId::PNG, EXCHG_IN_ACTION_COPY }, { SotClipboardFormatId::JPEG, EXCHG_IN_ACTION_COPY }, { SotClipboardFormatId::BITMAP, EXCHG_IN_ACTION_COPY }, @@ -355,6 +359,9 @@ SotAction_Impl const aEXCHG_DEST_DOC_GRAPHOBJ_Move[] = { SotClipboardFormatId::DRAWING, EXCHG_OUT_ACTION_REPLACE_DRAWOBJ, SotExchangeActionFlags::InsertImageMap | SotExchangeActionFlags::InsertTargetUrl, 0 }, { SotClipboardFormatId::SVXB, EXCHG_OUT_ACTION_REPLACE_SVXB, SotExchangeActionFlags::InsertImageMap | SotExchangeActionFlags::InsertTargetUrl, 0 }, { SotClipboardFormatId::GDIMETAFILE, EXCHG_OUT_ACTION_REPLACE_GDIMETAFILE, SotExchangeActionFlags::InsertImageMap | SotExchangeActionFlags::InsertTargetUrl, 0 }, +#if HAVE_FEATURE_PDFIUM + { SotClipboardFormatId::PDF, EXCHG_OUT_ACTION_INSERT_GRAPH, SotExchangeActionFlags::InsertImageMap | SotExchangeActionFlags::InsertTargetUrl, 0 }, +#endif { SotClipboardFormatId::PNG, EXCHG_OUT_ACTION_REPLACE_BITMAP, SotExchangeActionFlags::InsertImageMap | SotExchangeActionFlags::InsertTargetUrl, 0 }, { SotClipboardFormatId::JPEG, EXCHG_OUT_ACTION_REPLACE_BITMAP, SotExchangeActionFlags::InsertImageMap | SotExchangeActionFlags::InsertTargetUrl, 0 }, { SotClipboardFormatId::BITMAP, EXCHG_OUT_ACTION_REPLACE_BITMAP, SotExchangeActionFlags::InsertImageMap | SotExchangeActionFlags::InsertTargetUrl, 0 }, @@ -370,6 +377,9 @@ SotAction_Impl const aEXCHG_DEST_DOC_GRAPHOBJ_Copy[] = { SotClipboardFormatId::DRAWING, EXCHG_OUT_ACTION_INSERT_DRAWOBJ, SotExchangeActionFlags::InsertImageMap | SotExchangeActionFlags::InsertTargetUrl, 0 }, { SotClipboardFormatId::SVXB, EXCHG_OUT_ACTION_INSERT_SVXB, SotExchangeActionFlags::InsertImageMap | SotExchangeActionFlags::InsertTargetUrl, 0 }, { SotClipboardFormatId::GDIMETAFILE, EXCHG_OUT_ACTION_INSERT_GDIMETAFILE, SotExchangeActionFlags::InsertImageMap | SotExchangeActionFlags::InsertTargetUrl, 0 }, +#if HAVE_FEATURE_PDFIUM + { SotClipboardFormatId::PDF, EXCHG_OUT_ACTION_INSERT_GRAPH, SotExchangeActionFlags::InsertImageMap | SotExchangeActionFlags::InsertTargetUrl, 0 }, +#endif { SotClipboardFormatId::PNG, EXCHG_OUT_ACTION_INSERT_BITMAP, SotExchangeActionFlags::InsertImageMap | SotExchangeActionFlags::InsertTargetUrl, 0 }, { SotClipboardFormatId::JPEG, EXCHG_OUT_ACTION_INSERT_BITMAP, SotExchangeActionFlags::InsertImageMap | SotExchangeActionFlags::InsertTargetUrl, 0 }, { SotClipboardFormatId::BITMAP, EXCHG_OUT_ACTION_INSERT_BITMAP, SotExchangeActionFlags::InsertImageMap | SotExchangeActionFlags::InsertTargetUrl, 0 }, @@ -827,6 +837,9 @@ SotAction_Impl const aEXCHG_DEST_SWDOC_FREE_AREA_Def[] = { SotClipboardFormatId::DRAWING, EXCHG_IN_ACTION_COPY }, { SotClipboardFormatId::SVXB, EXCHG_IN_ACTION_COPY }, { SotClipboardFormatId::GDIMETAFILE, EXCHG_IN_ACTION_COPY }, +#if HAVE_FEATURE_PDFIUM + { SotClipboardFormatId::PDF, EXCHG_IN_ACTION_COPY }, +#endif { SotClipboardFormatId::PNG, EXCHG_IN_ACTION_COPY }, { SotClipboardFormatId::JPEG, EXCHG_IN_ACTION_COPY }, { SotClipboardFormatId::BITMAP, EXCHG_IN_ACTION_COPY }, @@ -857,6 +870,9 @@ SotAction_Impl const aEXCHG_DEST_SWDOC_FREE_AREA_Move[] = { SotClipboardFormatId::RICHTEXT, EXCHG_IN_ACTION_COPY, SotExchangeActionFlags::InsertTargetUrl, 0 }, { SotClipboardFormatId::STRING, EXCHG_OUT_ACTION_INSERT_STRING }, { SotClipboardFormatId::GDIMETAFILE, EXCHG_OUT_ACTION_INSERT_GDIMETAFILE, SotExchangeActionFlags::InsertImageMap | SotExchangeActionFlags::InsertTargetUrl, 0 }, +#if HAVE_FEATURE_PDFIUM + { SotClipboardFormatId::PDF, EXCHG_OUT_ACTION_INSERT_GRAPH, SotExchangeActionFlags::InsertImageMap | SotExchangeActionFlags::InsertTargetUrl, 0 }, +#endif { SotClipboardFormatId::PNG, EXCHG_OUT_ACTION_INSERT_BITMAP, SotExchangeActionFlags::InsertImageMap | SotExchangeActionFlags::InsertTargetUrl, 0 }, { SotClipboardFormatId::JPEG, EXCHG_OUT_ACTION_INSERT_BITMAP, SotExchangeActionFlags::InsertImageMap | SotExchangeActionFlags::InsertTargetUrl, 0 }, { SotClipboardFormatId::BITMAP, EXCHG_OUT_ACTION_INSERT_BITMAP, SotExchangeActionFlags::InsertImageMap | SotExchangeActionFlags::InsertTargetUrl, 0 }, @@ -883,6 +899,9 @@ SotAction_Impl const aEXCHG_DEST_SWDOC_FREE_AREA_Copy[] = { SotClipboardFormatId::EMBEDDED_OBJ, EXCHG_OUT_ACTION_INSERT_OLE, SotExchangeActionFlags::InsertTargetUrl, 0 }, #ifndef MACOSX { SotClipboardFormatId::RTF, EXCHG_IN_ACTION_COPY, SotExchangeActionFlags::InsertTargetUrl, 0 }, +#endif +#if HAVE_FEATURE_PDFIUM + { SotClipboardFormatId::PDF, EXCHG_OUT_ACTION_INSERT_GRAPH, SotExchangeActionFlags::InsertImageMap | SotExchangeActionFlags::InsertTargetUrl, 0 }, #endif { SotClipboardFormatId::PNG, EXCHG_OUT_ACTION_INSERT_BITMAP, SotExchangeActionFlags::InsertImageMap | SotExchangeActionFlags::InsertTargetUrl, 0 }, { SotClipboardFormatId::JPEG, EXCHG_OUT_ACTION_INSERT_BITMAP, SotExchangeActionFlags::InsertImageMap | SotExchangeActionFlags::InsertTargetUrl, 0 }, -- cgit