vcl/inc/pdf/pdfwriter_impl.hxx | 3 ++- vcl/qa/cppunit/pdfexport/pdfexport.cxx | 11 +++-------- vcl/source/gdi/pdfwriter_impl.cxx | 14 +++++++++----- 3 files changed, 14 insertions(+), 14 deletions(-)
New commits: commit a0bc0cc81b597aa81189355a8125753d6b873cce Author: Caolán McNamara <[email protected]> AuthorDate: Mon Oct 3 09:01:56 2022 +0100 Commit: Caolán McNamara <[email protected]> CommitDate: Mon Oct 3 10:54:03 2022 +0200 tdf#150786 use the same colors for pdf widgets regardless of theme use StyleSettings::SetStandardStyles() Change-Id: Idf08872fabfe50cbc73091e17dd3ad7a4acc6715 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140900 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> diff --git a/vcl/inc/pdf/pdfwriter_impl.hxx b/vcl/inc/pdf/pdfwriter_impl.hxx index 500fd6e89d64..9f099f58b6a4 100644 --- a/vcl/inc/pdf/pdfwriter_impl.hxx +++ b/vcl/inc/pdf/pdfwriter_impl.hxx @@ -55,11 +55,11 @@ #include <vcl/BinaryDataContainer.hxx> #include <vcl/filter/pdfobjectcontainer.hxx> +#include <vcl/settings.hxx> #include <pdf/ExternalPDFStreams.hxx> #include <pdf/pdfbuildin_fonts.hxx> #include <salgdi.hxx> -class StyleSettings; class FontSubsetInfo; class ZCodec; class EncHashTransporter; @@ -692,6 +692,7 @@ private: void DrawHatchLine_DrawLine(const Point& rStartPoint, const Point& rEndPoint) override; MapMode m_aMapMode; // PDFWriterImpl scaled units + StyleSettings m_aWidgetStyleSettings; std::vector< PDFPage > m_aPages; /* maps object numbers to file offsets (needed for xref) */ std::vector< sal_uInt64 > m_aObjects; diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index faf87842d8cf..88139dd0ecd4 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -2732,17 +2732,12 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testFormFontName) CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFObjectType::String, pAnnot->getValueType("DA")); OUString aDA = pAnnot->getString("DA"); - // Workaround tdf#150786: skip color. It may be either "0 0 0 rg /TiRo 12 Tf" on light mode, - // or "1 1 1 rg /TiRo 12 Tf" on dark mode. - sal_Int32 rgPos = aDA.indexOf(u"rg"); - CPPUNIT_ASSERT(rgPos >= 0); - // Without the accompanying fix in place, this test would have failed with: - // - Expected: rg /TiRo 12 Tf - // - Actual : rg /F2 12 Tf + // - Expected: 0 0 0 rg /TiRo 12 Tf + // - Actual : 0 0 0 rg /F2 12 Tf // i.e. Liberation Serif was exposed as a form font as-is, without picking the closest built-in // font. - CPPUNIT_ASSERT_EQUAL(OUString("rg /TiRo 12 Tf"), aDA.copy(rgPos)); + CPPUNIT_ASSERT_EQUAL(OUString("0 0 0 rg /TiRo 12 Tf"), aDA); } // Check we don't have duplicated objects when we reexport the PDF multiple diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 5731352459ea..2082056940f9 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -1193,6 +1193,7 @@ PDFWriterImpl::PDFWriterImpl( const PDFWriter::PDFWriterContext& rContext, PDFWriter& i_rOuterFace) : VirtualDevice(Application::GetDefaultDevice(), DeviceFormat::DEFAULT, DeviceFormat::NONE, OUTDEV_PDF), m_aMapMode( MapUnit::MapPoint, Point(), Fraction( 1, pointToPixel(1) ), Fraction( 1, pointToPixel(1) ) ), + m_aWidgetStyleSettings(Application::GetSettings().GetStyleSettings()), m_nCurrentStructElement( 0 ), m_bEmitStructure( true ), m_nNextFID( 1 ), @@ -1228,6 +1229,9 @@ PDFWriterImpl::PDFWriterImpl( const PDFWriter::PDFWriterContext& rContext, aFont.SetFamilyName( "Times" ); aFont.SetFontSize( Size( 0, 12 ) ); + // tdf#150786 use the same settings for widgets regardless of theme + m_aWidgetStyleSettings.SetStandardStyles(); + GraphicsState aState; aState.m_aMapMode = m_aMapMode; aState.m_aFont = aFont; @@ -3902,7 +3906,7 @@ static const Color& replaceColor( const Color& rCol1, const Color& rCol2 ) void PDFWriterImpl::createDefaultPushButtonAppearance( PDFWidget& rButton, const PDFWriter::PushButtonWidget& rWidget ) { - const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); + const StyleSettings& rSettings = m_aWidgetStyleSettings; // save graphics state push( PushFlags::ALL ); @@ -4009,7 +4013,7 @@ Font PDFWriterImpl::drawFieldBorder( PDFWidget& rIntern, void PDFWriterImpl::createDefaultEditAppearance( PDFWidget& rEdit, const PDFWriter::EditWidget& rWidget ) { - const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); + const StyleSettings& rSettings = m_aWidgetStyleSettings; SvMemoryStream* pEditStream = new SvMemoryStream( 1024, 1024 ); push( PushFlags::ALL ); @@ -4055,7 +4059,7 @@ void PDFWriterImpl::createDefaultEditAppearance( PDFWidget& rEdit, const PDFWrit void PDFWriterImpl::createDefaultListBoxAppearance( PDFWidget& rBox, const PDFWriter::ListBoxWidget& rWidget ) { - const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); + const StyleSettings& rSettings = m_aWidgetStyleSettings; SvMemoryStream* pListBoxStream = new SvMemoryStream( 1024, 1024 ); push( PushFlags::ALL ); @@ -4100,7 +4104,7 @@ void PDFWriterImpl::createDefaultListBoxAppearance( PDFWidget& rBox, const PDFWr void PDFWriterImpl::createDefaultCheckBoxAppearance( PDFWidget& rBox, const PDFWriter::CheckBoxWidget& rWidget ) { - const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); + const StyleSettings& rSettings = m_aWidgetStyleSettings; // save graphics state push( PushFlags::ALL ); @@ -4230,7 +4234,7 @@ void PDFWriterImpl::createDefaultCheckBoxAppearance( PDFWidget& rBox, const PDFW void PDFWriterImpl::createDefaultRadioButtonAppearance( PDFWidget& rBox, const PDFWriter::RadioButtonWidget& rWidget ) { - const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); + const StyleSettings& rSettings = m_aWidgetStyleSettings; // save graphics state push( PushFlags::ALL );
