merge the formfield patch from ooo-build
[ooovba.git] / svtools / source / config / historyoptions.cxx
blobbd27291ca508093b90c60480a090abe4d7134f31
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: historyoptions.cxx,v $
10 * $Revision: 1.21.234.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
33 #ifndef GCC
34 #endif
36 //_________________________________________________________________________________________________________________
37 // includes
38 //_________________________________________________________________________________________________________________
40 #include <svtools/historyoptions.hxx>
41 #include "configitems/historyoptions_const.hxx"
42 #include <unotools/configmgr.hxx>
43 #include <unotools/configitem.hxx>
44 #include <tools/debug.hxx>
45 #include <com/sun/star/uno/Any.hxx>
46 #include <com/sun/star/uno/Sequence.hxx>
48 #ifndef __SGI_STL_DEQUE
49 #include <deque>
50 #endif
52 #ifndef __SGI_STL_ALGORITHM
53 #include <algorithm>
54 #endif
56 #include <rtl/logfile.hxx>
57 #include "itemholder1.hxx"
59 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
60 #include <com/sun/star/beans/XPropertySet.hpp>
61 #endif
63 #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
64 #include <com/sun/star/container/XNameAccess.hpp>
65 #endif
67 #ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
68 #include <com/sun/star/container/XNameContainer.hpp>
69 #endif
71 #ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
72 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
73 #endif
75 #ifndef _COMPHELPER_CONFIGURATIONHELPER_HXX_
76 #include <comphelper/configurationhelper.hxx>
77 #endif
79 #ifndef _UNOTOOLS_PROCESSFACTORY_HXX_
80 #include <unotools/processfactory.hxx>
81 #endif
83 #ifndef _SVT_LOGHELPER_HXX
84 #include "loghelper.hxx"
85 #endif
87 //_________________________________________________________________________________________________________________
88 // namespaces
89 //_________________________________________________________________________________________________________________
91 using namespace ::std ;
92 using namespace ::utl ;
93 using namespace ::rtl ;
94 using namespace ::osl ;
95 using namespace ::com::sun::star::uno ;
96 using namespace ::com::sun::star::beans ;
98 namespace css = ::com::sun::star;
100 //_________________________________________________________________________________________________________________
101 // const
102 //_________________________________________________________________________________________________________________
104 namespace {
105 static const ::sal_Int32 s_nOffsetURL = 0;
106 static const ::sal_Int32 s_nOffsetFilter = 1;
107 static const ::sal_Int32 s_nOffsetTitle = 2;
108 static const ::sal_Int32 s_nOffsetPassword = 3;
111 //_________________________________________________________________________________________________________________
112 // private declarations!
113 //_________________________________________________________________________________________________________________
115 struct IMPL_THistoryItem
117 IMPL_THistoryItem()
121 IMPL_THistoryItem( const OUString& sNewURL ,
122 const OUString& sNewFilter ,
123 const OUString& sNewTitle ,
124 const OUString& sNewPassword )
126 sURL = sNewURL ;
127 sFilter = sNewFilter ;
128 sTitle = sNewTitle ;
129 sPassword = sNewPassword ;
132 sal_Bool operator==( const OUString& sSearchedURL )
134 return( sURL == sSearchedURL );
137 OUString sURL ;
138 OUString sFilter ;
139 OUString sTitle ;
140 OUString sPassword ;
143 //*****************************************************************************************************************
144 // class SvtHistoryOptions_Impl
145 // redesigned
146 //*****************************************************************************************************************
147 class SvtHistoryOptions_Impl
149 public:
150 SvtHistoryOptions_Impl();
151 ~SvtHistoryOptions_Impl();
153 sal_uInt32 GetSize( EHistoryType eHistory );
154 void SetSize( EHistoryType eHistory, sal_uInt32 nSize );
155 void Clear( EHistoryType eHistory );
156 Sequence< Sequence< PropertyValue > > GetList( EHistoryType eHistory );
157 void AppendItem( EHistoryType eHistory ,
158 const OUString& sURL ,
159 const OUString& sFilter ,
160 const OUString& sTitle ,
161 const OUString& sPassword );
163 private:
164 void impl_truncateList (EHistoryType eHistory, sal_uInt32 nSize);
166 private:
167 css::uno::Reference< css::container::XNameAccess > m_xCfg;
168 css::uno::Reference< css::container::XNameAccess > m_xCommonXCU;
171 //*****************************************************************************************************************
172 // constructor
173 //*****************************************************************************************************************
174 SvtHistoryOptions_Impl::SvtHistoryOptions_Impl()
176 try
178 m_xCfg = Reference< css::container::XNameAccess > (
179 ::comphelper::ConfigurationHelper::openConfig(
180 utl::getProcessServiceFactory(),
181 s_sHistories,
182 ::comphelper::ConfigurationHelper::E_STANDARD),
183 css::uno::UNO_QUERY );
185 m_xCommonXCU = Reference< css::container::XNameAccess > (
186 ::comphelper::ConfigurationHelper::openConfig(
187 utl::getProcessServiceFactory(),
188 s_sCommonHistory,
189 ::comphelper::ConfigurationHelper::E_STANDARD),
190 css::uno::UNO_QUERY );
192 catch(const css::uno::Exception& ex)
194 m_xCfg.clear();
195 m_xCommonXCU.clear();
197 LogHelper::logIt(ex);
201 //*****************************************************************************************************************
202 // destructor
203 //*****************************************************************************************************************
204 SvtHistoryOptions_Impl::~SvtHistoryOptions_Impl()
208 //*****************************************************************************************************************
209 // public method
210 // Attention: We return the max. size of our internal lists - That is the capacity not the size!
211 //*****************************************************************************************************************
212 sal_uInt32 SvtHistoryOptions_Impl::GetSize( EHistoryType eHistory )
214 sal_uInt32 nSize = 0 ;
215 css::uno::Reference< css::beans::XPropertySet > xListAccess(m_xCommonXCU, css::uno::UNO_QUERY);
217 try
219 switch( eHistory )
221 case ePICKLIST:
222 xListAccess->getPropertyValue(s_sPickListSize) >>= nSize;
223 break;
225 case eHISTORY:
226 xListAccess->getPropertyValue(s_sURLHistorySize) >>= nSize;
227 break;
229 case eHELPBOOKMARKS:
230 xListAccess->getPropertyValue(s_sHelpBookmarksSize) >>= nSize;
231 break;
233 default:
234 break;
237 catch(const css::uno::Exception& ex)
239 LogHelper::logIt(ex);
242 return nSize;
245 //*****************************************************************************************************************
246 // public method
247 // Attention: We return the max. size of our internal lists - That is the capacity not the size!
248 //*****************************************************************************************************************
249 void SvtHistoryOptions_Impl::SetSize( EHistoryType eHistory, sal_uInt32 nSize )
251 css::uno::Reference< css::beans::XPropertySet > xListAccess(m_xCommonXCU, css::uno::UNO_QUERY);
252 if (! xListAccess.is ())
253 return;
255 try
257 switch( eHistory )
259 case ePICKLIST:
260 if(nSize!=GetSize(ePICKLIST))
262 xListAccess->setPropertyValue(s_sPickListSize, css::uno::makeAny(nSize));
263 ::comphelper::ConfigurationHelper::flush(m_xCommonXCU);
265 break;
267 case eHISTORY:
268 if(nSize!=GetSize(eHISTORY))
270 xListAccess->setPropertyValue(s_sURLHistorySize, css::uno::makeAny(nSize));
271 ::comphelper::ConfigurationHelper::flush(m_xCommonXCU);
273 break;
275 case eHELPBOOKMARKS:
276 if(nSize!=GetSize(eHELPBOOKMARKS))
278 xListAccess->setPropertyValue(s_sHelpBookmarksSize, css::uno::makeAny(nSize));
279 ::comphelper::ConfigurationHelper::flush(m_xCommonXCU);
281 break;
283 default:
284 break;
287 impl_truncateList (eHistory, nSize);
289 catch(const css::uno::Exception& ex)
291 LogHelper::logIt(ex);
295 //*****************************************************************************************************************
296 void SvtHistoryOptions_Impl::impl_truncateList ( EHistoryType eHistory, sal_uInt32 nSize )
298 css::uno::Reference< css::container::XNameAccess > xList;
299 css::uno::Reference< css::container::XNameContainer > xItemList;
300 css::uno::Reference< css::container::XNameContainer > xOrderList;
301 css::uno::Reference< css::beans::XPropertySet > xSet;
303 try
305 switch( eHistory )
307 case ePICKLIST:
308 m_xCfg->getByName(s_sPickList) >>= xList;
309 break;
311 case eHISTORY:
312 m_xCfg->getByName(s_sURLHistory) >>= xList;
313 break;
315 case eHELPBOOKMARKS:
316 m_xCfg->getByName(s_sHelpBookmarks) >>= xList;
317 break;
319 default:
320 break;
323 // If too much items in current list ...
324 // truncate the oldest items BEFORE you set the new one.
325 if ( ! xList.is())
326 return;
328 xList->getByName(s_sOrderList) >>= xOrderList;
329 xList->getByName(s_sItemList) >>= xItemList;
331 const sal_uInt32 nLength = xOrderList->getElementNames().getLength();
332 if (nSize < nLength)
334 for (sal_uInt32 i=nLength-1; i>=nSize; --i)
336 ::rtl::OUString sTmp;
337 const ::rtl::OUString sRemove = ::rtl::OUString::valueOf((sal_Int32)i);
338 xOrderList->getByName(sRemove) >>= xSet;
339 xSet->getPropertyValue(s_sHistoryItemRef) >>= sTmp;
340 xItemList->removeByName(sTmp);
341 xOrderList->removeByName(sRemove);
344 ::comphelper::ConfigurationHelper::flush(m_xCfg);
347 catch(const css::uno::Exception& ex)
349 LogHelper::logIt(ex);
353 //*****************************************************************************************************************
354 // public method
355 // Clear specified history list
356 //*****************************************************************************************************************
357 void SvtHistoryOptions_Impl::Clear( EHistoryType eHistory )
359 css::uno::Reference< css::container::XNameAccess > xListAccess;
360 css::uno::Reference< css::container::XNameContainer > xNode;
361 Sequence< ::rtl::OUString > lOrders;
363 try
365 switch( eHistory )
367 case ePICKLIST:
369 m_xCfg->getByName(s_sPickList) >>= xListAccess;
370 break;
373 case eHISTORY:
375 m_xCfg->getByName(s_sURLHistory) >>= xListAccess;
376 break;
379 case eHELPBOOKMARKS:
381 m_xCfg->getByName(s_sHelpBookmarks) >>= xListAccess;
382 break;
385 default:
386 break;
389 if (xListAccess.is())
391 // clear ItemList
392 xListAccess->getByName(s_sItemList) >>= xNode ;
393 lOrders = xNode->getElementNames();
394 const sal_Int32 nLength = lOrders.getLength();
395 for(sal_Int32 i=0; i<nLength; ++i)
396 xNode->removeByName(lOrders[i]);
398 // clear OrderList
399 xListAccess->getByName(s_sOrderList) >>= xNode ;
400 lOrders = xNode->getElementNames();
401 for(sal_Int32 j=0; j<nLength; ++j)
402 xNode->removeByName(lOrders[j]);
404 ::comphelper::ConfigurationHelper::flush(m_xCfg);
407 catch(const css::uno::Exception& ex)
409 LogHelper::logIt(ex);
413 //*****************************************************************************************************************
414 // public method
415 // get a sequence list from the items
416 //*****************************************************************************************************************
417 Sequence< Sequence< PropertyValue > > SvtHistoryOptions_Impl::GetList( EHistoryType eHistory )
419 impl_truncateList (eHistory, GetSize (eHistory));
421 Sequence< Sequence< PropertyValue > > seqReturn; // Set default return value.
422 Sequence< PropertyValue > seqProperties( 4 );
423 Sequence< ::rtl::OUString > lOrders;
425 css::uno::Reference< css::container::XNameAccess > xListAccess;
426 css::uno::Reference< css::container::XNameAccess > xItemList;
427 css::uno::Reference< css::container::XNameAccess > xOrderList;
428 css::uno::Reference< css::beans::XPropertySet > xSet;
430 seqProperties[s_nOffsetURL ].Name = HISTORY_PROPERTYNAME_URL;
431 seqProperties[s_nOffsetFilter ].Name = HISTORY_PROPERTYNAME_FILTER;
432 seqProperties[s_nOffsetTitle ].Name = HISTORY_PROPERTYNAME_TITLE;
433 seqProperties[s_nOffsetPassword ].Name = HISTORY_PROPERTYNAME_PASSWORD;
435 try
437 switch( eHistory )
439 case ePICKLIST:
441 m_xCfg->getByName(s_sPickList) >>= xListAccess;
442 break;
445 case eHISTORY:
447 m_xCfg->getByName(s_sURLHistory) >>= xListAccess;
448 break;
451 case eHELPBOOKMARKS:
453 m_xCfg->getByName(s_sHelpBookmarks) >>= xListAccess;
454 break;
457 default:
458 break;
461 if (xListAccess.is())
463 xListAccess->getByName(s_sItemList) >>= xItemList;
464 xListAccess->getByName(s_sOrderList) >>= xOrderList;
466 const sal_Int32 nLength = xOrderList->getElementNames().getLength();
467 Sequence< Sequence< PropertyValue > > aRet(nLength);
469 for(sal_Int32 nItem=0; nItem<nLength; ++nItem)
471 ::rtl::OUString sUrl;
472 xOrderList->getByName(::rtl::OUString::valueOf(nItem)) >>= xSet;
473 xSet->getPropertyValue(s_sHistoryItemRef) >>= sUrl;
475 xItemList->getByName(sUrl) >>= xSet;
476 seqProperties[s_nOffsetURL ].Value <<= sUrl;
477 xSet->getPropertyValue(s_sFilter) >>= seqProperties[s_nOffsetFilter ].Value;
478 xSet->getPropertyValue(s_sTitle) >>= seqProperties[s_nOffsetTitle ].Value;
479 xSet->getPropertyValue(s_sPassword) >>= seqProperties[s_nOffsetPassword ].Value;
480 aRet[nItem] = seqProperties;
482 seqReturn = aRet;
485 catch(const css::uno::Exception& ex)
487 LogHelper::logIt(ex);
490 return seqReturn;
493 //*****************************************************************************************************************
494 // public method
495 // implements a deque in XML
496 //*****************************************************************************************************************
497 void SvtHistoryOptions_Impl::AppendItem( EHistoryType eHistory ,
498 const OUString& sURL ,
499 const OUString& sFilter ,
500 const OUString& sTitle ,
501 const OUString& sPassword )
503 impl_truncateList (eHistory, GetSize (eHistory));
505 css::uno::Reference< css::container::XNameAccess > xListAccess;
506 sal_Int32 nMaxSize = 0;
508 switch(eHistory)
510 case ePICKLIST:
512 m_xCfg->getByName(s_sPickList) >>= xListAccess;
513 nMaxSize = GetSize(ePICKLIST);
515 break;
516 case eHISTORY:
518 m_xCfg->getByName(s_sURLHistory) >>= xListAccess;
519 nMaxSize = GetSize(eHISTORY);
521 break;
522 case eHELPBOOKMARKS:
524 m_xCfg->getByName(s_sHelpBookmarks) >>= xListAccess;
525 nMaxSize = GetSize(eHELPBOOKMARKS);
527 break;
528 default:
529 break;
532 if (nMaxSize==0)
533 return;
535 css::uno::Reference< css::container::XNameContainer > xItemList;
536 css::uno::Reference< css::container::XNameContainer > xOrderList;
537 css::uno::Reference< css::beans::XPropertySet > xSet;
539 try
541 xListAccess->getByName(s_sItemList) >>= xItemList;
542 xListAccess->getByName(s_sOrderList) >>= xOrderList;
543 sal_Int32 nLength = xOrderList->getElementNames().getLength();
545 // The item to be appended is already existing!
546 if (xItemList->hasByName(sURL))
548 for (sal_Int32 i=0; i<nLength; ++i)
550 ::rtl::OUString sTmp;
551 xOrderList->getByName(::rtl::OUString::valueOf(i)) >>= xSet;
552 xSet->getPropertyValue(s_sHistoryItemRef) >>= sTmp;
554 if(sURL == sTmp)
556 ::rtl::OUString sFind;
557 xOrderList->getByName( ::rtl::OUString::valueOf(i) ) >>= xSet;
558 xSet->getPropertyValue(s_sHistoryItemRef) >>= sFind;
559 for (sal_Int32 j=i-1; j>=0; --j)
561 css::uno::Reference< css::beans::XPropertySet > xPrevSet;
562 css::uno::Reference< css::beans::XPropertySet > xNextSet;
563 xOrderList->getByName( ::rtl::OUString::valueOf(j+1) ) >>= xPrevSet;
564 xOrderList->getByName( ::rtl::OUString::valueOf(j) ) >>= xNextSet;
566 ::rtl::OUString sTemp;
567 xNextSet->getPropertyValue(s_sHistoryItemRef) >>= sTemp;
568 xPrevSet->setPropertyValue(s_sHistoryItemRef, css::uno::makeAny(sTemp));
570 xOrderList->getByName( ::rtl::OUString::valueOf((sal_Int32)0) ) >>= xSet;
571 xSet->setPropertyValue(s_sHistoryItemRef, css::uno::makeAny(sFind));
573 ::comphelper::ConfigurationHelper::flush(m_xCfg);
574 break;
579 // The item to be appended is not existing!
580 else
582 css::uno::Reference< css::lang::XSingleServiceFactory > xFac;
583 css::uno::Reference< css::uno::XInterface > xInst;
584 css::uno::Reference< css::beans::XPropertySet > xPrevSet;
585 css::uno::Reference< css::beans::XPropertySet > xNextSet;
587 // Append new item to OrderList.
588 if ( nLength == nMaxSize )
590 ::rtl::OUString sRemove;
591 xOrderList->getByName(::rtl::OUString::valueOf(nLength-1)) >>= xSet;
592 xSet->getPropertyValue(s_sHistoryItemRef) >>= sRemove;
593 xItemList->removeByName(sRemove);
595 if ( nLength != nMaxSize )
597 xFac = css::uno::Reference< css::lang::XSingleServiceFactory >(xOrderList, css::uno::UNO_QUERY);
598 xInst = xFac->createInstance();
599 ::rtl::OUString sPush = ::rtl::OUString::valueOf(nLength++);
600 xOrderList->insertByName(sPush, css::uno::makeAny(xInst));
602 for (sal_Int32 j=nLength-1; j>0; --j)
604 xOrderList->getByName( ::rtl::OUString::valueOf(j) ) >>= xPrevSet;
605 xOrderList->getByName( ::rtl::OUString::valueOf(j-1) ) >>= xNextSet;
606 ::rtl::OUString sTemp;
607 xNextSet->getPropertyValue(s_sHistoryItemRef) >>= sTemp;
608 xPrevSet->setPropertyValue(s_sHistoryItemRef, css::uno::makeAny(sTemp));
610 xOrderList->getByName( ::rtl::OUString::valueOf((sal_Int32)0) ) >>= xSet;
611 xSet->setPropertyValue(s_sHistoryItemRef, css::uno::makeAny(sURL));
613 // Append the item to ItemList.
614 xFac = css::uno::Reference< css::lang::XSingleServiceFactory >(xItemList, css::uno::UNO_QUERY);
615 xInst = xFac->createInstance();
616 xItemList->insertByName(sURL, css::uno::makeAny(xInst));
617 xSet = css::uno::Reference< css::beans::XPropertySet >(xInst, css::uno::UNO_QUERY);
618 xSet->setPropertyValue(s_sFilter, css::uno::makeAny(sFilter));
619 xSet->setPropertyValue(s_sTitle, css::uno::makeAny(sTitle));
620 xSet->setPropertyValue(s_sPassword, css::uno::makeAny(sPassword));
622 ::comphelper::ConfigurationHelper::flush(m_xCfg);
625 catch(const css::uno::Exception& ex)
627 LogHelper::logIt(ex);
631 //*****************************************************************************************************************
632 // initialize static member
633 // DON'T DO IT IN YOUR HEADER!
634 // see definition for further informations
635 //*****************************************************************************************************************
636 SvtHistoryOptions_Impl* SvtHistoryOptions::m_pDataContainer = NULL ;
637 sal_Int32 SvtHistoryOptions::m_nRefCount = 0 ;
639 //*****************************************************************************************************************
640 // constructor
641 //*****************************************************************************************************************
642 SvtHistoryOptions::SvtHistoryOptions()
644 // Global access, must be guarded (multithreading!).
645 MutexGuard aGuard( GetOwnStaticMutex() );
646 // Increase ouer refcount ...
647 ++m_nRefCount;
648 // ... and initialize ouer data container only if it not already exist!
649 if( m_pDataContainer == NULL )
651 RTL_LOGFILE_CONTEXT(aLog, "svtools ( ??? ) ::SvtHistoryOptions_Impl::ctor()");
652 m_pDataContainer = new SvtHistoryOptions_Impl;
654 ItemHolder1::holdConfigItem(E_HISTORYOPTIONS);
658 //*****************************************************************************************************************
659 // destructor
660 //*****************************************************************************************************************
661 SvtHistoryOptions::~SvtHistoryOptions()
663 // Global access, must be guarded (multithreading!)
664 MutexGuard aGuard( GetOwnStaticMutex() );
665 // Decrease ouer refcount.
666 --m_nRefCount;
667 // If last instance was deleted ...
668 // we must destroy ouer static data container!
669 if( m_nRefCount <= 0 )
671 delete m_pDataContainer;
672 m_pDataContainer = NULL;
676 //*****************************************************************************************************************
677 // public method
678 //*****************************************************************************************************************
679 sal_uInt32 SvtHistoryOptions::GetSize( EHistoryType eHistory ) const
681 MutexGuard aGuard( GetOwnStaticMutex() );
682 return m_pDataContainer->GetSize( eHistory );
685 //*****************************************************************************************************************
686 // public method
687 //*****************************************************************************************************************
688 void SvtHistoryOptions::SetSize( EHistoryType eHistory, sal_uInt32 nSize )
690 MutexGuard aGuard( GetOwnStaticMutex() );
691 m_pDataContainer->SetSize( eHistory, nSize );
694 //*****************************************************************************************************************
695 // public method
696 //*****************************************************************************************************************
697 void SvtHistoryOptions::Clear( EHistoryType eHistory )
699 MutexGuard aGuard( GetOwnStaticMutex() );
700 m_pDataContainer->Clear( eHistory );
703 //*****************************************************************************************************************
704 // public method
705 //*****************************************************************************************************************
706 Sequence< Sequence< PropertyValue > > SvtHistoryOptions::GetList( EHistoryType eHistory ) const
708 MutexGuard aGuard( GetOwnStaticMutex() );
709 return m_pDataContainer->GetList( eHistory );
712 //*****************************************************************************************************************
713 // public method
714 //*****************************************************************************************************************
715 void SvtHistoryOptions::AppendItem( EHistoryType eHistory ,
716 const OUString& sURL ,
717 const OUString& sFilter ,
718 const OUString& sTitle ,
719 const OUString& sPassword )
721 MutexGuard aGuard( GetOwnStaticMutex() );
722 m_pDataContainer->AppendItem( eHistory, sURL, sFilter, sTitle, sPassword );
725 //*****************************************************************************************************************
726 // private method
727 //*****************************************************************************************************************
728 Mutex& SvtHistoryOptions::GetOwnStaticMutex()
730 // Initialize static mutex only for one time!
731 static Mutex* pMutex = NULL;
732 // If these method first called (Mutex not already exist!) ...
733 if( pMutex == NULL )
735 // ... we must create a new one. Protect follow code with the global mutex -
736 // It must be - we create a static variable!
737 MutexGuard aGuard( Mutex::getGlobalMutex() );
738 // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
739 if( pMutex == NULL )
741 // Create the new mutex and set it for return on static variable.
742 static Mutex aMutex;
743 pMutex = &aMutex;
746 // Return new created or already existing mutex object.
747 return *pMutex;