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