1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_unotools.hxx"
30*cdf0e10cSrcweir #ifndef GCC
31*cdf0e10cSrcweir #endif
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
34*cdf0e10cSrcweir //	includes
35*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir #include <unotools/printwarningoptions.hxx>
38*cdf0e10cSrcweir #include <unotools/configmgr.hxx>
39*cdf0e10cSrcweir #include <unotools/configitem.hxx>
40*cdf0e10cSrcweir #include <tools/debug.hxx>
41*cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx>
42*cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir #include <itemholder1.hxx>
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
47*cdf0e10cSrcweir //	namespaces
48*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir using namespace ::utl					;
51*cdf0e10cSrcweir using namespace ::rtl					;
52*cdf0e10cSrcweir using namespace ::osl					;
53*cdf0e10cSrcweir using namespace ::com::sun::star::uno	;
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
56*cdf0e10cSrcweir //	const
57*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir #define ROOTNODE_START                  OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/Print"))
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir #define PROPERTYNAME_PAPERSIZE          OUString(RTL_CONSTASCII_USTRINGPARAM("Warning/PaperSize"))
62*cdf0e10cSrcweir #define PROPERTYNAME_PAPERORIENTATION   OUString(RTL_CONSTASCII_USTRINGPARAM("Warning/PaperOrientation"))
63*cdf0e10cSrcweir #define PROPERTYNAME_NOTFOUND           OUString(RTL_CONSTASCII_USTRINGPARAM("Warning/NotFound"))
64*cdf0e10cSrcweir #define PROPERTYNAME_TRANSPARENCY       OUString(RTL_CONSTASCII_USTRINGPARAM("Warning/Transparency"))
65*cdf0e10cSrcweir #define PROPERTYNAME_PRINTINGMODIFIESDOCUMENT  OUString(RTL_CONSTASCII_USTRINGPARAM("PrintingModifiesDocument"))
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir #define	PROPERTYHANDLE_PAPERSIZE		0
68*cdf0e10cSrcweir #define	PROPERTYHANDLE_PAPERORIENTATION	1
69*cdf0e10cSrcweir #define	PROPERTYHANDLE_NOTFOUND	        2
70*cdf0e10cSrcweir #define	PROPERTYHANDLE_TRANSPARENCY 	3
71*cdf0e10cSrcweir #define PROPERTYHDL_PRINTINGMODIFIESDOCUMENT            4
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir #define PROPERTYCOUNT                   5
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir class SvtPrintWarningOptions_Impl : public ConfigItem
76*cdf0e10cSrcweir {
77*cdf0e10cSrcweir public:
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir //---------------------------------------------------------------------------------------------------------
80*cdf0e10cSrcweir //	constructor / destructor
81*cdf0e10cSrcweir //---------------------------------------------------------------------------------------------------------
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir 	 SvtPrintWarningOptions_Impl();
84*cdf0e10cSrcweir 	~SvtPrintWarningOptions_Impl();
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir //---------------------------------------------------------------------------------------------------------
87*cdf0e10cSrcweir //	overloaded methods of baseclass
88*cdf0e10cSrcweir //---------------------------------------------------------------------------------------------------------
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir 	virtual void Commit();
91*cdf0e10cSrcweir     virtual void    Notify( const com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames );
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir //---------------------------------------------------------------------------------------------------------
94*cdf0e10cSrcweir //	public interface
95*cdf0e10cSrcweir //---------------------------------------------------------------------------------------------------------
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir 	sal_Bool	IsPaperSize() const { return m_bPaperSize; }
98*cdf0e10cSrcweir 	sal_Bool	IsPaperOrientation() const { return m_bPaperOrientation; }
99*cdf0e10cSrcweir 	sal_Bool	IsNotFound() const { return m_bNotFound; }
100*cdf0e10cSrcweir 	sal_Bool	IsTransparency() const { return m_bTransparency; }
101*cdf0e10cSrcweir     sal_Bool    IsModifyDocumentOnPrintingAllowed() const { return m_bModifyDocumentOnPrintingAllowed; }
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir 	void		SetPaperSize( sal_Bool bState ) { m_bPaperSize = bState; SetModified(); }
104*cdf0e10cSrcweir 	void		SetPaperOrientation( sal_Bool bState ) { m_bPaperOrientation = bState; SetModified(); }
105*cdf0e10cSrcweir 	void		SetNotFound( sal_Bool bState ) { m_bNotFound = bState; SetModified(); }
106*cdf0e10cSrcweir 	void		SetTransparency( sal_Bool bState ) { m_bTransparency = bState; SetModified(); }
107*cdf0e10cSrcweir     void        SetModifyDocumentOnPrintingAllowed( sal_Bool bState ) { m_bModifyDocumentOnPrintingAllowed = bState; SetModified(); }
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir //-------------------------------------------------------------------------------------------------------------
110*cdf0e10cSrcweir //	private methods
111*cdf0e10cSrcweir //-------------------------------------------------------------------------------------------------------------
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir private:
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir 	static Sequence< OUString > impl_GetPropertyNames();
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir //-------------------------------------------------------------------------------------------------------------
118*cdf0e10cSrcweir //	private member
119*cdf0e10cSrcweir //-------------------------------------------------------------------------------------------------------------
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir private:
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir 	sal_Bool	m_bPaperSize;
124*cdf0e10cSrcweir 	sal_Bool	m_bPaperOrientation;
125*cdf0e10cSrcweir 	sal_Bool	m_bNotFound;
126*cdf0e10cSrcweir 	sal_Bool	m_bTransparency;
127*cdf0e10cSrcweir     sal_Bool    m_bModifyDocumentOnPrintingAllowed;
128*cdf0e10cSrcweir };
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
131*cdf0e10cSrcweir //	definitions
132*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir //*****************************************************************************************************************
135*cdf0e10cSrcweir //	constructor
136*cdf0e10cSrcweir //*****************************************************************************************************************
137*cdf0e10cSrcweir SvtPrintWarningOptions_Impl::SvtPrintWarningOptions_Impl() :
138*cdf0e10cSrcweir 	ConfigItem( ROOTNODE_START	),
139*cdf0e10cSrcweir 	m_bPaperSize( sal_False ),
140*cdf0e10cSrcweir 	m_bPaperOrientation( sal_False ),
141*cdf0e10cSrcweir 	m_bNotFound( sal_False ),
142*cdf0e10cSrcweir     m_bTransparency( sal_True ),
143*cdf0e10cSrcweir     m_bModifyDocumentOnPrintingAllowed( sal_True )
144*cdf0e10cSrcweir {
145*cdf0e10cSrcweir 	Sequence< OUString >	seqNames( impl_GetPropertyNames() );
146*cdf0e10cSrcweir 	Sequence< Any >			seqValues( GetProperties( seqNames ) );
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir 	DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtPrintWarningOptions_Impl::SvtPrintWarningOptions_Impl()\nI miss some values of configuration keys!\n" );
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir 	// Copy values from list in right order to our internal member.
151*cdf0e10cSrcweir 	sal_Int32 nPropertyCount = seqValues.getLength();
152*cdf0e10cSrcweir 	sal_Int32 nProperty	= 0;
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir 	for( nProperty=0; nProperty<nPropertyCount; ++nProperty )
155*cdf0e10cSrcweir 	{
156*cdf0e10cSrcweir 		DBG_ASSERT( !(seqValues[nProperty].hasValue()==sal_False), "SvtPrintWarningOptions_Impl::SvtPrintWarningOptions_Impl()\nInvalid property value for property detected!\n" );
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir         switch( nProperty )
159*cdf0e10cSrcweir         {
160*cdf0e10cSrcweir             case PROPERTYHANDLE_PAPERSIZE:
161*cdf0e10cSrcweir 			{
162*cdf0e10cSrcweir 				DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "Invalid type" );
163*cdf0e10cSrcweir 				seqValues[nProperty] >>= m_bPaperSize;
164*cdf0e10cSrcweir 			}
165*cdf0e10cSrcweir 			break;
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir             case PROPERTYHANDLE_PAPERORIENTATION:
168*cdf0e10cSrcweir 			{
169*cdf0e10cSrcweir 				DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "Invalid type" );
170*cdf0e10cSrcweir 				seqValues[nProperty] >>= m_bPaperOrientation;
171*cdf0e10cSrcweir 			}
172*cdf0e10cSrcweir 			break;
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir             case PROPERTYHANDLE_NOTFOUND:
175*cdf0e10cSrcweir 			{
176*cdf0e10cSrcweir 				DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "Invalid type" );
177*cdf0e10cSrcweir 				seqValues[nProperty] >>= m_bNotFound;
178*cdf0e10cSrcweir 			}
179*cdf0e10cSrcweir 			break;
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir             case PROPERTYHANDLE_TRANSPARENCY:
182*cdf0e10cSrcweir 			{
183*cdf0e10cSrcweir 				DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "Invalid type" );
184*cdf0e10cSrcweir 				seqValues[nProperty] >>= m_bTransparency;
185*cdf0e10cSrcweir 			}
186*cdf0e10cSrcweir 			break;
187*cdf0e10cSrcweir             case PROPERTYHDL_PRINTINGMODIFIESDOCUMENT:
188*cdf0e10cSrcweir             {
189*cdf0e10cSrcweir 				DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "Invalid type" );
190*cdf0e10cSrcweir                 seqValues[nProperty] >>= m_bModifyDocumentOnPrintingAllowed;
191*cdf0e10cSrcweir 			}
192*cdf0e10cSrcweir 			break;
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir         }
195*cdf0e10cSrcweir 	}
196*cdf0e10cSrcweir }
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir //*****************************************************************************************************************
199*cdf0e10cSrcweir //	destructor
200*cdf0e10cSrcweir //*****************************************************************************************************************
201*cdf0e10cSrcweir SvtPrintWarningOptions_Impl::~SvtPrintWarningOptions_Impl()
202*cdf0e10cSrcweir {
203*cdf0e10cSrcweir 	if( IsModified() )
204*cdf0e10cSrcweir 		Commit();
205*cdf0e10cSrcweir }
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir //*****************************************************************************************************************
208*cdf0e10cSrcweir //	Commit
209*cdf0e10cSrcweir //*****************************************************************************************************************
210*cdf0e10cSrcweir void SvtPrintWarningOptions_Impl::Commit()
211*cdf0e10cSrcweir {
212*cdf0e10cSrcweir 	Sequence< OUString >	aSeqNames( impl_GetPropertyNames() );
213*cdf0e10cSrcweir 	Sequence< Any >			aSeqValues( aSeqNames.getLength() );
214*cdf0e10cSrcweir 
215*cdf0e10cSrcweir 	for( sal_Int32 nProperty = 0, nCount = aSeqNames.getLength(); nProperty < nCount; ++nProperty )
216*cdf0e10cSrcweir 	{
217*cdf0e10cSrcweir         switch( nProperty )
218*cdf0e10cSrcweir         {
219*cdf0e10cSrcweir             case PROPERTYHANDLE_PAPERSIZE:
220*cdf0e10cSrcweir 				aSeqValues[nProperty] <<= m_bPaperSize;
221*cdf0e10cSrcweir 			break;
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir             case PROPERTYHANDLE_PAPERORIENTATION:
224*cdf0e10cSrcweir 				aSeqValues[nProperty] <<= m_bPaperOrientation;
225*cdf0e10cSrcweir 			break;
226*cdf0e10cSrcweir 
227*cdf0e10cSrcweir             case PROPERTYHANDLE_NOTFOUND:
228*cdf0e10cSrcweir 				aSeqValues[nProperty] <<= m_bNotFound;
229*cdf0e10cSrcweir 			break;
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir             case PROPERTYHANDLE_TRANSPARENCY:
232*cdf0e10cSrcweir 				aSeqValues[nProperty] <<= m_bTransparency;
233*cdf0e10cSrcweir 			break;
234*cdf0e10cSrcweir             case PROPERTYHDL_PRINTINGMODIFIESDOCUMENT:
235*cdf0e10cSrcweir                 aSeqValues[nProperty] <<= m_bModifyDocumentOnPrintingAllowed;
236*cdf0e10cSrcweir 			break;
237*cdf0e10cSrcweir         }
238*cdf0e10cSrcweir 	}
239*cdf0e10cSrcweir 
240*cdf0e10cSrcweir 	PutProperties( aSeqNames, aSeqValues );
241*cdf0e10cSrcweir }
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir void SvtPrintWarningOptions_Impl::Notify( const Sequence< rtl::OUString >&  )
244*cdf0e10cSrcweir {
245*cdf0e10cSrcweir }
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir //*****************************************************************************************************************
248*cdf0e10cSrcweir //	private method
249*cdf0e10cSrcweir //*****************************************************************************************************************
250*cdf0e10cSrcweir Sequence< OUString > SvtPrintWarningOptions_Impl::impl_GetPropertyNames()
251*cdf0e10cSrcweir {
252*cdf0e10cSrcweir 	// Build static list of configuration key names.
253*cdf0e10cSrcweir 	static const OUString pProperties[] =
254*cdf0e10cSrcweir 	{
255*cdf0e10cSrcweir 		PROPERTYNAME_PAPERSIZE,
256*cdf0e10cSrcweir 		PROPERTYNAME_PAPERORIENTATION,
257*cdf0e10cSrcweir 		PROPERTYNAME_NOTFOUND,
258*cdf0e10cSrcweir         PROPERTYNAME_TRANSPARENCY,
259*cdf0e10cSrcweir         PROPERTYNAME_PRINTINGMODIFIESDOCUMENT
260*cdf0e10cSrcweir 	};
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir     // Initialize return sequence with these list ...
263*cdf0e10cSrcweir 	static const Sequence< OUString > seqPropertyNames( pProperties, PROPERTYCOUNT );
264*cdf0e10cSrcweir 
265*cdf0e10cSrcweir 	return seqPropertyNames;
266*cdf0e10cSrcweir }
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir //*****************************************************************************************************************
269*cdf0e10cSrcweir //	initialize static member
270*cdf0e10cSrcweir //	DON'T DO IT IN YOUR HEADER!
271*cdf0e10cSrcweir //	see definition for further informations
272*cdf0e10cSrcweir //*****************************************************************************************************************
273*cdf0e10cSrcweir SvtPrintWarningOptions_Impl*    SvtPrintWarningOptions::m_pDataContainer = NULL;
274*cdf0e10cSrcweir sal_Int32				        SvtPrintWarningOptions::m_nRefCount = 0;
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir //*****************************************************************************************************************
277*cdf0e10cSrcweir //	constructor
278*cdf0e10cSrcweir //*****************************************************************************************************************
279*cdf0e10cSrcweir SvtPrintWarningOptions::SvtPrintWarningOptions()
280*cdf0e10cSrcweir {
281*cdf0e10cSrcweir     // Global access, must be guarded (multithreading!).
282*cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
283*cdf0e10cSrcweir 	// Increase ouer refcount ...
284*cdf0e10cSrcweir 	++m_nRefCount;
285*cdf0e10cSrcweir 	// ... and initialize ouer data container only if it not already!
286*cdf0e10cSrcweir     if( m_pDataContainer == NULL )
287*cdf0e10cSrcweir 	{
288*cdf0e10cSrcweir         m_pDataContainer = new SvtPrintWarningOptions_Impl();
289*cdf0e10cSrcweir 		ItemHolder1::holdConfigItem(E_PRINTWARNINGOPTIONS);
290*cdf0e10cSrcweir 	}
291*cdf0e10cSrcweir }
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir //*****************************************************************************************************************
294*cdf0e10cSrcweir //	destructor
295*cdf0e10cSrcweir //*****************************************************************************************************************
296*cdf0e10cSrcweir SvtPrintWarningOptions::~SvtPrintWarningOptions()
297*cdf0e10cSrcweir {
298*cdf0e10cSrcweir     // Global access, must be guarded (multithreading!)
299*cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
300*cdf0e10cSrcweir 	// Decrease ouer refcount.
301*cdf0e10cSrcweir 	--m_nRefCount;
302*cdf0e10cSrcweir 	// If last instance was deleted ...
303*cdf0e10cSrcweir 	// we must destroy ouer static data container!
304*cdf0e10cSrcweir     if( m_nRefCount <= 0 )
305*cdf0e10cSrcweir 	{
306*cdf0e10cSrcweir 		delete m_pDataContainer;
307*cdf0e10cSrcweir 		m_pDataContainer = NULL;
308*cdf0e10cSrcweir 	}
309*cdf0e10cSrcweir }
310*cdf0e10cSrcweir 
311*cdf0e10cSrcweir //*****************************************************************************************************************
312*cdf0e10cSrcweir //	public method
313*cdf0e10cSrcweir //*****************************************************************************************************************
314*cdf0e10cSrcweir sal_Bool SvtPrintWarningOptions::IsPaperSize() const
315*cdf0e10cSrcweir {
316*cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
317*cdf0e10cSrcweir 	return m_pDataContainer->IsPaperSize();
318*cdf0e10cSrcweir }
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir //*****************************************************************************************************************
321*cdf0e10cSrcweir //	public method
322*cdf0e10cSrcweir //*****************************************************************************************************************
323*cdf0e10cSrcweir sal_Bool SvtPrintWarningOptions::IsPaperOrientation() const
324*cdf0e10cSrcweir {
325*cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
326*cdf0e10cSrcweir 	return m_pDataContainer->IsPaperOrientation();
327*cdf0e10cSrcweir }
328*cdf0e10cSrcweir 
329*cdf0e10cSrcweir //*****************************************************************************************************************
330*cdf0e10cSrcweir //	public method
331*cdf0e10cSrcweir //*****************************************************************************************************************
332*cdf0e10cSrcweir sal_Bool SvtPrintWarningOptions::IsNotFound() const
333*cdf0e10cSrcweir {
334*cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
335*cdf0e10cSrcweir 	return m_pDataContainer->IsNotFound();
336*cdf0e10cSrcweir }
337*cdf0e10cSrcweir 
338*cdf0e10cSrcweir //*****************************************************************************************************************
339*cdf0e10cSrcweir //	public method
340*cdf0e10cSrcweir //*****************************************************************************************************************
341*cdf0e10cSrcweir sal_Bool SvtPrintWarningOptions::IsTransparency() const
342*cdf0e10cSrcweir {
343*cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
344*cdf0e10cSrcweir 	return m_pDataContainer->IsTransparency();
345*cdf0e10cSrcweir }
346*cdf0e10cSrcweir 
347*cdf0e10cSrcweir //*****************************************************************************************************************
348*cdf0e10cSrcweir //	public method
349*cdf0e10cSrcweir //*****************************************************************************************************************
350*cdf0e10cSrcweir void SvtPrintWarningOptions::SetPaperSize( sal_Bool bState )
351*cdf0e10cSrcweir {
352*cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
353*cdf0e10cSrcweir 	m_pDataContainer->SetPaperSize( bState );
354*cdf0e10cSrcweir }
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir //*****************************************************************************************************************
357*cdf0e10cSrcweir //	public method
358*cdf0e10cSrcweir //*****************************************************************************************************************
359*cdf0e10cSrcweir void SvtPrintWarningOptions::SetPaperOrientation( sal_Bool bState )
360*cdf0e10cSrcweir {
361*cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
362*cdf0e10cSrcweir 	m_pDataContainer->SetPaperOrientation( bState );
363*cdf0e10cSrcweir }
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir //*****************************************************************************************************************
366*cdf0e10cSrcweir //	public method
367*cdf0e10cSrcweir //*****************************************************************************************************************
368*cdf0e10cSrcweir void SvtPrintWarningOptions::SetNotFound( sal_Bool bState )
369*cdf0e10cSrcweir {
370*cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
371*cdf0e10cSrcweir 	m_pDataContainer->SetNotFound( bState );
372*cdf0e10cSrcweir }
373*cdf0e10cSrcweir 
374*cdf0e10cSrcweir //*****************************************************************************************************************
375*cdf0e10cSrcweir //	public method
376*cdf0e10cSrcweir //*****************************************************************************************************************
377*cdf0e10cSrcweir void SvtPrintWarningOptions::SetTransparency( sal_Bool bState )
378*cdf0e10cSrcweir {
379*cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
380*cdf0e10cSrcweir 	m_pDataContainer->SetTransparency( bState );
381*cdf0e10cSrcweir }
382*cdf0e10cSrcweir // -----------------------------------------------------------------------------
383*cdf0e10cSrcweir 
384*cdf0e10cSrcweir sal_Bool SvtPrintWarningOptions::IsModifyDocumentOnPrintingAllowed() const
385*cdf0e10cSrcweir {
386*cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
387*cdf0e10cSrcweir     return m_pDataContainer->IsModifyDocumentOnPrintingAllowed();
388*cdf0e10cSrcweir }
389*cdf0e10cSrcweir 
390*cdf0e10cSrcweir // -----------------------------------------------------------------------------
391*cdf0e10cSrcweir 
392*cdf0e10cSrcweir void SvtPrintWarningOptions::SetModifyDocumentOnPrintingAllowed( sal_Bool bState )
393*cdf0e10cSrcweir {
394*cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
395*cdf0e10cSrcweir     m_pDataContainer->SetModifyDocumentOnPrintingAllowed( bState ) ;
396*cdf0e10cSrcweir }
397*cdf0e10cSrcweir 
398*cdf0e10cSrcweir //*****************************************************************************************************************
399*cdf0e10cSrcweir //	private method
400*cdf0e10cSrcweir //*****************************************************************************************************************
401*cdf0e10cSrcweir Mutex& SvtPrintWarningOptions::GetOwnStaticMutex()
402*cdf0e10cSrcweir {
403*cdf0e10cSrcweir 	// Initialize static mutex only for one time!
404*cdf0e10cSrcweir     static Mutex* pMutex = NULL;
405*cdf0e10cSrcweir 	// If these method first called (Mutex not already exist!) ...
406*cdf0e10cSrcweir     if( pMutex == NULL )
407*cdf0e10cSrcweir     {
408*cdf0e10cSrcweir 		// ... we must create a new one. Protect follow code with the global mutex -
409*cdf0e10cSrcweir 		// It must be - we create a static variable!
410*cdf0e10cSrcweir         MutexGuard aGuard( Mutex::getGlobalMutex() );
411*cdf0e10cSrcweir 		// We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
412*cdf0e10cSrcweir         if( pMutex == NULL )
413*cdf0e10cSrcweir         {
414*cdf0e10cSrcweir 			// Create the new mutex and set it for return on static variable.
415*cdf0e10cSrcweir             static Mutex aMutex;
416*cdf0e10cSrcweir             pMutex = &aMutex;
417*cdf0e10cSrcweir         }
418*cdf0e10cSrcweir     }
419*cdf0e10cSrcweir 	// Return new created or already existing mutex object.
420*cdf0e10cSrcweir     return *pMutex;
421*cdf0e10cSrcweir }
422