LCOV - code coverage report
Current view: top level - svtools/source/config - printoptions.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 333 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 60 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <svtools/printoptions.hxx>
      21             : #include <unotools/configmgr.hxx>
      22             : #include <unotools/configitem.hxx>
      23             : #include <vcl/print.hxx>
      24             : #include <com/sun/star/uno/Any.hxx>
      25             : #include <com/sun/star/uno/Sequence.hxx>
      26             : 
      27             : #include <com/sun/star/beans/XPropertySet.hpp>
      28             : #include <com/sun/star/container/XNameAccess.hpp>
      29             : #include <com/sun/star/container/XNameContainer.hpp>
      30             : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
      31             : 
      32             : #include <comphelper/configurationhelper.hxx>
      33             : #include <comphelper/processfactory.hxx>
      34             : #include <comphelper/string.hxx>
      35             : 
      36             : #include "itemholder2.hxx"
      37             : 
      38             : #include <sal/macros.h>
      39             : 
      40             : static sal_uInt16 aDPIArray[] = { 72, 96, 150, 200, 300, 600 };
      41             : 
      42             : #define DPI_COUNT (SAL_N_ELEMENTS(aDPIArray))
      43             : 
      44             : #define ROOTNODE_START                                  OUString("Office.Common/Print/Option")
      45             : #define ROOTNODE_PRINTOPTION                            OUString("org.openoffice.Office.Common/Print/Option")
      46             : 
      47             : #define PROPERTYNAME_REDUCETRANSPARENCY                 OUString("ReduceTransparency")
      48             : #define PROPERTYNAME_REDUCEDTRANSPARENCYMODE            OUString("ReducedTransparencyMode")
      49             : #define PROPERTYNAME_REDUCEGRADIENTS                    OUString("ReduceGradients")
      50             : #define PROPERTYNAME_REDUCEDGRADIENTMODE                OUString("ReducedGradientMode")
      51             : #define PROPERTYNAME_REDUCEDGRADIENTSTEPCOUNT           OUString("ReducedGradientStepCount")
      52             : #define PROPERTYNAME_REDUCEBITMAPS                      OUString("ReduceBitmaps")
      53             : #define PROPERTYNAME_REDUCEDBITMAPMODE                  OUString("ReducedBitmapMode")
      54             : #define PROPERTYNAME_REDUCEDBITMAPRESOLUTION            OUString("ReducedBitmapResolution")
      55             : #define PROPERTYNAME_REDUCEDBITMAPINCLUDESTRANSPARENCY  OUString("ReducedBitmapIncludesTransparency")
      56             : #define PROPERTYNAME_CONVERTTOGREYSCALES                OUString("ConvertToGreyscales")
      57             : #define PROPERTYNAME_PDFASSTANDARDPRINTJOBFORMAT        OUString("PDFAsStandardPrintJobFormat")
      58             : 
      59             : using namespace ::utl;
      60             : using namespace ::osl;
      61             : using namespace ::com::sun::star::uno;
      62             : 
      63             : static SvtPrintOptions_Impl*   pPrinterOptionsDataContainer = NULL;
      64             : static SvtPrintOptions_Impl*   pPrintFileOptionsDataContainer = NULL;
      65             : 
      66             : SvtPrintOptions_Impl*   SvtPrinterOptions::m_pStaticDataContainer = NULL;
      67             : sal_Int32               SvtPrinterOptions::m_nRefCount = 0;
      68             : 
      69             : SvtPrintOptions_Impl*   SvtPrintFileOptions::m_pStaticDataContainer = NULL;
      70             : sal_Int32               SvtPrintFileOptions::m_nRefCount = 0;
      71             : 
      72             : class SvtPrintOptions_Impl
      73             : {
      74             : public:
      75             :     explicit SvtPrintOptions_Impl( const OUString& rConfigRoot );
      76             :     ~SvtPrintOptions_Impl();
      77             : 
      78             :     bool        IsReduceTransparency() const ;
      79             :     sal_Int16   GetReducedTransparencyMode() const ;
      80             :     bool        IsReduceGradients() const ;
      81             :     sal_Int16   GetReducedGradientMode() const ;
      82             :     sal_Int16   GetReducedGradientStepCount() const ;
      83             :     bool        IsReduceBitmaps() const ;
      84             :     sal_Int16   GetReducedBitmapMode() const ;
      85             :     sal_Int16   GetReducedBitmapResolution() const ;
      86             :     bool        IsReducedBitmapIncludesTransparency() const ;
      87             :     bool        IsConvertToGreyscales() const;
      88             :     bool        IsPDFAsStandardPrintJobFormat() const;
      89             : 
      90             :     void        SetReduceTransparency( bool bState ) ;
      91             :     void        SetReducedTransparencyMode( sal_Int16 nMode ) ;
      92             :     void        SetReduceGradients( bool bState ) ;
      93             :     void        SetReducedGradientMode( sal_Int16 nMode ) ;
      94             :     void        SetReducedGradientStepCount( sal_Int16 nStepCount ) ;
      95             :     void        SetReduceBitmaps( bool bState ) ;
      96             :     void        SetReducedBitmapMode( sal_Int16 nMode ) ;
      97             :     void        SetReducedBitmapResolution( sal_Int16 nResolution ) ;
      98             :     void        SetReducedBitmapIncludesTransparency( bool bState ) ;
      99             :     void        SetConvertToGreyscales( bool bState ) ;
     100             :     void        SetPDFAsStandardPrintJobFormat( bool bState ) ;
     101             : 
     102             : 
     103             : //  private API
     104             : 
     105             : 
     106             : private:
     107             :     void impl_setValue (const OUString& sProp, bool bNew );
     108             :     void impl_setValue (const OUString& sProp, sal_Int16 nNew );
     109             : 
     110             : 
     111             : //  private member
     112             : 
     113             : 
     114             : private:
     115             :        css::uno::Reference< css::container::XNameAccess > m_xCfg;
     116             :     css::uno::Reference< css::container::XNameAccess > m_xNode;
     117             : };
     118             : 
     119           0 : SvtPrintOptions_Impl::SvtPrintOptions_Impl(const OUString& rConfigRoot)
     120             : {
     121             :     try
     122             :     {
     123           0 :         m_xCfg = css::uno::Reference< css::container::XNameAccess >(
     124             :             ::comphelper::ConfigurationHelper::openConfig(
     125             :             comphelper::getProcessComponentContext(),
     126             :             ROOTNODE_PRINTOPTION,
     127             :             ::comphelper::ConfigurationHelper::E_STANDARD),
     128           0 :             css::uno::UNO_QUERY);
     129             : 
     130           0 :         if (m_xCfg.is())
     131             :         {
     132             :             using comphelper::string::getTokenCount;
     133           0 :             sal_Int32 nTokenCount = getTokenCount(rConfigRoot, '/');
     134           0 :             OUString sTok = rConfigRoot.getToken(nTokenCount - 1, '/');
     135           0 :             m_xCfg->getByName(sTok) >>= m_xNode;
     136             :         }
     137             :     }
     138           0 :     catch (const css::uno::Exception& ex)
     139             :     {
     140           0 :         m_xNode.clear();
     141           0 :         m_xCfg.clear();
     142             :         SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
     143             :     }
     144           0 : }
     145             : 
     146           0 : bool SvtPrintOptions_Impl::IsReduceTransparency() const
     147             : {
     148           0 :     bool bRet = false;
     149             :     try
     150             :     {
     151           0 :         if (m_xNode.is())
     152             :         {
     153           0 :             css::uno::Reference< css::beans::XPropertySet > xSet(m_xNode, css::uno::UNO_QUERY);
     154           0 :             if (xSet.is())
     155           0 :                 xSet->getPropertyValue(PROPERTYNAME_REDUCETRANSPARENCY) >>= bRet;
     156             :         }
     157             :     }
     158           0 :     catch (const css::uno::Exception& ex)
     159             :     {
     160             :         SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
     161             :     }
     162             : 
     163           0 :     return bRet;
     164             : }
     165             : 
     166           0 : sal_Int16 SvtPrintOptions_Impl::GetReducedTransparencyMode() const
     167             : {
     168           0 :     sal_Int16 nRet = 0;
     169             :     try
     170             :     {
     171           0 :         if (m_xNode.is())
     172             :         {
     173           0 :             css::uno::Reference< css::beans::XPropertySet > xSet(m_xNode, css::uno::UNO_QUERY);
     174           0 :             if (xSet.is())
     175           0 :                 xSet->getPropertyValue(PROPERTYNAME_REDUCEDTRANSPARENCYMODE) >>= nRet;
     176             :         }
     177             :     }
     178           0 :     catch (const css::uno::Exception& ex)
     179             :     {
     180             :         SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
     181             :     }
     182             : 
     183           0 :     return  nRet;
     184             : }
     185             : 
     186           0 : bool SvtPrintOptions_Impl::IsReduceGradients() const
     187             : {
     188           0 :     bool bRet = false;
     189             :     try
     190             :     {
     191           0 :         if (m_xNode.is())
     192             :         {
     193           0 :             css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
     194           0 :             if (xSet.is())
     195             :             {
     196           0 :                 xSet->getPropertyValue(PROPERTYNAME_REDUCEGRADIENTS) >>= bRet;
     197           0 :             }
     198             :         }
     199             :     }
     200           0 :     catch (const css::uno::Exception& ex)
     201             :     {
     202             :         SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
     203             :     }
     204             : 
     205           0 :     return bRet;
     206             : }
     207             : 
     208           0 : sal_Int16 SvtPrintOptions_Impl::GetReducedGradientMode() const
     209             : {
     210           0 :     sal_Int16 nRet = 0;
     211             :     try
     212             :     {
     213           0 :         if (m_xNode.is())
     214             :         {
     215           0 :             css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
     216           0 :             if (xSet.is())
     217             :             {
     218           0 :                 xSet->getPropertyValue(PROPERTYNAME_REDUCEDGRADIENTMODE) >>= nRet;
     219           0 :             }
     220             :         }
     221             :     }
     222           0 :     catch (const css::uno::Exception& ex)
     223             :     {
     224             :         SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
     225             :     }
     226             : 
     227           0 :     return nRet;
     228             : }
     229             : 
     230           0 : sal_Int16 SvtPrintOptions_Impl::GetReducedGradientStepCount() const
     231             : {
     232           0 :     sal_Int16 nRet = 64;
     233             :     try
     234             :     {
     235           0 :         if (m_xNode.is())
     236             :         {
     237           0 :             css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
     238           0 :             if (xSet.is())
     239             :             {
     240           0 :                 xSet->getPropertyValue(PROPERTYNAME_REDUCEDGRADIENTSTEPCOUNT) >>= nRet;
     241           0 :             }
     242             :         }
     243             :     }
     244           0 :     catch (const css::uno::Exception& ex)
     245             :     {
     246             :         SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
     247             :     }
     248             : 
     249           0 :     return nRet;
     250             : }
     251             : 
     252           0 : bool SvtPrintOptions_Impl::IsReduceBitmaps() const
     253             : {
     254           0 :     bool bRet = false;
     255             :     try
     256             :     {
     257           0 :         if (m_xNode.is())
     258             :         {
     259           0 :             css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
     260           0 :             if (xSet.is())
     261             :             {
     262           0 :                 xSet->getPropertyValue(PROPERTYNAME_REDUCEBITMAPS) >>= bRet;
     263           0 :             }
     264             :         }
     265             :     }
     266           0 :     catch (const css::uno::Exception& ex)
     267             :     {
     268             :         SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
     269             :     }
     270             : 
     271           0 :     return bRet;
     272             : }
     273             : 
     274           0 : sal_Int16 SvtPrintOptions_Impl::GetReducedBitmapMode() const
     275             : {
     276           0 :     sal_Int16 nRet = 1;
     277             :     try
     278             :     {
     279           0 :         if (m_xNode.is())
     280             :         {
     281           0 :             css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
     282           0 :             if (xSet.is())
     283             :             {
     284           0 :                 xSet->getPropertyValue(PROPERTYNAME_REDUCEDBITMAPMODE) >>= nRet;
     285           0 :             }
     286             :         }
     287             :     }
     288           0 :     catch (const css::uno::Exception& ex)
     289             :     {
     290             :         SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
     291             :     }
     292             : 
     293           0 :     return nRet;
     294             : }
     295             : 
     296           0 : sal_Int16 SvtPrintOptions_Impl::GetReducedBitmapResolution() const
     297             : {
     298           0 :     sal_Int16 nRet = 3;
     299             :     try
     300             :     {
     301           0 :         if (m_xNode.is())
     302             :         {
     303           0 :             css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
     304           0 :             if (xSet.is())
     305             :             {
     306           0 :                 xSet->getPropertyValue(PROPERTYNAME_REDUCEDBITMAPRESOLUTION) >>= nRet;
     307           0 :             }
     308             :         }
     309             :     }
     310           0 :     catch (const css::uno::Exception& ex)
     311             :     {
     312             :         SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
     313             :     }
     314             : 
     315           0 :     return  nRet;
     316             : }
     317             : 
     318           0 : bool SvtPrintOptions_Impl::IsReducedBitmapIncludesTransparency() const
     319             : {
     320           0 :     bool bRet = true;
     321             :     try
     322             :     {
     323           0 :         if (m_xNode.is())
     324             :         {
     325           0 :             css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
     326           0 :             if (xSet.is())
     327             :             {
     328           0 :                 xSet->getPropertyValue(PROPERTYNAME_REDUCEDBITMAPINCLUDESTRANSPARENCY) >>= bRet;
     329           0 :             }
     330             :         }
     331             :     }
     332           0 :     catch (const css::uno::Exception& ex)
     333             :     {
     334             :         SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
     335             :     }
     336             : 
     337           0 :     return  bRet;
     338             : }
     339             : 
     340           0 : bool SvtPrintOptions_Impl::IsConvertToGreyscales() const
     341             : {
     342           0 :     bool bRet = false;
     343             :     try
     344             :     {
     345           0 :         if (m_xNode.is())
     346             :         {
     347           0 :             css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
     348           0 :             if (xSet.is())
     349             :             {
     350           0 :                 xSet->getPropertyValue(PROPERTYNAME_CONVERTTOGREYSCALES) >>= bRet;
     351           0 :             }
     352             :         }
     353             :     }
     354           0 :     catch (const css::uno::Exception& ex)
     355             :     {
     356             :         SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
     357             :     }
     358             : 
     359           0 :     return  bRet;
     360             : 
     361             : }
     362             : 
     363           0 : bool SvtPrintOptions_Impl::IsPDFAsStandardPrintJobFormat() const
     364             : {
     365           0 :     bool bRet = true;
     366             :     try
     367             :     {
     368           0 :         if (m_xNode.is())
     369             :         {
     370           0 :             css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
     371           0 :             if (xSet.is())
     372             :             {
     373           0 :                 xSet->getPropertyValue(PROPERTYNAME_PDFASSTANDARDPRINTJOBFORMAT) >>= bRet;
     374           0 :             }
     375             :         }
     376             :     }
     377           0 :     catch (const css::uno::Exception& ex)
     378             :     {
     379             :         SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
     380             :     }
     381             : 
     382           0 :     return  bRet;
     383             : }
     384             : 
     385           0 : void SvtPrintOptions_Impl::SetReduceTransparency(bool bState)
     386             : {
     387           0 :     impl_setValue(PROPERTYNAME_REDUCETRANSPARENCY, bState);
     388           0 : }
     389             : 
     390           0 : void SvtPrintOptions_Impl::SetReducedTransparencyMode(sal_Int16 nMode)
     391             : {
     392           0 :     impl_setValue(PROPERTYNAME_REDUCEDTRANSPARENCYMODE, nMode);
     393           0 : }
     394             : 
     395           0 : void SvtPrintOptions_Impl::SetReduceGradients(bool bState)
     396             : {
     397           0 :     impl_setValue(PROPERTYNAME_REDUCEGRADIENTS, bState);
     398           0 : }
     399             : 
     400           0 : void SvtPrintOptions_Impl::SetReducedGradientMode(sal_Int16 nMode)
     401             : {
     402           0 :     impl_setValue(PROPERTYNAME_REDUCEDGRADIENTMODE, nMode);
     403           0 : }
     404             : 
     405           0 : void SvtPrintOptions_Impl::SetReducedGradientStepCount(sal_Int16 nStepCount )
     406             : {
     407           0 :     impl_setValue(PROPERTYNAME_REDUCEDGRADIENTSTEPCOUNT, nStepCount);
     408           0 : }
     409             : 
     410           0 : void SvtPrintOptions_Impl::SetReduceBitmaps(bool bState )
     411             : {
     412           0 :     impl_setValue(PROPERTYNAME_REDUCEBITMAPS, bState);
     413           0 : }
     414             : 
     415           0 : void SvtPrintOptions_Impl::SetReducedBitmapMode(sal_Int16 nMode )
     416             : {
     417           0 :     impl_setValue(PROPERTYNAME_REDUCEDBITMAPMODE, nMode);
     418           0 : }
     419             : 
     420           0 : void SvtPrintOptions_Impl::SetReducedBitmapResolution(sal_Int16 nResolution )
     421             : {
     422           0 :     impl_setValue(PROPERTYNAME_REDUCEDBITMAPRESOLUTION, nResolution);
     423           0 : }
     424             : 
     425           0 : void SvtPrintOptions_Impl::SetReducedBitmapIncludesTransparency(bool bState )
     426             : {
     427           0 :     impl_setValue(PROPERTYNAME_REDUCEDBITMAPINCLUDESTRANSPARENCY, bState);
     428           0 : }
     429             : 
     430           0 : void SvtPrintOptions_Impl::SetConvertToGreyscales(bool bState)
     431             : {
     432           0 :     impl_setValue(PROPERTYNAME_CONVERTTOGREYSCALES, bState);
     433           0 : }
     434             : 
     435           0 : void SvtPrintOptions_Impl::SetPDFAsStandardPrintJobFormat(bool bState)
     436             : {
     437           0 :     impl_setValue(PROPERTYNAME_PDFASSTANDARDPRINTJOBFORMAT, bState);
     438           0 : }
     439             : 
     440           0 : SvtPrintOptions_Impl::~SvtPrintOptions_Impl()
     441             : {
     442           0 :     m_xNode.clear();
     443           0 :     m_xCfg.clear();
     444           0 : }
     445             : 
     446           0 : void SvtPrintOptions_Impl::impl_setValue (const OUString& sProp, bool bNew )
     447             : {
     448             :     try
     449             :     {
     450           0 :         if ( ! m_xNode.is())
     451           0 :             return;
     452             : 
     453           0 :         css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
     454           0 :         if ( ! xSet.is())
     455           0 :             return;
     456             : 
     457           0 :         bool bOld = ! bNew;
     458           0 :         if ( ! (xSet->getPropertyValue(sProp) >>= bOld))
     459           0 :             return;
     460             : 
     461           0 :         if (bOld != bNew)
     462             :         {
     463           0 :             xSet->setPropertyValue(sProp, css::uno::makeAny(bNew));
     464           0 :             ::comphelper::ConfigurationHelper::flush(m_xCfg);
     465           0 :         }
     466             :     }
     467           0 :     catch(const css::uno::Exception& ex)
     468             :     {
     469             :         SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
     470             :     }
     471             : }
     472             : 
     473           0 : void SvtPrintOptions_Impl::impl_setValue (const OUString& sProp,
     474             :                                                 ::sal_Int16      nNew )
     475             : {
     476             :     try
     477             :     {
     478           0 :         if ( ! m_xNode.is())
     479           0 :             return;
     480             : 
     481           0 :         css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
     482           0 :         if ( ! xSet.is())
     483           0 :             return;
     484             : 
     485           0 :         ::sal_Int16 nOld = nNew+1;
     486           0 :         if ( ! (xSet->getPropertyValue(sProp) >>= nOld))
     487           0 :             return;
     488             : 
     489           0 :         if (nOld != nNew)
     490             :         {
     491           0 :             xSet->setPropertyValue(sProp, css::uno::makeAny(nNew));
     492           0 :             ::comphelper::ConfigurationHelper::flush(m_xCfg);
     493           0 :         }
     494             :     }
     495           0 :     catch(const css::uno::Exception& ex)
     496             :     {
     497             :         SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
     498             :     }
     499             : }
     500             : 
     501           0 : SvtBasePrintOptions::SvtBasePrintOptions()
     502           0 :     : m_pDataContainer(NULL)
     503             : {
     504           0 : }
     505             : 
     506           0 : SvtBasePrintOptions::~SvtBasePrintOptions()
     507             : {
     508           0 : }
     509             : 
     510           0 : Mutex& SvtBasePrintOptions::GetOwnStaticMutex()
     511             : {
     512             :     // Initialize static mutex only for one time!
     513             :     static Mutex* pMutex = NULL;
     514             :     // If these method first called (Mutex not already exist!) ...
     515           0 :     if( pMutex == NULL )
     516             :     {
     517             :         // ... we must create a new one. Protect follow code with the global mutex -
     518             :         // It must be - we create a static variable!
     519           0 :         MutexGuard aGuard( Mutex::getGlobalMutex() );
     520             :         // We must check our pointer again - because it can be that another instance of our class will be fastr then these!
     521           0 :         if( pMutex == NULL )
     522             :         {
     523             :             // Create the new mutex and set it for return on static variable.
     524           0 :             static Mutex aMutex;
     525           0 :             pMutex = &aMutex;
     526           0 :         }
     527             :     }
     528             :     // Return new created or already existing mutex object.
     529           0 :     return *pMutex;
     530             : }
     531             : 
     532           0 : bool SvtBasePrintOptions::IsReduceTransparency() const
     533             : {
     534           0 :     MutexGuard aGuard( GetOwnStaticMutex() );
     535           0 :     return m_pDataContainer->IsReduceTransparency();
     536             : }
     537             : 
     538           0 : sal_Int16 SvtBasePrintOptions::GetReducedTransparencyMode() const
     539             : {
     540           0 :     MutexGuard aGuard( GetOwnStaticMutex() );
     541           0 :     return m_pDataContainer->GetReducedTransparencyMode();
     542             : }
     543             : 
     544           0 : bool SvtBasePrintOptions::IsReduceGradients() const
     545             : {
     546           0 :     MutexGuard aGuard( GetOwnStaticMutex() );
     547           0 :     return m_pDataContainer->IsReduceGradients();
     548             : }
     549             : 
     550           0 : sal_Int16 SvtBasePrintOptions::GetReducedGradientMode() const
     551             : {
     552           0 :     MutexGuard aGuard( GetOwnStaticMutex() );
     553           0 :     return m_pDataContainer->GetReducedGradientMode();
     554             : }
     555             : 
     556           0 : sal_Int16 SvtBasePrintOptions::GetReducedGradientStepCount() const
     557             : {
     558           0 :     MutexGuard aGuard( GetOwnStaticMutex() );
     559           0 :     return m_pDataContainer->GetReducedGradientStepCount();
     560             : }
     561             : 
     562           0 : bool SvtBasePrintOptions::IsReduceBitmaps() const
     563             : {
     564           0 :     MutexGuard aGuard( GetOwnStaticMutex() );
     565           0 :     return m_pDataContainer->IsReduceBitmaps();
     566             : }
     567             : 
     568           0 : sal_Int16 SvtBasePrintOptions::GetReducedBitmapMode() const
     569             : {
     570           0 :     MutexGuard aGuard( GetOwnStaticMutex() );
     571           0 :     return m_pDataContainer->GetReducedBitmapMode();
     572             : }
     573             : 
     574           0 : sal_Int16 SvtBasePrintOptions::GetReducedBitmapResolution() const
     575             : {
     576           0 :     MutexGuard aGuard( GetOwnStaticMutex() );
     577           0 :     return m_pDataContainer->GetReducedBitmapResolution();
     578             : }
     579             : 
     580           0 : bool SvtBasePrintOptions::IsReducedBitmapIncludesTransparency() const
     581             : {
     582           0 :     MutexGuard aGuard( GetOwnStaticMutex() );
     583           0 :     return m_pDataContainer->IsReducedBitmapIncludesTransparency();
     584             : }
     585             : 
     586           0 : bool SvtBasePrintOptions::IsConvertToGreyscales() const
     587             : {
     588           0 :     MutexGuard aGuard( GetOwnStaticMutex() );
     589           0 :     return m_pDataContainer->IsConvertToGreyscales();
     590             : }
     591             : 
     592           0 : bool SvtBasePrintOptions::IsPDFAsStandardPrintJobFormat() const
     593             : {
     594           0 :     MutexGuard aGuard( GetOwnStaticMutex() );
     595           0 :     return m_pDataContainer->IsPDFAsStandardPrintJobFormat();
     596             : }
     597             : 
     598           0 : void SvtBasePrintOptions::SetReduceTransparency( bool bState )
     599             : {
     600           0 :     MutexGuard aGuard( GetOwnStaticMutex() );
     601           0 :     m_pDataContainer->SetReduceTransparency( bState ) ;
     602           0 : }
     603             : 
     604           0 : void SvtBasePrintOptions::SetReducedTransparencyMode( sal_Int16 nMode )
     605             : {
     606           0 :     MutexGuard aGuard( GetOwnStaticMutex() );
     607           0 :     m_pDataContainer->SetReducedTransparencyMode( nMode );
     608           0 : }
     609             : 
     610           0 : void SvtBasePrintOptions::SetReduceGradients( bool bState )
     611             : {
     612           0 :     MutexGuard aGuard( GetOwnStaticMutex() );
     613           0 :     m_pDataContainer->SetReduceGradients( bState );
     614           0 : }
     615             : 
     616           0 : void SvtBasePrintOptions::SetReducedGradientMode( sal_Int16 nMode )
     617             : {
     618           0 :     MutexGuard aGuard( GetOwnStaticMutex() );
     619           0 :     m_pDataContainer->SetReducedGradientMode( nMode );
     620           0 : }
     621             : 
     622           0 : void SvtBasePrintOptions::SetReducedGradientStepCount( sal_Int16 nStepCount )
     623             : {
     624           0 :     MutexGuard aGuard( GetOwnStaticMutex() );
     625           0 :     m_pDataContainer->SetReducedGradientStepCount( nStepCount );
     626           0 : }
     627             : 
     628           0 : void SvtBasePrintOptions::SetReduceBitmaps( bool bState )
     629             : {
     630           0 :     MutexGuard aGuard( GetOwnStaticMutex() );
     631           0 :     m_pDataContainer->SetReduceBitmaps( bState );
     632           0 : }
     633             : 
     634           0 : void SvtBasePrintOptions::SetReducedBitmapMode( sal_Int16 nMode )
     635             : {
     636           0 :     MutexGuard aGuard( GetOwnStaticMutex() );
     637           0 :     m_pDataContainer->SetReducedBitmapMode( nMode );
     638           0 : }
     639             : 
     640           0 : void SvtBasePrintOptions::SetReducedBitmapResolution( sal_Int16 nResolution )
     641             : {
     642           0 :     MutexGuard aGuard( GetOwnStaticMutex() );
     643           0 :     m_pDataContainer->SetReducedBitmapResolution( nResolution );
     644           0 : }
     645             : 
     646           0 : void SvtBasePrintOptions::SetReducedBitmapIncludesTransparency( bool bState )
     647             : {
     648           0 :     MutexGuard aGuard( GetOwnStaticMutex() );
     649           0 :     m_pDataContainer->SetReducedBitmapIncludesTransparency( bState );
     650           0 : }
     651             : 
     652           0 : void SvtBasePrintOptions::SetConvertToGreyscales( bool bState )
     653             : {
     654           0 :     MutexGuard aGuard( GetOwnStaticMutex() );
     655           0 :     m_pDataContainer->SetConvertToGreyscales( bState );
     656           0 : }
     657             : 
     658           0 : void SvtBasePrintOptions::SetPDFAsStandardPrintJobFormat( bool bState )
     659             : {
     660           0 :     MutexGuard aGuard( GetOwnStaticMutex() );
     661           0 :     m_pDataContainer->SetPDFAsStandardPrintJobFormat( bState );
     662           0 : }
     663             : 
     664           0 : void SvtBasePrintOptions::GetPrinterOptions( PrinterOptions& rOptions ) const
     665             : {
     666           0 :     rOptions.SetReduceTransparency( IsReduceTransparency() );
     667           0 :     rOptions.SetReducedTransparencyMode( (PrinterTransparencyMode) GetReducedTransparencyMode() );
     668           0 :     rOptions.SetReduceGradients( IsReduceGradients() );
     669           0 :     rOptions.SetReducedGradientMode( (PrinterGradientMode) GetReducedGradientMode() );
     670           0 :     rOptions.SetReducedGradientStepCount( GetReducedGradientStepCount() );
     671           0 :     rOptions.SetReduceBitmaps( IsReduceBitmaps() );
     672           0 :     rOptions.SetReducedBitmapMode( (PrinterBitmapMode) GetReducedBitmapMode() );
     673           0 :     rOptions.SetReducedBitmapResolution( aDPIArray[ std::min( (sal_uInt16) GetReducedBitmapResolution(), (sal_uInt16)( DPI_COUNT - 1 ) ) ] );
     674           0 :     rOptions.SetReducedBitmapIncludesTransparency( IsReducedBitmapIncludesTransparency() );
     675           0 :     rOptions.SetConvertToGreyscales( IsConvertToGreyscales() );
     676           0 :     rOptions.SetPDFAsStandardPrintJobFormat( IsPDFAsStandardPrintJobFormat() );
     677           0 : }
     678             : 
     679           0 : void SvtBasePrintOptions::SetPrinterOptions( const PrinterOptions& rOptions )
     680             : {
     681           0 :     SetReduceTransparency( rOptions.IsReduceTransparency() );
     682             :     SetReducedTransparencyMode(
     683             :         sal::static_int_cast< sal_Int16 >(
     684           0 :             rOptions.GetReducedTransparencyMode()) );
     685           0 :     SetReduceGradients( rOptions.IsReduceGradients() );
     686             :     SetReducedGradientMode(
     687           0 :         sal::static_int_cast< sal_Int16 >(rOptions.GetReducedGradientMode()) );
     688           0 :     SetReducedGradientStepCount( rOptions.GetReducedGradientStepCount() );
     689           0 :     SetReduceBitmaps( rOptions.IsReduceBitmaps() );
     690             :     SetReducedBitmapMode(
     691           0 :         sal::static_int_cast< sal_Int16 >(rOptions.GetReducedBitmapMode()) );
     692           0 :     SetReducedBitmapIncludesTransparency( rOptions.IsReducedBitmapIncludesTransparency() );
     693           0 :     SetConvertToGreyscales( rOptions.IsConvertToGreyscales() );
     694           0 :     SetPDFAsStandardPrintJobFormat( rOptions.IsPDFAsStandardPrintJobFormat() );
     695             : 
     696           0 :     const sal_uInt16 nDPI = rOptions.GetReducedBitmapResolution();
     697             : 
     698           0 :     if( nDPI < aDPIArray[ 0 ] )
     699           0 :         SetReducedBitmapResolution( 0 );
     700             :     else
     701             :     {
     702           0 :         for( long i = ( DPI_COUNT - 1 ); i >= 0; i-- )
     703             :         {
     704           0 :             if( nDPI >= aDPIArray[ i ] )
     705             :             {
     706           0 :                 SetReducedBitmapResolution( (sal_Int16) i );
     707           0 :                 i = -1;
     708             :             }
     709             :         }
     710             :     }
     711           0 : }
     712             : 
     713           0 : SvtPrinterOptions::SvtPrinterOptions()
     714             : {
     715             :     // Global access, must be guarded (multithreading!).
     716           0 :     MutexGuard aGuard( GetOwnStaticMutex() );
     717             :     // Increase our refcount ...
     718           0 :     ++m_nRefCount;
     719             :     // ... and initialize our data container only if it not already!
     720           0 :     if( m_pStaticDataContainer == NULL )
     721             :     {
     722           0 :         OUString aRootPath( ROOTNODE_START );
     723           0 :         m_pStaticDataContainer = new SvtPrintOptions_Impl( aRootPath += "/Printer" );
     724           0 :         pPrinterOptionsDataContainer = m_pStaticDataContainer;
     725           0 :         svtools::ItemHolder2::holdConfigItem(E_PRINTOPTIONS);
     726             :     }
     727             : 
     728           0 :     SetDataContainer( m_pStaticDataContainer );
     729           0 : }
     730             : 
     731           0 : SvtPrinterOptions::~SvtPrinterOptions()
     732             : {
     733             :     // Global access, must be guarded (multithreading!)
     734           0 :     MutexGuard aGuard( GetOwnStaticMutex() );
     735             :     // Decrease our refcount.
     736           0 :     --m_nRefCount;
     737             :     // If last instance was deleted ...
     738             :     // we must destroy our static data container!
     739           0 :     if( m_nRefCount <= 0 )
     740             :     {
     741           0 :         delete m_pStaticDataContainer;
     742           0 :         m_pStaticDataContainer = NULL;
     743           0 :         pPrinterOptionsDataContainer = NULL;
     744           0 :     }
     745           0 : }
     746             : 
     747           0 : SvtPrintFileOptions::SvtPrintFileOptions()
     748             : {
     749             :     // Global access, must be guarded (multithreading!).
     750           0 :     MutexGuard aGuard( GetOwnStaticMutex() );
     751             :     // Increase our refcount ...
     752           0 :     ++m_nRefCount;
     753             :     // ... and initialize our data container only if it not already!
     754           0 :     if( m_pStaticDataContainer == NULL )
     755             :     {
     756           0 :         OUString aRootPath( ROOTNODE_START );
     757           0 :         m_pStaticDataContainer = new SvtPrintOptions_Impl( aRootPath += "/File" );
     758           0 :         pPrintFileOptionsDataContainer = m_pStaticDataContainer;
     759             : 
     760           0 :         svtools::ItemHolder2::holdConfigItem(E_PRINTFILEOPTIONS);
     761             :     }
     762             : 
     763           0 :     SetDataContainer( m_pStaticDataContainer );
     764           0 : }
     765             : 
     766           0 : SvtPrintFileOptions::~SvtPrintFileOptions()
     767             : {
     768             :     // Global access, must be guarded (multithreading!)
     769           0 :     MutexGuard aGuard( GetOwnStaticMutex() );
     770             :     // Decrease our refcount.
     771           0 :     --m_nRefCount;
     772             :     // If last instance was deleted ...
     773             :     // we must destroy our static data container!
     774           0 :     if( m_nRefCount <= 0 )
     775             :     {
     776           0 :         delete m_pStaticDataContainer;
     777           0 :         m_pStaticDataContainer = NULL;
     778           0 :         pPrintFileOptionsDataContainer = NULL;
     779           0 :     }
     780           0 : }
     781             : 
     782             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11