merge the formfield patch from ooo-build
[ooovba.git] / svtools / source / config / printoptions.cxx
blobcb1375bf2d7a7003f6767933703e036cff0c542a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: printoptions.cxx,v $
10 * $Revision: 1.14.236.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
34 #ifdef SVL_DLLIMPLEMENTATION
35 #undef SVL_DLLIMPLEMENTATION
36 #endif
37 #define SVT_DLLIMPLEMENTATION
39 //_________________________________________________________________________________________________________________
40 // includes
41 //_________________________________________________________________________________________________________________
43 #include <svtools/printoptions.hxx>
44 #include <unotools/configmgr.hxx>
45 #include <unotools/configitem.hxx>
46 #include <tools/debug.hxx>
47 #include <vcl/print.hxx>
48 #include <com/sun/star/uno/Any.hxx>
49 #include <com/sun/star/uno/Sequence.hxx>
51 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
52 #include <com/sun/star/beans/XPropertySet.hpp>
53 #endif
55 #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
56 #include <com/sun/star/container/XNameAccess.hpp>
57 #endif
59 #ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
60 #include <com/sun/star/container/XNameContainer.hpp>
61 #endif
63 #ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
64 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
65 #endif
67 #ifndef _COMPHELPER_CONFIGURATIONHELPER_HXX_
68 #include <comphelper/configurationhelper.hxx>
69 #endif
71 #ifndef _UNOTOOLS_PROCESSFACTORY_HXX_
72 #include <unotools/processfactory.hxx>
73 #endif
75 #ifndef _SVT_LOGHELPER_HXX
76 #include <loghelper.hxx>
77 #endif
79 #include <itemholder2.hxx>
82 // -----------
83 // - statics -
84 // -----------
86 static USHORT aDPIArray[] = { 72, 96, 150, 200, 300, 600 };
88 #define DPI_COUNT (sizeof(aDPIArray)/sizeof(aDPIArray[0 ]))
90 // -----------
91 // - Defines -
92 // -----------
94 #define ROOTNODE_START OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/Print/Option"))
95 #define ROOTNODE_PRINTOPTION OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.Common/Print/Option"))
97 #define PROPERTYNAME_REDUCETRANSPARENCY OUString(RTL_CONSTASCII_USTRINGPARAM("ReduceTransparency"))
98 #define PROPERTYNAME_REDUCEDTRANSPARENCYMODE OUString(RTL_CONSTASCII_USTRINGPARAM("ReducedTransparencyMode"))
99 #define PROPERTYNAME_REDUCEGRADIENTS OUString(RTL_CONSTASCII_USTRINGPARAM("ReduceGradients"))
100 #define PROPERTYNAME_REDUCEDGRADIENTMODE OUString(RTL_CONSTASCII_USTRINGPARAM("ReducedGradientMode"))
101 #define PROPERTYNAME_REDUCEDGRADIENTSTEPCOUNT OUString(RTL_CONSTASCII_USTRINGPARAM("ReducedGradientStepCount"))
102 #define PROPERTYNAME_REDUCEBITMAPS OUString(RTL_CONSTASCII_USTRINGPARAM("ReduceBitmaps"))
103 #define PROPERTYNAME_REDUCEDBITMAPMODE OUString(RTL_CONSTASCII_USTRINGPARAM("ReducedBitmapMode"))
104 #define PROPERTYNAME_REDUCEDBITMAPRESOLUTION OUString(RTL_CONSTASCII_USTRINGPARAM("ReducedBitmapResolution"))
105 #define PROPERTYNAME_REDUCEDBITMAPINCLUDESTRANSPARENCY OUString(RTL_CONSTASCII_USTRINGPARAM("ReducedBitmapIncludesTransparency"))
106 #define PROPERTYNAME_CONVERTTOGREYSCALES OUString(RTL_CONSTASCII_USTRINGPARAM("ConvertToGreyscales"))
108 // --------------
109 // - Namespaces -
110 // --------------
112 using namespace ::utl;
113 using namespace ::rtl;
114 using namespace ::osl;
115 using namespace ::com::sun::star::uno;
116 namespace css = com::sun::star;
118 // -----------
119 // - statics -
120 // -----------
122 static SvtPrintOptions_Impl* pPrinterOptionsDataContainer = NULL;
123 static SvtPrintOptions_Impl* pPrintFileOptionsDataContainer = NULL;
125 SvtPrintOptions_Impl* SvtPrinterOptions::m_pStaticDataContainer = NULL;
126 sal_Int32 SvtPrinterOptions::m_nRefCount = 0;
128 SvtPrintOptions_Impl* SvtPrintFileOptions::m_pStaticDataContainer = NULL;
129 sal_Int32 SvtPrintFileOptions::m_nRefCount = 0;
131 // ------------------------
132 // - SvtPrintOptions_Impl -
133 // ------------------------
135 class SvtPrintOptions_Impl
137 public:
139 //---------------------------------------------------------------------------------------------------------
140 // constructor / destructor
141 //---------------------------------------------------------------------------------------------------------
143 SvtPrintOptions_Impl( const OUString& rConfigRoot );
144 ~SvtPrintOptions_Impl();
146 //---------------------------------------------------------------------------------------------------------
147 // public interface
148 //---------------------------------------------------------------------------------------------------------
150 sal_Bool IsReduceTransparency() const ;
151 sal_Int16 GetReducedTransparencyMode() const ;
152 sal_Bool IsReduceGradients() const ;
153 sal_Int16 GetReducedGradientMode() const ;
154 sal_Int16 GetReducedGradientStepCount() const ;
155 sal_Bool IsReduceBitmaps() const ;
156 sal_Int16 GetReducedBitmapMode() const ;
157 sal_Int16 GetReducedBitmapResolution() const ;
158 sal_Bool IsReducedBitmapIncludesTransparency() const ;
159 sal_Bool IsConvertToGreyscales() const;
161 void SetReduceTransparency( sal_Bool bState ) ;
162 void SetReducedTransparencyMode( sal_Int16 nMode ) ;
163 void SetReduceGradients( sal_Bool bState ) ;
164 void SetReducedGradientMode( sal_Int16 nMode ) ;
165 void SetReducedGradientStepCount( sal_Int16 nStepCount ) ;
166 void SetReduceBitmaps( sal_Bool bState ) ;
167 void SetReducedBitmapMode( sal_Int16 nMode ) ;
168 void SetReducedBitmapResolution( sal_Int16 nResolution ) ;
169 void SetReducedBitmapIncludesTransparency( sal_Bool bState ) ;
170 void SetConvertToGreyscales( sal_Bool bState ) ;
172 //-------------------------------------------------------------------------------------------------------------
173 // private API
174 //-------------------------------------------------------------------------------------------------------------
176 private:
177 void impl_setValue (const ::rtl::OUString& sProp,
178 ::sal_Bool bNew );
179 void impl_setValue (const ::rtl::OUString& sProp,
180 ::sal_Int16 nNew );
182 //-------------------------------------------------------------------------------------------------------------
183 // private member
184 //-------------------------------------------------------------------------------------------------------------
186 private:
187 css::uno::Reference< css::container::XNameAccess > m_xCfg;
188 css::uno::Reference< css::container::XNameAccess > m_xNode;
191 SvtPrintOptions_Impl::SvtPrintOptions_Impl(const OUString& rConfigRoot)
195 m_xCfg = css::uno::Reference< css::container::XNameAccess >(
196 ::comphelper::ConfigurationHelper::openConfig(
197 utl::getProcessServiceFactory(),
198 ROOTNODE_PRINTOPTION,
199 ::comphelper::ConfigurationHelper::E_STANDARD),
200 css::uno::UNO_QUERY);
202 if (m_xCfg.is())
204 UniString sTmp = UniString(rConfigRoot);
205 xub_StrLen nTokenCount = sTmp.GetTokenCount('/');
206 sTmp = sTmp.GetToken(nTokenCount - 1, '/');
207 m_xCfg->getByName(OUString(sTmp.GetBuffer())) >>= m_xNode;
210 catch (const css::uno::Exception& ex)
212 m_xNode.clear();
213 m_xCfg.clear();
214 LogHelper::logIt(ex);
218 sal_Bool SvtPrintOptions_Impl::IsReduceTransparency() const
220 sal_Bool bRet = sal_False;
223 if (m_xNode.is())
225 css::uno::Reference< css::beans::XPropertySet > xSet(m_xNode, css::uno::UNO_QUERY);
226 if (xSet.is())
227 xSet->getPropertyValue(PROPERTYNAME_REDUCETRANSPARENCY) >>= bRet;
230 catch (const css::uno::Exception& ex)
232 LogHelper::logIt(ex);
235 return bRet;
238 sal_Int16 SvtPrintOptions_Impl::GetReducedTransparencyMode() const
240 sal_Int16 nRet = 0;
243 if (m_xNode.is())
245 css::uno::Reference< css::beans::XPropertySet > xSet(m_xNode, css::uno::UNO_QUERY);
246 if (xSet.is())
247 xSet->getPropertyValue(PROPERTYNAME_REDUCEDTRANSPARENCYMODE) >>= nRet;
250 catch (const css::uno::Exception& ex)
252 LogHelper::logIt(ex);
255 return nRet;
258 sal_Bool SvtPrintOptions_Impl::IsReduceGradients() const
260 sal_Bool bRet = sal_False;
263 if (m_xNode.is())
265 css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
266 if (xSet.is())
268 xSet->getPropertyValue(PROPERTYNAME_REDUCEGRADIENTS) >>= bRet;
272 catch (const css::uno::Exception& ex)
274 LogHelper::logIt(ex);
277 return bRet;
280 sal_Int16 SvtPrintOptions_Impl::GetReducedGradientMode() const
282 sal_Int16 nRet = 0;
285 if (m_xNode.is())
287 css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
288 if (xSet.is())
290 xSet->getPropertyValue(PROPERTYNAME_REDUCEDGRADIENTMODE) >>= nRet;
294 catch (const css::uno::Exception& ex)
296 LogHelper::logIt(ex);
299 return nRet;
302 sal_Int16 SvtPrintOptions_Impl::GetReducedGradientStepCount() const
304 sal_Int16 nRet = 64;
307 if (m_xNode.is())
309 css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
310 if (xSet.is())
312 xSet->getPropertyValue(PROPERTYNAME_REDUCEDGRADIENTSTEPCOUNT) >>= nRet;
316 catch (const css::uno::Exception& ex)
318 LogHelper::logIt(ex);
321 return nRet;
324 sal_Bool SvtPrintOptions_Impl::IsReduceBitmaps() const
326 sal_Bool bRet = sal_False;
329 if (m_xNode.is())
331 css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
332 if (xSet.is())
334 xSet->getPropertyValue(PROPERTYNAME_REDUCEBITMAPS) >>= bRet;
338 catch (const css::uno::Exception& ex)
340 LogHelper::logIt(ex);
343 return bRet;
346 sal_Int16 SvtPrintOptions_Impl::GetReducedBitmapMode() const
348 sal_Int16 nRet = 1;
351 if (m_xNode.is())
353 css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
354 if (xSet.is())
356 xSet->getPropertyValue(PROPERTYNAME_REDUCEDBITMAPMODE) >>= nRet;
360 catch (const css::uno::Exception& ex)
362 LogHelper::logIt(ex);
365 return nRet;
368 sal_Int16 SvtPrintOptions_Impl::GetReducedBitmapResolution() const
370 sal_Int16 nRet = 3;
373 if (m_xNode.is())
375 css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
376 if (xSet.is())
378 xSet->getPropertyValue(PROPERTYNAME_REDUCEDBITMAPRESOLUTION) >>= nRet;
382 catch (const css::uno::Exception& ex)
384 LogHelper::logIt(ex);
387 return nRet;
390 sal_Bool SvtPrintOptions_Impl::IsReducedBitmapIncludesTransparency() const
392 sal_Bool bRet = sal_True;
395 if (m_xNode.is())
397 css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
398 if (xSet.is())
400 xSet->getPropertyValue(PROPERTYNAME_REDUCEDBITMAPINCLUDESTRANSPARENCY) >>= bRet;
404 catch (const css::uno::Exception& ex)
406 LogHelper::logIt(ex);
409 return bRet;
412 sal_Bool SvtPrintOptions_Impl::IsConvertToGreyscales() const
414 sal_Bool bRet = sal_False;
417 if (m_xNode.is())
419 css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
420 if (xSet.is())
422 xSet->getPropertyValue(PROPERTYNAME_CONVERTTOGREYSCALES) >>= bRet;
426 catch (const css::uno::Exception& ex)
428 LogHelper::logIt(ex);
431 return bRet;
435 void SvtPrintOptions_Impl::SetReduceTransparency(sal_Bool bState)
437 impl_setValue(PROPERTYNAME_REDUCETRANSPARENCY, bState);
440 void SvtPrintOptions_Impl::SetReducedTransparencyMode(sal_Int16 nMode)
442 impl_setValue(PROPERTYNAME_REDUCEDTRANSPARENCYMODE, nMode);
445 void SvtPrintOptions_Impl::SetReduceGradients(sal_Bool bState)
447 impl_setValue(PROPERTYNAME_REDUCEGRADIENTS, bState);
450 void SvtPrintOptions_Impl::SetReducedGradientMode(sal_Int16 nMode)
452 impl_setValue(PROPERTYNAME_REDUCEDGRADIENTMODE, nMode);
455 void SvtPrintOptions_Impl::SetReducedGradientStepCount(sal_Int16 nStepCount )
457 impl_setValue(PROPERTYNAME_REDUCEDGRADIENTSTEPCOUNT, nStepCount);
460 void SvtPrintOptions_Impl::SetReduceBitmaps(sal_Bool bState )
462 impl_setValue(PROPERTYNAME_REDUCEBITMAPS, bState);
465 void SvtPrintOptions_Impl::SetReducedBitmapMode(sal_Int16 nMode )
467 impl_setValue(PROPERTYNAME_REDUCEDBITMAPMODE, nMode);
470 void SvtPrintOptions_Impl::SetReducedBitmapResolution(sal_Int16 nResolution )
472 impl_setValue(PROPERTYNAME_REDUCEDBITMAPRESOLUTION, nResolution);
475 void SvtPrintOptions_Impl::SetReducedBitmapIncludesTransparency(sal_Bool bState )
477 impl_setValue(PROPERTYNAME_REDUCEDBITMAPINCLUDESTRANSPARENCY, bState);
480 void SvtPrintOptions_Impl::SetConvertToGreyscales(sal_Bool bState)
482 impl_setValue(PROPERTYNAME_CONVERTTOGREYSCALES, bState);
485 SvtPrintOptions_Impl::~SvtPrintOptions_Impl()
487 m_xNode.clear();
488 m_xCfg.clear();
491 void SvtPrintOptions_Impl::impl_setValue (const ::rtl::OUString& sProp,
492 ::sal_Bool bNew )
496 if ( ! m_xNode.is())
497 return;
499 css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
500 if ( ! xSet.is())
501 return;
503 ::sal_Bool bOld = ! bNew;
504 if ( ! (xSet->getPropertyValue(sProp) >>= bOld))
505 return;
507 if (bOld != bNew)
509 xSet->setPropertyValue(sProp, css::uno::makeAny(bNew));
510 ::comphelper::ConfigurationHelper::flush(m_xCfg);
513 catch(const css::uno::Exception& ex)
515 LogHelper::logIt(ex);
519 void SvtPrintOptions_Impl::impl_setValue (const ::rtl::OUString& sProp,
520 ::sal_Int16 nNew )
524 if ( ! m_xNode.is())
525 return;
527 css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
528 if ( ! xSet.is())
529 return;
531 ::sal_Int16 nOld = nNew+1;
532 if ( ! (xSet->getPropertyValue(sProp) >>= nOld))
533 return;
535 if (nOld != nNew)
537 xSet->setPropertyValue(sProp, css::uno::makeAny(nNew));
538 ::comphelper::ConfigurationHelper::flush(m_xCfg);
541 catch(const css::uno::Exception& ex)
543 LogHelper::logIt(ex);
547 // -----------------------------------------------------------------------------
550 // -----------------------
551 // - SvtBasePrintOptions -
552 // -----------------------
554 SvtBasePrintOptions::SvtBasePrintOptions()
558 // -----------------------------------------------------------------------------
560 SvtBasePrintOptions::~SvtBasePrintOptions()
564 // -----------------------------------------------------------------------------
566 Mutex& SvtBasePrintOptions::GetOwnStaticMutex()
568 // Initialize static mutex only for one time!
569 static Mutex* pMutex = NULL;
570 // If these method first called (Mutex not already exist!) ...
571 if( pMutex == NULL )
573 // ... we must create a new one. Protect follow code with the global mutex -
574 // It must be - we create a static variable!
575 MutexGuard aGuard( Mutex::getGlobalMutex() );
576 // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
577 if( pMutex == NULL )
579 // Create the new mutex and set it for return on static variable.
580 static Mutex aMutex;
581 pMutex = &aMutex;
584 // Return new created or already existing mutex object.
585 return *pMutex;
588 // -----------------------------------------------------------------------------
590 sal_Bool SvtBasePrintOptions::IsReduceTransparency() const
592 MutexGuard aGuard( GetOwnStaticMutex() );
593 return m_pDataContainer->IsReduceTransparency();
596 // -----------------------------------------------------------------------------
598 sal_Int16 SvtBasePrintOptions::GetReducedTransparencyMode() const
600 MutexGuard aGuard( GetOwnStaticMutex() );
601 return m_pDataContainer->GetReducedTransparencyMode();
604 // -----------------------------------------------------------------------------
606 sal_Bool SvtBasePrintOptions::IsReduceGradients() const
608 MutexGuard aGuard( GetOwnStaticMutex() );
609 return m_pDataContainer->IsReduceGradients();
612 // -----------------------------------------------------------------------------
614 sal_Int16 SvtBasePrintOptions::GetReducedGradientMode() const
616 MutexGuard aGuard( GetOwnStaticMutex() );
617 return m_pDataContainer->GetReducedGradientMode();
620 // -----------------------------------------------------------------------------
622 sal_Int16 SvtBasePrintOptions::GetReducedGradientStepCount() const
624 MutexGuard aGuard( GetOwnStaticMutex() );
625 return m_pDataContainer->GetReducedGradientStepCount();
628 // -----------------------------------------------------------------------------
630 sal_Bool SvtBasePrintOptions::IsReduceBitmaps() const
632 MutexGuard aGuard( GetOwnStaticMutex() );
633 return m_pDataContainer->IsReduceBitmaps();
636 // -----------------------------------------------------------------------------
638 sal_Int16 SvtBasePrintOptions::GetReducedBitmapMode() const
640 MutexGuard aGuard( GetOwnStaticMutex() );
641 return m_pDataContainer->GetReducedBitmapMode();
644 // -----------------------------------------------------------------------------
646 sal_Int16 SvtBasePrintOptions::GetReducedBitmapResolution() const
648 MutexGuard aGuard( GetOwnStaticMutex() );
649 return m_pDataContainer->GetReducedBitmapResolution();
652 // -----------------------------------------------------------------------------
654 sal_Bool SvtBasePrintOptions::IsReducedBitmapIncludesTransparency() const
656 MutexGuard aGuard( GetOwnStaticMutex() );
657 return m_pDataContainer->IsReducedBitmapIncludesTransparency();
660 // -----------------------------------------------------------------------------
662 sal_Bool SvtBasePrintOptions::IsConvertToGreyscales() const
664 MutexGuard aGuard( GetOwnStaticMutex() );
665 return m_pDataContainer->IsConvertToGreyscales();
668 // -----------------------------------------------------------------------------
670 void SvtBasePrintOptions::SetReduceTransparency( sal_Bool bState )
672 MutexGuard aGuard( GetOwnStaticMutex() );
673 m_pDataContainer->SetReduceTransparency( bState ) ;
676 // -----------------------------------------------------------------------------
678 void SvtBasePrintOptions::SetReducedTransparencyMode( sal_Int16 nMode )
680 MutexGuard aGuard( GetOwnStaticMutex() );
681 m_pDataContainer->SetReducedTransparencyMode( nMode );
684 // -----------------------------------------------------------------------------
686 void SvtBasePrintOptions::SetReduceGradients( sal_Bool bState )
688 MutexGuard aGuard( GetOwnStaticMutex() );
689 m_pDataContainer->SetReduceGradients( bState );
692 // -----------------------------------------------------------------------------
694 void SvtBasePrintOptions::SetReducedGradientMode( sal_Int16 nMode )
696 MutexGuard aGuard( GetOwnStaticMutex() );
697 m_pDataContainer->SetReducedGradientMode( nMode );
700 // -----------------------------------------------------------------------------
702 void SvtBasePrintOptions::SetReducedGradientStepCount( sal_Int16 nStepCount )
704 MutexGuard aGuard( GetOwnStaticMutex() );
705 m_pDataContainer->SetReducedGradientStepCount( nStepCount );
708 // -----------------------------------------------------------------------------
710 void SvtBasePrintOptions::SetReduceBitmaps( sal_Bool bState )
712 MutexGuard aGuard( GetOwnStaticMutex() );
713 m_pDataContainer->SetReduceBitmaps( bState );
716 // -----------------------------------------------------------------------------
718 void SvtBasePrintOptions::SetReducedBitmapMode( sal_Int16 nMode )
720 MutexGuard aGuard( GetOwnStaticMutex() );
721 m_pDataContainer->SetReducedBitmapMode( nMode );
724 // -----------------------------------------------------------------------------
726 void SvtBasePrintOptions::SetReducedBitmapResolution( sal_Int16 nResolution )
728 MutexGuard aGuard( GetOwnStaticMutex() );
729 m_pDataContainer->SetReducedBitmapResolution( nResolution );
732 // -----------------------------------------------------------------------------
734 void SvtBasePrintOptions::SetReducedBitmapIncludesTransparency( sal_Bool bState )
736 MutexGuard aGuard( GetOwnStaticMutex() );
737 m_pDataContainer->SetReducedBitmapIncludesTransparency( bState );
740 // -----------------------------------------------------------------------------
742 void SvtBasePrintOptions::SetConvertToGreyscales( sal_Bool bState )
744 MutexGuard aGuard( GetOwnStaticMutex() );
745 m_pDataContainer->SetConvertToGreyscales( bState );
748 // -----------------------------------------------------------------------------
750 void SvtBasePrintOptions::GetPrinterOptions( PrinterOptions& rOptions ) const
752 rOptions.SetReduceTransparency( IsReduceTransparency() );
753 rOptions.SetReducedTransparencyMode( (PrinterTransparencyMode) GetReducedTransparencyMode() );
754 rOptions.SetReduceGradients( IsReduceGradients() );
755 rOptions.SetReducedGradientMode( (PrinterGradientMode) GetReducedGradientMode() );
756 rOptions.SetReducedGradientStepCount( GetReducedGradientStepCount() );
757 rOptions.SetReduceBitmaps( IsReduceBitmaps() );
758 rOptions.SetReducedBitmapMode( (PrinterBitmapMode) GetReducedBitmapMode() );
759 rOptions.SetReducedBitmapResolution( aDPIArray[ Min( (USHORT) GetReducedBitmapResolution(), (USHORT)( DPI_COUNT - 1 ) ) ] );
760 rOptions.SetReducedBitmapIncludesTransparency( IsReducedBitmapIncludesTransparency() );
761 rOptions.SetConvertToGreyscales( IsConvertToGreyscales() );
764 // -----------------------------------------------------------------------------
766 void SvtBasePrintOptions::SetPrinterOptions( const PrinterOptions& rOptions )
768 SetReduceTransparency( rOptions.IsReduceTransparency() );
769 SetReducedTransparencyMode(
770 sal::static_int_cast< sal_Int16 >(
771 rOptions.GetReducedTransparencyMode()) );
772 SetReduceGradients( rOptions.IsReduceGradients() );
773 SetReducedGradientMode(
774 sal::static_int_cast< sal_Int16 >(rOptions.GetReducedGradientMode()) );
775 SetReducedGradientStepCount( rOptions.GetReducedGradientStepCount() );
776 SetReduceBitmaps( rOptions.IsReduceBitmaps() );
777 SetReducedBitmapMode(
778 sal::static_int_cast< sal_Int16 >(rOptions.GetReducedBitmapMode()) );
779 SetReducedBitmapIncludesTransparency( rOptions.IsReducedBitmapIncludesTransparency() );
780 SetConvertToGreyscales( rOptions.IsConvertToGreyscales() );
782 const USHORT nDPI = rOptions.GetReducedBitmapResolution();
784 if( nDPI < aDPIArray[ 0 ] )
785 SetReducedBitmapResolution( 0 );
786 else
788 for( long i = ( DPI_COUNT - 1 ); i >= 0; i-- )
790 if( nDPI >= aDPIArray[ i ] )
792 SetReducedBitmapResolution( (sal_Int16) i );
793 i = -1;
799 // ---------------------
800 // - SvtPrinterOptions -
801 // ---------------------
803 SvtPrinterOptions::SvtPrinterOptions()
805 // Global access, must be guarded (multithreading!).
806 MutexGuard aGuard( GetOwnStaticMutex() );
807 // Increase ouer refcount ...
808 ++m_nRefCount;
809 // ... and initialize ouer data container only if it not already!
810 if( m_pStaticDataContainer == NULL )
812 OUString aRootPath( ROOTNODE_START );
813 m_pStaticDataContainer = new SvtPrintOptions_Impl( aRootPath += OUString( RTL_CONSTASCII_USTRINGPARAM( "/Printer" ) ) );
814 pPrinterOptionsDataContainer = m_pStaticDataContainer;
815 ItemHolder2::holdConfigItem(E_PRINTOPTIONS);
818 SetDataContainer( m_pStaticDataContainer );
821 // -----------------------------------------------------------------------------
823 SvtPrinterOptions::~SvtPrinterOptions()
825 // Global access, must be guarded (multithreading!)
826 MutexGuard aGuard( GetOwnStaticMutex() );
827 // Decrease ouer refcount.
828 --m_nRefCount;
829 // If last instance was deleted ...
830 // we must destroy ouer static data container!
831 if( m_nRefCount <= 0 )
833 delete m_pStaticDataContainer;
834 m_pStaticDataContainer = NULL;
835 pPrinterOptionsDataContainer = NULL;
839 // ---------------------
840 // - SvtPrintFileOptions -
841 // ---------------------
843 SvtPrintFileOptions::SvtPrintFileOptions()
845 // Global access, must be guarded (multithreading!).
846 MutexGuard aGuard( GetOwnStaticMutex() );
847 // Increase ouer refcount ...
848 ++m_nRefCount;
849 // ... and initialize ouer data container only if it not already!
850 if( m_pStaticDataContainer == NULL )
852 OUString aRootPath( ROOTNODE_START );
853 m_pStaticDataContainer = new SvtPrintOptions_Impl( aRootPath += OUString( RTL_CONSTASCII_USTRINGPARAM( "/File" ) ) );
854 pPrintFileOptionsDataContainer = m_pStaticDataContainer;
856 ItemHolder2::holdConfigItem(E_PRINTFILEOPTIONS);
859 SetDataContainer( m_pStaticDataContainer );
862 // -----------------------------------------------------------------------------
864 SvtPrintFileOptions::~SvtPrintFileOptions()
866 // Global access, must be guarded (multithreading!)
867 MutexGuard aGuard( GetOwnStaticMutex() );
868 // Decrease ouer refcount.
869 --m_nRefCount;
870 // If last instance was deleted ...
871 // we must destroy ouer static data container!
872 if( m_nRefCount <= 0 )
874 delete m_pStaticDataContainer;
875 m_pStaticDataContainer = NULL;
876 pPrintFileOptionsDataContainer = NULL;