2010-10-14 08:27:31 +02:00
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2012-07-11 09:51:50 +01:00
/*
* This file is part of the LibreOffice project .
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License , v . 2.0 . If a copy of the MPL was not distributed with this
* file , You can obtain one at http : //mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice :
*
* Licensed to the Apache Software Foundation ( ASF ) under one or more
* contributor license agreements . See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership . The ASF licenses this file to you under the Apache
* License , Version 2.0 ( the " License " ) ; you may not use this file
* except in compliance with the License . You may obtain a copy of
* the License at http : //www.apache.org/licenses/LICENSE-2.0 .
*/
2006-09-17 13:31:06 +00:00
2009-10-06 07:38:24 +02:00
# include <unotools/viewoptions.hxx>
2000-11-10 08:32:42 +00:00
# include <com/sun/star/uno/Any.hxx>
# include <com/sun/star/beans/PropertyValue.hpp>
2005-09-30 09:14:22 +00:00
# include <com/sun/star/container/XNameContainer.hpp>
# include <com/sun/star/container/XNameAccess.hpp>
# include <com/sun/star/beans/XPropertySet.hpp>
2001-10-19 07:16:30 +00:00
# include <rtl/ustrbuf.hxx>
2014-11-14 22:52:35 +01:00
# include <osl/diagnose.h>
2012-04-09 13:43:22 +03:00
# include <unotools/configpaths.hxx>
2005-09-30 09:14:22 +00:00
# include <comphelper/configurationhelper.hxx>
2011-11-14 11:49:31 +01:00
# include <comphelper/processfactory.hxx>
2005-09-30 09:14:22 +00:00
2014-05-10 18:12:32 +02:00
# include "itemholder1.hxx"
2005-11-11 07:55:28 +00:00
2013-02-01 09:33:19 +01:00
# define PACKAGE_VIEWS "org.openoffice.Office.Views"
2001-10-12 12:26:23 +00:00
2013-02-01 09:33:19 +01:00
# define LIST_DIALOGS "Dialogs"
# define LIST_TABDIALOGS "TabDialogs"
# define LIST_TABPAGES "TabPages"
# define LIST_WINDOWS "Windows"
2001-10-12 12:26:23 +00:00
2013-02-01 09:33:19 +01:00
# define PROPERTY_WINDOWSTATE "WindowState"
# define PROPERTY_PAGEID "PageID"
# define PROPERTY_VISIBLE "Visible"
# define PROPERTY_USERDATA "UserData"
2001-10-12 12:26:23 +00:00
2001-10-31 11:53:53 +00:00
//#define DEBUG_VIEWOPTIONS
2001-10-19 07:16:30 +00:00
# ifdef DEBUG_VIEWOPTIONS
# define _LOG_COUNTER_( _SVIEW_, _NREAD_, _NWRITE_ ) \
{ \
FILE * pFile = fopen ( " viewdbg.txt " , " a " ) ; \
2013-04-07 12:06:47 +02:00
fprintf ( pFile , " %s[%d, %d] \n " , OUStringToOString ( _SVIEW_ , RTL_TEXTENCODING_UTF8 ) . getStr ( ) , _NREAD_ , _NWRITE_ ) ; \
2001-10-19 07:16:30 +00:00
fclose ( pFile ) ; \
}
# endif // DEBUG_VIEWOPTIONS
2000-11-10 08:32:42 +00:00
2005-11-04 14:45:35 +00:00
# define SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION(SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION_PARAM_EXCEPTION) \
{ \
2013-04-07 12:06:47 +02:00
OUStringBuffer sMsg ( 256 ) ; \
2005-11-04 14:45:35 +00:00
sMsg . appendAscii ( " Unexpected exception catched. Original message was: \n \" " ) ; \
sMsg . append ( SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION_PARAM_EXCEPTION . Message ) ; \
sMsg . appendAscii ( " \" " ) ; \
}
2000-11-10 11:23:27 +00:00
// initialization!
2014-02-25 22:46:10 +01:00
2014-04-07 13:47:22 +02:00
SvtViewOptionsBase_Impl * SvtViewOptions : : m_pDataContainer_Dialogs = NULL ;
sal_Int32 SvtViewOptions : : m_nRefCount_Dialogs = 0 ;
SvtViewOptionsBase_Impl * SvtViewOptions : : m_pDataContainer_TabDialogs = NULL ;
sal_Int32 SvtViewOptions : : m_nRefCount_TabDialogs = 0 ;
SvtViewOptionsBase_Impl * SvtViewOptions : : m_pDataContainer_TabPages = NULL ;
sal_Int32 SvtViewOptions : : m_nRefCount_TabPages = 0 ;
SvtViewOptionsBase_Impl * SvtViewOptions : : m_pDataContainer_Windows = NULL ;
sal_Int32 SvtViewOptions : : m_nRefCount_Windows = 0 ;
2000-11-10 08:32:42 +00:00
2014-02-25 22:46:10 +01:00
/*-************************************************************************************************************
2001-10-19 07:16:30 +00:00
@ descr Implement base data container for view options elements .
2013-04-15 04:49:39 +02:00
Every item support ALL possible configuration information .
2001-10-19 07:16:30 +00:00
But not every superclass should use them ! Because some view types don ' t
2013-12-20 11:25:37 +01:00
have it really .
2001-10-19 07:16:30 +00:00
@ attention We implement a write - througt - cache ! We use it for reading - but write all changes directly to
configuration . ( changes are made on internal cache too ! ) . So it ' s easier to distinguish
2013-04-15 04:49:39 +02:00
between added / changed / removed elements without any complex mask or bool flag information .
2001-10-19 07:16:30 +00:00
Caches from configuration and our own one are synchronized every time - if we do so .
2000-11-10 08:32:42 +00:00
*/ /*-*************************************************************************************************************/
2005-09-30 09:14:22 +00:00
class SvtViewOptionsBase_Impl
2000-11-10 08:32:42 +00:00
{
2014-02-22 21:20:15 +01:00
2000-11-10 08:32:42 +00:00
public :
2012-10-05 15:00:39 +02:00
enum State { STATE_NONE , STATE_FALSE , STATE_TRUE } ;
2015-05-25 15:28:47 +01:00
explicit SvtViewOptionsBase_Impl ( const OUString & rList ) ;
2001-10-12 12:26:23 +00:00
virtual ~ SvtViewOptionsBase_Impl ( ) ;
2014-02-19 12:30:34 +01:00
bool Exists ( const OUString & sName ) ;
bool Delete ( const OUString & sName ) ;
2013-04-07 12:06:47 +02:00
OUString GetWindowState ( const OUString & sName ) ;
void SetWindowState ( const OUString & sName ,
const OUString & sState ) ;
css : : uno : : Sequence < css : : beans : : NamedValue > GetUserData ( const OUString & sName ) ;
void SetUserData ( const OUString & sName ,
2001-10-12 12:26:23 +00:00
const css : : uno : : Sequence < css : : beans : : NamedValue > & lData ) ;
2013-04-07 12:06:47 +02:00
sal_Int32 GetPageID ( const OUString & sName ) ;
void SetPageID ( const OUString & sName ,
2001-10-12 12:26:23 +00:00
sal_Int32 nID ) ;
2013-04-07 12:06:47 +02:00
State GetVisible ( const OUString & sName ) ;
void SetVisible ( const OUString & sName ,
2014-02-19 12:30:34 +01:00
bool bVisible ) ;
2013-04-07 12:06:47 +02:00
css : : uno : : Any GetUserItem ( const OUString & sName ,
const OUString & sItem ) ;
void SetUserItem ( const OUString & sName ,
const OUString & sItem ,
2001-10-12 12:26:23 +00:00
const css : : uno : : Any & aValue ) ;
2000-11-10 13:55:55 +00:00
private :
2013-04-07 12:06:47 +02:00
css : : uno : : Reference < css : : uno : : XInterface > impl_getSetNode ( const OUString & sNode ,
2014-02-19 12:30:34 +01:00
bool bCreateIfMissing ) ;
2000-11-10 13:55:55 +00:00
2000-11-10 08:32:42 +00:00
private :
2013-04-07 12:06:47 +02:00
OUString m_sListName ;
2005-09-30 09:14:22 +00:00
css : : uno : : Reference < css : : container : : XNameAccess > m_xRoot ;
css : : uno : : Reference < css : : container : : XNameAccess > m_xSet ;
2001-10-19 07:16:30 +00:00
# ifdef DEBUG_VIEWOPTIONS
2014-04-06 18:58:39 +03:00
sal_Int32 m_nReadCount ;
sal_Int32 m_nWriteCount ;
2001-10-19 07:16:30 +00:00
# endif
2000-11-10 08:32:42 +00:00
} ;
2014-02-25 22:46:10 +01:00
/*-************************************************************************************************************
2001-10-12 12:26:23 +00:00
@ descr Implement the base data container .
2000-11-10 08:32:42 +00:00
*/ /*-*************************************************************************************************************/
2014-02-25 22:46:10 +01:00
/*-************************************************************************************************************
2001-10-19 07:16:30 +00:00
@ short ctor
@ descr We use it to open right configuration file and let configuration objects fill her caches .
Then we read all existing entries from right list and cached it inside our object too .
2014-09-10 22:35:39 +02:00
Normally we should enable notifications for changes on these values too . . . but these feature
2001-10-19 07:16:30 +00:00
isn ' t full implemented in the moment .
@ seealso baseclass : : utl : : ConfigItem
@ seealso method Notify ( )
2001-10-12 12:26:23 +00:00
*/ /*-*************************************************************************************************************/
2013-04-07 12:06:47 +02:00
SvtViewOptionsBase_Impl : : SvtViewOptionsBase_Impl ( const OUString & sList )
2005-09-30 09:14:22 +00:00
: m_sListName ( sList ) // we must know, which view type we must support
2001-10-19 07:16:30 +00:00
# ifdef DEBUG_VIEWOPTIONS
, m_nReadCount ( 0 )
, m_nWriteCount ( 0 )
# endif
2000-11-10 08:32:42 +00:00
{
2005-09-30 09:14:22 +00:00
try
{
m_xRoot = css : : uno : : Reference < css : : container : : XNameAccess > (
: : comphelper : : ConfigurationHelper : : openConfig (
2012-10-16 14:05:41 +02:00
: : comphelper : : getProcessComponentContext ( ) ,
2005-09-30 09:14:22 +00:00
PACKAGE_VIEWS ,
: : comphelper : : ConfigurationHelper : : E_STANDARD ) ,
css : : uno : : UNO_QUERY ) ;
if ( m_xRoot . is ( ) )
m_xRoot - > getByName ( sList ) > > = m_xSet ;
}
2005-11-04 14:45:35 +00:00
catch ( const css : : uno : : Exception & ex )
2005-09-30 09:14:22 +00:00
{
m_xRoot . clear ( ) ;
m_xSet . clear ( ) ;
2005-11-04 14:45:35 +00:00
SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION ( ex )
2005-09-30 09:14:22 +00:00
}
2000-11-10 08:32:42 +00:00
}
2014-02-25 22:46:10 +01:00
/*-************************************************************************************************************
2001-10-19 07:16:30 +00:00
@ short dtor
2008-12-09 11:54:53 +00:00
@ descr clean up something
2001-10-12 12:26:23 +00:00
2013-12-20 11:25:37 +01:00
@ attention We implement a write through cache ! So we mustn ' t do it really . All changes was written to cfg directly .
Commit isn ' t necessary then .
2001-10-12 12:26:23 +00:00
2001-10-19 07:16:30 +00:00
@ seealso baseclass : : utl : : ConfigItem
@ seealso method IsModified ( )
@ seealso method SetModified ( )
@ seealso method Commit ( )
2001-10-12 12:26:23 +00:00
*/ /*-*************************************************************************************************************/
SvtViewOptionsBase_Impl : : ~ SvtViewOptionsBase_Impl ( )
2000-11-10 08:32:42 +00:00
{
2008-12-09 11:54:53 +00:00
// dont flush configuration changes here to m_xRoot.
// That must be done inside every SetXXX() method already !
2013-09-26 11:44:54 +02:00
// Here its to late - DisposedExceptions from used configuration access can occur otherwise.
2008-12-09 11:54:53 +00:00
2005-09-30 09:14:22 +00:00
m_xRoot . clear ( ) ;
m_xSet . clear ( ) ;
2001-10-19 07:16:30 +00:00
2005-09-30 09:14:22 +00:00
# ifdef DEBUG_VIEWOPTIONS
_LOG_COUNTER_ ( m_sListName , m_nReadCount , m_nWriteCount )
# endif // DEBUG_VIEWOPTIONS
2000-11-10 08:32:42 +00:00
}
2014-02-25 22:46:10 +01:00
/*-************************************************************************************************************
2001-10-19 07:16:30 +00:00
@ short checks for already existing entries
@ descr If user don ' t know , if an entry already exist - he can get this information by calling this method .
@ seealso member m_aList
2001-10-12 12:26:23 +00:00
2001-10-19 07:16:30 +00:00
@ param " sName " , name of entry to check exist state
@ return true , if item exist
false , otherwise
2001-10-12 12:26:23 +00:00
*/ /*-*************************************************************************************************************/
2014-02-19 12:30:34 +01:00
bool SvtViewOptionsBase_Impl : : Exists ( const OUString & sName )
2000-11-10 10:42:50 +00:00
{
2014-02-19 12:30:34 +01:00
bool bExists = false ;
2005-09-30 09:14:22 +00:00
try
{
if ( m_xSet . is ( ) )
bExists = m_xSet - > hasByName ( sName ) ;
}
2005-11-04 14:45:35 +00:00
catch ( const css : : uno : : Exception & ex )
{
2014-02-19 12:30:34 +01:00
bExists = false ;
2005-11-04 14:45:35 +00:00
SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION ( ex )
}
2005-09-30 09:14:22 +00:00
return bExists ;
2000-11-10 10:42:50 +00:00
}
2014-02-25 22:46:10 +01:00
/*-************************************************************************************************************
2001-10-19 07:16:30 +00:00
@ short delete entry
@ descr Use it to delete set entry by given name .
2001-10-12 12:26:23 +00:00
2001-10-19 07:16:30 +00:00
@ seealso member m_aList
2001-10-12 12:26:23 +00:00
2001-10-19 07:16:30 +00:00
@ param " sName " , name of entry to delete it
@ return true , if item not exist ( ! ) or could be deleted ( should be the same ! )
false , otherwise
2001-10-12 12:26:23 +00:00
*/ /*-*************************************************************************************************************/
2014-02-19 12:30:34 +01:00
bool SvtViewOptionsBase_Impl : : Delete ( const OUString & sName )
2000-11-10 10:42:50 +00:00
{
2001-10-19 07:16:30 +00:00
# ifdef DEBUG_VIEWOPTIONS
+ + m_nWriteCount ;
# endif
2000-12-04 11:07:08 +00:00
2014-02-19 12:30:34 +01:00
bool bDeleted = false ;
2005-09-30 09:14:22 +00:00
try
2000-11-10 10:42:50 +00:00
{
2005-11-04 14:45:35 +00:00
css : : uno : : Reference < css : : container : : XNameContainer > xSet ( m_xSet , css : : uno : : UNO_QUERY_THROW ) ;
xSet - > removeByName ( sName ) ;
2014-02-19 12:30:34 +01:00
bDeleted = true ;
2005-12-14 15:01:18 +00:00
: : comphelper : : ConfigurationHelper : : flush ( m_xRoot ) ;
2000-11-10 10:42:50 +00:00
}
2005-09-30 09:14:22 +00:00
catch ( const css : : container : : NoSuchElementException & )
2014-02-19 12:30:34 +01:00
{ bDeleted = true ; }
2005-11-04 14:45:35 +00:00
catch ( const css : : uno : : Exception & ex )
{
2014-02-19 12:30:34 +01:00
bDeleted = false ;
2005-11-04 14:45:35 +00:00
SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION ( ex )
}
2005-09-30 09:14:22 +00:00
return bDeleted ;
2000-11-10 10:42:50 +00:00
}
2014-02-25 22:46:10 +01:00
/*-************************************************************************************************************
2001-10-19 07:16:30 +00:00
@ short read / write access to cache view items and her properties
@ descr Follow methods support read / write access to all cache view items .
@ seealso member m_sList
2001-10-12 12:26:23 +00:00
*/ /*-*************************************************************************************************************/
2013-04-07 12:06:47 +02:00
OUString SvtViewOptionsBase_Impl : : GetWindowState ( const OUString & sName )
2000-11-10 08:32:42 +00:00
{
2001-10-19 07:16:30 +00:00
# ifdef DEBUG_VIEWOPTIONS
+ + m_nReadCount ;
# endif
2001-10-12 12:26:23 +00:00
2013-04-07 12:06:47 +02:00
OUString sWindowState ;
2005-09-30 09:14:22 +00:00
try
{
2005-11-04 14:45:35 +00:00
css : : uno : : Reference < css : : beans : : XPropertySet > xNode (
2014-02-19 12:30:34 +01:00
impl_getSetNode ( sName , false ) ,
2005-09-30 09:14:22 +00:00
css : : uno : : UNO_QUERY ) ;
if ( xNode . is ( ) )
2005-11-04 14:45:35 +00:00
xNode - > getPropertyValue ( PROPERTY_WINDOWSTATE ) > > = sWindowState ;
2005-09-30 09:14:22 +00:00
}
2005-11-04 14:45:35 +00:00
catch ( const css : : uno : : Exception & ex )
{
2014-11-12 14:24:10 +05:30
sWindowState . clear ( ) ;
2005-11-04 14:45:35 +00:00
SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION ( ex )
}
2005-09-30 09:14:22 +00:00
return sWindowState ;
2001-10-19 07:16:30 +00:00
}
2001-10-12 12:26:23 +00:00
2013-04-07 12:06:47 +02:00
void SvtViewOptionsBase_Impl : : SetWindowState ( const OUString & sName ,
const OUString & sState )
2000-11-10 08:32:42 +00:00
{
2001-10-19 07:16:30 +00:00
# ifdef DEBUG_VIEWOPTIONS
+ + m_nWriteCount ;
# endif
2001-10-12 12:26:23 +00:00
2005-09-30 09:14:22 +00:00
try
2001-10-19 07:16:30 +00:00
{
2005-11-04 14:45:35 +00:00
css : : uno : : Reference < css : : beans : : XPropertySet > xNode (
2014-02-19 12:30:34 +01:00
impl_getSetNode ( sName , true ) ,
2005-11-04 14:45:35 +00:00
css : : uno : : UNO_QUERY_THROW ) ;
xNode - > setPropertyValue ( PROPERTY_WINDOWSTATE , css : : uno : : makeAny ( sState ) ) ;
2005-12-14 15:01:18 +00:00
: : comphelper : : ConfigurationHelper : : flush ( m_xRoot ) ;
2001-10-19 07:16:30 +00:00
}
2005-11-04 14:45:35 +00:00
catch ( const css : : uno : : Exception & ex )
{
SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION ( ex )
}
2001-10-19 07:16:30 +00:00
}
2001-10-12 12:26:23 +00:00
2013-04-07 12:06:47 +02:00
css : : uno : : Sequence < css : : beans : : NamedValue > SvtViewOptionsBase_Impl : : GetUserData ( const OUString & sName )
2000-11-10 08:32:42 +00:00
{
2001-10-19 07:16:30 +00:00
# ifdef DEBUG_VIEWOPTIONS
+ + m_nReadCount ;
# endif
2001-10-12 12:26:23 +00:00
2005-09-30 09:14:22 +00:00
try
{
css : : uno : : Reference < css : : container : : XNameAccess > xNode (
2014-02-19 12:30:34 +01:00
impl_getSetNode ( sName , false ) ,
2005-11-04 14:45:35 +00:00
css : : uno : : UNO_QUERY ) ; // no _THROW ! because we dont create missing items here. So we have to live with zero references .-)
2005-09-30 09:14:22 +00:00
css : : uno : : Reference < css : : container : : XNameAccess > xUserData ;
if ( xNode . is ( ) )
xNode - > getByName ( PROPERTY_USERDATA ) > > = xUserData ;
if ( xUserData . is ( ) )
{
2014-11-22 15:52:19 +01:00
const css : : uno : : Sequence < OUString > lNames = xUserData - > getElementNames ( ) ;
const OUString * pNames = lNames . getConstArray ( ) ;
sal_Int32 c = lNames . getLength ( ) ;
sal_Int32 i = 0 ;
css : : uno : : Sequence < css : : beans : : NamedValue > lUserData ( c ) ;
2005-09-30 09:14:22 +00:00
for ( i = 0 ; i < c ; + + i )
{
lUserData [ i ] . Name = pNames [ i ] ;
lUserData [ i ] . Value = xUserData - > getByName ( pNames [ i ] ) ;
}
return lUserData ;
}
}
2005-11-04 14:45:35 +00:00
catch ( const css : : uno : : Exception & ex )
{
SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION ( ex )
}
2005-09-30 09:14:22 +00:00
return css : : uno : : Sequence < css : : beans : : NamedValue > ( ) ;
2001-10-19 07:16:30 +00:00
}
2001-10-12 12:26:23 +00:00
2013-04-07 12:06:47 +02:00
void SvtViewOptionsBase_Impl : : SetUserData ( const OUString & sName ,
2001-10-12 12:26:23 +00:00
const css : : uno : : Sequence < css : : beans : : NamedValue > & lData )
2000-11-10 08:32:42 +00:00
{
2001-10-19 07:16:30 +00:00
# ifdef DEBUG_VIEWOPTIONS
+ + m_nWriteCount ;
# endif
2005-09-30 09:14:22 +00:00
try
2001-10-19 07:16:30 +00:00
{
2005-09-30 09:14:22 +00:00
css : : uno : : Reference < css : : container : : XNameAccess > xNode (
2014-02-19 12:30:34 +01:00
impl_getSetNode ( sName , true ) ,
2005-11-04 14:45:35 +00:00
css : : uno : : UNO_QUERY_THROW ) ;
2005-09-30 09:14:22 +00:00
css : : uno : : Reference < css : : container : : XNameContainer > xUserData ;
2005-11-04 14:45:35 +00:00
xNode - > getByName ( PROPERTY_USERDATA ) > > = xUserData ;
2005-09-30 09:14:22 +00:00
if ( xUserData . is ( ) )
2001-10-19 07:16:30 +00:00
{
2005-09-30 09:14:22 +00:00
const css : : beans : : NamedValue * pData = lData . getConstArray ( ) ;
sal_Int32 c = lData . getLength ( ) ;
sal_Int32 i = 0 ;
for ( i = 0 ; i < c ; + + i )
{
if ( xUserData - > hasByName ( pData [ i ] . Name ) )
xUserData - > replaceByName ( pData [ i ] . Name , pData [ i ] . Value ) ;
else
xUserData - > insertByName ( pData [ i ] . Name , pData [ i ] . Value ) ;
}
2001-10-19 07:16:30 +00:00
}
2005-12-14 15:01:18 +00:00
: : comphelper : : ConfigurationHelper : : flush ( m_xRoot ) ;
2001-10-19 07:16:30 +00:00
}
2005-11-04 14:45:35 +00:00
catch ( const css : : uno : : Exception & ex )
{
SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION ( ex )
}
2000-11-10 08:32:42 +00:00
}
2013-04-07 12:06:47 +02:00
css : : uno : : Any SvtViewOptionsBase_Impl : : GetUserItem ( const OUString & sName ,
const OUString & sItem )
2000-11-10 08:32:42 +00:00
{
2001-10-19 07:16:30 +00:00
# ifdef DEBUG_VIEWOPTIONS
+ + m_nReadCount ;
# endif
2005-09-30 09:14:22 +00:00
css : : uno : : Any aItem ;
try
{
css : : uno : : Reference < css : : container : : XNameAccess > xNode (
2014-02-19 12:30:34 +01:00
impl_getSetNode ( sName , false ) ,
2005-09-30 09:14:22 +00:00
css : : uno : : UNO_QUERY ) ;
css : : uno : : Reference < css : : container : : XNameAccess > xUserData ;
if ( xNode . is ( ) )
xNode - > getByName ( PROPERTY_USERDATA ) > > = xUserData ;
if ( xUserData . is ( ) )
aItem = xUserData - > getByName ( sItem ) ;
}
2005-11-04 14:45:35 +00:00
catch ( const css : : container : : NoSuchElementException & )
2005-09-30 09:14:22 +00:00
{ aItem . clear ( ) ; }
2005-11-04 14:45:35 +00:00
catch ( const css : : uno : : Exception & ex )
{
aItem . clear ( ) ;
SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION ( ex )
}
2005-09-30 09:14:22 +00:00
return aItem ;
2000-11-10 08:32:42 +00:00
}
2013-04-07 12:06:47 +02:00
void SvtViewOptionsBase_Impl : : SetUserItem ( const OUString & sName ,
const OUString & sItem ,
2001-10-12 12:26:23 +00:00
const css : : uno : : Any & aValue )
2000-11-10 08:32:42 +00:00
{
2001-10-19 07:16:30 +00:00
# ifdef DEBUG_VIEWOPTIONS
+ + m_nWriteCount ;
# endif
2005-09-30 09:14:22 +00:00
try
2001-10-19 07:16:30 +00:00
{
2005-09-30 09:14:22 +00:00
css : : uno : : Reference < css : : container : : XNameAccess > xNode (
2014-02-19 12:30:34 +01:00
impl_getSetNode ( sName , true ) ,
2005-11-04 14:45:35 +00:00
css : : uno : : UNO_QUERY_THROW ) ;
2005-09-30 09:14:22 +00:00
css : : uno : : Reference < css : : container : : XNameContainer > xUserData ;
2005-11-04 14:45:35 +00:00
xNode - > getByName ( PROPERTY_USERDATA ) > > = xUserData ;
2005-09-30 09:14:22 +00:00
if ( xUserData . is ( ) )
2001-10-19 07:16:30 +00:00
{
2005-09-30 09:14:22 +00:00
if ( xUserData - > hasByName ( sItem ) )
xUserData - > replaceByName ( sItem , aValue ) ;
else
xUserData - > insertByName ( sItem , aValue ) ;
2001-10-19 07:16:30 +00:00
}
2005-12-14 15:01:18 +00:00
: : comphelper : : ConfigurationHelper : : flush ( m_xRoot ) ;
2001-10-19 07:16:30 +00:00
}
2005-11-04 14:45:35 +00:00
catch ( const css : : uno : : Exception & ex )
{
SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION ( ex )
}
2000-11-10 08:32:42 +00:00
}
2013-04-07 12:06:47 +02:00
sal_Int32 SvtViewOptionsBase_Impl : : GetPageID ( const OUString & sName )
2000-11-10 08:32:42 +00:00
{
2001-10-19 07:16:30 +00:00
# ifdef DEBUG_VIEWOPTIONS
+ + m_nReadCount ;
# endif
2005-09-30 09:14:22 +00:00
sal_Int32 nID = 0 ;
try
{
2005-11-04 14:45:35 +00:00
css : : uno : : Reference < css : : beans : : XPropertySet > xNode (
2014-02-19 12:30:34 +01:00
impl_getSetNode ( sName , false ) ,
2005-09-30 09:14:22 +00:00
css : : uno : : UNO_QUERY ) ;
if ( xNode . is ( ) )
2005-11-04 14:45:35 +00:00
xNode - > getPropertyValue ( PROPERTY_PAGEID ) > > = nID ;
2005-09-30 09:14:22 +00:00
}
2005-11-04 14:45:35 +00:00
catch ( const css : : uno : : Exception & ex )
{
nID = 0 ;
SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION ( ex )
}
2005-09-30 09:14:22 +00:00
return nID ;
2000-11-10 08:32:42 +00:00
}
2013-04-07 12:06:47 +02:00
void SvtViewOptionsBase_Impl : : SetPageID ( const OUString & sName ,
2001-10-12 12:26:23 +00:00
sal_Int32 nID )
2001-08-10 08:21:35 +00:00
{
2001-10-19 07:16:30 +00:00
# ifdef DEBUG_VIEWOPTIONS
+ + m_nWriteCount ;
# endif
2005-09-30 09:14:22 +00:00
try
2001-10-19 07:16:30 +00:00
{
2005-11-04 14:45:35 +00:00
css : : uno : : Reference < css : : beans : : XPropertySet > xNode (
2014-02-19 12:30:34 +01:00
impl_getSetNode ( sName , true ) ,
2005-11-04 14:45:35 +00:00
css : : uno : : UNO_QUERY_THROW ) ;
xNode - > setPropertyValue ( PROPERTY_PAGEID , css : : uno : : makeAny ( nID ) ) ;
2005-12-14 15:01:18 +00:00
: : comphelper : : ConfigurationHelper : : flush ( m_xRoot ) ;
2001-10-19 07:16:30 +00:00
}
2005-11-04 14:45:35 +00:00
catch ( const css : : uno : : Exception & ex )
{
SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION ( ex )
}
2001-08-10 08:21:35 +00:00
}
2013-04-07 12:06:47 +02:00
SvtViewOptionsBase_Impl : : State SvtViewOptionsBase_Impl : : GetVisible ( const OUString & sName )
2001-08-10 08:21:35 +00:00
{
2001-10-19 07:16:30 +00:00
# ifdef DEBUG_VIEWOPTIONS
+ + m_nReadCount ;
# endif
2012-10-05 15:00:39 +02:00
State eState = STATE_NONE ;
2005-09-30 09:14:22 +00:00
try
{
2005-11-04 14:45:35 +00:00
css : : uno : : Reference < css : : beans : : XPropertySet > xNode (
2014-02-19 12:30:34 +01:00
impl_getSetNode ( sName , false ) ,
2005-09-30 09:14:22 +00:00
css : : uno : : UNO_QUERY ) ;
if ( xNode . is ( ) )
2012-10-05 15:00:39 +02:00
{
2014-02-19 12:30:34 +01:00
bool bVisible = false ;
2012-10-05 15:00:39 +02:00
if ( xNode - > getPropertyValue ( PROPERTY_VISIBLE ) > > = bVisible )
{
eState = bVisible ? STATE_TRUE : STATE_FALSE ;
}
}
2005-09-30 09:14:22 +00:00
}
2005-11-04 14:45:35 +00:00
catch ( const css : : uno : : Exception & ex )
{
SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION ( ex )
}
2005-09-30 09:14:22 +00:00
2012-10-05 15:00:39 +02:00
return eState ;
2001-08-10 08:21:35 +00:00
}
2013-04-07 12:06:47 +02:00
void SvtViewOptionsBase_Impl : : SetVisible ( const OUString & sName ,
2014-02-19 12:30:34 +01:00
bool bVisible )
2001-08-10 08:21:35 +00:00
{
2001-10-19 07:16:30 +00:00
# ifdef DEBUG_VIEWOPTIONS
+ + m_nWriteCount ;
# endif
2005-09-30 09:14:22 +00:00
try
2001-10-19 07:16:30 +00:00
{
2005-11-04 14:45:35 +00:00
css : : uno : : Reference < css : : beans : : XPropertySet > xNode (
2014-02-19 12:30:34 +01:00
impl_getSetNode ( sName , true ) ,
2005-11-04 14:45:35 +00:00
css : : uno : : UNO_QUERY_THROW ) ;
xNode - > setPropertyValue ( PROPERTY_VISIBLE , css : : uno : : makeAny ( bVisible ) ) ;
2005-12-14 15:01:18 +00:00
: : comphelper : : ConfigurationHelper : : flush ( m_xRoot ) ;
2001-10-19 07:16:30 +00:00
}
2005-11-04 14:45:35 +00:00
catch ( const css : : uno : : Exception & ex )
{
SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION ( ex )
}
2001-10-19 07:16:30 +00:00
}
2014-02-25 22:46:10 +01:00
/*-************************************************************************************************************
2001-10-19 07:16:30 +00:00
@ short create new set node with default values on disk
@ descr To create a new UserData item - the super node of these property must already exist !
You can call this method to create these new entry with default values and change UserData then .
@ seealso method impl_writeDirectProp ( )
@ param " sNode " , name of new entry
*/ /*-*************************************************************************************************************/
2013-04-07 12:06:47 +02:00
css : : uno : : Reference < css : : uno : : XInterface > SvtViewOptionsBase_Impl : : impl_getSetNode ( const OUString & sNode ,
2014-02-19 12:30:34 +01:00
bool bCreateIfMissing )
2001-10-19 07:16:30 +00:00
{
2005-09-30 09:14:22 +00:00
css : : uno : : Reference < css : : uno : : XInterface > xNode ;
2001-10-19 07:16:30 +00:00
2005-09-30 09:14:22 +00:00
try
2001-10-19 07:16:30 +00:00
{
2005-09-30 09:14:22 +00:00
if ( bCreateIfMissing )
xNode = : : comphelper : : ConfigurationHelper : : makeSureSetNodeExists ( m_xRoot , m_sListName , sNode ) ;
else
2001-10-19 07:16:30 +00:00
{
2010-09-17 13:58:19 +02:00
if ( m_xSet . is ( ) & & m_xSet - > hasByName ( sNode ) )
2005-09-30 09:14:22 +00:00
m_xSet - > getByName ( sNode ) > > = xNode ;
2001-10-12 12:26:23 +00:00
}
2000-11-10 13:55:55 +00:00
}
2005-11-04 14:45:35 +00:00
catch ( const css : : container : : NoSuchElementException & )
2005-09-30 09:14:22 +00:00
{ xNode . clear ( ) ; }
2005-11-04 14:45:35 +00:00
catch ( const css : : uno : : Exception & ex )
{
xNode . clear ( ) ;
SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION ( ex )
}
2005-09-30 09:14:22 +00:00
return xNode ;
2000-11-10 13:55:55 +00:00
}
2000-11-10 08:32:42 +00:00
// constructor
2014-02-25 22:46:10 +01:00
2001-10-12 12:26:23 +00:00
SvtViewOptions : : SvtViewOptions ( EViewType eType ,
2013-04-07 12:06:47 +02:00
const OUString & sViewName )
2000-11-10 08:32:42 +00:00
: m_eViewType ( eType )
, m_sViewName ( sViewName )
{
// Global access, must be guarded (multithreading!)
2001-10-12 12:26:23 +00:00
: : osl : : MutexGuard aGuard ( GetOwnStaticMutex ( ) ) ;
2000-11-10 08:32:42 +00:00
// Search for right dat container for this view type and initialize right data container or set right ref count!
switch ( eType )
{
case E_DIALOG : {
// Increase ref count for dialog data container first.
+ + m_nRefCount_Dialogs ;
// If these instance the first user of the dialog data container - create these impl static container!
2000-11-15 08:06:06 +00:00
if ( m_nRefCount_Dialogs = = 1 )
2000-11-10 08:32:42 +00:00
{
2001-10-12 12:26:23 +00:00
//m_pDataContainer_Dialogs = new SvtViewDialogOptions_Impl( LIST_DIALOGS );
m_pDataContainer_Dialogs = new SvtViewOptionsBase_Impl ( LIST_DIALOGS ) ;
2005-11-11 07:55:28 +00:00
ItemHolder1 : : holdConfigItem ( E_VIEWOPTIONS_DIALOG ) ;
2000-11-10 08:32:42 +00:00
}
}
break ;
case E_TABDIALOG : {
// Increase ref count for tab-dialog data container first.
+ + m_nRefCount_TabDialogs ;
// If these instance the first user of the tab-dialog data container - create these impl static container!
2000-11-15 08:06:06 +00:00
if ( m_nRefCount_TabDialogs = = 1 )
2000-11-10 08:32:42 +00:00
{
2001-10-12 12:26:23 +00:00
m_pDataContainer_TabDialogs = new SvtViewOptionsBase_Impl ( LIST_TABDIALOGS ) ;
2005-11-11 07:55:28 +00:00
ItemHolder1 : : holdConfigItem ( E_VIEWOPTIONS_TABDIALOG ) ;
2000-11-10 08:32:42 +00:00
}
}
break ;
case E_TABPAGE : {
// Increase ref count for tab-page data container first.
+ + m_nRefCount_TabPages ;
// If these instance the first user of the tab-page data container - create these impl static container!
2000-11-15 08:06:06 +00:00
if ( m_nRefCount_TabPages = = 1 )
2000-11-10 08:32:42 +00:00
{
2001-10-12 12:26:23 +00:00
m_pDataContainer_TabPages = new SvtViewOptionsBase_Impl ( LIST_TABPAGES ) ;
2005-11-11 07:55:28 +00:00
ItemHolder1 : : holdConfigItem ( E_VIEWOPTIONS_TABPAGE ) ;
2000-11-10 08:32:42 +00:00
}
}
break ;
case E_WINDOW : {
// Increase ref count for window data container first.
+ + m_nRefCount_Windows ;
// If these instance the first user of the window data container - create these impl static container!
2000-11-15 08:06:06 +00:00
if ( m_nRefCount_Windows = = 1 )
2000-11-10 08:32:42 +00:00
{
2001-10-12 12:26:23 +00:00
m_pDataContainer_Windows = new SvtViewOptionsBase_Impl ( LIST_WINDOWS ) ;
2005-11-11 07:55:28 +00:00
ItemHolder1 : : holdConfigItem ( E_VIEWOPTIONS_WINDOW ) ;
2000-11-10 08:32:42 +00:00
}
}
break ;
2011-03-19 14:11:09 +01:00
default : OSL_FAIL ( " SvtViewOptions::SvtViewOptions() \n These view type is unknown! All following calls at these instance will do nothing! \n " ) ;
2000-11-10 08:32:42 +00:00
}
}
// destructor
2014-02-25 22:46:10 +01:00
2000-11-10 08:32:42 +00:00
SvtViewOptions : : ~ SvtViewOptions ( )
{
// Global access, must be guarded (multithreading!)
2001-10-12 12:26:23 +00:00
: : osl : : MutexGuard aGuard ( GetOwnStaticMutex ( ) ) ;
2000-11-10 08:32:42 +00:00
// Search for right dat container for this view type and deinitialize right data container or set right ref count!
switch ( m_eViewType )
{
case E_DIALOG : {
// Decrease ref count for dialog data container first.
- - m_nRefCount_Dialogs ;
// If these instance the last user of the dialog data container - delete these impl static container!
2000-11-15 08:06:06 +00:00
if ( m_nRefCount_Dialogs = = 0 )
2000-11-10 08:32:42 +00:00
{
delete m_pDataContainer_Dialogs ;
m_pDataContainer_Dialogs = NULL ;
}
}
break ;
case E_TABDIALOG : {
// Decrease ref count for tab-dialog data container first.
- - m_nRefCount_TabDialogs ;
// If these instance the last user of the tab-dialog data container - delete these impl static container!
2000-11-15 08:06:06 +00:00
if ( m_nRefCount_TabDialogs = = 0 )
2000-11-10 08:32:42 +00:00
{
delete m_pDataContainer_TabDialogs ;
m_pDataContainer_TabDialogs = NULL ;
}
}
break ;
case E_TABPAGE : {
// Decrease ref count for tab-page data container first.
- - m_nRefCount_TabPages ;
// If these instance the last user of the tab-page data container - delete these impl static container!
2000-11-15 08:06:06 +00:00
if ( m_nRefCount_TabPages = = 0 )
2000-11-10 08:32:42 +00:00
{
delete m_pDataContainer_TabPages ;
m_pDataContainer_TabPages = NULL ;
}
}
break ;
case E_WINDOW : {
// Decrease ref count for window data container first.
- - m_nRefCount_Windows ;
// If these instance the last user of the window data container - delete these impl static container!
2000-11-15 08:06:06 +00:00
if ( m_nRefCount_Windows = = 0 )
2000-11-10 08:32:42 +00:00
{
delete m_pDataContainer_Windows ;
m_pDataContainer_Windows = NULL ;
}
}
break ;
}
}
2000-11-10 10:42:50 +00:00
// public method
2014-02-25 22:46:10 +01:00
2014-02-19 12:30:34 +01:00
bool SvtViewOptions : : Exists ( ) const
2000-11-10 10:42:50 +00:00
{
// Ready for multithreading
2001-10-12 12:26:23 +00:00
: : osl : : MutexGuard aGuard ( GetOwnStaticMutex ( ) ) ;
2000-11-10 10:42:50 +00:00
2014-02-19 12:30:34 +01:00
bool bExists = false ;
2000-11-10 10:42:50 +00:00
switch ( m_eViewType )
{
case E_DIALOG : {
2000-11-10 13:55:55 +00:00
bExists = m_pDataContainer_Dialogs - > Exists ( m_sViewName ) ;
2000-11-10 10:42:50 +00:00
}
break ;
case E_TABDIALOG : {
2000-11-10 13:55:55 +00:00
bExists = m_pDataContainer_TabDialogs - > Exists ( m_sViewName ) ;
2000-11-10 10:42:50 +00:00
}
break ;
case E_TABPAGE : {
2000-11-10 13:55:55 +00:00
bExists = m_pDataContainer_TabPages - > Exists ( m_sViewName ) ;
2000-11-10 10:42:50 +00:00
}
break ;
case E_WINDOW : {
2000-11-10 13:55:55 +00:00
bExists = m_pDataContainer_Windows - > Exists ( m_sViewName ) ;
2000-11-10 10:42:50 +00:00
}
break ;
}
2000-11-10 13:55:55 +00:00
return bExists ;
2000-11-10 10:42:50 +00:00
}
// public method
2014-02-25 22:46:10 +01:00
2014-02-19 12:30:34 +01:00
bool SvtViewOptions : : Delete ( )
2000-11-10 10:42:50 +00:00
{
// Ready for multithreading
2001-10-12 12:26:23 +00:00
: : osl : : MutexGuard aGuard ( GetOwnStaticMutex ( ) ) ;
2000-11-10 10:42:50 +00:00
2014-02-19 12:30:34 +01:00
bool bState = false ;
2000-11-10 10:42:50 +00:00
switch ( m_eViewType )
{
case E_DIALOG : {
2000-11-10 10:47:48 +00:00
bState = m_pDataContainer_Dialogs - > Delete ( m_sViewName ) ;
2000-11-10 10:42:50 +00:00
}
break ;
case E_TABDIALOG : {
2000-11-10 10:47:48 +00:00
bState = m_pDataContainer_TabDialogs - > Delete ( m_sViewName ) ;
2000-11-10 10:42:50 +00:00
}
break ;
case E_TABPAGE : {
2000-11-10 10:47:48 +00:00
bState = m_pDataContainer_TabPages - > Delete ( m_sViewName ) ;
2000-11-10 10:42:50 +00:00
}
break ;
case E_WINDOW : {
2000-11-10 10:47:48 +00:00
bState = m_pDataContainer_Windows - > Delete ( m_sViewName ) ;
2000-11-10 10:42:50 +00:00
}
break ;
}
2000-11-10 10:47:48 +00:00
return bState ;
2000-11-10 10:42:50 +00:00
}
2000-11-10 08:32:42 +00:00
// public method
2014-02-25 22:46:10 +01:00
2013-04-07 12:06:47 +02:00
OUString SvtViewOptions : : GetWindowState ( ) const
2000-11-10 08:32:42 +00:00
{
// Ready for multithreading
2001-10-12 12:26:23 +00:00
: : osl : : MutexGuard aGuard ( GetOwnStaticMutex ( ) ) ;
2000-11-10 08:32:42 +00:00
2013-04-07 12:06:47 +02:00
OUString sState ;
2000-11-10 08:32:42 +00:00
switch ( m_eViewType )
{
case E_DIALOG : {
2001-10-12 12:26:23 +00:00
sState = m_pDataContainer_Dialogs - > GetWindowState ( m_sViewName ) ;
2000-11-10 08:32:42 +00:00
}
break ;
case E_TABDIALOG : {
2001-10-12 12:26:23 +00:00
sState = m_pDataContainer_TabDialogs - > GetWindowState ( m_sViewName ) ;
2000-11-10 08:32:42 +00:00
}
break ;
2001-10-12 12:26:23 +00:00
case E_TABPAGE : {
sState = m_pDataContainer_TabPages - > GetWindowState ( m_sViewName ) ;
2000-11-10 08:32:42 +00:00
}
break ;
case E_WINDOW : {
2001-10-12 12:26:23 +00:00
sState = m_pDataContainer_Windows - > GetWindowState ( m_sViewName ) ;
2000-11-10 08:32:42 +00:00
}
break ;
}
2001-10-12 12:26:23 +00:00
return sState ;
2000-11-10 08:32:42 +00:00
}
// public method
2014-02-25 22:46:10 +01:00
2013-04-07 12:06:47 +02:00
void SvtViewOptions : : SetWindowState ( const OUString & sState )
2000-11-10 08:32:42 +00:00
{
// Ready for multithreading
2001-10-12 12:26:23 +00:00
: : osl : : MutexGuard aGuard ( GetOwnStaticMutex ( ) ) ;
2000-11-10 08:32:42 +00:00
switch ( m_eViewType )
{
case E_DIALOG : {
2001-10-12 12:26:23 +00:00
m_pDataContainer_Dialogs - > SetWindowState ( m_sViewName , sState ) ;
2000-11-10 08:32:42 +00:00
}
break ;
2001-10-12 12:26:23 +00:00
case E_TABDIALOG : {
m_pDataContainer_TabDialogs - > SetWindowState ( m_sViewName , sState ) ;
2000-11-10 08:32:42 +00:00
}
break ;
2001-10-12 12:26:23 +00:00
case E_TABPAGE : {
m_pDataContainer_TabPages - > SetWindowState ( m_sViewName , sState ) ;
2000-11-10 08:32:42 +00:00
}
break ;
case E_WINDOW : {
2001-10-12 12:26:23 +00:00
m_pDataContainer_Windows - > SetWindowState ( m_sViewName , sState ) ;
2000-11-10 08:32:42 +00:00
}
break ;
}
}
// public method
2014-02-25 22:46:10 +01:00
2000-11-10 08:32:42 +00:00
sal_Int32 SvtViewOptions : : GetPageID ( ) const
{
// Ready for multithreading
2001-10-12 12:26:23 +00:00
: : osl : : MutexGuard aGuard ( GetOwnStaticMutex ( ) ) ;
2000-11-10 08:32:42 +00:00
// Safe impossible cases.
// These call isn't allowed for dialogs, tab-pages or windows!
2001-10-12 12:26:23 +00:00
OSL_ENSURE ( ! ( m_eViewType = = E_DIALOG | | m_eViewType = = E_TABPAGE | | m_eViewType = = E_WINDOW ) , " SvtViewOptions::GetPageID() \n Call not allowed for Dialogs, TabPages or Windows! I do nothing! \n " ) ;
2000-11-10 08:32:42 +00:00
sal_Int32 nID = 0 ;
2006-06-19 19:49:41 +00:00
if ( m_eViewType = = E_TABDIALOG )
nID = m_pDataContainer_TabDialogs - > GetPageID ( m_sViewName ) ;
2000-11-10 08:32:42 +00:00
return nID ;
}
// public method
2014-02-25 22:46:10 +01:00
2000-11-10 08:32:42 +00:00
void SvtViewOptions : : SetPageID ( sal_Int32 nID )
{
// Ready for multithreading
2001-10-12 12:26:23 +00:00
: : osl : : MutexGuard aGuard ( GetOwnStaticMutex ( ) ) ;
2000-11-10 08:32:42 +00:00
// Safe impossible cases.
// These call isn't allowed for dialogs, tab-pages or windows!
2001-10-12 12:26:23 +00:00
OSL_ENSURE ( ! ( m_eViewType = = E_DIALOG | | m_eViewType = = E_TABPAGE | | m_eViewType = = E_WINDOW ) , " SvtViewOptions::SetPageID() \n Call not allowed for Dialogs, TabPages or Windows! I do nothing! \n " ) ;
2000-11-10 08:32:42 +00:00
2006-06-19 19:49:41 +00:00
if ( m_eViewType = = E_TABDIALOG )
m_pDataContainer_TabDialogs - > SetPageID ( m_sViewName , nID ) ;
2000-11-10 08:32:42 +00:00
}
// public method
2014-02-25 22:46:10 +01:00
2014-02-19 12:30:34 +01:00
bool SvtViewOptions : : IsVisible ( ) const
2000-11-10 08:32:42 +00:00
{
// Ready for multithreading
2001-10-12 12:26:23 +00:00
: : osl : : MutexGuard aGuard ( GetOwnStaticMutex ( ) ) ;
2000-11-10 08:32:42 +00:00
// Safe impossible cases.
// These call isn't allowed for dialogs, tab-dialogs or tab-pages!
2001-10-12 12:26:23 +00:00
OSL_ENSURE ( ! ( m_eViewType = = E_DIALOG | | m_eViewType = = E_TABDIALOG | | m_eViewType = = E_TABPAGE ) , " SvtViewOptions::IsVisible() \n Call not allowed for Dialogs, TabDialogs or TabPages! I do nothing! \n " ) ;
2000-11-10 08:32:42 +00:00
2014-02-19 12:30:34 +01:00
bool bState = false ;
2006-06-19 19:49:41 +00:00
if ( m_eViewType = = E_WINDOW )
2012-10-05 15:00:39 +02:00
bState = m_pDataContainer_Windows - > GetVisible ( m_sViewName ) = = SvtViewOptionsBase_Impl : : STATE_TRUE ;
2006-06-19 19:49:41 +00:00
2000-11-10 08:32:42 +00:00
return bState ;
}
// public method
2014-02-25 22:46:10 +01:00
2014-02-19 12:30:34 +01:00
void SvtViewOptions : : SetVisible ( bool bState )
2000-11-10 08:32:42 +00:00
{
// Ready for multithreading
2001-10-12 12:26:23 +00:00
: : osl : : MutexGuard aGuard ( GetOwnStaticMutex ( ) ) ;
2000-11-10 08:32:42 +00:00
// Safe impossible cases.
// These call isn't allowed for dialogs, tab-dialogs or tab-pages!
2001-10-12 12:26:23 +00:00
OSL_ENSURE ( ! ( m_eViewType = = E_DIALOG | | m_eViewType = = E_TABDIALOG | | m_eViewType = = E_TABPAGE ) , " SvtViewOptions::SetVisible() \n Call not allowed for Dialogs, TabDialogs or TabPages! I do nothing! \n " ) ;
2000-11-10 08:32:42 +00:00
2006-06-19 19:49:41 +00:00
if ( m_eViewType = = E_WINDOW )
m_pDataContainer_Windows - > SetVisible ( m_sViewName , bState ) ;
2000-11-10 08:32:42 +00:00
}
2012-10-05 15:00:39 +02:00
// public method
2014-02-25 22:46:10 +01:00
2012-10-05 15:00:39 +02:00
bool SvtViewOptions : : HasVisible ( ) const
{
// Ready for multithreading
: : osl : : MutexGuard aGuard ( GetOwnStaticMutex ( ) ) ;
// Safe impossible cases.
// These call isn't allowed for dialogs, tab-dialogs or tab-pages!
OSL_ENSURE ( ! ( m_eViewType = = E_DIALOG | | m_eViewType = = E_TABDIALOG | | m_eViewType = = E_TABPAGE ) , " SvtViewOptions::IsVisible() \n Call not allowed for Dialogs, TabDialogs or TabPages! I do nothing! \n " ) ;
bool bState = false ;
if ( m_eViewType = = E_WINDOW )
bState = m_pDataContainer_Windows - > GetVisible ( m_sViewName ) ! = SvtViewOptionsBase_Impl : : STATE_NONE ;
return bState ;
}
2001-10-12 12:26:23 +00:00
css : : uno : : Sequence < css : : beans : : NamedValue > SvtViewOptions : : GetUserData ( ) const
{
2000-11-10 08:32:42 +00:00
// Ready for multithreading
2001-10-12 12:26:23 +00:00
: : osl : : MutexGuard aGuard ( GetOwnStaticMutex ( ) ) ;
2000-11-10 08:32:42 +00:00
2001-10-12 12:26:23 +00:00
css : : uno : : Sequence < css : : beans : : NamedValue > lData ;
2000-11-10 08:32:42 +00:00
switch ( m_eViewType )
{
case E_DIALOG : {
2001-10-12 12:26:23 +00:00
lData = m_pDataContainer_Dialogs - > GetUserData ( m_sViewName ) ;
2000-11-10 08:32:42 +00:00
}
break ;
case E_TABDIALOG : {
2001-10-12 12:26:23 +00:00
lData = m_pDataContainer_TabDialogs - > GetUserData ( m_sViewName ) ;
2000-11-10 08:32:42 +00:00
}
break ;
case E_TABPAGE : {
2001-10-12 12:26:23 +00:00
lData = m_pDataContainer_TabPages - > GetUserData ( m_sViewName ) ;
2000-11-10 08:32:42 +00:00
}
break ;
case E_WINDOW : {
2001-10-12 12:26:23 +00:00
lData = m_pDataContainer_Windows - > GetUserData ( m_sViewName ) ;
2000-11-10 08:32:42 +00:00
}
break ;
}
2001-10-12 12:26:23 +00:00
return lData ;
2000-11-10 08:32:42 +00:00
}
2001-10-12 12:26:23 +00:00
void SvtViewOptions : : SetUserData ( const css : : uno : : Sequence < css : : beans : : NamedValue > & lData )
2000-11-10 08:32:42 +00:00
{
// Ready for multithreading
2001-10-12 12:26:23 +00:00
: : osl : : MutexGuard aGuard ( GetOwnStaticMutex ( ) ) ;
2000-11-10 08:32:42 +00:00
switch ( m_eViewType )
{
case E_DIALOG : {
2001-10-12 12:26:23 +00:00
m_pDataContainer_Dialogs - > SetUserData ( m_sViewName , lData ) ;
2000-11-10 08:32:42 +00:00
}
break ;
case E_TABDIALOG : {
2001-10-12 12:26:23 +00:00
m_pDataContainer_TabDialogs - > SetUserData ( m_sViewName , lData ) ;
2000-11-10 08:32:42 +00:00
}
break ;
case E_TABPAGE : {
2001-10-12 12:26:23 +00:00
m_pDataContainer_TabPages - > SetUserData ( m_sViewName , lData ) ;
2000-11-10 08:32:42 +00:00
}
break ;
case E_WINDOW : {
2001-10-12 12:26:23 +00:00
m_pDataContainer_Windows - > SetUserData ( m_sViewName , lData ) ;
2000-11-10 08:32:42 +00:00
}
break ;
}
}
2013-04-07 12:06:47 +02:00
css : : uno : : Any SvtViewOptions : : GetUserItem ( const OUString & sName ) const
2001-08-10 08:21:35 +00:00
{
2001-10-19 07:16:30 +00:00
// Ready for multithreading
2001-10-12 12:26:23 +00:00
: : osl : : MutexGuard aGuard ( GetOwnStaticMutex ( ) ) ;
2001-10-19 07:16:30 +00:00
css : : uno : : Any aItem ;
2001-08-10 08:21:35 +00:00
switch ( m_eViewType )
{
case E_DIALOG : {
2001-10-19 07:16:30 +00:00
aItem = m_pDataContainer_Dialogs - > GetUserItem ( m_sViewName , sName ) ;
2001-08-10 08:21:35 +00:00
}
break ;
case E_TABDIALOG : {
2001-10-19 07:16:30 +00:00
aItem = m_pDataContainer_TabDialogs - > GetUserItem ( m_sViewName , sName ) ;
2001-08-10 08:21:35 +00:00
}
break ;
case E_TABPAGE : {
2001-10-19 07:16:30 +00:00
aItem = m_pDataContainer_TabPages - > GetUserItem ( m_sViewName , sName ) ;
2001-08-10 08:21:35 +00:00
}
break ;
case E_WINDOW : {
2001-10-19 07:16:30 +00:00
aItem = m_pDataContainer_Windows - > GetUserItem ( m_sViewName , sName ) ;
2001-08-10 08:21:35 +00:00
}
break ;
}
2001-10-19 07:16:30 +00:00
return aItem ;
2001-08-10 08:21:35 +00:00
}
2013-04-07 12:06:47 +02:00
void SvtViewOptions : : SetUserItem ( const OUString & sName ,
2001-10-19 07:16:30 +00:00
const css : : uno : : Any & aValue )
2001-10-12 12:26:23 +00:00
{
2001-10-19 07:16:30 +00:00
// Ready for multithreading
2001-10-12 12:26:23 +00:00
: : osl : : MutexGuard aGuard ( GetOwnStaticMutex ( ) ) ;
2001-08-10 08:21:35 +00:00
switch ( m_eViewType )
{
case E_DIALOG : {
2001-10-19 07:16:30 +00:00
m_pDataContainer_Dialogs - > SetUserItem ( m_sViewName , sName , aValue ) ;
2001-08-10 08:21:35 +00:00
}
break ;
case E_TABDIALOG : {
2001-10-19 07:16:30 +00:00
m_pDataContainer_TabDialogs - > SetUserItem ( m_sViewName , sName , aValue ) ;
2001-08-10 08:21:35 +00:00
}
break ;
case E_TABPAGE : {
2001-10-19 07:16:30 +00:00
m_pDataContainer_TabPages - > SetUserItem ( m_sViewName , sName , aValue ) ;
2001-08-10 08:21:35 +00:00
}
break ;
case E_WINDOW : {
2001-10-19 07:16:30 +00:00
m_pDataContainer_Windows - > SetUserItem ( m_sViewName , sName , aValue ) ;
2001-08-10 08:21:35 +00:00
}
break ;
}
2001-10-12 12:26:23 +00:00
}
2011-04-03 21:34:16 +01:00
namespace
{
class theViewOptionsMutex : public rtl : : Static < osl : : Mutex , theViewOptionsMutex > { } ;
}
2000-11-10 08:32:42 +00:00
// private method
2014-02-25 22:46:10 +01:00
2001-10-12 12:26:23 +00:00
: : osl : : Mutex & SvtViewOptions : : GetOwnStaticMutex ( )
2000-11-10 08:32:42 +00:00
{
2011-04-03 21:34:16 +01:00
return theViewOptionsMutex : : get ( ) ;
2000-11-10 08:32:42 +00:00
}
2000-12-08 09:59:27 +00:00
void SvtViewOptions : : AcquireOptions ( )
{
2001-10-12 12:26:23 +00:00
: : osl : : MutexGuard aGuard ( GetOwnStaticMutex ( ) ) ;
2000-12-08 09:59:27 +00:00
if ( + + m_nRefCount_Dialogs = = 1 )
2005-11-11 07:55:28 +00:00
{
2001-10-12 12:26:23 +00:00
m_pDataContainer_Dialogs = new SvtViewOptionsBase_Impl ( LIST_DIALOGS ) ;
2005-11-11 07:55:28 +00:00
ItemHolder1 : : holdConfigItem ( E_VIEWOPTIONS_DIALOG ) ;
}
2000-12-08 09:59:27 +00:00
if ( + + m_nRefCount_TabDialogs = = 1 )
2005-11-11 07:55:28 +00:00
{
2001-10-12 12:26:23 +00:00
m_pDataContainer_TabDialogs = new SvtViewOptionsBase_Impl ( LIST_TABDIALOGS ) ;
2005-11-11 07:55:28 +00:00
ItemHolder1 : : holdConfigItem ( E_VIEWOPTIONS_TABDIALOG ) ;
}
2000-12-08 09:59:27 +00:00
if ( + + m_nRefCount_TabPages = = 1 )
2005-11-11 07:55:28 +00:00
{
2001-10-12 12:26:23 +00:00
m_pDataContainer_TabPages = new SvtViewOptionsBase_Impl ( LIST_TABPAGES ) ;
2005-11-11 07:55:28 +00:00
ItemHolder1 : : holdConfigItem ( E_VIEWOPTIONS_TABPAGE ) ;
}
2000-12-08 09:59:27 +00:00
if ( + + m_nRefCount_Windows = = 1 )
2005-11-11 07:55:28 +00:00
{
2001-10-12 12:26:23 +00:00
m_pDataContainer_Windows = new SvtViewOptionsBase_Impl ( LIST_WINDOWS ) ;
2005-11-11 07:55:28 +00:00
ItemHolder1 : : holdConfigItem ( E_VIEWOPTIONS_WINDOW ) ;
}
2000-12-08 09:59:27 +00:00
}
void SvtViewOptions : : ReleaseOptions ( )
{
2001-10-12 12:26:23 +00:00
: : osl : : MutexGuard aGuard ( GetOwnStaticMutex ( ) ) ;
2000-12-08 09:59:27 +00:00
if ( - - m_nRefCount_Dialogs = = 0 )
{
delete m_pDataContainer_Dialogs ;
m_pDataContainer_Dialogs = NULL ;
}
if ( - - m_nRefCount_TabDialogs = = 0 )
{
delete m_pDataContainer_TabDialogs ;
m_pDataContainer_TabDialogs = NULL ;
}
if ( - - m_nRefCount_TabPages = = 0 )
{
delete m_pDataContainer_TabPages ;
m_pDataContainer_TabPages = NULL ;
}
if ( - - m_nRefCount_Windows = = 0 )
{
delete m_pDataContainer_Windows ;
m_pDataContainer_Windows = NULL ;
}
}
2010-10-14 08:27:31 +02:00
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */