sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx | 14 ++++++++++++++ sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx | 10 ++++++++++ 2 files changed, 24 insertions(+)
New commits: commit a102aeb72cb50c8b27dfd85a086e9c4264c305c8 Author: Dr. David Alan Gilbert <d...@treblig.org> AuthorDate: Mon Jul 7 01:41:13 2025 +0100 Commit: David Gilbert <d...@treblig.org> CommitDate: Fri Jul 25 02:11:12 2025 +0200 sdext,pdfimport: Fix opacity during axial fills There's a corner case where some fills use the stroke opacity rather than the fill opacity; Poppler has a test case for this for the axial case, and a comment saying they've compared it with acroread but can't find any spec wording for it. It's the top left box of: https://gitlab.freedesktop.org/poppler/poppler/-/issues/178 We can enable it for other fills if we find examples. Change-Id: Ib5d34494f2e5ed2cb964d407599f06530f34283e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187455 Tested-by: Jenkins Reviewed-by: David Gilbert <freedesk...@treblig.org> diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx index a6205d0c6296..0fb6bdb82df0 100644 --- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx +++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx @@ -1247,6 +1247,20 @@ void PDFOutDev::setSkipImages( bool bSkipImages ) m_bSkipImages = bSkipImages; } +// This is a fudge to fixup the opacity during shaded fills, +// there are situations where the stroke opacity is used rather than the +// fill opacity is ued, so flip it here. +// Note that Poppler does a state save around the fill, so it restores this hack +// See https://gitlab.freedesktop.org/poppler/poppler/-/issues/178#note_472334 +poppler_bool PDFOutDev::axialShadedFill(GfxState *state, GfxAxialShading *, double, double) +{ + if (state->getStrokePattern()!=nullptr) + { + state->setFillOpacity(state->getStrokeOpacity()); + } + return false; +} + #if POPPLER_CHECK_VERSION(21, 3, 0) poppler_bool PDFOutDev::tilingPatternFill(GfxState *state, Gfx *, Catalog *, GfxTilingPattern *tPat, const double *mat, diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx index eb0e3e29f5f5..051b6ab51206 100644 --- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx +++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx @@ -284,6 +284,16 @@ namespace pdfi static void setPageNum( int nNumPages ); void setSkipImages ( bool bSkipImages ); + + // This is a fudge to allow us to do a fixup in axialShadedFill for + // opacity, which may need extending to other types, see axialShadedFill + // definition for details + poppler_bool useShadedFills(int type) override + { + return type == 2; // Axial + }; + poppler_bool axialShadedFill(GfxState *state, GfxAxialShading *, double, double) override; + #if POPPLER_CHECK_VERSION(21, 3, 0) poppler_bool useTilingPatternFill() override { return true; }; poppler_bool tilingPatternFill(GfxState *state, Gfx *gfx, Catalog *cat,