sdext/qa/unit/pdfimport.cxx | 6 ++++++ sdext/source/pdfimport/inc/contentsink.hxx | 2 ++ sdext/source/pdfimport/inc/pdfiprocessor.hxx | 2 ++ sdext/source/pdfimport/tree/pdfiprocessor.cxx | 14 ++++++++++++++ sdext/source/pdfimport/wrapper/keyword_list | 1 + sdext/source/pdfimport/wrapper/wrapper.cxx | 3 +++ 6 files changed, 28 insertions(+)
New commits: commit a61eff73a16d891828e8723ad02fffe94b2d2216 Author: Dr. David Alan Gilbert <[email protected]> AuthorDate: Wed Aug 14 02:12:17 2024 +0100 Commit: David Gilbert <[email protected]> CommitDate: Thu Oct 17 20:49:00 2024 +0200 tdf#148526 sdext,pdfimport: Parse clipToStrokePath Parse the soon to be created clipToStrokePath command and route it through the tree code. Change-Id: I8fa17457ffd062e91983b6ed80bd64259aa7114e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172923 Tested-by: Jenkins Reviewed-by: David Gilbert <[email protected]> diff --git a/sdext/qa/unit/pdfimport.cxx b/sdext/qa/unit/pdfimport.cxx index ddae491db9e4..ee3b8b494db2 100644 --- a/sdext/qa/unit/pdfimport.cxx +++ b/sdext/qa/unit/pdfimport.cxx @@ -340,6 +340,12 @@ namespace getCurrentContext().Clip = aNewClip; } + virtual void intersectClipToStroke(const uno::Reference<rendering::XPolyPolygon2D>& /* rPath */) override + { + // Not copying the contents of this, unlike the other clip functions above + // it's too complex to copy in, and I don't think the clip is actually used in the test + } + virtual void drawGlyphs( const OUString& rGlyphs, const geometry::RealRectangle2D& /*rRect*/, const geometry::Matrix2D& /*rFontMatrix*/, diff --git a/sdext/source/pdfimport/inc/contentsink.hxx b/sdext/source/pdfimport/inc/contentsink.hxx index 5354e4370f14..d251aef623bc 100644 --- a/sdext/source/pdfimport/inc/contentsink.hxx +++ b/sdext/source/pdfimport/inc/contentsink.hxx @@ -136,6 +136,8 @@ namespace pdfi virtual void intersectClip(const css::uno::Reference< css::rendering::XPolyPolygon2D >& rPath) = 0; + virtual void intersectClipToStroke(const css::uno::Reference< + css::rendering::XPolyPolygon2D >& rPath) = 0; virtual void intersectEoClip(const css::uno::Reference< css::rendering::XPolyPolygon2D >& rPath) = 0; diff --git a/sdext/source/pdfimport/inc/pdfiprocessor.hxx b/sdext/source/pdfimport/inc/pdfiprocessor.hxx index 11b7761d1738..6db7d9d6eb46 100644 --- a/sdext/source/pdfimport/inc/pdfiprocessor.hxx +++ b/sdext/source/pdfimport/inc/pdfiprocessor.hxx @@ -118,6 +118,8 @@ namespace pdfi virtual void intersectClip(const css::uno::Reference< css::rendering::XPolyPolygon2D >& rPath) override; + virtual void intersectClipToStroke(const css::uno::Reference< + css::rendering::XPolyPolygon2D >& rPath) override; virtual void intersectEoClip(const css::uno::Reference< css::rendering::XPolyPolygon2D >& rPath) override; diff --git a/sdext/source/pdfimport/tree/pdfiprocessor.cxx b/sdext/source/pdfimport/tree/pdfiprocessor.cxx index 0b5c5ada984b..d798a49ae032 100644 --- a/sdext/source/pdfimport/tree/pdfiprocessor.cxx +++ b/sdext/source/pdfimport/tree/pdfiprocessor.cxx @@ -528,6 +528,20 @@ void PDFIProcessor::intersectEoClip(const uno::Reference< rendering::XPolyPolygo getCurrentContext().Clip = std::move(aNewClip); } +void PDFIProcessor::intersectClipToStroke(const uno::Reference< rendering::XPolyPolygon2D >& rPath) +{ + // TODO! Expand the path to the outline of the stroked path + // TODO(F3): interpret fill mode + basegfx::B2DPolyPolygon aNewClip = basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(rPath); + aNewClip.transform(getCurrentContext().Transformation); + basegfx::B2DPolyPolygon aCurClip = getCurrentContext().Clip; + + if( aCurClip.count() ) // #i92985# adapted API from (..., false, false) to (..., true, false) + aNewClip = basegfx::utils::clipPolyPolygonOnPolyPolygon( aCurClip, aNewClip, true, false ); + + getCurrentContext().Clip = aNewClip; +} + void PDFIProcessor::hyperLink( const geometry::RealRectangle2D& rBounds, const OUString& rURI ) { diff --git a/sdext/source/pdfimport/wrapper/keyword_list b/sdext/source/pdfimport/wrapper/keyword_list index 4d1e6d2d4013..470a414f68fb 100644 --- a/sdext/source/pdfimport/wrapper/keyword_list +++ b/sdext/source/pdfimport/wrapper/keyword_list @@ -6,6 +6,7 @@ struct hash_entry { const char* name; enum parseKey eKey; }; %% clipPath,CLIPPATH +clipToStrokePath,CLIPTOSTROKEPATH drawChar,DRAWCHAR drawImage,DRAWIMAGE drawLink,DRAWLINK diff --git a/sdext/source/pdfimport/wrapper/wrapper.cxx b/sdext/source/pdfimport/wrapper/wrapper.cxx index 6ecf0c14d7a9..5f5fe296e947 100644 --- a/sdext/source/pdfimport/wrapper/wrapper.cxx +++ b/sdext/source/pdfimport/wrapper/wrapper.cxx @@ -76,6 +76,7 @@ namespace // converter enum parseKey { CLIPPATH, + CLIPTOSTROKEPATH, DRAWCHAR, DRAWIMAGE, DRAWLINK, @@ -863,6 +864,8 @@ void Parser::parseLine( std::string_view aLine ) { case CLIPPATH: m_pSink->intersectClip(lp.readPath()); break; + case CLIPTOSTROKEPATH: + m_pSink->intersectClipToStroke(lp.readPath()); break; case DRAWCHAR: lp.readChar(); break; case DRAWIMAGE:
