sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx |   64 +++++++++++++++++-
 sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx |    7 +
 2 files changed, 70 insertions(+), 1 deletion(-)

New commits:
commit 8e4a351f12d777ad9102086298741d0a97e5eeb9
Author:     Dr. David Alan Gilbert <d...@treblig.org>
AuthorDate: Mon Jan 15 02:09:39 2024 +0000
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Feb 29 08:21:09 2024 +0100

    tdf#113050 sdext.pdfimport: Write the tiling pattern header
    
    Add the 'tilingPatternFill' hook to our output device, but don't enable
    it yet; we can do that at the end of the series.
    
    Change-Id: Id52b023c3025f5addce1ab09663da9b8bd8a75e4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163561
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx 
b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
index 2517618e1019..e7afe67afef4 100644
--- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
+++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
@@ -20,6 +20,25 @@
 #include "pdfioutdev_gpl.hxx"
 #include "pnghelper.hxx"
 
+#if defined __GNUC__ || defined __clang__
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wunused-parameter"
+#elif defined _MSC_VER
+#pragma warning(push)
+#pragma warning(disable : 4100) // unreferenced formal parameter
+#pragma warning(disable : 4121) // alignment of a member was sensitive to 
packing in Gfx.h/Operator
+#endif
+
+#include <Gfx.h>
+#include <splash/SplashBitmap.h>
+#include <SplashOutputDev.h>
+#if defined __GNUC__ || defined __clang__
+# pragma GCC diagnostic pop
+#elif defined _MSC_VER
+#pragma warning(pop)
+#endif
+
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <assert.h>
@@ -426,7 +445,6 @@ static void writeMaskLF( OutputBuffer&     o_rOutputBuf,
                          int               height,
                          bool              bInvert ) { 
writeMask_(o_rOutputBuf,str,width,height,bInvert); }
 
-
 int PDFOutDev::parseFont( long long nNewId, GfxFont* gfxFont, const GfxState* 
state ) const
 {
     FontAttributes aNewFont;
@@ -1163,6 +1181,50 @@ void PDFOutDev::setSkipImages( bool bSkipImages )
     m_bSkipImages = bSkipImages;
 }
 
+#if POPPLER_CHECK_VERSION(21, 3, 0)
+poppler_bool PDFOutDev::tilingPatternFill(GfxState *, Gfx *, Catalog *,
+                                          GfxTilingPattern *tPat, const double 
*mat,
+                                          int x0, int y0, int x1, int y1,
+                                          double xStep, double yStep)
+{
+    const double *pBbox = tPat->getBBox();
+    const int nPaintType = tPat->getPaintType();
+    double nWidth = pBbox[2] - pBbox[0];
+    double nHeight = pBbox[3] - pBbox[1];
+
+    // If our wrapper is skipping images then we don't need to do anything
+    // but return 'true' so that Poppler doesn't do the slow method
+    if (m_bSkipImages)
+        return true;
+
+    // Copied from the Cairo output dev; I think this is patterns
+    // with gaps, let poppler do the slow method for now.
+    if (xStep != nWidth || yStep != nHeight)
+        return false;
+
+    printf( "tilingPatternFill %d %d %d %d %f %f "
+            "%d "
+            "%f %f %f %f %f %f", // No ending space!
+
+            x0, y0, x1, y1, normalize(xStep), normalize(yStep),
+
+            nPaintType,
+
+            normalize(mat[0]), normalize(mat[1]),
+            normalize(mat[2]), normalize(mat[3]),
+            normalize(mat[4]), normalize(mat[5])
+            );
+
+    // TODO: Write the image
+
+    // If we return false here we can fall back to the slow path
+    return true;
+}
+
+// This could be implemented for earlier versions, but the interface keeps
+// changing a little; not having it is only a problem for inputs with
+// large patterns.
+#endif
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx 
b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx
index b34fad1ba90a..f38bf423423b 100644
--- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx
+++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx
@@ -283,6 +283,13 @@ namespace pdfi
 
         static void setPageNum( int nNumPages );
         void setSkipImages ( bool bSkipImages );
+#if POPPLER_CHECK_VERSION(21, 3, 0)
+        poppler_bool useTilingPatternFill() override { return false; };
+        poppler_bool tilingPatternFill(GfxState *state, Gfx *gfx, Catalog *cat,
+                                       GfxTilingPattern *tPat, const double 
*mat,
+                                       int x0, int y0, int x1, int y1,
+                                       double xStep, double yStep) override;
+#endif
     };
 }
 

Reply via email to