Update ooo320-m1
[ooovba.git] / svtools / source / config / internaloptions.cxx
blob413559e8e5700f77e265cb2fe6f591de9352cb83
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: internaloptions.cxx,v $
10 * $Revision: 1.21 $
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 <deque>
42 #include <svtools/internaloptions.hxx>
43 #include <unotools/configmgr.hxx>
44 #include <unotools/configitem.hxx>
45 #include <tools/debug.hxx>
46 #include <com/sun/star/uno/Any.hxx>
47 #include <com/sun/star/uno/Sequence.hxx>
48 #include <com/sun/star/beans/PropertyValue.hpp>
50 #include <rtl/logfile.hxx>
51 #include "itemholder1.hxx"
53 //_________________________________________________________________________________________________________________
54 // namespaces
55 //_________________________________________________________________________________________________________________
57 using namespace ::utl ;
58 using namespace ::rtl ;
59 using namespace ::osl ;
60 using namespace ::std ;
61 using namespace ::com::sun::star::uno ;
62 using namespace ::com::sun::star::beans ;
64 //_________________________________________________________________________________________________________________
65 // const
66 //_________________________________________________________________________________________________________________
68 #define ROOTNODE_INTERNAL OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/Internal" ))
69 #define DEFAULT_SLOTCFG sal_False
70 #define DEFAULT_SENDCRASHMAIL sal_False
71 #define DEFAULT_USEMAILUI sal_True
72 #define DEFAULT_CURRENTTEMPURL OUString(RTL_CONSTASCII_USTRINGPARAM(""))
74 #define FIXPROPERTYNAME_SLOTCFG OUString(RTL_CONSTASCII_USTRINGPARAM("Slot" ))
75 #define FIXPROPERTYNAME_SENDCRASHMAIL OUString(RTL_CONSTASCII_USTRINGPARAM("SendCrashMail" ))
76 #define FIXPROPERTYNAME_USEMAILUI OUString(RTL_CONSTASCII_USTRINGPARAM("UseMailUI" ))
77 #define FIXPROPERTYNAME_CURRENTTEMPURL OUString(RTL_CONSTASCII_USTRINGPARAM("CurrentTempURL" ))
78 //#define FIXPROPERTYNAME_REMOVEMENUENTRYCLOSE OUString(RTL_CONSTASCII_USTRINGPARAM("RemoveMenuEntryClose"))
79 //#define FIXPROPERTYNAME_REMOVEMENUENTRYBACKTOWEBTOP OUString(RTL_CONSTASCII_USTRINGPARAM("RemoveMenuEntryBackToWebtop"))
80 //#define FIXPROPERTYNAME_REMOVEMENUENTRYNEWWEBTOP OUString(RTL_CONSTASCII_USTRINGPARAM("RemoveMenuEntryNewWebtop"))
81 //#define FIXPROPERTYNAME_REMOVEMENUENTRYLOGOUT OUString(RTL_CONSTASCII_USTRINGPARAM("RemoveMenuEntryLogout"))
83 #define FIXPROPERTYHANDLE_SLOTCFG 0
84 #define FIXPROPERTYHANDLE_SENDCRASHMAIL 1
85 #define FIXPROPERTYHANDLE_USEMAILUI 2
86 #define FIXPROPERTYHANDLE_CURRENTTEMPURL 3
87 //#define FIXPROPERTYHANDLE_REMOVEMENUENTRYCLOSE 3
88 //#define FIXPROPERTYHANDLE_REMOVEMENUENTRYBACKTOWEBTOP 4
89 //#define FIXPROPERTYHANDLE_REMOVEMENUENTRYNEWWEBTOP 5
90 //#define FIXPROPERTYHANDLE_REMOVEMENUENTRYLOGOUT 6
92 #define FIXPROPERTYCOUNT 4
94 #define PROPERTYNAME_RECOVERYLIST OUString(RTL_CONSTASCII_USTRINGPARAM("RecoveryList" ))
95 #define PROPERTYNAME_URL OUString(RTL_CONSTASCII_USTRINGPARAM("OrgURL" ))
96 #define PROPERTYNAME_FILTER OUString(RTL_CONSTASCII_USTRINGPARAM("FilterName" ))
97 #define PROPERTYNAME_TEMPNAME OUString(RTL_CONSTASCII_USTRINGPARAM("TempURL" ))
99 #define OFFSET_URL 0
100 #define OFFSET_FILTER 1
101 #define OFFSET_TEMPNAME 2
103 #define PATHDELIMITER OUString(RTL_CONSTASCII_USTRINGPARAM("/" ))
104 #define FIXR OUString(RTL_CONSTASCII_USTRINGPARAM("r" ))
106 //_________________________________________________________________________________________________________________
107 // private declarations!
108 //_________________________________________________________________________________________________________________
110 struct tIMPL_RecoveryEntry
112 OUString sURL ;
113 OUString sFilter ;
114 OUString sTempName ;
116 tIMPL_RecoveryEntry()
118 sURL = OUString();
119 sFilter = OUString();
120 sTempName = OUString();
123 tIMPL_RecoveryEntry( const OUString& sNewURL ,
124 const OUString& sNewFilter ,
125 const OUString& sNewTempName )
127 sURL = sNewURL ;
128 sFilter = sNewFilter ;
129 sTempName = sNewTempName ;
133 typedef deque< tIMPL_RecoveryEntry > tIMPL_RecoveryStack;
135 class SvtInternalOptions_Impl : public ConfigItem
137 //-------------------------------------------------------------------------------------------------------------
138 // private member
139 //-------------------------------------------------------------------------------------------------------------
141 private:
143 sal_Bool m_bRemoveMenuEntryClose;
144 sal_Bool m_bRemoveMenuEntryBackToWebtop;
145 sal_Bool m_bRemoveMenuEntryNewWebtop;
146 sal_Bool m_bRemoveMenuEntryLogout;
147 sal_Bool m_bSlotCFG ; /// cache "Slot" of Internal section
148 sal_Bool m_bSendCrashMail ; /// cache "SendCrashMail" of Internal section
149 sal_Bool m_bUseMailUI;
150 OUString m_aCurrentTempURL ;
151 // tIMPL_RecoveryStack m_aRecoveryList ; /// cache "RecoveryList" of Internal section
152 //-------------------------------------------------------------------------------------------------------------
153 // public methods
154 //-------------------------------------------------------------------------------------------------------------
156 public:
158 //---------------------------------------------------------------------------------------------------------
159 // constructor / destructor
160 //---------------------------------------------------------------------------------------------------------
162 SvtInternalOptions_Impl();
163 ~SvtInternalOptions_Impl();
165 //---------------------------------------------------------------------------------------------------------
166 // overloaded methods of baseclass
167 //---------------------------------------------------------------------------------------------------------
169 /*-****************************************************************************************************//**
170 @short called for notify of configmanager
171 @descr These method is called from the ConfigManager before application ends or from the
172 PropertyChangeListener if the sub tree broadcasts changes. You must update your
173 internal values.
175 @seealso baseclass ConfigItem
177 @param "seqPropertyNames" is the list of properties which should be updated.
178 @return -
180 @onerror -
181 *//*-*****************************************************************************************************/
183 virtual void Notify( const Sequence< OUString >& )
185 DBG_ASSERT( sal_False, "SvtInternalOptions::Notify()\nNot used yet ... but called!?\n" );
188 /*-****************************************************************************************************//**
189 @short write changes to configuration
190 @descr These method writes the changed values into the sub tree
191 and should always called in our destructor to guarantee consistency of config data.
193 @seealso baseclass ConfigItem
195 @param -
196 @return -
198 @onerror -
199 *//*-*****************************************************************************************************/
201 virtual void Commit();
203 //---------------------------------------------------------------------------------------------------------
204 // public interface
205 //---------------------------------------------------------------------------------------------------------
207 /*-****************************************************************************************************//**
208 @short access method to get internal values
209 @descr These method give us a chance to regulate acces to ouer internal values.
210 It's not used in the moment - but it's possible for the feature!
212 @seealso -
214 @param -
215 @return -
217 @onerror -
218 *//*-*****************************************************************************************************/
220 sal_Bool IsRemoveMenuEntryClose() const { return m_bRemoveMenuEntryClose; }
221 sal_Bool IsRemoveMenuEntryBackToWebtop() const { return m_bRemoveMenuEntryBackToWebtop; }
222 sal_Bool IsRemoveMenuEntryNewWebtop() const { return m_bRemoveMenuEntryNewWebtop; }
223 sal_Bool IsRemoveMenuEntryLogout() const { return m_bRemoveMenuEntryLogout; }
224 sal_Bool SlotCFGEnabled () const { return m_bSlotCFG; }
225 sal_Bool CrashMailEnabled () const { return m_bSendCrashMail; }
226 sal_Bool MailUIEnabled () const { return m_bUseMailUI; }
228 OUString GetCurrentTempURL() const { return m_aCurrentTempURL; }
229 void SetCurrentTempURL( const OUString& aNewCurrentTempURL );
231 void PushRecoveryItem ( const OUString& sURL ,
232 const OUString& sFilter ,
233 const OUString& sTempName );
234 void PopRecoveryItem ( OUString& sURL ,
235 OUString& sFilter ,
236 OUString& sTempName );
237 sal_Bool IsRecoveryListEmpty ( ) const;
239 //-------------------------------------------------------------------------------------------------------------
240 // private methods
241 //-------------------------------------------------------------------------------------------------------------
243 private:
245 /*-****************************************************************************************************//**
246 @short return list of fix key names of ouer configuration management which represent oue module tree
247 @descr These methods return a static const list of key names. We need it to get needed values from our
248 configuration management. We return well known key names only - because the "UserData" node
249 is handled in a special way!
251 @seealso -
253 @param -
254 @return A list of needed configuration keys is returned.
256 @onerror -
257 *//*-*****************************************************************************************************/
259 Sequence< OUString > impl_GetPropertyNames();
262 //_________________________________________________________________________________________________________________
263 // definitions
264 //_________________________________________________________________________________________________________________
266 //*****************************************************************************************************************
267 // constructor
268 //*****************************************************************************************************************
269 SvtInternalOptions_Impl::SvtInternalOptions_Impl()
270 // Init baseclasses first
271 : ConfigItem ( ROOTNODE_INTERNAL, CONFIG_MODE_IMMEDIATE_UPDATE )
272 // Init member then.
273 , m_bRemoveMenuEntryClose ( sal_False )
274 , m_bRemoveMenuEntryBackToWebtop ( sal_False )
275 , m_bRemoveMenuEntryNewWebtop ( sal_False )
276 , m_bRemoveMenuEntryLogout ( sal_False )
277 , m_bSlotCFG ( DEFAULT_SLOTCFG )
278 , m_bSendCrashMail ( DEFAULT_SENDCRASHMAIL )
279 , m_bUseMailUI ( DEFAULT_USEMAILUI )
280 , m_aCurrentTempURL ( DEFAULT_CURRENTTEMPURL )
282 // Use our list of configuration keys to get his values.
283 // structure of internal section: (first 2 entries are fixed - all other are member of a set!)
284 // "Slot"
285 // "SendCrashMail"
286 // "RecoveryList/r1/URL"
287 // "RecoveryList/r1/Filter"
288 // "RecoveryList/r1/TempName"
289 // "RecoveryList/r2/URL"
290 // "RecoveryList/r2/Filter"
291 // "RecoveryList/r2/TempName"
292 // "RecoveryList/.."
293 Sequence< OUString > seqNames = impl_GetPropertyNames() ;
294 Sequence< Any > seqValues = GetProperties( seqNames ) ;
296 // Safe impossible cases.
297 // We need values from ALL configuration keys.
298 // Follow assignment use order of values in relation to our list of key names!
299 DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtInternalOptions_Impl::SvtInternalOptions_Impl()\nI miss some values of configuration keys!\n" );
301 // Read fixed values first!
302 DBG_ASSERT(!(seqValues[FIXPROPERTYHANDLE_SLOTCFG].getValueTypeClass()!=TypeClass_BOOLEAN) , "SvtInternalOptions_Impl::SvtInternalOptions_Impl()\nWho has changed the value type of \"Office.Common\\Internal\\Slot\"?" );
303 DBG_ASSERT(!(seqValues[FIXPROPERTYHANDLE_SENDCRASHMAIL].getValueTypeClass()!=TypeClass_BOOLEAN) , "SvtInternalOptions_Impl::SvtInternalOptions_Impl()\nWho has changed the value type of \"Office.Common\\Internal\\SendCrashMail\"?" );
304 seqValues[FIXPROPERTYHANDLE_SLOTCFG ] >>= m_bSlotCFG ;
305 seqValues[FIXPROPERTYHANDLE_SENDCRASHMAIL ] >>= m_bSendCrashMail ;
306 seqValues[FIXPROPERTYHANDLE_USEMAILUI ] >>= m_bUseMailUI ;
307 seqValues[FIXPROPERTYHANDLE_CURRENTTEMPURL ] >>= m_aCurrentTempURL ;
308 // seqValues[FIXPROPERTYHANDLE_REMOVEMENUENTRYCLOSE ] >>= m_bRemoveMenuEntryClose ;
309 // seqValues[FIXPROPERTYHANDLE_REMOVEMENUENTRYBACKTOWEBTOP ] >>= m_bRemoveMenuEntryBackToWebtop ;
310 // seqValues[FIXPROPERTYHANDLE_REMOVEMENUENTRYNEWWEBTOP ] >>= m_bRemoveMenuEntryNewWebtop ;
311 // seqValues[FIXPROPERTYHANDLE_REMOVEMENUENTRYLOGOUT ] >>= m_bRemoveMenuEntryLogout ;
313 // Read dynamical set "RecoveryList" then.
314 // 3 subkeys for every item!
315 // Attention: Start at next element after last fixed entry! We must ignore "Slot" and "SendCrashMail" ...
316 tIMPL_RecoveryEntry aEntry;
317 sal_uInt32 nCount = seqValues.getLength() ;
318 sal_uInt32 nPosition = FIXPROPERTYCOUNT ;
320 while( nPosition<nCount )
322 seqValues[nPosition] >>= aEntry.sURL ;
323 ++nPosition;
324 seqValues[nPosition] >>= aEntry.sFilter ;
325 ++nPosition;
326 seqValues[nPosition] >>= aEntry.sTempName ;
327 ++nPosition;
328 m_aRecoveryList.push_front( aEntry );
331 // We don't need any notifications here.
332 // "Slot" and "SendCrashMail" are readonly(!) and our recovery list should not modified during runtime - it's used
333 // by our crash guard only ... otherwise we have a big problem.
336 //*****************************************************************************************************************
337 // destructor
338 //*****************************************************************************************************************
339 SvtInternalOptions_Impl::~SvtInternalOptions_Impl()
341 if( IsModified() == sal_True )
343 Commit();
347 //*****************************************************************************************************************
348 // public method
349 //*****************************************************************************************************************
350 void SvtInternalOptions_Impl::Commit()
352 // We have to write our current temp URL
353 Sequence< OUString > aNames( 1 );
354 OUString* pNames = aNames.getArray();
355 Sequence< Any > aValues( 1 );
356 Any* pValues = aValues.getArray();
358 pNames[0] = FIXPROPERTYNAME_CURRENTTEMPURL;
359 pValues[0] <<= m_aCurrentTempURL;
361 PutProperties( aNames, aValues );
364 // Write set of dynamic properties then.
365 ClearNodeSet( PROPERTYNAME_RECOVERYLIST );
367 tIMPL_RecoveryEntry aItem ;
368 OUString sNode ;
369 Sequence< PropertyValue > seqPropertyValues( 3 ) ; // Every node in set has 3 sub-nodes!( url, filter, tempname )
371 // Copy list entries to save-list and write it to configuration.
373 sal_uInt32 nCount = m_aRecoveryList.size();
374 for( sal_uInt32 nItem=0; nItem<nCount; ++nItem )
376 aItem = m_aRecoveryList.top();
377 m_aRecoveryList.pop();
378 sNode = PROPERTYNAME_RECOVERYLIST + PATHDELIMITER + FIXR + OUString::valueOf( (sal_Int32)nItem ) + PATHDELIMITER;
379 seqPropertyValues[OFFSET_URL ].Name = sNode + PROPERTYNAME_URL ;
380 seqPropertyValues[OFFSET_FILTER ].Name = sNode + PROPERTYNAME_FILTER ;
381 seqPropertyValues[OFFSET_TEMPNAME ].Name = sNode + PROPERTYNAME_TEMPNAME ;
382 seqPropertyValues[OFFSET_URL ].Value <<= aItem.sURL ;
383 seqPropertyValues[OFFSET_FILTER ].Value <<= aItem.sFilter ;
384 seqPropertyValues[OFFSET_TEMPNAME ].Value <<= aItem.sTempName ;
386 SetSetProperties( PROPERTYNAME_RECOVERYLIST, seqPropertyValues );
389 tIMPL_RecoveryStack::iterator iRecovery = m_aRecoveryList.begin();
390 for ( sal_uInt32 nItem=0; iRecovery != m_aRecoveryList.end(); ++nItem, ++iRecovery)
392 aItem = *iRecovery;
393 sNode = PROPERTYNAME_RECOVERYLIST + PATHDELIMITER + FIXR +
394 OUString::valueOf( (sal_Int32)nItem ) + PATHDELIMITER;
395 seqPropertyValues[OFFSET_URL ].Name = sNode + PROPERTYNAME_URL ;
396 seqPropertyValues[OFFSET_FILTER ].Name = sNode + PROPERTYNAME_FILTER ;
397 seqPropertyValues[OFFSET_TEMPNAME ].Name = sNode + PROPERTYNAME_TEMPNAME ;
398 seqPropertyValues[OFFSET_URL ].Value <<= iRecovery->sURL ;
399 seqPropertyValues[OFFSET_FILTER ].Value <<= iRecovery->sFilter ;
400 seqPropertyValues[OFFSET_TEMPNAME ].Value <<= iRecovery->sTempName ;
401 SetSetProperties( PROPERTYNAME_RECOVERYLIST, seqPropertyValues );
407 //*****************************************************************************************************************
408 // public method
409 //*****************************************************************************************************************
410 void SvtInternalOptions_Impl::SetCurrentTempURL( const OUString& aNewCurrentTempURL )
412 m_aCurrentTempURL = aNewCurrentTempURL;
413 SetModified();
414 Commit();
417 #if 0
418 //*****************************************************************************************************************
419 // public method
420 //*****************************************************************************************************************
421 void SvtInternalOptions_Impl::PushRecoveryItem( const OUString& sURL ,
422 const OUString& sFilter ,
423 const OUString& sTempName )
425 tIMPL_RecoveryEntry aEntry( sURL, sFilter, sTempName );
426 m_aRecoveryList.push_front( aEntry );
427 SetModified();
430 //*****************************************************************************************************************
431 // public method
432 //*****************************************************************************************************************
433 void SvtInternalOptions_Impl::PopRecoveryItem( OUString& sURL ,
434 OUString& sFilter ,
435 OUString& sTempName )
437 tIMPL_RecoveryEntry aEntry = m_aRecoveryList.front();
438 m_aRecoveryList.pop_front();
439 SetModified(); // Don't forget it - we delete an entry here!
440 sURL = aEntry.sURL ;
441 sFilter = aEntry.sFilter ;
442 sTempName = aEntry.sTempName ;
445 //*****************************************************************************************************************
446 // public method
447 //*****************************************************************************************************************
448 sal_Bool SvtInternalOptions_Impl::IsRecoveryListEmpty() const
450 return ( m_aRecoveryList.empty() );
452 #endif
454 //*****************************************************************************************************************
455 // private method
456 //*****************************************************************************************************************
457 Sequence< OUString > SvtInternalOptions_Impl::impl_GetPropertyNames()
460 // First get ALL names of current existing list items in configuration!
461 Sequence< OUString > seqRecoveryItems = GetNodeNames( PROPERTYNAME_RECOVERYLIST );
462 // Get information about list counts ...
463 sal_Int32 nRecoveryCount = seqRecoveryItems.getLength();
464 // ... and create a property list with right size! (+2...for fix properties!) (*3 ... = sub nodes for every set node!)
465 Sequence< OUString > seqProperties( FIXPROPERTYCOUNT + (nRecoveryCount*3) );
467 Sequence< OUString > seqProperties(4);
469 // Add names of fix properties to list.
470 seqProperties[FIXPROPERTYHANDLE_SLOTCFG ] = FIXPROPERTYNAME_SLOTCFG ;
471 seqProperties[FIXPROPERTYHANDLE_SENDCRASHMAIL ] = FIXPROPERTYNAME_SENDCRASHMAIL ;
472 seqProperties[FIXPROPERTYHANDLE_USEMAILUI ] = FIXPROPERTYNAME_USEMAILUI ;
473 seqProperties[FIXPROPERTYHANDLE_CURRENTTEMPURL ] = FIXPROPERTYNAME_CURRENTTEMPURL ;
474 // seqProperties[FIXPROPERTYHANDLE_REMOVEMENUENTRYCLOSE ] = FIXPROPERTYNAME_REMOVEMENUENTRYCLOSE;
475 // seqProperties[FIXPROPERTYHANDLE_REMOVEMENUENTRYBACKTOWEBTOP ] = FIXPROPERTYNAME_REMOVEMENUENTRYBACKTOWEBTOP;
476 // seqProperties[FIXPROPERTYHANDLE_REMOVEMENUENTRYNEWWEBTOP ] = FIXPROPERTYNAME_REMOVEMENUENTRYNEWWEBTOP;
477 // seqProperties[FIXPROPERTYHANDLE_REMOVEMENUENTRYLOGOUT ] = FIXPROPERTYNAME_REMOVEMENUENTRYLOGOUT;
479 sal_uInt32 nPosition = FIXPROPERTYCOUNT;
480 // Add names for recovery list to list.
481 // 3 subkeys for every item!
482 // nPosition is the start point of an list item, nItem an index into right list of node names!
483 for( sal_Int32 nItem=0; nItem<nRecoveryCount; ++nItem )
485 seqProperties[nPosition] = PROPERTYNAME_RECOVERYLIST + PATHDELIMITER + seqRecoveryItems[nItem] + PATHDELIMITER + PROPERTYNAME_URL ;
486 ++nPosition;
487 seqProperties[nPosition] = PROPERTYNAME_RECOVERYLIST + PATHDELIMITER + seqRecoveryItems[nItem] + PATHDELIMITER + PROPERTYNAME_FILTER ;
488 ++nPosition;
489 seqProperties[nPosition] = PROPERTYNAME_RECOVERYLIST + PATHDELIMITER + seqRecoveryItems[nItem] + PATHDELIMITER + PROPERTYNAME_TEMPNAME ;
490 ++nPosition;
493 // Return result.
494 return seqProperties;
497 //*****************************************************************************************************************
498 // initialize static member
499 // DON'T DO IT IN YOUR HEADER!
500 // see definition for further informations
501 //*****************************************************************************************************************
502 SvtInternalOptions_Impl* SvtInternalOptions::m_pDataContainer = NULL ;
503 sal_Int32 SvtInternalOptions::m_nRefCount = 0 ;
505 //*****************************************************************************************************************
506 // constructor
507 //*****************************************************************************************************************
508 SvtInternalOptions::SvtInternalOptions()
510 // Global access, must be guarded (multithreading!).
511 MutexGuard aGuard( GetOwnStaticMutex() );
512 // Increase ouer refcount ...
513 ++m_nRefCount;
514 // ... and initialize ouer data container only if it not already!
515 if( m_pDataContainer == NULL )
517 RTL_LOGFILE_CONTEXT(aLog, "svtools ( ??? ) ::SvtInternalOptions_Impl::ctor()");
518 m_pDataContainer = new SvtInternalOptions_Impl();
520 ItemHolder1::holdConfigItem(E_INTERNALOPTIONS);
524 //*****************************************************************************************************************
525 // destructor
526 //*****************************************************************************************************************
527 SvtInternalOptions::~SvtInternalOptions()
529 // Global access, must be guarded (multithreading!)
530 MutexGuard aGuard( GetOwnStaticMutex() );
531 // Decrease ouer refcount.
532 --m_nRefCount;
533 // If last instance was deleted ...
534 // we must destroy ouer static data container!
535 if( m_nRefCount <= 0 )
537 delete m_pDataContainer;
538 m_pDataContainer = NULL;
542 //*****************************************************************************************************************
543 // public method
544 //*****************************************************************************************************************
545 sal_Bool SvtInternalOptions::SlotCFGEnabled() const
547 MutexGuard aGuard( GetOwnStaticMutex() );
548 return m_pDataContainer->SlotCFGEnabled();
551 //*****************************************************************************************************************
552 // public method
553 //*****************************************************************************************************************
554 sal_Bool SvtInternalOptions::CrashMailEnabled() const
556 MutexGuard aGuard( GetOwnStaticMutex() );
557 return m_pDataContainer->CrashMailEnabled();
560 //*****************************************************************************************************************
561 // public method
562 //*****************************************************************************************************************
563 sal_Bool SvtInternalOptions::MailUIEnabled() const
565 MutexGuard aGuard( GetOwnStaticMutex() );
566 return m_pDataContainer->MailUIEnabled();
569 //*****************************************************************************************************************
570 // public methods
571 //*****************************************************************************************************************
572 sal_Bool SvtInternalOptions::IsRemoveMenuEntryClose() const
574 MutexGuard aGuard( GetOwnStaticMutex() );
575 return m_pDataContainer->IsRemoveMenuEntryClose();
578 sal_Bool SvtInternalOptions::IsRemoveMenuEntryBackToWebtop() const
580 MutexGuard aGuard( GetOwnStaticMutex() );
581 return m_pDataContainer->IsRemoveMenuEntryBackToWebtop();
584 sal_Bool SvtInternalOptions::IsRemoveMenuEntryNewWebtop() const
586 MutexGuard aGuard( GetOwnStaticMutex() );
587 return m_pDataContainer->IsRemoveMenuEntryNewWebtop();
590 sal_Bool SvtInternalOptions::IsRemoveMenuEntryLogout() const
592 MutexGuard aGuard( GetOwnStaticMutex() );
593 return m_pDataContainer->IsRemoveMenuEntryLogout();
596 OUString SvtInternalOptions::GetCurrentTempURL() const
598 MutexGuard aGuard( GetOwnStaticMutex() );
599 return m_pDataContainer->GetCurrentTempURL();
602 void SvtInternalOptions::SetCurrentTempURL( const OUString& aNewCurrentTempURL )
604 MutexGuard aGuard( GetOwnStaticMutex() );
605 m_pDataContainer->SetCurrentTempURL( aNewCurrentTempURL );
608 //*****************************************************************************************************************
609 // private method
610 //*****************************************************************************************************************
611 Mutex& SvtInternalOptions::GetOwnStaticMutex()
613 // Initialize static mutex only for one time!
614 static Mutex* pMutex = NULL;
615 // If these method first called (Mutex not already exist!) ...
616 if( pMutex == NULL )
618 // ... we must create a new one. Protect follow code with the global mutex -
619 // It must be - we create a static variable!
620 MutexGuard aGuard( Mutex::getGlobalMutex() );
621 // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
622 if( pMutex == NULL )
624 // Create the new mutex and set it for return on static variable.
625 static Mutex aMutex;
626 pMutex = &aMutex;
629 // Return new created or already existing mutex object.
630 return *pMutex;