1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 ::rtl
;
61 using namespace ::osl
;
62 using namespace ::com::sun::star::uno
;
64 static SvtPrintOptions_Impl
* pPrinterOptionsDataContainer
= NULL
;
65 static SvtPrintOptions_Impl
* pPrintFileOptionsDataContainer
= NULL
;
67 SvtPrintOptions_Impl
* SvtPrinterOptions::m_pStaticDataContainer
= NULL
;
68 sal_Int32
SvtPrinterOptions::m_nRefCount
= 0;
70 SvtPrintOptions_Impl
* SvtPrintFileOptions::m_pStaticDataContainer
= NULL
;
71 sal_Int32
SvtPrintFileOptions::m_nRefCount
= 0;
73 class SvtPrintOptions_Impl
76 SvtPrintOptions_Impl( const OUString
& rConfigRoot
);
77 ~SvtPrintOptions_Impl();
79 sal_Bool
IsReduceTransparency() const ;
80 sal_Int16
GetReducedTransparencyMode() const ;
81 sal_Bool
IsReduceGradients() const ;
82 sal_Int16
GetReducedGradientMode() const ;
83 sal_Int16
GetReducedGradientStepCount() const ;
84 sal_Bool
IsReduceBitmaps() const ;
85 sal_Int16
GetReducedBitmapMode() const ;
86 sal_Int16
GetReducedBitmapResolution() const ;
87 sal_Bool
IsReducedBitmapIncludesTransparency() const ;
88 sal_Bool
IsConvertToGreyscales() const;
89 sal_Bool
IsPDFAsStandardPrintJobFormat() const;
91 void SetReduceTransparency( sal_Bool bState
) ;
92 void SetReducedTransparencyMode( sal_Int16 nMode
) ;
93 void SetReduceGradients( sal_Bool bState
) ;
94 void SetReducedGradientMode( sal_Int16 nMode
) ;
95 void SetReducedGradientStepCount( sal_Int16 nStepCount
) ;
96 void SetReduceBitmaps( sal_Bool bState
) ;
97 void SetReducedBitmapMode( sal_Int16 nMode
) ;
98 void SetReducedBitmapResolution( sal_Int16 nResolution
) ;
99 void SetReducedBitmapIncludesTransparency( sal_Bool bState
) ;
100 void SetConvertToGreyscales( sal_Bool bState
) ;
101 void SetPDFAsStandardPrintJobFormat( sal_Bool bState
) ;
103 //-------------------------------------------------------------------------------------------------------------
105 //-------------------------------------------------------------------------------------------------------------
108 void impl_setValue (const OUString
& sProp
,
110 void impl_setValue (const OUString
& sProp
,
113 //-------------------------------------------------------------------------------------------------------------
115 //-------------------------------------------------------------------------------------------------------------
118 css::uno::Reference
< css::container::XNameAccess
> m_xCfg
;
119 css::uno::Reference
< css::container::XNameAccess
> m_xNode
;
122 SvtPrintOptions_Impl::SvtPrintOptions_Impl(const OUString
& rConfigRoot
)
126 m_xCfg
= css::uno::Reference
< css::container::XNameAccess
>(
127 ::comphelper::ConfigurationHelper::openConfig(
128 comphelper::getProcessComponentContext(),
129 ROOTNODE_PRINTOPTION
,
130 ::comphelper::ConfigurationHelper::E_STANDARD
),
131 css::uno::UNO_QUERY
);
135 using comphelper::string::getTokenCount
;
136 using comphelper::string::getToken
;
137 sal_Int32 nTokenCount
= getTokenCount(rConfigRoot
, '/');
138 OUString sTok
= getToken(rConfigRoot
, nTokenCount
- 1, '/');
139 m_xCfg
->getByName(sTok
) >>= m_xNode
;
142 catch (const css::uno::Exception
& ex
)
146 SAL_WARN("svtools.config", "Caught unexpected: " << ex
.Message
);
150 sal_Bool
SvtPrintOptions_Impl::IsReduceTransparency() const
152 sal_Bool bRet
= sal_False
;
157 css::uno::Reference
< css::beans::XPropertySet
> xSet(m_xNode
, css::uno::UNO_QUERY
);
159 xSet
->getPropertyValue(PROPERTYNAME_REDUCETRANSPARENCY
) >>= bRet
;
162 catch (const css::uno::Exception
& ex
)
164 SAL_WARN("svtools.config", "Caught unexpected: " << ex
.Message
);
170 sal_Int16
SvtPrintOptions_Impl::GetReducedTransparencyMode() const
177 css::uno::Reference
< css::beans::XPropertySet
> xSet(m_xNode
, css::uno::UNO_QUERY
);
179 xSet
->getPropertyValue(PROPERTYNAME_REDUCEDTRANSPARENCYMODE
) >>= nRet
;
182 catch (const css::uno::Exception
& ex
)
184 SAL_WARN("svtools.config", "Caught unexpected: " << ex
.Message
);
190 sal_Bool
SvtPrintOptions_Impl::IsReduceGradients() const
192 sal_Bool bRet
= sal_False
;
197 css::uno::Reference
<css::beans::XPropertySet
> xSet(m_xNode
, css::uno::UNO_QUERY
);
200 xSet
->getPropertyValue(PROPERTYNAME_REDUCEGRADIENTS
) >>= bRet
;
204 catch (const css::uno::Exception
& ex
)
206 SAL_WARN("svtools.config", "Caught unexpected: " << ex
.Message
);
212 sal_Int16
SvtPrintOptions_Impl::GetReducedGradientMode() const
219 css::uno::Reference
<css::beans::XPropertySet
> xSet(m_xNode
, css::uno::UNO_QUERY
);
222 xSet
->getPropertyValue(PROPERTYNAME_REDUCEDGRADIENTMODE
) >>= nRet
;
226 catch (const css::uno::Exception
& ex
)
228 SAL_WARN("svtools.config", "Caught unexpected: " << ex
.Message
);
234 sal_Int16
SvtPrintOptions_Impl::GetReducedGradientStepCount() const
241 css::uno::Reference
<css::beans::XPropertySet
> xSet(m_xNode
, css::uno::UNO_QUERY
);
244 xSet
->getPropertyValue(PROPERTYNAME_REDUCEDGRADIENTSTEPCOUNT
) >>= nRet
;
248 catch (const css::uno::Exception
& ex
)
250 SAL_WARN("svtools.config", "Caught unexpected: " << ex
.Message
);
256 sal_Bool
SvtPrintOptions_Impl::IsReduceBitmaps() const
258 sal_Bool bRet
= sal_False
;
263 css::uno::Reference
<css::beans::XPropertySet
> xSet(m_xNode
, css::uno::UNO_QUERY
);
266 xSet
->getPropertyValue(PROPERTYNAME_REDUCEBITMAPS
) >>= bRet
;
270 catch (const css::uno::Exception
& ex
)
272 SAL_WARN("svtools.config", "Caught unexpected: " << ex
.Message
);
278 sal_Int16
SvtPrintOptions_Impl::GetReducedBitmapMode() const
285 css::uno::Reference
<css::beans::XPropertySet
> xSet(m_xNode
, css::uno::UNO_QUERY
);
288 xSet
->getPropertyValue(PROPERTYNAME_REDUCEDBITMAPMODE
) >>= nRet
;
292 catch (const css::uno::Exception
& ex
)
294 SAL_WARN("svtools.config", "Caught unexpected: " << ex
.Message
);
300 sal_Int16
SvtPrintOptions_Impl::GetReducedBitmapResolution() const
307 css::uno::Reference
<css::beans::XPropertySet
> xSet(m_xNode
, css::uno::UNO_QUERY
);
310 xSet
->getPropertyValue(PROPERTYNAME_REDUCEDBITMAPRESOLUTION
) >>= nRet
;
314 catch (const css::uno::Exception
& ex
)
316 SAL_WARN("svtools.config", "Caught unexpected: " << ex
.Message
);
322 sal_Bool
SvtPrintOptions_Impl::IsReducedBitmapIncludesTransparency() const
324 sal_Bool bRet
= sal_True
;
329 css::uno::Reference
<css::beans::XPropertySet
> xSet(m_xNode
, css::uno::UNO_QUERY
);
332 xSet
->getPropertyValue(PROPERTYNAME_REDUCEDBITMAPINCLUDESTRANSPARENCY
) >>= bRet
;
336 catch (const css::uno::Exception
& ex
)
338 SAL_WARN("svtools.config", "Caught unexpected: " << ex
.Message
);
344 sal_Bool
SvtPrintOptions_Impl::IsConvertToGreyscales() const
346 sal_Bool bRet
= sal_False
;
351 css::uno::Reference
<css::beans::XPropertySet
> xSet(m_xNode
, css::uno::UNO_QUERY
);
354 xSet
->getPropertyValue(PROPERTYNAME_CONVERTTOGREYSCALES
) >>= bRet
;
358 catch (const css::uno::Exception
& ex
)
360 SAL_WARN("svtools.config", "Caught unexpected: " << ex
.Message
);
367 sal_Bool
SvtPrintOptions_Impl::IsPDFAsStandardPrintJobFormat() const
369 sal_Bool bRet
= sal_True
;
374 css::uno::Reference
<css::beans::XPropertySet
> xSet(m_xNode
, css::uno::UNO_QUERY
);
377 xSet
->getPropertyValue(PROPERTYNAME_PDFASSTANDARDPRINTJOBFORMAT
) >>= bRet
;
381 catch (const css::uno::Exception
& ex
)
383 SAL_WARN("svtools.config", "Caught unexpected: " << ex
.Message
);
389 void SvtPrintOptions_Impl::SetReduceTransparency(sal_Bool bState
)
391 impl_setValue(PROPERTYNAME_REDUCETRANSPARENCY
, bState
);
394 void SvtPrintOptions_Impl::SetReducedTransparencyMode(sal_Int16 nMode
)
396 impl_setValue(PROPERTYNAME_REDUCEDTRANSPARENCYMODE
, nMode
);
399 void SvtPrintOptions_Impl::SetReduceGradients(sal_Bool bState
)
401 impl_setValue(PROPERTYNAME_REDUCEGRADIENTS
, bState
);
404 void SvtPrintOptions_Impl::SetReducedGradientMode(sal_Int16 nMode
)
406 impl_setValue(PROPERTYNAME_REDUCEDGRADIENTMODE
, nMode
);
409 void SvtPrintOptions_Impl::SetReducedGradientStepCount(sal_Int16 nStepCount
)
411 impl_setValue(PROPERTYNAME_REDUCEDGRADIENTSTEPCOUNT
, nStepCount
);
414 void SvtPrintOptions_Impl::SetReduceBitmaps(sal_Bool bState
)
416 impl_setValue(PROPERTYNAME_REDUCEBITMAPS
, bState
);
419 void SvtPrintOptions_Impl::SetReducedBitmapMode(sal_Int16 nMode
)
421 impl_setValue(PROPERTYNAME_REDUCEDBITMAPMODE
, nMode
);
424 void SvtPrintOptions_Impl::SetReducedBitmapResolution(sal_Int16 nResolution
)
426 impl_setValue(PROPERTYNAME_REDUCEDBITMAPRESOLUTION
, nResolution
);
429 void SvtPrintOptions_Impl::SetReducedBitmapIncludesTransparency(sal_Bool bState
)
431 impl_setValue(PROPERTYNAME_REDUCEDBITMAPINCLUDESTRANSPARENCY
, bState
);
434 void SvtPrintOptions_Impl::SetConvertToGreyscales(sal_Bool bState
)
436 impl_setValue(PROPERTYNAME_CONVERTTOGREYSCALES
, bState
);
439 void SvtPrintOptions_Impl::SetPDFAsStandardPrintJobFormat(sal_Bool bState
)
441 impl_setValue(PROPERTYNAME_PDFASSTANDARDPRINTJOBFORMAT
, bState
);
444 SvtPrintOptions_Impl::~SvtPrintOptions_Impl()
450 void SvtPrintOptions_Impl::impl_setValue (const OUString
& sProp
,
458 css::uno::Reference
<css::beans::XPropertySet
> xSet(m_xNode
, css::uno::UNO_QUERY
);
462 ::sal_Bool bOld
= ! bNew
;
463 if ( ! (xSet
->getPropertyValue(sProp
) >>= bOld
))
468 xSet
->setPropertyValue(sProp
, css::uno::makeAny(bNew
));
469 ::comphelper::ConfigurationHelper::flush(m_xCfg
);
472 catch(const css::uno::Exception
& ex
)
474 SAL_WARN("svtools.config", "Caught unexpected: " << ex
.Message
);
478 void SvtPrintOptions_Impl::impl_setValue (const OUString
& sProp
,
486 css::uno::Reference
<css::beans::XPropertySet
> xSet(m_xNode
, css::uno::UNO_QUERY
);
490 ::sal_Int16 nOld
= nNew
+1;
491 if ( ! (xSet
->getPropertyValue(sProp
) >>= nOld
))
496 xSet
->setPropertyValue(sProp
, css::uno::makeAny(nNew
));
497 ::comphelper::ConfigurationHelper::flush(m_xCfg
);
500 catch(const css::uno::Exception
& ex
)
502 SAL_WARN("svtools.config", "Caught unexpected: " << ex
.Message
);
506 SvtBasePrintOptions::SvtBasePrintOptions()
510 SvtBasePrintOptions::~SvtBasePrintOptions()
514 Mutex
& SvtBasePrintOptions::GetOwnStaticMutex()
516 // Initialize static mutex only for one time!
517 static Mutex
* pMutex
= NULL
;
518 // If these method first called (Mutex not already exist!) ...
521 // ... we must create a new one. Protect follow code with the global mutex -
522 // It must be - we create a static variable!
523 MutexGuard
aGuard( Mutex::getGlobalMutex() );
524 // We must check our pointer again - because it can be that another instance of our class will be fastr then these!
527 // Create the new mutex and set it for return on static variable.
532 // Return new created or already existing mutex object.
536 sal_Bool
SvtBasePrintOptions::IsReduceTransparency() const
538 MutexGuard
aGuard( GetOwnStaticMutex() );
539 return m_pDataContainer
->IsReduceTransparency();
542 sal_Int16
SvtBasePrintOptions::GetReducedTransparencyMode() const
544 MutexGuard
aGuard( GetOwnStaticMutex() );
545 return m_pDataContainer
->GetReducedTransparencyMode();
548 sal_Bool
SvtBasePrintOptions::IsReduceGradients() const
550 MutexGuard
aGuard( GetOwnStaticMutex() );
551 return m_pDataContainer
->IsReduceGradients();
554 sal_Int16
SvtBasePrintOptions::GetReducedGradientMode() const
556 MutexGuard
aGuard( GetOwnStaticMutex() );
557 return m_pDataContainer
->GetReducedGradientMode();
560 sal_Int16
SvtBasePrintOptions::GetReducedGradientStepCount() const
562 MutexGuard
aGuard( GetOwnStaticMutex() );
563 return m_pDataContainer
->GetReducedGradientStepCount();
566 sal_Bool
SvtBasePrintOptions::IsReduceBitmaps() const
568 MutexGuard
aGuard( GetOwnStaticMutex() );
569 return m_pDataContainer
->IsReduceBitmaps();
572 sal_Int16
SvtBasePrintOptions::GetReducedBitmapMode() const
574 MutexGuard
aGuard( GetOwnStaticMutex() );
575 return m_pDataContainer
->GetReducedBitmapMode();
578 sal_Int16
SvtBasePrintOptions::GetReducedBitmapResolution() const
580 MutexGuard
aGuard( GetOwnStaticMutex() );
581 return m_pDataContainer
->GetReducedBitmapResolution();
584 sal_Bool
SvtBasePrintOptions::IsReducedBitmapIncludesTransparency() const
586 MutexGuard
aGuard( GetOwnStaticMutex() );
587 return m_pDataContainer
->IsReducedBitmapIncludesTransparency();
590 sal_Bool
SvtBasePrintOptions::IsConvertToGreyscales() const
592 MutexGuard
aGuard( GetOwnStaticMutex() );
593 return m_pDataContainer
->IsConvertToGreyscales();
596 sal_Bool
SvtBasePrintOptions::IsPDFAsStandardPrintJobFormat() const
598 MutexGuard
aGuard( GetOwnStaticMutex() );
599 return m_pDataContainer
->IsPDFAsStandardPrintJobFormat();
602 void SvtBasePrintOptions::SetReduceTransparency( sal_Bool bState
)
604 MutexGuard
aGuard( GetOwnStaticMutex() );
605 m_pDataContainer
->SetReduceTransparency( bState
) ;
608 void SvtBasePrintOptions::SetReducedTransparencyMode( sal_Int16 nMode
)
610 MutexGuard
aGuard( GetOwnStaticMutex() );
611 m_pDataContainer
->SetReducedTransparencyMode( nMode
);
614 void SvtBasePrintOptions::SetReduceGradients( sal_Bool bState
)
616 MutexGuard
aGuard( GetOwnStaticMutex() );
617 m_pDataContainer
->SetReduceGradients( bState
);
620 void SvtBasePrintOptions::SetReducedGradientMode( sal_Int16 nMode
)
622 MutexGuard
aGuard( GetOwnStaticMutex() );
623 m_pDataContainer
->SetReducedGradientMode( nMode
);
626 void SvtBasePrintOptions::SetReducedGradientStepCount( sal_Int16 nStepCount
)
628 MutexGuard
aGuard( GetOwnStaticMutex() );
629 m_pDataContainer
->SetReducedGradientStepCount( nStepCount
);
632 void SvtBasePrintOptions::SetReduceBitmaps( sal_Bool bState
)
634 MutexGuard
aGuard( GetOwnStaticMutex() );
635 m_pDataContainer
->SetReduceBitmaps( bState
);
638 void SvtBasePrintOptions::SetReducedBitmapMode( sal_Int16 nMode
)
640 MutexGuard
aGuard( GetOwnStaticMutex() );
641 m_pDataContainer
->SetReducedBitmapMode( nMode
);
644 void SvtBasePrintOptions::SetReducedBitmapResolution( sal_Int16 nResolution
)
646 MutexGuard
aGuard( GetOwnStaticMutex() );
647 m_pDataContainer
->SetReducedBitmapResolution( nResolution
);
650 void SvtBasePrintOptions::SetReducedBitmapIncludesTransparency( sal_Bool bState
)
652 MutexGuard
aGuard( GetOwnStaticMutex() );
653 m_pDataContainer
->SetReducedBitmapIncludesTransparency( bState
);
656 void SvtBasePrintOptions::SetConvertToGreyscales( sal_Bool bState
)
658 MutexGuard
aGuard( GetOwnStaticMutex() );
659 m_pDataContainer
->SetConvertToGreyscales( bState
);
662 void SvtBasePrintOptions::SetPDFAsStandardPrintJobFormat( sal_Bool bState
)
664 MutexGuard
aGuard( GetOwnStaticMutex() );
665 m_pDataContainer
->SetPDFAsStandardPrintJobFormat( bState
);
668 void SvtBasePrintOptions::GetPrinterOptions( PrinterOptions
& rOptions
) const
670 rOptions
.SetReduceTransparency( IsReduceTransparency() );
671 rOptions
.SetReducedTransparencyMode( (PrinterTransparencyMode
) GetReducedTransparencyMode() );
672 rOptions
.SetReduceGradients( IsReduceGradients() );
673 rOptions
.SetReducedGradientMode( (PrinterGradientMode
) GetReducedGradientMode() );
674 rOptions
.SetReducedGradientStepCount( GetReducedGradientStepCount() );
675 rOptions
.SetReduceBitmaps( IsReduceBitmaps() );
676 rOptions
.SetReducedBitmapMode( (PrinterBitmapMode
) GetReducedBitmapMode() );
677 rOptions
.SetReducedBitmapResolution( aDPIArray
[ std::min( (sal_uInt16
) GetReducedBitmapResolution(), (sal_uInt16
)( DPI_COUNT
- 1 ) ) ] );
678 rOptions
.SetReducedBitmapIncludesTransparency( IsReducedBitmapIncludesTransparency() );
679 rOptions
.SetConvertToGreyscales( IsConvertToGreyscales() );
680 rOptions
.SetPDFAsStandardPrintJobFormat( IsPDFAsStandardPrintJobFormat() );
683 void SvtBasePrintOptions::SetPrinterOptions( const PrinterOptions
& rOptions
)
685 SetReduceTransparency( rOptions
.IsReduceTransparency() );
686 SetReducedTransparencyMode(
687 sal::static_int_cast
< sal_Int16
>(
688 rOptions
.GetReducedTransparencyMode()) );
689 SetReduceGradients( rOptions
.IsReduceGradients() );
690 SetReducedGradientMode(
691 sal::static_int_cast
< sal_Int16
>(rOptions
.GetReducedGradientMode()) );
692 SetReducedGradientStepCount( rOptions
.GetReducedGradientStepCount() );
693 SetReduceBitmaps( rOptions
.IsReduceBitmaps() );
694 SetReducedBitmapMode(
695 sal::static_int_cast
< sal_Int16
>(rOptions
.GetReducedBitmapMode()) );
696 SetReducedBitmapIncludesTransparency( rOptions
.IsReducedBitmapIncludesTransparency() );
697 SetConvertToGreyscales( rOptions
.IsConvertToGreyscales() );
698 SetPDFAsStandardPrintJobFormat( rOptions
.IsPDFAsStandardPrintJobFormat() );
700 const sal_uInt16 nDPI
= rOptions
.GetReducedBitmapResolution();
702 if( nDPI
< aDPIArray
[ 0 ] )
703 SetReducedBitmapResolution( 0 );
706 for( long i
= ( DPI_COUNT
- 1 ); i
>= 0; i
-- )
708 if( nDPI
>= aDPIArray
[ i
] )
710 SetReducedBitmapResolution( (sal_Int16
) i
);
717 SvtPrinterOptions::SvtPrinterOptions()
719 // Global access, must be guarded (multithreading!).
720 MutexGuard
aGuard( GetOwnStaticMutex() );
721 // Increase our refcount ...
723 // ... and initialize our data container only if it not already!
724 if( m_pStaticDataContainer
== NULL
)
726 OUString
aRootPath( ROOTNODE_START
);
727 m_pStaticDataContainer
= new SvtPrintOptions_Impl( aRootPath
+= "/Printer" );
728 pPrinterOptionsDataContainer
= m_pStaticDataContainer
;
729 svtools::ItemHolder2::holdConfigItem(E_PRINTOPTIONS
);
732 SetDataContainer( m_pStaticDataContainer
);
735 SvtPrinterOptions::~SvtPrinterOptions()
737 // Global access, must be guarded (multithreading!)
738 MutexGuard
aGuard( GetOwnStaticMutex() );
739 // Decrease our refcount.
741 // If last instance was deleted ...
742 // we must destroy our static data container!
743 if( m_nRefCount
<= 0 )
745 delete m_pStaticDataContainer
;
746 m_pStaticDataContainer
= NULL
;
747 pPrinterOptionsDataContainer
= NULL
;
751 SvtPrintFileOptions::SvtPrintFileOptions()
753 // Global access, must be guarded (multithreading!).
754 MutexGuard
aGuard( GetOwnStaticMutex() );
755 // Increase our refcount ...
757 // ... and initialize our data container only if it not already!
758 if( m_pStaticDataContainer
== NULL
)
760 OUString
aRootPath( ROOTNODE_START
);
761 m_pStaticDataContainer
= new SvtPrintOptions_Impl( aRootPath
+= "/File" );
762 pPrintFileOptionsDataContainer
= m_pStaticDataContainer
;
764 svtools::ItemHolder2::holdConfigItem(E_PRINTFILEOPTIONS
);
767 SetDataContainer( m_pStaticDataContainer
);
770 SvtPrintFileOptions::~SvtPrintFileOptions()
772 // Global access, must be guarded (multithreading!)
773 MutexGuard
aGuard( GetOwnStaticMutex() );
774 // Decrease our refcount.
776 // If last instance was deleted ...
777 // we must destroy our static data container!
778 if( m_nRefCount
<= 0 )
780 delete m_pStaticDataContainer
;
781 m_pStaticDataContainer
= NULL
;
782 pPrintFileOptionsDataContainer
= NULL
;
786 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */