1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_unotools.hxx" 30*cdf0e10cSrcweir #ifndef GCC 31*cdf0e10cSrcweir #endif 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 34*cdf0e10cSrcweir // includes 35*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir #include <unotools/fontoptions.hxx> 38*cdf0e10cSrcweir #include <unotools/configmgr.hxx> 39*cdf0e10cSrcweir #include <unotools/configitem.hxx> 40*cdf0e10cSrcweir #include <tools/debug.hxx> 41*cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx> 42*cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx> 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir #include <rtl/logfile.hxx> 45*cdf0e10cSrcweir #include "itemholder1.hxx" 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 48*cdf0e10cSrcweir // namespaces 49*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir using namespace ::utl ; 52*cdf0e10cSrcweir using namespace ::rtl ; 53*cdf0e10cSrcweir using namespace ::osl ; 54*cdf0e10cSrcweir using namespace ::com::sun::star::uno ; 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 57*cdf0e10cSrcweir // const 58*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir #define ROOTNODE_FONT OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/Font" )) 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir #define PROPERTYNAME_REPLACEMENTTABLE OUString(RTL_CONSTASCII_USTRINGPARAM("Substitution/Replacement" )) 63*cdf0e10cSrcweir #define PROPERTYNAME_FONTHISTORY OUString(RTL_CONSTASCII_USTRINGPARAM("View/History" )) 64*cdf0e10cSrcweir #define PROPERTYNAME_FONTWYSIWYG OUString(RTL_CONSTASCII_USTRINGPARAM("View/ShowFontBoxWYSIWYG" )) 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir #define PROPERTYHANDLE_REPLACEMENTTABLE 0 67*cdf0e10cSrcweir #define PROPERTYHANDLE_FONTHISTORY 1 68*cdf0e10cSrcweir #define PROPERTYHANDLE_FONTWYSIWYG 2 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir #define PROPERTYCOUNT 3 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 73*cdf0e10cSrcweir // private declarations! 74*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir class SvtFontOptions_Impl : public ConfigItem 77*cdf0e10cSrcweir { 78*cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 79*cdf0e10cSrcweir // public methods 80*cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir public: 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 85*cdf0e10cSrcweir // constructor / destructor 86*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir SvtFontOptions_Impl(); 89*cdf0e10cSrcweir ~SvtFontOptions_Impl(); 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 92*cdf0e10cSrcweir // overloaded methods of baseclass 93*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir /*-****************************************************************************************************//** 96*cdf0e10cSrcweir @short called for notify of configmanager 97*cdf0e10cSrcweir @descr These method is called from the ConfigManager before application ends or from the 98*cdf0e10cSrcweir PropertyChangeListener if the sub tree broadcasts changes. You must update your 99*cdf0e10cSrcweir internal values. 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir @seealso baseclass ConfigItem 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir @param "seqPropertyNames" is the list of properties which should be updated. 104*cdf0e10cSrcweir @return - 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir @onerror - 107*cdf0e10cSrcweir *//*-*****************************************************************************************************/ 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir virtual void Notify( const Sequence< OUString >& seqPropertyNames ); 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir /*-****************************************************************************************************//** 112*cdf0e10cSrcweir @short write changes to configuration 113*cdf0e10cSrcweir @descr These method writes the changed values into the sub tree 114*cdf0e10cSrcweir and should always called in our destructor to guarantee consistency of config data. 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir @seealso baseclass ConfigItem 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir @param - 119*cdf0e10cSrcweir @return - 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir @onerror - 122*cdf0e10cSrcweir *//*-*****************************************************************************************************/ 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir virtual void Commit(); 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 127*cdf0e10cSrcweir // public interface 128*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir /*-****************************************************************************************************//** 131*cdf0e10cSrcweir @short access method to get internal values 132*cdf0e10cSrcweir @descr These method give us a chance to regulate acces to ouer internal values. 133*cdf0e10cSrcweir It's not used in the moment - but it's possible for the feature! 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir @seealso - 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir @param - 138*cdf0e10cSrcweir @return - 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir @onerror - 141*cdf0e10cSrcweir *//*-*****************************************************************************************************/ 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir sal_Bool IsReplacementTableEnabled ( ) const ; 144*cdf0e10cSrcweir void EnableReplacementTable ( sal_Bool bState ) ; 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir sal_Bool IsFontHistoryEnabled ( ) const ; 147*cdf0e10cSrcweir void EnableFontHistory ( sal_Bool bState ) ; 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir sal_Bool IsFontWYSIWYGEnabled ( ) const ; 150*cdf0e10cSrcweir void EnableFontWYSIWYG ( sal_Bool bState ) ; 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 153*cdf0e10cSrcweir // private methods 154*cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir private: 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir /*-****************************************************************************************************//** 159*cdf0e10cSrcweir @short return list of key names of ouer configuration management which represent oue module tree 160*cdf0e10cSrcweir @descr These methods return a static const list of key names. We need it to get needed values from our 161*cdf0e10cSrcweir configuration management. 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir @seealso - 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir @param - 166*cdf0e10cSrcweir @return A list of needed configuration keys is returned. 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir @onerror - 169*cdf0e10cSrcweir *//*-*****************************************************************************************************/ 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir static Sequence< OUString > impl_GetPropertyNames(); 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 174*cdf0e10cSrcweir // private member 175*cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir private: 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir sal_Bool m_bReplacementTable ; 180*cdf0e10cSrcweir sal_Bool m_bFontHistory ; 181*cdf0e10cSrcweir sal_Bool m_bFontWYSIWYG ; 182*cdf0e10cSrcweir }; 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 185*cdf0e10cSrcweir // definitions 186*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir //***************************************************************************************************************** 189*cdf0e10cSrcweir // constructor 190*cdf0e10cSrcweir //***************************************************************************************************************** 191*cdf0e10cSrcweir SvtFontOptions_Impl::SvtFontOptions_Impl() 192*cdf0e10cSrcweir // Init baseclasses first 193*cdf0e10cSrcweir : ConfigItem ( ROOTNODE_FONT ) 194*cdf0e10cSrcweir // Init member then. 195*cdf0e10cSrcweir , m_bReplacementTable ( sal_False ) 196*cdf0e10cSrcweir , m_bFontHistory ( sal_False ) 197*cdf0e10cSrcweir , m_bFontWYSIWYG ( sal_False ) 198*cdf0e10cSrcweir { 199*cdf0e10cSrcweir // Use our static list of configuration keys to get his values. 200*cdf0e10cSrcweir Sequence< OUString > seqNames = impl_GetPropertyNames ( ); 201*cdf0e10cSrcweir Sequence< Any > seqValues = GetProperties ( seqNames ); 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir // Safe impossible cases. 204*cdf0e10cSrcweir // We need values from ALL configuration keys. 205*cdf0e10cSrcweir // Follow assignment use order of values in relation to our list of key names! 206*cdf0e10cSrcweir DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtFontOptions_Impl::SvtFontOptions_Impl()\nI miss some values of configuration keys!\n" ); 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir // Copy values from list in right order to ouer internal member. 209*cdf0e10cSrcweir sal_Int32 nPropertyCount = seqValues.getLength(); 210*cdf0e10cSrcweir for( sal_Int32 nProperty=0; nProperty<nPropertyCount; ++nProperty ) 211*cdf0e10cSrcweir { 212*cdf0e10cSrcweir // Safe impossible cases. 213*cdf0e10cSrcweir // Check any for valid value. 214*cdf0e10cSrcweir DBG_ASSERT( !(seqValues[nProperty].hasValue()==sal_False), "SvtFontOptions_Impl::SvtFontOptions_Impl()\nInvalid property value detected!\n" ); 215*cdf0e10cSrcweir switch( nProperty ) 216*cdf0e10cSrcweir { 217*cdf0e10cSrcweir case PROPERTYHANDLE_REPLACEMENTTABLE : { 218*cdf0e10cSrcweir DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtFontOptions_Impl::SvtFontOptions_Impl()\nWho has changed the value type of \"Office.Common\\Font\\Substitution\\Replacement\"?" ); 219*cdf0e10cSrcweir seqValues[nProperty] >>= m_bReplacementTable; 220*cdf0e10cSrcweir } 221*cdf0e10cSrcweir break; 222*cdf0e10cSrcweir case PROPERTYHANDLE_FONTHISTORY : { 223*cdf0e10cSrcweir DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtFontOptions_Impl::SvtFontOptions_Impl()\nWho has changed the value type of \"Office.Common\\Font\\View\\History\"?" ); 224*cdf0e10cSrcweir seqValues[nProperty] >>= m_bFontHistory; 225*cdf0e10cSrcweir } 226*cdf0e10cSrcweir break; 227*cdf0e10cSrcweir case PROPERTYHANDLE_FONTWYSIWYG : { 228*cdf0e10cSrcweir DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtFontOptions_Impl::SvtFontOptions_Impl()\nWho has changed the value type of \"Office.Common\\Font\\View\\ShowFontBoxWYSIWYG\"?" ); 229*cdf0e10cSrcweir seqValues[nProperty] >>= m_bFontWYSIWYG; 230*cdf0e10cSrcweir } 231*cdf0e10cSrcweir break; 232*cdf0e10cSrcweir } 233*cdf0e10cSrcweir } 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir // Enable notification mechanism of ouer baseclass. 236*cdf0e10cSrcweir // We need it to get information about changes outside these class on ouer used configuration keys! 237*cdf0e10cSrcweir EnableNotification( seqNames ); 238*cdf0e10cSrcweir } 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir //***************************************************************************************************************** 241*cdf0e10cSrcweir // destructor 242*cdf0e10cSrcweir //***************************************************************************************************************** 243*cdf0e10cSrcweir SvtFontOptions_Impl::~SvtFontOptions_Impl() 244*cdf0e10cSrcweir { 245*cdf0e10cSrcweir // We must save our current values .. if user forget it! 246*cdf0e10cSrcweir if( IsModified() == sal_True ) 247*cdf0e10cSrcweir { 248*cdf0e10cSrcweir Commit(); 249*cdf0e10cSrcweir } 250*cdf0e10cSrcweir } 251*cdf0e10cSrcweir 252*cdf0e10cSrcweir //***************************************************************************************************************** 253*cdf0e10cSrcweir // public method 254*cdf0e10cSrcweir //***************************************************************************************************************** 255*cdf0e10cSrcweir void SvtFontOptions_Impl::Notify( const Sequence< OUString >& seqPropertyNames ) 256*cdf0e10cSrcweir { 257*cdf0e10cSrcweir // Use given list of updated properties to get his values from configuration directly! 258*cdf0e10cSrcweir Sequence< Any > seqValues = GetProperties( seqPropertyNames ); 259*cdf0e10cSrcweir // Safe impossible cases. 260*cdf0e10cSrcweir // We need values from ALL notified configuration keys. 261*cdf0e10cSrcweir DBG_ASSERT( !(seqPropertyNames.getLength()!=seqValues.getLength()), "SvtFontOptions_Impl::Notify()\nI miss some values of configuration keys!\n" ); 262*cdf0e10cSrcweir // Step over list of property names and get right value from coreesponding value list to set it on internal members! 263*cdf0e10cSrcweir sal_Int32 nCount = seqPropertyNames.getLength(); 264*cdf0e10cSrcweir for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty ) 265*cdf0e10cSrcweir { 266*cdf0e10cSrcweir if( seqPropertyNames[nProperty] == PROPERTYNAME_REPLACEMENTTABLE ) 267*cdf0e10cSrcweir { 268*cdf0e10cSrcweir DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtFontOptions_Impl::Notify()\nWho has changed the value type of \"Office.Common\\Font\\Substitution\\Replacement\"?" ); 269*cdf0e10cSrcweir seqValues[nProperty] >>= m_bReplacementTable; 270*cdf0e10cSrcweir } 271*cdf0e10cSrcweir else 272*cdf0e10cSrcweir if( seqPropertyNames[nProperty] == PROPERTYNAME_FONTHISTORY ) 273*cdf0e10cSrcweir { 274*cdf0e10cSrcweir DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtFontOptions_Impl::Notify()\nWho has changed the value type of \"Office.Common\\Font\\View\\History\"?" ); 275*cdf0e10cSrcweir seqValues[nProperty] >>= m_bFontHistory; 276*cdf0e10cSrcweir } 277*cdf0e10cSrcweir else 278*cdf0e10cSrcweir if( seqPropertyNames[nProperty] == PROPERTYNAME_FONTWYSIWYG ) 279*cdf0e10cSrcweir { 280*cdf0e10cSrcweir DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtFontOptions_Impl::Notify()\nWho has changed the value type of \"Office.Common\\Font\\View\\ShowFontBoxWYSIWYG\"?" ); 281*cdf0e10cSrcweir seqValues[nProperty] >>= m_bFontWYSIWYG; 282*cdf0e10cSrcweir } 283*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 284*cdf0e10cSrcweir else DBG_ASSERT( sal_False, "SvtFontOptions_Impl::Notify()\nUnkown property detected ... I can't handle these!\n" ); 285*cdf0e10cSrcweir #endif 286*cdf0e10cSrcweir } 287*cdf0e10cSrcweir } 288*cdf0e10cSrcweir 289*cdf0e10cSrcweir //***************************************************************************************************************** 290*cdf0e10cSrcweir // public method 291*cdf0e10cSrcweir //***************************************************************************************************************** 292*cdf0e10cSrcweir void SvtFontOptions_Impl::Commit() 293*cdf0e10cSrcweir { 294*cdf0e10cSrcweir // Get names of supported properties, create a list for values and copy current values to it. 295*cdf0e10cSrcweir Sequence< OUString > seqNames = impl_GetPropertyNames(); 296*cdf0e10cSrcweir sal_Int32 nCount = seqNames.getLength(); 297*cdf0e10cSrcweir Sequence< Any > seqValues ( nCount ); 298*cdf0e10cSrcweir for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty ) 299*cdf0e10cSrcweir { 300*cdf0e10cSrcweir switch( nProperty ) 301*cdf0e10cSrcweir { 302*cdf0e10cSrcweir case PROPERTYHANDLE_REPLACEMENTTABLE : { 303*cdf0e10cSrcweir seqValues[nProperty] <<= m_bReplacementTable; 304*cdf0e10cSrcweir } 305*cdf0e10cSrcweir break; 306*cdf0e10cSrcweir case PROPERTYHANDLE_FONTHISTORY : { 307*cdf0e10cSrcweir seqValues[nProperty] <<= m_bFontHistory; 308*cdf0e10cSrcweir } 309*cdf0e10cSrcweir break; 310*cdf0e10cSrcweir case PROPERTYHANDLE_FONTWYSIWYG : { 311*cdf0e10cSrcweir seqValues[nProperty] <<= m_bFontWYSIWYG; 312*cdf0e10cSrcweir } 313*cdf0e10cSrcweir break; 314*cdf0e10cSrcweir } 315*cdf0e10cSrcweir } 316*cdf0e10cSrcweir // Set properties in configuration. 317*cdf0e10cSrcweir PutProperties( seqNames, seqValues ); 318*cdf0e10cSrcweir } 319*cdf0e10cSrcweir 320*cdf0e10cSrcweir //***************************************************************************************************************** 321*cdf0e10cSrcweir // public method 322*cdf0e10cSrcweir //***************************************************************************************************************** 323*cdf0e10cSrcweir sal_Bool SvtFontOptions_Impl::IsReplacementTableEnabled() const 324*cdf0e10cSrcweir { 325*cdf0e10cSrcweir return m_bReplacementTable; 326*cdf0e10cSrcweir } 327*cdf0e10cSrcweir 328*cdf0e10cSrcweir //***************************************************************************************************************** 329*cdf0e10cSrcweir // public method 330*cdf0e10cSrcweir //***************************************************************************************************************** 331*cdf0e10cSrcweir void SvtFontOptions_Impl::EnableReplacementTable( sal_Bool bState ) 332*cdf0e10cSrcweir { 333*cdf0e10cSrcweir m_bReplacementTable = bState; 334*cdf0e10cSrcweir SetModified(); 335*cdf0e10cSrcweir } 336*cdf0e10cSrcweir 337*cdf0e10cSrcweir //***************************************************************************************************************** 338*cdf0e10cSrcweir // public method 339*cdf0e10cSrcweir //***************************************************************************************************************** 340*cdf0e10cSrcweir sal_Bool SvtFontOptions_Impl::IsFontHistoryEnabled() const 341*cdf0e10cSrcweir { 342*cdf0e10cSrcweir return m_bFontHistory; 343*cdf0e10cSrcweir } 344*cdf0e10cSrcweir 345*cdf0e10cSrcweir //***************************************************************************************************************** 346*cdf0e10cSrcweir // public method 347*cdf0e10cSrcweir //***************************************************************************************************************** 348*cdf0e10cSrcweir void SvtFontOptions_Impl::EnableFontHistory( sal_Bool bState ) 349*cdf0e10cSrcweir { 350*cdf0e10cSrcweir m_bFontHistory = bState; 351*cdf0e10cSrcweir SetModified(); 352*cdf0e10cSrcweir } 353*cdf0e10cSrcweir 354*cdf0e10cSrcweir //***************************************************************************************************************** 355*cdf0e10cSrcweir // public method 356*cdf0e10cSrcweir //***************************************************************************************************************** 357*cdf0e10cSrcweir sal_Bool SvtFontOptions_Impl::IsFontWYSIWYGEnabled() const 358*cdf0e10cSrcweir { 359*cdf0e10cSrcweir return m_bFontWYSIWYG; 360*cdf0e10cSrcweir } 361*cdf0e10cSrcweir 362*cdf0e10cSrcweir //***************************************************************************************************************** 363*cdf0e10cSrcweir // public method 364*cdf0e10cSrcweir //***************************************************************************************************************** 365*cdf0e10cSrcweir void SvtFontOptions_Impl::EnableFontWYSIWYG( sal_Bool bState ) 366*cdf0e10cSrcweir { 367*cdf0e10cSrcweir m_bFontWYSIWYG = bState; 368*cdf0e10cSrcweir SetModified(); 369*cdf0e10cSrcweir } 370*cdf0e10cSrcweir 371*cdf0e10cSrcweir //***************************************************************************************************************** 372*cdf0e10cSrcweir // private method 373*cdf0e10cSrcweir //***************************************************************************************************************** 374*cdf0e10cSrcweir Sequence< OUString > SvtFontOptions_Impl::impl_GetPropertyNames() 375*cdf0e10cSrcweir { 376*cdf0e10cSrcweir // Build static list of configuration key names. 377*cdf0e10cSrcweir static const OUString pProperties[] = 378*cdf0e10cSrcweir { 379*cdf0e10cSrcweir PROPERTYNAME_REPLACEMENTTABLE , 380*cdf0e10cSrcweir PROPERTYNAME_FONTHISTORY , 381*cdf0e10cSrcweir PROPERTYNAME_FONTWYSIWYG , 382*cdf0e10cSrcweir }; 383*cdf0e10cSrcweir // Initialize return sequence with these list ... 384*cdf0e10cSrcweir static const Sequence< OUString > seqPropertyNames( pProperties, PROPERTYCOUNT ); 385*cdf0e10cSrcweir // ... and return it. 386*cdf0e10cSrcweir return seqPropertyNames; 387*cdf0e10cSrcweir } 388*cdf0e10cSrcweir 389*cdf0e10cSrcweir //***************************************************************************************************************** 390*cdf0e10cSrcweir // initialize static member 391*cdf0e10cSrcweir // DON'T DO IT IN YOUR HEADER! 392*cdf0e10cSrcweir // see definition for further informations 393*cdf0e10cSrcweir //***************************************************************************************************************** 394*cdf0e10cSrcweir SvtFontOptions_Impl* SvtFontOptions::m_pDataContainer = NULL ; 395*cdf0e10cSrcweir sal_Int32 SvtFontOptions::m_nRefCount = 0 ; 396*cdf0e10cSrcweir 397*cdf0e10cSrcweir //***************************************************************************************************************** 398*cdf0e10cSrcweir // constructor 399*cdf0e10cSrcweir //***************************************************************************************************************** 400*cdf0e10cSrcweir SvtFontOptions::SvtFontOptions() 401*cdf0e10cSrcweir { 402*cdf0e10cSrcweir // Global access, must be guarded (multithreading!). 403*cdf0e10cSrcweir MutexGuard aGuard( impl_GetOwnStaticMutex() ); 404*cdf0e10cSrcweir // Increase ouer refcount ... 405*cdf0e10cSrcweir ++m_nRefCount; 406*cdf0e10cSrcweir // ... and initialize ouer data container only if it not already exist! 407*cdf0e10cSrcweir if( m_pDataContainer == NULL ) 408*cdf0e10cSrcweir { 409*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT(aLog, "unotools ( ??? ) ::SvtFontOptions_Impl::ctor()"); 410*cdf0e10cSrcweir m_pDataContainer = new SvtFontOptions_Impl; 411*cdf0e10cSrcweir 412*cdf0e10cSrcweir ItemHolder1::holdConfigItem(E_FONTOPTIONS); 413*cdf0e10cSrcweir } 414*cdf0e10cSrcweir } 415*cdf0e10cSrcweir 416*cdf0e10cSrcweir //***************************************************************************************************************** 417*cdf0e10cSrcweir // destructor 418*cdf0e10cSrcweir //***************************************************************************************************************** 419*cdf0e10cSrcweir SvtFontOptions::~SvtFontOptions() 420*cdf0e10cSrcweir { 421*cdf0e10cSrcweir // Global access, must be guarded (multithreading!) 422*cdf0e10cSrcweir MutexGuard aGuard( impl_GetOwnStaticMutex() ); 423*cdf0e10cSrcweir // Decrease ouer refcount. 424*cdf0e10cSrcweir --m_nRefCount; 425*cdf0e10cSrcweir // If last instance was deleted ... 426*cdf0e10cSrcweir // we must destroy ouer static data container! 427*cdf0e10cSrcweir if( m_nRefCount <= 0 ) 428*cdf0e10cSrcweir { 429*cdf0e10cSrcweir delete m_pDataContainer; 430*cdf0e10cSrcweir m_pDataContainer = NULL; 431*cdf0e10cSrcweir } 432*cdf0e10cSrcweir } 433*cdf0e10cSrcweir 434*cdf0e10cSrcweir //***************************************************************************************************************** 435*cdf0e10cSrcweir // public method 436*cdf0e10cSrcweir //***************************************************************************************************************** 437*cdf0e10cSrcweir sal_Bool SvtFontOptions::IsReplacementTableEnabled() const 438*cdf0e10cSrcweir { 439*cdf0e10cSrcweir MutexGuard aGuard( impl_GetOwnStaticMutex() ); 440*cdf0e10cSrcweir return m_pDataContainer->IsReplacementTableEnabled(); 441*cdf0e10cSrcweir } 442*cdf0e10cSrcweir 443*cdf0e10cSrcweir //***************************************************************************************************************** 444*cdf0e10cSrcweir // public method 445*cdf0e10cSrcweir //***************************************************************************************************************** 446*cdf0e10cSrcweir void SvtFontOptions::EnableReplacementTable( sal_Bool bState ) 447*cdf0e10cSrcweir { 448*cdf0e10cSrcweir MutexGuard aGuard( impl_GetOwnStaticMutex() ); 449*cdf0e10cSrcweir m_pDataContainer->EnableReplacementTable( bState ); 450*cdf0e10cSrcweir } 451*cdf0e10cSrcweir 452*cdf0e10cSrcweir //***************************************************************************************************************** 453*cdf0e10cSrcweir // public method 454*cdf0e10cSrcweir //***************************************************************************************************************** 455*cdf0e10cSrcweir sal_Bool SvtFontOptions::IsFontHistoryEnabled() const 456*cdf0e10cSrcweir { 457*cdf0e10cSrcweir MutexGuard aGuard( impl_GetOwnStaticMutex() ); 458*cdf0e10cSrcweir return m_pDataContainer->IsFontHistoryEnabled(); 459*cdf0e10cSrcweir } 460*cdf0e10cSrcweir 461*cdf0e10cSrcweir //***************************************************************************************************************** 462*cdf0e10cSrcweir // public method 463*cdf0e10cSrcweir //***************************************************************************************************************** 464*cdf0e10cSrcweir void SvtFontOptions::EnableFontHistory( sal_Bool bState ) 465*cdf0e10cSrcweir { 466*cdf0e10cSrcweir MutexGuard aGuard( impl_GetOwnStaticMutex() ); 467*cdf0e10cSrcweir m_pDataContainer->EnableFontHistory( bState ); 468*cdf0e10cSrcweir } 469*cdf0e10cSrcweir 470*cdf0e10cSrcweir //***************************************************************************************************************** 471*cdf0e10cSrcweir // public method 472*cdf0e10cSrcweir //***************************************************************************************************************** 473*cdf0e10cSrcweir sal_Bool SvtFontOptions::IsFontWYSIWYGEnabled() const 474*cdf0e10cSrcweir { 475*cdf0e10cSrcweir MutexGuard aGuard( impl_GetOwnStaticMutex() ); 476*cdf0e10cSrcweir return m_pDataContainer->IsFontWYSIWYGEnabled(); 477*cdf0e10cSrcweir } 478*cdf0e10cSrcweir 479*cdf0e10cSrcweir //***************************************************************************************************************** 480*cdf0e10cSrcweir // public method 481*cdf0e10cSrcweir //***************************************************************************************************************** 482*cdf0e10cSrcweir void SvtFontOptions::EnableFontWYSIWYG( sal_Bool bState ) 483*cdf0e10cSrcweir { 484*cdf0e10cSrcweir MutexGuard aGuard( impl_GetOwnStaticMutex() ); 485*cdf0e10cSrcweir m_pDataContainer->EnableFontWYSIWYG( bState ); 486*cdf0e10cSrcweir } 487*cdf0e10cSrcweir 488*cdf0e10cSrcweir //***************************************************************************************************************** 489*cdf0e10cSrcweir // private method 490*cdf0e10cSrcweir //***************************************************************************************************************** 491*cdf0e10cSrcweir Mutex& SvtFontOptions::impl_GetOwnStaticMutex() 492*cdf0e10cSrcweir { 493*cdf0e10cSrcweir // Initialize static mutex only for one time! 494*cdf0e10cSrcweir static Mutex* pMutex = NULL; 495*cdf0e10cSrcweir // If these method first called (Mutex not already exist!) ... 496*cdf0e10cSrcweir if( pMutex == NULL ) 497*cdf0e10cSrcweir { 498*cdf0e10cSrcweir // ... we must create a new one. Protect follow code with the global mutex - 499*cdf0e10cSrcweir // It must be - we create a static variable! 500*cdf0e10cSrcweir MutexGuard aGuard( Mutex::getGlobalMutex() ); 501*cdf0e10cSrcweir // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these! 502*cdf0e10cSrcweir if( pMutex == NULL ) 503*cdf0e10cSrcweir { 504*cdf0e10cSrcweir // Create the new mutex and set it for return on static variable. 505*cdf0e10cSrcweir static Mutex aMutex; 506*cdf0e10cSrcweir pMutex = &aMutex; 507*cdf0e10cSrcweir } 508*cdf0e10cSrcweir } 509*cdf0e10cSrcweir // Return new created or already existing mutex object. 510*cdf0e10cSrcweir return *pMutex; 511*cdf0e10cSrcweir } 512