sdext/source/pdfimport/tree/drawtreevisiting.cxx   |   21 ++++++++++++++++++++-
 sdext/source/pdfimport/tree/writertreevisiting.cxx |   21 ++++++++++++++++++++-
 2 files changed, 40 insertions(+), 2 deletions(-)

New commits:
commit 4b295b1b77b33c9a5b5fcfab58132ca0dcb7f90b
Author:     Dr. David Alan Gilbert <d...@treblig.org>
AuthorDate: Mon Feb 12 01:24:07 2024 +0000
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Feb 29 08:27:48 2024 +0100

    tdf#113050 sdext.pdfimport: Create the fill-image style and use it
    
    In a poly which is being image filled, we need to create a style
    with the actual image definition in the 'Contents'
    and then set the (automatically created) name of this in
    the prop on the main style.
    Also we need to set draw:fill to "bitmap" rather than "solid"
    
    Change-Id: I253704519011e98fd106331ccfb139ad93ef6dee
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163572
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sdext/source/pdfimport/tree/drawtreevisiting.cxx 
b/sdext/source/pdfimport/tree/drawtreevisiting.cxx
index 5aae54415800..2c02adde8874 100644
--- a/sdext/source/pdfimport/tree/drawtreevisiting.cxx
+++ b/sdext/source/pdfimport/tree/drawtreevisiting.cxx
@@ -817,10 +817,29 @@ void DrawXmlFinalizer::visit( PolyPolyElement& elem, 
const std::list< std::uniqu
         aGCProps[ "draw:stroke" ] = "none";
     }
 
+    if (elem.FillImage != -1)
+    {
+        PropertyMap props;
+        // The image isn't actually in a prop, it's in an extra chunk inside.
+        StyleContainer::Style style("draw:fill-image"_ostr, std::move(props));
+        style.Contents = 
m_rProcessor.getImages().asBase64EncodedString(elem.FillImage);
+        aGCProps[ "draw:fill-image-name" ] =
+            m_rStyleContainer.getStyleName(
+            m_rStyleContainer.getStyleId(style));
+
+    }
+
     // TODO(F1): check whether stuff could be emulated by gradient/bitmap/hatch
     if( elem.Action & (PATH_FILL | PATH_EOFILL) )
     {
-        aGCProps[ "draw:fill" ]   = "solid";
+        if (elem.FillImage == -1)
+        {
+            aGCProps[ "draw:fill" ]   = "solid";
+        }
+        else
+        {
+            aGCProps[ "draw:fill" ]   = "bitmap";
+        }
         aGCProps[ "draw:fill-color" ] = getColorString(rGC.FillColor);
         if (rGC.FillColor.Alpha != 1.0)
             aGCProps["draw:opacity"] = getPercentString(rGC.FillColor.Alpha * 
100.0);
diff --git a/sdext/source/pdfimport/tree/writertreevisiting.cxx 
b/sdext/source/pdfimport/tree/writertreevisiting.cxx
index 9ecce8f48be4..746fc9e77eb2 100644
--- a/sdext/source/pdfimport/tree/writertreevisiting.cxx
+++ b/sdext/source/pdfimport/tree/writertreevisiting.cxx
@@ -995,10 +995,29 @@ void WriterXmlFinalizer::visit( PolyPolyElement& elem, 
const std::list< std::uni
         aGCProps[ "draw:stroke" ] = "none";
     }
 
+    if (elem.FillImage != -1)
+    {
+        PropertyMap props;
+        // The image isn't actually in a prop, it's in an extra chunk inside.
+        StyleContainer::Style style("draw:fill-image"_ostr, std::move(props));
+        style.Contents = 
m_rProcessor.getImages().asBase64EncodedString(elem.FillImage);
+        aGCProps[ "draw:fill-image-name" ] =
+            m_rStyleContainer.getStyleName(
+            m_rStyleContainer.getStyleId(style));
+
+    }
+
     // TODO(F1): check whether stuff could be emulated by gradient/bitmap/hatch
     if( elem.Action & (PATH_FILL | PATH_EOFILL) )
     {
-        aGCProps[ "draw:fill" ]   = "solid";
+        if (elem.FillImage == -1)
+        {
+            aGCProps[ "draw:fill" ]   = "solid";
+        }
+        else
+        {
+            aGCProps[ "draw:fill" ]   = "bitmap";
+        }
         aGCProps[ "draw:fill-color" ] = getColorString( rGC.FillColor );
     }
     else

Reply via email to