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/historyoptions.hxx>
34cdf0e10cSrcweir #include <unotools/historyoptions_const.hxx>
35cdf0e10cSrcweir #include <unotools/configmgr.hxx>
36cdf0e10cSrcweir #include <unotools/configitem.hxx>
37cdf0e10cSrcweir #include <tools/debug.hxx>
38cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx>
39cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
40cdf0e10cSrcweir 
41cdf0e10cSrcweir #ifndef __SGI_STL_DEQUE
42cdf0e10cSrcweir #include <deque>
43cdf0e10cSrcweir #endif
44cdf0e10cSrcweir 
45cdf0e10cSrcweir #ifndef __SGI_STL_ALGORITHM
46cdf0e10cSrcweir #include <algorithm>
47cdf0e10cSrcweir #endif
48cdf0e10cSrcweir 
49cdf0e10cSrcweir #include <rtl/logfile.hxx>
50cdf0e10cSrcweir #include "itemholder1.hxx"
51cdf0e10cSrcweir 
52cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
53cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
54cdf0e10cSrcweir #endif
55cdf0e10cSrcweir 
56cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
57cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
58cdf0e10cSrcweir #endif
59cdf0e10cSrcweir 
60cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
61cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp>
62cdf0e10cSrcweir #endif
63cdf0e10cSrcweir 
64cdf0e10cSrcweir #ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
65cdf0e10cSrcweir #include <com/sun/star/lang/XSingleServiceFactory.hpp>
66cdf0e10cSrcweir #endif
67cdf0e10cSrcweir 
68cdf0e10cSrcweir #ifndef _COMPHELPER_CONFIGURATIONHELPER_HXX_
69cdf0e10cSrcweir #include <comphelper/configurationhelper.hxx>
70cdf0e10cSrcweir #endif
71cdf0e10cSrcweir 
72cdf0e10cSrcweir #ifndef _UNOTOOLS_PROCESSFACTORY_HXX_
73cdf0e10cSrcweir #include <unotools/processfactory.hxx>
74cdf0e10cSrcweir #endif
75cdf0e10cSrcweir 
76cdf0e10cSrcweir #ifndef _SVT_LOGHELPER_HXX
77cdf0e10cSrcweir #include <unotools/loghelper.hxx>
78cdf0e10cSrcweir #endif
79cdf0e10cSrcweir 
80cdf0e10cSrcweir //_________________________________________________________________________________________________________________
81cdf0e10cSrcweir // namespaces
82cdf0e10cSrcweir //_________________________________________________________________________________________________________________
83cdf0e10cSrcweir 
84cdf0e10cSrcweir using namespace ::std     ;
85cdf0e10cSrcweir using namespace ::utl     ;
86cdf0e10cSrcweir using namespace ::rtl     ;
87cdf0e10cSrcweir using namespace ::osl     ;
88cdf0e10cSrcweir using namespace ::com::sun::star::uno ;
89cdf0e10cSrcweir using namespace ::com::sun::star::beans ;
90cdf0e10cSrcweir 
91cdf0e10cSrcweir namespace css = ::com::sun::star;
92cdf0e10cSrcweir 
93cdf0e10cSrcweir //_________________________________________________________________________________________________________________
94cdf0e10cSrcweir // const
95cdf0e10cSrcweir //_________________________________________________________________________________________________________________
96cdf0e10cSrcweir 
97cdf0e10cSrcweir namespace {
98cdf0e10cSrcweir 	static const ::sal_Int32 s_nOffsetURL               = 0;
99cdf0e10cSrcweir 	static const ::sal_Int32 s_nOffsetFilter            = 1;
100cdf0e10cSrcweir 	static const ::sal_Int32 s_nOffsetTitle             = 2;
101cdf0e10cSrcweir 	static const ::sal_Int32 s_nOffsetPassword          = 3;
102cdf0e10cSrcweir }
103cdf0e10cSrcweir 
104cdf0e10cSrcweir //_________________________________________________________________________________________________________________
105cdf0e10cSrcweir // private declarations!
106cdf0e10cSrcweir //_________________________________________________________________________________________________________________
107cdf0e10cSrcweir 
108cdf0e10cSrcweir struct IMPL_THistoryItem
109cdf0e10cSrcweir {
IMPL_THistoryItemIMPL_THistoryItem110cdf0e10cSrcweir 	IMPL_THistoryItem()
111cdf0e10cSrcweir 	{
112cdf0e10cSrcweir 	}
113cdf0e10cSrcweir 
IMPL_THistoryItemIMPL_THistoryItem114cdf0e10cSrcweir 	IMPL_THistoryItem( const OUString& sNewURL   ,
115cdf0e10cSrcweir 		const OUString& sNewFilter  ,
116cdf0e10cSrcweir 		const OUString& sNewTitle  ,
117cdf0e10cSrcweir 		const OUString& sNewPassword )
118cdf0e10cSrcweir 	{
119cdf0e10cSrcweir 		sURL  = sNewURL  ;
120cdf0e10cSrcweir 		sFilter  = sNewFilter ;
121cdf0e10cSrcweir 		sTitle  = sNewTitle  ;
122cdf0e10cSrcweir 		sPassword = sNewPassword ;
123cdf0e10cSrcweir 	}
124cdf0e10cSrcweir 
operator ==IMPL_THistoryItem125cdf0e10cSrcweir 	sal_Bool operator==( const OUString& sSearchedURL )
126cdf0e10cSrcweir 	{
127cdf0e10cSrcweir 		return( sURL == sSearchedURL );
128cdf0e10cSrcweir 	}
129cdf0e10cSrcweir 
130cdf0e10cSrcweir 	OUString sURL  ;
131cdf0e10cSrcweir 	OUString sFilter  ;
132cdf0e10cSrcweir 	OUString sTitle  ;
133cdf0e10cSrcweir 	OUString sPassword ;
134cdf0e10cSrcweir };
135cdf0e10cSrcweir 
136cdf0e10cSrcweir //*****************************************************************************************************************
137cdf0e10cSrcweir //  class SvtHistoryOptions_Impl
138cdf0e10cSrcweir //  redesigned
139cdf0e10cSrcweir //*****************************************************************************************************************
140cdf0e10cSrcweir class SvtHistoryOptions_Impl
141cdf0e10cSrcweir {
142cdf0e10cSrcweir public:
143cdf0e10cSrcweir 	SvtHistoryOptions_Impl();
144cdf0e10cSrcweir 	~SvtHistoryOptions_Impl();
145cdf0e10cSrcweir 
146cdf0e10cSrcweir 	sal_uInt32 GetSize( EHistoryType eHistory );
147cdf0e10cSrcweir 	void SetSize( EHistoryType eHistory, sal_uInt32 nSize );
148cdf0e10cSrcweir 	void Clear( EHistoryType eHistory );
149cdf0e10cSrcweir 	Sequence< Sequence< PropertyValue > > GetList( EHistoryType eHistory );
150cdf0e10cSrcweir 	void                                  AppendItem(       EHistoryType eHistory ,
151cdf0e10cSrcweir 		const OUString&    sURL     ,
152cdf0e10cSrcweir 		const OUString&    sFilter  ,
153cdf0e10cSrcweir 		const OUString&    sTitle   ,
154cdf0e10cSrcweir 		const OUString&    sPassword );
155cdf0e10cSrcweir 
156cdf0e10cSrcweir private:
157cdf0e10cSrcweir     void impl_truncateList (EHistoryType eHistory, sal_uInt32 nSize);
158cdf0e10cSrcweir 
159cdf0e10cSrcweir private:
160cdf0e10cSrcweir 	css::uno::Reference< css::container::XNameAccess > m_xCfg;
161cdf0e10cSrcweir 	css::uno::Reference< css::container::XNameAccess > m_xCommonXCU;
162cdf0e10cSrcweir };
163cdf0e10cSrcweir 
164cdf0e10cSrcweir //*****************************************************************************************************************
165cdf0e10cSrcweir //  constructor
166cdf0e10cSrcweir //*****************************************************************************************************************
SvtHistoryOptions_Impl()167cdf0e10cSrcweir SvtHistoryOptions_Impl::SvtHistoryOptions_Impl()
168cdf0e10cSrcweir {
169cdf0e10cSrcweir 	try
170cdf0e10cSrcweir 	{
171cdf0e10cSrcweir 		m_xCfg = Reference< css::container::XNameAccess > (
172cdf0e10cSrcweir 			::comphelper::ConfigurationHelper::openConfig(
173cdf0e10cSrcweir 			utl::getProcessServiceFactory(),
174cdf0e10cSrcweir 			s_sHistories,
175cdf0e10cSrcweir 			::comphelper::ConfigurationHelper::E_STANDARD),
176cdf0e10cSrcweir 			css::uno::UNO_QUERY );
177cdf0e10cSrcweir 
178cdf0e10cSrcweir 		m_xCommonXCU = Reference< css::container::XNameAccess > (
179cdf0e10cSrcweir 			::comphelper::ConfigurationHelper::openConfig(
180cdf0e10cSrcweir 			utl::getProcessServiceFactory(),
181cdf0e10cSrcweir 			s_sCommonHistory,
182cdf0e10cSrcweir 			::comphelper::ConfigurationHelper::E_STANDARD),
183cdf0e10cSrcweir 			css::uno::UNO_QUERY );
184cdf0e10cSrcweir 	}
185cdf0e10cSrcweir 	catch(const css::uno::Exception& ex)
186cdf0e10cSrcweir 	{
187cdf0e10cSrcweir 		m_xCfg.clear();
188cdf0e10cSrcweir 		m_xCommonXCU.clear();
189cdf0e10cSrcweir 
190cdf0e10cSrcweir 		LogHelper::logIt(ex);
191cdf0e10cSrcweir 	}
192cdf0e10cSrcweir }
193cdf0e10cSrcweir 
194cdf0e10cSrcweir //*****************************************************************************************************************
195cdf0e10cSrcweir //  destructor
196cdf0e10cSrcweir //*****************************************************************************************************************
~SvtHistoryOptions_Impl()197cdf0e10cSrcweir SvtHistoryOptions_Impl::~SvtHistoryOptions_Impl()
198cdf0e10cSrcweir {
199cdf0e10cSrcweir }
200cdf0e10cSrcweir 
201cdf0e10cSrcweir //*****************************************************************************************************************
202cdf0e10cSrcweir //  public method
203cdf0e10cSrcweir //  Attention: We return the max. size of our internal lists - That is the capacity not the size!
204cdf0e10cSrcweir //*****************************************************************************************************************
GetSize(EHistoryType eHistory)205cdf0e10cSrcweir sal_uInt32 SvtHistoryOptions_Impl::GetSize( EHistoryType eHistory )
206cdf0e10cSrcweir {
207cdf0e10cSrcweir 	sal_uInt32                                       nSize = 0  ;
208cdf0e10cSrcweir 	css::uno::Reference< css::beans::XPropertySet >  xListAccess(m_xCommonXCU, css::uno::UNO_QUERY);
209cdf0e10cSrcweir 
210cdf0e10cSrcweir 	try
211cdf0e10cSrcweir 	{
212cdf0e10cSrcweir 		switch( eHistory )
213cdf0e10cSrcweir 		{
214cdf0e10cSrcweir 		case ePICKLIST:
215cdf0e10cSrcweir 			xListAccess->getPropertyValue(s_sPickListSize) >>= nSize;
216cdf0e10cSrcweir 			break;
217cdf0e10cSrcweir 
218cdf0e10cSrcweir 		case eHISTORY:
219cdf0e10cSrcweir 			xListAccess->getPropertyValue(s_sURLHistorySize) >>= nSize;
220cdf0e10cSrcweir 			break;
221cdf0e10cSrcweir 
222cdf0e10cSrcweir 		case eHELPBOOKMARKS:
223cdf0e10cSrcweir 			xListAccess->getPropertyValue(s_sHelpBookmarksSize) >>= nSize;
224cdf0e10cSrcweir 			break;
225cdf0e10cSrcweir 
226cdf0e10cSrcweir 		default:
227cdf0e10cSrcweir 			break;
228cdf0e10cSrcweir 		}
229cdf0e10cSrcweir 	}
230cdf0e10cSrcweir 	catch(const css::uno::Exception& ex)
231cdf0e10cSrcweir 	{
232cdf0e10cSrcweir 		LogHelper::logIt(ex);
233cdf0e10cSrcweir 	}
234cdf0e10cSrcweir 
235cdf0e10cSrcweir 	return nSize;
236cdf0e10cSrcweir }
237cdf0e10cSrcweir 
238cdf0e10cSrcweir //*****************************************************************************************************************
239cdf0e10cSrcweir //  public method
240cdf0e10cSrcweir //  Attention: We return the max. size of our internal lists - That is the capacity not the size!
241cdf0e10cSrcweir //*****************************************************************************************************************
SetSize(EHistoryType eHistory,sal_uInt32 nSize)242cdf0e10cSrcweir void SvtHistoryOptions_Impl::SetSize( EHistoryType eHistory, sal_uInt32 nSize )
243cdf0e10cSrcweir {
244cdf0e10cSrcweir 	css::uno::Reference< css::beans::XPropertySet > xListAccess(m_xCommonXCU, css::uno::UNO_QUERY);
245cdf0e10cSrcweir     if (! xListAccess.is ())
246cdf0e10cSrcweir         return;
247cdf0e10cSrcweir 
248cdf0e10cSrcweir 	try
249cdf0e10cSrcweir 	{
250cdf0e10cSrcweir 		switch( eHistory )
251cdf0e10cSrcweir 		{
252cdf0e10cSrcweir 		case ePICKLIST:
253cdf0e10cSrcweir 			if(nSize!=GetSize(ePICKLIST))
254cdf0e10cSrcweir 			{
255cdf0e10cSrcweir 				xListAccess->setPropertyValue(s_sPickListSize, css::uno::makeAny(nSize));
256cdf0e10cSrcweir 				::comphelper::ConfigurationHelper::flush(m_xCommonXCU);
257cdf0e10cSrcweir 			}
258cdf0e10cSrcweir 			break;
259cdf0e10cSrcweir 
260cdf0e10cSrcweir 		case eHISTORY:
261cdf0e10cSrcweir 			if(nSize!=GetSize(eHISTORY))
262cdf0e10cSrcweir 			{
263cdf0e10cSrcweir 				xListAccess->setPropertyValue(s_sURLHistorySize, css::uno::makeAny(nSize));
264cdf0e10cSrcweir 				::comphelper::ConfigurationHelper::flush(m_xCommonXCU);
265cdf0e10cSrcweir 			}
266cdf0e10cSrcweir 			break;
267cdf0e10cSrcweir 
268cdf0e10cSrcweir 		case eHELPBOOKMARKS:
269cdf0e10cSrcweir 			if(nSize!=GetSize(eHELPBOOKMARKS))
270cdf0e10cSrcweir 			{
271cdf0e10cSrcweir 				xListAccess->setPropertyValue(s_sHelpBookmarksSize, css::uno::makeAny(nSize));
272cdf0e10cSrcweir 				::comphelper::ConfigurationHelper::flush(m_xCommonXCU);
273cdf0e10cSrcweir 			}
274cdf0e10cSrcweir 			break;
275cdf0e10cSrcweir 
276cdf0e10cSrcweir 		default:
277cdf0e10cSrcweir 			break;
278cdf0e10cSrcweir 		}
279cdf0e10cSrcweir 
280cdf0e10cSrcweir         impl_truncateList (eHistory, nSize);
281cdf0e10cSrcweir 	}
282cdf0e10cSrcweir 	catch(const css::uno::Exception& ex)
283cdf0e10cSrcweir 	{
284cdf0e10cSrcweir 		LogHelper::logIt(ex);
285cdf0e10cSrcweir 	}
286cdf0e10cSrcweir }
287cdf0e10cSrcweir 
288cdf0e10cSrcweir //*****************************************************************************************************************
impl_truncateList(EHistoryType eHistory,sal_uInt32 nSize)289cdf0e10cSrcweir void SvtHistoryOptions_Impl::impl_truncateList ( EHistoryType eHistory, sal_uInt32 nSize )
290cdf0e10cSrcweir {
291cdf0e10cSrcweir 	css::uno::Reference< css::container::XNameAccess >    xList;
292cdf0e10cSrcweir 	css::uno::Reference< css::container::XNameContainer > xItemList;
293cdf0e10cSrcweir 	css::uno::Reference< css::container::XNameContainer > xOrderList;
294cdf0e10cSrcweir 	css::uno::Reference< css::beans::XPropertySet >       xSet;
295cdf0e10cSrcweir 
296cdf0e10cSrcweir 	try
297cdf0e10cSrcweir 	{
298cdf0e10cSrcweir 		switch( eHistory )
299cdf0e10cSrcweir 		{
300cdf0e10cSrcweir 		case ePICKLIST:
301cdf0e10cSrcweir             m_xCfg->getByName(s_sPickList) >>= xList;
302cdf0e10cSrcweir 			break;
303cdf0e10cSrcweir 
304cdf0e10cSrcweir 		case eHISTORY:
305cdf0e10cSrcweir             m_xCfg->getByName(s_sURLHistory) >>= xList;
306cdf0e10cSrcweir 			break;
307cdf0e10cSrcweir 
308cdf0e10cSrcweir 		case eHELPBOOKMARKS:
309cdf0e10cSrcweir             m_xCfg->getByName(s_sHelpBookmarks) >>= xList;
310cdf0e10cSrcweir 			break;
311cdf0e10cSrcweir 
312cdf0e10cSrcweir 		default:
313cdf0e10cSrcweir 			break;
314cdf0e10cSrcweir 		}
315cdf0e10cSrcweir 
316cdf0e10cSrcweir 		// If too much items in current list ...
317cdf0e10cSrcweir 		// truncate the oldest items BEFORE you set the new one.
318cdf0e10cSrcweir 		if ( ! xList.is())
319cdf0e10cSrcweir             return;
320cdf0e10cSrcweir 
321cdf0e10cSrcweir         xList->getByName(s_sOrderList) >>= xOrderList;
322cdf0e10cSrcweir         xList->getByName(s_sItemList)  >>= xItemList;
323cdf0e10cSrcweir 
324cdf0e10cSrcweir         const sal_uInt32 nLength = xOrderList->getElementNames().getLength();
325cdf0e10cSrcweir         if (nSize < nLength)
326cdf0e10cSrcweir         {
327cdf0e10cSrcweir             for (sal_uInt32 i=nLength-1; i>=nSize; --i)
328cdf0e10cSrcweir             {
329cdf0e10cSrcweir                 ::rtl::OUString sTmp;
330cdf0e10cSrcweir                 const ::rtl::OUString sRemove = ::rtl::OUString::valueOf((sal_Int32)i);
331cdf0e10cSrcweir                 xOrderList->getByName(sRemove) >>= xSet;
332cdf0e10cSrcweir                 xSet->getPropertyValue(s_sHistoryItemRef) >>= sTmp;
333cdf0e10cSrcweir                 xItemList->removeByName(sTmp);
334cdf0e10cSrcweir                 xOrderList->removeByName(sRemove);
335cdf0e10cSrcweir             }
336cdf0e10cSrcweir 
337cdf0e10cSrcweir             ::comphelper::ConfigurationHelper::flush(m_xCfg);
338cdf0e10cSrcweir         }
339cdf0e10cSrcweir 	}
340cdf0e10cSrcweir 	catch(const css::uno::Exception& ex)
341cdf0e10cSrcweir 	{
342cdf0e10cSrcweir 		LogHelper::logIt(ex);
343cdf0e10cSrcweir 	}
344cdf0e10cSrcweir }
345cdf0e10cSrcweir 
346cdf0e10cSrcweir //*****************************************************************************************************************
347cdf0e10cSrcweir //  public method
348cdf0e10cSrcweir //  Clear specified history list
349cdf0e10cSrcweir //*****************************************************************************************************************
Clear(EHistoryType eHistory)350cdf0e10cSrcweir void SvtHistoryOptions_Impl::Clear( EHistoryType eHistory )
351cdf0e10cSrcweir {
352cdf0e10cSrcweir 	css::uno::Reference< css::container::XNameAccess >    xListAccess;
353cdf0e10cSrcweir 	css::uno::Reference< css::container::XNameContainer > xNode;
354cdf0e10cSrcweir 	Sequence< ::rtl::OUString >                           lOrders;
355cdf0e10cSrcweir 
356cdf0e10cSrcweir 	try
357cdf0e10cSrcweir 	{
358cdf0e10cSrcweir 		switch( eHistory )
359cdf0e10cSrcweir 		{
360cdf0e10cSrcweir 		case ePICKLIST:
361cdf0e10cSrcweir 			{
362cdf0e10cSrcweir 				m_xCfg->getByName(s_sPickList) >>= xListAccess;
363cdf0e10cSrcweir 				break;
364cdf0e10cSrcweir 			}
365cdf0e10cSrcweir 
366cdf0e10cSrcweir 		case eHISTORY:
367cdf0e10cSrcweir 			{
368cdf0e10cSrcweir 				m_xCfg->getByName(s_sURLHistory) >>= xListAccess;
369cdf0e10cSrcweir 				break;
370cdf0e10cSrcweir 			}
371cdf0e10cSrcweir 
372cdf0e10cSrcweir 		case eHELPBOOKMARKS:
373cdf0e10cSrcweir 			{
374cdf0e10cSrcweir 				m_xCfg->getByName(s_sHelpBookmarks) >>= xListAccess;
375cdf0e10cSrcweir 				break;
376cdf0e10cSrcweir 			}
377cdf0e10cSrcweir 
378cdf0e10cSrcweir 		default:
379cdf0e10cSrcweir 			break;
380cdf0e10cSrcweir 		}
381cdf0e10cSrcweir 
382cdf0e10cSrcweir 		if (xListAccess.is())
383cdf0e10cSrcweir 		{
384cdf0e10cSrcweir 			// clear ItemList
385cdf0e10cSrcweir 			xListAccess->getByName(s_sItemList)  >>= xNode  ;
386cdf0e10cSrcweir 			lOrders = xNode->getElementNames();
387cdf0e10cSrcweir 			const sal_Int32 nLength = lOrders.getLength();
388cdf0e10cSrcweir 			for(sal_Int32 i=0; i<nLength; ++i)
389cdf0e10cSrcweir 				xNode->removeByName(lOrders[i]);
390cdf0e10cSrcweir 
391cdf0e10cSrcweir 			// clear OrderList
392cdf0e10cSrcweir 			xListAccess->getByName(s_sOrderList) >>= xNode ;
393cdf0e10cSrcweir 			lOrders = xNode->getElementNames();
394cdf0e10cSrcweir 			for(sal_Int32 j=0; j<nLength; ++j)
395cdf0e10cSrcweir 				xNode->removeByName(lOrders[j]);
396cdf0e10cSrcweir 
397cdf0e10cSrcweir 			::comphelper::ConfigurationHelper::flush(m_xCfg);
398cdf0e10cSrcweir 		}
399cdf0e10cSrcweir 	}
400cdf0e10cSrcweir 	catch(const css::uno::Exception& ex)
401cdf0e10cSrcweir 	{
402cdf0e10cSrcweir 		LogHelper::logIt(ex);
403cdf0e10cSrcweir 	}
404cdf0e10cSrcweir }
405cdf0e10cSrcweir 
406cdf0e10cSrcweir //*****************************************************************************************************************
407cdf0e10cSrcweir //  public method
408cdf0e10cSrcweir //  get a sequence list from the items
409cdf0e10cSrcweir //*****************************************************************************************************************
GetList(EHistoryType eHistory)410cdf0e10cSrcweir Sequence< Sequence< PropertyValue > > SvtHistoryOptions_Impl::GetList( EHistoryType eHistory )
411cdf0e10cSrcweir {
412cdf0e10cSrcweir     impl_truncateList (eHistory, GetSize (eHistory));
413cdf0e10cSrcweir 
414cdf0e10cSrcweir 	Sequence< Sequence< PropertyValue > > seqReturn; // Set default return value.
415cdf0e10cSrcweir 	Sequence< PropertyValue >             seqProperties( 4 );
416cdf0e10cSrcweir 	Sequence< ::rtl::OUString >           lOrders;
417cdf0e10cSrcweir 
418cdf0e10cSrcweir 	css::uno::Reference< css::container::XNameAccess > xListAccess;
419cdf0e10cSrcweir 	css::uno::Reference< css::container::XNameAccess > xItemList;
420cdf0e10cSrcweir 	css::uno::Reference< css::container::XNameAccess > xOrderList;
421cdf0e10cSrcweir 	css::uno::Reference< css::beans::XPropertySet >    xSet;
422cdf0e10cSrcweir 
423cdf0e10cSrcweir 	seqProperties[s_nOffsetURL       ].Name = HISTORY_PROPERTYNAME_URL;
424cdf0e10cSrcweir 	seqProperties[s_nOffsetFilter    ].Name = HISTORY_PROPERTYNAME_FILTER;
425cdf0e10cSrcweir 	seqProperties[s_nOffsetTitle     ].Name = HISTORY_PROPERTYNAME_TITLE;
426cdf0e10cSrcweir 	seqProperties[s_nOffsetPassword  ].Name = HISTORY_PROPERTYNAME_PASSWORD;
427cdf0e10cSrcweir 
428cdf0e10cSrcweir 	try
429cdf0e10cSrcweir 	{
430cdf0e10cSrcweir 		switch( eHistory )
431cdf0e10cSrcweir 		{
432cdf0e10cSrcweir 		case ePICKLIST:
433cdf0e10cSrcweir 			{
434cdf0e10cSrcweir 				m_xCfg->getByName(s_sPickList) >>= xListAccess;
435cdf0e10cSrcweir 				break;
436cdf0e10cSrcweir 			}
437cdf0e10cSrcweir 
438cdf0e10cSrcweir 		case eHISTORY:
439cdf0e10cSrcweir 			{
440cdf0e10cSrcweir 				m_xCfg->getByName(s_sURLHistory) >>= xListAccess;
441cdf0e10cSrcweir 				break;
442cdf0e10cSrcweir 			}
443cdf0e10cSrcweir 
444cdf0e10cSrcweir 		case eHELPBOOKMARKS:
445cdf0e10cSrcweir 			{
446cdf0e10cSrcweir 				m_xCfg->getByName(s_sHelpBookmarks) >>= xListAccess;
447cdf0e10cSrcweir 				break;
448cdf0e10cSrcweir 			}
449cdf0e10cSrcweir 
450cdf0e10cSrcweir 		default:
451cdf0e10cSrcweir 			break;
452cdf0e10cSrcweir 		}
453cdf0e10cSrcweir 
454cdf0e10cSrcweir 		if (xListAccess.is())
455cdf0e10cSrcweir 		{
456cdf0e10cSrcweir 			xListAccess->getByName(s_sItemList)  >>= xItemList;
457cdf0e10cSrcweir 			xListAccess->getByName(s_sOrderList) >>= xOrderList;
458cdf0e10cSrcweir 
459cdf0e10cSrcweir 			const sal_Int32 nLength = xOrderList->getElementNames().getLength();
460cdf0e10cSrcweir 			Sequence< Sequence< PropertyValue > > aRet(nLength);
461cdf0e10cSrcweir 
462cdf0e10cSrcweir 			for(sal_Int32 nItem=0; nItem<nLength; ++nItem)
463cdf0e10cSrcweir 			{
464cdf0e10cSrcweir 				::rtl::OUString sUrl;
465cdf0e10cSrcweir 				xOrderList->getByName(::rtl::OUString::valueOf(nItem)) >>= xSet;
466cdf0e10cSrcweir 				xSet->getPropertyValue(s_sHistoryItemRef) >>= sUrl;
467cdf0e10cSrcweir 
468cdf0e10cSrcweir 				xItemList->getByName(sUrl) >>= xSet;
469cdf0e10cSrcweir 				seqProperties[s_nOffsetURL  ].Value <<= sUrl;
470cdf0e10cSrcweir 				xSet->getPropertyValue(s_sFilter)   >>= seqProperties[s_nOffsetFilter   ].Value;
471cdf0e10cSrcweir 				xSet->getPropertyValue(s_sTitle)    >>= seqProperties[s_nOffsetTitle    ].Value;
472cdf0e10cSrcweir 				xSet->getPropertyValue(s_sPassword) >>= seqProperties[s_nOffsetPassword ].Value;
473cdf0e10cSrcweir 				aRet[nItem] = seqProperties;
474cdf0e10cSrcweir 			}
475cdf0e10cSrcweir 			seqReturn = aRet;
476cdf0e10cSrcweir 		}
477cdf0e10cSrcweir 	}
478cdf0e10cSrcweir 	catch(const css::uno::Exception& ex)
479cdf0e10cSrcweir 	{
480cdf0e10cSrcweir 		LogHelper::logIt(ex);
481cdf0e10cSrcweir 	}
482cdf0e10cSrcweir 
483cdf0e10cSrcweir 	return seqReturn;
484cdf0e10cSrcweir }
485cdf0e10cSrcweir 
486cdf0e10cSrcweir //*****************************************************************************************************************
487cdf0e10cSrcweir //  public method
488cdf0e10cSrcweir //  implements a deque in XML
489cdf0e10cSrcweir //*****************************************************************************************************************
AppendItem(EHistoryType eHistory,const OUString & sURL,const OUString & sFilter,const OUString & sTitle,const OUString & sPassword)490cdf0e10cSrcweir void SvtHistoryOptions_Impl::AppendItem(       EHistoryType eHistory ,
491cdf0e10cSrcweir 										const OUString& sURL        ,
492cdf0e10cSrcweir 										const OUString& sFilter     ,
493cdf0e10cSrcweir 										const OUString& sTitle      ,
494cdf0e10cSrcweir 										const OUString& sPassword   )
495cdf0e10cSrcweir {
496cdf0e10cSrcweir     impl_truncateList (eHistory, GetSize (eHistory));
497cdf0e10cSrcweir 
498cdf0e10cSrcweir 	css::uno::Reference< css::container::XNameAccess > xListAccess;
499cdf0e10cSrcweir 	sal_Int32             nMaxSize = 0;
500cdf0e10cSrcweir 
501cdf0e10cSrcweir 	switch(eHistory)
502cdf0e10cSrcweir 	{
503cdf0e10cSrcweir 	case ePICKLIST:
504cdf0e10cSrcweir 		{
505cdf0e10cSrcweir 			m_xCfg->getByName(s_sPickList) >>= xListAccess;
506cdf0e10cSrcweir 			nMaxSize = GetSize(ePICKLIST);
507cdf0e10cSrcweir 		}
508cdf0e10cSrcweir 		break;
509cdf0e10cSrcweir 	case eHISTORY:
510cdf0e10cSrcweir 		{
511cdf0e10cSrcweir 			m_xCfg->getByName(s_sURLHistory) >>= xListAccess;
512cdf0e10cSrcweir 			nMaxSize = GetSize(eHISTORY);
513cdf0e10cSrcweir 		}
514cdf0e10cSrcweir 		break;
515cdf0e10cSrcweir 	case eHELPBOOKMARKS:
516cdf0e10cSrcweir 		{
517cdf0e10cSrcweir 			m_xCfg->getByName(s_sHelpBookmarks) >>= xListAccess;
518cdf0e10cSrcweir 			nMaxSize = GetSize(eHELPBOOKMARKS);
519cdf0e10cSrcweir 		}
520cdf0e10cSrcweir 		break;
521cdf0e10cSrcweir 	default:
522cdf0e10cSrcweir 		break;
523cdf0e10cSrcweir 	}
524cdf0e10cSrcweir 
525cdf0e10cSrcweir 	if (nMaxSize==0)
526cdf0e10cSrcweir 		return;
527cdf0e10cSrcweir 
528cdf0e10cSrcweir 	css::uno::Reference< css::container::XNameContainer > xItemList;
529cdf0e10cSrcweir 	css::uno::Reference< css::container::XNameContainer > xOrderList;
530cdf0e10cSrcweir 	css::uno::Reference< css::beans::XPropertySet >       xSet;
531cdf0e10cSrcweir 
532cdf0e10cSrcweir 	try
533cdf0e10cSrcweir 	{
534cdf0e10cSrcweir 		xListAccess->getByName(s_sItemList)  >>= xItemList;
535cdf0e10cSrcweir 		xListAccess->getByName(s_sOrderList) >>= xOrderList;
536cdf0e10cSrcweir 		sal_Int32 nLength = xOrderList->getElementNames().getLength();
537cdf0e10cSrcweir 
538cdf0e10cSrcweir 		// The item to be appended is already existing!
539cdf0e10cSrcweir 		if (xItemList->hasByName(sURL))
540cdf0e10cSrcweir 		{
541cdf0e10cSrcweir 			for (sal_Int32 i=0; i<nLength; ++i)
542cdf0e10cSrcweir 			{
543cdf0e10cSrcweir 				::rtl::OUString sTmp;
544cdf0e10cSrcweir 				xOrderList->getByName(::rtl::OUString::valueOf(i)) >>= xSet;
545cdf0e10cSrcweir 				xSet->getPropertyValue(s_sHistoryItemRef) >>= sTmp;
546cdf0e10cSrcweir 
547cdf0e10cSrcweir 				if(sURL == sTmp)
548cdf0e10cSrcweir 				{
549cdf0e10cSrcweir 					::rtl::OUString sFind;
550cdf0e10cSrcweir 					xOrderList->getByName( ::rtl::OUString::valueOf(i) ) >>= xSet;
551cdf0e10cSrcweir 					xSet->getPropertyValue(s_sHistoryItemRef) >>= sFind;
552cdf0e10cSrcweir 					for (sal_Int32 j=i-1; j>=0; --j)
553cdf0e10cSrcweir 					{
554cdf0e10cSrcweir 						css::uno::Reference< css::beans::XPropertySet > xPrevSet;
555cdf0e10cSrcweir 						css::uno::Reference< css::beans::XPropertySet > xNextSet;
556cdf0e10cSrcweir 						xOrderList->getByName( ::rtl::OUString::valueOf(j+1) )   >>= xPrevSet;
557cdf0e10cSrcweir 						xOrderList->getByName( ::rtl::OUString::valueOf(j) )     >>= xNextSet;
558cdf0e10cSrcweir 
559cdf0e10cSrcweir 						::rtl::OUString sTemp;
560cdf0e10cSrcweir 						xNextSet->getPropertyValue(s_sHistoryItemRef) >>= sTemp;
561cdf0e10cSrcweir 						xPrevSet->setPropertyValue(s_sHistoryItemRef, css::uno::makeAny(sTemp));
562cdf0e10cSrcweir 					}
563cdf0e10cSrcweir 					xOrderList->getByName( ::rtl::OUString::valueOf((sal_Int32)0) ) >>= xSet;
564cdf0e10cSrcweir 					xSet->setPropertyValue(s_sHistoryItemRef, css::uno::makeAny(sFind));
565cdf0e10cSrcweir 
566cdf0e10cSrcweir 					::comphelper::ConfigurationHelper::flush(m_xCfg);
567cdf0e10cSrcweir 					break;
568cdf0e10cSrcweir 				}
569cdf0e10cSrcweir 			}
570cdf0e10cSrcweir 		}
571cdf0e10cSrcweir 
572cdf0e10cSrcweir 		// The item to be appended is not existing!
573cdf0e10cSrcweir 		else
574cdf0e10cSrcweir 		{
575cdf0e10cSrcweir 			css::uno::Reference< css::lang::XSingleServiceFactory > xFac;
576cdf0e10cSrcweir 			css::uno::Reference< css::uno::XInterface >             xInst;
577cdf0e10cSrcweir 			css::uno::Reference< css::beans::XPropertySet > xPrevSet;
578cdf0e10cSrcweir 			css::uno::Reference< css::beans::XPropertySet > xNextSet;
579cdf0e10cSrcweir 
580cdf0e10cSrcweir 			// Append new item to OrderList.
581cdf0e10cSrcweir 			if ( nLength == nMaxSize )
582cdf0e10cSrcweir 			{
583cdf0e10cSrcweir 				::rtl::OUString sRemove;
584cdf0e10cSrcweir 				xOrderList->getByName(::rtl::OUString::valueOf(nLength-1)) >>= xSet;
585cdf0e10cSrcweir 				xSet->getPropertyValue(s_sHistoryItemRef) >>= sRemove;
586cdf0e10cSrcweir 				xItemList->removeByName(sRemove);
587cdf0e10cSrcweir 			}
588cdf0e10cSrcweir 			if ( nLength != nMaxSize )
589cdf0e10cSrcweir 			{
590cdf0e10cSrcweir 				xFac = css::uno::Reference< css::lang::XSingleServiceFactory >(xOrderList, css::uno::UNO_QUERY);
591cdf0e10cSrcweir 				xInst = xFac->createInstance();
592cdf0e10cSrcweir 				::rtl::OUString sPush = ::rtl::OUString::valueOf(nLength++);
593cdf0e10cSrcweir 				xOrderList->insertByName(sPush, css::uno::makeAny(xInst));
594cdf0e10cSrcweir 			}
595cdf0e10cSrcweir 			for (sal_Int32 j=nLength-1; j>0; --j)
596cdf0e10cSrcweir 			{
597cdf0e10cSrcweir 				xOrderList->getByName( ::rtl::OUString::valueOf(j) )   >>= xPrevSet;
598cdf0e10cSrcweir 				xOrderList->getByName( ::rtl::OUString::valueOf(j-1) ) >>= xNextSet;
599cdf0e10cSrcweir 				::rtl::OUString sTemp;
600cdf0e10cSrcweir 				xNextSet->getPropertyValue(s_sHistoryItemRef) >>= sTemp;
601cdf0e10cSrcweir 				xPrevSet->setPropertyValue(s_sHistoryItemRef, css::uno::makeAny(sTemp));
602cdf0e10cSrcweir 			}
603cdf0e10cSrcweir 			xOrderList->getByName( ::rtl::OUString::valueOf((sal_Int32)0) ) >>= xSet;
604cdf0e10cSrcweir 			xSet->setPropertyValue(s_sHistoryItemRef, css::uno::makeAny(sURL));
605cdf0e10cSrcweir 
606cdf0e10cSrcweir 			// Append the item to ItemList.
607cdf0e10cSrcweir 			xFac = css::uno::Reference< css::lang::XSingleServiceFactory >(xItemList, css::uno::UNO_QUERY);
608cdf0e10cSrcweir 			xInst = xFac->createInstance();
609cdf0e10cSrcweir 			xItemList->insertByName(sURL, css::uno::makeAny(xInst));
610cdf0e10cSrcweir 			xSet = css::uno::Reference< css::beans::XPropertySet >(xInst, css::uno::UNO_QUERY);
611cdf0e10cSrcweir 			xSet->setPropertyValue(s_sFilter, css::uno::makeAny(sFilter));
612cdf0e10cSrcweir 			xSet->setPropertyValue(s_sTitle, css::uno::makeAny(sTitle));
613cdf0e10cSrcweir 			xSet->setPropertyValue(s_sPassword, css::uno::makeAny(sPassword));
614cdf0e10cSrcweir 
615cdf0e10cSrcweir 			::comphelper::ConfigurationHelper::flush(m_xCfg);
616cdf0e10cSrcweir 		}
617cdf0e10cSrcweir 	}
618cdf0e10cSrcweir 	catch(const css::uno::Exception& ex)
619cdf0e10cSrcweir 	{
620cdf0e10cSrcweir 		LogHelper::logIt(ex);
621cdf0e10cSrcweir 	}
622cdf0e10cSrcweir }
623cdf0e10cSrcweir 
624cdf0e10cSrcweir //*****************************************************************************************************************
625cdf0e10cSrcweir // initialize static member
626cdf0e10cSrcweir // DON'T DO IT IN YOUR HEADER!
627cdf0e10cSrcweir // see definition for further informations
628cdf0e10cSrcweir //*****************************************************************************************************************
629cdf0e10cSrcweir SvtHistoryOptions_Impl*  SvtHistoryOptions::m_pDataContainer = NULL ;
630cdf0e10cSrcweir sal_Int32     SvtHistoryOptions::m_nRefCount  = 0  ;
631cdf0e10cSrcweir 
632cdf0e10cSrcweir //*****************************************************************************************************************
633cdf0e10cSrcweir // constructor
634cdf0e10cSrcweir //*****************************************************************************************************************
SvtHistoryOptions()635cdf0e10cSrcweir SvtHistoryOptions::SvtHistoryOptions()
636cdf0e10cSrcweir {
637cdf0e10cSrcweir 	// Global access, must be guarded (multithreading!).
638cdf0e10cSrcweir 	MutexGuard aGuard( GetOwnStaticMutex() );
639cdf0e10cSrcweir 	// Increase ouer refcount ...
640cdf0e10cSrcweir 	++m_nRefCount;
641cdf0e10cSrcweir 	// ... and initialize ouer data container only if it not already exist!
642cdf0e10cSrcweir 	if( m_pDataContainer == NULL )
643cdf0e10cSrcweir 	{
644cdf0e10cSrcweir 		RTL_LOGFILE_CONTEXT(aLog, "unotools ( ??? ) ::SvtHistoryOptions_Impl::ctor()");
645cdf0e10cSrcweir 		m_pDataContainer = new SvtHistoryOptions_Impl;
646cdf0e10cSrcweir 
647cdf0e10cSrcweir 		ItemHolder1::holdConfigItem(E_HISTORYOPTIONS);
648cdf0e10cSrcweir 	}
649cdf0e10cSrcweir }
650cdf0e10cSrcweir 
651cdf0e10cSrcweir //*****************************************************************************************************************
652cdf0e10cSrcweir // destructor
653cdf0e10cSrcweir //*****************************************************************************************************************
~SvtHistoryOptions()654cdf0e10cSrcweir SvtHistoryOptions::~SvtHistoryOptions()
655cdf0e10cSrcweir {
656cdf0e10cSrcweir 	// Global access, must be guarded (multithreading!)
657cdf0e10cSrcweir 	MutexGuard aGuard( GetOwnStaticMutex() );
658cdf0e10cSrcweir 	// Decrease ouer refcount.
659cdf0e10cSrcweir 	--m_nRefCount;
660cdf0e10cSrcweir 	// If last instance was deleted ...
661cdf0e10cSrcweir 	// we must destroy ouer static data container!
662cdf0e10cSrcweir 	if( m_nRefCount <= 0 )
663cdf0e10cSrcweir 	{
664cdf0e10cSrcweir 		delete m_pDataContainer;
665cdf0e10cSrcweir 		m_pDataContainer = NULL;
666cdf0e10cSrcweir 	}
667cdf0e10cSrcweir }
668cdf0e10cSrcweir 
669cdf0e10cSrcweir //*****************************************************************************************************************
670cdf0e10cSrcweir // public method
671cdf0e10cSrcweir //*****************************************************************************************************************
GetSize(EHistoryType eHistory) const672cdf0e10cSrcweir sal_uInt32 SvtHistoryOptions::GetSize( EHistoryType eHistory ) const
673cdf0e10cSrcweir {
674cdf0e10cSrcweir 	MutexGuard aGuard( GetOwnStaticMutex() );
675cdf0e10cSrcweir 	return m_pDataContainer->GetSize( eHistory );
676cdf0e10cSrcweir }
677cdf0e10cSrcweir 
678cdf0e10cSrcweir //*****************************************************************************************************************
679cdf0e10cSrcweir // public method
680cdf0e10cSrcweir //*****************************************************************************************************************
SetSize(EHistoryType eHistory,sal_uInt32 nSize)681cdf0e10cSrcweir void SvtHistoryOptions::SetSize( EHistoryType eHistory, sal_uInt32 nSize )
682cdf0e10cSrcweir {
683cdf0e10cSrcweir 	MutexGuard aGuard( GetOwnStaticMutex() );
684cdf0e10cSrcweir 	m_pDataContainer->SetSize( eHistory, nSize );
685cdf0e10cSrcweir }
686cdf0e10cSrcweir 
687cdf0e10cSrcweir //*****************************************************************************************************************
688cdf0e10cSrcweir // public method
689cdf0e10cSrcweir //*****************************************************************************************************************
Clear(EHistoryType eHistory)690cdf0e10cSrcweir void SvtHistoryOptions::Clear( EHistoryType eHistory )
691cdf0e10cSrcweir {
692cdf0e10cSrcweir 	MutexGuard aGuard( GetOwnStaticMutex() );
693cdf0e10cSrcweir 	m_pDataContainer->Clear( eHistory );
694cdf0e10cSrcweir }
695cdf0e10cSrcweir 
696cdf0e10cSrcweir //*****************************************************************************************************************
697cdf0e10cSrcweir // public method
698cdf0e10cSrcweir //*****************************************************************************************************************
GetList(EHistoryType eHistory) const699cdf0e10cSrcweir Sequence< Sequence< PropertyValue > > SvtHistoryOptions::GetList( EHistoryType eHistory ) const
700cdf0e10cSrcweir {
701cdf0e10cSrcweir 	MutexGuard aGuard( GetOwnStaticMutex() );
702cdf0e10cSrcweir 	return m_pDataContainer->GetList( eHistory );
703cdf0e10cSrcweir }
704cdf0e10cSrcweir 
705cdf0e10cSrcweir //*****************************************************************************************************************
706cdf0e10cSrcweir // public method
707cdf0e10cSrcweir //*****************************************************************************************************************
AppendItem(EHistoryType eHistory,const OUString & sURL,const OUString & sFilter,const OUString & sTitle,const OUString & sPassword)708cdf0e10cSrcweir void SvtHistoryOptions::AppendItem(   EHistoryType eHistory ,
709cdf0e10cSrcweir 								   const OUString&  sURL  ,
710cdf0e10cSrcweir 								   const OUString&  sFilter  ,
711cdf0e10cSrcweir 								   const OUString&  sTitle  ,
712cdf0e10cSrcweir 								   const OUString&  sPassword )
713cdf0e10cSrcweir {
714cdf0e10cSrcweir 	MutexGuard aGuard( GetOwnStaticMutex() );
715cdf0e10cSrcweir 	m_pDataContainer->AppendItem( eHistory, sURL, sFilter, sTitle, sPassword );
716cdf0e10cSrcweir }
717cdf0e10cSrcweir 
718cdf0e10cSrcweir //*****************************************************************************************************************
719cdf0e10cSrcweir // private method
720cdf0e10cSrcweir //*****************************************************************************************************************
GetOwnStaticMutex()721cdf0e10cSrcweir Mutex& SvtHistoryOptions::GetOwnStaticMutex()
722cdf0e10cSrcweir {
723cdf0e10cSrcweir 	// Initialize static mutex only for one time!
724cdf0e10cSrcweir 	static Mutex* pMutex = NULL;
725cdf0e10cSrcweir 	// If these method first called (Mutex not already exist!) ...
726cdf0e10cSrcweir 	if( pMutex == NULL )
727cdf0e10cSrcweir 	{
728cdf0e10cSrcweir 		// ... we must create a new one. Protect follow code with the global mutex -
729cdf0e10cSrcweir 		// It must be - we create a static variable!
730cdf0e10cSrcweir 		MutexGuard aGuard( Mutex::getGlobalMutex() );
731cdf0e10cSrcweir 		// We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
732cdf0e10cSrcweir 		if( pMutex == NULL )
733cdf0e10cSrcweir 		{
734cdf0e10cSrcweir 			// Create the new mutex and set it for return on static variable.
735cdf0e10cSrcweir 			static Mutex aMutex;
736cdf0e10cSrcweir 			pMutex = &aMutex;
737cdf0e10cSrcweir 		}
738cdf0e10cSrcweir 	}
739cdf0e10cSrcweir 	// Return new created or already existing mutex object.
740cdf0e10cSrcweir 	return *pMutex;
741cdf0e10cSrcweir }
742