Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #include <unotools/viewoptions.hxx>
21 : : #include <com/sun/star/uno/Any.hxx>
22 : :
23 : : #include <boost/unordered_map.hpp>
24 : : #include <com/sun/star/beans/PropertyValue.hpp>
25 : : #include <com/sun/star/container/XNameContainer.hpp>
26 : : #include <com/sun/star/container/XNameAccess.hpp>
27 : : #include <com/sun/star/beans/XPropertySet.hpp>
28 : : #include <rtl/ustrbuf.hxx>
29 : : #include <unotools/configpaths.hxx>
30 : : #include <comphelper/configurationhelper.hxx>
31 : : #include <comphelper/processfactory.hxx>
32 : :
33 : : #include <itemholder1.hxx>
34 : :
35 : : //_________________________________________________________________________________________________________________
36 : : // namespaces
37 : : //_________________________________________________________________________________________________________________
38 : :
39 : : namespace css = ::com::sun::star;
40 : :
41 : : #ifdef CONST_ASCII
42 : : #error "Who define CONST_ASCII before! I use it to create const ascii strings ..."
43 : : #else
44 : : #define CONST_ASCII(SASCIIVALUE) ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SASCIIVALUE))
45 : : #endif
46 : :
47 : : #define PACKAGE_VIEWS CONST_ASCII("org.openoffice.Office.Views")
48 : :
49 : : #define LIST_DIALOGS CONST_ASCII("Dialogs" )
50 : : #define LIST_TABDIALOGS CONST_ASCII("TabDialogs")
51 : : #define LIST_TABPAGES CONST_ASCII("TabPages" )
52 : : #define LIST_WINDOWS CONST_ASCII("Windows" )
53 : :
54 : : #define PROPERTY_WINDOWSTATE CONST_ASCII("WindowState")
55 : : #define PROPERTY_PAGEID CONST_ASCII("PageID" )
56 : : #define PROPERTY_VISIBLE CONST_ASCII("Visible" )
57 : : #define PROPERTY_USERDATA CONST_ASCII("UserData" )
58 : :
59 : : #define DEFAULT_WINDOWSTATE ::rtl::OUString()
60 : : #define DEFAULT_USERDATA css::uno::Sequence< css::beans::NamedValue >()
61 : : #define DEFAULT_PAGEID 0
62 : : #define DEFAULT_VISIBLE sal_False
63 : :
64 : : //#define DEBUG_VIEWOPTIONS
65 : :
66 : : #ifdef DEBUG_VIEWOPTIONS
67 : : #define _LOG_COUNTER_( _SVIEW_, _NREAD_, _NWRITE_ ) \
68 : : { \
69 : : FILE* pFile = fopen( "viewdbg.txt", "a" ); \
70 : : fprintf( pFile, "%s[%d, %d]\n", ::rtl::OUStringToOString(_SVIEW_, RTL_TEXTENCODING_UTF8).getStr(), _NREAD_, _NWRITE_ ); \
71 : : fclose( pFile ); \
72 : : }
73 : : #endif // DEBUG_VIEWOPTIONS
74 : :
75 : : #define SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION(SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION_PARAM_EXCEPTION) \
76 : : { \
77 : : ::rtl::OUStringBuffer sMsg(256); \
78 : : sMsg.appendAscii("Unexpected exception catched. Original message was:\n\"" ); \
79 : : sMsg.append (SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION_PARAM_EXCEPTION.Message); \
80 : : sMsg.appendAscii("\"" ); \
81 : : }
82 : :
83 : : //_________________________________________________________________________________________________________________
84 : : // initialization!
85 : : //_________________________________________________________________________________________________________________
86 : :
87 : : SvtViewOptionsBase_Impl* SvtViewOptions::m_pDataContainer_Dialogs = NULL ;
88 : : sal_Int32 SvtViewOptions::m_nRefCount_Dialogs = 0 ;
89 : : SvtViewOptionsBase_Impl* SvtViewOptions::m_pDataContainer_TabDialogs = NULL ;
90 : : sal_Int32 SvtViewOptions::m_nRefCount_TabDialogs = 0 ;
91 : : SvtViewOptionsBase_Impl* SvtViewOptions::m_pDataContainer_TabPages = NULL ;
92 : : sal_Int32 SvtViewOptions::m_nRefCount_TabPages = 0 ;
93 : : SvtViewOptionsBase_Impl* SvtViewOptions::m_pDataContainer_Windows = NULL ;
94 : : sal_Int32 SvtViewOptions::m_nRefCount_Windows = 0 ;
95 : :
96 : : //_________________________________________________________________________________________________________________
97 : : // private declarations!
98 : : //_________________________________________________________________________________________________________________
99 : :
100 : : /*-************************************************************************************************************//**
101 : : @descr declare one configuration item
102 : : These struct hold information about one view item. But not all member are used for all entries!
103 : : User must decide which information are usefull and which not. We are a container iztem only and doesnt
104 : : know anything about the context.
105 : : But; we support a feature:
106 : : decision between items with default values (should not realy exist in configuration!)
107 : : and items with real values - changed by user. So user can suppress saving of realy unused items
108 : : to disk - because; defaulted items could be restored on runtime without reading from disk!!!
109 : : And if only items with valid information was written to cfg - we mustn't read so much and save time.
110 : : So we start with an member m_bDefault=True and reset it to False after first set-call.
111 : : Deficiencies of these solution - we cant allow direct read/write access to our member. We must
112 : : support it by set/get-methods ...
113 : : *//*-*************************************************************************************************************/
114 : : class IMPL_TViewData
115 : : {
116 : : public:
117 : : //---------------------------------------------------------------------------------------------------------
118 : : // create "default" item
119 : : IMPL_TViewData()
120 : : {
121 : : m_sWindowState = DEFAULT_WINDOWSTATE ;
122 : : m_lUserData = DEFAULT_USERDATA ;
123 : : m_nPageID = DEFAULT_PAGEID ;
124 : : m_bVisible = DEFAULT_VISIBLE ;
125 : :
126 : : m_bDefault = sal_True ;
127 : : }
128 : :
129 : : //---------------------------------------------------------------------------------------------------------
130 : : // write access - with reseting of default state
131 : : void setWindowState( const ::rtl::OUString& sValue )
132 : : {
133 : : m_bDefault = (
134 : : ( m_bDefault == sal_True ) &&
135 : : ( sValue == DEFAULT_WINDOWSTATE )
136 : : );
137 : : m_sWindowState = sValue;
138 : : }
139 : :
140 : : //---------------------------------------------------------------------------------------------------------
141 : : void setUserData( const css::uno::Sequence< css::beans::NamedValue >& lValue )
142 : : {
143 : : m_bDefault = (
144 : : ( m_bDefault == sal_True ) &&
145 : : ( lValue == DEFAULT_USERDATA )
146 : : );
147 : : m_lUserData = lValue;
148 : : }
149 : :
150 : : //---------------------------------------------------------------------------------------------------------
151 : : void setPageID( sal_Int32 nValue )
152 : : {
153 : : m_bDefault = (
154 : : ( m_bDefault == sal_True ) &&
155 : : ( nValue == DEFAULT_PAGEID )
156 : : );
157 : : m_nPageID = nValue;
158 : : }
159 : :
160 : : //---------------------------------------------------------------------------------------------------------
161 : : void setVisible( sal_Bool bValue )
162 : : {
163 : : m_bDefault = (
164 : : ( m_bDefault == sal_True ) &&
165 : : ( bValue == DEFAULT_VISIBLE )
166 : : );
167 : : m_bVisible = bValue;
168 : : }
169 : :
170 : : //---------------------------------------------------------------------------------------------------------
171 : : // read access
172 : : ::rtl::OUString getWindowState() { return m_sWindowState; }
173 : : css::uno::Sequence< css::beans::NamedValue > getUserData () { return m_lUserData ; }
174 : : sal_Int32 getPageID () { return m_nPageID ; }
175 : : sal_Bool getVisible () { return m_bVisible ; }
176 : :
177 : : //---------------------------------------------------------------------------------------------------------
178 : : // special operation for easy access on user data
179 : : void setUserItem( const ::rtl::OUString& sName ,
180 : : const css::uno::Any& aValue )
181 : : {
182 : : // we change UserData in every case!
183 : : // a) we change already existing item
184 : : // or b) we add a new one
185 : : m_bDefault = sal_False;
186 : :
187 : : sal_Bool bExist = sal_False;
188 : : sal_Int32 nCount = m_lUserData.getLength();
189 : :
190 : : // change it, if it already exist ...
191 : : for( sal_Int32 nStep=0; nStep<nCount; ++nStep )
192 : : {
193 : : if( m_lUserData[nStep].Name == sName )
194 : : {
195 : : m_lUserData[nStep].Value = aValue ;
196 : : bExist = sal_True;
197 : : break;
198 : : }
199 : : }
200 : :
201 : : // ... or create new list item
202 : : if( bExist == sal_False )
203 : : {
204 : : m_lUserData.realloc( nCount+1 );
205 : : m_lUserData[nCount].Name = sName ;
206 : : m_lUserData[nCount].Value = aValue ;
207 : : }
208 : : }
209 : :
210 : : //---------------------------------------------------------------------------------------------------------
211 : : css::uno::Any getUserItem( const ::rtl::OUString& sName )
212 : : {
213 : : // default value - if item not exist!
214 : : css::uno::Any aValue;
215 : :
216 : : sal_Int32 nCount = m_lUserData.getLength();
217 : : for( sal_Int32 nStep=0; nStep<nCount; ++nStep )
218 : : {
219 : : if( m_lUserData[nStep].Name == sName )
220 : : {
221 : : aValue = m_lUserData[nStep].Value;
222 : : break;
223 : : }
224 : : }
225 : : return aValue;
226 : : }
227 : :
228 : : //---------------------------------------------------------------------------------------------------------
229 : : // check for default items
230 : : sal_Bool isDefault() { return m_bDefault; }
231 : :
232 : : private:
233 : : ::rtl::OUString m_sWindowState ;
234 : : css::uno::Sequence< css::beans::NamedValue > m_lUserData ;
235 : : sal_Int32 m_nPageID ;
236 : : sal_Bool m_bVisible ;
237 : :
238 : : sal_Bool m_bDefault ;
239 : : };
240 : :
241 : : struct IMPL_TStringHashCode
242 : : {
243 : : size_t operator()(const ::rtl::OUString& sString) const
244 : : {
245 : : return sString.hashCode();
246 : : }
247 : : };
248 : :
249 : : typedef ::boost::unordered_map< ::rtl::OUString ,
250 : : IMPL_TViewData ,
251 : : IMPL_TStringHashCode ,
252 : : ::std::equal_to< ::rtl::OUString > > IMPL_TViewHash;
253 : :
254 : : /*-************************************************************************************************************//**
255 : : @descr Implement base data container for view options elements.
256 : : Every item support ALL possible configuration informations.
257 : : But not every superclass should use them! Because some view types don't
258 : : have it realy.
259 : :
260 : : @attention We implement a write-througt-cache! We use it for reading - but write all changes directly to
261 : : configuration. (changes are made on internal cache too!). So it's easier to distinguish
262 : : between added/changed/removed elements without any complex mask or bool flag informations.
263 : : Caches from configuration and our own one are synchronized every time - if we do so.
264 : : *//*-*************************************************************************************************************/
265 : : class SvtViewOptionsBase_Impl
266 : : {
267 : : //-------------------------------------------------------------------------------------------------------------
268 : : public:
269 : : SvtViewOptionsBase_Impl ( const ::rtl::OUString& sList );
270 : : virtual ~SvtViewOptionsBase_Impl ( );
271 : : sal_Bool Exists ( const ::rtl::OUString& sName );
272 : : sal_Bool Delete ( const ::rtl::OUString& sName );
273 : : ::rtl::OUString GetWindowState ( const ::rtl::OUString& sName );
274 : : void SetWindowState ( const ::rtl::OUString& sName ,
275 : : const ::rtl::OUString& sState );
276 : : css::uno::Sequence< css::beans::NamedValue > GetUserData ( const ::rtl::OUString& sName );
277 : : void SetUserData ( const ::rtl::OUString& sName ,
278 : : const css::uno::Sequence< css::beans::NamedValue >& lData );
279 : : sal_Int32 GetPageID ( const ::rtl::OUString& sName );
280 : : void SetPageID ( const ::rtl::OUString& sName ,
281 : : sal_Int32 nID );
282 : : sal_Bool GetVisible ( const ::rtl::OUString& sName );
283 : : void SetVisible ( const ::rtl::OUString& sName ,
284 : : sal_Bool bVisible );
285 : : css::uno::Any GetUserItem ( const ::rtl::OUString& sName ,
286 : : const ::rtl::OUString& sItem );
287 : : void SetUserItem ( const ::rtl::OUString& sName ,
288 : : const ::rtl::OUString& sItem ,
289 : : const css::uno::Any& aValue );
290 : :
291 : : //-------------------------------------------------------------------------------------------------------------
292 : : private:
293 : : css::uno::Reference< css::uno::XInterface > impl_getSetNode( const ::rtl::OUString& sNode ,
294 : : sal_Bool bCreateIfMissing);
295 : :
296 : : //-------------------------------------------------------------------------------------------------------------
297 : : private:
298 : : ::rtl::OUString m_sListName;
299 : : css::uno::Reference< css::container::XNameAccess > m_xRoot;
300 : : css::uno::Reference< css::container::XNameAccess > m_xSet;
301 : :
302 : : #ifdef DEBUG_VIEWOPTIONS
303 : : sal_Int32 m_nReadCount ;
304 : : sal_Int32 m_nWriteCount ;
305 : : #endif
306 : : };
307 : :
308 : : /*-************************************************************************************************************//**
309 : : @descr Implement the base data container.
310 : : *//*-*************************************************************************************************************/
311 : :
312 : : /*-************************************************************************************************************//**
313 : : @short ctor
314 : : @descr We use it to open right configuration file and let configuration objects fill her caches.
315 : : Then we read all existing entries from right list and cached it inside our object too.
316 : : Normaly we should enable notifications for changes on these values too ... but these feature
317 : : isn't full implemented in the moment.
318 : :
319 : : @seealso baseclass ::utl::ConfigItem
320 : : @seealso method Notify()
321 : :
322 : : @param -
323 : : @return -
324 : : *//*-*************************************************************************************************************/
325 : 932 : SvtViewOptionsBase_Impl::SvtViewOptionsBase_Impl( const ::rtl::OUString& sList )
326 : 932 : : m_sListName ( sList ) // we must know, which view type we must support
327 : : #ifdef DEBUG_VIEWOPTIONS
328 : : , m_nReadCount ( 0 )
329 : : , m_nWriteCount( 0 )
330 : : #endif
331 : : {
332 : : try
333 : : {
334 : : m_xRoot = css::uno::Reference< css::container::XNameAccess >(
335 : : ::comphelper::ConfigurationHelper::openConfig(
336 : : ::comphelper::getProcessServiceFactory(),
337 : : PACKAGE_VIEWS,
338 : : ::comphelper::ConfigurationHelper::E_STANDARD),
339 [ + - ][ + - ]: 932 : css::uno::UNO_QUERY);
[ + - ][ + - ]
[ + - ]
340 [ + - ]: 932 : if (m_xRoot.is())
341 [ + - ][ + - ]: 932 : m_xRoot->getByName(sList) >>= m_xSet;
[ + - ]
342 : : }
343 [ # # # # ]: 0 : catch(const css::uno::Exception& ex)
344 : : {
345 : 0 : m_xRoot.clear();
346 : 0 : m_xSet.clear();
347 : :
348 [ # # # # : 0 : SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION(ex)
# # ]
349 : : }
350 : 932 : }
351 : :
352 : : /*-************************************************************************************************************//**
353 : : @short dtor
354 : : @descr clean up something
355 : :
356 : : @attention We implement a write through cache! So we mustn't do it realy. All changes was written to cfg directly.
357 : : Commit isn't neccessary then.
358 : :
359 : : @seealso baseclass ::utl::ConfigItem
360 : : @seealso method IsModified()
361 : : @seealso method SetModified()
362 : : @seealso method Commit()
363 : :
364 : : @param -
365 : : @return -
366 : : *//*-*************************************************************************************************************/
367 : 632 : SvtViewOptionsBase_Impl::~SvtViewOptionsBase_Impl()
368 : : {
369 : : // dont flush configuration changes here to m_xRoot.
370 : : // That must be done inside every SetXXX() method already !
371 : : // Here its to late - DisposedExceptions from used configuration access can occure otherwise.
372 : :
373 : 632 : m_xRoot.clear();
374 : 632 : m_xSet.clear();
375 : :
376 : : #ifdef DEBUG_VIEWOPTIONS
377 : : _LOG_COUNTER_( m_sListName, m_nReadCount, m_nWriteCount )
378 : : #endif // DEBUG_VIEWOPTIONS
379 [ - + ]: 1264 : }
380 : :
381 : : /*-************************************************************************************************************//**
382 : : @short checks for already existing entries
383 : : @descr If user don't know, if an entry already exist - he can get this information by calling this method.
384 : :
385 : : @seealso member m_aList
386 : :
387 : : @param "sName", name of entry to check exist state
388 : : @return true , if item exist
389 : : false, otherwise
390 : : *//*-*************************************************************************************************************/
391 : 53855 : sal_Bool SvtViewOptionsBase_Impl::Exists( const ::rtl::OUString& sName )
392 : : {
393 : 53855 : sal_Bool bExists = sal_False;
394 : :
395 : : try
396 : : {
397 [ + - ]: 53855 : if (m_xSet.is())
398 [ + - ][ + - ]: 53855 : bExists = m_xSet->hasByName(sName);
399 : : }
400 [ # # ]: 0 : catch(const css::uno::Exception& ex)
401 : : {
402 : 0 : bExists = sal_False;
403 [ # # # # : 0 : SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION(ex)
# # ]
404 : : }
405 : :
406 : 53855 : return bExists;
407 : : }
408 : :
409 : : /*-************************************************************************************************************//**
410 : : @short delete entry
411 : : @descr Use it to delete set entry by given name.
412 : :
413 : : @seealso member m_aList
414 : :
415 : : @param "sName", name of entry to delete it
416 : : @return true , if item not exist(!) or could be deleted (should be the same!)
417 : : false, otherwise
418 : : *//*-*************************************************************************************************************/
419 : 0 : sal_Bool SvtViewOptionsBase_Impl::Delete( const ::rtl::OUString& sName )
420 : : {
421 : : #ifdef DEBUG_VIEWOPTIONS
422 : : ++m_nWriteCount;
423 : : #endif
424 : :
425 : 0 : sal_Bool bDeleted = sal_False;
426 : : try
427 : : {
428 [ # # ]: 0 : css::uno::Reference< css::container::XNameContainer > xSet(m_xSet, css::uno::UNO_QUERY_THROW);
429 [ # # ][ # # ]: 0 : xSet->removeByName(sName);
430 : 0 : bDeleted = sal_True;
431 [ # # ]: 0 : ::comphelper::ConfigurationHelper::flush(m_xRoot);
432 : : }
433 : 0 : catch(const css::container::NoSuchElementException&)
434 : 0 : { bDeleted = sal_True; }
435 [ # # # ]: 0 : catch(const css::uno::Exception& ex)
436 : : {
437 : 0 : bDeleted = sal_False;
438 [ # # # # : 0 : SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION(ex)
# # ]
439 : : }
440 : :
441 : 0 : return bDeleted;
442 : : }
443 : :
444 : : /*-************************************************************************************************************//**
445 : : @short read/write access to cache view items and her properties
446 : : @descr Follow methods support read/write access to all cache view items.
447 : :
448 : : @seealso member m_sList
449 : :
450 : : @param -
451 : : @return -
452 : : *//*-*************************************************************************************************************/
453 : 53855 : ::rtl::OUString SvtViewOptionsBase_Impl::GetWindowState( const ::rtl::OUString& sName )
454 : : {
455 : : #ifdef DEBUG_VIEWOPTIONS
456 : : ++m_nReadCount;
457 : : #endif
458 : :
459 : 53855 : ::rtl::OUString sWindowState;
460 : : try
461 : : {
462 : : css::uno::Reference< css::beans::XPropertySet > xNode(
463 : : impl_getSetNode(sName, sal_False),
464 [ + - ][ + - ]: 53855 : css::uno::UNO_QUERY);
465 [ + + ]: 53855 : if (xNode.is())
466 [ + - ][ + - ]: 53855 : xNode->getPropertyValue(PROPERTY_WINDOWSTATE) >>= sWindowState;
[ + - ]
467 : : }
468 [ # # # # ]: 0 : catch(const css::uno::Exception& ex)
469 : : {
470 : 0 : sWindowState = ::rtl::OUString();
471 [ # # # # : 0 : SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION(ex)
# # ]
472 : : }
473 : :
474 : 53855 : return sWindowState;
475 : : }
476 : :
477 : : //*****************************************************************************************************************
478 : 767 : void SvtViewOptionsBase_Impl::SetWindowState( const ::rtl::OUString& sName ,
479 : : const ::rtl::OUString& sState )
480 : : {
481 : : #ifdef DEBUG_VIEWOPTIONS
482 : : ++m_nWriteCount;
483 : : #endif
484 : :
485 : : try
486 : : {
487 : : css::uno::Reference< css::beans::XPropertySet > xNode(
488 : : impl_getSetNode(sName, sal_True),
489 [ + - ][ + - ]: 767 : css::uno::UNO_QUERY_THROW);
490 [ + - ][ + - ]: 767 : xNode->setPropertyValue(PROPERTY_WINDOWSTATE, css::uno::makeAny(sState));
[ + - ][ + - ]
491 [ + - ]: 767 : ::comphelper::ConfigurationHelper::flush(m_xRoot);
492 : : }
493 [ # # ]: 0 : catch(const css::uno::Exception& ex)
494 : : {
495 [ # # # # : 0 : SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION(ex)
# # ]
496 : : }
497 : 767 : }
498 : :
499 : : //*****************************************************************************************************************
500 : 53855 : css::uno::Sequence< css::beans::NamedValue > SvtViewOptionsBase_Impl::GetUserData( const ::rtl::OUString& sName )
501 : : {
502 : : #ifdef DEBUG_VIEWOPTIONS
503 : : ++m_nReadCount;
504 : : #endif
505 : :
506 : : try
507 : : {
508 : : css::uno::Reference< css::container::XNameAccess > xNode(
509 : : impl_getSetNode(sName, sal_False),
510 [ + - ][ + - ]: 53855 : css::uno::UNO_QUERY); // no _THROW ! because we dont create missing items here. So we have to live with zero references .-)
511 : 53855 : css::uno::Reference< css::container::XNameAccess > xUserData;
512 [ + + ]: 53855 : if (xNode.is())
513 [ + - ][ + - ]: 2050 : xNode->getByName(PROPERTY_USERDATA) >>= xUserData;
[ + - ][ + - ]
514 [ + + ]: 53855 : if (xUserData.is())
515 : : {
516 [ + - ][ + - ]: 2050 : const css::uno::Sequence< ::rtl::OUString > lNames = xUserData->getElementNames();
517 : 2050 : const ::rtl::OUString* pNames = lNames.getConstArray();
518 : 2050 : sal_Int32 c = lNames.getLength();
519 : 2050 : sal_Int32 i = 0;
520 [ + - ]: 2050 : css::uno::Sequence< css::beans::NamedValue > lUserData(c);
521 : :
522 [ + + ]: 2565 : for (i=0; i<c; ++i)
523 : : {
524 [ + - ]: 515 : lUserData[i].Name = pNames[i];
525 [ + - ][ + - ]: 515 : lUserData[i].Value = xUserData->getByName(pNames[i]);
[ + - ]
526 : : }
527 : :
528 [ + - ][ + - ]: 53855 : return lUserData;
[ + - ]
529 [ + + ][ + + ]: 53855 : }
530 : : }
531 [ # # ]: 0 : catch(const css::uno::Exception& ex)
532 : : {
533 [ # # # # : 0 : SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION(ex)
# # ]
534 : : }
535 : :
536 : 53855 : return css::uno::Sequence< css::beans::NamedValue >();
537 : : }
538 : :
539 : : //*****************************************************************************************************************
540 : 767 : void SvtViewOptionsBase_Impl::SetUserData( const ::rtl::OUString& sName ,
541 : : const css::uno::Sequence< css::beans::NamedValue >& lData )
542 : : {
543 : : #ifdef DEBUG_VIEWOPTIONS
544 : : ++m_nWriteCount;
545 : : #endif
546 : :
547 : : try
548 : : {
549 : : css::uno::Reference< css::container::XNameAccess > xNode(
550 : : impl_getSetNode(sName, sal_True),
551 [ + - ][ + - ]: 767 : css::uno::UNO_QUERY_THROW);
552 : 767 : css::uno::Reference< css::container::XNameContainer > xUserData;
553 [ + - ][ + - ]: 767 : xNode->getByName(PROPERTY_USERDATA) >>= xUserData;
[ + - ][ + - ]
554 [ + - ]: 767 : if (xUserData.is())
555 : : {
556 : 767 : const css::beans::NamedValue* pData = lData.getConstArray();
557 : 767 : sal_Int32 c = lData.getLength();
558 : 767 : sal_Int32 i = 0;
559 [ + + ]: 1534 : for (i=0; i<c; ++i)
560 : : {
561 [ + - ][ + - ]: 767 : if (xUserData->hasByName(pData[i].Name))
[ + + ]
562 [ + - ][ + - ]: 687 : xUserData->replaceByName(pData[i].Name, pData[i].Value);
563 : : else
564 [ + - ][ + - ]: 80 : xUserData->insertByName(pData[i].Name, pData[i].Value);
565 : : }
566 : : }
567 [ + - ]: 767 : ::comphelper::ConfigurationHelper::flush(m_xRoot);
568 : : }
569 [ # # ]: 0 : catch(const css::uno::Exception& ex)
570 : : {
571 [ # # # # : 0 : SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION(ex)
# # ]
572 : : }
573 : 767 : }
574 : :
575 : : //*****************************************************************************************************************
576 : 6844 : css::uno::Any SvtViewOptionsBase_Impl::GetUserItem( const ::rtl::OUString& sName ,
577 : : const ::rtl::OUString& sItem )
578 : : {
579 : : #ifdef DEBUG_VIEWOPTIONS
580 : : ++m_nReadCount;
581 : : #endif
582 : :
583 : 6844 : css::uno::Any aItem;
584 : : try
585 : : {
586 : : css::uno::Reference< css::container::XNameAccess > xNode(
587 : : impl_getSetNode(sName, sal_False),
588 [ + - ][ + - ]: 6844 : css::uno::UNO_QUERY);
589 : 6844 : css::uno::Reference< css::container::XNameAccess > xUserData;
590 [ + + ]: 6844 : if (xNode.is())
591 [ + - ][ + - ]: 6448 : xNode->getByName(PROPERTY_USERDATA) >>= xUserData;
[ + - ][ + - ]
592 [ + + ]: 6844 : if (xUserData.is())
593 [ + - ][ + - ]: 6844 : aItem = xUserData->getByName(sItem);
594 : : }
595 [ # # ]: 0 : catch(const css::container::NoSuchElementException&)
596 : 0 : { aItem.clear(); }
597 [ # # # # : 0 : catch(const css::uno::Exception& ex)
# ]
598 : : {
599 : 0 : aItem.clear();
600 [ # # # # : 0 : SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION(ex)
# # ]
601 : : }
602 : :
603 : 6844 : return aItem;
604 : : }
605 : :
606 : : //*****************************************************************************************************************
607 : 6518 : void SvtViewOptionsBase_Impl::SetUserItem( const ::rtl::OUString& sName ,
608 : : const ::rtl::OUString& sItem ,
609 : : const css::uno::Any& aValue )
610 : : {
611 : : #ifdef DEBUG_VIEWOPTIONS
612 : : ++m_nWriteCount;
613 : : #endif
614 : :
615 : : try
616 : : {
617 : : css::uno::Reference< css::container::XNameAccess > xNode(
618 : : impl_getSetNode(sName, sal_True),
619 [ + - ][ + - ]: 6518 : css::uno::UNO_QUERY_THROW);
620 : 6518 : css::uno::Reference< css::container::XNameContainer > xUserData;
621 [ + - ][ + - ]: 6518 : xNode->getByName(PROPERTY_USERDATA) >>= xUserData;
[ + - ][ + - ]
622 [ + - ]: 6518 : if (xUserData.is())
623 : : {
624 [ + - ][ + - ]: 6518 : if (xUserData->hasByName(sItem))
[ + + ]
625 [ + - ][ + - ]: 6170 : xUserData->replaceByName(sItem, aValue);
626 : : else
627 [ + - ][ + - ]: 348 : xUserData->insertByName(sItem, aValue);
628 : : }
629 [ + - ]: 6518 : ::comphelper::ConfigurationHelper::flush(m_xRoot);
630 : : }
631 [ # # ]: 0 : catch(const css::uno::Exception& ex)
632 : : {
633 [ # # # # : 0 : SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION(ex)
# # ]
634 : : }
635 : 6518 : }
636 : :
637 : : //*****************************************************************************************************************
638 : 0 : sal_Int32 SvtViewOptionsBase_Impl::GetPageID( const ::rtl::OUString& sName )
639 : : {
640 : : #ifdef DEBUG_VIEWOPTIONS
641 : : ++m_nReadCount;
642 : : #endif
643 : :
644 : 0 : sal_Int32 nID = 0;
645 : : try
646 : : {
647 : : css::uno::Reference< css::beans::XPropertySet > xNode(
648 : : impl_getSetNode(sName, sal_False),
649 [ # # ][ # # ]: 0 : css::uno::UNO_QUERY);
650 [ # # ]: 0 : if (xNode.is())
651 [ # # ][ # # ]: 0 : xNode->getPropertyValue(PROPERTY_PAGEID) >>= nID;
[ # # ]
652 : : }
653 [ # # # # ]: 0 : catch(const css::uno::Exception& ex)
654 : : {
655 : 0 : nID = 0;
656 [ # # # # : 0 : SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION(ex)
# # ]
657 : : }
658 : :
659 : 0 : return nID;
660 : : }
661 : :
662 : : //*****************************************************************************************************************
663 : 0 : void SvtViewOptionsBase_Impl::SetPageID( const ::rtl::OUString& sName ,
664 : : sal_Int32 nID )
665 : : {
666 : : #ifdef DEBUG_VIEWOPTIONS
667 : : ++m_nWriteCount;
668 : : #endif
669 : :
670 : : try
671 : : {
672 : : css::uno::Reference< css::beans::XPropertySet > xNode(
673 : : impl_getSetNode(sName, sal_True),
674 [ # # ][ # # ]: 0 : css::uno::UNO_QUERY_THROW);
675 [ # # ][ # # ]: 0 : xNode->setPropertyValue(PROPERTY_PAGEID, css::uno::makeAny(nID));
[ # # ][ # # ]
676 [ # # ]: 0 : ::comphelper::ConfigurationHelper::flush(m_xRoot);
677 : : }
678 [ # # ]: 0 : catch(const css::uno::Exception& ex)
679 : : {
680 [ # # # # : 0 : SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION(ex)
# # ]
681 : : }
682 : 0 : }
683 : :
684 : : //*****************************************************************************************************************
685 : 2050 : sal_Bool SvtViewOptionsBase_Impl::GetVisible( const ::rtl::OUString& sName )
686 : : {
687 : : #ifdef DEBUG_VIEWOPTIONS
688 : : ++m_nReadCount;
689 : : #endif
690 : :
691 : 2050 : sal_Bool bVisible = sal_False;
692 : : try
693 : : {
694 : : css::uno::Reference< css::beans::XPropertySet > xNode(
695 : : impl_getSetNode(sName, sal_False),
696 [ + - ][ + - ]: 2050 : css::uno::UNO_QUERY);
697 [ + - ]: 2050 : if (xNode.is())
698 [ + - ][ + - ]: 2050 : xNode->getPropertyValue(PROPERTY_VISIBLE) >>= bVisible;
[ + - ]
699 : : }
700 [ # # # # ]: 0 : catch(const css::uno::Exception& ex)
701 : : {
702 : 0 : bVisible = sal_False;
703 [ # # # # : 0 : SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION(ex)
# # ]
704 : : }
705 : :
706 : 2050 : return bVisible;
707 : : }
708 : :
709 : : //*****************************************************************************************************************
710 : 0 : void SvtViewOptionsBase_Impl::SetVisible( const ::rtl::OUString& sName ,
711 : : sal_Bool bVisible )
712 : : {
713 : : #ifdef DEBUG_VIEWOPTIONS
714 : : ++m_nWriteCount;
715 : : #endif
716 : :
717 : : try
718 : : {
719 : : css::uno::Reference< css::beans::XPropertySet > xNode(
720 : : impl_getSetNode(sName, sal_True),
721 [ # # ][ # # ]: 0 : css::uno::UNO_QUERY_THROW);
722 [ # # ][ # # ]: 0 : xNode->setPropertyValue(PROPERTY_VISIBLE, css::uno::makeAny(bVisible));
[ # # ][ # # ]
723 [ # # ]: 0 : ::comphelper::ConfigurationHelper::flush(m_xRoot);
724 : : }
725 [ # # ]: 0 : catch(const css::uno::Exception& ex)
726 : : {
727 [ # # # # : 0 : SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION(ex)
# # ]
728 : : }
729 : 0 : }
730 : :
731 : : /*-************************************************************************************************************//**
732 : : @short create new set node with default values on disk
733 : : @descr To create a new UserData item - the super node of these property must already exist!
734 : : You can call this method to create these new entry with default values and change UserData then.
735 : :
736 : : @seealso method impl_writeDirectProp()
737 : :
738 : : @param "sNode", name of new entry
739 : : @return -
740 : : *//*-*************************************************************************************************************/
741 : 124656 : css::uno::Reference< css::uno::XInterface > SvtViewOptionsBase_Impl::impl_getSetNode( const ::rtl::OUString& sNode ,
742 : : sal_Bool bCreateIfMissing)
743 : : {
744 : 124656 : css::uno::Reference< css::uno::XInterface > xNode;
745 : :
746 : : try
747 : : {
748 [ + + ]: 124656 : if (bCreateIfMissing)
749 [ + - ][ + - ]: 8052 : xNode = ::comphelper::ConfigurationHelper::makeSureSetNodeExists(m_xRoot, m_sListName, sNode);
750 : : else
751 : : {
752 [ + - ][ + - ]: 116604 : if (m_xSet.is() && m_xSet->hasByName(sNode) )
[ + - ][ + + ]
[ + + ]
753 [ + - ][ + - ]: 12598 : m_xSet->getByName(sNode) >>= xNode;
[ + - ]
754 : : }
755 : : }
756 [ # # ]: 0 : catch(const css::container::NoSuchElementException&)
757 : 0 : { xNode.clear(); }
758 [ # # # # : 0 : catch(const css::uno::Exception& ex)
# ]
759 : : {
760 : 0 : xNode.clear();
761 [ # # # # : 0 : SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION(ex)
# # ]
762 : : }
763 : :
764 : 124656 : return xNode;
765 : : }
766 : :
767 : : //*****************************************************************************************************************
768 : : // constructor
769 : : //*****************************************************************************************************************
770 : 68916 : SvtViewOptions::SvtViewOptions( EViewType eType ,
771 : : const ::rtl::OUString& sViewName )
772 : : : m_eViewType ( eType )
773 : 68916 : , m_sViewName ( sViewName )
774 : : {
775 : : // Global access, must be guarded (multithreading!)
776 [ + - ][ + - ]: 68916 : ::osl::MutexGuard aGuard( GetOwnStaticMutex() );
777 : :
778 : : // Search for right dat container for this view type and initialize right data container or set right ref count!
779 [ + + + + : 68916 : switch( eType )
- ]
780 : : {
781 : : case E_DIALOG : {
782 : : // Increase ref count for dialog data container first.
783 : 233 : ++m_nRefCount_Dialogs;
784 : : // If these instance the first user of the dialog data container - create these impl static container!
785 [ - + ]: 233 : if( m_nRefCount_Dialogs == 1 )
786 : : {
787 : : //m_pDataContainer_Dialogs = new SvtViewDialogOptions_Impl( LIST_DIALOGS );
788 [ # # ][ # # ]: 0 : m_pDataContainer_Dialogs = new SvtViewOptionsBase_Impl( LIST_DIALOGS );
[ # # ]
789 [ # # ]: 0 : ItemHolder1::holdConfigItem(E_VIEWOPTIONS_DIALOG);
790 : : }
791 : : }
792 : 233 : break;
793 : : case E_TABDIALOG : {
794 : : // Increase ref count for tab-dialog data container first.
795 : 233 : ++m_nRefCount_TabDialogs;
796 : : // If these instance the first user of the tab-dialog data container - create these impl static container!
797 [ - + ]: 233 : if( m_nRefCount_TabDialogs == 1 )
798 : : {
799 [ # # ][ # # ]: 0 : m_pDataContainer_TabDialogs = new SvtViewOptionsBase_Impl( LIST_TABDIALOGS );
[ # # ]
800 [ # # ]: 0 : ItemHolder1::holdConfigItem(E_VIEWOPTIONS_TABDIALOG);
801 : : }
802 : : }
803 : 233 : break;
804 : : case E_TABPAGE : {
805 : : // Increase ref count for tab-page data container first.
806 : 233 : ++m_nRefCount_TabPages;
807 : : // If these instance the first user of the tab-page data container - create these impl static container!
808 [ - + ]: 233 : if( m_nRefCount_TabPages == 1 )
809 : : {
810 [ # # ][ # # ]: 0 : m_pDataContainer_TabPages = new SvtViewOptionsBase_Impl( LIST_TABPAGES );
[ # # ]
811 [ # # ]: 0 : ItemHolder1::holdConfigItem(E_VIEWOPTIONS_TABPAGE);
812 : : }
813 : : }
814 : 233 : break;
815 : : case E_WINDOW : {
816 : : // Increase ref count for window data container first.
817 : 68217 : ++m_nRefCount_Windows;
818 : : // If these instance the first user of the window data container - create these impl static container!
819 [ - + ]: 68217 : if( m_nRefCount_Windows == 1 )
820 : : {
821 [ # # ][ # # ]: 0 : m_pDataContainer_Windows = new SvtViewOptionsBase_Impl( LIST_WINDOWS );
[ # # ]
822 [ # # ]: 0 : ItemHolder1::holdConfigItem(E_VIEWOPTIONS_WINDOW);
823 : : }
824 : : }
825 : 68217 : break;
826 : : default : OSL_FAIL( "SvtViewOptions::SvtViewOptions()\nThese view type is unknown! All following calls at these instance will do nothing!\n" );
827 [ + - ]: 68916 : }
828 : 68916 : }
829 : :
830 : : //*****************************************************************************************************************
831 : : // destructor
832 : : //*****************************************************************************************************************
833 : 68916 : SvtViewOptions::~SvtViewOptions()
834 : : {
835 : : // Global access, must be guarded (multithreading!)
836 [ + - ][ + - ]: 68916 : ::osl::MutexGuard aGuard( GetOwnStaticMutex() );
837 : :
838 : : // Search for right dat container for this view type and deinitialize right data container or set right ref count!
839 [ + + + + : 68916 : switch( m_eViewType )
- ]
840 : : {
841 : : case E_DIALOG : {
842 : : // Decrease ref count for dialog data container first.
843 : 233 : --m_nRefCount_Dialogs;
844 : : // If these instance the last user of the dialog data container - delete these impl static container!
845 [ + + ]: 233 : if( m_nRefCount_Dialogs == 0 )
846 : : {
847 [ + - ][ + - ]: 158 : delete m_pDataContainer_Dialogs;
848 : 158 : m_pDataContainer_Dialogs = NULL;
849 : : }
850 : : }
851 : 233 : break;
852 : : case E_TABDIALOG : {
853 : : // Decrease ref count for tab-dialog data container first.
854 : 233 : --m_nRefCount_TabDialogs;
855 : : // If these instance the last user of the tab-dialog data container - delete these impl static container!
856 [ + + ]: 233 : if( m_nRefCount_TabDialogs == 0 )
857 : : {
858 [ + - ][ + - ]: 158 : delete m_pDataContainer_TabDialogs;
859 : 158 : m_pDataContainer_TabDialogs = NULL;
860 : : }
861 : : }
862 : 233 : break;
863 : : case E_TABPAGE : {
864 : : // Decrease ref count for tab-page data container first.
865 : 233 : --m_nRefCount_TabPages;
866 : : // If these instance the last user of the tab-page data container - delete these impl static container!
867 [ + + ]: 233 : if( m_nRefCount_TabPages == 0 )
868 : : {
869 [ + - ][ + - ]: 158 : delete m_pDataContainer_TabPages;
870 : 158 : m_pDataContainer_TabPages = NULL;
871 : : }
872 : : }
873 : 233 : break;
874 : : case E_WINDOW : {
875 : : // Decrease ref count for window data container first.
876 : 68217 : --m_nRefCount_Windows;
877 : : // If these instance the last user of the window data container - delete these impl static container!
878 [ + + ]: 68217 : if( m_nRefCount_Windows == 0 )
879 : : {
880 [ + - ][ + - ]: 158 : delete m_pDataContainer_Windows;
881 : 158 : m_pDataContainer_Windows = NULL;
882 : : }
883 : : }
884 : 68217 : break;
885 [ + - ]: 68916 : }
886 [ - + ]: 69848 : }
887 : :
888 : : //*****************************************************************************************************************
889 : : // public method
890 : : //*****************************************************************************************************************
891 : 53855 : sal_Bool SvtViewOptions::Exists() const
892 : : {
893 : : // Ready for multithreading
894 [ + - ][ + - ]: 53855 : ::osl::MutexGuard aGuard( GetOwnStaticMutex() );
895 : :
896 : 53855 : sal_Bool bExists = sal_False;
897 [ - - - + : 53855 : switch( m_eViewType )
- ]
898 : : {
899 : : case E_DIALOG : {
900 [ # # ]: 0 : bExists = m_pDataContainer_Dialogs->Exists( m_sViewName );
901 : : }
902 : 0 : break;
903 : : case E_TABDIALOG : {
904 [ # # ]: 0 : bExists = m_pDataContainer_TabDialogs->Exists( m_sViewName );
905 : : }
906 : 0 : break;
907 : : case E_TABPAGE : {
908 [ # # ]: 0 : bExists = m_pDataContainer_TabPages->Exists( m_sViewName );
909 : : }
910 : 0 : break;
911 : : case E_WINDOW : {
912 [ + - ]: 53855 : bExists = m_pDataContainer_Windows->Exists( m_sViewName );
913 : : }
914 : 53855 : break;
915 : : }
916 [ + - ]: 53855 : return bExists;
917 : : }
918 : :
919 : : //*****************************************************************************************************************
920 : : // public method
921 : : //*****************************************************************************************************************
922 : 0 : sal_Bool SvtViewOptions::Delete()
923 : : {
924 : : // Ready for multithreading
925 [ # # ][ # # ]: 0 : ::osl::MutexGuard aGuard( GetOwnStaticMutex() );
926 : :
927 : 0 : sal_Bool bState = sal_False;
928 [ # # # # : 0 : switch( m_eViewType )
# ]
929 : : {
930 : : case E_DIALOG : {
931 [ # # ]: 0 : bState = m_pDataContainer_Dialogs->Delete( m_sViewName );
932 : : }
933 : 0 : break;
934 : : case E_TABDIALOG : {
935 [ # # ]: 0 : bState = m_pDataContainer_TabDialogs->Delete( m_sViewName );
936 : : }
937 : 0 : break;
938 : : case E_TABPAGE : {
939 [ # # ]: 0 : bState = m_pDataContainer_TabPages->Delete( m_sViewName );
940 : : }
941 : 0 : break;
942 : : case E_WINDOW : {
943 [ # # ]: 0 : bState = m_pDataContainer_Windows->Delete( m_sViewName );
944 : : }
945 : 0 : break;
946 : : }
947 [ # # ]: 0 : return bState;
948 : : }
949 : :
950 : : //*****************************************************************************************************************
951 : : // public method
952 : : //*****************************************************************************************************************
953 : 53855 : ::rtl::OUString SvtViewOptions::GetWindowState() const
954 : : {
955 : : // Ready for multithreading
956 [ + - ][ + - ]: 53855 : ::osl::MutexGuard aGuard( GetOwnStaticMutex() );
957 : :
958 : 53855 : ::rtl::OUString sState;
959 [ - - - + : 53855 : switch( m_eViewType )
- ]
960 : : {
961 : : case E_DIALOG : {
962 [ # # ]: 0 : sState = m_pDataContainer_Dialogs->GetWindowState( m_sViewName );
963 : : }
964 : 0 : break;
965 : : case E_TABDIALOG : {
966 [ # # ]: 0 : sState = m_pDataContainer_TabDialogs->GetWindowState( m_sViewName );
967 : : }
968 : 0 : break;
969 : : case E_TABPAGE : {
970 [ # # ]: 0 : sState = m_pDataContainer_TabPages->GetWindowState( m_sViewName );
971 : : }
972 : 0 : break;
973 : : case E_WINDOW : {
974 [ + - ]: 53855 : sState = m_pDataContainer_Windows->GetWindowState( m_sViewName );
975 : : }
976 : 53855 : break;
977 : : }
978 [ + - ]: 53855 : return sState;
979 : : }
980 : :
981 : : //*****************************************************************************************************************
982 : : // public method
983 : : //*****************************************************************************************************************
984 : 767 : void SvtViewOptions::SetWindowState( const ::rtl::OUString& sState )
985 : : {
986 : : // Ready for multithreading
987 [ + - ][ + - ]: 767 : ::osl::MutexGuard aGuard( GetOwnStaticMutex() );
988 : :
989 [ - - - + : 767 : switch( m_eViewType )
- ]
990 : : {
991 : : case E_DIALOG : {
992 [ # # ]: 0 : m_pDataContainer_Dialogs->SetWindowState( m_sViewName, sState );
993 : : }
994 : 0 : break;
995 : : case E_TABDIALOG : {
996 [ # # ]: 0 : m_pDataContainer_TabDialogs->SetWindowState( m_sViewName, sState );
997 : : }
998 : 0 : break;
999 : : case E_TABPAGE : {
1000 [ # # ]: 0 : m_pDataContainer_TabPages->SetWindowState( m_sViewName, sState );
1001 : : }
1002 : 0 : break;
1003 : : case E_WINDOW : {
1004 [ + - ]: 767 : m_pDataContainer_Windows->SetWindowState( m_sViewName, sState );
1005 : : }
1006 : 767 : break;
1007 [ + - ]: 767 : }
1008 : 767 : }
1009 : :
1010 : : //*****************************************************************************************************************
1011 : : // public method
1012 : : //*****************************************************************************************************************
1013 : 0 : sal_Int32 SvtViewOptions::GetPageID() const
1014 : : {
1015 : : // Ready for multithreading
1016 [ # # ][ # # ]: 0 : ::osl::MutexGuard aGuard( GetOwnStaticMutex() );
1017 : :
1018 : : // Safe impossible cases.
1019 : : // These call isn't allowed for dialogs, tab-pages or windows!
1020 : : OSL_ENSURE( !(m_eViewType==E_DIALOG||m_eViewType==E_TABPAGE||m_eViewType==E_WINDOW), "SvtViewOptions::GetPageID()\nCall not allowed for Dialogs, TabPages or Windows! I do nothing!\n" );
1021 : :
1022 : 0 : sal_Int32 nID = 0;
1023 [ # # ]: 0 : if( m_eViewType == E_TABDIALOG )
1024 [ # # ]: 0 : nID = m_pDataContainer_TabDialogs->GetPageID( m_sViewName );
1025 [ # # ]: 0 : return nID;
1026 : : }
1027 : :
1028 : : //*****************************************************************************************************************
1029 : : // public method
1030 : : //*****************************************************************************************************************
1031 : 0 : void SvtViewOptions::SetPageID( sal_Int32 nID )
1032 : : {
1033 : : // Ready for multithreading
1034 [ # # ][ # # ]: 0 : ::osl::MutexGuard aGuard( GetOwnStaticMutex() );
1035 : :
1036 : : // Safe impossible cases.
1037 : : // These call isn't allowed for dialogs, tab-pages or windows!
1038 : : OSL_ENSURE( !(m_eViewType==E_DIALOG||m_eViewType==E_TABPAGE||m_eViewType==E_WINDOW), "SvtViewOptions::SetPageID()\nCall not allowed for Dialogs, TabPages or Windows! I do nothing!\n" );
1039 : :
1040 [ # # ]: 0 : if( m_eViewType == E_TABDIALOG )
1041 [ # # ][ # # ]: 0 : m_pDataContainer_TabDialogs->SetPageID( m_sViewName, nID );
1042 : 0 : }
1043 : :
1044 : : //*****************************************************************************************************************
1045 : : // public method
1046 : : //*****************************************************************************************************************
1047 : 2050 : sal_Bool SvtViewOptions::IsVisible() const
1048 : : {
1049 : : // Ready for multithreading
1050 [ + - ][ + - ]: 2050 : ::osl::MutexGuard aGuard( GetOwnStaticMutex() );
1051 : :
1052 : : // Safe impossible cases.
1053 : : // These call isn't allowed for dialogs, tab-dialogs or tab-pages!
1054 : : OSL_ENSURE( !(m_eViewType==E_DIALOG||m_eViewType==E_TABDIALOG||m_eViewType==E_TABPAGE), "SvtViewOptions::IsVisible()\nCall not allowed for Dialogs, TabDialogs or TabPages! I do nothing!\n" );
1055 : :
1056 : 2050 : sal_Bool bState = sal_False;
1057 [ + - ]: 2050 : if( m_eViewType == E_WINDOW )
1058 [ + - ]: 2050 : bState = m_pDataContainer_Windows->GetVisible( m_sViewName );
1059 : :
1060 [ + - ]: 2050 : return bState;
1061 : : }
1062 : :
1063 : : //*****************************************************************************************************************
1064 : : // public method
1065 : : //*****************************************************************************************************************
1066 : 0 : void SvtViewOptions::SetVisible( sal_Bool bState )
1067 : : {
1068 : : // Ready for multithreading
1069 [ # # ][ # # ]: 0 : ::osl::MutexGuard aGuard( GetOwnStaticMutex() );
1070 : :
1071 : : // Safe impossible cases.
1072 : : // These call isn't allowed for dialogs, tab-dialogs or tab-pages!
1073 : : OSL_ENSURE( !(m_eViewType==E_DIALOG||m_eViewType==E_TABDIALOG||m_eViewType==E_TABPAGE), "SvtViewOptions::SetVisible()\nCall not allowed for Dialogs, TabDialogs or TabPages! I do nothing!\n" );
1074 : :
1075 [ # # ]: 0 : if( m_eViewType == E_WINDOW )
1076 [ # # ][ # # ]: 0 : m_pDataContainer_Windows->SetVisible( m_sViewName, bState );
1077 : 0 : }
1078 : :
1079 : : //*****************************************************************************************************************
1080 : 53855 : css::uno::Sequence< css::beans::NamedValue > SvtViewOptions::GetUserData() const
1081 : : {
1082 : : // Ready for multithreading
1083 [ + - ][ + - ]: 53855 : ::osl::MutexGuard aGuard( GetOwnStaticMutex() );
1084 : :
1085 [ + - ]: 53855 : css::uno::Sequence< css::beans::NamedValue > lData;
1086 [ - - - + : 53855 : switch( m_eViewType )
- ]
1087 : : {
1088 : : case E_DIALOG : {
1089 [ # # ][ # # ]: 0 : lData = m_pDataContainer_Dialogs->GetUserData( m_sViewName );
[ # # ]
1090 : : }
1091 : 0 : break;
1092 : : case E_TABDIALOG : {
1093 [ # # ][ # # ]: 0 : lData = m_pDataContainer_TabDialogs->GetUserData( m_sViewName );
[ # # ]
1094 : : }
1095 : 0 : break;
1096 : : case E_TABPAGE : {
1097 [ # # ][ # # ]: 0 : lData = m_pDataContainer_TabPages->GetUserData( m_sViewName );
[ # # ]
1098 : : }
1099 : 0 : break;
1100 : : case E_WINDOW : {
1101 [ + - ][ + - ]: 53855 : lData = m_pDataContainer_Windows->GetUserData( m_sViewName );
[ + - ]
1102 : : }
1103 : 53855 : break;
1104 : : }
1105 [ + - ]: 53855 : return lData;
1106 : : }
1107 : :
1108 : : //*****************************************************************************************************************
1109 : 767 : void SvtViewOptions::SetUserData( const css::uno::Sequence< css::beans::NamedValue >& lData )
1110 : : {
1111 : : // Ready for multithreading
1112 [ + - ][ + - ]: 767 : ::osl::MutexGuard aGuard( GetOwnStaticMutex() );
1113 : :
1114 [ - - - + : 767 : switch( m_eViewType )
- ]
1115 : : {
1116 : : case E_DIALOG : {
1117 [ # # ]: 0 : m_pDataContainer_Dialogs->SetUserData( m_sViewName, lData );
1118 : : }
1119 : 0 : break;
1120 : : case E_TABDIALOG : {
1121 [ # # ]: 0 : m_pDataContainer_TabDialogs->SetUserData( m_sViewName, lData );
1122 : : }
1123 : 0 : break;
1124 : : case E_TABPAGE : {
1125 [ # # ]: 0 : m_pDataContainer_TabPages->SetUserData( m_sViewName, lData );
1126 : : }
1127 : 0 : break;
1128 : : case E_WINDOW : {
1129 [ + - ]: 767 : m_pDataContainer_Windows->SetUserData( m_sViewName, lData );
1130 : : }
1131 : 767 : break;
1132 [ + - ]: 767 : }
1133 : 767 : }
1134 : :
1135 : : //*****************************************************************************************************************
1136 : 6844 : css::uno::Any SvtViewOptions::GetUserItem( const ::rtl::OUString& sName ) const
1137 : : {
1138 : : // Ready for multithreading
1139 [ + - ][ + - ]: 6844 : ::osl::MutexGuard aGuard( GetOwnStaticMutex() );
1140 : :
1141 : 6844 : css::uno::Any aItem;
1142 [ - - - + : 6844 : switch( m_eViewType )
- ]
1143 : : {
1144 : : case E_DIALOG : {
1145 [ # # ]: 0 : aItem = m_pDataContainer_Dialogs->GetUserItem( m_sViewName, sName );
1146 : : }
1147 : 0 : break;
1148 : : case E_TABDIALOG : {
1149 [ # # ]: 0 : aItem = m_pDataContainer_TabDialogs->GetUserItem( m_sViewName, sName );
1150 : : }
1151 : 0 : break;
1152 : : case E_TABPAGE : {
1153 [ # # ]: 0 : aItem = m_pDataContainer_TabPages->GetUserItem( m_sViewName, sName );
1154 : : }
1155 : 0 : break;
1156 : : case E_WINDOW : {
1157 [ + - ]: 6844 : aItem = m_pDataContainer_Windows->GetUserItem( m_sViewName, sName );
1158 : : }
1159 : 6844 : break;
1160 : : }
1161 [ + - ]: 6844 : return aItem;
1162 : : }
1163 : :
1164 : : //*****************************************************************************************************************
1165 : 6518 : void SvtViewOptions::SetUserItem( const ::rtl::OUString& sName ,
1166 : : const css::uno::Any& aValue )
1167 : : {
1168 : : // Ready for multithreading
1169 [ + - ][ + - ]: 6518 : ::osl::MutexGuard aGuard( GetOwnStaticMutex() );
1170 : :
1171 [ - - - + : 6518 : switch( m_eViewType )
- ]
1172 : : {
1173 : : case E_DIALOG : {
1174 [ # # ]: 0 : m_pDataContainer_Dialogs->SetUserItem( m_sViewName, sName, aValue );
1175 : : }
1176 : 0 : break;
1177 : : case E_TABDIALOG : {
1178 [ # # ]: 0 : m_pDataContainer_TabDialogs->SetUserItem( m_sViewName, sName, aValue );
1179 : : }
1180 : 0 : break;
1181 : : case E_TABPAGE : {
1182 [ # # ]: 0 : m_pDataContainer_TabPages->SetUserItem( m_sViewName, sName, aValue );
1183 : : }
1184 : 0 : break;
1185 : : case E_WINDOW : {
1186 [ + - ]: 6518 : m_pDataContainer_Windows->SetUserItem( m_sViewName, sName, aValue );
1187 : : }
1188 : 6518 : break;
1189 [ + - ]: 6518 : }
1190 : 6518 : }
1191 : :
1192 : : namespace
1193 : : {
1194 : : class theViewOptionsMutex : public rtl::Static<osl::Mutex, theViewOptionsMutex>{};
1195 : : }
1196 : :
1197 : : //*****************************************************************************************************************
1198 : : // private method
1199 : : //*****************************************************************************************************************
1200 : 316734 : ::osl::Mutex& SvtViewOptions::GetOwnStaticMutex()
1201 : : {
1202 : 316734 : return theViewOptionsMutex::get();
1203 : : }
1204 : :
1205 : 233 : void SvtViewOptions::AcquireOptions()
1206 : : {
1207 [ + - ][ + - ]: 233 : ::osl::MutexGuard aGuard( GetOwnStaticMutex() );
1208 [ + - ]: 233 : if( ++m_nRefCount_Dialogs == 1 )
1209 : : {
1210 [ + - ][ + - ]: 233 : m_pDataContainer_Dialogs = new SvtViewOptionsBase_Impl( LIST_DIALOGS );
[ + - ]
1211 [ + - ]: 233 : ItemHolder1::holdConfigItem(E_VIEWOPTIONS_DIALOG);
1212 : : }
1213 [ + - ]: 233 : if( ++m_nRefCount_TabDialogs == 1 )
1214 : : {
1215 [ + - ][ + - ]: 233 : m_pDataContainer_TabDialogs = new SvtViewOptionsBase_Impl( LIST_TABDIALOGS );
[ + - ]
1216 [ + - ]: 233 : ItemHolder1::holdConfigItem(E_VIEWOPTIONS_TABDIALOG);
1217 : : }
1218 [ + - ]: 233 : if( ++m_nRefCount_TabPages == 1 )
1219 : : {
1220 [ + - ][ + - ]: 233 : m_pDataContainer_TabPages = new SvtViewOptionsBase_Impl( LIST_TABPAGES );
[ + - ]
1221 [ + - ]: 233 : ItemHolder1::holdConfigItem(E_VIEWOPTIONS_TABPAGE);
1222 : : }
1223 [ + - ]: 233 : if( ++m_nRefCount_Windows == 1 )
1224 : : {
1225 [ + - ][ + - ]: 233 : m_pDataContainer_Windows = new SvtViewOptionsBase_Impl( LIST_WINDOWS );
[ + - ]
1226 [ + - ]: 233 : ItemHolder1::holdConfigItem(E_VIEWOPTIONS_WINDOW);
1227 [ + - ]: 233 : }
1228 : 233 : }
1229 : :
1230 : 158 : void SvtViewOptions::ReleaseOptions()
1231 : : {
1232 [ + - ][ + - ]: 158 : ::osl::MutexGuard aGuard( GetOwnStaticMutex() );
1233 [ - + ]: 158 : if( --m_nRefCount_Dialogs == 0 )
1234 : : {
1235 [ # # ][ # # ]: 0 : delete m_pDataContainer_Dialogs;
1236 : 0 : m_pDataContainer_Dialogs = NULL;
1237 : : }
1238 [ - + ]: 158 : if( --m_nRefCount_TabDialogs == 0 )
1239 : : {
1240 [ # # ][ # # ]: 0 : delete m_pDataContainer_TabDialogs;
1241 : 0 : m_pDataContainer_TabDialogs = NULL;
1242 : : }
1243 [ - + ]: 158 : if( --m_nRefCount_TabPages == 0 )
1244 : : {
1245 [ # # ][ # # ]: 0 : delete m_pDataContainer_TabPages;
1246 : 0 : m_pDataContainer_TabPages = NULL;
1247 : : }
1248 [ - + ]: 158 : if( --m_nRefCount_Windows == 0 )
1249 : : {
1250 [ # # ][ # # ]: 0 : delete m_pDataContainer_Windows;
1251 : 0 : m_pDataContainer_Windows = NULL;
1252 [ + - ]: 158 : }
1253 : 158 : }
1254 : :
1255 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|