[Libreoffice-commits] core.git: include/svtools sfx2/source svtools/source

Julien Nabet (via logerrit) logerrit at kemper.freedesktop.org
Fri Dec 27 12:26:02 UTC 2019


 include/svtools/printoptions.hxx       |   26 +-
 sfx2/source/dialog/printopt.cxx        |    6 
 svtools/source/config/printoptions.cxx |  299 ++-------------------------------
 3 files changed, 40 insertions(+), 291 deletions(-)

New commits:
commit 1241ae1327242dca4af2e38e571f872aa882e156
Author:     Julien Nabet <serval2412 at yahoo.fr>
AuthorDate: Mon Dec 23 19:12:48 2019 +0100
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Dec 27 13:25:24 2019 +0100

    tdf#46037: simplify is/get methods in svtools/printoptions
    
    Change-Id: I4358cfdbb2dbd7ad8d3cc7de82163303d403a8ec
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/85767
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/svtools/printoptions.hxx b/include/svtools/printoptions.hxx
index 44f064f9c782..f5fe0a6da2a8 100644
--- a/include/svtools/printoptions.hxx
+++ b/include/svtools/printoptions.hxx
@@ -48,17 +48,17 @@ public:
                 SvtBasePrintOptions();
                 virtual ~SvtBasePrintOptions() override;
 
-    bool        IsReduceTransparency() const;
-    sal_Int16   GetReducedTransparencyMode() const;
-    bool        IsReduceGradients() const;
-    sal_Int16   GetReducedGradientMode() const;
-    sal_Int16   GetReducedGradientStepCount() const;
-    bool        IsReduceBitmaps() const;
-    sal_Int16   GetReducedBitmapMode() const;
-    sal_Int16   GetReducedBitmapResolution() const;
-    bool        IsReducedBitmapIncludesTransparency() const;
-    bool        IsConvertToGreyscales() const;
-    bool        IsPDFAsStandardPrintJobFormat() const;
+    static bool        IsReduceTransparency();
+    static sal_Int16   GetReducedTransparencyMode();
+    static bool        IsReduceGradients();
+    static sal_Int16   GetReducedGradientMode();
+    static sal_Int16   GetReducedGradientStepCount();
+    static bool        IsReduceBitmaps();
+    static sal_Int16   GetReducedBitmapMode();
+    static sal_Int16   GetReducedBitmapResolution();
+    static bool        IsReducedBitmapIncludesTransparency();
+    static bool        IsConvertToGreyscales();
+    static bool        IsPDFAsStandardPrintJobFormat();
 
     void        SetReduceTransparency( bool bState );
     void        SetReducedTransparencyMode( sal_Int16 nMode );
@@ -74,8 +74,8 @@ public:
 
 public:
 
-    void        GetPrinterOptions( PrinterOptions& rOptions ) const;
-    void        SetPrinterOptions( const PrinterOptions& rOptions );
+    static void        GetPrinterOptions( PrinterOptions& rOptions );
+    void               SetPrinterOptions( const PrinterOptions& rOptions );
 };
 
 
diff --git a/sfx2/source/dialog/printopt.cxx b/sfx2/source/dialog/printopt.cxx
index 63313a5a09ba..e6b37a7cd649 100644
--- a/sfx2/source/dialog/printopt.cxx
+++ b/sfx2/source/dialog/printopt.cxx
@@ -116,8 +116,6 @@ bool SfxCommonPrintOptionsTabPage::FillItemSet( SfxItemSet* /*rSet*/ )
 void SfxCommonPrintOptionsTabPage::Reset( const SfxItemSet* /*rSet*/ )
 {
     SvtPrintWarningOptions  aWarnOptions;
-    SvtPrinterOptions       aPrinterOptions;
-    SvtPrintFileOptions     aPrintFileOptions;
 
     m_xPaperSizeCB->set_active( aWarnOptions.IsPaperSize() );
     m_xPaperOrientationCB->set_active( aWarnOptions.IsPaperOrientation() );
@@ -128,8 +126,8 @@ void SfxCommonPrintOptionsTabPage::Reset( const SfxItemSet* /*rSet*/ )
     m_xPaperOrientationCB->save_state();
     m_xTransparencyCB->save_state();
 
-    aPrinterOptions.GetPrinterOptions( maPrinterOptions );
-    aPrintFileOptions.GetPrinterOptions( maPrintFileOptions );
+    SvtBasePrintOptions::GetPrinterOptions( maPrinterOptions );
+    SvtBasePrintOptions::GetPrinterOptions( maPrintFileOptions );
     if(m_xPrintFileOutputRB->get_active()){
        m_xPrinterOutputRB->set_active(true);
     }
diff --git a/svtools/source/config/printoptions.cxx b/svtools/source/config/printoptions.cxx
index c7d3353911dc..4a783863eb96 100644
--- a/svtools/source/config/printoptions.cxx
+++ b/svtools/source/config/printoptions.cxx
@@ -27,6 +27,8 @@
 #include <comphelper/configurationhelper.hxx>
 #include <comphelper/processfactory.hxx>
 
+#include <officecfg/Office/Common.hxx>
+
 #include "itemholder2.hxx"
 
 #include <sal/macros.h>
@@ -70,18 +72,6 @@ public:
     explicit SvtPrintOptions_Impl( const OUString& rConfigRoot );
     ~SvtPrintOptions_Impl();
 
-    bool        IsReduceTransparency() const ;
-    sal_Int16   GetReducedTransparencyMode() const ;
-    bool        IsReduceGradients() const ;
-    sal_Int16   GetReducedGradientMode() const ;
-    sal_Int16   GetReducedGradientStepCount() const ;
-    bool        IsReduceBitmaps() const ;
-    sal_Int16   GetReducedBitmapMode() const ;
-    sal_Int16   GetReducedBitmapResolution() const ;
-    bool        IsReducedBitmapIncludesTransparency() const ;
-    bool        IsConvertToGreyscales() const;
-    bool        IsPDFAsStandardPrintJobFormat() const;
-
     void        SetReduceTransparency( bool bState ) ;
     void        SetReducedTransparencyMode( sal_Int16 nMode ) ;
     void        SetReduceGradients( bool bState ) ;
@@ -135,245 +125,6 @@ SvtPrintOptions_Impl::SvtPrintOptions_Impl(const OUString& rConfigRoot)
     }
 }
 
-bool SvtPrintOptions_Impl::IsReduceTransparency() const
-{
-    bool bRet = false;
-    try
-    {
-        if (m_xNode.is())
-        {
-            css::uno::Reference< css::beans::XPropertySet > xSet(m_xNode, css::uno::UNO_QUERY);
-            if (xSet.is())
-                xSet->getPropertyValue(PROPERTYNAME_REDUCETRANSPARENCY) >>= bRet;
-        }
-    }
-    catch (const css::uno::Exception&)
-    {
-        DBG_UNHANDLED_EXCEPTION("svtools.config");
-    }
-
-    return bRet;
-}
-
-sal_Int16 SvtPrintOptions_Impl::GetReducedTransparencyMode() const
-{
-    sal_Int16 nRet = 0;
-    try
-    {
-        if (m_xNode.is())
-        {
-            css::uno::Reference< css::beans::XPropertySet > xSet(m_xNode, css::uno::UNO_QUERY);
-            if (xSet.is())
-                xSet->getPropertyValue(PROPERTYNAME_REDUCEDTRANSPARENCYMODE) >>= nRet;
-        }
-    }
-    catch (const css::uno::Exception&)
-    {
-        DBG_UNHANDLED_EXCEPTION("svtools.config");
-    }
-
-    return  nRet;
-}
-
-bool SvtPrintOptions_Impl::IsReduceGradients() const
-{
-    bool bRet = false;
-    try
-    {
-        if (m_xNode.is())
-        {
-            css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
-            if (xSet.is())
-            {
-                xSet->getPropertyValue(PROPERTYNAME_REDUCEGRADIENTS) >>= bRet;
-            }
-        }
-    }
-    catch (const css::uno::Exception&)
-    {
-        DBG_UNHANDLED_EXCEPTION("svtools.config");
-    }
-
-    return bRet;
-}
-
-sal_Int16 SvtPrintOptions_Impl::GetReducedGradientMode() const
-{
-    sal_Int16 nRet = 0;
-    try
-    {
-        if (m_xNode.is())
-        {
-            css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
-            if (xSet.is())
-            {
-                xSet->getPropertyValue(PROPERTYNAME_REDUCEDGRADIENTMODE) >>= nRet;
-            }
-        }
-    }
-    catch (const css::uno::Exception&)
-    {
-        DBG_UNHANDLED_EXCEPTION("svtools.config");
-    }
-
-    return nRet;
-}
-
-sal_Int16 SvtPrintOptions_Impl::GetReducedGradientStepCount() const
-{
-    sal_Int16 nRet = 64;
-    try
-    {
-        if (m_xNode.is())
-        {
-            css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
-            if (xSet.is())
-            {
-                xSet->getPropertyValue(PROPERTYNAME_REDUCEDGRADIENTSTEPCOUNT) >>= nRet;
-            }
-        }
-    }
-    catch (const css::uno::Exception&)
-    {
-        DBG_UNHANDLED_EXCEPTION("svtools.config");
-    }
-
-    return nRet;
-}
-
-bool SvtPrintOptions_Impl::IsReduceBitmaps() const
-{
-    bool bRet = false;
-    try
-    {
-        if (m_xNode.is())
-        {
-            css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
-            if (xSet.is())
-            {
-                xSet->getPropertyValue(PROPERTYNAME_REDUCEBITMAPS) >>= bRet;
-            }
-        }
-    }
-    catch (const css::uno::Exception&)
-    {
-        DBG_UNHANDLED_EXCEPTION("svtools.config");
-    }
-
-    return bRet;
-}
-
-sal_Int16 SvtPrintOptions_Impl::GetReducedBitmapMode() const
-{
-    sal_Int16 nRet = 1;
-    try
-    {
-        if (m_xNode.is())
-        {
-            css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
-            if (xSet.is())
-            {
-                xSet->getPropertyValue(PROPERTYNAME_REDUCEDBITMAPMODE) >>= nRet;
-            }
-        }
-    }
-    catch (const css::uno::Exception&)
-    {
-        DBG_UNHANDLED_EXCEPTION("svtools.config");
-    }
-
-    return nRet;
-}
-
-sal_Int16 SvtPrintOptions_Impl::GetReducedBitmapResolution() const
-{
-    sal_Int16 nRet = 3;
-    try
-    {
-        if (m_xNode.is())
-        {
-            css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
-            if (xSet.is())
-            {
-                xSet->getPropertyValue(PROPERTYNAME_REDUCEDBITMAPRESOLUTION) >>= nRet;
-            }
-        }
-    }
-    catch (const css::uno::Exception&)
-    {
-        DBG_UNHANDLED_EXCEPTION("svtools.config");
-    }
-
-    return  nRet;
-}
-
-bool SvtPrintOptions_Impl::IsReducedBitmapIncludesTransparency() const
-{
-    bool bRet = true;
-    try
-    {
-        if (m_xNode.is())
-        {
-            css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
-            if (xSet.is())
-            {
-                xSet->getPropertyValue(PROPERTYNAME_REDUCEDBITMAPINCLUDESTRANSPARENCY) >>= bRet;
-            }
-        }
-    }
-    catch (const css::uno::Exception&)
-    {
-        DBG_UNHANDLED_EXCEPTION("svtools.config");
-    }
-
-    return  bRet;
-}
-
-bool SvtPrintOptions_Impl::IsConvertToGreyscales() const
-{
-    bool bRet = false;
-    try
-    {
-        if (m_xNode.is())
-        {
-            css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
-            if (xSet.is())
-            {
-                xSet->getPropertyValue(PROPERTYNAME_CONVERTTOGREYSCALES) >>= bRet;
-            }
-        }
-    }
-    catch (const css::uno::Exception&)
-    {
-        DBG_UNHANDLED_EXCEPTION("svtools.config");
-    }
-
-    return  bRet;
-
-}
-
-bool SvtPrintOptions_Impl::IsPDFAsStandardPrintJobFormat() const
-{
-    bool bRet = true;
-    try
-    {
-        if (m_xNode.is())
-        {
-            css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
-            if (xSet.is())
-            {
-                xSet->getPropertyValue(PROPERTYNAME_PDFASSTANDARDPRINTJOBFORMAT) >>= bRet;
-            }
-        }
-    }
-    catch (const css::uno::Exception&)
-    {
-        DBG_UNHANDLED_EXCEPTION("svtools.config");
-    }
-
-    return  bRet;
-}
-
 void SvtPrintOptions_Impl::SetReduceTransparency(bool bState)
 {
     impl_setValue(PROPERTYNAME_REDUCETRANSPARENCY, bState);
@@ -506,70 +257,70 @@ Mutex& SvtBasePrintOptions::GetOwnStaticMutex()
     return ourMutex;
 }
 
-bool SvtBasePrintOptions::IsReduceTransparency() const
+bool SvtBasePrintOptions::IsReduceTransparency()
 {
     MutexGuard aGuard( GetOwnStaticMutex() );
-    return m_pDataContainer->IsReduceTransparency();
+    return officecfg::Office::Common::Print::Option::Printer::ReduceTransparency::get();
 }
 
-sal_Int16 SvtBasePrintOptions::GetReducedTransparencyMode() const
+sal_Int16 SvtBasePrintOptions::GetReducedTransparencyMode()
 {
     MutexGuard aGuard( GetOwnStaticMutex() );
-    return m_pDataContainer->GetReducedTransparencyMode();
+    return officecfg::Office::Common::Print::Option::Printer::ReducedTransparencyMode::get();
 }
 
-bool SvtBasePrintOptions::IsReduceGradients() const
+bool SvtBasePrintOptions::IsReduceGradients()
 {
     MutexGuard aGuard( GetOwnStaticMutex() );
-    return m_pDataContainer->IsReduceGradients();
+    return officecfg::Office::Common::Print::Option::Printer::ReduceGradients::get();
 }
 
-sal_Int16 SvtBasePrintOptions::GetReducedGradientMode() const
+sal_Int16 SvtBasePrintOptions::GetReducedGradientMode()
 {
     MutexGuard aGuard( GetOwnStaticMutex() );
-    return m_pDataContainer->GetReducedGradientMode();
+    return officecfg::Office::Common::Print::Option::Printer::ReducedGradientMode::get();
 }
 
-sal_Int16 SvtBasePrintOptions::GetReducedGradientStepCount() const
+sal_Int16 SvtBasePrintOptions::GetReducedGradientStepCount()
 {
     MutexGuard aGuard( GetOwnStaticMutex() );
-    return m_pDataContainer->GetReducedGradientStepCount();
+    return officecfg::Office::Common::Print::Option::Printer::ReducedGradientStepCount::get();
 }
 
-bool SvtBasePrintOptions::IsReduceBitmaps() const
+bool SvtBasePrintOptions::IsReduceBitmaps()
 {
     MutexGuard aGuard( GetOwnStaticMutex() );
-    return m_pDataContainer->IsReduceBitmaps();
+    return officecfg::Office::Common::Print::Option::Printer::ReduceBitmaps::get();
 }
 
-sal_Int16 SvtBasePrintOptions::GetReducedBitmapMode() const
+sal_Int16 SvtBasePrintOptions::GetReducedBitmapMode()
 {
     MutexGuard aGuard( GetOwnStaticMutex() );
-    return m_pDataContainer->GetReducedBitmapMode();
+    return officecfg::Office::Common::Print::Option::Printer::ReducedBitmapMode::get();
 }
 
-sal_Int16 SvtBasePrintOptions::GetReducedBitmapResolution() const
+sal_Int16 SvtBasePrintOptions::GetReducedBitmapResolution()
 {
     MutexGuard aGuard( GetOwnStaticMutex() );
-    return m_pDataContainer->GetReducedBitmapResolution();
+    return officecfg::Office::Common::Print::Option::Printer::ReducedBitmapResolution::get();
 }
 
-bool SvtBasePrintOptions::IsReducedBitmapIncludesTransparency() const
+bool SvtBasePrintOptions::IsReducedBitmapIncludesTransparency()
 {
     MutexGuard aGuard( GetOwnStaticMutex() );
-    return m_pDataContainer->IsReducedBitmapIncludesTransparency();
+    return officecfg::Office::Common::Print::Option::Printer::ReducedBitmapIncludesTransparency::get();
 }
 
-bool SvtBasePrintOptions::IsConvertToGreyscales() const
+bool SvtBasePrintOptions::IsConvertToGreyscales()
 {
     MutexGuard aGuard( GetOwnStaticMutex() );
-    return m_pDataContainer->IsConvertToGreyscales();
+    return officecfg::Office::Common::Print::Option::Printer::ConvertToGreyscales::get();
 }
 
-bool SvtBasePrintOptions::IsPDFAsStandardPrintJobFormat() const
+bool SvtBasePrintOptions::IsPDFAsStandardPrintJobFormat()
 {
     MutexGuard aGuard( GetOwnStaticMutex() );
-    return m_pDataContainer->IsPDFAsStandardPrintJobFormat();
+    return officecfg::Office::Common::Print::Option::Printer::PDFAsStandardPrintJobFormat::get();
 }
 
 void SvtBasePrintOptions::SetReduceTransparency( bool bState )
@@ -638,7 +389,7 @@ void SvtBasePrintOptions::SetPDFAsStandardPrintJobFormat( bool bState )
     m_pDataContainer->SetPDFAsStandardPrintJobFormat( bState );
 }
 
-void SvtBasePrintOptions::GetPrinterOptions( PrinterOptions& rOptions ) const
+void SvtBasePrintOptions::GetPrinterOptions( PrinterOptions& rOptions )
 {
     rOptions.SetReduceTransparency( IsReduceTransparency() );
     rOptions.SetReducedTransparencyMode( static_cast<PrinterTransparencyMode>(GetReducedTransparencyMode()) );


More information about the Libreoffice-commits mailing list