xref: /AOO41X/main/svtools/source/config/helpopt.cxx (revision 5900e8ec128faec89519683efce668ccd8cc6084)
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_svtools.hxx"
26 
27 #include <svtools/helpopt.hxx>
28 #include <unotools/configmgr.hxx>
29 #include <unotools/configitem.hxx>
30 #include <tools/debug.hxx>
31 #include <com/sun/star/uno/Any.hxx>
32 #include <com/sun/star/uno/Sequence.hxx>
33 #include <vcl/help.hxx>
34 #include <osl/mutex.hxx>
35 #include <comphelper/stl_types.hxx>
36 
37 #include <rtl/logfile.hxx>
38 #include "itemholder2.hxx"
39 
40 using namespace utl;
41 using namespace rtl;
42 using namespace com::sun::star::uno;
43 using namespace com::sun::star;
44 
45 static SvtHelpOptions_Impl* pOptions = NULL;
46 static sal_Int32           nRefCount = 0;
47 
48 #define EXTENDEDHELP        0
49 #define HELPTIPS            1
50 #define AGENT_ENABLED       2
51 #define AGENT_TIMEOUT       3
52 #define AGENT_RETRYLIMIT    4
53 #define LOCALE              5
54 #define SYSTEM              6
55 #define STYLESHEET          7
56 
57 class SvtHelpOptions_Impl : public utl::ConfigItem
58 {
59     IdList*         pList;
60     sal_Int32       nHelpAgentTimeoutPeriod;
61     sal_Int32       nHelpAgentRetryLimit;
62     sal_Bool        bExtendedHelp;
63     sal_Bool        bHelpTips;
64     sal_Bool        bHelpAgentEnabled;
65     sal_Bool        bWelcomeScreen;
66     String          aLocale;
67     String          aSystem;
68     String          sHelpStyleSheet;
69 
70     DECLARE_STL_USTRINGACCESS_MAP( sal_Int32, MapString2Int );
71     MapString2Int   aURLIgnoreCounters;
72     ::osl::Mutex    aIgnoreCounterSafety;
73 
74     Sequence< OUString > GetPropertyNames();
75 
76 public:
77                     SvtHelpOptions_Impl();
78 
79     virtual void    Notify( const com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames );
80     void            Load( const ::com::sun::star::uno::Sequence< ::rtl::OUString>& aPropertyNames);
81     virtual void    Commit();
82 
SetExtendedHelp(sal_Bool b)83     void            SetExtendedHelp( sal_Bool b )           { bExtendedHelp= b; SetModified(); }
IsExtendedHelp() const84     sal_Bool        IsExtendedHelp() const                  { return bExtendedHelp; }
SetHelpTips(sal_Bool b)85     void            SetHelpTips( sal_Bool b )               { bHelpTips = b; SetModified(); }
IsHelpTips() const86     sal_Bool        IsHelpTips() const                      { return bHelpTips; }
87 
SetHelpAgentEnabled(sal_Bool b)88     void            SetHelpAgentEnabled( sal_Bool b )       { bHelpAgentEnabled = b; SetModified(); }
IsHelpAgentEnabled() const89     sal_Bool        IsHelpAgentEnabled() const              { return bHelpAgentEnabled; }
SetHelpAgentTimeoutPeriod(sal_Int32 _nSeconds)90     void            SetHelpAgentTimeoutPeriod( sal_Int32 _nSeconds )    { nHelpAgentTimeoutPeriod = _nSeconds; SetModified(); }
GetHelpAgentTimeoutPeriod() const91     sal_Int32       GetHelpAgentTimeoutPeriod( ) const      { return nHelpAgentTimeoutPeriod; }
SetHelpAgentRetryLimit(sal_Int32 _nTrials)92     void            SetHelpAgentRetryLimit( sal_Int32 _nTrials )        { nHelpAgentRetryLimit = _nTrials; SetModified(); }
GetHelpAgentRetryLimit() const93     sal_Int32       GetHelpAgentRetryLimit( ) const         { return nHelpAgentRetryLimit; }
94 
95     sal_Int32       getAgentIgnoreURLCounter( const ::rtl::OUString& _rURL );
96     void            decAgentIgnoreURLCounter( const ::rtl::OUString& _rURL );
97     void            resetAgentIgnoreURLCounter( const ::rtl::OUString& _rURL );
98     void            resetAgentIgnoreURLCounter();
99 
SetWelcomeScreen(sal_Bool b)100     void            SetWelcomeScreen( sal_Bool b )          { bWelcomeScreen = b; SetModified(); }
IsWelcomeScreen() const101     sal_Bool        IsWelcomeScreen() const                 { return bWelcomeScreen; }
GetPIStarterList()102     IdList*         GetPIStarterList()                      { return pList; }
103     void            AddToPIStarterList( sal_Int32 nId );
104     void            RemoveFromPIStarterList( sal_Int32 nId );
GetLocale() const105     String          GetLocale() const                       { return aLocale; }
GetSystem() const106     String          GetSystem() const                       { return aSystem; }
107 
GetHelpStyleSheet() const108     const String&   GetHelpStyleSheet()const{return sHelpStyleSheet;}
SetHelpStyleSheet(const String & rStyleSheet)109     void            SetHelpStyleSheet(const String& rStyleSheet){sHelpStyleSheet = rStyleSheet; SetModified();}
110 
111     static ::osl::Mutex & getInitMutex();
112 
113 protected:
114     void    implLoadURLCounters();
115     void    implSaveURLCounters();
116     // to be called with aIgnoreCounterSafety locked
117     void    implGetURLCounters( Sequence< ::rtl::OUString >& _rNodeNames, Sequence< Any >& _rURLs, Sequence< Any >& _rCounter );
118 };
119 
GetPropertyNames()120 Sequence< OUString > SvtHelpOptions_Impl::GetPropertyNames()
121 {
122     static const char* aPropNames[] =
123     {
124         "ExtendedTip",
125         "Tip",
126         "HelpAgent/Enabled",
127         "HelpAgent/Timeout",
128         "HelpAgent/RetryLimit",
129         "Locale",
130         "System",
131         "HelpStyleSheet",
132 //      "HowTo/Show"
133     };
134 
135     const int nCount = sizeof( aPropNames ) / sizeof( const char* );
136     Sequence< OUString > aNames( nCount );
137     OUString* pNames = aNames.getArray();
138     for ( int i = 0; i < nCount; i++ )
139         pNames[i] = OUString::createFromAscii( aPropNames[i] );
140 
141     return aNames;
142 }
143 
getInitMutex()144 ::osl::Mutex & SvtHelpOptions_Impl::getInitMutex()
145 {
146     static ::osl::Mutex *pMutex = 0;
147 
148     if( ! pMutex )
149     {
150         ::osl::MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
151         if( ! pMutex )
152         {
153             static ::osl::Mutex mutex;
154             pMutex = &mutex;
155         }
156     }
157     return *pMutex;
158 }
159 
160 
161 // -----------------------------------------------------------------------
162 
SvtHelpOptions_Impl()163 SvtHelpOptions_Impl::SvtHelpOptions_Impl()
164     : ConfigItem( OUString::createFromAscii("Office.Common/Help") )
165     , pList( 0 )
166     , bExtendedHelp( sal_False )
167     , bHelpTips( sal_True )
168     , bHelpAgentEnabled( sal_False )
169     , bWelcomeScreen( sal_False )
170 {
171     Sequence< OUString > aNames = GetPropertyNames();
172     Load( aNames );
173     EnableNotification( aNames );
174     implLoadURLCounters();
175 }
176 
177 // -----------------------------------------------------------------------
lcl_MapPropertyName(const::rtl::OUString rCompare,const uno::Sequence<::rtl::OUString> & aInternalPropertyNames)178 static int lcl_MapPropertyName( const ::rtl::OUString rCompare,
179                 const uno::Sequence< ::rtl::OUString>& aInternalPropertyNames)
180 {
181     for(int nProp = 0; nProp < aInternalPropertyNames.getLength(); ++nProp)
182     {
183         if( aInternalPropertyNames[nProp] == rCompare )
184             return nProp;
185     }
186     return -1;
187 }
188 
Load(const uno::Sequence<::rtl::OUString> & rPropertyNames)189 void  SvtHelpOptions_Impl::Load(const uno::Sequence< ::rtl::OUString>& rPropertyNames)
190 {
191     const uno::Sequence< ::rtl::OUString> aInternalPropertyNames( GetPropertyNames());
192     Sequence< Any > aValues = GetProperties( rPropertyNames );
193     const Any* pValues = aValues.getConstArray();
194     DBG_ASSERT( aValues.getLength() == rPropertyNames.getLength(), "GetProperties failed" );
195     if ( aValues.getLength() == rPropertyNames.getLength() )
196     {
197         for ( int nProp = 0; nProp < rPropertyNames.getLength(); nProp++ )
198         {
199             DBG_ASSERT( pValues[nProp].hasValue(), "property value missing" );
200             if ( pValues[nProp].hasValue() )
201             {
202                 sal_Bool bTmp = sal_Bool();
203                 ::rtl::OUString aTmpStr;
204                 sal_Int32 nTmpInt = 0;
205                 if ( pValues[nProp] >>= bTmp )
206                 {
207                     switch ( lcl_MapPropertyName(rPropertyNames[nProp], aInternalPropertyNames) )
208                     {
209                         case EXTENDEDHELP :
210                             bExtendedHelp = bTmp;
211                             break;
212                         case HELPTIPS :
213                             bHelpTips = bTmp;
214                             break;
215                         case AGENT_ENABLED :
216                             bHelpAgentEnabled = bTmp;
217                             break;
218                         default:
219                             DBG_ERRORFILE( "Wrong Member!" );
220                             break;
221                     }
222                 }
223                 else if ( pValues[nProp] >>= aTmpStr )
224                 {
225                     switch ( nProp )
226                     {
227                         case LOCALE:
228                             aLocale = aTmpStr;
229                             break;
230 
231                         case SYSTEM:
232                             aSystem = aTmpStr;
233                             break;
234                         case STYLESHEET :
235                             sHelpStyleSheet = aTmpStr;
236                         break;
237                         default:
238                             DBG_ERRORFILE( "Wrong Member!" );
239                             break;
240                     }
241                 }
242                 else if ( pValues[nProp] >>= nTmpInt )
243                 {
244                     switch ( nProp )
245                     {
246                         case AGENT_TIMEOUT:
247                             nHelpAgentTimeoutPeriod = nTmpInt;
248                             break;
249 
250                         case AGENT_RETRYLIMIT:
251                             nHelpAgentRetryLimit = nTmpInt;
252                             break;
253 
254                         default:
255                             DBG_ERRORFILE( "Wrong Member!" );
256                             break;
257                     }
258                 }
259                 else
260                 {
261             DBG_ERRORFILE( "Wrong Type!" );
262         }
263             }
264         }
265         if ( IsHelpTips() != Help::IsQuickHelpEnabled() )
266             IsHelpTips() ? Help::EnableQuickHelp() : Help::DisableQuickHelp();
267         if ( IsExtendedHelp() != Help::IsBalloonHelpEnabled() )
268             IsExtendedHelp() ? Help::EnableBalloonHelp() : Help::DisableBalloonHelp();
269     }
270 }
271 
272 // -----------------------------------------------------------------------
273 
implGetURLCounters(Sequence<::rtl::OUString> & _rNodeNames,Sequence<Any> & _rURLs,Sequence<Any> & _rCounters)274 void SvtHelpOptions_Impl::implGetURLCounters( Sequence< ::rtl::OUString >& _rNodeNames, Sequence< Any >& _rURLs, Sequence< Any >& _rCounters )
275 {
276     // the ignore counters for the help agent URLs
277     const ::rtl::OUString sIgnoreListNodePath = ::rtl::OUString::createFromAscii("HelpAgent/IgnoreList");
278     const ::rtl::OUString sPathSeparator = ::rtl::OUString::createFromAscii("/");
279     const ::rtl::OUString sURLLocalPath = ::rtl::OUString::createFromAscii("/Name");
280     const ::rtl::OUString sCounterLocalPath = ::rtl::OUString::createFromAscii("/Counter");
281 
282     // get the names of all the nodes containing ignore counters
283     // collect the node names we have to ask
284     // first get the node names of all children of HelpAgent/IgnoreList
285     _rNodeNames = GetNodeNames(sIgnoreListNodePath);
286     const ::rtl::OUString* pIgnoredURLsNodes = _rNodeNames.getConstArray();
287     const ::rtl::OUString* pIgnoredURLsNodesEnd = pIgnoredURLsNodes + _rNodeNames.getLength();
288 
289     // then assemble the two lists (of node paths) for the URLs and the counters
290     Sequence< ::rtl::OUString > aIgnoredURLs(_rNodeNames.getLength());
291     Sequence< ::rtl::OUString > aIgnoredURLsCounter(_rNodeNames.getLength());
292     ::rtl::OUString* pIgnoredURLs = aIgnoredURLs.getArray();
293     ::rtl::OUString* pIgnoredURLsCounter = aIgnoredURLsCounter.getArray();
294     for (;pIgnoredURLsNodes != pIgnoredURLsNodesEnd; ++pIgnoredURLsNodes, ++pIgnoredURLs, ++pIgnoredURLsCounter)
295     {
296         ::rtl::OUString sLocalURLAccess = sIgnoreListNodePath;
297         sLocalURLAccess += sPathSeparator;
298         sLocalURLAccess += *pIgnoredURLsNodes;
299 
300         // the path to the URL of this specific entry
301         *pIgnoredURLs = sLocalURLAccess;
302         *pIgnoredURLs += sURLLocalPath;
303 
304         // the path of the counter for that URL
305         *pIgnoredURLsCounter = sLocalURLAccess;
306         *pIgnoredURLsCounter += sCounterLocalPath;
307     }
308 
309     // now collect the values
310     _rURLs = GetProperties(aIgnoredURLs);
311     _rCounters = GetProperties(aIgnoredURLsCounter);
312 
313     sal_Int32 nURLs = _rURLs.getLength();
314     sal_Int32 nCounters = _rCounters.getLength();
315     DBG_ASSERT(nURLs == nCounters, "SvtHelpOptions_Impl::implGetURLCounters: inconsistence while retrieving the visited URLs!");
316 
317     // normalize in case something went wrong
318     sal_Int32 nKnownURLs = nURLs < nCounters ? nURLs : nCounters;
319     if (nURLs < nCounters)
320     {
321         _rCounters.realloc(nKnownURLs);
322         _rNodeNames.realloc(nKnownURLs);
323     }
324     else if (nURLs > nCounters)
325     {
326         _rURLs.realloc(nKnownURLs);
327         _rNodeNames.realloc(nKnownURLs);
328     }
329 }
330 
331 // -----------------------------------------------------------------------
332 
implSaveURLCounters()333 void SvtHelpOptions_Impl::implSaveURLCounters()
334 {
335     ::osl::MutexGuard aGuard(aIgnoreCounterSafety);
336 
337     const ::rtl::OUString sIgnoreListNodePath = ::rtl::OUString::createFromAscii("HelpAgent/IgnoreList");
338     const ::rtl::OUString sPathSeparator = ::rtl::OUString::createFromAscii("/");
339     const ::rtl::OUString sURLLocalPath = ::rtl::OUString::createFromAscii("/Name");
340     const ::rtl::OUString sCounterLocalPath = ::rtl::OUString::createFromAscii("/Counter");
341 
342     // get the current URL/counter pairs (as they're persistent at the moment)
343     Sequence< ::rtl::OUString > aNodeNames;
344     Sequence< Any >             aURLs;
345     Sequence< Any >             aCounters;
346 
347     implGetURLCounters(aNodeNames, aURLs, aCounters);
348     sal_Int32 nKnownURLs = aURLs.getLength();
349 
350     const ::rtl::OUString* pNodeNames   = aNodeNames.getConstArray();
351     const Any* pURLs                    = aURLs.getConstArray();
352     const Any* pCounters                = aCounters.getConstArray();
353 
354     // check which of them must be deleted/modified
355     Sequence< ::rtl::OUString >     aDeleteFromConfig(nKnownURLs);  // names of nodes to be deleted
356     ::rtl::OUString*                pDeleteFromConfig = aDeleteFromConfig.getArray();
357     ::std::set< ::rtl::OUString >   aAlreadyPresent;    // URLs currently persistent
358 
359     // for modifying already existent nodes
360     Sequence< ::rtl::OUString > aNewCounterNodePaths(nKnownURLs);
361     Sequence< Any >             aNewCounterValues(nKnownURLs);
362     ::rtl::OUString*            pNewCounterNodePaths = aNewCounterNodePaths.getArray();
363     Any*                        pNewCounterValues = aNewCounterValues.getArray();
364 
365     // temporaries needed inside the loop
366     ::rtl::OUString sCurrentURL, sCurrentURLNodeName;
367 
368     for (sal_Int32 i=0; i<nKnownURLs; ++i, ++pNodeNames, ++pURLs, ++pCounters)
369     {
370         if (!((*pURLs) >>= sCurrentURL))
371             continue;
372 
373         ConstMapString2IntIterator aThisURLNewCounter = aURLIgnoreCounters.find(sCurrentURL);
374         if (aURLIgnoreCounters.end() == aThisURLNewCounter)
375         {   // we do not know anything about this URL anymore.
376             // -> have to removed it from the configuration later on
377             *pDeleteFromConfig = *pNodeNames;
378             ++pDeleteFromConfig;
379         }
380         else
381         {   // we know this URL
382             sCurrentURLNodeName = sIgnoreListNodePath;
383             sCurrentURLNodeName += sPathSeparator;
384             sCurrentURLNodeName += *pNodeNames;
385 
386             // -> remember this (so we don't need to add a new node for this URL later on)
387             aAlreadyPresent.insert(sCurrentURL);
388 
389             sal_Int32 nThisURLPersistentCounter = 0;
390             (*pCounters) >>= nThisURLPersistentCounter;
391 
392             if (aThisURLNewCounter->second != nThisURLPersistentCounter)
393             {   // the counter changed
394                 // -> remember the path and the new counter for the adjustment below
395                 *pNewCounterNodePaths = sCurrentURLNodeName;
396                 *pNewCounterNodePaths += sCounterLocalPath;
397                 ++pNewCounterNodePaths;
398 
399                 (*pNewCounterValues) <<= aThisURLNewCounter->second;
400                 ++pNewCounterValues;
401             }
402         }
403     }
404 
405     // delete the nodes which are flagged so ...
406     aDeleteFromConfig.realloc(pDeleteFromConfig - aDeleteFromConfig.getArray());
407     if (0 != aDeleteFromConfig.getLength())
408     {
409         ClearNodeElements(sIgnoreListNodePath, aDeleteFromConfig);
410     }
411 
412     // modify the nodes which need to be
413     aNewCounterNodePaths.realloc(pNewCounterNodePaths - aNewCounterNodePaths.getArray());
414     aNewCounterValues.realloc(pNewCounterValues - aNewCounterValues.getArray());
415     if (0 != aNewCounterNodePaths.getLength())
416     {
417         PutProperties(aNewCounterNodePaths, aNewCounterValues);
418     }
419 
420     // and for the new ones ...
421     ::rtl::OUString sNewNodeName;
422     Sequence< ::rtl::OUString > aNewCounterDataNodeNames(2);
423     Sequence< Any >             aNewCounterDataValues(2);
424     const ::rtl::OUString sNodeNameBase = ::rtl::OUString::createFromAscii("URL");
425     for (   ConstMapString2IntIterator aCollectNew = aURLIgnoreCounters.begin();
426             aCollectNew != aURLIgnoreCounters.end();
427             ++aCollectNew
428         )
429     {
430         if (aAlreadyPresent.end() == aAlreadyPresent.find(aCollectNew->first))
431         {   // this URL is not persistent, yet
432             // -> add a new node
433             sNewNodeName = sNodeNameBase;
434             if (!getUniqueSetElementName(sIgnoreListNodePath, sNewNodeName))
435             {
436                 DBG_ERRORFILE( "SvtHelpOptions_Impl::implSaveURLCounters: could not get a free name!" );
437                 continue;
438             }
439             AddNode(sIgnoreListNodePath, sNewNodeName);
440 
441             // and set the URL/counter pair
442             aNewCounterDataNodeNames[0] = sIgnoreListNodePath;
443             aNewCounterDataNodeNames[0] += sPathSeparator;
444             aNewCounterDataNodeNames[0] += sNewNodeName;
445             aNewCounterDataNodeNames[0] += sURLLocalPath;
446             aNewCounterDataValues[0]    <<= aCollectNew->first;
447 
448             aNewCounterDataNodeNames[1] = sIgnoreListNodePath;
449             aNewCounterDataNodeNames[1] += sPathSeparator;
450             aNewCounterDataNodeNames[1] += sNewNodeName;
451             aNewCounterDataNodeNames[1] += sCounterLocalPath;
452             aNewCounterDataValues[1]    <<= aCollectNew->second;
453 
454             PutProperties(aNewCounterDataNodeNames, aNewCounterDataValues);
455         }
456     }
457 }
458 
459 // -----------------------------------------------------------------------
460 
implLoadURLCounters()461 void SvtHelpOptions_Impl::implLoadURLCounters()
462 {
463     ::osl::MutexGuard aGuard(aIgnoreCounterSafety);
464 
465     Sequence< ::rtl::OUString > aNodeNames;
466     Sequence< Any >             aURLs;
467     Sequence< Any >             aCounters;
468 
469     implGetURLCounters(aNodeNames, aURLs, aCounters);
470     sal_Int32 nKnownURLs = aURLs.getLength();
471 
472     const Any* pURLs = aURLs.getConstArray();
473     const Any* pCounters = aCounters.getConstArray();
474 
475     ::rtl::OUString sCurrentURL;
476     sal_Int32 nCurrentCounter;
477     for (sal_Int32 i=0; i<nKnownURLs; ++i, ++pURLs, ++pCounters)
478     {
479         (*pURLs) >>= sCurrentURL;
480         nCurrentCounter = 0;
481         (*pCounters) >>= nCurrentCounter;
482         aURLIgnoreCounters[sCurrentURL] = nCurrentCounter;
483     }
484 }
485 
486 // -----------------------------------------------------------------------
487 
Commit()488 void SvtHelpOptions_Impl::Commit()
489 {
490     Sequence< OUString > aNames = GetPropertyNames();
491     Sequence< Any > aValues( aNames.getLength() );
492     Any* pValues = aValues.getArray();
493     for ( int nProp = 0; nProp < aNames.getLength(); nProp++ )
494     {
495         switch ( nProp )
496         {
497             case EXTENDEDHELP :
498                 pValues[nProp] <<= bExtendedHelp;
499                 break;
500 
501             case HELPTIPS :
502                 pValues[nProp] <<= bHelpTips;
503                 break;
504 
505             case AGENT_ENABLED :
506                 pValues[nProp] <<= bHelpAgentEnabled;
507                 break;
508 
509             case AGENT_TIMEOUT:
510                 pValues[nProp] <<= nHelpAgentTimeoutPeriod;
511                 break;
512 
513             case AGENT_RETRYLIMIT:
514                 pValues[nProp] <<= nHelpAgentRetryLimit;
515                 break;
516 
517             case LOCALE:
518                 pValues[nProp] <<= ::rtl::OUString(aLocale);
519                 break;
520 
521             case SYSTEM:
522                 pValues[nProp] <<= ::rtl::OUString(aSystem);
523                 break;
524             case STYLESHEET :
525                 pValues[nProp] <<= ::rtl::OUString(sHelpStyleSheet);
526             break;
527 
528         }
529     }
530 
531     PutProperties( aNames, aValues );
532 
533     implSaveURLCounters();
534 }
535 
536 // -----------------------------------------------------------------------
537 
Notify(const Sequence<rtl::OUString> & aPropertyNames)538 void SvtHelpOptions_Impl::Notify( const Sequence<rtl::OUString>& aPropertyNames )
539 {
540     Load( aPropertyNames );
541 }
542 
SvtHelpOptions()543 SvtHelpOptions::SvtHelpOptions()
544 {
545     // Global access, must be guarded (multithreading)
546     ::osl::MutexGuard aGuard( SvtHelpOptions_Impl::getInitMutex() );
547     ++nRefCount;
548     if ( !pOptions )
549     {
550         RTL_LOGFILE_CONTEXT(aLog, "svtools ( ??? ) ::SvtHelpOptions_Impl::ctor()");
551         pOptions = new SvtHelpOptions_Impl;
552 
553         ItemHolder2::holdConfigItem(E_HELPOPTIONS);
554     }
555     pImp = pOptions;
556 }
557 
558 // -----------------------------------------------------------------------
559 
getAgentIgnoreURLCounter(const::rtl::OUString & _rURL)560 sal_Int32 SvtHelpOptions_Impl::getAgentIgnoreURLCounter( const ::rtl::OUString& _rURL )
561 {
562     ::osl::MutexGuard aGuard(aIgnoreCounterSafety);
563     ConstMapString2IntIterator aMapPos = aURLIgnoreCounters.find(_rURL);
564     if (aURLIgnoreCounters.end() == aMapPos)
565         return GetHelpAgentRetryLimit();
566     return aMapPos->second;
567 }
568 
569 // -----------------------------------------------------------------------
570 
decAgentIgnoreURLCounter(const::rtl::OUString & _rURL)571 void SvtHelpOptions_Impl::decAgentIgnoreURLCounter( const ::rtl::OUString& _rURL )
572 {
573     ::osl::MutexGuard aGuard(aIgnoreCounterSafety);
574     MapString2IntIterator aMapPos = aURLIgnoreCounters.find(_rURL);
575     if (aURLIgnoreCounters.end() == aMapPos)
576     {   // nothing known about this URL 'til now
577         sal_Int32 nLimit = GetHelpAgentRetryLimit();
578         sal_Int32 nIgnoreAgain = nLimit > 0 ? nLimit - 1 : 0;
579         aURLIgnoreCounters[_rURL] = nIgnoreAgain;
580     }
581     else
582     {
583         sal_Int32& rCounter = aMapPos->second;
584         if (rCounter)
585             --rCounter;
586     }
587     SetModified();
588 }
589 
590 // -----------------------------------------------------------------------
591 
resetAgentIgnoreURLCounter(const::rtl::OUString & _rURL)592 void SvtHelpOptions_Impl::resetAgentIgnoreURLCounter( const ::rtl::OUString& _rURL )
593 {
594     ::osl::MutexGuard aGuard(aIgnoreCounterSafety);
595     MapString2IntIterator aMapPos = aURLIgnoreCounters.find(_rURL);
596     if (aURLIgnoreCounters.end() != aMapPos)
597     {
598         aURLIgnoreCounters.erase(aMapPos);
599         SetModified();
600     }
601 }
602 
603 // -----------------------------------------------------------------------
604 
resetAgentIgnoreURLCounter()605 void SvtHelpOptions_Impl::resetAgentIgnoreURLCounter()
606 {
607     ::osl::MutexGuard aGuard(aIgnoreCounterSafety);
608     aURLIgnoreCounters.clear();
609     SetModified();
610 }
611 
612 // -----------------------------------------------------------------------
613 
~SvtHelpOptions()614 SvtHelpOptions::~SvtHelpOptions()
615 {
616     // Global access, must be guarded (multithreading)
617     ::osl::MutexGuard aGuard( SvtHelpOptions_Impl::getInitMutex() );
618     if ( !--nRefCount )
619     {
620         if ( pOptions->IsModified() )
621             pOptions->Commit();
622         DELETEZ( pOptions );
623     }
624 }
625 
SetExtendedHelp(sal_Bool b)626 void SvtHelpOptions::SetExtendedHelp( sal_Bool b )
627 {
628     pImp->SetExtendedHelp( b );
629 }
630 
IsExtendedHelp() const631 sal_Bool SvtHelpOptions::IsExtendedHelp() const
632 {
633     return pImp->IsExtendedHelp();
634 }
635 
SetHelpTips(sal_Bool b)636 void SvtHelpOptions::SetHelpTips( sal_Bool b )
637 {
638     pImp->SetHelpTips( b );
639 }
640 
IsHelpTips() const641 sal_Bool SvtHelpOptions::IsHelpTips() const
642 {
643     return pImp->IsHelpTips();
644 }
645 
646 // -----------------------------------------------------------------------
647 
SetHelpAgentRetryLimit(sal_Int32 _nTrials)648 void SvtHelpOptions::SetHelpAgentRetryLimit( sal_Int32 _nTrials )
649 {
650     pImp->SetHelpAgentRetryLimit( _nTrials );
651 }
652 
653 // -----------------------------------------------------------------------
654 
GetHelpAgentRetryLimit() const655 sal_Int32 SvtHelpOptions::GetHelpAgentRetryLimit( ) const
656 {
657     return pImp->GetHelpAgentRetryLimit( );
658 }
659 
660 // -----------------------------------------------------------------------
661 
SetHelpAgentTimeoutPeriod(sal_Int32 _nSeconds)662 void SvtHelpOptions::SetHelpAgentTimeoutPeriod( sal_Int32 _nSeconds )
663 {
664     pImp->SetHelpAgentTimeoutPeriod( _nSeconds );
665 }
666 
667 // -----------------------------------------------------------------------
668 
GetHelpAgentTimeoutPeriod() const669 sal_Int32 SvtHelpOptions::GetHelpAgentTimeoutPeriod( ) const
670 {
671     return pImp->GetHelpAgentTimeoutPeriod( );
672 }
673 
674 // -----------------------------------------------------------------------
675 
SetHelpAgentAutoStartMode(sal_Bool b)676 void SvtHelpOptions::SetHelpAgentAutoStartMode( sal_Bool b )
677 {
678     pImp->SetHelpAgentEnabled( b );
679 }
680 
681 // -----------------------------------------------------------------------
682 
IsHelpAgentAutoStartMode() const683 sal_Bool SvtHelpOptions::IsHelpAgentAutoStartMode() const
684 {
685     return pImp->IsHelpAgentEnabled();
686 }
687 
688 // -----------------------------------------------------------------------
689 
getAgentIgnoreURLCounter(const::rtl::OUString & _rURL)690 sal_Int32 SvtHelpOptions::getAgentIgnoreURLCounter( const ::rtl::OUString& _rURL )
691 {
692     return pImp->getAgentIgnoreURLCounter( _rURL );
693 }
694 
695 // -----------------------------------------------------------------------
696 
decAgentIgnoreURLCounter(const::rtl::OUString & _rURL)697 void SvtHelpOptions::decAgentIgnoreURLCounter( const ::rtl::OUString& _rURL )
698 {
699     pImp->decAgentIgnoreURLCounter( _rURL );
700 }
701 
702 // -----------------------------------------------------------------------
703 
resetAgentIgnoreURLCounter(const::rtl::OUString & _rURL)704 void SvtHelpOptions::resetAgentIgnoreURLCounter( const ::rtl::OUString& _rURL )
705 {
706     pImp->resetAgentIgnoreURLCounter( _rURL );
707 }
708 
709 // -----------------------------------------------------------------------
710 
resetAgentIgnoreURLCounter()711 void SvtHelpOptions::resetAgentIgnoreURLCounter()
712 {
713     pImp->resetAgentIgnoreURLCounter();
714 }
715 
716 // -----------------------------------------------------------------------
717 
SetWelcomeScreen(sal_Bool b)718 void SvtHelpOptions::SetWelcomeScreen( sal_Bool b )
719 {
720     pImp->SetWelcomeScreen( b );
721 }
722 
IsWelcomeScreen() const723 sal_Bool SvtHelpOptions::IsWelcomeScreen() const
724 {
725     return pImp->IsWelcomeScreen();
726 }
727 
GetPIStarterList()728 IdList* SvtHelpOptions::GetPIStarterList()
729 {
730     return pImp->GetPIStarterList();
731 }
732 
AddToPIStarterList(sal_Int32)733 void SvtHelpOptions::AddToPIStarterList( sal_Int32 )
734 {
735 }
736 
RemoveFromPIStarterList(sal_Int32)737 void SvtHelpOptions::RemoveFromPIStarterList( sal_Int32 )
738 {
739 }
740 
GetLocale() const741 String SvtHelpOptions::GetLocale() const
742 {
743     return pImp->GetLocale();
744 }
745 
GetSystem() const746 String SvtHelpOptions::GetSystem() const
747 {
748     return pImp->GetSystem();
749 }
750 
GetHelpStyleSheet() const751 const String&   SvtHelpOptions::GetHelpStyleSheet()const
752 {
753     return pImp->GetHelpStyleSheet();
754 }
755 
SetHelpStyleSheet(const String & rStyleSheet)756 void  SvtHelpOptions::SetHelpStyleSheet(const String& rStyleSheet)
757 {
758     pImp->SetHelpStyleSheet(rStyleSheet);
759 }
760 
761