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/cacheoptions.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 //_________________________________________________________________________________________________________________
45*cdf0e10cSrcweir //	namespaces
46*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir using namespace ::utl;
49*cdf0e10cSrcweir using namespace ::rtl;
50*cdf0e10cSrcweir using namespace ::osl;
51*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
54*cdf0e10cSrcweir //	const
55*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir #define	ROOTNODE_START			   			OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/Cache"	))
58*cdf0e10cSrcweir #define	DEFAULT_WRITEROLE					20
59*cdf0e10cSrcweir #define	DEFAULT_DRAWINGOLE					20
60*cdf0e10cSrcweir #define	DEFAULT_GRFMGR_TOTALSIZE			10000000
61*cdf0e10cSrcweir #define	DEFAULT_GRFMGR_OBJECTSIZE			2400000
62*cdf0e10cSrcweir #define	DEFAULT_GRFMGR_OBJECTRELEASE	    600
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir #define	PROPERTYNAME_WRITEROLE				OUString(RTL_CONSTASCII_USTRINGPARAM("Writer/OLE_Objects"))
65*cdf0e10cSrcweir #define	PROPERTYNAME_DRAWINGOLE				OUString(RTL_CONSTASCII_USTRINGPARAM("DrawingEngine/OLE_Objects"))
66*cdf0e10cSrcweir #define	PROPERTYNAME_GRFMGR_TOTALSIZE		OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicManager/TotalCacheSize"))
67*cdf0e10cSrcweir #define	PROPERTYNAME_GRFMGR_OBJECTSIZE		OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicManager/ObjectCacheSize"))
68*cdf0e10cSrcweir #define PROPERTYNAME_GRFMGR_OBJECTRELEASE   OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicManager/ObjectReleaseTime"))
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir #define	PROPERTYHANDLE_WRITEROLE			0
71*cdf0e10cSrcweir #define	PROPERTYHANDLE_DRAWINGOLE			1
72*cdf0e10cSrcweir #define	PROPERTYHANDLE_GRFMGR_TOTALSIZE		2
73*cdf0e10cSrcweir #define	PROPERTYHANDLE_GRFMGR_OBJECTSIZE	3
74*cdf0e10cSrcweir #define PROPERTYHANDLE_GRFMGR_OBJECTRELEASE 4
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir #define	PROPERTYCOUNT						5
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir class SvtCacheOptions_Impl : public ConfigItem
79*cdf0e10cSrcweir {
80*cdf0e10cSrcweir public:
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir //---------------------------------------------------------------------------------------------------------
83*cdf0e10cSrcweir //	constructor / destructor
84*cdf0e10cSrcweir //---------------------------------------------------------------------------------------------------------
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir 	 SvtCacheOptions_Impl();
87*cdf0e10cSrcweir 	~SvtCacheOptions_Impl();
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir //---------------------------------------------------------------------------------------------------------
90*cdf0e10cSrcweir //	overloaded methods of baseclass
91*cdf0e10cSrcweir //---------------------------------------------------------------------------------------------------------
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir 	virtual void	Commit();
94*cdf0e10cSrcweir     virtual void    Notify( const com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames );
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir //---------------------------------------------------------------------------------------------------------
97*cdf0e10cSrcweir //	public interface
98*cdf0e10cSrcweir //---------------------------------------------------------------------------------------------------------
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir 	sal_Int32		GetWriterOLE_Objects() const;
101*cdf0e10cSrcweir 	sal_Int32		GetDrawingEngineOLE_Objects() const;
102*cdf0e10cSrcweir 	sal_Int32		GetGraphicManagerTotalCacheSize() const;
103*cdf0e10cSrcweir 	sal_Int32		GetGraphicManagerObjectCacheSize() const;
104*cdf0e10cSrcweir 	sal_Int32		GetGraphicManagerObjectReleaseTime() const;
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir 	void			SetWriterOLE_Objects( sal_Int32 nObjects );
107*cdf0e10cSrcweir 	void			SetDrawingEngineOLE_Objects( sal_Int32 nObjects );
108*cdf0e10cSrcweir 	void			SetGraphicManagerTotalCacheSize( sal_Int32 nTotalCacheSize );
109*cdf0e10cSrcweir 	void			SetGraphicManagerObjectCacheSize( sal_Int32 nObjectCacheSize );
110*cdf0e10cSrcweir 	void            SetGraphicManagerObjectReleaseTime( sal_Int32 nReleaseTimeSeconds );
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir //-------------------------------------------------------------------------------------------------------------
113*cdf0e10cSrcweir //	private methods
114*cdf0e10cSrcweir //-------------------------------------------------------------------------------------------------------------
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir private:
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir 	static Sequence< OUString > impl_GetPropertyNames();
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir //-------------------------------------------------------------------------------------------------------------
121*cdf0e10cSrcweir //	private member
122*cdf0e10cSrcweir //-------------------------------------------------------------------------------------------------------------
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir private:
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir 		sal_Int32	mnWriterOLE;
127*cdf0e10cSrcweir 		sal_Int32	mnDrawingOLE;
128*cdf0e10cSrcweir 		sal_Int32	mnGrfMgrTotalSize;
129*cdf0e10cSrcweir 		sal_Int32	mnGrfMgrObjectSize;
130*cdf0e10cSrcweir         sal_Int32   mnGrfMgrObjectRelease;
131*cdf0e10cSrcweir };
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
134*cdf0e10cSrcweir //	definitions
135*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir //*****************************************************************************************************************
138*cdf0e10cSrcweir //	constructor
139*cdf0e10cSrcweir //*****************************************************************************************************************
140*cdf0e10cSrcweir SvtCacheOptions_Impl::SvtCacheOptions_Impl() :
141*cdf0e10cSrcweir 	ConfigItem( ROOTNODE_START	),
142*cdf0e10cSrcweir 	mnWriterOLE( DEFAULT_WRITEROLE ),
143*cdf0e10cSrcweir 	mnDrawingOLE( DEFAULT_DRAWINGOLE ),
144*cdf0e10cSrcweir 	mnGrfMgrTotalSize( DEFAULT_GRFMGR_TOTALSIZE ),
145*cdf0e10cSrcweir 	mnGrfMgrObjectSize( DEFAULT_GRFMGR_OBJECTSIZE ),
146*cdf0e10cSrcweir     mnGrfMgrObjectRelease( DEFAULT_GRFMGR_OBJECTRELEASE )
147*cdf0e10cSrcweir {
148*cdf0e10cSrcweir 	Sequence< OUString >	seqNames( impl_GetPropertyNames() );
149*cdf0e10cSrcweir 	Sequence< Any >			seqValues	= GetProperties( seqNames )	;
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir 	DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtCacheOptions_Impl::SvtCacheOptions_Impl()\nI miss some values of configuration keys!\n" );
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir 	// Copy values from list in right order to ouer internal member.
154*cdf0e10cSrcweir 	sal_Int32 nPropertyCount = seqValues.getLength();
155*cdf0e10cSrcweir 	sal_Int32 nProperty	= 0;
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir 	for( nProperty=0; nProperty<nPropertyCount; ++nProperty )
158*cdf0e10cSrcweir 	{
159*cdf0e10cSrcweir 		if( seqValues[ nProperty ].hasValue() )
160*cdf0e10cSrcweir 		{
161*cdf0e10cSrcweir 			switch( nProperty )
162*cdf0e10cSrcweir 			{
163*cdf0e10cSrcweir 				case PROPERTYHANDLE_WRITEROLE:
164*cdf0e10cSrcweir 				{
165*cdf0e10cSrcweir 					if( seqValues[ nProperty ].getValueTypeClass() == TypeClass_LONG )
166*cdf0e10cSrcweir 						seqValues[nProperty] >>= mnWriterOLE;
167*cdf0e10cSrcweir 				}
168*cdf0e10cSrcweir 				break;
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir 				case PROPERTYHANDLE_DRAWINGOLE:
171*cdf0e10cSrcweir 				{
172*cdf0e10cSrcweir 					if( seqValues[ nProperty ].getValueTypeClass() == TypeClass_LONG )
173*cdf0e10cSrcweir 						seqValues[nProperty] >>= mnDrawingOLE;
174*cdf0e10cSrcweir 				}
175*cdf0e10cSrcweir 				break;
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir 				case PROPERTYHANDLE_GRFMGR_TOTALSIZE:
178*cdf0e10cSrcweir 				{
179*cdf0e10cSrcweir 					if( seqValues[ nProperty ].getValueTypeClass() == TypeClass_LONG )
180*cdf0e10cSrcweir 						seqValues[nProperty] >>= mnGrfMgrTotalSize;
181*cdf0e10cSrcweir 				}
182*cdf0e10cSrcweir 				break;
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir 				case PROPERTYHANDLE_GRFMGR_OBJECTSIZE:
185*cdf0e10cSrcweir 				{
186*cdf0e10cSrcweir 					if( seqValues[ nProperty ].getValueTypeClass() == TypeClass_LONG )
187*cdf0e10cSrcweir 						seqValues[nProperty] >>= mnGrfMgrObjectSize;
188*cdf0e10cSrcweir 				}
189*cdf0e10cSrcweir 				break;
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir 				case PROPERTYHANDLE_GRFMGR_OBJECTRELEASE:
192*cdf0e10cSrcweir 				{
193*cdf0e10cSrcweir 					if( seqValues[ nProperty ].getValueTypeClass() == TypeClass_LONG )
194*cdf0e10cSrcweir 						seqValues[nProperty] >>= mnGrfMgrObjectRelease;
195*cdf0e10cSrcweir 				}
196*cdf0e10cSrcweir 				break;
197*cdf0e10cSrcweir 			}
198*cdf0e10cSrcweir 		}
199*cdf0e10cSrcweir 	}
200*cdf0e10cSrcweir }
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir //*****************************************************************************************************************
203*cdf0e10cSrcweir //	destructor
204*cdf0e10cSrcweir //*****************************************************************************************************************
205*cdf0e10cSrcweir SvtCacheOptions_Impl::~SvtCacheOptions_Impl()
206*cdf0e10cSrcweir {
207*cdf0e10cSrcweir 	if( IsModified() )
208*cdf0e10cSrcweir 		Commit();
209*cdf0e10cSrcweir }
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir //*****************************************************************************************************************
212*cdf0e10cSrcweir //	Commit
213*cdf0e10cSrcweir //*****************************************************************************************************************
214*cdf0e10cSrcweir void SvtCacheOptions_Impl::Commit()
215*cdf0e10cSrcweir {
216*cdf0e10cSrcweir 	Sequence< OUString >	aSeqNames( impl_GetPropertyNames() );
217*cdf0e10cSrcweir 	Sequence< Any >			aSeqValues( aSeqNames.getLength() );
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir 	for( sal_Int32 nProperty = 0, nCount = aSeqNames.getLength(); nProperty < nCount; ++nProperty )
220*cdf0e10cSrcweir 	{
221*cdf0e10cSrcweir         switch( nProperty )
222*cdf0e10cSrcweir         {
223*cdf0e10cSrcweir             case PROPERTYHANDLE_WRITEROLE:
224*cdf0e10cSrcweir 				aSeqValues[nProperty] <<= mnWriterOLE;
225*cdf0e10cSrcweir 			break;
226*cdf0e10cSrcweir 
227*cdf0e10cSrcweir             case PROPERTYHANDLE_DRAWINGOLE:
228*cdf0e10cSrcweir 				aSeqValues[nProperty] <<= mnDrawingOLE;
229*cdf0e10cSrcweir 			break;
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir             case PROPERTYHANDLE_GRFMGR_TOTALSIZE:
232*cdf0e10cSrcweir 				aSeqValues[nProperty] <<= mnGrfMgrTotalSize;
233*cdf0e10cSrcweir 			break;
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir             case PROPERTYHANDLE_GRFMGR_OBJECTSIZE:
236*cdf0e10cSrcweir 				aSeqValues[nProperty] <<= mnGrfMgrObjectSize;
237*cdf0e10cSrcweir 			break;
238*cdf0e10cSrcweir 
239*cdf0e10cSrcweir             case PROPERTYHANDLE_GRFMGR_OBJECTRELEASE:
240*cdf0e10cSrcweir 				aSeqValues[nProperty] <<= mnGrfMgrObjectRelease;
241*cdf0e10cSrcweir 			break;
242*cdf0e10cSrcweir         }
243*cdf0e10cSrcweir 	}
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir 	PutProperties( aSeqNames, aSeqValues );
246*cdf0e10cSrcweir }
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir void SvtCacheOptions_Impl::Notify( const Sequence< rtl::OUString >&  )
249*cdf0e10cSrcweir {
250*cdf0e10cSrcweir }
251*cdf0e10cSrcweir 
252*cdf0e10cSrcweir //*****************************************************************************************************************
253*cdf0e10cSrcweir //	public method
254*cdf0e10cSrcweir //*****************************************************************************************************************
255*cdf0e10cSrcweir sal_Int32 SvtCacheOptions_Impl::GetWriterOLE_Objects() const
256*cdf0e10cSrcweir {
257*cdf0e10cSrcweir 	return mnWriterOLE;
258*cdf0e10cSrcweir }
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir //*****************************************************************************************************************
261*cdf0e10cSrcweir //	public method
262*cdf0e10cSrcweir //*****************************************************************************************************************
263*cdf0e10cSrcweir sal_Int32 SvtCacheOptions_Impl::GetDrawingEngineOLE_Objects() const
264*cdf0e10cSrcweir {
265*cdf0e10cSrcweir 	return mnDrawingOLE;
266*cdf0e10cSrcweir }
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir //*****************************************************************************************************************
269*cdf0e10cSrcweir //	public method
270*cdf0e10cSrcweir //*****************************************************************************************************************
271*cdf0e10cSrcweir sal_Int32 SvtCacheOptions_Impl::GetGraphicManagerTotalCacheSize() const
272*cdf0e10cSrcweir {
273*cdf0e10cSrcweir 	return mnGrfMgrTotalSize;
274*cdf0e10cSrcweir }
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir //*****************************************************************************************************************
277*cdf0e10cSrcweir //	public method
278*cdf0e10cSrcweir //*****************************************************************************************************************
279*cdf0e10cSrcweir sal_Int32 SvtCacheOptions_Impl::GetGraphicManagerObjectCacheSize() const
280*cdf0e10cSrcweir {
281*cdf0e10cSrcweir 	return mnGrfMgrObjectSize;
282*cdf0e10cSrcweir }
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir //*****************************************************************************************************************
285*cdf0e10cSrcweir //	public method
286*cdf0e10cSrcweir //*****************************************************************************************************************
287*cdf0e10cSrcweir sal_Int32 SvtCacheOptions_Impl::GetGraphicManagerObjectReleaseTime() const
288*cdf0e10cSrcweir {
289*cdf0e10cSrcweir 	return mnGrfMgrObjectRelease;
290*cdf0e10cSrcweir }
291*cdf0e10cSrcweir 
292*cdf0e10cSrcweir //*****************************************************************************************************************
293*cdf0e10cSrcweir //	public method
294*cdf0e10cSrcweir //*****************************************************************************************************************
295*cdf0e10cSrcweir void SvtCacheOptions_Impl::SetWriterOLE_Objects( sal_Int32 nWriterOLE )
296*cdf0e10cSrcweir {
297*cdf0e10cSrcweir 	mnWriterOLE = nWriterOLE;
298*cdf0e10cSrcweir 	SetModified();
299*cdf0e10cSrcweir }
300*cdf0e10cSrcweir 
301*cdf0e10cSrcweir //*****************************************************************************************************************
302*cdf0e10cSrcweir //	public method
303*cdf0e10cSrcweir //*****************************************************************************************************************
304*cdf0e10cSrcweir void SvtCacheOptions_Impl::SetDrawingEngineOLE_Objects( sal_Int32 nDrawingOLE )
305*cdf0e10cSrcweir {
306*cdf0e10cSrcweir 	mnDrawingOLE = nDrawingOLE;
307*cdf0e10cSrcweir 	SetModified();
308*cdf0e10cSrcweir }
309*cdf0e10cSrcweir 
310*cdf0e10cSrcweir //*****************************************************************************************************************
311*cdf0e10cSrcweir //	public method
312*cdf0e10cSrcweir //*****************************************************************************************************************
313*cdf0e10cSrcweir void SvtCacheOptions_Impl::SetGraphicManagerTotalCacheSize( sal_Int32 nGrfMgrTotalSize )
314*cdf0e10cSrcweir {
315*cdf0e10cSrcweir 	mnGrfMgrTotalSize = nGrfMgrTotalSize;
316*cdf0e10cSrcweir 	SetModified();
317*cdf0e10cSrcweir }
318*cdf0e10cSrcweir 
319*cdf0e10cSrcweir //*****************************************************************************************************************
320*cdf0e10cSrcweir //	public method
321*cdf0e10cSrcweir //*****************************************************************************************************************
322*cdf0e10cSrcweir void SvtCacheOptions_Impl::SetGraphicManagerObjectCacheSize( sal_Int32 nGrfMgrObjectSize )
323*cdf0e10cSrcweir {
324*cdf0e10cSrcweir 	mnGrfMgrObjectSize = nGrfMgrObjectSize;
325*cdf0e10cSrcweir 	SetModified();
326*cdf0e10cSrcweir }
327*cdf0e10cSrcweir 
328*cdf0e10cSrcweir //*****************************************************************************************************************
329*cdf0e10cSrcweir //	public method
330*cdf0e10cSrcweir //*****************************************************************************************************************
331*cdf0e10cSrcweir void SvtCacheOptions_Impl::SetGraphicManagerObjectReleaseTime( sal_Int32 nGrfMgrObjectReleaseTime )
332*cdf0e10cSrcweir {
333*cdf0e10cSrcweir 	mnGrfMgrObjectRelease = nGrfMgrObjectReleaseTime;
334*cdf0e10cSrcweir 	SetModified();
335*cdf0e10cSrcweir }
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir //*****************************************************************************************************************
338*cdf0e10cSrcweir //	private method
339*cdf0e10cSrcweir //*****************************************************************************************************************
340*cdf0e10cSrcweir Sequence< OUString > SvtCacheOptions_Impl::impl_GetPropertyNames()
341*cdf0e10cSrcweir {
342*cdf0e10cSrcweir 	// Build static list of configuration key names.
343*cdf0e10cSrcweir 	static const OUString pProperties[] =
344*cdf0e10cSrcweir 	{
345*cdf0e10cSrcweir 		PROPERTYNAME_WRITEROLE,
346*cdf0e10cSrcweir 		PROPERTYNAME_DRAWINGOLE,
347*cdf0e10cSrcweir 		PROPERTYNAME_GRFMGR_TOTALSIZE,
348*cdf0e10cSrcweir 		PROPERTYNAME_GRFMGR_OBJECTSIZE,
349*cdf0e10cSrcweir 		PROPERTYNAME_GRFMGR_OBJECTRELEASE
350*cdf0e10cSrcweir 	};
351*cdf0e10cSrcweir 	// Initialize return sequence with these list ...
352*cdf0e10cSrcweir 	static const Sequence< OUString > seqPropertyNames( pProperties, PROPERTYCOUNT );
353*cdf0e10cSrcweir 	// ... and return it.
354*cdf0e10cSrcweir 	return seqPropertyNames;
355*cdf0e10cSrcweir }
356*cdf0e10cSrcweir 
357*cdf0e10cSrcweir //*****************************************************************************************************************
358*cdf0e10cSrcweir //	initialize static member
359*cdf0e10cSrcweir //	DON'T DO IT IN YOUR HEADER!
360*cdf0e10cSrcweir //	see definition for further informations
361*cdf0e10cSrcweir //*****************************************************************************************************************
362*cdf0e10cSrcweir SvtCacheOptions_Impl*	SvtCacheOptions::m_pDataContainer = NULL;
363*cdf0e10cSrcweir sal_Int32				SvtCacheOptions::m_nRefCount = 0;
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir //*****************************************************************************************************************
366*cdf0e10cSrcweir //	constructor
367*cdf0e10cSrcweir //*****************************************************************************************************************
368*cdf0e10cSrcweir SvtCacheOptions::SvtCacheOptions()
369*cdf0e10cSrcweir {
370*cdf0e10cSrcweir     // Global access, must be guarded (multithreading!).
371*cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
372*cdf0e10cSrcweir 	// Increase ouer refcount ...
373*cdf0e10cSrcweir 	++m_nRefCount;
374*cdf0e10cSrcweir 	// ... and initialize ouer data container only if it not already!
375*cdf0e10cSrcweir     if( m_pDataContainer == NULL )
376*cdf0e10cSrcweir 	{
377*cdf0e10cSrcweir         m_pDataContainer = new SvtCacheOptions_Impl();
378*cdf0e10cSrcweir 	}
379*cdf0e10cSrcweir }
380*cdf0e10cSrcweir 
381*cdf0e10cSrcweir //*****************************************************************************************************************
382*cdf0e10cSrcweir //	destructor
383*cdf0e10cSrcweir //*****************************************************************************************************************
384*cdf0e10cSrcweir SvtCacheOptions::~SvtCacheOptions()
385*cdf0e10cSrcweir {
386*cdf0e10cSrcweir     // Global access, must be guarded (multithreading!)
387*cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
388*cdf0e10cSrcweir 	// Decrease ouer refcount.
389*cdf0e10cSrcweir 	--m_nRefCount;
390*cdf0e10cSrcweir 	// If last instance was deleted ...
391*cdf0e10cSrcweir 	// we must destroy ouer static data container!
392*cdf0e10cSrcweir     if( m_nRefCount <= 0 )
393*cdf0e10cSrcweir 	{
394*cdf0e10cSrcweir 		delete m_pDataContainer;
395*cdf0e10cSrcweir 		m_pDataContainer = NULL;
396*cdf0e10cSrcweir 	}
397*cdf0e10cSrcweir }
398*cdf0e10cSrcweir 
399*cdf0e10cSrcweir //*****************************************************************************************************************
400*cdf0e10cSrcweir //	public method
401*cdf0e10cSrcweir //*****************************************************************************************************************
402*cdf0e10cSrcweir sal_Int32 SvtCacheOptions::GetWriterOLE_Objects() const
403*cdf0e10cSrcweir {
404*cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
405*cdf0e10cSrcweir 	return m_pDataContainer->GetWriterOLE_Objects();
406*cdf0e10cSrcweir }
407*cdf0e10cSrcweir 
408*cdf0e10cSrcweir //*****************************************************************************************************************
409*cdf0e10cSrcweir //	public method
410*cdf0e10cSrcweir //*****************************************************************************************************************
411*cdf0e10cSrcweir sal_Int32 SvtCacheOptions::GetDrawingEngineOLE_Objects() const
412*cdf0e10cSrcweir {
413*cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
414*cdf0e10cSrcweir 	return m_pDataContainer->GetDrawingEngineOLE_Objects();
415*cdf0e10cSrcweir }
416*cdf0e10cSrcweir 
417*cdf0e10cSrcweir //*****************************************************************************************************************
418*cdf0e10cSrcweir //	public method
419*cdf0e10cSrcweir //*****************************************************************************************************************
420*cdf0e10cSrcweir sal_Int32 SvtCacheOptions::GetGraphicManagerTotalCacheSize() const
421*cdf0e10cSrcweir {
422*cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
423*cdf0e10cSrcweir 	return m_pDataContainer->GetGraphicManagerTotalCacheSize();
424*cdf0e10cSrcweir }
425*cdf0e10cSrcweir 
426*cdf0e10cSrcweir //*****************************************************************************************************************
427*cdf0e10cSrcweir //	public method
428*cdf0e10cSrcweir //*****************************************************************************************************************
429*cdf0e10cSrcweir sal_Int32 SvtCacheOptions::GetGraphicManagerObjectCacheSize() const
430*cdf0e10cSrcweir {
431*cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
432*cdf0e10cSrcweir 	return m_pDataContainer->GetGraphicManagerObjectCacheSize();
433*cdf0e10cSrcweir }
434*cdf0e10cSrcweir 
435*cdf0e10cSrcweir //*****************************************************************************************************************
436*cdf0e10cSrcweir //	public method
437*cdf0e10cSrcweir //*****************************************************************************************************************
438*cdf0e10cSrcweir sal_Int32 SvtCacheOptions::GetGraphicManagerObjectReleaseTime() const
439*cdf0e10cSrcweir {
440*cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
441*cdf0e10cSrcweir 	return m_pDataContainer->GetGraphicManagerObjectReleaseTime();
442*cdf0e10cSrcweir }
443*cdf0e10cSrcweir 
444*cdf0e10cSrcweir //*****************************************************************************************************************
445*cdf0e10cSrcweir //	public method
446*cdf0e10cSrcweir //*****************************************************************************************************************
447*cdf0e10cSrcweir void SvtCacheOptions::SetWriterOLE_Objects( sal_Int32 nWriterOLE )
448*cdf0e10cSrcweir {
449*cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
450*cdf0e10cSrcweir 	m_pDataContainer->SetWriterOLE_Objects( nWriterOLE );
451*cdf0e10cSrcweir }
452*cdf0e10cSrcweir 
453*cdf0e10cSrcweir //*****************************************************************************************************************
454*cdf0e10cSrcweir //	public method
455*cdf0e10cSrcweir //*****************************************************************************************************************
456*cdf0e10cSrcweir void SvtCacheOptions::SetDrawingEngineOLE_Objects( sal_Int32 nDrawingOLE )
457*cdf0e10cSrcweir {
458*cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
459*cdf0e10cSrcweir 	m_pDataContainer->SetDrawingEngineOLE_Objects( nDrawingOLE );
460*cdf0e10cSrcweir }
461*cdf0e10cSrcweir 
462*cdf0e10cSrcweir //*****************************************************************************************************************
463*cdf0e10cSrcweir //	public method
464*cdf0e10cSrcweir //*****************************************************************************************************************
465*cdf0e10cSrcweir void SvtCacheOptions::SetGraphicManagerTotalCacheSize( sal_Int32 nGrfMgrTotalSize )
466*cdf0e10cSrcweir {
467*cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
468*cdf0e10cSrcweir 	m_pDataContainer->SetGraphicManagerTotalCacheSize( nGrfMgrTotalSize );
469*cdf0e10cSrcweir }
470*cdf0e10cSrcweir 
471*cdf0e10cSrcweir //*****************************************************************************************************************
472*cdf0e10cSrcweir //	public method
473*cdf0e10cSrcweir //*****************************************************************************************************************
474*cdf0e10cSrcweir void SvtCacheOptions::SetGraphicManagerObjectCacheSize( sal_Int32 nGrfMgrObjectSize )
475*cdf0e10cSrcweir {
476*cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
477*cdf0e10cSrcweir 	m_pDataContainer->SetGraphicManagerObjectCacheSize( nGrfMgrObjectSize );
478*cdf0e10cSrcweir }
479*cdf0e10cSrcweir 
480*cdf0e10cSrcweir //*****************************************************************************************************************
481*cdf0e10cSrcweir //	public method
482*cdf0e10cSrcweir //*****************************************************************************************************************
483*cdf0e10cSrcweir void SvtCacheOptions::SetGraphicManagerObjectReleaseTime( sal_Int32 nGrfMgrObjectReleaseTime )
484*cdf0e10cSrcweir {
485*cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
486*cdf0e10cSrcweir 	m_pDataContainer->SetGraphicManagerObjectReleaseTime( nGrfMgrObjectReleaseTime );
487*cdf0e10cSrcweir }
488*cdf0e10cSrcweir 
489*cdf0e10cSrcweir //*****************************************************************************************************************
490*cdf0e10cSrcweir //	private method
491*cdf0e10cSrcweir //*****************************************************************************************************************
492*cdf0e10cSrcweir Mutex& SvtCacheOptions::GetOwnStaticMutex()
493*cdf0e10cSrcweir {
494*cdf0e10cSrcweir 	// Initialize static mutex only for one time!
495*cdf0e10cSrcweir     static Mutex* pMutex = NULL;
496*cdf0e10cSrcweir 	// If these method first called (Mutex not already exist!) ...
497*cdf0e10cSrcweir     if( pMutex == NULL )
498*cdf0e10cSrcweir     {
499*cdf0e10cSrcweir 		// ... we must create a new one. Protect follow code with the global mutex -
500*cdf0e10cSrcweir 		// It must be - we create a static variable!
501*cdf0e10cSrcweir         MutexGuard aGuard( Mutex::getGlobalMutex() );
502*cdf0e10cSrcweir 		// We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
503*cdf0e10cSrcweir         if( pMutex == NULL )
504*cdf0e10cSrcweir         {
505*cdf0e10cSrcweir 			// Create the new mutex and set it for return on static variable.
506*cdf0e10cSrcweir             static Mutex aMutex;
507*cdf0e10cSrcweir             pMutex = &aMutex;
508*cdf0e10cSrcweir         }
509*cdf0e10cSrcweir     }
510*cdf0e10cSrcweir 	// Return new created or already existing mutex object.
511*cdf0e10cSrcweir     return *pMutex;
512*cdf0e10cSrcweir }
513