From 2350357d5cc2ac1787816ce887af6e9f36b8d252 Mon Sep 17 00:00:00 2001 From: "Dr. David Alan Gilbert" Date: Fri, 9 Feb 2024 02:42:30 +0000 Subject: tdf#113050 sdext.pdfimport: Create poly for tiling pattern Create a poly for the tiling pattern fill. Change-Id: Iaeadfe51bed6d4de87f36b3a78145829ea8443e6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163566 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sdext/source/pdfimport/tree/pdfiprocessor.cxx | 52 ++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 4 deletions(-) (limited to 'sdext') diff --git a/sdext/source/pdfimport/tree/pdfiprocessor.cxx b/sdext/source/pdfimport/tree/pdfiprocessor.cxx index cf65223f167a..32280f8fd110 100644 --- a/sdext/source/pdfimport/tree/pdfiprocessor.cxx +++ b/sdext/source/pdfimport/tree/pdfiprocessor.cxx @@ -28,6 +28,8 @@ #include +#include + #include #include #include @@ -383,13 +385,55 @@ void PDFIProcessor::drawAlphaMaskedImage(const uno::Sequence& /*xTile*/) { - // TODO + const GraphicsContext& rGC(getCurrentContext()); + + basegfx::B2DTuple aScale, aTranslation; + double fRotate, fShearX; + auto rTfm = rGC.Transformation; + rTfm.decompose(aScale, aTranslation, fRotate, fShearX); + + // Build a poly covering the whole fill area + double np0x = nX0 * nxStep; + double np0y = nY0 * nyStep; + double np1x = nX1 * nxStep; + double np1y = nY1 * nyStep; + + // Transform with the rMat passed in + double tmpx, tmpy; + tmpx = np0x * rMat.m00 + np0y * rMat.m01 + rMat.m02; + tmpy = np0x * rMat.m10 + np0y * rMat.m11 + rMat.m12; + np0x = tmpx; + np0y = tmpy; + tmpx = np1x * rMat.m00 + np1y * rMat.m01 + rMat.m02; + tmpy = np1x * rMat.m10 + np1y * rMat.m11 + rMat.m12; + np1x = tmpx; + np1y = tmpy; + + auto aB2DPoly = basegfx::B2DPolyPolygon(basegfx::utils::createPolygonFromRect(basegfx::B2DRange(np0x, np0y, np1x, np1y))); + aB2DPoly.transform(getCurrentContext().Transformation); + + // Clip against current clip path, if any + basegfx::B2DPolyPolygon aCurClip = getCurrentContext().Clip; + if( aCurClip.count() ) { + aB2DPoly = basegfx::utils::clipPolyPolygonOnPolyPolygon( aB2DPoly, aCurClip, + true, /* bInside, keep parts inside the clip */ + false /* bStroke, filled not stroked */ ); + } + // TODO: That clipping might shift the fill pattern offsets + + auto pPolyElement = ElementFactory::createPolyPolyElement( + m_pCurElement, + getGCId(getCurrentContext()), + aB2DPoly, + PATH_EOFILL ); // Hmm how do I know if this should be EO or not? + pPolyElement->updateGeometry(); + pPolyElement->ZOrder = m_nNextZOrder++; } void PDFIProcessor::strokePath( const uno::Reference< rendering::XPolyPolygon2D >& rPath ) -- cgit