LCOV - code coverage report
Current view: top level - libreoffice/svtools/source/config - menuoptions.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 137 0.0 %
Date: 2012-12-27 Functions: 0 21 0.0 %
Legend: Lines: hit not hit

          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             : 
      21             : #include <svtools/menuoptions.hxx>
      22             : #include <unotools/configmgr.hxx>
      23             : #include <unotools/configitem.hxx>
      24             : #include <tools/debug.hxx>
      25             : #include <com/sun/star/uno/Any.hxx>
      26             : #include <com/sun/star/uno/Sequence.hxx>
      27             : #include <vcl/svapp.hxx>
      28             : 
      29             : #include <rtl/logfile.hxx>
      30             : #include "itemholder2.hxx"
      31             : 
      32             : #include <list>
      33             : 
      34             : //_________________________________________________________________________________________________________________
      35             : //  namespaces
      36             : //_________________________________________________________________________________________________________________
      37             : 
      38             : using namespace ::utl                   ;
      39             : using namespace ::rtl                   ;
      40             : using namespace ::osl                   ;
      41             : using namespace ::com::sun::star::uno   ;
      42             : 
      43             : #define ROOTNODE_MENU                           OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/View/Menu"  ))
      44             : #define DEFAULT_DONTHIDEDISABLEDENTRIES         sal_False
      45             : #define DEFAULT_FOLLOWMOUSE                     sal_True
      46             : #define DEFAULT_MENUICONS                       2
      47             : 
      48             : #define PROPERTYNAME_DONTHIDEDISABLEDENTRIES    OUString(RTL_CONSTASCII_USTRINGPARAM("DontHideDisabledEntry"    ))
      49             : #define PROPERTYNAME_FOLLOWMOUSE                OUString(RTL_CONSTASCII_USTRINGPARAM("FollowMouse"              ))
      50             : #define PROPERTYNAME_SHOWICONSINMENUES          OUString(RTL_CONSTASCII_USTRINGPARAM("ShowIconsInMenues"        ))
      51             : #define PROPERTYNAME_SYSTEMICONSINMENUES        OUString(RTL_CONSTASCII_USTRINGPARAM("IsSystemIconsInMenus"     ))
      52             : 
      53             : #define PROPERTYHANDLE_DONTHIDEDISABLEDENTRIES  0
      54             : #define PROPERTYHANDLE_FOLLOWMOUSE              1
      55             : #define PROPERTYHANDLE_SHOWICONSINMENUES        2
      56             : #define PROPERTYHANDLE_SYSTEMICONSINMENUES      3
      57             : 
      58             : #define PROPERTYCOUNT                           4
      59             : 
      60             : #include <tools/link.hxx>
      61             : 
      62             : //_________________________________________________________________________________________________________________
      63             : //  private declarations!
      64             : //_________________________________________________________________________________________________________________
      65             : 
      66             : class SvtMenuOptions_Impl : public ConfigItem
      67             : {
      68             :     //-------------------------------------------------------------------------------------------------------------
      69             :     //  private member
      70             :     //-------------------------------------------------------------------------------------------------------------
      71             : 
      72             :     private:
      73             :         ::std::list<Link> aList;
      74             :         sal_Bool    m_bDontHideDisabledEntries          ;   /// cache "DontHideDisabledEntries" of Menu section
      75             :         sal_Bool    m_bFollowMouse                      ;   /// cache "FollowMouse" of Menu section
      76             :         sal_Int16   m_nMenuIcons                        ;   /// cache "MenuIcons" of Menu section
      77             : 
      78             :     //-------------------------------------------------------------------------------------------------------------
      79             :     //  public methods
      80             :     //-------------------------------------------------------------------------------------------------------------
      81             : 
      82             :     public:
      83             : 
      84             :         //---------------------------------------------------------------------------------------------------------
      85             :         //  constructor / destructor
      86             :         //---------------------------------------------------------------------------------------------------------
      87             : 
      88             :          SvtMenuOptions_Impl();
      89             :         ~SvtMenuOptions_Impl();
      90             : 
      91             :         void AddListenerLink( const Link& rLink );
      92             :         void RemoveListenerLink( const Link& rLink );
      93             : 
      94             :         //---------------------------------------------------------------------------------------------------------
      95             :         //  overloaded methods of baseclass
      96             :         //---------------------------------------------------------------------------------------------------------
      97             : 
      98             :         /*-****************************************************************************************************//**
      99             :             @short      called for notify of configmanager
     100             :             @descr      These method is called from the ConfigManager before application ends or from the
     101             :                          PropertyChangeListener if the sub tree broadcasts changes. You must update your
     102             :                         internal values.
     103             : 
     104             :             @seealso    baseclass ConfigItem
     105             : 
     106             :             @param      "seqPropertyNames" is the list of properties which should be updated.
     107             :             @return     -
     108             : 
     109             :             @onerror    -
     110             :         *//*-*****************************************************************************************************/
     111             : 
     112             :         virtual void Notify( const Sequence< OUString >& seqPropertyNames );
     113             : 
     114             :         /*-****************************************************************************************************//**
     115             :             @short      write changes to configuration
     116             :             @descr      These method writes the changed values into the sub tree
     117             :                         and should always called in our destructor to guarantee consistency of config data.
     118             : 
     119             :             @seealso    baseclass ConfigItem
     120             : 
     121             :             @param      -
     122             :             @return     -
     123             : 
     124             :             @onerror    -
     125             :         *//*-*****************************************************************************************************/
     126             : 
     127             :         virtual void Commit();
     128             : 
     129             :         //---------------------------------------------------------------------------------------------------------
     130             :         //  public interface
     131             :         //---------------------------------------------------------------------------------------------------------
     132             : 
     133             :         /*-****************************************************************************************************//**
     134             :             @short      access method to get internal values
     135             :             @descr      These methods give us a chance to regulate access to our internal values.
     136             :                         It's not used in the moment - but it's possible for the future!
     137             : 
     138             :             @seealso    -
     139             : 
     140             :             @param      -
     141             :             @return     -
     142             : 
     143             :             @onerror    -
     144             :         *//*-*****************************************************************************************************/
     145             : 
     146           0 :         sal_Bool    IsEntryHidingEnabled() const
     147           0 :                     { return m_bDontHideDisabledEntries; }
     148             : 
     149             :         sal_Bool    IsFollowMouseEnabled() const
     150             :                     { return m_bFollowMouse; }
     151             : 
     152           0 :         sal_Int16   GetMenuIconsState() const
     153           0 :                     { return m_nMenuIcons; }
     154             : 
     155             :         void        SetEntryHidingState ( sal_Bool bState )
     156             :                     {
     157             :                         m_bDontHideDisabledEntries = bState;
     158             :                         SetModified();
     159             :                         for ( ::std::list<Link>::const_iterator iter = aList.begin(); iter != aList.end(); ++iter )
     160             :                             iter->Call( this );
     161             :                         Commit();
     162             :                     }
     163             : 
     164             :         void        SetFollowMouseState ( sal_Bool bState )
     165             :                     {
     166             :                         m_bFollowMouse = bState;
     167             :                         SetModified();
     168             :                         for ( ::std::list<Link>::const_iterator iter = aList.begin(); iter != aList.end(); ++iter )
     169             :                             iter->Call( this );
     170             :                         Commit();
     171             :                     }
     172             : 
     173           0 :         void        SetMenuIconsState ( sal_Int16 nState    )
     174             :                     {
     175           0 :                         m_nMenuIcons = nState;
     176           0 :                         SetModified();
     177           0 :                         for ( ::std::list<Link>::const_iterator iter = aList.begin(); iter != aList.end(); ++iter )
     178           0 :                             iter->Call( this );
     179           0 :                         Commit();
     180           0 :                     }
     181             : 
     182             :     //-------------------------------------------------------------------------------------------------------------
     183             :     //  private methods
     184             :     //-------------------------------------------------------------------------------------------------------------
     185             : 
     186             :     private:
     187             : 
     188             :         /*-****************************************************************************************************//**
     189             :             @short      return list of fix key names of our configuration management which represent our module tree
     190             :             @descr      These methods return a static const list of key names. We need it to get needed values from our
     191             :                         configuration management.
     192             : 
     193             :             @seealso    -
     194             : 
     195             :             @param      -
     196             :             @return     A list of needed configuration keys is returned.
     197             : 
     198             :             @onerror    -
     199             :         *//*-*****************************************************************************************************/
     200             : 
     201             :         static Sequence< OUString > impl_GetPropertyNames();
     202             : };
     203             : 
     204             : //*****************************************************************************************************************
     205             : //  constructor
     206             : //*****************************************************************************************************************
     207           0 : SvtMenuOptions_Impl::SvtMenuOptions_Impl()
     208             :     // Init baseclasses first
     209             :     :   ConfigItem                  ( ROOTNODE_MENU                     )
     210             :     // Init member then.
     211             :     ,   m_bDontHideDisabledEntries  ( DEFAULT_DONTHIDEDISABLEDENTRIES   )
     212             :     ,   m_bFollowMouse              ( DEFAULT_FOLLOWMOUSE               )
     213           0 :     ,   m_nMenuIcons                ( DEFAULT_MENUICONS                 )
     214             : {
     215             :     // Use our static list of configuration keys to get his values.
     216           0 :     Sequence< OUString >    seqNames    = impl_GetPropertyNames();
     217           0 :     Sequence< Any >         seqValues   = GetProperties( seqNames ) ;
     218             : 
     219             :     // Safe impossible cases.
     220             :     // We need values from ALL configuration keys.
     221             :     // Follow assignment use order of values in relation to our list of key names!
     222             :     DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nI miss some values of configuration keys!\n" );
     223             : 
     224           0 :     sal_Bool bMenuIcons = sal_True;
     225           0 :     sal_Bool bSystemMenuIcons = sal_True;
     226           0 :     if (m_nMenuIcons == 2)
     227           0 :         bMenuIcons = (sal_Bool)(Application::GetSettings().GetStyleSettings().GetPreferredUseImagesInMenus());
     228             :     else
     229             :     {
     230           0 :         bSystemMenuIcons = sal_False;
     231           0 :         bMenuIcons = m_nMenuIcons ? sal_True : sal_False;
     232             :     }
     233             : 
     234             :     // Copy values from list in right order to our internal member.
     235           0 :     sal_Int32 nPropertyCount    =   seqValues.getLength()   ;
     236           0 :     sal_Int32 nProperty         =   0                       ;
     237           0 :     for( nProperty=0; nProperty<nPropertyCount; ++nProperty )
     238             :     {
     239             :         // Safe impossible cases.
     240             :         // Check any for valid value.
     241             :         DBG_ASSERT( !(seqValues[nProperty].hasValue()==sal_False), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nInvalid property value for property detected!\n" );
     242             : 
     243           0 :         if (!seqValues[nProperty].hasValue())
     244           0 :             continue;
     245             : 
     246           0 :         switch( nProperty )
     247             :         {
     248             :             case PROPERTYHANDLE_DONTHIDEDISABLEDENTRIES :   {
     249             :                                                                 DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Menu\\DontHideDisabledEntry\"?" );
     250           0 :                                                                 seqValues[nProperty] >>= m_bDontHideDisabledEntries;
     251             :                                                             }
     252           0 :                                                             break;
     253             : 
     254             :             case PROPERTYHANDLE_FOLLOWMOUSE             :   {
     255             :                                                                 DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Menu\\FollowMouse\"?" );
     256           0 :                                                                 seqValues[nProperty] >>= m_bFollowMouse;
     257             :                                                             }
     258           0 :                                                             break;
     259             :             case PROPERTYHANDLE_SHOWICONSINMENUES       :   {
     260             :                                                                 DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Menu\\ShowIconsInMenues\"?" );
     261           0 :                                                                 seqValues[nProperty] >>= bMenuIcons;
     262             :                                                             }
     263           0 :                                                             break;
     264             :             case PROPERTYHANDLE_SYSTEMICONSINMENUES     :   {
     265             :                                                                 DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Menu\\IsSystemIconsInMenus\"?" );
     266           0 :                                                                 seqValues[nProperty] >>= bSystemMenuIcons;
     267             :                                                             }
     268           0 :                                                             break;
     269             :         }
     270             :     }
     271             : 
     272           0 :     m_nMenuIcons = bSystemMenuIcons ? 2 : bMenuIcons;
     273             : 
     274           0 :     EnableNotification( seqNames );
     275           0 : }
     276             : 
     277             : //*****************************************************************************************************************
     278             : //  destructor
     279             : //*****************************************************************************************************************
     280           0 : SvtMenuOptions_Impl::~SvtMenuOptions_Impl()
     281             : {
     282             :     // Flush data to configuration!
     283             :     // User has no chance to do that.
     284           0 :     if( IsModified() == sal_True )
     285             :     {
     286           0 :         Commit();
     287             :     }
     288           0 : }
     289             : 
     290             : //*****************************************************************************************************************
     291             : //  public method
     292             : //*****************************************************************************************************************
     293           0 : void SvtMenuOptions_Impl::Notify( const Sequence< OUString >& seqPropertyNames )
     294             : {
     295             :     // Use given list of updated properties to get his values from configuration directly!
     296           0 :     Sequence< Any > seqValues = GetProperties( seqPropertyNames );
     297             :     // Safe impossible cases.
     298             :     // We need values from ALL notified configuration keys.
     299             :     DBG_ASSERT( !(seqPropertyNames.getLength()!=seqValues.getLength()), "SvtMenuOptions_Impl::Notify()\nI miss some values of configuration keys!\n" );
     300             : 
     301           0 :     sal_Bool bMenuSettingsChanged = sal_False;
     302           0 :     sal_Bool bMenuIcons = sal_True;
     303           0 :     sal_Bool bSystemMenuIcons = sal_True;
     304           0 :     if (m_nMenuIcons == 2)
     305           0 :         bMenuIcons = (sal_Bool)(Application::GetSettings().GetStyleSettings().GetUseImagesInMenus());
     306             :     else
     307             :     {
     308           0 :         bSystemMenuIcons = sal_False;
     309           0 :         bMenuIcons = m_nMenuIcons ? sal_True : sal_False;
     310             :     }
     311             : 
     312             :     // Step over list of property names and get right value from coreesponding value list to set it on internal members!
     313           0 :     sal_Int32 nCount = seqPropertyNames.getLength();
     314           0 :     for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty )
     315             :     {
     316           0 :         if( seqPropertyNames[nProperty] == PROPERTYNAME_DONTHIDEDISABLEDENTRIES )
     317             :         {
     318             :             DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtMenuOptions_Impl::Notify()\nWho has changed the value type of \"Office.Common\\View\\Menu\\DontHideDisabledEntry\"?" );
     319           0 :             seqValues[nProperty] >>= m_bDontHideDisabledEntries;
     320             :         }
     321           0 :         else if( seqPropertyNames[nProperty] == PROPERTYNAME_FOLLOWMOUSE )
     322             :         {
     323             :             DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtMenuOptions_Impl::Notify()\nWho has changed the value type of \"Office.Common\\View\\Menu\\FollowMouse\"?" );
     324           0 :             seqValues[nProperty] >>= m_bFollowMouse;
     325             :         }
     326           0 :         else if( seqPropertyNames[nProperty] == PROPERTYNAME_SHOWICONSINMENUES )
     327             :         {
     328             :             DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Menu\\ShowIconsInMenues\"?" );
     329           0 :             bMenuSettingsChanged |= seqValues[nProperty] >>= bMenuIcons;
     330             :         }
     331           0 :         else if( seqPropertyNames[nProperty] == PROPERTYNAME_SYSTEMICONSINMENUES )
     332             :         {
     333             :             DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Menu\\IsSystemIconsInMenus\"?" );
     334           0 :             bMenuSettingsChanged |= seqValues[nProperty] >>= bSystemMenuIcons;
     335             :         }
     336             : 
     337             :         #if OSL_DEBUG_LEVEL > 1
     338             :         else DBG_ASSERT( sal_False, "SvtMenuOptions_Impl::Notify()\nUnkown property detected ... I can't handle these!\n" );
     339             :         #endif
     340             :     }
     341             : 
     342           0 :     if ( bMenuSettingsChanged )
     343           0 :         m_nMenuIcons = bSystemMenuIcons ? 2 : bMenuIcons;
     344             : 
     345           0 :     for ( ::std::list<Link>::const_iterator iter = aList.begin(); iter != aList.end(); ++iter )
     346           0 :         iter->Call( this );
     347           0 : }
     348             : 
     349             : //*****************************************************************************************************************
     350             : //  public method
     351             : //*****************************************************************************************************************
     352           0 : void SvtMenuOptions_Impl::Commit()
     353             : {
     354             :     // Get names of supported properties, create a list for values and copy current values to it.
     355           0 :     Sequence< OUString >    seqNames    = impl_GetPropertyNames();
     356           0 :     sal_Int32               nCount      = seqNames.getLength();
     357           0 :     Sequence< Any >         seqValues   ( nCount );
     358           0 :     for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty )
     359             :     {
     360           0 :         switch( nProperty )
     361             :         {
     362             :             case PROPERTYHANDLE_DONTHIDEDISABLEDENTRIES :   {
     363           0 :                                                                 seqValues[nProperty] <<= m_bDontHideDisabledEntries;
     364             :                                                             }
     365           0 :                                                             break;
     366             : 
     367             :             case PROPERTYHANDLE_FOLLOWMOUSE             :   {
     368           0 :                                                                 seqValues[nProperty] <<= m_bFollowMouse;
     369             :                                                             }
     370           0 :                                                             break;
     371             :             //Output cache of current setting as possibly modified by System Theme for older version
     372             :             case PROPERTYHANDLE_SHOWICONSINMENUES       :   {
     373           0 :                                                                 sal_Bool bValue = (sal_Bool)(Application::GetSettings().GetStyleSettings().GetUseImagesInMenus());
     374           0 :                                                                 seqValues[nProperty] <<= bValue;
     375             :                                                             }
     376           0 :                                                             break;
     377             :             case PROPERTYHANDLE_SYSTEMICONSINMENUES     :   {
     378           0 :                                                                 sal_Bool bValue = (m_nMenuIcons == 2 ? sal_True : sal_False) ;
     379           0 :                                                                 seqValues[nProperty] <<= bValue;
     380             :                                                             }
     381           0 :                                                             break;
     382             :         }
     383             :     }
     384             :     // Set properties in configuration.
     385           0 :     PutProperties( seqNames, seqValues );
     386           0 : }
     387             : 
     388             : //*****************************************************************************************************************
     389             : //  private method
     390             : //*****************************************************************************************************************
     391           0 : Sequence< OUString > SvtMenuOptions_Impl::impl_GetPropertyNames()
     392             : {
     393             :     // Build static list of configuration key names.
     394             :     static const OUString pProperties[] =
     395             :     {
     396             :         PROPERTYNAME_DONTHIDEDISABLEDENTRIES    ,
     397             :         PROPERTYNAME_FOLLOWMOUSE                ,
     398             :         PROPERTYNAME_SHOWICONSINMENUES          ,
     399             :         PROPERTYNAME_SYSTEMICONSINMENUES
     400           0 :     };
     401             :     // Initialize return sequence with these list ...
     402           0 :     static const Sequence< OUString > seqPropertyNames( pProperties, PROPERTYCOUNT );
     403             :     // ... and return it.
     404           0 :     return seqPropertyNames;
     405             : }
     406             : 
     407           0 : void SvtMenuOptions_Impl::AddListenerLink( const Link& rLink )
     408             : {
     409           0 :     aList.push_back( rLink );
     410           0 : }
     411             : 
     412           0 : void SvtMenuOptions_Impl::RemoveListenerLink( const Link& rLink )
     413             : {
     414           0 :     for ( ::std::list<Link>::iterator iter = aList.begin(); iter != aList.end(); ++iter )
     415             :     {
     416           0 :         if ( *iter == rLink )
     417             :         {
     418           0 :             aList.erase(iter);
     419           0 :             break;
     420             :         }
     421             :     }
     422           0 : }
     423             : 
     424             : //*****************************************************************************************************************
     425             : //  initialize static member
     426             : //  DON'T DO IT IN YOUR HEADER!
     427             : //  see definition for further informations
     428             : //*****************************************************************************************************************
     429             : SvtMenuOptions_Impl*    SvtMenuOptions::m_pDataContainer    = NULL  ;
     430             : sal_Int32               SvtMenuOptions::m_nRefCount         = 0     ;
     431             : 
     432             : //*****************************************************************************************************************
     433             : //  constructor
     434             : //*****************************************************************************************************************
     435           0 : SvtMenuOptions::SvtMenuOptions()
     436             : {
     437             :     // Global access, must be guarded (multithreading!).
     438           0 :     MutexGuard aGuard( GetOwnStaticMutex() );
     439             :     // Increase our refcount ...
     440           0 :     ++m_nRefCount;
     441             :     // ... and initialize our data container only if it not already!
     442           0 :     if( m_pDataContainer == NULL )
     443             :     {
     444             :         RTL_LOGFILE_CONTEXT(aLog, "svtools ( ??? ) ::SvtMenuOptions_Impl::ctor()");
     445           0 :         m_pDataContainer = new SvtMenuOptions_Impl();
     446             : 
     447           0 :         svtools::ItemHolder2::holdConfigItem(E_MENUOPTIONS);
     448           0 :     }
     449           0 : }
     450             : 
     451             : //*****************************************************************************************************************
     452             : //  destructor
     453             : //*****************************************************************************************************************
     454           0 : SvtMenuOptions::~SvtMenuOptions()
     455             : {
     456             :     // Global access, must be guarded (multithreading!)
     457           0 :     MutexGuard aGuard( GetOwnStaticMutex() );
     458             :     // Decrease our refcount.
     459           0 :     --m_nRefCount;
     460             :     // If last instance was deleted ...
     461             :     // we must destroy our static data container!
     462           0 :     if( m_nRefCount <= 0 )
     463             :     {
     464           0 :         delete m_pDataContainer;
     465           0 :         m_pDataContainer = NULL;
     466           0 :     }
     467           0 : }
     468             : 
     469             : //*****************************************************************************************************************
     470             : //  public method
     471             : //*****************************************************************************************************************
     472           0 : sal_Bool SvtMenuOptions::IsEntryHidingEnabled() const
     473             : {
     474           0 :     MutexGuard aGuard( GetOwnStaticMutex() );
     475           0 :     return m_pDataContainer->IsEntryHidingEnabled();
     476             : }
     477             : 
     478             : //*****************************************************************************************************************
     479             : //  public method
     480             : //*****************************************************************************************************************
     481           0 : sal_Int16 SvtMenuOptions::GetMenuIconsState() const
     482             : {
     483           0 :     MutexGuard aGuard( GetOwnStaticMutex() );
     484           0 :     return m_pDataContainer->GetMenuIconsState();
     485             : }
     486             : 
     487             : //*****************************************************************************************************************
     488             : //  public method
     489             : //*****************************************************************************************************************
     490           0 : void SvtMenuOptions::SetMenuIconsState( sal_Int16 bState )
     491             : {
     492           0 :     MutexGuard aGuard( GetOwnStaticMutex() );
     493           0 :     m_pDataContainer->SetMenuIconsState( bState );
     494           0 : }
     495             : 
     496             : //*****************************************************************************************************************
     497             : //  private method
     498             : //*****************************************************************************************************************
     499           0 : Mutex& SvtMenuOptions::GetOwnStaticMutex()
     500             : {
     501             :     // Initialize static mutex only for one time!
     502             :     static Mutex* pMutex = NULL;
     503             :     // If these method first called (Mutex not already exist!) ...
     504           0 :     if( pMutex == NULL )
     505             :     {
     506             :         // ... we must create a new one. Protect follow code with the global mutex -
     507             :         // It must be - we create a static variable!
     508           0 :         MutexGuard aGuard( Mutex::getGlobalMutex() );
     509             :         // We must check our pointer again - because it can be that another instance of our class will be faster than these!
     510           0 :         if( pMutex == NULL )
     511             :         {
     512             :             // Create the new mutex and set it for return on static variable.
     513           0 :             static Mutex aMutex;
     514           0 :             pMutex = &aMutex;
     515           0 :         }
     516             :     }
     517             :     // Return new created or already existing mutex object.
     518           0 :     return *pMutex;
     519             : }
     520             : 
     521           0 : void SvtMenuOptions::AddListenerLink( const Link& rLink )
     522             : {
     523           0 :     m_pDataContainer->AddListenerLink( rLink );
     524           0 : }
     525             : 
     526           0 : void SvtMenuOptions::RemoveListenerLink( const Link& rLink )
     527             : {
     528           0 :     m_pDataContainer->RemoveListenerLink( rLink );
     529           0 : }
     530             : 
     531             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10