filter/source/pdf/impdialog.cxx         |    9 +++++----
 filter/source/pdf/pdfexport.cxx         |    5 +++--
 filter/source/pdf/pdffilter.cxx         |    5 +++--
 include/vcl/graphic/GraphicMetadata.hxx |    3 +++
 vcl/source/gdi/pdfextoutdevdata.cxx     |    3 ++-
 5 files changed, 16 insertions(+), 9 deletions(-)

New commits:
commit 2a2b565880b39c8ff76edde68e2b61f24839113f
Author:     Michael Stahl <[email protected]>
AuthorDate: Tue Aug 27 14:52:30 2024 +0200
Commit:     Michael Stahl <[email protected]>
CommitDate: Tue Aug 27 17:19:44 2024 +0200

    vcl,filter: replace about 5 hard-coded JPEG PDF export qualitys
    
    ... with a constant; depending on whether FilterData is passed, the
    effective default is either 80 or 90.
    
    Change-Id: Iffaf8baf8f0ae8ea1cc96c299e4c415d91f818f8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172469
    Reviewed-by: Michael Stahl <[email protected]>
    Tested-by: Jenkins

diff --git a/filter/source/pdf/impdialog.cxx b/filter/source/pdf/impdialog.cxx
index 0ce804066362..b24414ea9e98 100644
--- a/filter/source/pdf/impdialog.cxx
+++ b/filter/source/pdf/impdialog.cxx
@@ -21,6 +21,7 @@
 #include <strings.hrc>
 #include <officecfg/Office/Common.hxx>
 #include <vcl/errinf.hxx>
+#include <vcl/graphic/GraphicMetadata.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/weld.hxx>
 #include <sfx2/passwd.hxx>
@@ -64,9 +65,9 @@ ImpPDFTabDialog::ImpPDFTabDialog(weld::Window* pParent, const 
Sequence< Property
     mbSelectionPresent( false ),
     mbUseCTLFont( false ),
     mbUseLosslessCompression( true ),
-    mnQuality( 90 ),
+    mnQuality( DefaultPDFJPEGQuality ),
     mbReduceImageResolution( false ),
-    mnMaxImageResolution( 300 ),
+    mnMaxImageResolution( DefaultPDFImageDPI ),
     mbUseTaggedPDF( false ),
     mbUseTaggedPDFUserSelection( false ),
     mbExportNotes( true ),
@@ -180,9 +181,9 @@ ImpPDFTabDialog::ImpPDFTabDialog(weld::Window* pParent, 
const Sequence< Property
     mbUseCTLFont = maConfigI18N.ReadBool( u"CTLFont"_ustr, false );
 
     mbUseLosslessCompression = maConfigItem.ReadBool( 
u"UseLosslessCompression"_ustr, false );
-    mnQuality = maConfigItem.ReadInt32( u"Quality"_ustr, 90 );
+    mnQuality = maConfigItem.ReadInt32(u"Quality"_ustr, DefaultPDFJPEGQuality);
     mbReduceImageResolution = maConfigItem.ReadBool( 
u"ReduceImageResolution"_ustr, false );
-    mnMaxImageResolution = maConfigItem.ReadInt32( u"MaxImageResolution"_ustr, 
300 );
+    mnMaxImageResolution = maConfigItem.ReadInt32(u"MaxImageResolution"_ustr, 
DefaultPDFImageDPI);
 
     // this is always the user selection, independent from the PDF/A forced 
selection
     mbUseTaggedPDF = maConfigItem.ReadBool( u"UseTaggedPDF"_ustr, false );
diff --git a/filter/source/pdf/pdfexport.cxx b/filter/source/pdf/pdfexport.cxx
index dac9e816bfe2..708891deab7d 100644
--- a/filter/source/pdf/pdfexport.cxx
+++ b/filter/source/pdf/pdfexport.cxx
@@ -27,6 +27,7 @@
 #include <vcl/canvastools.hxx>
 #include <vcl/mapmod.hxx>
 #include <vcl/gdimtf.hxx>
+#include <vcl/graphic/GraphicMetadata.hxx>
 #include <rtl/ustring.hxx>
 #include <comphelper/propertyvalue.hxx>
 #include <comphelper/sequence.hxx>
@@ -88,8 +89,8 @@ PDFExport::PDFExport( const Reference< XComponent >& rxSrcDoc,
     mbUseLosslessCompression    ( false ),
     mbReduceImageResolution     ( true ),
     mbSkipEmptyPages            ( true ),
-    mnMaxImageResolution        ( 300 ),
-    mnQuality                   ( 80 ),
+    mnMaxImageResolution        ( DefaultPDFImageDPI ),
+    mnQuality                   ( DefaultPDFJPEGQuality ),
     mnProgressValue             ( 0 ),
     mbRemoveTransparencies      ( false ),
 
diff --git a/filter/source/pdf/pdffilter.cxx b/filter/source/pdf/pdffilter.cxx
index 373c7d859787..da0c907649e8 100644
--- a/filter/source/pdf/pdffilter.cxx
+++ b/filter/source/pdf/pdffilter.cxx
@@ -27,6 +27,7 @@
 #include <unotools/tempfile.hxx>
 #include <vcl/FilterConfigItem.hxx>
 #include <vcl/glyphitemcache.hxx>
+#include <vcl/graphic/GraphicMetadata.hxx>
 #include <memory>
 
 #include <com/sun/star/io/XOutputStream.hpp>
@@ -97,9 +98,9 @@ bool PDFFilter::implExport( const Sequence< PropertyValue >& 
rDescriptor )
     {
         FilterConfigItem aCfgItem( u"Office.Common/Filter/PDF/Export/" );
         aCfgItem.ReadBool(  u"UseLosslessCompression"_ustr, false );
-        aCfgItem.ReadInt32( u"Quality"_ustr, 90 );
+        aCfgItem.ReadInt32( u"Quality"_ustr, DefaultPDFJPEGQuality );
         aCfgItem.ReadBool(  u"ReduceImageResolution"_ustr, false );
-        aCfgItem.ReadInt32( u"MaxImageResolution"_ustr, 300 );
+        aCfgItem.ReadInt32( u"MaxImageResolution"_ustr, DefaultPDFImageDPI );
         aCfgItem.ReadBool(  u"UseTaggedPDF"_ustr, false );
         aCfgItem.ReadInt32( u"SelectPdfVersion"_ustr, 0 );
         aCfgItem.ReadBool(u"PDFUACompliance"_ustr, false);
diff --git a/include/vcl/graphic/GraphicMetadata.hxx 
b/include/vcl/graphic/GraphicMetadata.hxx
index 2aa9f1cb4107..b01e38c8cfab 100644
--- a/include/vcl/graphic/GraphicMetadata.hxx
+++ b/include/vcl/graphic/GraphicMetadata.hxx
@@ -14,6 +14,9 @@
 
 #include <optional>
 
+const sal_Int32 DefaultPDFJPEGQuality = 90;
+const sal_Int32 DefaultPDFImageDPI = 300;
+
 // Info class for all supported file formats
 enum class GraphicFileFormat
 {
diff --git a/vcl/source/gdi/pdfextoutdevdata.cxx 
b/vcl/source/gdi/pdfextoutdevdata.cxx
index 9d3269e9e70c..9a1b6a0c642f 100644
--- a/vcl/source/gdi/pdfextoutdevdata.cxx
+++ b/vcl/source/gdi/pdfextoutdevdata.cxx
@@ -24,6 +24,7 @@
 #include <vcl/gfxlink.hxx>
 #include <vcl/metaact.hxx>
 #include <vcl/graphicfilter.hxx>
+#include <vcl/graphic/GraphicMetadata.hxx>
 #include <vcl/pdf/PDFNote.hxx>
 #include <basegfx/polygon/b2dpolygon.hxx>
 #include <basegfx/polygon/b2dpolygontools.hxx>
@@ -531,7 +532,7 @@ PDFExtOutDevData::PDFExtOutDevData( const OutputDevice& 
rOutDev ) :
     mbSinglePageSheets      ( false ),
     mbExportNDests          ( false ),
     mnPage                  ( -1 ),
-    mnCompressionQuality    ( 90 ),
+    mnCompressionQuality    ( DefaultPDFJPEGQuality ),
     mpGlobalSyncData        ( new GlobalSyncData() )
 {
     mpPageSyncData.reset( new PageSyncData( mpGlobalSyncData.get() ) );

Reply via email to