LCOV - code coverage report
Current view: top level - libreoffice/svtools/source/config - miscopt.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 198 302 65.6 %
Date: 2012-12-17 Functions: 35 68 51.5 %
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             : #include <svtools/miscopt.hxx>
      21             : #include <unotools/configmgr.hxx>
      22             : #include <unotools/configitem.hxx>
      23             : #include <tools/debug.hxx>
      24             : #include <com/sun/star/uno/Any.hxx>
      25             : #include <com/sun/star/uno/Sequence.hxx>
      26             : #include <tools/link.hxx>
      27             : 
      28             : #include <rtl/logfile.hxx>
      29             : #include <rtl/instance.hxx>
      30             : #include "itemholder2.hxx"
      31             : 
      32             : #include <svtools/imgdef.hxx>
      33             : #include <vcl/svapp.hxx>
      34             : 
      35             : #include <list>
      36             : 
      37             : using namespace ::utl                   ;
      38             : using namespace ::rtl                   ;
      39             : using namespace ::osl                   ;
      40             : using namespace ::com::sun::star::uno   ;
      41             : using namespace ::com::sun::star;
      42             : 
      43             : #define ASCII_STR(s)                        OUString( RTL_CONSTASCII_USTRINGPARAM(s) )
      44             : #define ROOTNODE_MISC                       ASCII_STR("Office.Common/Misc")
      45             : 
      46             : #define PROPERTYNAME_PLUGINSENABLED         ASCII_STR("PluginsEnabled")
      47             : #define PROPERTYHANDLE_PLUGINSENABLED       0
      48             : #define PROPERTYNAME_SYMBOLSET              ASCII_STR("SymbolSet")
      49             : #define PROPERTYHANDLE_SYMBOLSET            1
      50             : #define PROPERTYNAME_TOOLBOXSTYLE           ASCII_STR("ToolboxStyle")
      51             : #define PROPERTYHANDLE_TOOLBOXSTYLE         2
      52             : #define PROPERTYNAME_USESYSTEMFILEDIALOG    ASCII_STR("UseSystemFileDialog")
      53             : #define PROPERTYHANDLE_USESYSTEMFILEDIALOG  3
      54             : #define PROPERTYNAME_SYMBOLSTYLE            ASCII_STR("SymbolStyle")
      55             : #define PROPERTYHANDLE_SYMBOLSTYLE          4
      56             : #define PROPERTYNAME_USESYSTEMPRINTDIALOG   ASCII_STR("UseSystemPrintDialog")
      57             : #define PROPERTYHANDLE_USESYSTEMPRINTDIALOG 5
      58             : #define PROPERTYNAME_SHOWLINKWARNINGDIALOG  ASCII_STR("ShowLinkWarningDialog")
      59             : #define PROPERTYHANDLE_SHOWLINKWARNINGDIALOG 7
      60             : #define PROPERTYNAME_DISABLEUICUSTOMIZATION ASCII_STR("DisableUICustomization")
      61             : #define PROPERTYHANDLE_DISABLEUICUSTOMIZATION           8
      62             : #define PROPERTYNAME_ALWAYSALLOWSAVE        ASCII_STR("AlwaysAllowSave")
      63             : #define PROPERTYHANDLE_ALWAYSALLOWSAVE      9
      64             : #define PROPERTYNAME_EXPERIMENTALMODE       ASCII_STR("ExperimentalMode")
      65             : #define PROPERTYHANDLE_EXPERIMENTALMODE     10
      66             : #define PROPERTYNAME_MACRORECORDERMODE       ASCII_STR("MacroRecorderMode")
      67             : #define PROPERTYHANDLE_MACRORECORDERMODE    11
      68             : 
      69             : #define VCL_TOOLBOX_STYLE_FLAT              ((sal_uInt16)0x0004) // from <vcl/toolbox.hxx>
      70             : 
      71             : class SvtMiscOptions_Impl : public ConfigItem
      72             : {
      73             :     private:
      74             :     ::std::list<Link> aList;
      75             :     sal_Bool    m_bUseSystemFileDialog;
      76             :     sal_Bool    m_bIsUseSystemFileDialogRO;
      77             :     sal_Bool    m_bPluginsEnabled;
      78             :     sal_Bool    m_bIsPluginsEnabledRO;
      79             :     sal_Int16   m_nSymbolsSize;
      80             :     sal_Bool    m_bIsSymbolsSizeRO;
      81             :     sal_Bool    m_bIsSymbolsStyleRO;
      82             :     sal_Int16   m_nToolboxStyle;
      83             :     sal_Bool    m_bIsToolboxStyleRO;
      84             :     sal_Bool    m_bUseSystemPrintDialog;
      85             :     sal_Bool    m_bIsUseSystemPrintDialogRO;
      86             :     sal_Bool    m_bShowLinkWarningDialog;
      87             :     sal_Bool    m_bIsShowLinkWarningDialogRO;
      88             :     sal_Bool    m_bDisableUICustomization;
      89             :     sal_Bool    m_bAlwaysAllowSave;
      90             :     sal_Bool    m_bExperimentalMode;
      91             :     sal_Bool    m_bMacroRecorderMode;
      92             : 
      93             :     public:
      94             : 
      95             :          SvtMiscOptions_Impl();
      96             :         ~SvtMiscOptions_Impl();
      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             :         /** loads required data from the configuration. It's called in the constructor to
     115             :          read all entries and form ::Notify to re-read changed settings
     116             : 
     117             :          */
     118             :         void Load( const Sequence< OUString >& rPropertyNames );
     119             : 
     120             :         /*-****************************************************************************************************//**
     121             :             @short      write changes to configuration
     122             :             @descr      These method writes the changed values into the sub tree
     123             :                         and should always called in our destructor to guarantee consistency of config data.
     124             : 
     125             :             @seealso    baseclass ConfigItem
     126             : 
     127             :             @param      -
     128             :             @return     -
     129             : 
     130             :             @onerror    -
     131             :         *//*-*****************************************************************************************************/
     132             : 
     133             :         virtual void Commit();
     134             : 
     135             :         //---------------------------------------------------------------------------------------------------------
     136             :         //  public interface
     137             :         //---------------------------------------------------------------------------------------------------------
     138             : 
     139           8 :         inline sal_Bool UseSystemFileDialog() const
     140           8 :         { return m_bUseSystemFileDialog; }
     141             : 
     142          16 :         inline void SetUseSystemFileDialog( sal_Bool bSet )
     143          16 :         {  m_bUseSystemFileDialog = bSet; SetModified(); }
     144             : 
     145           0 :         inline sal_Bool IsUseSystemFileDialogReadOnly() const
     146           0 :         { return m_bIsUseSystemFileDialogRO; }
     147             : 
     148         660 :         inline sal_Bool DisableUICustomization() const
     149         660 :         { return m_bDisableUICustomization; }
     150             : 
     151           0 :         inline void SetSaveAlwaysAllowed( sal_Bool bSet )
     152           0 :         { m_bAlwaysAllowSave = bSet; SetModified(); }
     153             : 
     154           7 :         inline sal_Bool IsSaveAlwaysAllowed() const
     155           7 :         { return m_bAlwaysAllowSave; }
     156             : 
     157           0 :         inline void SetExperimentalMode( sal_Bool bSet )
     158           0 :         { m_bExperimentalMode = bSet; SetModified(); }
     159             : 
     160          46 :         inline sal_Bool IsExperimentalMode() const
     161          46 :         { return m_bExperimentalMode; }
     162             : 
     163           0 :         inline void SetMacroRecorderMode( sal_Bool bSet )
     164           0 :         { m_bMacroRecorderMode = bSet; SetModified(); }
     165             : 
     166           0 :         inline sal_Bool IsMacroRecorderMode() const
     167           0 :         { return m_bMacroRecorderMode; }
     168             : 
     169           0 :         inline sal_Bool IsPluginsEnabled() const
     170           0 :         { return m_bPluginsEnabled; }
     171             : 
     172             :         inline sal_Bool IsPluginsEnabledReadOnly() const
     173             :         { return m_bIsPluginsEnabledRO; }
     174             : 
     175        1668 :         inline sal_Int16 GetSymbolsSize()
     176        1668 :         { return m_nSymbolsSize; }
     177             : 
     178             :         void SetSymbolsSize( sal_Int16 nSet );
     179             : 
     180             :         inline sal_Bool IsGetSymbolsSizeReadOnly()
     181             :         { return m_bIsSymbolsSizeRO; }
     182             : 
     183             :         sal_Int16 GetSymbolsStyle() const;
     184             :         ::rtl::OUString GetSymbolsStyleName() const;
     185             :         sal_Int16 GetCurrentSymbolsStyle() const;
     186             : 
     187           0 :         inline void SetSymbolsStyle( sal_Int16 nSet )
     188           0 :         { ImplSetSymbolsStyle( true, nSet, ::rtl::OUString() ); }
     189             : 
     190         104 :         inline void SetSymbolsStyleName( ::rtl::OUString &rName )
     191         104 :         { ImplSetSymbolsStyle( false, 0, rName ); }
     192             : 
     193             :         inline sal_Bool IsGetSymbolsStyleReadOnly()
     194             :         { return m_bIsSymbolsStyleRO; }
     195             : 
     196             :         // translate to VCL settings ( "0" = 3D, "1" = FLAT )
     197        1540 :         inline sal_Int16 GetToolboxStyle()
     198        1540 :         { return m_nToolboxStyle ? VCL_TOOLBOX_STYLE_FLAT : 0; }
     199             : 
     200             :         // translate from VCL settings
     201             :         void SetToolboxStyle( sal_Int16 nStyle, bool _bSetModified );
     202             : 
     203             :         inline sal_Bool IsGetToolboxStyleReadOnly()
     204             :         { return m_bIsToolboxStyleRO; }
     205             : 
     206           0 :         inline sal_Bool UseSystemPrintDialog() const
     207           0 :         { return m_bUseSystemPrintDialog; }
     208             : 
     209           0 :         inline void SetUseSystemPrintDialog( sal_Bool bSet )
     210           0 :         {  m_bUseSystemPrintDialog = bSet; SetModified(); }
     211             : 
     212             :         inline sal_Bool IsUseSystemPrintDialogReadOnly() const
     213             :         { return m_bIsUseSystemPrintDialogRO; }
     214             : 
     215           0 :         inline sal_Bool ShowLinkWarningDialog() const
     216           0 :         { return m_bShowLinkWarningDialog; }
     217             : 
     218           0 :         void SetShowLinkWarningDialog( sal_Bool bSet )
     219           0 :         {  m_bShowLinkWarningDialog = bSet; SetModified(); }
     220             : 
     221           0 :         sal_Bool IsShowLinkWarningDialogReadOnly() const
     222           0 :         { return m_bIsShowLinkWarningDialogRO; }
     223             : 
     224             :         void AddListenerLink( const Link& rLink );
     225             :         void RemoveListenerLink( const Link& rLink );
     226             :         void CallListeners();
     227             : 
     228             :     //-------------------------------------------------------------------------------------------------------------
     229             :     //  private methods
     230             :     //-------------------------------------------------------------------------------------------------------------
     231             : 
     232             :     private:
     233             : 
     234             :         /*-****************************************************************************************************//**
     235             :             @short      return list of key names of our configuration management which represent oue module tree
     236             :             @descr      These methods return a static const list of key names. We need it to get needed values from our
     237             :                         configuration management.
     238             : 
     239             :             @seealso    -
     240             : 
     241             :             @param      -
     242             :             @return     A list of needed configuration keys is returned.
     243             : 
     244             :             @onerror    -
     245             :         *//*-*****************************************************************************************************/
     246             : 
     247             :         static Sequence< OUString > GetPropertyNames();
     248             : 
     249             :     protected:
     250             :         void ImplSetSymbolsStyle( bool bValue, sal_Int16 nSet, const ::rtl::OUString &rName );
     251             : };
     252             : 
     253             : //*****************************************************************************************************************
     254             : //  constructor
     255             : //*****************************************************************************************************************
     256          52 : SvtMiscOptions_Impl::SvtMiscOptions_Impl()
     257             :     // Init baseclasses first
     258             :     : ConfigItem( ROOTNODE_MISC )
     259             : 
     260             :     , m_bUseSystemFileDialog( sal_False )
     261             :     , m_bIsUseSystemFileDialogRO( sal_False )
     262             :     , m_bPluginsEnabled( sal_False )
     263             :     , m_bIsPluginsEnabledRO( sal_False )
     264             :     , m_nSymbolsSize( 0 )
     265             :     , m_bIsSymbolsSizeRO( sal_False )
     266             :     , m_bIsSymbolsStyleRO( sal_False )
     267             :     , m_nToolboxStyle( 1 )
     268             :     , m_bIsToolboxStyleRO( sal_False )
     269             :     , m_bUseSystemPrintDialog( sal_False )
     270             :     , m_bIsUseSystemPrintDialogRO( sal_False )
     271             :     , m_bShowLinkWarningDialog( sal_True )
     272             :     , m_bIsShowLinkWarningDialogRO( sal_False )
     273             :     , m_bAlwaysAllowSave( sal_False )
     274             :     , m_bExperimentalMode( sal_False )
     275          52 :     , m_bMacroRecorderMode( sal_False )
     276             : 
     277             : {
     278             :     // Use our static list of configuration keys to get his values.
     279          52 :     Sequence< OUString >    seqNames    = GetPropertyNames  (           );
     280          52 :     Load( seqNames );
     281          52 :     Sequence< Any >         seqValues   = GetProperties     ( seqNames  );
     282          52 :     Sequence< sal_Bool >    seqRO       = GetReadOnlyStates ( seqNames  );
     283             : 
     284             :     // Safe impossible cases.
     285             :     // We need values from ALL configuration keys.
     286             :     // Follow assignment use order of values in relation to our list of key names!
     287             :     DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtMiscOptions_Impl::SvtMiscOptions_Impl()\nI miss some values of configuration keys!\n" );
     288             : 
     289             :     // Copy values from list in right order to our internal member.
     290          52 :     sal_Int32 nPropertyCount = seqValues.getLength();
     291         624 :     for( sal_Int32 nProperty=0; nProperty<nPropertyCount; ++nProperty )
     292             :     {
     293         572 :         if (seqValues[nProperty].hasValue()==sal_False)
     294           0 :             continue;
     295         572 :         switch( nProperty )
     296             :         {
     297             :             case PROPERTYHANDLE_PLUGINSENABLED :
     298             :             {
     299          52 :                 if( !(seqValues[nProperty] >>= m_bPluginsEnabled) )
     300             :                 {
     301             :                     OSL_FAIL("Wrong type of \"Misc\\PluginsEnabled\"!" );
     302             :                 }
     303          52 :                 m_bIsPluginsEnabledRO = seqRO[nProperty];
     304          52 :                 break;
     305             :             }
     306             : 
     307             :             case PROPERTYHANDLE_SYMBOLSET :
     308             :             {
     309          52 :                 if( !(seqValues[nProperty] >>= m_nSymbolsSize) )
     310             :                 {
     311             :                     OSL_FAIL("Wrong type of \"Misc\\SymbolSet\"!" );
     312             :                 }
     313          52 :                 m_bIsSymbolsSizeRO = seqRO[nProperty];
     314          52 :                 break;
     315             :             }
     316             : 
     317             :             case PROPERTYHANDLE_TOOLBOXSTYLE :
     318             :             {
     319          52 :                 if( !(seqValues[nProperty] >>= m_nToolboxStyle) )
     320             :                 {
     321             :                     OSL_FAIL("Wrong type of \"Misc\\ToolboxStyle\"!" );
     322             :                 }
     323          52 :                 m_bIsToolboxStyleRO = seqRO[nProperty];
     324          52 :                 break;
     325             :             }
     326             : 
     327             :             case PROPERTYHANDLE_USESYSTEMFILEDIALOG :
     328             :             {
     329          52 :                 if( !(seqValues[nProperty] >>= m_bUseSystemFileDialog) )
     330             :                 {
     331             :                     OSL_FAIL("Wrong type of \"Misc\\UseSystemFileDialog\"!" );
     332             :                 }
     333          52 :                 m_bIsUseSystemFileDialogRO = seqRO[nProperty];
     334          52 :                 break;
     335             :             }
     336             : 
     337             :             case PROPERTYHANDLE_USESYSTEMPRINTDIALOG :
     338             :             {
     339          52 :                 if( !(seqValues[nProperty] >>= m_bUseSystemPrintDialog) )
     340             :                 {
     341             :                     OSL_FAIL("Wrong type of \"Misc\\UseSystemPrintDialog\"!" );
     342             :                 }
     343          52 :                 m_bIsUseSystemPrintDialogRO = seqRO[nProperty];
     344          52 :                 break;
     345             :             }
     346             : 
     347             :             case PROPERTYHANDLE_SHOWLINKWARNINGDIALOG :
     348             :             {
     349          52 :                 if( !(seqValues[nProperty] >>= m_bShowLinkWarningDialog) )
     350             :                 {
     351             :                     OSL_FAIL("Wrong type of \"Misc\\ShowLinkWarningDialog\"!" );
     352             :                 }
     353          52 :                 m_bIsShowLinkWarningDialogRO = seqRO[nProperty];
     354          52 :                 break;
     355             :             }
     356             : 
     357             :             case PROPERTYHANDLE_SYMBOLSTYLE :
     358             :             {
     359          52 :                 ::rtl::OUString aSymbolsStyle;
     360          52 :                 if( seqValues[nProperty] >>= aSymbolsStyle )
     361          52 :                     SetSymbolsStyleName( aSymbolsStyle );
     362             :                 else
     363             :                 {
     364             :                     OSL_FAIL("Wrong type of \"Misc\\SymbolStyle\"!" );
     365             :                 }
     366          52 :                 m_bIsSymbolsStyleRO = seqRO[nProperty];
     367          52 :                 break;
     368             :             }
     369             : 
     370             :             case PROPERTYHANDLE_DISABLEUICUSTOMIZATION :
     371             :             {
     372          52 :                 if( !(seqValues[nProperty] >>= m_bDisableUICustomization) )
     373             :                     OSL_FAIL("Wrong type of \"Misc\\DisableUICustomization\"!" );
     374          52 :                 break;
     375             :             }
     376             :             case PROPERTYHANDLE_ALWAYSALLOWSAVE :
     377             :             {
     378          52 :                 if( !(seqValues[nProperty] >>= m_bAlwaysAllowSave) )
     379             :                     OSL_FAIL("Wrong type of \"Misc\\AlwaysAllowSave\"!" );
     380          52 :                 break;
     381             :             }
     382             :             case PROPERTYHANDLE_EXPERIMENTALMODE :
     383             :             {
     384          52 :                 if( !(seqValues[nProperty] >>= m_bExperimentalMode) )
     385             :                     OSL_FAIL("Wrong type of \"Misc\\ExperimentalMode\"!" );
     386          52 :                 break;
     387             :             }
     388             :             case PROPERTYHANDLE_MACRORECORDERMODE :
     389             :             {
     390           0 :                 if( !(seqValues[nProperty] >>= m_bMacroRecorderMode) )
     391             :                     OSL_FAIL("Wrong type of \"Misc\\MacroRecorderMode\"!" );
     392           0 :                 break;
     393             :             }
     394             :         }
     395             :     }
     396             : 
     397             :     // Enable notification mechanism of our baseclass.
     398             :     // We need it to get information about changes outside these class on our used configuration keys!
     399          52 :     EnableNotification( seqNames );
     400          52 : }
     401             : 
     402             : //*****************************************************************************************************************
     403             : //  destructor
     404             : //*****************************************************************************************************************
     405         150 : SvtMiscOptions_Impl::~SvtMiscOptions_Impl()
     406             : {
     407             :     // We must save our current values .. if user forgets it!
     408          50 :     if( IsModified() == sal_True )
     409             :     {
     410           0 :         Commit();
     411             :     }
     412         100 : }
     413             : 
     414         572 : static int lcl_MapPropertyName( const ::rtl::OUString rCompare,
     415             :                 const uno::Sequence< ::rtl::OUString>& aInternalPropertyNames)
     416             : {
     417        3432 :     for(int nProp = 0; nProp < aInternalPropertyNames.getLength(); ++nProp)
     418             :     {
     419        3432 :         if( aInternalPropertyNames[nProp] == rCompare )
     420         572 :             return nProp;
     421             :     }
     422           0 :     return -1;
     423             : }
     424             : 
     425          52 : void SvtMiscOptions_Impl::Load( const Sequence< OUString >& rPropertyNames )
     426             : {
     427          52 :     const uno::Sequence< ::rtl::OUString> aInternalPropertyNames( GetPropertyNames());
     428          52 :     Sequence< Any > seqValues = GetProperties( rPropertyNames  );
     429             : 
     430             :     // Safe impossible cases.
     431             :     // We need values from ALL configuration keys.
     432             :     // Follow assignment use order of values in relation to our list of key names!
     433             :     DBG_ASSERT( !(rPropertyNames.getLength()!=seqValues.getLength()), "SvtSecurityOptions_Impl::SvtSecurityOptions_Impl()\nI miss some values of configuration keys!\n" );
     434             : 
     435             :     // Copy values from list in right order to our internal member.
     436          52 :     sal_Int32 nPropertyCount = seqValues.getLength();
     437         624 :     for( sal_Int32 nProperty=0; nProperty<nPropertyCount; ++nProperty )
     438             :     {
     439         572 :         if (seqValues[nProperty].hasValue()==sal_False)
     440           0 :             continue;
     441         572 :         switch( lcl_MapPropertyName(rPropertyNames[nProperty], aInternalPropertyNames) )
     442             :         {
     443             :             case PROPERTYHANDLE_PLUGINSENABLED      :   {
     444          52 :                                                             if( !(seqValues[nProperty] >>= m_bPluginsEnabled) )
     445             :                                                             {
     446             :                                                                 OSL_FAIL("Wrong type of \"Misc\\PluginsEnabled\"!" );
     447             :                                                             }
     448             :                                                         }
     449          52 :                                                     break;
     450             :             case PROPERTYHANDLE_SYMBOLSET           :   {
     451          52 :                                                             if( !(seqValues[nProperty] >>= m_nSymbolsSize) )
     452             :                                                             {
     453             :                                                                 OSL_FAIL("Wrong type of \"Misc\\SymbolSet\"!" );
     454             :                                                             }
     455             :                                                         }
     456          52 :                                                     break;
     457             :             case PROPERTYHANDLE_TOOLBOXSTYLE        :   {
     458          52 :                                                             if( !(seqValues[nProperty] >>= m_nToolboxStyle) )
     459             :                                                             {
     460             :                                                                 OSL_FAIL("Wrong type of \"Misc\\ToolboxStyle\"!" );
     461             :                                                             }
     462             :                                                         }
     463          52 :                                                     break;
     464             :             case PROPERTYHANDLE_USESYSTEMFILEDIALOG      :   {
     465          52 :                                                             if( !(seqValues[nProperty] >>= m_bUseSystemFileDialog) )
     466             :                                                             {
     467             :                                                                 OSL_FAIL("Wrong type of \"Misc\\UseSystemFileDialog\"!" );
     468             :                                                             }
     469             :                                                         }
     470          52 :                                                     break;
     471             :             case PROPERTYHANDLE_USESYSTEMPRINTDIALOG     :   {
     472          52 :                                                             if( !(seqValues[nProperty] >>= m_bUseSystemPrintDialog) )
     473             :                                                             {
     474             :                                                                 OSL_FAIL("Wrong type of \"Misc\\UseSystemPrintDialog\"!" );
     475             :                                                             }
     476             :                                                         }
     477          52 :                                                     break;
     478             :             case PROPERTYHANDLE_SHOWLINKWARNINGDIALOG     :   {
     479          52 :                                                             if( !(seqValues[nProperty] >>= m_bShowLinkWarningDialog) )
     480             :                                                             {
     481             :                                                                 OSL_FAIL("Wrong type of \"Misc\\ShowLinkWarningDialog\"!" );
     482             :                                                             }
     483             :                                                         }
     484          52 :                                                     break;
     485             :             case PROPERTYHANDLE_SYMBOLSTYLE         :   {
     486          52 :                                                             ::rtl::OUString aSymbolsStyle;
     487          52 :                                                             if( seqValues[nProperty] >>= aSymbolsStyle )
     488          52 :                                                                 SetSymbolsStyleName( aSymbolsStyle );
     489             :                                                             else
     490             :                                                             {
     491             :                                                                 OSL_FAIL("Wrong type of \"Misc\\SymbolStyle\"!" );
     492          52 :                                                             }
     493             :                                                         }
     494          52 :                                                     break;
     495             :             case PROPERTYHANDLE_DISABLEUICUSTOMIZATION      :   {
     496          52 :                                                             if( !(seqValues[nProperty] >>= m_bDisableUICustomization) )
     497             :                                                                 OSL_FAIL("Wrong type of \"Misc\\DisableUICustomization\"!" );
     498             :                                                         }
     499          52 :                                                     break;
     500             :             case PROPERTYHANDLE_ALWAYSALLOWSAVE:
     501             :             {
     502          52 :                 if( !(seqValues[nProperty] >>= m_bAlwaysAllowSave) )
     503             :                     OSL_FAIL("Wrong type of \"Misc\\AlwaysAllowSave\"!" );
     504             :             }
     505          52 :             break;
     506             :         }
     507          52 :     }
     508          52 : }
     509             : 
     510        1564 : void SvtMiscOptions_Impl::AddListenerLink( const Link& rLink )
     511             : {
     512        1564 :     aList.push_back( rLink );
     513        1564 : }
     514             : 
     515         298 : void SvtMiscOptions_Impl::RemoveListenerLink( const Link& rLink )
     516             : {
     517        9684 :     for ( ::std::list<Link>::iterator iter = aList.begin(); iter != aList.end(); ++iter )
     518             :     {
     519        9684 :         if ( *iter == rLink )
     520             :         {
     521         298 :             aList.erase(iter);
     522         298 :             break;
     523             :         }
     524             :     }
     525         298 : }
     526             : 
     527           0 : void SvtMiscOptions_Impl::CallListeners()
     528             : {
     529           0 :     for ( ::std::list<Link>::const_iterator iter = aList.begin(); iter != aList.end(); ++iter )
     530           0 :         iter->Call( this );
     531           0 : }
     532             : 
     533           0 : void SvtMiscOptions_Impl::SetToolboxStyle( sal_Int16 nStyle, bool _bSetModified )
     534             : {
     535           0 :     m_nToolboxStyle = nStyle ? 1 : 0;
     536           0 :     if ( _bSetModified )
     537           0 :         SetModified();
     538           0 :     CallListeners();
     539           0 : }
     540             : 
     541           0 : void SvtMiscOptions_Impl::SetSymbolsSize( sal_Int16 nSet )
     542             : {
     543           0 :     m_nSymbolsSize = nSet;
     544           0 :     SetModified();
     545           0 :     CallListeners();
     546           0 : }
     547             : 
     548           0 : sal_Int16 SvtMiscOptions_Impl::GetSymbolsStyle() const
     549             : {
     550           0 :     return (sal_Int16)Application::GetSettings().GetStyleSettings().GetSymbolsStyle();
     551             : }
     552             : 
     553         120 : ::rtl::OUString SvtMiscOptions_Impl::GetSymbolsStyleName() const
     554             : {
     555         120 :     return Application::GetSettings().GetStyleSettings().GetSymbolsStyleName();
     556             : }
     557             : 
     558        2246 : sal_Int16 SvtMiscOptions_Impl::GetCurrentSymbolsStyle() const
     559             : {
     560        2246 :     return (sal_Int16)Application::GetSettings().GetStyleSettings().GetCurrentSymbolsStyle();
     561             : }
     562             : 
     563         104 : void SvtMiscOptions_Impl::ImplSetSymbolsStyle( bool bValue, sal_Int16 nSet, const ::rtl::OUString &rName )
     564             : {
     565         520 :     if ( ( bValue && ( nSet != GetSymbolsStyle() ) ) ||
     566         416 :          ( !bValue && ( rName != GetSymbolsStyleName() ) ) )
     567             :     {
     568           0 :         AllSettings aAllSettings = Application::GetSettings();
     569           0 :         StyleSettings aStyleSettings = aAllSettings.GetStyleSettings();
     570             : 
     571           0 :         if ( bValue )
     572           0 :             aStyleSettings.SetSymbolsStyle( nSet );
     573             :         else
     574           0 :             aStyleSettings.SetSymbolsStyleName( rName );
     575             : 
     576           0 :         aAllSettings.SetStyleSettings(aStyleSettings);
     577           0 :         Application::MergeSystemSettings( aAllSettings );
     578           0 :         Application::SetSettings(aAllSettings);
     579             : 
     580           0 :         SetModified();
     581           0 :         CallListeners();
     582             :     }
     583         104 : }
     584             : 
     585             : //*****************************************************************************************************************
     586             : //  public method
     587             : //*****************************************************************************************************************
     588           0 : void SvtMiscOptions_Impl::Notify( const Sequence< OUString >& rPropertyNames )
     589             : {
     590           0 :     Load( rPropertyNames );
     591           0 :     CallListeners();
     592           0 : }
     593             : 
     594             : //*****************************************************************************************************************
     595             : //  public method
     596             : //*****************************************************************************************************************
     597          16 : void SvtMiscOptions_Impl::Commit()
     598             : {
     599             :     // Get names of supported properties, create a list for values and copy current values to it.
     600          16 :     Sequence< OUString >    seqNames    = GetPropertyNames  ();
     601          16 :     sal_Int32               nCount      = seqNames.getLength();
     602          16 :     Sequence< Any >         seqValues   ( nCount );
     603         192 :     for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty )
     604             :     {
     605         176 :         switch( nProperty )
     606             :         {
     607             :             case PROPERTYHANDLE_PLUGINSENABLED :
     608             :             {
     609          16 :                 if ( !m_bIsPluginsEnabledRO )
     610          16 :                     seqValues[nProperty] <<= m_bPluginsEnabled;
     611          16 :                 break;
     612             :             }
     613             : 
     614             :             case PROPERTYHANDLE_SYMBOLSET :
     615             :             {
     616          16 :                 if ( !m_bIsSymbolsSizeRO )
     617          16 :                    seqValues[nProperty] <<= m_nSymbolsSize;
     618          16 :                 break;
     619             :             }
     620             : 
     621             :             case PROPERTYHANDLE_TOOLBOXSTYLE :
     622             :             {
     623          16 :                 if ( !m_bIsToolboxStyleRO )
     624          16 :                     seqValues[nProperty] <<= m_nToolboxStyle;
     625          16 :                 break;
     626             :             }
     627             : 
     628             :             case PROPERTYHANDLE_USESYSTEMFILEDIALOG :
     629             :             {
     630          16 :                 if ( !m_bIsUseSystemFileDialogRO )
     631          16 :                     seqValues[nProperty] <<= m_bUseSystemFileDialog;
     632          16 :                 break;
     633             :             }
     634             : 
     635             :             case PROPERTYHANDLE_SYMBOLSTYLE :
     636             :             {
     637          16 :                 if ( !m_bIsSymbolsStyleRO )
     638          16 :                     seqValues[nProperty] <<= GetSymbolsStyleName();
     639          16 :                 break;
     640             :             }
     641             : 
     642             :             case PROPERTYHANDLE_USESYSTEMPRINTDIALOG :
     643             :             {
     644          16 :                 if ( !m_bIsUseSystemPrintDialogRO )
     645          16 :                     seqValues[nProperty] <<= m_bUseSystemPrintDialog;
     646          16 :                 break;
     647             :             }
     648             : 
     649             :             case PROPERTYHANDLE_SHOWLINKWARNINGDIALOG :
     650             :             {
     651          16 :                 if ( !m_bIsShowLinkWarningDialogRO )
     652          16 :                     seqValues[nProperty] <<= m_bShowLinkWarningDialog;
     653          16 :                 break;
     654             :             }
     655             : 
     656             :             case PROPERTYHANDLE_DISABLEUICUSTOMIZATION :
     657             :             {
     658          16 :                 seqValues[nProperty] <<= m_bDisableUICustomization;
     659          16 :                 break;
     660             :             }
     661             :             case PROPERTYHANDLE_ALWAYSALLOWSAVE :
     662             :             {
     663          16 :                 seqValues[nProperty] <<= m_bAlwaysAllowSave;
     664          16 :                 break;
     665             :             }
     666             :             case PROPERTYHANDLE_EXPERIMENTALMODE :
     667             :             {
     668          16 :                 seqValues[nProperty] <<= m_bExperimentalMode;
     669          16 :                 break;
     670             :             }
     671             :             case PROPERTYHANDLE_MACRORECORDERMODE :
     672             :             {
     673           0 :                 seqValues[nProperty] <<= m_bMacroRecorderMode;
     674           0 :                 break;
     675             :             }
     676             :         }
     677             :     }
     678             :     // Set properties in configuration.
     679          16 :     PutProperties( seqNames, seqValues );
     680          16 : }
     681             : 
     682             : //*****************************************************************************************************************
     683             : //  private method
     684             : //*****************************************************************************************************************
     685         120 : Sequence< OUString > SvtMiscOptions_Impl::GetPropertyNames()
     686             : {
     687             :     // Build list of configuration key names.
     688             :     const OUString pProperties[] =
     689             :     {
     690             :         PROPERTYNAME_PLUGINSENABLED,
     691             :         PROPERTYNAME_SYMBOLSET,
     692             :         PROPERTYNAME_TOOLBOXSTYLE,
     693             :         PROPERTYNAME_USESYSTEMFILEDIALOG,
     694             :         PROPERTYNAME_SYMBOLSTYLE,
     695             :         PROPERTYNAME_USESYSTEMPRINTDIALOG,
     696             :         PROPERTYNAME_SHOWLINKWARNINGDIALOG,
     697             :         PROPERTYNAME_DISABLEUICUSTOMIZATION,
     698             :         PROPERTYNAME_ALWAYSALLOWSAVE,
     699             :         PROPERTYNAME_EXPERIMENTALMODE,
     700             :         PROPERTYNAME_MACRORECORDERMODE
     701        1440 :     };
     702             : 
     703             :     // Initialize return sequence with these list ...
     704         120 :     const Sequence< OUString > seqPropertyNames( pProperties, SAL_N_ELEMENTS( pProperties ) );
     705             :     // ... and return it.
     706        1440 :     return seqPropertyNames;
     707             : }
     708             : 
     709             : //*****************************************************************************************************************
     710             : //  initialize static member
     711             : //  DON'T DO IT IN YOUR HEADER!
     712             : //  see definition for further informations
     713             : //*****************************************************************************************************************
     714             : SvtMiscOptions_Impl*    SvtMiscOptions::m_pDataContainer    = NULL  ;
     715             : sal_Int32               SvtMiscOptions::m_nRefCount = 0     ;
     716             : 
     717             : //*****************************************************************************************************************
     718             : //  constructor
     719             : //*****************************************************************************************************************
     720        8011 : SvtMiscOptions::SvtMiscOptions()
     721             : {
     722             :     // Global access, must be guarded (multithreading!).
     723        8011 :     MutexGuard aGuard( GetInitMutex() );
     724             :     // Increase our refcount ...
     725        8011 :     ++m_nRefCount;
     726             :     // ... and initialize our data container only if it not already exist!
     727        8011 :     if( m_pDataContainer == NULL )
     728             :     {
     729             :        RTL_LOGFILE_CONTEXT(aLog, "svtools ( ??? ) ::SvtMiscOptions_Impl::ctor()");
     730          52 :        m_pDataContainer = new SvtMiscOptions_Impl;
     731          52 :        svtools::ItemHolder2::holdConfigItem(E_MISCOPTIONS);
     732        8011 :     }
     733        8011 : }
     734             : 
     735             : //*****************************************************************************************************************
     736             : //  destructor
     737             : //*****************************************************************************************************************
     738       16058 : SvtMiscOptions::~SvtMiscOptions()
     739             : {
     740             :     // Global access, must be guarded (multithreading!)
     741        8003 :     MutexGuard aGuard( GetInitMutex() );
     742             :     // Decrease our refcount.
     743        8003 :     --m_nRefCount;
     744             :     // If last instance was deleted ...
     745             :     // we must destroy our static data container!
     746        8003 :     if( m_nRefCount <= 0 )
     747             :     {
     748          50 :         delete m_pDataContainer;
     749          50 :         m_pDataContainer = NULL;
     750        8003 :     }
     751        8055 : }
     752             : 
     753           8 : sal_Bool SvtMiscOptions::UseSystemFileDialog() const
     754             : {
     755           8 :     return m_pDataContainer->UseSystemFileDialog();
     756             : }
     757             : 
     758          16 : void SvtMiscOptions::SetUseSystemFileDialog( sal_Bool bEnable )
     759             : {
     760          16 :     m_pDataContainer->SetUseSystemFileDialog( bEnable );
     761          16 : }
     762             : 
     763           0 : sal_Bool SvtMiscOptions::IsUseSystemFileDialogReadOnly() const
     764             : {
     765           0 :     return m_pDataContainer->IsUseSystemFileDialogReadOnly();
     766             : }
     767             : 
     768           0 : sal_Bool SvtMiscOptions::IsPluginsEnabled() const
     769             : {
     770           0 :     return m_pDataContainer->IsPluginsEnabled();
     771             : }
     772             : 
     773           0 : sal_Int16 SvtMiscOptions::GetSymbolsSize() const
     774             : {
     775           0 :     return m_pDataContainer->GetSymbolsSize();
     776             : }
     777             : 
     778           0 : void SvtMiscOptions::SetSymbolsSize( sal_Int16 nSet )
     779             : {
     780           0 :     m_pDataContainer->SetSymbolsSize( nSet );
     781           0 : }
     782             : 
     783        1668 : sal_Int16 SvtMiscOptions::GetCurrentSymbolsSize() const
     784             : {
     785        1668 :     sal_Int16 eOptSymbolsSize = m_pDataContainer->GetSymbolsSize();
     786             : 
     787        1668 :     if ( eOptSymbolsSize == SFX_SYMBOLS_SIZE_AUTO )
     788             :     {
     789             :         // Use system settings, we have to retrieve the toolbar icon size from the
     790             :         // Application class
     791        1668 :         sal_uLong nStyleIconSize = Application::GetSettings().GetStyleSettings().GetToolbarIconSize();
     792        1668 :         if ( nStyleIconSize == STYLE_TOOLBAR_ICONSIZE_LARGE )
     793           0 :             eOptSymbolsSize = SFX_SYMBOLS_SIZE_LARGE;
     794             :         else
     795        1668 :             eOptSymbolsSize = SFX_SYMBOLS_SIZE_SMALL;
     796             :     }
     797             : 
     798        1668 :     return eOptSymbolsSize;
     799             : }
     800             : 
     801        1644 : bool SvtMiscOptions::AreCurrentSymbolsLarge() const
     802             : {
     803        1644 :     return ( GetCurrentSymbolsSize() == SFX_SYMBOLS_SIZE_LARGE );
     804             : }
     805             : 
     806           0 : sal_Int16 SvtMiscOptions::GetSymbolsStyle() const
     807             : {
     808           0 :     return m_pDataContainer->GetSymbolsStyle();
     809             : }
     810             : 
     811        2246 : sal_Int16 SvtMiscOptions::GetCurrentSymbolsStyle() const
     812             : {
     813        2246 :     return m_pDataContainer->GetCurrentSymbolsStyle();
     814             : }
     815             : 
     816           0 : void SvtMiscOptions::SetSymbolsStyle( sal_Int16 nSet )
     817             : {
     818           0 :     m_pDataContainer->SetSymbolsStyle( nSet );
     819           0 : }
     820             : 
     821         660 : sal_Bool SvtMiscOptions::DisableUICustomization() const
     822             : {
     823         660 :     return m_pDataContainer->DisableUICustomization();
     824             : }
     825             : 
     826        1540 : sal_Int16 SvtMiscOptions::GetToolboxStyle() const
     827             : {
     828        1540 :     return m_pDataContainer->GetToolboxStyle();
     829             : }
     830             : 
     831           0 : void SvtMiscOptions::SetToolboxStyle( sal_Int16 nStyle )
     832             : {
     833           0 :     m_pDataContainer->SetToolboxStyle( nStyle, true );
     834           0 : }
     835             : 
     836           0 : sal_Bool SvtMiscOptions::UseSystemPrintDialog() const
     837             : {
     838           0 :     return m_pDataContainer->UseSystemPrintDialog();
     839             : }
     840             : 
     841           0 : void SvtMiscOptions::SetUseSystemPrintDialog( sal_Bool bEnable )
     842             : {
     843           0 :     m_pDataContainer->SetUseSystemPrintDialog( bEnable );
     844           0 : }
     845             : 
     846           0 : sal_Bool SvtMiscOptions::ShowLinkWarningDialog() const
     847             : {
     848           0 :     return m_pDataContainer->ShowLinkWarningDialog();
     849             : }
     850             : 
     851           0 : void SvtMiscOptions::SetShowLinkWarningDialog( sal_Bool bSet )
     852             : {
     853           0 :     m_pDataContainer->SetShowLinkWarningDialog( bSet );
     854           0 : }
     855             : 
     856           0 : sal_Bool SvtMiscOptions::IsShowLinkWarningDialogReadOnly() const
     857             : {
     858           0 :     return m_pDataContainer->IsShowLinkWarningDialogReadOnly();
     859             : }
     860             : 
     861           0 : void SvtMiscOptions::SetSaveAlwaysAllowed( sal_Bool bSet )
     862             : {
     863           0 :     m_pDataContainer->SetSaveAlwaysAllowed( bSet );
     864           0 : }
     865             : 
     866           7 : sal_Bool SvtMiscOptions::IsSaveAlwaysAllowed() const
     867             : {
     868           7 :     return m_pDataContainer->IsSaveAlwaysAllowed();
     869             : }
     870             : 
     871           0 : void SvtMiscOptions::SetExperimentalMode( sal_Bool bSet )
     872             : {
     873           0 :     m_pDataContainer->SetExperimentalMode( bSet );
     874           0 : }
     875             : 
     876          46 : sal_Bool SvtMiscOptions::IsExperimentalMode() const
     877             : {
     878          46 :     return m_pDataContainer->IsExperimentalMode();
     879             : }
     880             : 
     881           0 : void SvtMiscOptions::SetMacroRecorderMode( sal_Bool bSet )
     882             : {
     883           0 :     m_pDataContainer->SetMacroRecorderMode( bSet );
     884           0 : }
     885             : 
     886           0 : sal_Bool SvtMiscOptions::IsMacroRecorderMode() const
     887             : {
     888           0 :     return m_pDataContainer->IsMacroRecorderMode();
     889             : }
     890             : 
     891             : namespace
     892             : {
     893             :     class theSvtMiscOptionsMutex :
     894             :         public rtl::Static< osl::Mutex, theSvtMiscOptionsMutex > {};
     895             : }
     896             : 
     897       16014 : Mutex & SvtMiscOptions::GetInitMutex()
     898             : {
     899       16014 :     return theSvtMiscOptionsMutex::get();
     900             : }
     901             : 
     902        1564 : void SvtMiscOptions::AddListenerLink( const Link& rLink )
     903             : {
     904        1564 :     m_pDataContainer->AddListenerLink( rLink );
     905        1564 : }
     906             : 
     907         298 : void SvtMiscOptions::RemoveListenerLink( const Link& rLink )
     908             : {
     909         298 :     m_pDataContainer->RemoveListenerLink( rLink );
     910         298 : }
     911             : 
     912             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10