include/sot/formats.hxx          |    3 ++-
 sot/source/base/exchange.cxx     |    3 ++-
 sot/source/base/formats.cxx      |   19 +++++++++++++++++++
 vcl/osx/DataFlavorMapping.cxx    |    1 +
 vcl/source/treelist/transfer.cxx |   14 ++++++++++++++
 5 files changed, 38 insertions(+), 2 deletions(-)

New commits:
commit e20c57976583cb2721dd91949d8ff0e8db446351
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Fri Apr 26 20:17:00 2019 +0900
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Tue Apr 30 15:19:46 2019 +0200

    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.
    
    Reviewed-on: https://gerrit.libreoffice.org/71364
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    (cherry picked from commit 615202cab983f1f13407f6515aeb047e4e09f6ed)
    
    Change-Id: Ib982b55391b390ae06974b4ad836e376dd722a4c
    Reviewed-on: https://gerrit.libreoffice.org/71575
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/include/sot/formats.hxx b/include/sot/formats.hxx
index 968af5232c79..202c03bbe280 100644
--- a/include/sot/formats.hxx
+++ b/include/sot/formats.hxx
@@ -174,8 +174,9 @@ enum class SotClipboardFormatId : sal_uInt32
     JPEG                   = 144,
     RICHTEXT               = 145,
     STRING_TSVC            = 146,
+    PDF                    = 147,
     // the point at which we start allocating "runtime" format IDs
-    USER_END  = STRING_TSVC
+    USER_END  = PDF
 };
 
 /** Make it easier to iterate over format IDs */
diff --git a/sot/source/base/exchange.cxx b/sot/source/base/exchange.cxx
index cb9c502b0561..99f941e3321d 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<const Sequence< sal_Int8 >>::get() },
             /*144 SotClipboardFormatId::JPEG*/ { "image/jpeg", "JPEG Bitmap", 
&cppu::UnoType<Sequence<sal_Int8>>::get() },
             /*145 SotClipboardFormatId::RICHTEXT*/ { "text/richtext", 
"Richtext Format", &cppu::UnoType<Sequence<sal_Int8>>::get() },
-            /*146 SotClipboardFormatId::STRING_TSVC*/            { 
"application/x-libreoffice-tsvc", "Text TSV-Calc", 
&cppu::UnoType<OUString>::get() }
+            /*146 SotClipboardFormatId::STRING_TSVC*/            { 
"application/x-libreoffice-tsvc", "Text TSV-Calc", 
&cppu::UnoType<OUString>::get() },
+            /*147 SotClipboardFormatId::PDF*/            { "application/pdf", 
"PDF Document", &cppu::UnoType<Sequence<sal_Int8>>::get() },
             };
         return &aInstance[0];
         }
diff --git a/sot/source/base/formats.cxx b/sot/source/base/formats.cxx
index 9b7770f146ef..b3199f39142e 100644
--- a/sot/source/base/formats.cxx
+++ b/sot/source/base/formats.cxx
@@ -18,6 +18,7 @@
  */
 
 #include <tools/solar.h>
+#include <config_features.h>
 
 #include <sot/exchange.hxx>
 #include <sot/formats.hxx>
@@ -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::KeepPosSize | 
SotExchangeActionFlags::InsertTargetUrl, 0 },
     { SotClipboardFormatId::SVXB, EXCHG_OUT_ACTION_REPLACE_SVXB, 
SotExchangeActionFlags::InsertImageMap | SotExchangeActionFlags::KeepPosSize | 
SotExchangeActionFlags::InsertTargetUrl, 0 },
     { SotClipboardFormatId::GDIMETAFILE, EXCHG_OUT_ACTION_REPLACE_GDIMETAFILE, 
SotExchangeActionFlags::InsertImageMap | SotExchangeActionFlags::KeepPosSize | 
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::KeepPosSize | 
SotExchangeActionFlags::InsertTargetUrl, 0 },
     { SotClipboardFormatId::JPEG, EXCHG_OUT_ACTION_REPLACE_BITMAP, 
SotExchangeActionFlags::InsertImageMap | SotExchangeActionFlags::KeepPosSize | 
SotExchangeActionFlags::InsertTargetUrl, 0 },
     { SotClipboardFormatId::BITMAP, EXCHG_OUT_ACTION_REPLACE_BITMAP, 
SotExchangeActionFlags::InsertImageMap | SotExchangeActionFlags::KeepPosSize | 
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 },
@@ -884,6 +900,9 @@ SotAction_Impl const aEXCHG_DEST_SWDOC_FREE_AREA_Copy[] =
 #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 },
     { SotClipboardFormatId::BITMAP, EXCHG_OUT_ACTION_INSERT_BITMAP, 
SotExchangeActionFlags::InsertImageMap | 
SotExchangeActionFlags::InsertTargetUrl, 0 },
diff --git a/vcl/osx/DataFlavorMapping.cxx b/vcl/osx/DataFlavorMapping.cxx
index de8dc8c41338..6ccc2b81b63a 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 28fe43fda5f3..5dfb5c60f36e 100644
--- a/vcl/source/treelist/transfer.cxx
+++ b/vcl/source/treelist/transfer.cxx
@@ -1686,6 +1686,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;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to