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