1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_unotools.hxx"
26 #ifndef GCC
27 #endif
28
29 //_________________________________________________________________________________________________________________
30 // includes
31 //_________________________________________________________________________________________________________________
32
33 #include <deque>
34
35 #include <unotools/internaloptions.hxx>
36 #include <unotools/configmgr.hxx>
37 #include <unotools/configitem.hxx>
38 #include <tools/debug.hxx>
39 #include <com/sun/star/uno/Any.hxx>
40 #include <com/sun/star/uno/Sequence.hxx>
41 #include <com/sun/star/beans/PropertyValue.hpp>
42
43 #include <rtl/logfile.hxx>
44 #include "itemholder1.hxx"
45
46 //_________________________________________________________________________________________________________________
47 // namespaces
48 //_________________________________________________________________________________________________________________
49
50 using namespace ::utl ;
51 using namespace ::rtl ;
52 using namespace ::osl ;
53 using namespace ::std ;
54 using namespace ::com::sun::star::uno ;
55 using namespace ::com::sun::star::beans ;
56
57 //_________________________________________________________________________________________________________________
58 // const
59 //_________________________________________________________________________________________________________________
60
61 #define ROOTNODE_INTERNAL OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/Internal" ))
62 #define DEFAULT_SLOTCFG sal_False
63 #define DEFAULT_SENDCRASHMAIL sal_False
64 #define DEFAULT_USEMAILUI sal_True
65 #define DEFAULT_CURRENTTEMPURL OUString(RTL_CONSTASCII_USTRINGPARAM(""))
66
67 #define FIXPROPERTYNAME_SLOTCFG OUString(RTL_CONSTASCII_USTRINGPARAM("Slot" ))
68 #define FIXPROPERTYNAME_SENDCRASHMAIL OUString(RTL_CONSTASCII_USTRINGPARAM("SendCrashMail" ))
69 #define FIXPROPERTYNAME_USEMAILUI OUString(RTL_CONSTASCII_USTRINGPARAM("UseMailUI" ))
70 #define FIXPROPERTYNAME_CURRENTTEMPURL OUString(RTL_CONSTASCII_USTRINGPARAM("CurrentTempURL" ))
71 //#define FIXPROPERTYNAME_REMOVEMENUENTRYCLOSE OUString(RTL_CONSTASCII_USTRINGPARAM("RemoveMenuEntryClose"))
72 //#define FIXPROPERTYNAME_REMOVEMENUENTRYBACKTOWEBTOP OUString(RTL_CONSTASCII_USTRINGPARAM("RemoveMenuEntryBackToWebtop"))
73 //#define FIXPROPERTYNAME_REMOVEMENUENTRYNEWWEBTOP OUString(RTL_CONSTASCII_USTRINGPARAM("RemoveMenuEntryNewWebtop"))
74 //#define FIXPROPERTYNAME_REMOVEMENUENTRYLOGOUT OUString(RTL_CONSTASCII_USTRINGPARAM("RemoveMenuEntryLogout"))
75
76 #define FIXPROPERTYHANDLE_SLOTCFG 0
77 #define FIXPROPERTYHANDLE_SENDCRASHMAIL 1
78 #define FIXPROPERTYHANDLE_USEMAILUI 2
79 #define FIXPROPERTYHANDLE_CURRENTTEMPURL 3
80 //#define FIXPROPERTYHANDLE_REMOVEMENUENTRYCLOSE 3
81 //#define FIXPROPERTYHANDLE_REMOVEMENUENTRYBACKTOWEBTOP 4
82 //#define FIXPROPERTYHANDLE_REMOVEMENUENTRYNEWWEBTOP 5
83 //#define FIXPROPERTYHANDLE_REMOVEMENUENTRYLOGOUT 6
84
85 #define FIXPROPERTYCOUNT 4
86 /*
87 #define PROPERTYNAME_RECOVERYLIST OUString(RTL_CONSTASCII_USTRINGPARAM("RecoveryList" ))
88 #define PROPERTYNAME_URL OUString(RTL_CONSTASCII_USTRINGPARAM("OrgURL" ))
89 #define PROPERTYNAME_FILTER OUString(RTL_CONSTASCII_USTRINGPARAM("FilterName" ))
90 #define PROPERTYNAME_TEMPNAME OUString(RTL_CONSTASCII_USTRINGPARAM("TempURL" ))
91
92 #define OFFSET_URL 0
93 #define OFFSET_FILTER 1
94 #define OFFSET_TEMPNAME 2
95 */
96 #define PATHDELIMITER OUString(RTL_CONSTASCII_USTRINGPARAM("/" ))
97 #define FIXR OUString(RTL_CONSTASCII_USTRINGPARAM("r" ))
98
99 //_________________________________________________________________________________________________________________
100 // private declarations!
101 //_________________________________________________________________________________________________________________
102 /*
103 struct tIMPL_RecoveryEntry
104 {
105 OUString sURL ;
106 OUString sFilter ;
107 OUString sTempName ;
108
109 tIMPL_RecoveryEntry()
110 {
111 sURL = OUString();
112 sFilter = OUString();
113 sTempName = OUString();
114 }
115
116 tIMPL_RecoveryEntry( const OUString& sNewURL ,
117 const OUString& sNewFilter ,
118 const OUString& sNewTempName )
119 {
120 sURL = sNewURL ;
121 sFilter = sNewFilter ;
122 sTempName = sNewTempName ;
123 }
124 };
125
126 typedef deque< tIMPL_RecoveryEntry > tIMPL_RecoveryStack;
127 */
128 class SvtInternalOptions_Impl : public ConfigItem
129 {
130 //-------------------------------------------------------------------------------------------------------------
131 // private member
132 //-------------------------------------------------------------------------------------------------------------
133
134 private:
135
136 sal_Bool m_bRemoveMenuEntryClose;
137 sal_Bool m_bRemoveMenuEntryBackToWebtop;
138 sal_Bool m_bRemoveMenuEntryNewWebtop;
139 sal_Bool m_bRemoveMenuEntryLogout;
140 sal_Bool m_bSlotCFG ; /// cache "Slot" of Internal section
141 sal_Bool m_bSendCrashMail ; /// cache "SendCrashMail" of Internal section
142 sal_Bool m_bUseMailUI;
143 OUString m_aCurrentTempURL ;
144 // tIMPL_RecoveryStack m_aRecoveryList ; /// cache "RecoveryList" of Internal section
145 //-------------------------------------------------------------------------------------------------------------
146 // public methods
147 //-------------------------------------------------------------------------------------------------------------
148
149 public:
150
151 //---------------------------------------------------------------------------------------------------------
152 // constructor / destructor
153 //---------------------------------------------------------------------------------------------------------
154
155 SvtInternalOptions_Impl();
156 ~SvtInternalOptions_Impl();
157
158 //---------------------------------------------------------------------------------------------------------
159 // overloaded methods of baseclass
160 //---------------------------------------------------------------------------------------------------------
161
162 /*-****************************************************************************************************//**
163 @short called for notify of configmanager
164 @descr These method is called from the ConfigManager before application ends or from the
165 PropertyChangeListener if the sub tree broadcasts changes. You must update your
166 internal values.
167
168 @seealso baseclass ConfigItem
169
170 @param "seqPropertyNames" is the list of properties which should be updated.
171 @return -
172
173 @onerror -
174 *//*-*****************************************************************************************************/
175
Notify(const Sequence<OUString> &)176 virtual void Notify( const Sequence< OUString >& )
177 {
178 DBG_ASSERT( sal_False, "SvtInternalOptions::Notify()\nNot used yet ... but called!?\n" );
179 }
180
181 /*-****************************************************************************************************//**
182 @short write changes to configuration
183 @descr These method writes the changed values into the sub tree
184 and should always called in our destructor to guarantee consistency of config data.
185
186 @seealso baseclass ConfigItem
187
188 @param -
189 @return -
190
191 @onerror -
192 *//*-*****************************************************************************************************/
193
194 virtual void Commit();
195
196 //---------------------------------------------------------------------------------------------------------
197 // public interface
198 //---------------------------------------------------------------------------------------------------------
199
200 /*-****************************************************************************************************//**
201 @short access method to get internal values
202 @descr These method give us a chance to regulate acces to ouer internal values.
203 It's not used in the moment - but it's possible for the feature!
204
205 @seealso -
206
207 @param -
208 @return -
209
210 @onerror -
211 *//*-*****************************************************************************************************/
212
IsRemoveMenuEntryClose() const213 sal_Bool IsRemoveMenuEntryClose() const { return m_bRemoveMenuEntryClose; }
IsRemoveMenuEntryBackToWebtop() const214 sal_Bool IsRemoveMenuEntryBackToWebtop() const { return m_bRemoveMenuEntryBackToWebtop; }
IsRemoveMenuEntryNewWebtop() const215 sal_Bool IsRemoveMenuEntryNewWebtop() const { return m_bRemoveMenuEntryNewWebtop; }
IsRemoveMenuEntryLogout() const216 sal_Bool IsRemoveMenuEntryLogout() const { return m_bRemoveMenuEntryLogout; }
SlotCFGEnabled() const217 sal_Bool SlotCFGEnabled () const { return m_bSlotCFG; }
CrashMailEnabled() const218 sal_Bool CrashMailEnabled () const { return m_bSendCrashMail; }
MailUIEnabled() const219 sal_Bool MailUIEnabled () const { return m_bUseMailUI; }
220
GetCurrentTempURL() const221 OUString GetCurrentTempURL() const { return m_aCurrentTempURL; }
222 void SetCurrentTempURL( const OUString& aNewCurrentTempURL );
223 /*
224 void PushRecoveryItem ( const OUString& sURL ,
225 const OUString& sFilter ,
226 const OUString& sTempName );
227 void PopRecoveryItem ( OUString& sURL ,
228 OUString& sFilter ,
229 OUString& sTempName );
230 sal_Bool IsRecoveryListEmpty ( ) const;
231 */
232 //-------------------------------------------------------------------------------------------------------------
233 // private methods
234 //-------------------------------------------------------------------------------------------------------------
235
236 private:
237
238 /*-****************************************************************************************************//**
239 @short return list of fix key names of ouer configuration management which represent oue module tree
240 @descr These methods return a static const list of key names. We need it to get needed values from our
241 configuration management. We return well known key names only - because the "UserData" node
242 is handled in a special way!
243
244 @seealso -
245
246 @param -
247 @return A list of needed configuration keys is returned.
248
249 @onerror -
250 *//*-*****************************************************************************************************/
251
252 Sequence< OUString > impl_GetPropertyNames();
253 };
254
255 //_________________________________________________________________________________________________________________
256 // definitions
257 //_________________________________________________________________________________________________________________
258
259 //*****************************************************************************************************************
260 // constructor
261 //*****************************************************************************************************************
SvtInternalOptions_Impl()262 SvtInternalOptions_Impl::SvtInternalOptions_Impl()
263 // Init baseclasses first
264 : ConfigItem ( ROOTNODE_INTERNAL, CONFIG_MODE_IMMEDIATE_UPDATE )
265 // Init member then.
266 , m_bRemoveMenuEntryClose ( sal_False )
267 , m_bRemoveMenuEntryBackToWebtop ( sal_False )
268 , m_bRemoveMenuEntryNewWebtop ( sal_False )
269 , m_bRemoveMenuEntryLogout ( sal_False )
270 , m_bSlotCFG ( DEFAULT_SLOTCFG )
271 , m_bSendCrashMail ( DEFAULT_SENDCRASHMAIL )
272 , m_bUseMailUI ( DEFAULT_USEMAILUI )
273 , m_aCurrentTempURL ( DEFAULT_CURRENTTEMPURL )
274 {
275 // Use our list of configuration keys to get his values.
276 // structure of internal section: (first 2 entries are fixed - all other are member of a set!)
277 // "Slot"
278 // "SendCrashMail"
279 // "RecoveryList/r1/URL"
280 // "RecoveryList/r1/Filter"
281 // "RecoveryList/r1/TempName"
282 // "RecoveryList/r2/URL"
283 // "RecoveryList/r2/Filter"
284 // "RecoveryList/r2/TempName"
285 // "RecoveryList/.."
286 Sequence< OUString > seqNames = impl_GetPropertyNames() ;
287 Sequence< Any > seqValues = GetProperties( seqNames ) ;
288
289 // Safe impossible cases.
290 // We need values from ALL configuration keys.
291 // Follow assignment use order of values in relation to our list of key names!
292 DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtInternalOptions_Impl::SvtInternalOptions_Impl()\nI miss some values of configuration keys!\n" );
293
294 // Read fixed values first!
295 DBG_ASSERT(!(seqValues[FIXPROPERTYHANDLE_SLOTCFG].getValueTypeClass()!=TypeClass_BOOLEAN) , "SvtInternalOptions_Impl::SvtInternalOptions_Impl()\nWho has changed the value type of \"Office.Common\\Internal\\Slot\"?" );
296 DBG_ASSERT(!(seqValues[FIXPROPERTYHANDLE_SENDCRASHMAIL].getValueTypeClass()!=TypeClass_BOOLEAN) , "SvtInternalOptions_Impl::SvtInternalOptions_Impl()\nWho has changed the value type of \"Office.Common\\Internal\\SendCrashMail\"?" );
297 seqValues[FIXPROPERTYHANDLE_SLOTCFG ] >>= m_bSlotCFG ;
298 seqValues[FIXPROPERTYHANDLE_SENDCRASHMAIL ] >>= m_bSendCrashMail ;
299 seqValues[FIXPROPERTYHANDLE_USEMAILUI ] >>= m_bUseMailUI ;
300 seqValues[FIXPROPERTYHANDLE_CURRENTTEMPURL ] >>= m_aCurrentTempURL ;
301 // seqValues[FIXPROPERTYHANDLE_REMOVEMENUENTRYCLOSE ] >>= m_bRemoveMenuEntryClose ;
302 // seqValues[FIXPROPERTYHANDLE_REMOVEMENUENTRYBACKTOWEBTOP ] >>= m_bRemoveMenuEntryBackToWebtop ;
303 // seqValues[FIXPROPERTYHANDLE_REMOVEMENUENTRYNEWWEBTOP ] >>= m_bRemoveMenuEntryNewWebtop ;
304 // seqValues[FIXPROPERTYHANDLE_REMOVEMENUENTRYLOGOUT ] >>= m_bRemoveMenuEntryLogout ;
305 /*
306 // Read dynamical set "RecoveryList" then.
307 // 3 subkeys for every item!
308 // Attention: Start at next element after last fixed entry! We must ignore "Slot" and "SendCrashMail" ...
309 tIMPL_RecoveryEntry aEntry;
310 sal_uInt32 nCount = seqValues.getLength() ;
311 sal_uInt32 nPosition = FIXPROPERTYCOUNT ;
312
313 while( nPosition<nCount )
314 {
315 seqValues[nPosition] >>= aEntry.sURL ;
316 ++nPosition;
317 seqValues[nPosition] >>= aEntry.sFilter ;
318 ++nPosition;
319 seqValues[nPosition] >>= aEntry.sTempName ;
320 ++nPosition;
321 m_aRecoveryList.push_front( aEntry );
322 }
323 */
324 // We don't need any notifications here.
325 // "Slot" and "SendCrashMail" are readonly(!) and our recovery list should not modified during runtime - it's used
326 // by our crash guard only ... otherwise we have a big problem.
327 }
328
329 //*****************************************************************************************************************
330 // destructor
331 //*****************************************************************************************************************
~SvtInternalOptions_Impl()332 SvtInternalOptions_Impl::~SvtInternalOptions_Impl()
333 {
334 if( IsModified() == sal_True )
335 {
336 Commit();
337 }
338 }
339
340 //*****************************************************************************************************************
341 // public method
342 //*****************************************************************************************************************
Commit()343 void SvtInternalOptions_Impl::Commit()
344 {
345 // We have to write our current temp URL
346 Sequence< OUString > aNames( 1 );
347 OUString* pNames = aNames.getArray();
348 Sequence< Any > aValues( 1 );
349 Any* pValues = aValues.getArray();
350
351 pNames[0] = FIXPROPERTYNAME_CURRENTTEMPURL;
352 pValues[0] <<= m_aCurrentTempURL;
353
354 PutProperties( aNames, aValues );
355
356 /*
357 // Write set of dynamic properties then.
358 ClearNodeSet( PROPERTYNAME_RECOVERYLIST );
359
360 tIMPL_RecoveryEntry aItem ;
361 OUString sNode ;
362 Sequence< PropertyValue > seqPropertyValues( 3 ) ; // Every node in set has 3 sub-nodes!( url, filter, tempname )
363
364 // Copy list entries to save-list and write it to configuration.
365
366 sal_uInt32 nCount = m_aRecoveryList.size();
367 for( sal_uInt32 nItem=0; nItem<nCount; ++nItem )
368 {
369 aItem = m_aRecoveryList.top();
370 m_aRecoveryList.pop();
371 sNode = PROPERTYNAME_RECOVERYLIST + PATHDELIMITER + FIXR + OUString::valueOf( (sal_Int32)nItem ) + PATHDELIMITER;
372 seqPropertyValues[OFFSET_URL ].Name = sNode + PROPERTYNAME_URL ;
373 seqPropertyValues[OFFSET_FILTER ].Name = sNode + PROPERTYNAME_FILTER ;
374 seqPropertyValues[OFFSET_TEMPNAME ].Name = sNode + PROPERTYNAME_TEMPNAME ;
375 seqPropertyValues[OFFSET_URL ].Value <<= aItem.sURL ;
376 seqPropertyValues[OFFSET_FILTER ].Value <<= aItem.sFilter ;
377 seqPropertyValues[OFFSET_TEMPNAME ].Value <<= aItem.sTempName ;
378
379 SetSetProperties( PROPERTYNAME_RECOVERYLIST, seqPropertyValues );
380 }
381
382 tIMPL_RecoveryStack::iterator iRecovery = m_aRecoveryList.begin();
383 for ( sal_uInt32 nItem=0; iRecovery != m_aRecoveryList.end(); ++nItem, ++iRecovery)
384 {
385 aItem = *iRecovery;
386 sNode = PROPERTYNAME_RECOVERYLIST + PATHDELIMITER + FIXR +
387 OUString::valueOf( (sal_Int32)nItem ) + PATHDELIMITER;
388 seqPropertyValues[OFFSET_URL ].Name = sNode + PROPERTYNAME_URL ;
389 seqPropertyValues[OFFSET_FILTER ].Name = sNode + PROPERTYNAME_FILTER ;
390 seqPropertyValues[OFFSET_TEMPNAME ].Name = sNode + PROPERTYNAME_TEMPNAME ;
391 seqPropertyValues[OFFSET_URL ].Value <<= iRecovery->sURL ;
392 seqPropertyValues[OFFSET_FILTER ].Value <<= iRecovery->sFilter ;
393 seqPropertyValues[OFFSET_TEMPNAME ].Value <<= iRecovery->sTempName ;
394 SetSetProperties( PROPERTYNAME_RECOVERYLIST, seqPropertyValues );
395 }
396
397 */
398 }
399
400 //*****************************************************************************************************************
401 // public method
402 //*****************************************************************************************************************
SetCurrentTempURL(const OUString & aNewCurrentTempURL)403 void SvtInternalOptions_Impl::SetCurrentTempURL( const OUString& aNewCurrentTempURL )
404 {
405 m_aCurrentTempURL = aNewCurrentTempURL;
406 SetModified();
407 Commit();
408 }
409
410 #if 0
411 //*****************************************************************************************************************
412 // public method
413 //*****************************************************************************************************************
414 void SvtInternalOptions_Impl::PushRecoveryItem( const OUString& sURL ,
415 const OUString& sFilter ,
416 const OUString& sTempName )
417 {
418 tIMPL_RecoveryEntry aEntry( sURL, sFilter, sTempName );
419 m_aRecoveryList.push_front( aEntry );
420 SetModified();
421 }
422
423 //*****************************************************************************************************************
424 // public method
425 //*****************************************************************************************************************
426 void SvtInternalOptions_Impl::PopRecoveryItem( OUString& sURL ,
427 OUString& sFilter ,
428 OUString& sTempName )
429 {
430 tIMPL_RecoveryEntry aEntry = m_aRecoveryList.front();
431 m_aRecoveryList.pop_front();
432 SetModified(); // Don't forget it - we delete an entry here!
433 sURL = aEntry.sURL ;
434 sFilter = aEntry.sFilter ;
435 sTempName = aEntry.sTempName ;
436 }
437
438 //*****************************************************************************************************************
439 // public method
440 //*****************************************************************************************************************
441 sal_Bool SvtInternalOptions_Impl::IsRecoveryListEmpty() const
442 {
443 return ( m_aRecoveryList.empty() );
444 }
445 #endif
446
447 //*****************************************************************************************************************
448 // private method
449 //*****************************************************************************************************************
impl_GetPropertyNames()450 Sequence< OUString > SvtInternalOptions_Impl::impl_GetPropertyNames()
451 {
452 /*
453 // First get ALL names of current existing list items in configuration!
454 Sequence< OUString > seqRecoveryItems = GetNodeNames( PROPERTYNAME_RECOVERYLIST );
455 // Get information about list counts ...
456 sal_Int32 nRecoveryCount = seqRecoveryItems.getLength();
457 // ... and create a property list with right size! (+2...for fix properties!) (*3 ... = sub nodes for every set node!)
458 Sequence< OUString > seqProperties( FIXPROPERTYCOUNT + (nRecoveryCount*3) );
459 */
460 Sequence< OUString > seqProperties(4);
461
462 // Add names of fix properties to list.
463 seqProperties[FIXPROPERTYHANDLE_SLOTCFG ] = FIXPROPERTYNAME_SLOTCFG ;
464 seqProperties[FIXPROPERTYHANDLE_SENDCRASHMAIL ] = FIXPROPERTYNAME_SENDCRASHMAIL ;
465 seqProperties[FIXPROPERTYHANDLE_USEMAILUI ] = FIXPROPERTYNAME_USEMAILUI ;
466 seqProperties[FIXPROPERTYHANDLE_CURRENTTEMPURL ] = FIXPROPERTYNAME_CURRENTTEMPURL ;
467 // seqProperties[FIXPROPERTYHANDLE_REMOVEMENUENTRYCLOSE ] = FIXPROPERTYNAME_REMOVEMENUENTRYCLOSE;
468 // seqProperties[FIXPROPERTYHANDLE_REMOVEMENUENTRYBACKTOWEBTOP ] = FIXPROPERTYNAME_REMOVEMENUENTRYBACKTOWEBTOP;
469 // seqProperties[FIXPROPERTYHANDLE_REMOVEMENUENTRYNEWWEBTOP ] = FIXPROPERTYNAME_REMOVEMENUENTRYNEWWEBTOP;
470 // seqProperties[FIXPROPERTYHANDLE_REMOVEMENUENTRYLOGOUT ] = FIXPROPERTYNAME_REMOVEMENUENTRYLOGOUT;
471 /*
472 sal_uInt32 nPosition = FIXPROPERTYCOUNT;
473 // Add names for recovery list to list.
474 // 3 subkeys for every item!
475 // nPosition is the start point of an list item, nItem an index into right list of node names!
476 for( sal_Int32 nItem=0; nItem<nRecoveryCount; ++nItem )
477 {
478 seqProperties[nPosition] = PROPERTYNAME_RECOVERYLIST + PATHDELIMITER + seqRecoveryItems[nItem] + PATHDELIMITER + PROPERTYNAME_URL ;
479 ++nPosition;
480 seqProperties[nPosition] = PROPERTYNAME_RECOVERYLIST + PATHDELIMITER + seqRecoveryItems[nItem] + PATHDELIMITER + PROPERTYNAME_FILTER ;
481 ++nPosition;
482 seqProperties[nPosition] = PROPERTYNAME_RECOVERYLIST + PATHDELIMITER + seqRecoveryItems[nItem] + PATHDELIMITER + PROPERTYNAME_TEMPNAME ;
483 ++nPosition;
484 }
485 */
486 // Return result.
487 return seqProperties;
488 }
489
490 //*****************************************************************************************************************
491 // initialize static member
492 // DON'T DO IT IN YOUR HEADER!
493 // see definition for further informations
494 //*****************************************************************************************************************
495 SvtInternalOptions_Impl* SvtInternalOptions::m_pDataContainer = NULL ;
496 sal_Int32 SvtInternalOptions::m_nRefCount = 0 ;
497
498 //*****************************************************************************************************************
499 // constructor
500 //*****************************************************************************************************************
SvtInternalOptions()501 SvtInternalOptions::SvtInternalOptions()
502 {
503 // Global access, must be guarded (multithreading!).
504 MutexGuard aGuard( GetOwnStaticMutex() );
505 // Increase ouer refcount ...
506 ++m_nRefCount;
507 // ... and initialize ouer data container only if it not already!
508 if( m_pDataContainer == NULL )
509 {
510 RTL_LOGFILE_CONTEXT(aLog, "unotools ( ??? ) ::SvtInternalOptions_Impl::ctor()");
511 m_pDataContainer = new SvtInternalOptions_Impl();
512
513 ItemHolder1::holdConfigItem(E_INTERNALOPTIONS);
514 }
515 }
516
517 //*****************************************************************************************************************
518 // destructor
519 //*****************************************************************************************************************
~SvtInternalOptions()520 SvtInternalOptions::~SvtInternalOptions()
521 {
522 // Global access, must be guarded (multithreading!)
523 MutexGuard aGuard( GetOwnStaticMutex() );
524 // Decrease ouer refcount.
525 --m_nRefCount;
526 // If last instance was deleted ...
527 // we must destroy ouer static data container!
528 if( m_nRefCount <= 0 )
529 {
530 delete m_pDataContainer;
531 m_pDataContainer = NULL;
532 }
533 }
534
535 //*****************************************************************************************************************
536 // public method
537 //*****************************************************************************************************************
SlotCFGEnabled() const538 sal_Bool SvtInternalOptions::SlotCFGEnabled() const
539 {
540 MutexGuard aGuard( GetOwnStaticMutex() );
541 return m_pDataContainer->SlotCFGEnabled();
542 }
543
544 //*****************************************************************************************************************
545 // public method
546 //*****************************************************************************************************************
CrashMailEnabled() const547 sal_Bool SvtInternalOptions::CrashMailEnabled() const
548 {
549 MutexGuard aGuard( GetOwnStaticMutex() );
550 return m_pDataContainer->CrashMailEnabled();
551 }
552
553 //*****************************************************************************************************************
554 // public method
555 //*****************************************************************************************************************
MailUIEnabled() const556 sal_Bool SvtInternalOptions::MailUIEnabled() const
557 {
558 MutexGuard aGuard( GetOwnStaticMutex() );
559 return m_pDataContainer->MailUIEnabled();
560 }
561
562 //*****************************************************************************************************************
563 // public methods
564 //*****************************************************************************************************************
IsRemoveMenuEntryClose() const565 sal_Bool SvtInternalOptions::IsRemoveMenuEntryClose() const
566 {
567 MutexGuard aGuard( GetOwnStaticMutex() );
568 return m_pDataContainer->IsRemoveMenuEntryClose();
569 }
570
IsRemoveMenuEntryBackToWebtop() const571 sal_Bool SvtInternalOptions::IsRemoveMenuEntryBackToWebtop() const
572 {
573 MutexGuard aGuard( GetOwnStaticMutex() );
574 return m_pDataContainer->IsRemoveMenuEntryBackToWebtop();
575 }
576
IsRemoveMenuEntryNewWebtop() const577 sal_Bool SvtInternalOptions::IsRemoveMenuEntryNewWebtop() const
578 {
579 MutexGuard aGuard( GetOwnStaticMutex() );
580 return m_pDataContainer->IsRemoveMenuEntryNewWebtop();
581 }
582
IsRemoveMenuEntryLogout() const583 sal_Bool SvtInternalOptions::IsRemoveMenuEntryLogout() const
584 {
585 MutexGuard aGuard( GetOwnStaticMutex() );
586 return m_pDataContainer->IsRemoveMenuEntryLogout();
587 }
588
GetCurrentTempURL() const589 OUString SvtInternalOptions::GetCurrentTempURL() const
590 {
591 MutexGuard aGuard( GetOwnStaticMutex() );
592 return m_pDataContainer->GetCurrentTempURL();
593 }
594
SetCurrentTempURL(const OUString & aNewCurrentTempURL)595 void SvtInternalOptions::SetCurrentTempURL( const OUString& aNewCurrentTempURL )
596 {
597 MutexGuard aGuard( GetOwnStaticMutex() );
598 m_pDataContainer->SetCurrentTempURL( aNewCurrentTempURL );
599 }
600
601 //*****************************************************************************************************************
602 // private method
603 //*****************************************************************************************************************
GetOwnStaticMutex()604 Mutex& SvtInternalOptions::GetOwnStaticMutex()
605 {
606 // Initialize static mutex only for one time!
607 static Mutex* pMutex = NULL;
608 // If these method first called (Mutex not already exist!) ...
609 if( pMutex == NULL )
610 {
611 // ... we must create a new one. Protect follow code with the global mutex -
612 // It must be - we create a static variable!
613 MutexGuard aGuard( Mutex::getGlobalMutex() );
614 // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
615 if( pMutex == NULL )
616 {
617 // Create the new mutex and set it for return on static variable.
618 static Mutex aMutex;
619 pMutex = &aMutex;
620 }
621 }
622 // Return new created or already existing mutex object.
623 return *pMutex;
624 }
625