[Libreoffice-commits] core.git: vcl/inc vcl/source

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Mon Feb 1 06:49:53 UTC 2021


 vcl/inc/graphic/VectorGraphicLoader.hxx    |    4 +--
 vcl/source/gdi/impgraph.cxx                |   32 +++++++++++++++++++++++++++--
 vcl/source/graphic/VectorGraphicLoader.cxx |    6 ++---
 3 files changed, 35 insertions(+), 7 deletions(-)

New commits:
commit c81f3aec1ae17c6a1c6a5702cf5e42fbbad4e4b1
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Mon Jan 25 23:07:39 2021 +0900
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Mon Feb 1 07:49:08 2021 +0100

    vcl: swap-in load all vector formats without intermediate Graphic
    
    Previously only PDF were loaded without the intermediate Graphic
    objects. With this change all vector graphic formats are loaded
    directly to a new VectorGraphicData instance, without the need
    to create a intermediate Graphic object.
    
    Change-Id: Idfa7c0ae433c4bf9500110dff82b6d1ec3f3caa4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109931
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/vcl/inc/graphic/VectorGraphicLoader.hxx b/vcl/inc/graphic/VectorGraphicLoader.hxx
index b6f38120885c..943f7b8dc6d5 100644
--- a/vcl/inc/graphic/VectorGraphicLoader.hxx
+++ b/vcl/inc/graphic/VectorGraphicLoader.hxx
@@ -17,8 +17,8 @@
 
 namespace vcl
 {
-std::shared_ptr<VectorGraphicData>
-loadPdfFromDataContainer(BinaryDataContainer const& rDataContainer);
+std::shared_ptr<VectorGraphicData> loadVectorGraphic(BinaryDataContainer const& rDataContainer,
+                                                     VectorGraphicDataType eType);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 9e57ff26ce98..6d10f7268e38 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -1424,6 +1424,33 @@ void ImpGraphic::restoreFromSwapInfo()
     }
 }
 
+namespace
+{
+
+std::optional<VectorGraphicDataType> lclConvertToVectorGraphicType(GfxLink const & rLink)
+{
+    switch(rLink.GetType())
+    {
+        case GfxLinkType::NativePdf:
+            return VectorGraphicDataType::Pdf;
+
+        case GfxLinkType::NativeWmf:
+            if (rLink.IsEMF())
+                return VectorGraphicDataType::Emf;
+            else
+                return VectorGraphicDataType::Wmf;
+
+        case GfxLinkType::NativeSvg:
+            return VectorGraphicDataType::Svg;
+
+        default:
+            break;
+    }
+    return std::optional<VectorGraphicDataType>();
+}
+
+} // end namespace
+
 bool ImpGraphic::swapIn()
 {
     if (!isSwappedOut())
@@ -1444,9 +1471,10 @@ bool ImpGraphic::swapIn()
     }
     else if (mpGfxLink && mpGfxLink->IsNative())
     {
-        if (mpGfxLink->GetType() == GfxLinkType::NativePdf)
+        std::optional<VectorGraphicDataType> oType = lclConvertToVectorGraphicType(*mpGfxLink);
+        if (oType)
         {
-            maVectorGraphicData = vcl::loadPdfFromDataContainer(mpGfxLink->getDataContainer());
+            maVectorGraphicData = vcl::loadVectorGraphic(mpGfxLink->getDataContainer(), *oType);
 
             // Set to 0, to force recalculation
             mnSizeBytes = 0;
diff --git a/vcl/source/graphic/VectorGraphicLoader.cxx b/vcl/source/graphic/VectorGraphicLoader.cxx
index 988c3db803be..997681092305 100644
--- a/vcl/source/graphic/VectorGraphicLoader.cxx
+++ b/vcl/source/graphic/VectorGraphicLoader.cxx
@@ -13,13 +13,13 @@
 
 namespace vcl
 {
-std::shared_ptr<VectorGraphicData>
-loadPdfFromDataContainer(BinaryDataContainer const& rDataContainer)
+std::shared_ptr<VectorGraphicData> loadVectorGraphic(BinaryDataContainer const& rDataContainer,
+                                                     VectorGraphicDataType eType)
 {
     if (rDataContainer.isEmpty())
         return std::shared_ptr<VectorGraphicData>();
 
-    return std::make_shared<VectorGraphicData>(rDataContainer, VectorGraphicDataType::Pdf);
+    return std::make_shared<VectorGraphicData>(rDataContainer, eType);
 }
 }
 


More information about the Libreoffice-commits mailing list