1b5088357SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3b5088357SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4b5088357SAndrew Rist * or more contributor license agreements. See the NOTICE file
5b5088357SAndrew Rist * distributed with this work for additional information
6b5088357SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7b5088357SAndrew Rist * to you under the Apache License, Version 2.0 (the
8b5088357SAndrew Rist * "License"); you may not use this file except in compliance
9b5088357SAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11b5088357SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13b5088357SAndrew Rist * Unless required by applicable law or agreed to in writing,
14b5088357SAndrew Rist * software distributed under the License is distributed on an
15b5088357SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16b5088357SAndrew Rist * KIND, either express or implied. See the License for the
17b5088357SAndrew Rist * specific language governing permissions and limitations
18b5088357SAndrew Rist * under the License.
19cdf0e10cSrcweir *
20b5088357SAndrew Rist *************************************************************/
21b5088357SAndrew Rist
22cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
23cdf0e10cSrcweir #include "precompiled_unotools.hxx"
24cdf0e10cSrcweir #ifndef GCC
25cdf0e10cSrcweir #endif
26cdf0e10cSrcweir
27cdf0e10cSrcweir //_________________________________________________________________________________________________________________
28cdf0e10cSrcweir // includes
29cdf0e10cSrcweir //_________________________________________________________________________________________________________________
30cdf0e10cSrcweir
31cdf0e10cSrcweir #include <unotools/startoptions.hxx>
32cdf0e10cSrcweir #include <unotools/configmgr.hxx>
33cdf0e10cSrcweir #include <unotools/configitem.hxx>
34cdf0e10cSrcweir #include <tools/debug.hxx>
35cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx>
36cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
37cdf0e10cSrcweir
38cdf0e10cSrcweir #include <rtl/logfile.hxx>
39cdf0e10cSrcweir #include "itemholder1.hxx"
40cdf0e10cSrcweir //_________________________________________________________________________________________________________________
41cdf0e10cSrcweir // namespaces
42cdf0e10cSrcweir //_________________________________________________________________________________________________________________
43cdf0e10cSrcweir
44cdf0e10cSrcweir using namespace ::utl ;
45cdf0e10cSrcweir using namespace ::rtl ;
46cdf0e10cSrcweir using namespace ::osl ;
47cdf0e10cSrcweir using namespace ::com::sun::star::uno ;
48cdf0e10cSrcweir
49cdf0e10cSrcweir //_________________________________________________________________________________________________________________
50cdf0e10cSrcweir // const
51cdf0e10cSrcweir //_________________________________________________________________________________________________________________
52cdf0e10cSrcweir
53cdf0e10cSrcweir #define DEFAULT_SHOWINTRO sal_True
54cdf0e10cSrcweir #define DEFAULT_CONNECTIONURL OUString()
55cdf0e10cSrcweir
56cdf0e10cSrcweir #define ROOTNODE_START OUString(RTL_CONSTASCII_USTRINGPARAM("Setup/Office" ))
57cdf0e10cSrcweir #define PROPERTYNAME_SHOWINTRO OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupShowIntro" ))
58cdf0e10cSrcweir #define PROPERTYNAME_CONNECTIONURL OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupConnectionURL" ))
59cdf0e10cSrcweir
60cdf0e10cSrcweir #define PROPERTYHANDLE_SHOWINTRO 0
61cdf0e10cSrcweir #define PROPERTYHANDLE_CONNECTIONURL 1
62cdf0e10cSrcweir
63cdf0e10cSrcweir #define PROPERTYCOUNT 2
64cdf0e10cSrcweir
65cdf0e10cSrcweir //_________________________________________________________________________________________________________________
66cdf0e10cSrcweir // private declarations!
67cdf0e10cSrcweir //_________________________________________________________________________________________________________________
68cdf0e10cSrcweir
69cdf0e10cSrcweir class SvtStartOptions_Impl : public ConfigItem
70cdf0e10cSrcweir {
71cdf0e10cSrcweir //-------------------------------------------------------------------------------------------------------------
72cdf0e10cSrcweir // public methods
73cdf0e10cSrcweir //-------------------------------------------------------------------------------------------------------------
74cdf0e10cSrcweir
75cdf0e10cSrcweir public:
76cdf0e10cSrcweir
77cdf0e10cSrcweir //---------------------------------------------------------------------------------------------------------
78cdf0e10cSrcweir // constructor / destructor
79cdf0e10cSrcweir //---------------------------------------------------------------------------------------------------------
80cdf0e10cSrcweir
81cdf0e10cSrcweir SvtStartOptions_Impl();
82cdf0e10cSrcweir ~SvtStartOptions_Impl();
83cdf0e10cSrcweir
84cdf0e10cSrcweir //---------------------------------------------------------------------------------------------------------
85cdf0e10cSrcweir // overloaded methods of baseclass
86cdf0e10cSrcweir //---------------------------------------------------------------------------------------------------------
87cdf0e10cSrcweir
88cdf0e10cSrcweir /*-****************************************************************************************************//**
89cdf0e10cSrcweir @short called for notify of configmanager
90cdf0e10cSrcweir @descr These method is called from the ConfigManager before application ends or from the
91cdf0e10cSrcweir PropertyChangeListener if the sub tree broadcasts changes. You must update your
92cdf0e10cSrcweir internal values.
93cdf0e10cSrcweir
94cdf0e10cSrcweir @ATTENTION We don't implement these method - because we support readonly values at runtime only!
95cdf0e10cSrcweir
96cdf0e10cSrcweir @seealso baseclass ConfigItem
97cdf0e10cSrcweir
98cdf0e10cSrcweir @param "seqPropertyNames" is the list of properties which should be updated.
99cdf0e10cSrcweir @return -
100cdf0e10cSrcweir
101cdf0e10cSrcweir @onerror -
102cdf0e10cSrcweir *//*-*****************************************************************************************************/
103cdf0e10cSrcweir
104cdf0e10cSrcweir virtual void Notify( const Sequence< OUString >& seqPropertyNames );
105cdf0e10cSrcweir
106cdf0e10cSrcweir /*-****************************************************************************************************//**
107cdf0e10cSrcweir @short write changes to configuration
108cdf0e10cSrcweir @descr These method writes the changed values into the sub tree
109cdf0e10cSrcweir and should always called in our destructor to guarantee consistency of config data.
110cdf0e10cSrcweir
111cdf0e10cSrcweir @ATTENTION We don't implement these method - because we support readonly values at runtime only!
112cdf0e10cSrcweir
113cdf0e10cSrcweir @seealso baseclass ConfigItem
114cdf0e10cSrcweir
115cdf0e10cSrcweir @param -
116cdf0e10cSrcweir @return -
117cdf0e10cSrcweir
118cdf0e10cSrcweir @onerror -
119cdf0e10cSrcweir *//*-*****************************************************************************************************/
120cdf0e10cSrcweir
121cdf0e10cSrcweir virtual void Commit();
122cdf0e10cSrcweir
123cdf0e10cSrcweir //---------------------------------------------------------------------------------------------------------
124cdf0e10cSrcweir // public interface
125cdf0e10cSrcweir //---------------------------------------------------------------------------------------------------------
126cdf0e10cSrcweir
127cdf0e10cSrcweir /*-****************************************************************************************************//**
128cdf0e10cSrcweir @short access method to get internal values
129b12a77c9Smseidel @descr This method gives us a chance to regulate access to our internal values.
130b12a77c9Smseidel It's not used in the moment - but it's possible for the future!
131cdf0e10cSrcweir
132cdf0e10cSrcweir @seealso -
133cdf0e10cSrcweir
134cdf0e10cSrcweir @param -
135cdf0e10cSrcweir @return -
136cdf0e10cSrcweir
137cdf0e10cSrcweir @onerror -
138cdf0e10cSrcweir *//*-*****************************************************************************************************/
139cdf0e10cSrcweir
140cdf0e10cSrcweir sal_Bool IsIntroEnabled ( ) const ;
141cdf0e10cSrcweir void EnableIntro ( sal_Bool bState ) ;
142cdf0e10cSrcweir OUString GetConnectionURL( ) const ;
143cdf0e10cSrcweir void SetConnectionURL( const OUString& sURL ) ;
144cdf0e10cSrcweir
145cdf0e10cSrcweir //-------------------------------------------------------------------------------------------------------------
146cdf0e10cSrcweir // private methods
147cdf0e10cSrcweir //-------------------------------------------------------------------------------------------------------------
148cdf0e10cSrcweir
149cdf0e10cSrcweir private:
150cdf0e10cSrcweir
151cdf0e10cSrcweir /*-****************************************************************************************************//**
152b12a77c9Smseidel @short return list of fix key names of our configuration management which represents our module tree
153cdf0e10cSrcweir @descr These methods return a static const list of key names. We need it to get needed values from our
154cdf0e10cSrcweir configuration management. We return well known key names only - because the "UserData" node
155cdf0e10cSrcweir is handled in a special way!
156cdf0e10cSrcweir
157cdf0e10cSrcweir @seealso -
158cdf0e10cSrcweir
159cdf0e10cSrcweir @param -
160cdf0e10cSrcweir @return A list of needed configuration keys is returned.
161cdf0e10cSrcweir
162cdf0e10cSrcweir @onerror -
163cdf0e10cSrcweir *//*-*****************************************************************************************************/
164cdf0e10cSrcweir
165cdf0e10cSrcweir static Sequence< OUString > impl_GetPropertyNames();
166cdf0e10cSrcweir
167cdf0e10cSrcweir //-------------------------------------------------------------------------------------------------------------
168cdf0e10cSrcweir // private member
169cdf0e10cSrcweir //-------------------------------------------------------------------------------------------------------------
170cdf0e10cSrcweir
171cdf0e10cSrcweir private:
172cdf0e10cSrcweir
173013b951eSmseidel sal_Bool m_bShowIntro ; // cache "ShowIntro" of Start section
174013b951eSmseidel OUString m_sConnectionURL ; // cache "Connection" of Start section
175cdf0e10cSrcweir };
176cdf0e10cSrcweir
177cdf0e10cSrcweir //_________________________________________________________________________________________________________________
178cdf0e10cSrcweir // definitions
179cdf0e10cSrcweir //_________________________________________________________________________________________________________________
180cdf0e10cSrcweir
181cdf0e10cSrcweir //*****************************************************************************************************************
182cdf0e10cSrcweir // constructor
183cdf0e10cSrcweir //*****************************************************************************************************************
SvtStartOptions_Impl()184cdf0e10cSrcweir SvtStartOptions_Impl::SvtStartOptions_Impl()
185cdf0e10cSrcweir // Init baseclasses first
186cdf0e10cSrcweir : ConfigItem ( ROOTNODE_START )
187cdf0e10cSrcweir // Init member then.
188cdf0e10cSrcweir , m_bShowIntro ( DEFAULT_SHOWINTRO )
189cdf0e10cSrcweir {
190cdf0e10cSrcweir // Use our static list of configuration keys to get his values.
191cdf0e10cSrcweir Sequence< OUString > seqNames = impl_GetPropertyNames();
192cdf0e10cSrcweir Sequence< Any > seqValues = GetProperties( seqNames ) ;
193cdf0e10cSrcweir
194cdf0e10cSrcweir // Safe impossible cases.
195cdf0e10cSrcweir // We need values from ALL configuration keys.
196cdf0e10cSrcweir // Follow assignment use order of values in relation to our list of key names!
197cdf0e10cSrcweir DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtStartOptions_Impl::SvtStartOptions_Impl()\nI miss some values of configuration keys!\n" );
198cdf0e10cSrcweir
199b12a77c9Smseidel // Copy values from list in right order to our internal member.
200cdf0e10cSrcweir sal_Int32 nPropertyCount = seqValues.getLength() ;
201cdf0e10cSrcweir sal_Int32 nProperty = 0 ;
202cdf0e10cSrcweir for( nProperty=0; nProperty<nPropertyCount; ++nProperty )
203cdf0e10cSrcweir {
204cdf0e10cSrcweir // Safe impossible cases.
205cdf0e10cSrcweir // Check any for valid value.
206cdf0e10cSrcweir DBG_ASSERT( !(seqValues[nProperty].hasValue()==sal_False), "SvtStartOptions_Impl::SvtStartOptions_Impl()\nInvalid property value for property detected!\n" );
207cdf0e10cSrcweir switch( nProperty )
208cdf0e10cSrcweir {
209cdf0e10cSrcweir case PROPERTYHANDLE_SHOWINTRO : {
210cdf0e10cSrcweir DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtStartOptions_Impl::SvtStartOptions_Impl()\nWho has changed the value type of \"Office.Common\\Start\\ShowIntro\"?" );
211cdf0e10cSrcweir seqValues[nProperty] >>= m_bShowIntro;
212cdf0e10cSrcweir }
213cdf0e10cSrcweir break;
214cdf0e10cSrcweir
215cdf0e10cSrcweir case PROPERTYHANDLE_CONNECTIONURL : {
216cdf0e10cSrcweir DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_STRING), "SvtStartOptions_Impl::SvtStartOptions_Impl()\nWho has changed the value type of \"Office.Common\\Start\\Connection\"?" );
217cdf0e10cSrcweir seqValues[nProperty] >>= m_sConnectionURL;
218cdf0e10cSrcweir }
219cdf0e10cSrcweir break;
220cdf0e10cSrcweir }
221cdf0e10cSrcweir }
222cdf0e10cSrcweir
223b12a77c9Smseidel // Don't enable notification mechanism of our baseclass!
224cdf0e10cSrcweir // We support readonly variables in the moment.
225cdf0e10cSrcweir }
226cdf0e10cSrcweir
227cdf0e10cSrcweir //*****************************************************************************************************************
228cdf0e10cSrcweir // destructor
229cdf0e10cSrcweir //*****************************************************************************************************************
~SvtStartOptions_Impl()230cdf0e10cSrcweir SvtStartOptions_Impl::~SvtStartOptions_Impl()
231cdf0e10cSrcweir {
232cdf0e10cSrcweir // We must save our current values .. if user forget it!
233cdf0e10cSrcweir if( IsModified() == sal_True )
234cdf0e10cSrcweir {
235cdf0e10cSrcweir Commit();
236cdf0e10cSrcweir }
237cdf0e10cSrcweir }
238cdf0e10cSrcweir
239cdf0e10cSrcweir //*****************************************************************************************************************
240cdf0e10cSrcweir // public method
241cdf0e10cSrcweir //*****************************************************************************************************************
Notify(const Sequence<OUString> & seqPropertyNames)242cdf0e10cSrcweir void SvtStartOptions_Impl::Notify( const Sequence< OUString >& seqPropertyNames )
243cdf0e10cSrcweir {
244cdf0e10cSrcweir // Use given list of updated properties to get his values from configuration directly!
245cdf0e10cSrcweir Sequence< Any > seqValues = GetProperties( seqPropertyNames );
246cdf0e10cSrcweir // Safe impossible cases.
247cdf0e10cSrcweir // We need values from ALL notified configuration keys.
248cdf0e10cSrcweir DBG_ASSERT( !(seqPropertyNames.getLength()!=seqValues.getLength()), "SvtStartOptions_Impl::Notify()\nI miss some values of configuration keys!\n" );
249*dcaf07f7SJohn Bampton // Step over list of property names and get right value from corresponding value list to set it on internal members!
250cdf0e10cSrcweir sal_Int32 nCount = seqPropertyNames.getLength();
251cdf0e10cSrcweir for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty )
252cdf0e10cSrcweir {
253cdf0e10cSrcweir if( seqPropertyNames[nProperty] == PROPERTYNAME_SHOWINTRO )
254cdf0e10cSrcweir {
255cdf0e10cSrcweir DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtStartOptions_Impl::Notify()\nWho has changed the value type of \"Office.Common\\Start\\ShowIntro\"?" );
256cdf0e10cSrcweir seqValues[nProperty] >>= m_bShowIntro;
257cdf0e10cSrcweir }
258cdf0e10cSrcweir else
259cdf0e10cSrcweir if( seqPropertyNames[nProperty] == PROPERTYNAME_CONNECTIONURL )
260cdf0e10cSrcweir {
261cdf0e10cSrcweir DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_STRING), "SvtStartOptions_Impl::Notify()\nWho has changed the value type of \"Office.Common\\Start\\Connection\"?" );
262cdf0e10cSrcweir seqValues[nProperty] >>= m_sConnectionURL;
263cdf0e10cSrcweir }
264cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
265cdf0e10cSrcweir else DBG_ASSERT( sal_False, "SvtStartOptions_Impl::Notify()\nUnkown property detected ... I can't handle these!\n" );
266cdf0e10cSrcweir #endif
267cdf0e10cSrcweir }
268cdf0e10cSrcweir }
269cdf0e10cSrcweir
270cdf0e10cSrcweir //*****************************************************************************************************************
271cdf0e10cSrcweir // public method
272cdf0e10cSrcweir //*****************************************************************************************************************
Commit()273cdf0e10cSrcweir void SvtStartOptions_Impl::Commit()
274cdf0e10cSrcweir {
275cdf0e10cSrcweir // Get names of supported properties, create a list for values and copy current values to it.
276cdf0e10cSrcweir Sequence< OUString > seqNames = impl_GetPropertyNames();
277cdf0e10cSrcweir sal_Int32 nCount = seqNames.getLength();
278cdf0e10cSrcweir Sequence< Any > seqValues ( nCount );
279cdf0e10cSrcweir for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty )
280cdf0e10cSrcweir {
281cdf0e10cSrcweir switch( nProperty )
282cdf0e10cSrcweir {
283cdf0e10cSrcweir case PROPERTYHANDLE_SHOWINTRO : {
284cdf0e10cSrcweir seqValues[nProperty] <<= m_bShowIntro;
285cdf0e10cSrcweir }
286cdf0e10cSrcweir break;
287cdf0e10cSrcweir case PROPERTYHANDLE_CONNECTIONURL : {
288cdf0e10cSrcweir seqValues[nProperty] <<= m_sConnectionURL;
289cdf0e10cSrcweir }
290cdf0e10cSrcweir break;
291cdf0e10cSrcweir }
292cdf0e10cSrcweir }
293cdf0e10cSrcweir // Set properties in configuration.
294cdf0e10cSrcweir PutProperties( seqNames, seqValues );
295cdf0e10cSrcweir }
296cdf0e10cSrcweir
297cdf0e10cSrcweir //*****************************************************************************************************************
298cdf0e10cSrcweir // public method
299cdf0e10cSrcweir //*****************************************************************************************************************
IsIntroEnabled() const300cdf0e10cSrcweir sal_Bool SvtStartOptions_Impl::IsIntroEnabled() const
301cdf0e10cSrcweir {
302cdf0e10cSrcweir return m_bShowIntro;
303cdf0e10cSrcweir }
304cdf0e10cSrcweir
305cdf0e10cSrcweir //*****************************************************************************************************************
306cdf0e10cSrcweir // public method
307cdf0e10cSrcweir //*****************************************************************************************************************
EnableIntro(sal_Bool bState)308cdf0e10cSrcweir void SvtStartOptions_Impl::EnableIntro( sal_Bool bState )
309cdf0e10cSrcweir {
310cdf0e10cSrcweir m_bShowIntro = bState;
311cdf0e10cSrcweir SetModified();
312cdf0e10cSrcweir }
313cdf0e10cSrcweir
314cdf0e10cSrcweir //*****************************************************************************************************************
315cdf0e10cSrcweir // public method
316cdf0e10cSrcweir //*****************************************************************************************************************
GetConnectionURL() const317cdf0e10cSrcweir OUString SvtStartOptions_Impl::GetConnectionURL() const
318cdf0e10cSrcweir {
319cdf0e10cSrcweir return m_sConnectionURL;
320cdf0e10cSrcweir }
321cdf0e10cSrcweir
322cdf0e10cSrcweir //*****************************************************************************************************************
323cdf0e10cSrcweir // public method
324cdf0e10cSrcweir //*****************************************************************************************************************
SetConnectionURL(const OUString & sURL)325cdf0e10cSrcweir void SvtStartOptions_Impl::SetConnectionURL( const OUString& sURL )
326cdf0e10cSrcweir {
327cdf0e10cSrcweir m_sConnectionURL = sURL;
328cdf0e10cSrcweir SetModified();
329cdf0e10cSrcweir }
330cdf0e10cSrcweir
331cdf0e10cSrcweir //*****************************************************************************************************************
332cdf0e10cSrcweir // private method
333cdf0e10cSrcweir //*****************************************************************************************************************
impl_GetPropertyNames()334cdf0e10cSrcweir Sequence< OUString > SvtStartOptions_Impl::impl_GetPropertyNames()
335cdf0e10cSrcweir {
336cdf0e10cSrcweir // Build static list of configuration key names.
337cdf0e10cSrcweir static const OUString pProperties[] =
338cdf0e10cSrcweir {
339cdf0e10cSrcweir PROPERTYNAME_SHOWINTRO ,
340cdf0e10cSrcweir PROPERTYNAME_CONNECTIONURL ,
341cdf0e10cSrcweir };
342cdf0e10cSrcweir // Initialize return sequence with these list ...
343cdf0e10cSrcweir static const Sequence< OUString > seqPropertyNames( pProperties, PROPERTYCOUNT );
344cdf0e10cSrcweir // ... and return it.
345cdf0e10cSrcweir return seqPropertyNames;
346cdf0e10cSrcweir }
347cdf0e10cSrcweir
348cdf0e10cSrcweir //*****************************************************************************************************************
349cdf0e10cSrcweir // initialize static member
350cdf0e10cSrcweir // DON'T DO IT IN YOUR HEADER!
351cdf0e10cSrcweir // see definition for further informations
352cdf0e10cSrcweir //*****************************************************************************************************************
353cdf0e10cSrcweir SvtStartOptions_Impl* SvtStartOptions::m_pDataContainer = NULL ;
354cdf0e10cSrcweir sal_Int32 SvtStartOptions::m_nRefCount = 0 ;
355cdf0e10cSrcweir
356cdf0e10cSrcweir //*****************************************************************************************************************
357cdf0e10cSrcweir // constructor
358cdf0e10cSrcweir //*****************************************************************************************************************
SvtStartOptions()359cdf0e10cSrcweir SvtStartOptions::SvtStartOptions()
360cdf0e10cSrcweir {
361cdf0e10cSrcweir // Global access, must be guarded (multithreading!).
362cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() );
363b12a77c9Smseidel // Increase our refcount ...
364cdf0e10cSrcweir ++m_nRefCount;
365b12a77c9Smseidel // ... and initialize our data container only if it not already!
366cdf0e10cSrcweir if( m_pDataContainer == NULL )
367cdf0e10cSrcweir {
368cdf0e10cSrcweir RTL_LOGFILE_CONTEXT(aLog, "unotools ( ??? ) ::SvtStartOptions_Impl::ctor()");
369cdf0e10cSrcweir m_pDataContainer = new SvtStartOptions_Impl();
370cdf0e10cSrcweir
371cdf0e10cSrcweir ItemHolder1::holdConfigItem(E_STARTOPTIONS);
372cdf0e10cSrcweir }
373cdf0e10cSrcweir }
374cdf0e10cSrcweir
375cdf0e10cSrcweir //*****************************************************************************************************************
376cdf0e10cSrcweir // destructor
377cdf0e10cSrcweir //*****************************************************************************************************************
~SvtStartOptions()378cdf0e10cSrcweir SvtStartOptions::~SvtStartOptions()
379cdf0e10cSrcweir {
380cdf0e10cSrcweir // Global access, must be guarded (multithreading!)
381cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() );
382b12a77c9Smseidel // Decrease our refcount.
383cdf0e10cSrcweir --m_nRefCount;
384cdf0e10cSrcweir // If last instance was deleted ...
385b12a77c9Smseidel // we must destroy our static data container!
386cdf0e10cSrcweir if( m_nRefCount <= 0 )
387cdf0e10cSrcweir {
388cdf0e10cSrcweir delete m_pDataContainer;
389cdf0e10cSrcweir m_pDataContainer = NULL;
390cdf0e10cSrcweir }
391cdf0e10cSrcweir }
392cdf0e10cSrcweir
393cdf0e10cSrcweir //*****************************************************************************************************************
394cdf0e10cSrcweir // public method
395cdf0e10cSrcweir //*****************************************************************************************************************
IsIntroEnabled() const396cdf0e10cSrcweir sal_Bool SvtStartOptions::IsIntroEnabled() const
397cdf0e10cSrcweir {
398cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() );
399cdf0e10cSrcweir return m_pDataContainer->IsIntroEnabled();
400cdf0e10cSrcweir }
401cdf0e10cSrcweir
402cdf0e10cSrcweir //*****************************************************************************************************************
403cdf0e10cSrcweir // public method
404cdf0e10cSrcweir //*****************************************************************************************************************
EnableIntro(sal_Bool bState)405cdf0e10cSrcweir void SvtStartOptions::EnableIntro( sal_Bool bState )
406cdf0e10cSrcweir {
407cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() );
408cdf0e10cSrcweir m_pDataContainer->EnableIntro( bState );
409cdf0e10cSrcweir }
410cdf0e10cSrcweir
411cdf0e10cSrcweir //*****************************************************************************************************************
412cdf0e10cSrcweir // public method
413cdf0e10cSrcweir //*****************************************************************************************************************
GetConnectionURL() const414cdf0e10cSrcweir OUString SvtStartOptions::GetConnectionURL() const
415cdf0e10cSrcweir {
416cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() );
417cdf0e10cSrcweir return m_pDataContainer->GetConnectionURL();
418cdf0e10cSrcweir }
419cdf0e10cSrcweir
420cdf0e10cSrcweir //*****************************************************************************************************************
421cdf0e10cSrcweir // public method
422cdf0e10cSrcweir //*****************************************************************************************************************
SetConnectionURL(const OUString & sURL)423cdf0e10cSrcweir void SvtStartOptions::SetConnectionURL( const OUString& sURL )
424cdf0e10cSrcweir {
425cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() );
426cdf0e10cSrcweir m_pDataContainer->SetConnectionURL( sURL );
427cdf0e10cSrcweir }
428cdf0e10cSrcweir
429cdf0e10cSrcweir //*****************************************************************************************************************
430cdf0e10cSrcweir // private method
431cdf0e10cSrcweir //*****************************************************************************************************************
GetOwnStaticMutex()432cdf0e10cSrcweir Mutex& SvtStartOptions::GetOwnStaticMutex()
433cdf0e10cSrcweir {
434cdf0e10cSrcweir // Initialize static mutex only for one time!
435cdf0e10cSrcweir static Mutex* pMutex = NULL;
436cdf0e10cSrcweir // If these method first called (Mutex not already exist!) ...
437cdf0e10cSrcweir if( pMutex == NULL )
438cdf0e10cSrcweir {
439cdf0e10cSrcweir // ... we must create a new one. Protect follow code with the global mutex -
440cdf0e10cSrcweir // It must be - we create a static variable!
441cdf0e10cSrcweir MutexGuard aGuard( Mutex::getGlobalMutex() );
442b12a77c9Smseidel // We must check our pointer again - because it can be that another instance of our class will be faster than these!
443cdf0e10cSrcweir if( pMutex == NULL )
444cdf0e10cSrcweir {
445cdf0e10cSrcweir // Create the new mutex and set it for return on static variable.
446cdf0e10cSrcweir static Mutex aMutex;
447cdf0e10cSrcweir pMutex = &aMutex;
448cdf0e10cSrcweir }
449cdf0e10cSrcweir }
450cdf0e10cSrcweir // Return new created or already existing mutex object.
451cdf0e10cSrcweir return *pMutex;
452cdf0e10cSrcweir }
453013b951eSmseidel
454013b951eSmseidel /* vim: set noet sw=4 ts=4: */
455