2010-10-14 08:27:31 +02:00
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2012-11-15 17:28:16 +00: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:26:43 +00:00
2000-11-06 08:46:14 +00:00
2013-08-15 17:15:26 +02:00
# include <svtools/menuoptions.hxx>
2000-11-06 08:46:14 +00:00
# include <unotools/configmgr.hxx>
# include <unotools/configitem.hxx>
# include <tools/debug.hxx>
# include <com/sun/star/uno/Any.hxx>
# include <com/sun/star/uno/Sequence.hxx>
2009-04-14 17:47:15 +00:00
# include <vcl/svapp.hxx>
2014-01-02 23:52:37 +01:00
# include <vcl/settings.hxx>
2000-11-06 08:46:14 +00:00
2009-10-06 07:38:24 +02:00
# include "itemholder2.hxx"
2004-11-15 16:22:20 +00:00
2011-02-01 01:32:54 -05:00
# include <list>
2014-02-22 21:20:15 +01:00
2000-11-06 08:46:14 +00:00
// namespaces
2014-02-22 21:20:15 +01:00
2000-11-06 08:46:14 +00:00
using namespace : : utl ;
using namespace : : osl ;
using namespace : : com : : sun : : star : : uno ;
2013-03-19 09:22:44 +01:00
# define ROOTNODE_MENU OUString("Office.Common / View / Menu" )
2014-03-20 16:41:09 +02:00
# define DEFAULT_DONTHIDEDISABLEDENTRIES false
# define DEFAULT_FOLLOWMOUSE true
2014-02-24 11:57:23 +00:00
# define DEFAULT_MENUICONS TRISTATE_INDET
2000-11-06 08:46:14 +00:00
2014-12-18 13:33:54 +01:00
# define PROPERTYNAME_DONTHIDEDISABLEDENTRIES "DontHideDisabledEntry"
# define PROPERTYNAME_FOLLOWMOUSE "FollowMouse"
# define PROPERTYNAME_SHOWICONSINMENUES "ShowIconsInMenues"
# define PROPERTYNAME_SYSTEMICONSINMENUES "IsSystemIconsInMenus"
2000-11-06 08:46:14 +00:00
# define PROPERTYHANDLE_DONTHIDEDISABLEDENTRIES 0
# define PROPERTYHANDLE_FOLLOWMOUSE 1
2001-07-02 10:07:53 +00:00
# define PROPERTYHANDLE_SHOWICONSINMENUES 2
2009-04-14 17:47:15 +00:00
# define PROPERTYHANDLE_SYSTEMICONSINMENUES 3
2000-11-06 08:46:14 +00:00
2009-04-14 17:47:15 +00:00
# define PROPERTYCOUNT 4
2001-07-02 10:07:53 +00:00
# include <tools/link.hxx>
2000-11-06 08:46:14 +00:00
2014-02-22 21:20:15 +01:00
2000-11-06 08:46:14 +00:00
// private declarations!
2014-02-22 21:20:15 +01:00
2000-11-06 08:46:14 +00:00
class SvtMenuOptions_Impl : public ConfigItem
{
2014-02-22 21:20:15 +01:00
2001-05-14 09:48:08 +00:00
// private member
2014-02-22 21:20:15 +01:00
2001-05-14 09:48:08 +00:00
private :
2015-04-30 10:20:00 +02:00
: : std : : list < Link < > > aList ;
2014-03-20 16:41:09 +02:00
bool m_bDontHideDisabledEntries ; /// cache "DontHideDisabledEntries" of Menu section
bool m_bFollowMouse ; /// cache "FollowMouse" of Menu section
2014-02-24 11:57:23 +00:00
TriState m_eMenuIcons ; /// cache "MenuIcons" of Menu section
2001-05-14 09:48:08 +00:00
2014-02-22 21:20:15 +01:00
2000-11-06 08:46:14 +00:00
// public methods
2014-02-22 21:20:15 +01:00
2000-11-06 08:46:14 +00:00
public :
2014-02-22 21:20:15 +01:00
2000-11-06 08:46:14 +00:00
// constructor / destructor
2014-02-22 21:20:15 +01:00
2000-11-06 08:46:14 +00:00
SvtMenuOptions_Impl ( ) ;
2014-04-01 19:18:35 +02:00
virtual ~ SvtMenuOptions_Impl ( ) ;
2000-11-06 08:46:14 +00:00
2015-04-30 10:20:00 +02:00
void AddListenerLink ( const Link < > & rLink ) ;
void RemoveListenerLink ( const Link < > & rLink ) ;
2001-07-02 10:07:53 +00:00
2014-02-22 21:20:15 +01:00
2015-01-08 23:08:34 +01:00
// override methods of baseclass
2014-02-22 21:20:15 +01:00
2000-11-06 08:46:14 +00:00
2014-02-25 20:45:41 +01:00
/*-****************************************************************************************************
2000-11-06 08:46:14 +00:00
@ short called for notify of configmanager
@ descr These method is called from the ConfigManager before application ends or from the
PropertyChangeListener if the sub tree broadcasts changes . You must update your
internal values .
@ seealso baseclass ConfigItem
@ param " seqPropertyNames " is the list of properties which should be updated .
*/ /*-*****************************************************************************************************/
2014-03-26 16:37:00 +01:00
virtual void Notify ( const Sequence < OUString > & seqPropertyNames ) SAL_OVERRIDE ;
2000-11-06 08:46:14 +00:00
// public interface
2014-02-22 21:20:15 +01:00
2000-11-06 08:46:14 +00:00
2014-02-25 20:45:41 +01:00
/*-****************************************************************************************************
2000-11-06 08:46:14 +00:00
@ short access method to get internal values
2011-02-12 21:19:41 +01:00
@ descr These methods give us a chance to regulate access to our internal values .
It ' s not used in the moment - but it ' s possible for the future !
2000-11-06 08:46:14 +00:00
*/ /*-*****************************************************************************************************/
2014-03-20 16:41:09 +02:00
bool IsEntryHidingEnabled ( ) const
2001-05-14 09:48:08 +00:00
{ return m_bDontHideDisabledEntries ; }
2014-02-24 11:57:23 +00:00
TriState GetMenuIconsState ( ) const
{ return m_eMenuIcons ; }
2001-05-14 09:48:08 +00:00
2014-02-24 11:57:23 +00:00
void SetMenuIconsState ( TriState eState )
2001-07-02 10:07:53 +00:00
{
2014-02-24 11:57:23 +00:00
m_eMenuIcons = eState ;
2001-07-02 10:07:53 +00:00
SetModified ( ) ;
2015-04-30 10:20:00 +02:00
for ( : : std : : list < Link < > > : : const_iterator iter = aList . begin ( ) ; iter ! = aList . end ( ) ; + + iter )
2011-02-01 01:32:54 -05:00
iter - > Call ( this ) ;
2002-12-13 06:45:00 +00:00
Commit ( ) ;
2001-07-02 10:07:53 +00:00
}
2000-11-06 08:46:14 +00:00
2014-02-22 21:20:15 +01:00
2000-11-06 08:46:14 +00:00
// private methods
2014-02-22 21:20:15 +01:00
2000-11-06 08:46:14 +00:00
private :
2015-03-11 16:14:47 +01:00
virtual void ImplCommit ( ) SAL_OVERRIDE ;
2014-02-25 20:45:41 +01:00
/*-****************************************************************************************************
2011-02-12 21:19:41 +01:00
@ short return list of fix key names of our configuration management which represent our module tree
2000-11-06 08:46:14 +00:00
@ descr These methods return a static const list of key names . We need it to get needed values from our
configuration management .
@ return A list of needed configuration keys is returned .
*/ /*-*****************************************************************************************************/
static Sequence < OUString > impl_GetPropertyNames ( ) ;
} ;
2014-02-25 20:45:41 +01:00
2000-11-06 08:46:14 +00:00
// constructor
2014-02-25 20:45:41 +01:00
2000-11-06 08:46:14 +00:00
SvtMenuOptions_Impl : : SvtMenuOptions_Impl ( )
// Init baseclasses first
: ConfigItem ( ROOTNODE_MENU )
// Init member then.
, m_bDontHideDisabledEntries ( DEFAULT_DONTHIDEDISABLEDENTRIES )
, m_bFollowMouse ( DEFAULT_FOLLOWMOUSE )
2014-02-24 11:57:23 +00:00
, m_eMenuIcons ( DEFAULT_MENUICONS )
2000-11-06 08:46:14 +00:00
{
// Use our static list of configuration keys to get his values.
Sequence < OUString > seqNames = impl_GetPropertyNames ( ) ;
Sequence < Any > seqValues = GetProperties ( seqNames ) ;
// Safe impossible cases.
// We need values from ALL configuration keys.
// Follow assignment use order of values in relation to our list of key names!
DBG_ASSERT ( ! ( seqNames . getLength ( ) ! = seqValues . getLength ( ) ) , " SvtMenuOptions_Impl::SvtMenuOptions_Impl() \n I miss some values of configuration keys! \n " ) ;
2014-03-20 16:41:09 +02:00
bool bMenuIcons = true ;
bool bSystemMenuIcons = true ;
2014-02-24 11:57:23 +00:00
if ( m_eMenuIcons = = TRISTATE_INDET )
2014-03-20 16:41:09 +02:00
bMenuIcons = Application : : GetSettings ( ) . GetStyleSettings ( ) . GetPreferredUseImagesInMenus ( ) ;
2010-10-01 20:40:46 +01:00
else
{
2014-03-20 16:41:09 +02:00
bSystemMenuIcons = false ;
2015-04-24 12:33:43 +02:00
bMenuIcons = m_eMenuIcons ! = TRISTATE_FALSE ;
2010-10-01 20:40:46 +01:00
}
2009-04-14 17:47:15 +00:00
2011-02-12 21:19:41 +01:00
// Copy values from list in right order to our internal member.
2000-11-06 08:46:14 +00:00
sal_Int32 nPropertyCount = seqValues . getLength ( ) ;
sal_Int32 nProperty = 0 ;
for ( nProperty = 0 ; nProperty < nPropertyCount ; + + nProperty )
{
// Safe impossible cases.
// Check any for valid value.
2014-01-21 17:59:02 +01:00
DBG_ASSERT ( seqValues [ nProperty ] . hasValue ( ) , " SvtMenuOptions_Impl::SvtMenuOptions_Impl() \n Invalid property value for property detected! \n " ) ;
2011-05-16 15:33:16 +01:00
if ( ! seqValues [ nProperty ] . hasValue ( ) )
continue ;
2000-11-06 08:46:14 +00:00
switch ( nProperty )
{
case PROPERTYHANDLE_DONTHIDEDISABLEDENTRIES : {
DBG_ASSERT ( ! ( seqValues [ nProperty ] . getValueTypeClass ( ) ! = TypeClass_BOOLEAN ) , " SvtMenuOptions_Impl::SvtMenuOptions_Impl() \n Who has changed the value type of \" Office.Common \\ View \\ Menu \\ DontHideDisabledEntry \" ? " ) ;
seqValues [ nProperty ] > > = m_bDontHideDisabledEntries ;
}
break ;
case PROPERTYHANDLE_FOLLOWMOUSE : {
DBG_ASSERT ( ! ( seqValues [ nProperty ] . getValueTypeClass ( ) ! = TypeClass_BOOLEAN ) , " SvtMenuOptions_Impl::SvtMenuOptions_Impl() \n Who has changed the value type of \" Office.Common \\ View \\ Menu \\ FollowMouse \" ? " ) ;
seqValues [ nProperty ] > > = m_bFollowMouse ;
}
break ;
2001-07-02 10:07:53 +00:00
case PROPERTYHANDLE_SHOWICONSINMENUES : {
DBG_ASSERT ( ! ( seqValues [ nProperty ] . getValueTypeClass ( ) ! = TypeClass_BOOLEAN ) , " SvtMenuOptions_Impl::SvtMenuOptions_Impl() \n Who has changed the value type of \" Office.Common \\ View \\ Menu \\ ShowIconsInMenues \" ? " ) ;
2009-04-14 17:47:15 +00:00
seqValues [ nProperty ] > > = bMenuIcons ;
}
break ;
case PROPERTYHANDLE_SYSTEMICONSINMENUES : {
DBG_ASSERT ( ! ( seqValues [ nProperty ] . getValueTypeClass ( ) ! = TypeClass_BOOLEAN ) , " SvtMenuOptions_Impl::SvtMenuOptions_Impl() \n Who has changed the value type of \" Office.Common \\ View \\ Menu \\ IsSystemIconsInMenus \" ? " ) ;
seqValues [ nProperty ] > > = bSystemMenuIcons ;
2001-07-02 10:07:53 +00:00
}
break ;
2000-11-06 08:46:14 +00:00
}
}
2014-02-24 11:57:23 +00:00
m_eMenuIcons = bSystemMenuIcons ? TRISTATE_INDET : static_cast < TriState > ( bMenuIcons ) ;
2009-04-14 17:47:15 +00:00
2000-11-06 08:46:14 +00:00
EnableNotification ( seqNames ) ;
}
2014-02-25 20:45:41 +01:00
2000-11-06 08:46:14 +00:00
// destructor
2014-02-25 20:45:41 +01:00
2000-11-06 08:46:14 +00:00
SvtMenuOptions_Impl : : ~ SvtMenuOptions_Impl ( )
{
2015-03-11 16:39:24 +01:00
assert ( ! IsModified ( ) ) ; // should have been committed
2000-11-06 08:46:14 +00:00
}
2014-02-25 20:45:41 +01:00
2000-11-06 08:46:14 +00:00
// public method
2014-02-25 20:45:41 +01:00
2000-11-06 08:46:14 +00:00
void SvtMenuOptions_Impl : : Notify ( const Sequence < OUString > & seqPropertyNames )
{
// Use given list of updated properties to get his values from configuration directly!
Sequence < Any > seqValues = GetProperties ( seqPropertyNames ) ;
// Safe impossible cases.
// We need values from ALL notified configuration keys.
DBG_ASSERT ( ! ( seqPropertyNames . getLength ( ) ! = seqValues . getLength ( ) ) , " SvtMenuOptions_Impl::Notify() \n I miss some values of configuration keys! \n " ) ;
2009-04-14 17:47:15 +00:00
2014-01-22 14:58:57 +01:00
bool bMenuSettingsChanged = false ;
2014-03-20 16:41:09 +02:00
bool bMenuIcons = true ;
bool bSystemMenuIcons = true ;
2014-02-24 11:57:23 +00:00
if ( m_eMenuIcons = = TRISTATE_INDET )
2014-03-20 16:41:09 +02:00
bMenuIcons = Application : : GetSettings ( ) . GetStyleSettings ( ) . GetUseImagesInMenus ( ) ;
2010-07-30 12:58:40 +01:00
else
{
2014-03-20 16:41:09 +02:00
bSystemMenuIcons = false ;
2015-04-24 12:33:43 +02:00
bMenuIcons = m_eMenuIcons ! = TRISTATE_FALSE ;
2010-07-30 12:58:40 +01:00
}
2009-04-14 17:47:15 +00:00
2000-11-06 08:46:14 +00:00
// Step over list of property names and get right value from coreesponding value list to set it on internal members!
sal_Int32 nCount = seqPropertyNames . getLength ( ) ;
for ( sal_Int32 nProperty = 0 ; nProperty < nCount ; + + nProperty )
{
if ( seqPropertyNames [ nProperty ] = = PROPERTYNAME_DONTHIDEDISABLEDENTRIES )
{
DBG_ASSERT ( ! ( seqValues [ nProperty ] . getValueTypeClass ( ) ! = TypeClass_BOOLEAN ) , " SvtMenuOptions_Impl::Notify() \n Who has changed the value type of \" Office.Common \\ View \\ Menu \\ DontHideDisabledEntry \" ? " ) ;
seqValues [ nProperty ] > > = m_bDontHideDisabledEntries ;
}
2009-04-14 17:47:15 +00:00
else if ( seqPropertyNames [ nProperty ] = = PROPERTYNAME_FOLLOWMOUSE )
2000-11-06 08:46:14 +00:00
{
DBG_ASSERT ( ! ( seqValues [ nProperty ] . getValueTypeClass ( ) ! = TypeClass_BOOLEAN ) , " SvtMenuOptions_Impl::Notify() \n Who has changed the value type of \" Office.Common \\ View \\ Menu \\ FollowMouse \" ? " ) ;
seqValues [ nProperty ] > > = m_bFollowMouse ;
}
2009-04-14 17:47:15 +00:00
else if ( seqPropertyNames [ nProperty ] = = PROPERTYNAME_SHOWICONSINMENUES )
2001-07-02 10:07:53 +00:00
{
DBG_ASSERT ( ! ( seqValues [ nProperty ] . getValueTypeClass ( ) ! = TypeClass_BOOLEAN ) , " SvtMenuOptions_Impl::SvtMenuOptions_Impl() \n Who has changed the value type of \" Office.Common \\ View \\ Menu \\ ShowIconsInMenues \" ? " ) ;
2010-10-01 20:40:46 +01:00
bMenuSettingsChanged | = seqValues [ nProperty ] > > = bMenuIcons ;
2001-07-02 10:07:53 +00:00
}
2009-04-14 17:47:15 +00:00
else if ( seqPropertyNames [ nProperty ] = = PROPERTYNAME_SYSTEMICONSINMENUES )
{
DBG_ASSERT ( ! ( seqValues [ nProperty ] . getValueTypeClass ( ) ! = TypeClass_BOOLEAN ) , " SvtMenuOptions_Impl::SvtMenuOptions_Impl() \n Who has changed the value type of \" Office.Common \\ View \\ Menu \\ IsSystemIconsInMenus \" ? " ) ;
2010-10-01 20:40:46 +01:00
bMenuSettingsChanged | = seqValues [ nProperty ] > > = bSystemMenuIcons ;
2009-04-14 17:47:15 +00:00
}
2003-04-15 16:52:06 +00:00
# if OSL_DEBUG_LEVEL > 1
2013-03-22 22:11:49 +08:00
else DBG_ASSERT ( sal_False , " SvtMenuOptions_Impl::Notify() \ nUnknown property detected . . . I can ' t handle these ! \ n " ) ;
2000-11-06 08:46:14 +00:00
# endif
}
2001-07-02 10:07:53 +00:00
2010-07-21 10:20:25 +02:00
if ( bMenuSettingsChanged )
2014-02-24 11:57:23 +00:00
m_eMenuIcons = bSystemMenuIcons ? TRISTATE_INDET : static_cast < TriState > ( bMenuIcons ) ;
2009-04-14 17:47:15 +00:00
2015-04-30 10:20:00 +02:00
for ( : : std : : list < Link < > > : : const_iterator iter = aList . begin ( ) ; iter ! = aList . end ( ) ; + + iter )
2011-02-01 01:32:54 -05:00
iter - > Call ( this ) ;
2000-11-06 08:46:14 +00:00
}
2014-02-25 20:45:41 +01:00
2000-11-06 08:46:14 +00:00
// public method
2014-02-25 20:45:41 +01:00
2015-03-11 16:14:47 +01:00
void SvtMenuOptions_Impl : : ImplCommit ( )
2000-11-06 08:46:14 +00:00
{
// Get names of supported properties, create a list for values and copy current values to it.
Sequence < OUString > seqNames = impl_GetPropertyNames ( ) ;
sal_Int32 nCount = seqNames . getLength ( ) ;
Sequence < Any > seqValues ( nCount ) ;
for ( sal_Int32 nProperty = 0 ; nProperty < nCount ; + + nProperty )
{
switch ( nProperty )
{
case PROPERTYHANDLE_DONTHIDEDISABLEDENTRIES : {
seqValues [ nProperty ] < < = m_bDontHideDisabledEntries ;
}
break ;
case PROPERTYHANDLE_FOLLOWMOUSE : {
seqValues [ nProperty ] < < = m_bFollowMouse ;
}
break ;
2009-04-14 17:47:15 +00:00
//Output cache of current setting as possibly modified by System Theme for older version
2001-07-02 10:07:53 +00:00
case PROPERTYHANDLE_SHOWICONSINMENUES : {
2014-05-08 11:42:56 +02:00
bool bValue = Application : : GetSettings ( ) . GetStyleSettings ( ) . GetUseImagesInMenus ( ) ;
2010-07-21 10:20:25 +02:00
seqValues [ nProperty ] < < = bValue ;
2009-04-14 17:47:15 +00:00
}
break ;
case PROPERTYHANDLE_SYSTEMICONSINMENUES : {
2014-05-08 11:42:56 +02:00
bool bValue = m_eMenuIcons = = TRISTATE_INDET ;
2010-07-21 10:20:25 +02:00
seqValues [ nProperty ] < < = bValue ;
2001-07-02 10:07:53 +00:00
}
break ;
2000-11-06 08:46:14 +00:00
}
}
// Set properties in configuration.
PutProperties ( seqNames , seqValues ) ;
}
2014-02-25 20:45:41 +01:00
2000-11-06 08:46:14 +00:00
// private method
2014-02-25 20:45:41 +01:00
2000-11-06 08:46:14 +00:00
Sequence < OUString > SvtMenuOptions_Impl : : impl_GetPropertyNames ( )
{
// Build static list of configuration key names.
static const OUString pProperties [ ] =
{
2014-12-18 20:45:06 -05:00
OUString ( PROPERTYNAME_DONTHIDEDISABLEDENTRIES ) ,
OUString ( PROPERTYNAME_FOLLOWMOUSE ) ,
OUString ( PROPERTYNAME_SHOWICONSINMENUES ) ,
OUString ( PROPERTYNAME_SYSTEMICONSINMENUES )
2000-11-06 08:46:14 +00:00
} ;
// Initialize return sequence with these list ...
static const Sequence < OUString > seqPropertyNames ( pProperties , PROPERTYCOUNT ) ;
// ... and return it.
return seqPropertyNames ;
}
2015-04-30 10:20:00 +02:00
void SvtMenuOptions_Impl : : AddListenerLink ( const Link < > & rLink )
2001-07-02 10:07:53 +00:00
{
2011-02-01 01:32:54 -05:00
aList . push_back ( rLink ) ;
2001-07-02 10:07:53 +00:00
}
2015-04-30 10:20:00 +02:00
void SvtMenuOptions_Impl : : RemoveListenerLink ( const Link < > & rLink )
2001-07-02 10:07:53 +00:00
{
2015-04-30 10:20:00 +02:00
for ( : : std : : list < Link < > > : : iterator iter = aList . begin ( ) ; iter ! = aList . end ( ) ; + + iter )
2001-07-02 10:07:53 +00:00
{
2011-02-01 01:32:54 -05:00
if ( * iter = = rLink )
2001-07-02 10:07:53 +00:00
{
2011-02-01 01:32:54 -05:00
aList . erase ( iter ) ;
2001-07-02 10:07:53 +00:00
break ;
}
}
}
2014-02-25 20:45:41 +01:00
2000-11-06 08:46:14 +00:00
// initialize static member
// DON'T DO IT IN YOUR HEADER!
2013-04-15 04:49:39 +02:00
// see definition for further information
2014-02-25 20:45:41 +01:00
2000-11-06 08:46:14 +00:00
SvtMenuOptions_Impl * SvtMenuOptions : : m_pDataContainer = NULL ;
sal_Int32 SvtMenuOptions : : m_nRefCount = 0 ;
2014-02-25 20:45:41 +01:00
2000-11-06 08:46:14 +00:00
// constructor
2014-02-25 20:45:41 +01:00
2000-11-06 08:46:14 +00:00
SvtMenuOptions : : SvtMenuOptions ( )
{
// Global access, must be guarded (multithreading!).
MutexGuard aGuard ( GetOwnStaticMutex ( ) ) ;
2011-02-12 21:19:41 +01:00
// Increase our refcount ...
2000-11-06 08:46:14 +00:00
+ + m_nRefCount ;
2011-02-12 21:19:41 +01:00
// ... and initialize our data container only if it not already!
2000-11-06 08:46:14 +00:00
if ( m_pDataContainer = = NULL )
{
m_pDataContainer = new SvtMenuOptions_Impl ( ) ;
2004-11-15 16:22:20 +00:00
2011-08-18 13:03:05 +02:00
svtools : : ItemHolder2 : : holdConfigItem ( E_MENUOPTIONS ) ;
2000-11-06 08:46:14 +00:00
}
}
2014-02-25 20:45:41 +01:00
2000-11-06 08:46:14 +00:00
// destructor
2014-02-25 20:45:41 +01:00
2000-11-06 08:46:14 +00:00
SvtMenuOptions : : ~ SvtMenuOptions ( )
{
// Global access, must be guarded (multithreading!)
MutexGuard aGuard ( GetOwnStaticMutex ( ) ) ;
2011-02-12 21:19:41 +01:00
// Decrease our refcount.
2000-11-06 08:46:14 +00:00
- - m_nRefCount ;
// If last instance was deleted ...
2011-02-12 21:19:41 +01:00
// we must destroy our static data container!
2000-11-06 08:46:14 +00:00
if ( m_nRefCount < = 0 )
{
delete m_pDataContainer ;
m_pDataContainer = NULL ;
}
}
2014-02-25 20:45:41 +01:00
2000-11-06 08:46:14 +00:00
// public method
2014-02-25 20:45:41 +01:00
2014-03-20 16:41:09 +02:00
bool SvtMenuOptions : : IsEntryHidingEnabled ( ) const
2000-11-06 08:46:14 +00:00
{
MutexGuard aGuard ( GetOwnStaticMutex ( ) ) ;
return m_pDataContainer - > IsEntryHidingEnabled ( ) ;
}
2014-02-25 20:45:41 +01:00
2000-11-06 08:46:14 +00:00
// public method
2014-02-25 20:45:41 +01:00
2014-02-24 11:57:23 +00:00
TriState SvtMenuOptions : : GetMenuIconsState ( ) const
2001-05-14 09:48:08 +00:00
{
MutexGuard aGuard ( GetOwnStaticMutex ( ) ) ;
2009-04-14 17:47:15 +00:00
return m_pDataContainer - > GetMenuIconsState ( ) ;
2001-05-14 09:48:08 +00:00
}
2014-02-25 20:45:41 +01:00
2001-05-14 09:48:08 +00:00
// public method
2014-02-25 20:45:41 +01:00
2014-02-24 11:57:23 +00:00
void SvtMenuOptions : : SetMenuIconsState ( TriState eState )
2001-05-14 09:48:08 +00:00
{
MutexGuard aGuard ( GetOwnStaticMutex ( ) ) ;
2014-02-24 11:57:23 +00:00
m_pDataContainer - > SetMenuIconsState ( eState ) ;
2001-05-14 09:48:08 +00:00
}
2014-02-25 20:45:41 +01:00
2000-11-06 08:46:14 +00:00
// private method
2014-02-25 20:45:41 +01:00
2000-11-06 08:46:14 +00:00
Mutex & SvtMenuOptions : : GetOwnStaticMutex ( )
{
// Initialize static mutex only for one time!
static Mutex * pMutex = NULL ;
// If these method first called (Mutex not already exist!) ...
if ( pMutex = = NULL )
{
// ... we must create a new one. Protect follow code with the global mutex -
// It must be - we create a static variable!
MutexGuard aGuard ( Mutex : : getGlobalMutex ( ) ) ;
2011-02-12 21:19:41 +01:00
// We must check our pointer again - because it can be that another instance of our class will be faster than these!
2000-11-06 08:46:14 +00:00
if ( pMutex = = NULL )
{
// Create the new mutex and set it for return on static variable.
static Mutex aMutex ;
pMutex = & aMutex ;
}
}
// Return new created or already existing mutex object.
return * pMutex ;
}
2001-07-02 10:07:53 +00:00
2015-04-30 10:20:00 +02:00
void SvtMenuOptions : : AddListenerLink ( const Link < > & rLink )
2001-07-02 10:07:53 +00:00
{
2009-11-03 18:41:58 +01:00
m_pDataContainer - > AddListenerLink ( rLink ) ;
2001-07-02 10:07:53 +00:00
}
2015-04-30 10:20:00 +02:00
void SvtMenuOptions : : RemoveListenerLink ( const Link < > & rLink )
2001-07-02 10:07:53 +00:00
{
2009-11-03 18:41:58 +01:00
m_pDataContainer - > RemoveListenerLink ( rLink ) ;
2001-07-02 10:07:53 +00:00
}
2010-10-14 08:27:31 +02:00
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */