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