[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - 2 commits - include/sot sot/source svtools/source vcl/osx

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Tue Apr 30 13:05:57 UTC 2019


 include/sot/formats.hxx          |    3 ++-
 sot/source/base/exchange.cxx     |    3 ++-
 sot/source/base/formats.cxx      |   19 +++++++++++++++++++
 svtools/source/misc/transfer.cxx |   14 ++++++++++++++
 vcl/osx/DataFlavorMapping.cxx    |    1 +
 vcl/osx/salframe.cxx             |    2 ++
 vcl/osx/salnativewidgets.cxx     |   17 +++++++++++++++++
 7 files changed, 57 insertions(+), 2 deletions(-)

New commits:
commit 8ed628cf8b7c6f1bc6dae9eb94c9b702aa93c21b
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Fri Apr 26 20:17:00 2019 +0900
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Tue Apr 30 21:29:24 2019 +0900

    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 <quikee at gmail.com>
    (cherry picked from commit 615202cab983f1f13407f6515aeb047e4e09f6ed)
    
    Change-Id: Ib982b55391b390ae06974b4ad836e376dd722a4c

diff --git a/include/sot/formats.hxx b/include/sot/formats.hxx
index 4e36686203a8..a096b904149d 100644
--- a/include/sot/formats.hxx
+++ b/include/sot/formats.hxx
@@ -174,8 +174,9 @@ enum class SotClipboardFormatId : sal_uLong
     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 8dbc5bfd4686..124fd6cf780a 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 522063972782..645152083a86 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>
@@ -347,6 +348,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 },
@@ -367,6 +371,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 },
@@ -382,6 +389,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 },
@@ -839,6 +849,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 },
@@ -869,6 +882,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 },
@@ -893,6 +909,9 @@ SotAction_Impl const aEXCHG_DEST_SWDOC_FREE_AREA_Copy[] =
     { SotClipboardFormatId::SD_OLE, EXCHG_OUT_ACTION_INSERT_OLE, SotExchangeActionFlags::InsertImageMap | SotExchangeActionFlags::InsertTargetUrl, 0 },
     { SotClipboardFormatId::EMBED_SOURCE, EXCHG_OUT_ACTION_INSERT_OLE, SotExchangeActionFlags::InsertTargetUrl, 0 },
     { SotClipboardFormatId::EMBEDDED_OBJ, EXCHG_OUT_ACTION_INSERT_OLE, 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 },
diff --git a/svtools/source/misc/transfer.cxx b/svtools/source/misc/transfer.cxx
index 7db9601c8aa7..03b306daed8b 100644
--- a/svtools/source/misc/transfer.cxx
+++ b/svtools/source/misc/transfer.cxx
@@ -1727,6 +1727,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;
diff --git a/vcl/osx/DataFlavorMapping.cxx b/vcl/osx/DataFlavorMapping.cxx
index 3b93b42da8d8..8ad2ab233c06 100644
--- a/vcl/osx/DataFlavorMapping.cxx
+++ b/vcl/osx/DataFlavorMapping.cxx
@@ -114,6 +114,7 @@ namespace
       { NSRTFPboardType, "text/rtf", "Rich Text Format", false },
       { NSTIFFPboardType, "image/png", "Portable Network Graphics", false },
       { NSHTMLPboardType, "text/html", "Plain Html", false },
+      { NSPDFPboardType, "application/pdf", "PDF File", false },
       { NSFilenamesPboardType, "application/x-openoffice-filelist;windows_formatname=\"FileList\"", "FileList", false },
       { PBTYPE_SESX, FLAVOR_SESX, "Star Embed Source (XML)", false },
       { PBTYPE_SLSDX, FLAVOR_SLSDX, "Star Link Source Descriptor (XML)", false },
commit 49093f1110b9a4752c0897886ff336003575764d
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Thu Apr 25 16:19:24 2019 +0900
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Tue Apr 30 21:29:24 2019 +0900

    tdf#119965 implement tooltip widget style on macos
    
    Change-Id: I7625adbf365aa908c072ca42060e926569629044
    Reviewed-on: https://gerrit.libreoffice.org/71279
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
    (cherry picked from commit 43f8ea2195015b2b204f61798daf8b41bd7809b5)

diff --git a/vcl/osx/salframe.cxx b/vcl/osx/salframe.cxx
index ef22d101cf6a..d3e038f9c232 100644
--- a/vcl/osx/salframe.cxx
+++ b/vcl/osx/salframe.cxx
@@ -1181,6 +1181,8 @@ void AquaSalFrame::UpdateSettings( AllSettings& rSettings )
     aStyleSettings.SetTitleFont( aTitleFont );
     aStyleSettings.SetFloatTitleFont( aTitleFont );
 
+    vcl::Font aTooltipFont(getFont([NSFont toolTipsFontOfSize: 0], nDPIY, aAppFont));
+    aStyleSettings.SetHelpFont(aTooltipFont);
 
     Color aHighlightColor( getColor( [NSColor selectedTextBackgroundColor],
                                       aStyleSettings.GetHighlightColor(), mpNSWindow ) );
diff --git a/vcl/osx/salnativewidgets.cxx b/vcl/osx/salnativewidgets.cxx
index 7db66ac1ac77..bf7b23a7cd41 100644
--- a/vcl/osx/salnativewidgets.cxx
+++ b/vcl/osx/salnativewidgets.cxx
@@ -255,6 +255,8 @@ bool AquaSalGraphics::IsNativeControlSupported( ControlType nType, ControlPart n
             break;
 
         case ControlType::Tooltip: // ** TO DO
+            if (nPart == ControlPart::Entire)
+                return true;
             break;
 
         case ControlType::MenuPopup:
@@ -423,6 +425,21 @@ bool AquaSalGraphics::drawNativeControl(ControlType nType,
         }
         break;
 
+        case ControlType::Tooltip:
+        {
+            HIThemeBackgroundDrawInfo aThemeBackgroundInfo;
+            aThemeBackgroundInfo.version = 0;
+            aThemeBackgroundInfo.state = getState( nState );
+            aThemeBackgroundInfo.kind = kThemeBrushAlertBackgroundActive;
+            rc.size.width += 2;
+            rc.size.height += 2;
+
+            HIThemeApplyBackground( &rc, &aThemeBackgroundInfo, mrContext, kHIThemeOrientationNormal);
+            CGContextFillRect( mrContext, rc );
+            bOK = true;
+        }
+        break;
+
     case ControlType::Menubar:
     case ControlType::MenuPopup:
         {


More information about the Libreoffice-commits mailing list