fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / svtools / source / config / printoptions.cxx
blobebd578c7dddc8b0448342c112e1badd881c87bcc
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
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>
32 #include <comphelper/configurationhelper.hxx>
33 #include <comphelper/processfactory.hxx>
34 #include <comphelper/string.hxx>
36 #include "itemholder2.hxx"
38 #include <sal/macros.h>
40 static sal_uInt16 aDPIArray[] = { 72, 96, 150, 200, 300, 600 };
42 #define DPI_COUNT (SAL_N_ELEMENTS(aDPIArray))
44 #define ROOTNODE_START OUString("Office.Common/Print/Option")
45 #define ROOTNODE_PRINTOPTION OUString("org.openoffice.Office.Common/Print/Option")
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")
59 using namespace ::utl;
60 using namespace ::osl;
61 using namespace ::com::sun::star::uno;
63 static SvtPrintOptions_Impl* pPrinterOptionsDataContainer = NULL;
64 static SvtPrintOptions_Impl* pPrintFileOptionsDataContainer = NULL;
66 SvtPrintOptions_Impl* SvtPrinterOptions::m_pStaticDataContainer = NULL;
67 sal_Int32 SvtPrinterOptions::m_nRefCount = 0;
69 SvtPrintOptions_Impl* SvtPrintFileOptions::m_pStaticDataContainer = NULL;
70 sal_Int32 SvtPrintFileOptions::m_nRefCount = 0;
72 class SvtPrintOptions_Impl
74 public:
75 SvtPrintOptions_Impl( const OUString& rConfigRoot );
76 ~SvtPrintOptions_Impl();
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;
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 ) ;
103 // private API
106 private:
107 void impl_setValue (const OUString& sProp, bool bNew );
108 void impl_setValue (const OUString& sProp, sal_Int16 nNew );
111 // private member
114 private:
115 css::uno::Reference< css::container::XNameAccess > m_xCfg;
116 css::uno::Reference< css::container::XNameAccess > m_xNode;
119 SvtPrintOptions_Impl::SvtPrintOptions_Impl(const OUString& rConfigRoot)
123 m_xCfg = css::uno::Reference< css::container::XNameAccess >(
124 ::comphelper::ConfigurationHelper::openConfig(
125 comphelper::getProcessComponentContext(),
126 ROOTNODE_PRINTOPTION,
127 ::comphelper::ConfigurationHelper::E_STANDARD),
128 css::uno::UNO_QUERY);
130 if (m_xCfg.is())
132 using comphelper::string::getTokenCount;
133 sal_Int32 nTokenCount = getTokenCount(rConfigRoot, '/');
134 OUString sTok = rConfigRoot.getToken(nTokenCount - 1, '/');
135 m_xCfg->getByName(sTok) >>= m_xNode;
138 catch (const css::uno::Exception& ex)
140 m_xNode.clear();
141 m_xCfg.clear();
142 SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
146 bool SvtPrintOptions_Impl::IsReduceTransparency() const
148 bool bRet = false;
151 if (m_xNode.is())
153 css::uno::Reference< css::beans::XPropertySet > xSet(m_xNode, css::uno::UNO_QUERY);
154 if (xSet.is())
155 xSet->getPropertyValue(PROPERTYNAME_REDUCETRANSPARENCY) >>= bRet;
158 catch (const css::uno::Exception& ex)
160 SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
163 return bRet;
166 sal_Int16 SvtPrintOptions_Impl::GetReducedTransparencyMode() const
168 sal_Int16 nRet = 0;
171 if (m_xNode.is())
173 css::uno::Reference< css::beans::XPropertySet > xSet(m_xNode, css::uno::UNO_QUERY);
174 if (xSet.is())
175 xSet->getPropertyValue(PROPERTYNAME_REDUCEDTRANSPARENCYMODE) >>= nRet;
178 catch (const css::uno::Exception& ex)
180 SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
183 return nRet;
186 bool SvtPrintOptions_Impl::IsReduceGradients() const
188 bool bRet = false;
191 if (m_xNode.is())
193 css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
194 if (xSet.is())
196 xSet->getPropertyValue(PROPERTYNAME_REDUCEGRADIENTS) >>= bRet;
200 catch (const css::uno::Exception& ex)
202 SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
205 return bRet;
208 sal_Int16 SvtPrintOptions_Impl::GetReducedGradientMode() const
210 sal_Int16 nRet = 0;
213 if (m_xNode.is())
215 css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
216 if (xSet.is())
218 xSet->getPropertyValue(PROPERTYNAME_REDUCEDGRADIENTMODE) >>= nRet;
222 catch (const css::uno::Exception& ex)
224 SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
227 return nRet;
230 sal_Int16 SvtPrintOptions_Impl::GetReducedGradientStepCount() const
232 sal_Int16 nRet = 64;
235 if (m_xNode.is())
237 css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
238 if (xSet.is())
240 xSet->getPropertyValue(PROPERTYNAME_REDUCEDGRADIENTSTEPCOUNT) >>= nRet;
244 catch (const css::uno::Exception& ex)
246 SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
249 return nRet;
252 bool SvtPrintOptions_Impl::IsReduceBitmaps() const
254 bool bRet = false;
257 if (m_xNode.is())
259 css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
260 if (xSet.is())
262 xSet->getPropertyValue(PROPERTYNAME_REDUCEBITMAPS) >>= bRet;
266 catch (const css::uno::Exception& ex)
268 SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
271 return bRet;
274 sal_Int16 SvtPrintOptions_Impl::GetReducedBitmapMode() const
276 sal_Int16 nRet = 1;
279 if (m_xNode.is())
281 css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
282 if (xSet.is())
284 xSet->getPropertyValue(PROPERTYNAME_REDUCEDBITMAPMODE) >>= nRet;
288 catch (const css::uno::Exception& ex)
290 SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
293 return nRet;
296 sal_Int16 SvtPrintOptions_Impl::GetReducedBitmapResolution() const
298 sal_Int16 nRet = 3;
301 if (m_xNode.is())
303 css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
304 if (xSet.is())
306 xSet->getPropertyValue(PROPERTYNAME_REDUCEDBITMAPRESOLUTION) >>= nRet;
310 catch (const css::uno::Exception& ex)
312 SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
315 return nRet;
318 bool SvtPrintOptions_Impl::IsReducedBitmapIncludesTransparency() const
320 bool bRet = true;
323 if (m_xNode.is())
325 css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
326 if (xSet.is())
328 xSet->getPropertyValue(PROPERTYNAME_REDUCEDBITMAPINCLUDESTRANSPARENCY) >>= bRet;
332 catch (const css::uno::Exception& ex)
334 SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
337 return bRet;
340 bool SvtPrintOptions_Impl::IsConvertToGreyscales() const
342 bool bRet = false;
345 if (m_xNode.is())
347 css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
348 if (xSet.is())
350 xSet->getPropertyValue(PROPERTYNAME_CONVERTTOGREYSCALES) >>= bRet;
354 catch (const css::uno::Exception& ex)
356 SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
359 return bRet;
363 bool SvtPrintOptions_Impl::IsPDFAsStandardPrintJobFormat() const
365 bool bRet = true;
368 if (m_xNode.is())
370 css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
371 if (xSet.is())
373 xSet->getPropertyValue(PROPERTYNAME_PDFASSTANDARDPRINTJOBFORMAT) >>= bRet;
377 catch (const css::uno::Exception& ex)
379 SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
382 return bRet;
385 void SvtPrintOptions_Impl::SetReduceTransparency(bool bState)
387 impl_setValue(PROPERTYNAME_REDUCETRANSPARENCY, bState);
390 void SvtPrintOptions_Impl::SetReducedTransparencyMode(sal_Int16 nMode)
392 impl_setValue(PROPERTYNAME_REDUCEDTRANSPARENCYMODE, nMode);
395 void SvtPrintOptions_Impl::SetReduceGradients(bool bState)
397 impl_setValue(PROPERTYNAME_REDUCEGRADIENTS, bState);
400 void SvtPrintOptions_Impl::SetReducedGradientMode(sal_Int16 nMode)
402 impl_setValue(PROPERTYNAME_REDUCEDGRADIENTMODE, nMode);
405 void SvtPrintOptions_Impl::SetReducedGradientStepCount(sal_Int16 nStepCount )
407 impl_setValue(PROPERTYNAME_REDUCEDGRADIENTSTEPCOUNT, nStepCount);
410 void SvtPrintOptions_Impl::SetReduceBitmaps(bool bState )
412 impl_setValue(PROPERTYNAME_REDUCEBITMAPS, bState);
415 void SvtPrintOptions_Impl::SetReducedBitmapMode(sal_Int16 nMode )
417 impl_setValue(PROPERTYNAME_REDUCEDBITMAPMODE, nMode);
420 void SvtPrintOptions_Impl::SetReducedBitmapResolution(sal_Int16 nResolution )
422 impl_setValue(PROPERTYNAME_REDUCEDBITMAPRESOLUTION, nResolution);
425 void SvtPrintOptions_Impl::SetReducedBitmapIncludesTransparency(bool bState )
427 impl_setValue(PROPERTYNAME_REDUCEDBITMAPINCLUDESTRANSPARENCY, bState);
430 void SvtPrintOptions_Impl::SetConvertToGreyscales(bool bState)
432 impl_setValue(PROPERTYNAME_CONVERTTOGREYSCALES, bState);
435 void SvtPrintOptions_Impl::SetPDFAsStandardPrintJobFormat(bool bState)
437 impl_setValue(PROPERTYNAME_PDFASSTANDARDPRINTJOBFORMAT, bState);
440 SvtPrintOptions_Impl::~SvtPrintOptions_Impl()
442 m_xNode.clear();
443 m_xCfg.clear();
446 void SvtPrintOptions_Impl::impl_setValue (const OUString& sProp, bool bNew )
450 if ( ! m_xNode.is())
451 return;
453 css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
454 if ( ! xSet.is())
455 return;
457 bool bOld = ! bNew;
458 if ( ! (xSet->getPropertyValue(sProp) >>= bOld))
459 return;
461 if (bOld != bNew)
463 xSet->setPropertyValue(sProp, css::uno::makeAny(bNew));
464 ::comphelper::ConfigurationHelper::flush(m_xCfg);
467 catch(const css::uno::Exception& ex)
469 SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
473 void SvtPrintOptions_Impl::impl_setValue (const OUString& sProp,
474 ::sal_Int16 nNew )
478 if ( ! m_xNode.is())
479 return;
481 css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
482 if ( ! xSet.is())
483 return;
485 ::sal_Int16 nOld = nNew+1;
486 if ( ! (xSet->getPropertyValue(sProp) >>= nOld))
487 return;
489 if (nOld != nNew)
491 xSet->setPropertyValue(sProp, css::uno::makeAny(nNew));
492 ::comphelper::ConfigurationHelper::flush(m_xCfg);
495 catch(const css::uno::Exception& ex)
497 SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
501 SvtBasePrintOptions::SvtBasePrintOptions()
502 : m_pDataContainer(NULL)
506 SvtBasePrintOptions::~SvtBasePrintOptions()
510 Mutex& SvtBasePrintOptions::GetOwnStaticMutex()
512 // Initialize static mutex only for one time!
513 static Mutex* pMutex = NULL;
514 // If these method first called (Mutex not already exist!) ...
515 if( pMutex == NULL )
517 // ... we must create a new one. Protect follow code with the global mutex -
518 // It must be - we create a static variable!
519 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 if( pMutex == NULL )
523 // Create the new mutex and set it for return on static variable.
524 static Mutex aMutex;
525 pMutex = &aMutex;
528 // Return new created or already existing mutex object.
529 return *pMutex;
532 bool SvtBasePrintOptions::IsReduceTransparency() const
534 MutexGuard aGuard( GetOwnStaticMutex() );
535 return m_pDataContainer->IsReduceTransparency();
538 sal_Int16 SvtBasePrintOptions::GetReducedTransparencyMode() const
540 MutexGuard aGuard( GetOwnStaticMutex() );
541 return m_pDataContainer->GetReducedTransparencyMode();
544 bool SvtBasePrintOptions::IsReduceGradients() const
546 MutexGuard aGuard( GetOwnStaticMutex() );
547 return m_pDataContainer->IsReduceGradients();
550 sal_Int16 SvtBasePrintOptions::GetReducedGradientMode() const
552 MutexGuard aGuard( GetOwnStaticMutex() );
553 return m_pDataContainer->GetReducedGradientMode();
556 sal_Int16 SvtBasePrintOptions::GetReducedGradientStepCount() const
558 MutexGuard aGuard( GetOwnStaticMutex() );
559 return m_pDataContainer->GetReducedGradientStepCount();
562 bool SvtBasePrintOptions::IsReduceBitmaps() const
564 MutexGuard aGuard( GetOwnStaticMutex() );
565 return m_pDataContainer->IsReduceBitmaps();
568 sal_Int16 SvtBasePrintOptions::GetReducedBitmapMode() const
570 MutexGuard aGuard( GetOwnStaticMutex() );
571 return m_pDataContainer->GetReducedBitmapMode();
574 sal_Int16 SvtBasePrintOptions::GetReducedBitmapResolution() const
576 MutexGuard aGuard( GetOwnStaticMutex() );
577 return m_pDataContainer->GetReducedBitmapResolution();
580 bool SvtBasePrintOptions::IsReducedBitmapIncludesTransparency() const
582 MutexGuard aGuard( GetOwnStaticMutex() );
583 return m_pDataContainer->IsReducedBitmapIncludesTransparency();
586 bool SvtBasePrintOptions::IsConvertToGreyscales() const
588 MutexGuard aGuard( GetOwnStaticMutex() );
589 return m_pDataContainer->IsConvertToGreyscales();
592 bool SvtBasePrintOptions::IsPDFAsStandardPrintJobFormat() const
594 MutexGuard aGuard( GetOwnStaticMutex() );
595 return m_pDataContainer->IsPDFAsStandardPrintJobFormat();
598 void SvtBasePrintOptions::SetReduceTransparency( bool bState )
600 MutexGuard aGuard( GetOwnStaticMutex() );
601 m_pDataContainer->SetReduceTransparency( bState ) ;
604 void SvtBasePrintOptions::SetReducedTransparencyMode( sal_Int16 nMode )
606 MutexGuard aGuard( GetOwnStaticMutex() );
607 m_pDataContainer->SetReducedTransparencyMode( nMode );
610 void SvtBasePrintOptions::SetReduceGradients( bool bState )
612 MutexGuard aGuard( GetOwnStaticMutex() );
613 m_pDataContainer->SetReduceGradients( bState );
616 void SvtBasePrintOptions::SetReducedGradientMode( sal_Int16 nMode )
618 MutexGuard aGuard( GetOwnStaticMutex() );
619 m_pDataContainer->SetReducedGradientMode( nMode );
622 void SvtBasePrintOptions::SetReducedGradientStepCount( sal_Int16 nStepCount )
624 MutexGuard aGuard( GetOwnStaticMutex() );
625 m_pDataContainer->SetReducedGradientStepCount( nStepCount );
628 void SvtBasePrintOptions::SetReduceBitmaps( bool bState )
630 MutexGuard aGuard( GetOwnStaticMutex() );
631 m_pDataContainer->SetReduceBitmaps( bState );
634 void SvtBasePrintOptions::SetReducedBitmapMode( sal_Int16 nMode )
636 MutexGuard aGuard( GetOwnStaticMutex() );
637 m_pDataContainer->SetReducedBitmapMode( nMode );
640 void SvtBasePrintOptions::SetReducedBitmapResolution( sal_Int16 nResolution )
642 MutexGuard aGuard( GetOwnStaticMutex() );
643 m_pDataContainer->SetReducedBitmapResolution( nResolution );
646 void SvtBasePrintOptions::SetReducedBitmapIncludesTransparency( bool bState )
648 MutexGuard aGuard( GetOwnStaticMutex() );
649 m_pDataContainer->SetReducedBitmapIncludesTransparency( bState );
652 void SvtBasePrintOptions::SetConvertToGreyscales( bool bState )
654 MutexGuard aGuard( GetOwnStaticMutex() );
655 m_pDataContainer->SetConvertToGreyscales( bState );
658 void SvtBasePrintOptions::SetPDFAsStandardPrintJobFormat( bool bState )
660 MutexGuard aGuard( GetOwnStaticMutex() );
661 m_pDataContainer->SetPDFAsStandardPrintJobFormat( bState );
664 void SvtBasePrintOptions::GetPrinterOptions( PrinterOptions& rOptions ) const
666 rOptions.SetReduceTransparency( IsReduceTransparency() );
667 rOptions.SetReducedTransparencyMode( (PrinterTransparencyMode) GetReducedTransparencyMode() );
668 rOptions.SetReduceGradients( IsReduceGradients() );
669 rOptions.SetReducedGradientMode( (PrinterGradientMode) GetReducedGradientMode() );
670 rOptions.SetReducedGradientStepCount( GetReducedGradientStepCount() );
671 rOptions.SetReduceBitmaps( IsReduceBitmaps() );
672 rOptions.SetReducedBitmapMode( (PrinterBitmapMode) GetReducedBitmapMode() );
673 rOptions.SetReducedBitmapResolution( aDPIArray[ std::min( (sal_uInt16) GetReducedBitmapResolution(), (sal_uInt16)( DPI_COUNT - 1 ) ) ] );
674 rOptions.SetReducedBitmapIncludesTransparency( IsReducedBitmapIncludesTransparency() );
675 rOptions.SetConvertToGreyscales( IsConvertToGreyscales() );
676 rOptions.SetPDFAsStandardPrintJobFormat( IsPDFAsStandardPrintJobFormat() );
679 void SvtBasePrintOptions::SetPrinterOptions( const PrinterOptions& rOptions )
681 SetReduceTransparency( rOptions.IsReduceTransparency() );
682 SetReducedTransparencyMode(
683 sal::static_int_cast< sal_Int16 >(
684 rOptions.GetReducedTransparencyMode()) );
685 SetReduceGradients( rOptions.IsReduceGradients() );
686 SetReducedGradientMode(
687 sal::static_int_cast< sal_Int16 >(rOptions.GetReducedGradientMode()) );
688 SetReducedGradientStepCount( rOptions.GetReducedGradientStepCount() );
689 SetReduceBitmaps( rOptions.IsReduceBitmaps() );
690 SetReducedBitmapMode(
691 sal::static_int_cast< sal_Int16 >(rOptions.GetReducedBitmapMode()) );
692 SetReducedBitmapIncludesTransparency( rOptions.IsReducedBitmapIncludesTransparency() );
693 SetConvertToGreyscales( rOptions.IsConvertToGreyscales() );
694 SetPDFAsStandardPrintJobFormat( rOptions.IsPDFAsStandardPrintJobFormat() );
696 const sal_uInt16 nDPI = rOptions.GetReducedBitmapResolution();
698 if( nDPI < aDPIArray[ 0 ] )
699 SetReducedBitmapResolution( 0 );
700 else
702 for( long i = ( DPI_COUNT - 1 ); i >= 0; i-- )
704 if( nDPI >= aDPIArray[ i ] )
706 SetReducedBitmapResolution( (sal_Int16) i );
707 i = -1;
713 SvtPrinterOptions::SvtPrinterOptions()
715 // Global access, must be guarded (multithreading!).
716 MutexGuard aGuard( GetOwnStaticMutex() );
717 // Increase our refcount ...
718 ++m_nRefCount;
719 // ... and initialize our data container only if it not already!
720 if( m_pStaticDataContainer == NULL )
722 OUString aRootPath( ROOTNODE_START );
723 m_pStaticDataContainer = new SvtPrintOptions_Impl( aRootPath += "/Printer" );
724 pPrinterOptionsDataContainer = m_pStaticDataContainer;
725 svtools::ItemHolder2::holdConfigItem(E_PRINTOPTIONS);
728 SetDataContainer( m_pStaticDataContainer );
731 SvtPrinterOptions::~SvtPrinterOptions()
733 // Global access, must be guarded (multithreading!)
734 MutexGuard aGuard( GetOwnStaticMutex() );
735 // Decrease our refcount.
736 --m_nRefCount;
737 // If last instance was deleted ...
738 // we must destroy our static data container!
739 if( m_nRefCount <= 0 )
741 delete m_pStaticDataContainer;
742 m_pStaticDataContainer = NULL;
743 pPrinterOptionsDataContainer = NULL;
747 SvtPrintFileOptions::SvtPrintFileOptions()
749 // Global access, must be guarded (multithreading!).
750 MutexGuard aGuard( GetOwnStaticMutex() );
751 // Increase our refcount ...
752 ++m_nRefCount;
753 // ... and initialize our data container only if it not already!
754 if( m_pStaticDataContainer == NULL )
756 OUString aRootPath( ROOTNODE_START );
757 m_pStaticDataContainer = new SvtPrintOptions_Impl( aRootPath += "/File" );
758 pPrintFileOptionsDataContainer = m_pStaticDataContainer;
760 svtools::ItemHolder2::holdConfigItem(E_PRINTFILEOPTIONS);
763 SetDataContainer( m_pStaticDataContainer );
766 SvtPrintFileOptions::~SvtPrintFileOptions()
768 // Global access, must be guarded (multithreading!)
769 MutexGuard aGuard( GetOwnStaticMutex() );
770 // Decrease our refcount.
771 --m_nRefCount;
772 // If last instance was deleted ...
773 // we must destroy our static data container!
774 if( m_nRefCount <= 0 )
776 delete m_pStaticDataContainer;
777 m_pStaticDataContainer = NULL;
778 pPrintFileOptionsDataContainer = NULL;
782 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */