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