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 <deque> 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir #include <unotools/internaloptions.hxx> 40*cdf0e10cSrcweir #include <unotools/configmgr.hxx> 41*cdf0e10cSrcweir #include <unotools/configitem.hxx> 42*cdf0e10cSrcweir #include <tools/debug.hxx> 43*cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx> 44*cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx> 45*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp> 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir #include <rtl/logfile.hxx> 48*cdf0e10cSrcweir #include "itemholder1.hxx" 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 51*cdf0e10cSrcweir // namespaces 52*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir using namespace ::utl ; 55*cdf0e10cSrcweir using namespace ::rtl ; 56*cdf0e10cSrcweir using namespace ::osl ; 57*cdf0e10cSrcweir using namespace ::std ; 58*cdf0e10cSrcweir using namespace ::com::sun::star::uno ; 59*cdf0e10cSrcweir using namespace ::com::sun::star::beans ; 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 62*cdf0e10cSrcweir // const 63*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir #define ROOTNODE_INTERNAL OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/Internal" )) 66*cdf0e10cSrcweir #define DEFAULT_SLOTCFG sal_False 67*cdf0e10cSrcweir #define DEFAULT_SENDCRASHMAIL sal_False 68*cdf0e10cSrcweir #define DEFAULT_USEMAILUI sal_True 69*cdf0e10cSrcweir #define DEFAULT_CURRENTTEMPURL OUString(RTL_CONSTASCII_USTRINGPARAM("")) 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir #define FIXPROPERTYNAME_SLOTCFG OUString(RTL_CONSTASCII_USTRINGPARAM("Slot" )) 72*cdf0e10cSrcweir #define FIXPROPERTYNAME_SENDCRASHMAIL OUString(RTL_CONSTASCII_USTRINGPARAM("SendCrashMail" )) 73*cdf0e10cSrcweir #define FIXPROPERTYNAME_USEMAILUI OUString(RTL_CONSTASCII_USTRINGPARAM("UseMailUI" )) 74*cdf0e10cSrcweir #define FIXPROPERTYNAME_CURRENTTEMPURL OUString(RTL_CONSTASCII_USTRINGPARAM("CurrentTempURL" )) 75*cdf0e10cSrcweir //#define FIXPROPERTYNAME_REMOVEMENUENTRYCLOSE OUString(RTL_CONSTASCII_USTRINGPARAM("RemoveMenuEntryClose")) 76*cdf0e10cSrcweir //#define FIXPROPERTYNAME_REMOVEMENUENTRYBACKTOWEBTOP OUString(RTL_CONSTASCII_USTRINGPARAM("RemoveMenuEntryBackToWebtop")) 77*cdf0e10cSrcweir //#define FIXPROPERTYNAME_REMOVEMENUENTRYNEWWEBTOP OUString(RTL_CONSTASCII_USTRINGPARAM("RemoveMenuEntryNewWebtop")) 78*cdf0e10cSrcweir //#define FIXPROPERTYNAME_REMOVEMENUENTRYLOGOUT OUString(RTL_CONSTASCII_USTRINGPARAM("RemoveMenuEntryLogout")) 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir #define FIXPROPERTYHANDLE_SLOTCFG 0 81*cdf0e10cSrcweir #define FIXPROPERTYHANDLE_SENDCRASHMAIL 1 82*cdf0e10cSrcweir #define FIXPROPERTYHANDLE_USEMAILUI 2 83*cdf0e10cSrcweir #define FIXPROPERTYHANDLE_CURRENTTEMPURL 3 84*cdf0e10cSrcweir //#define FIXPROPERTYHANDLE_REMOVEMENUENTRYCLOSE 3 85*cdf0e10cSrcweir //#define FIXPROPERTYHANDLE_REMOVEMENUENTRYBACKTOWEBTOP 4 86*cdf0e10cSrcweir //#define FIXPROPERTYHANDLE_REMOVEMENUENTRYNEWWEBTOP 5 87*cdf0e10cSrcweir //#define FIXPROPERTYHANDLE_REMOVEMENUENTRYLOGOUT 6 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir #define FIXPROPERTYCOUNT 4 90*cdf0e10cSrcweir /* 91*cdf0e10cSrcweir #define PROPERTYNAME_RECOVERYLIST OUString(RTL_CONSTASCII_USTRINGPARAM("RecoveryList" )) 92*cdf0e10cSrcweir #define PROPERTYNAME_URL OUString(RTL_CONSTASCII_USTRINGPARAM("OrgURL" )) 93*cdf0e10cSrcweir #define PROPERTYNAME_FILTER OUString(RTL_CONSTASCII_USTRINGPARAM("FilterName" )) 94*cdf0e10cSrcweir #define PROPERTYNAME_TEMPNAME OUString(RTL_CONSTASCII_USTRINGPARAM("TempURL" )) 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir #define OFFSET_URL 0 97*cdf0e10cSrcweir #define OFFSET_FILTER 1 98*cdf0e10cSrcweir #define OFFSET_TEMPNAME 2 99*cdf0e10cSrcweir */ 100*cdf0e10cSrcweir #define PATHDELIMITER OUString(RTL_CONSTASCII_USTRINGPARAM("/" )) 101*cdf0e10cSrcweir #define FIXR OUString(RTL_CONSTASCII_USTRINGPARAM("r" )) 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 104*cdf0e10cSrcweir // private declarations! 105*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 106*cdf0e10cSrcweir /* 107*cdf0e10cSrcweir struct tIMPL_RecoveryEntry 108*cdf0e10cSrcweir { 109*cdf0e10cSrcweir OUString sURL ; 110*cdf0e10cSrcweir OUString sFilter ; 111*cdf0e10cSrcweir OUString sTempName ; 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir tIMPL_RecoveryEntry() 114*cdf0e10cSrcweir { 115*cdf0e10cSrcweir sURL = OUString(); 116*cdf0e10cSrcweir sFilter = OUString(); 117*cdf0e10cSrcweir sTempName = OUString(); 118*cdf0e10cSrcweir } 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir tIMPL_RecoveryEntry( const OUString& sNewURL , 121*cdf0e10cSrcweir const OUString& sNewFilter , 122*cdf0e10cSrcweir const OUString& sNewTempName ) 123*cdf0e10cSrcweir { 124*cdf0e10cSrcweir sURL = sNewURL ; 125*cdf0e10cSrcweir sFilter = sNewFilter ; 126*cdf0e10cSrcweir sTempName = sNewTempName ; 127*cdf0e10cSrcweir } 128*cdf0e10cSrcweir }; 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir typedef deque< tIMPL_RecoveryEntry > tIMPL_RecoveryStack; 131*cdf0e10cSrcweir */ 132*cdf0e10cSrcweir class SvtInternalOptions_Impl : public ConfigItem 133*cdf0e10cSrcweir { 134*cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 135*cdf0e10cSrcweir // private member 136*cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir private: 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir sal_Bool m_bRemoveMenuEntryClose; 141*cdf0e10cSrcweir sal_Bool m_bRemoveMenuEntryBackToWebtop; 142*cdf0e10cSrcweir sal_Bool m_bRemoveMenuEntryNewWebtop; 143*cdf0e10cSrcweir sal_Bool m_bRemoveMenuEntryLogout; 144*cdf0e10cSrcweir sal_Bool m_bSlotCFG ; /// cache "Slot" of Internal section 145*cdf0e10cSrcweir sal_Bool m_bSendCrashMail ; /// cache "SendCrashMail" of Internal section 146*cdf0e10cSrcweir sal_Bool m_bUseMailUI; 147*cdf0e10cSrcweir OUString m_aCurrentTempURL ; 148*cdf0e10cSrcweir // tIMPL_RecoveryStack m_aRecoveryList ; /// cache "RecoveryList" of Internal section 149*cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 150*cdf0e10cSrcweir // public methods 151*cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir public: 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 156*cdf0e10cSrcweir // constructor / destructor 157*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir SvtInternalOptions_Impl(); 160*cdf0e10cSrcweir ~SvtInternalOptions_Impl(); 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 163*cdf0e10cSrcweir // overloaded methods of baseclass 164*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir /*-****************************************************************************************************//** 167*cdf0e10cSrcweir @short called for notify of configmanager 168*cdf0e10cSrcweir @descr These method is called from the ConfigManager before application ends or from the 169*cdf0e10cSrcweir PropertyChangeListener if the sub tree broadcasts changes. You must update your 170*cdf0e10cSrcweir internal values. 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir @seealso baseclass ConfigItem 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir @param "seqPropertyNames" is the list of properties which should be updated. 175*cdf0e10cSrcweir @return - 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir @onerror - 178*cdf0e10cSrcweir *//*-*****************************************************************************************************/ 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir virtual void Notify( const Sequence< OUString >& ) 181*cdf0e10cSrcweir { 182*cdf0e10cSrcweir DBG_ASSERT( sal_False, "SvtInternalOptions::Notify()\nNot used yet ... but called!?\n" ); 183*cdf0e10cSrcweir } 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir /*-****************************************************************************************************//** 186*cdf0e10cSrcweir @short write changes to configuration 187*cdf0e10cSrcweir @descr These method writes the changed values into the sub tree 188*cdf0e10cSrcweir and should always called in our destructor to guarantee consistency of config data. 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir @seealso baseclass ConfigItem 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir @param - 193*cdf0e10cSrcweir @return - 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir @onerror - 196*cdf0e10cSrcweir *//*-*****************************************************************************************************/ 197*cdf0e10cSrcweir 198*cdf0e10cSrcweir virtual void Commit(); 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 201*cdf0e10cSrcweir // public interface 202*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir /*-****************************************************************************************************//** 205*cdf0e10cSrcweir @short access method to get internal values 206*cdf0e10cSrcweir @descr These method give us a chance to regulate acces to ouer internal values. 207*cdf0e10cSrcweir It's not used in the moment - but it's possible for the feature! 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir @seealso - 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir @param - 212*cdf0e10cSrcweir @return - 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir @onerror - 215*cdf0e10cSrcweir *//*-*****************************************************************************************************/ 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir sal_Bool IsRemoveMenuEntryClose() const { return m_bRemoveMenuEntryClose; } 218*cdf0e10cSrcweir sal_Bool IsRemoveMenuEntryBackToWebtop() const { return m_bRemoveMenuEntryBackToWebtop; } 219*cdf0e10cSrcweir sal_Bool IsRemoveMenuEntryNewWebtop() const { return m_bRemoveMenuEntryNewWebtop; } 220*cdf0e10cSrcweir sal_Bool IsRemoveMenuEntryLogout() const { return m_bRemoveMenuEntryLogout; } 221*cdf0e10cSrcweir sal_Bool SlotCFGEnabled () const { return m_bSlotCFG; } 222*cdf0e10cSrcweir sal_Bool CrashMailEnabled () const { return m_bSendCrashMail; } 223*cdf0e10cSrcweir sal_Bool MailUIEnabled () const { return m_bUseMailUI; } 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir OUString GetCurrentTempURL() const { return m_aCurrentTempURL; } 226*cdf0e10cSrcweir void SetCurrentTempURL( const OUString& aNewCurrentTempURL ); 227*cdf0e10cSrcweir /* 228*cdf0e10cSrcweir void PushRecoveryItem ( const OUString& sURL , 229*cdf0e10cSrcweir const OUString& sFilter , 230*cdf0e10cSrcweir const OUString& sTempName ); 231*cdf0e10cSrcweir void PopRecoveryItem ( OUString& sURL , 232*cdf0e10cSrcweir OUString& sFilter , 233*cdf0e10cSrcweir OUString& sTempName ); 234*cdf0e10cSrcweir sal_Bool IsRecoveryListEmpty ( ) const; 235*cdf0e10cSrcweir */ 236*cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 237*cdf0e10cSrcweir // private methods 238*cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir private: 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir /*-****************************************************************************************************//** 243*cdf0e10cSrcweir @short return list of fix key names of ouer configuration management which represent oue module tree 244*cdf0e10cSrcweir @descr These methods return a static const list of key names. We need it to get needed values from our 245*cdf0e10cSrcweir configuration management. We return well known key names only - because the "UserData" node 246*cdf0e10cSrcweir is handled in a special way! 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir @seealso - 249*cdf0e10cSrcweir 250*cdf0e10cSrcweir @param - 251*cdf0e10cSrcweir @return A list of needed configuration keys is returned. 252*cdf0e10cSrcweir 253*cdf0e10cSrcweir @onerror - 254*cdf0e10cSrcweir *//*-*****************************************************************************************************/ 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir Sequence< OUString > impl_GetPropertyNames(); 257*cdf0e10cSrcweir }; 258*cdf0e10cSrcweir 259*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 260*cdf0e10cSrcweir // definitions 261*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 262*cdf0e10cSrcweir 263*cdf0e10cSrcweir //***************************************************************************************************************** 264*cdf0e10cSrcweir // constructor 265*cdf0e10cSrcweir //***************************************************************************************************************** 266*cdf0e10cSrcweir SvtInternalOptions_Impl::SvtInternalOptions_Impl() 267*cdf0e10cSrcweir // Init baseclasses first 268*cdf0e10cSrcweir : ConfigItem ( ROOTNODE_INTERNAL, CONFIG_MODE_IMMEDIATE_UPDATE ) 269*cdf0e10cSrcweir // Init member then. 270*cdf0e10cSrcweir , m_bRemoveMenuEntryClose ( sal_False ) 271*cdf0e10cSrcweir , m_bRemoveMenuEntryBackToWebtop ( sal_False ) 272*cdf0e10cSrcweir , m_bRemoveMenuEntryNewWebtop ( sal_False ) 273*cdf0e10cSrcweir , m_bRemoveMenuEntryLogout ( sal_False ) 274*cdf0e10cSrcweir , m_bSlotCFG ( DEFAULT_SLOTCFG ) 275*cdf0e10cSrcweir , m_bSendCrashMail ( DEFAULT_SENDCRASHMAIL ) 276*cdf0e10cSrcweir , m_bUseMailUI ( DEFAULT_USEMAILUI ) 277*cdf0e10cSrcweir , m_aCurrentTempURL ( DEFAULT_CURRENTTEMPURL ) 278*cdf0e10cSrcweir { 279*cdf0e10cSrcweir // Use our list of configuration keys to get his values. 280*cdf0e10cSrcweir // structure of internal section: (first 2 entries are fixed - all other are member of a set!) 281*cdf0e10cSrcweir // "Slot" 282*cdf0e10cSrcweir // "SendCrashMail" 283*cdf0e10cSrcweir // "RecoveryList/r1/URL" 284*cdf0e10cSrcweir // "RecoveryList/r1/Filter" 285*cdf0e10cSrcweir // "RecoveryList/r1/TempName" 286*cdf0e10cSrcweir // "RecoveryList/r2/URL" 287*cdf0e10cSrcweir // "RecoveryList/r2/Filter" 288*cdf0e10cSrcweir // "RecoveryList/r2/TempName" 289*cdf0e10cSrcweir // "RecoveryList/.." 290*cdf0e10cSrcweir Sequence< OUString > seqNames = impl_GetPropertyNames() ; 291*cdf0e10cSrcweir Sequence< Any > seqValues = GetProperties( seqNames ) ; 292*cdf0e10cSrcweir 293*cdf0e10cSrcweir // Safe impossible cases. 294*cdf0e10cSrcweir // We need values from ALL configuration keys. 295*cdf0e10cSrcweir // Follow assignment use order of values in relation to our list of key names! 296*cdf0e10cSrcweir DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtInternalOptions_Impl::SvtInternalOptions_Impl()\nI miss some values of configuration keys!\n" ); 297*cdf0e10cSrcweir 298*cdf0e10cSrcweir // Read fixed values first! 299*cdf0e10cSrcweir DBG_ASSERT(!(seqValues[FIXPROPERTYHANDLE_SLOTCFG].getValueTypeClass()!=TypeClass_BOOLEAN) , "SvtInternalOptions_Impl::SvtInternalOptions_Impl()\nWho has changed the value type of \"Office.Common\\Internal\\Slot\"?" ); 300*cdf0e10cSrcweir DBG_ASSERT(!(seqValues[FIXPROPERTYHANDLE_SENDCRASHMAIL].getValueTypeClass()!=TypeClass_BOOLEAN) , "SvtInternalOptions_Impl::SvtInternalOptions_Impl()\nWho has changed the value type of \"Office.Common\\Internal\\SendCrashMail\"?" ); 301*cdf0e10cSrcweir seqValues[FIXPROPERTYHANDLE_SLOTCFG ] >>= m_bSlotCFG ; 302*cdf0e10cSrcweir seqValues[FIXPROPERTYHANDLE_SENDCRASHMAIL ] >>= m_bSendCrashMail ; 303*cdf0e10cSrcweir seqValues[FIXPROPERTYHANDLE_USEMAILUI ] >>= m_bUseMailUI ; 304*cdf0e10cSrcweir seqValues[FIXPROPERTYHANDLE_CURRENTTEMPURL ] >>= m_aCurrentTempURL ; 305*cdf0e10cSrcweir // seqValues[FIXPROPERTYHANDLE_REMOVEMENUENTRYCLOSE ] >>= m_bRemoveMenuEntryClose ; 306*cdf0e10cSrcweir // seqValues[FIXPROPERTYHANDLE_REMOVEMENUENTRYBACKTOWEBTOP ] >>= m_bRemoveMenuEntryBackToWebtop ; 307*cdf0e10cSrcweir // seqValues[FIXPROPERTYHANDLE_REMOVEMENUENTRYNEWWEBTOP ] >>= m_bRemoveMenuEntryNewWebtop ; 308*cdf0e10cSrcweir // seqValues[FIXPROPERTYHANDLE_REMOVEMENUENTRYLOGOUT ] >>= m_bRemoveMenuEntryLogout ; 309*cdf0e10cSrcweir /* 310*cdf0e10cSrcweir // Read dynamical set "RecoveryList" then. 311*cdf0e10cSrcweir // 3 subkeys for every item! 312*cdf0e10cSrcweir // Attention: Start at next element after last fixed entry! We must ignore "Slot" and "SendCrashMail" ... 313*cdf0e10cSrcweir tIMPL_RecoveryEntry aEntry; 314*cdf0e10cSrcweir sal_uInt32 nCount = seqValues.getLength() ; 315*cdf0e10cSrcweir sal_uInt32 nPosition = FIXPROPERTYCOUNT ; 316*cdf0e10cSrcweir 317*cdf0e10cSrcweir while( nPosition<nCount ) 318*cdf0e10cSrcweir { 319*cdf0e10cSrcweir seqValues[nPosition] >>= aEntry.sURL ; 320*cdf0e10cSrcweir ++nPosition; 321*cdf0e10cSrcweir seqValues[nPosition] >>= aEntry.sFilter ; 322*cdf0e10cSrcweir ++nPosition; 323*cdf0e10cSrcweir seqValues[nPosition] >>= aEntry.sTempName ; 324*cdf0e10cSrcweir ++nPosition; 325*cdf0e10cSrcweir m_aRecoveryList.push_front( aEntry ); 326*cdf0e10cSrcweir } 327*cdf0e10cSrcweir */ 328*cdf0e10cSrcweir // We don't need any notifications here. 329*cdf0e10cSrcweir // "Slot" and "SendCrashMail" are readonly(!) and our recovery list should not modified during runtime - it's used 330*cdf0e10cSrcweir // by our crash guard only ... otherwise we have a big problem. 331*cdf0e10cSrcweir } 332*cdf0e10cSrcweir 333*cdf0e10cSrcweir //***************************************************************************************************************** 334*cdf0e10cSrcweir // destructor 335*cdf0e10cSrcweir //***************************************************************************************************************** 336*cdf0e10cSrcweir SvtInternalOptions_Impl::~SvtInternalOptions_Impl() 337*cdf0e10cSrcweir { 338*cdf0e10cSrcweir if( IsModified() == sal_True ) 339*cdf0e10cSrcweir { 340*cdf0e10cSrcweir Commit(); 341*cdf0e10cSrcweir } 342*cdf0e10cSrcweir } 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir //***************************************************************************************************************** 345*cdf0e10cSrcweir // public method 346*cdf0e10cSrcweir //***************************************************************************************************************** 347*cdf0e10cSrcweir void SvtInternalOptions_Impl::Commit() 348*cdf0e10cSrcweir { 349*cdf0e10cSrcweir // We have to write our current temp URL 350*cdf0e10cSrcweir Sequence< OUString > aNames( 1 ); 351*cdf0e10cSrcweir OUString* pNames = aNames.getArray(); 352*cdf0e10cSrcweir Sequence< Any > aValues( 1 ); 353*cdf0e10cSrcweir Any* pValues = aValues.getArray(); 354*cdf0e10cSrcweir 355*cdf0e10cSrcweir pNames[0] = FIXPROPERTYNAME_CURRENTTEMPURL; 356*cdf0e10cSrcweir pValues[0] <<= m_aCurrentTempURL; 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir PutProperties( aNames, aValues ); 359*cdf0e10cSrcweir 360*cdf0e10cSrcweir /* 361*cdf0e10cSrcweir // Write set of dynamic properties then. 362*cdf0e10cSrcweir ClearNodeSet( PROPERTYNAME_RECOVERYLIST ); 363*cdf0e10cSrcweir 364*cdf0e10cSrcweir tIMPL_RecoveryEntry aItem ; 365*cdf0e10cSrcweir OUString sNode ; 366*cdf0e10cSrcweir Sequence< PropertyValue > seqPropertyValues( 3 ) ; // Every node in set has 3 sub-nodes!( url, filter, tempname ) 367*cdf0e10cSrcweir 368*cdf0e10cSrcweir // Copy list entries to save-list and write it to configuration. 369*cdf0e10cSrcweir 370*cdf0e10cSrcweir sal_uInt32 nCount = m_aRecoveryList.size(); 371*cdf0e10cSrcweir for( sal_uInt32 nItem=0; nItem<nCount; ++nItem ) 372*cdf0e10cSrcweir { 373*cdf0e10cSrcweir aItem = m_aRecoveryList.top(); 374*cdf0e10cSrcweir m_aRecoveryList.pop(); 375*cdf0e10cSrcweir sNode = PROPERTYNAME_RECOVERYLIST + PATHDELIMITER + FIXR + OUString::valueOf( (sal_Int32)nItem ) + PATHDELIMITER; 376*cdf0e10cSrcweir seqPropertyValues[OFFSET_URL ].Name = sNode + PROPERTYNAME_URL ; 377*cdf0e10cSrcweir seqPropertyValues[OFFSET_FILTER ].Name = sNode + PROPERTYNAME_FILTER ; 378*cdf0e10cSrcweir seqPropertyValues[OFFSET_TEMPNAME ].Name = sNode + PROPERTYNAME_TEMPNAME ; 379*cdf0e10cSrcweir seqPropertyValues[OFFSET_URL ].Value <<= aItem.sURL ; 380*cdf0e10cSrcweir seqPropertyValues[OFFSET_FILTER ].Value <<= aItem.sFilter ; 381*cdf0e10cSrcweir seqPropertyValues[OFFSET_TEMPNAME ].Value <<= aItem.sTempName ; 382*cdf0e10cSrcweir 383*cdf0e10cSrcweir SetSetProperties( PROPERTYNAME_RECOVERYLIST, seqPropertyValues ); 384*cdf0e10cSrcweir } 385*cdf0e10cSrcweir 386*cdf0e10cSrcweir tIMPL_RecoveryStack::iterator iRecovery = m_aRecoveryList.begin(); 387*cdf0e10cSrcweir for ( sal_uInt32 nItem=0; iRecovery != m_aRecoveryList.end(); ++nItem, ++iRecovery) 388*cdf0e10cSrcweir { 389*cdf0e10cSrcweir aItem = *iRecovery; 390*cdf0e10cSrcweir sNode = PROPERTYNAME_RECOVERYLIST + PATHDELIMITER + FIXR + 391*cdf0e10cSrcweir OUString::valueOf( (sal_Int32)nItem ) + PATHDELIMITER; 392*cdf0e10cSrcweir seqPropertyValues[OFFSET_URL ].Name = sNode + PROPERTYNAME_URL ; 393*cdf0e10cSrcweir seqPropertyValues[OFFSET_FILTER ].Name = sNode + PROPERTYNAME_FILTER ; 394*cdf0e10cSrcweir seqPropertyValues[OFFSET_TEMPNAME ].Name = sNode + PROPERTYNAME_TEMPNAME ; 395*cdf0e10cSrcweir seqPropertyValues[OFFSET_URL ].Value <<= iRecovery->sURL ; 396*cdf0e10cSrcweir seqPropertyValues[OFFSET_FILTER ].Value <<= iRecovery->sFilter ; 397*cdf0e10cSrcweir seqPropertyValues[OFFSET_TEMPNAME ].Value <<= iRecovery->sTempName ; 398*cdf0e10cSrcweir SetSetProperties( PROPERTYNAME_RECOVERYLIST, seqPropertyValues ); 399*cdf0e10cSrcweir } 400*cdf0e10cSrcweir 401*cdf0e10cSrcweir */ 402*cdf0e10cSrcweir } 403*cdf0e10cSrcweir 404*cdf0e10cSrcweir //***************************************************************************************************************** 405*cdf0e10cSrcweir // public method 406*cdf0e10cSrcweir //***************************************************************************************************************** 407*cdf0e10cSrcweir void SvtInternalOptions_Impl::SetCurrentTempURL( const OUString& aNewCurrentTempURL ) 408*cdf0e10cSrcweir { 409*cdf0e10cSrcweir m_aCurrentTempURL = aNewCurrentTempURL; 410*cdf0e10cSrcweir SetModified(); 411*cdf0e10cSrcweir Commit(); 412*cdf0e10cSrcweir } 413*cdf0e10cSrcweir 414*cdf0e10cSrcweir #if 0 415*cdf0e10cSrcweir //***************************************************************************************************************** 416*cdf0e10cSrcweir // public method 417*cdf0e10cSrcweir //***************************************************************************************************************** 418*cdf0e10cSrcweir void SvtInternalOptions_Impl::PushRecoveryItem( const OUString& sURL , 419*cdf0e10cSrcweir const OUString& sFilter , 420*cdf0e10cSrcweir const OUString& sTempName ) 421*cdf0e10cSrcweir { 422*cdf0e10cSrcweir tIMPL_RecoveryEntry aEntry( sURL, sFilter, sTempName ); 423*cdf0e10cSrcweir m_aRecoveryList.push_front( aEntry ); 424*cdf0e10cSrcweir SetModified(); 425*cdf0e10cSrcweir } 426*cdf0e10cSrcweir 427*cdf0e10cSrcweir //***************************************************************************************************************** 428*cdf0e10cSrcweir // public method 429*cdf0e10cSrcweir //***************************************************************************************************************** 430*cdf0e10cSrcweir void SvtInternalOptions_Impl::PopRecoveryItem( OUString& sURL , 431*cdf0e10cSrcweir OUString& sFilter , 432*cdf0e10cSrcweir OUString& sTempName ) 433*cdf0e10cSrcweir { 434*cdf0e10cSrcweir tIMPL_RecoveryEntry aEntry = m_aRecoveryList.front(); 435*cdf0e10cSrcweir m_aRecoveryList.pop_front(); 436*cdf0e10cSrcweir SetModified(); // Don't forget it - we delete an entry here! 437*cdf0e10cSrcweir sURL = aEntry.sURL ; 438*cdf0e10cSrcweir sFilter = aEntry.sFilter ; 439*cdf0e10cSrcweir sTempName = aEntry.sTempName ; 440*cdf0e10cSrcweir } 441*cdf0e10cSrcweir 442*cdf0e10cSrcweir //***************************************************************************************************************** 443*cdf0e10cSrcweir // public method 444*cdf0e10cSrcweir //***************************************************************************************************************** 445*cdf0e10cSrcweir sal_Bool SvtInternalOptions_Impl::IsRecoveryListEmpty() const 446*cdf0e10cSrcweir { 447*cdf0e10cSrcweir return ( m_aRecoveryList.empty() ); 448*cdf0e10cSrcweir } 449*cdf0e10cSrcweir #endif 450*cdf0e10cSrcweir 451*cdf0e10cSrcweir //***************************************************************************************************************** 452*cdf0e10cSrcweir // private method 453*cdf0e10cSrcweir //***************************************************************************************************************** 454*cdf0e10cSrcweir Sequence< OUString > SvtInternalOptions_Impl::impl_GetPropertyNames() 455*cdf0e10cSrcweir { 456*cdf0e10cSrcweir /* 457*cdf0e10cSrcweir // First get ALL names of current existing list items in configuration! 458*cdf0e10cSrcweir Sequence< OUString > seqRecoveryItems = GetNodeNames( PROPERTYNAME_RECOVERYLIST ); 459*cdf0e10cSrcweir // Get information about list counts ... 460*cdf0e10cSrcweir sal_Int32 nRecoveryCount = seqRecoveryItems.getLength(); 461*cdf0e10cSrcweir // ... and create a property list with right size! (+2...for fix properties!) (*3 ... = sub nodes for every set node!) 462*cdf0e10cSrcweir Sequence< OUString > seqProperties( FIXPROPERTYCOUNT + (nRecoveryCount*3) ); 463*cdf0e10cSrcweir */ 464*cdf0e10cSrcweir Sequence< OUString > seqProperties(4); 465*cdf0e10cSrcweir 466*cdf0e10cSrcweir // Add names of fix properties to list. 467*cdf0e10cSrcweir seqProperties[FIXPROPERTYHANDLE_SLOTCFG ] = FIXPROPERTYNAME_SLOTCFG ; 468*cdf0e10cSrcweir seqProperties[FIXPROPERTYHANDLE_SENDCRASHMAIL ] = FIXPROPERTYNAME_SENDCRASHMAIL ; 469*cdf0e10cSrcweir seqProperties[FIXPROPERTYHANDLE_USEMAILUI ] = FIXPROPERTYNAME_USEMAILUI ; 470*cdf0e10cSrcweir seqProperties[FIXPROPERTYHANDLE_CURRENTTEMPURL ] = FIXPROPERTYNAME_CURRENTTEMPURL ; 471*cdf0e10cSrcweir // seqProperties[FIXPROPERTYHANDLE_REMOVEMENUENTRYCLOSE ] = FIXPROPERTYNAME_REMOVEMENUENTRYCLOSE; 472*cdf0e10cSrcweir // seqProperties[FIXPROPERTYHANDLE_REMOVEMENUENTRYBACKTOWEBTOP ] = FIXPROPERTYNAME_REMOVEMENUENTRYBACKTOWEBTOP; 473*cdf0e10cSrcweir // seqProperties[FIXPROPERTYHANDLE_REMOVEMENUENTRYNEWWEBTOP ] = FIXPROPERTYNAME_REMOVEMENUENTRYNEWWEBTOP; 474*cdf0e10cSrcweir // seqProperties[FIXPROPERTYHANDLE_REMOVEMENUENTRYLOGOUT ] = FIXPROPERTYNAME_REMOVEMENUENTRYLOGOUT; 475*cdf0e10cSrcweir /* 476*cdf0e10cSrcweir sal_uInt32 nPosition = FIXPROPERTYCOUNT; 477*cdf0e10cSrcweir // Add names for recovery list to list. 478*cdf0e10cSrcweir // 3 subkeys for every item! 479*cdf0e10cSrcweir // nPosition is the start point of an list item, nItem an index into right list of node names! 480*cdf0e10cSrcweir for( sal_Int32 nItem=0; nItem<nRecoveryCount; ++nItem ) 481*cdf0e10cSrcweir { 482*cdf0e10cSrcweir seqProperties[nPosition] = PROPERTYNAME_RECOVERYLIST + PATHDELIMITER + seqRecoveryItems[nItem] + PATHDELIMITER + PROPERTYNAME_URL ; 483*cdf0e10cSrcweir ++nPosition; 484*cdf0e10cSrcweir seqProperties[nPosition] = PROPERTYNAME_RECOVERYLIST + PATHDELIMITER + seqRecoveryItems[nItem] + PATHDELIMITER + PROPERTYNAME_FILTER ; 485*cdf0e10cSrcweir ++nPosition; 486*cdf0e10cSrcweir seqProperties[nPosition] = PROPERTYNAME_RECOVERYLIST + PATHDELIMITER + seqRecoveryItems[nItem] + PATHDELIMITER + PROPERTYNAME_TEMPNAME ; 487*cdf0e10cSrcweir ++nPosition; 488*cdf0e10cSrcweir } 489*cdf0e10cSrcweir */ 490*cdf0e10cSrcweir // Return result. 491*cdf0e10cSrcweir return seqProperties; 492*cdf0e10cSrcweir } 493*cdf0e10cSrcweir 494*cdf0e10cSrcweir //***************************************************************************************************************** 495*cdf0e10cSrcweir // initialize static member 496*cdf0e10cSrcweir // DON'T DO IT IN YOUR HEADER! 497*cdf0e10cSrcweir // see definition for further informations 498*cdf0e10cSrcweir //***************************************************************************************************************** 499*cdf0e10cSrcweir SvtInternalOptions_Impl* SvtInternalOptions::m_pDataContainer = NULL ; 500*cdf0e10cSrcweir sal_Int32 SvtInternalOptions::m_nRefCount = 0 ; 501*cdf0e10cSrcweir 502*cdf0e10cSrcweir //***************************************************************************************************************** 503*cdf0e10cSrcweir // constructor 504*cdf0e10cSrcweir //***************************************************************************************************************** 505*cdf0e10cSrcweir SvtInternalOptions::SvtInternalOptions() 506*cdf0e10cSrcweir { 507*cdf0e10cSrcweir // Global access, must be guarded (multithreading!). 508*cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 509*cdf0e10cSrcweir // Increase ouer refcount ... 510*cdf0e10cSrcweir ++m_nRefCount; 511*cdf0e10cSrcweir // ... and initialize ouer data container only if it not already! 512*cdf0e10cSrcweir if( m_pDataContainer == NULL ) 513*cdf0e10cSrcweir { 514*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT(aLog, "unotools ( ??? ) ::SvtInternalOptions_Impl::ctor()"); 515*cdf0e10cSrcweir m_pDataContainer = new SvtInternalOptions_Impl(); 516*cdf0e10cSrcweir 517*cdf0e10cSrcweir ItemHolder1::holdConfigItem(E_INTERNALOPTIONS); 518*cdf0e10cSrcweir } 519*cdf0e10cSrcweir } 520*cdf0e10cSrcweir 521*cdf0e10cSrcweir //***************************************************************************************************************** 522*cdf0e10cSrcweir // destructor 523*cdf0e10cSrcweir //***************************************************************************************************************** 524*cdf0e10cSrcweir SvtInternalOptions::~SvtInternalOptions() 525*cdf0e10cSrcweir { 526*cdf0e10cSrcweir // Global access, must be guarded (multithreading!) 527*cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 528*cdf0e10cSrcweir // Decrease ouer refcount. 529*cdf0e10cSrcweir --m_nRefCount; 530*cdf0e10cSrcweir // If last instance was deleted ... 531*cdf0e10cSrcweir // we must destroy ouer static data container! 532*cdf0e10cSrcweir if( m_nRefCount <= 0 ) 533*cdf0e10cSrcweir { 534*cdf0e10cSrcweir delete m_pDataContainer; 535*cdf0e10cSrcweir m_pDataContainer = NULL; 536*cdf0e10cSrcweir } 537*cdf0e10cSrcweir } 538*cdf0e10cSrcweir 539*cdf0e10cSrcweir //***************************************************************************************************************** 540*cdf0e10cSrcweir // public method 541*cdf0e10cSrcweir //***************************************************************************************************************** 542*cdf0e10cSrcweir sal_Bool SvtInternalOptions::SlotCFGEnabled() const 543*cdf0e10cSrcweir { 544*cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 545*cdf0e10cSrcweir return m_pDataContainer->SlotCFGEnabled(); 546*cdf0e10cSrcweir } 547*cdf0e10cSrcweir 548*cdf0e10cSrcweir //***************************************************************************************************************** 549*cdf0e10cSrcweir // public method 550*cdf0e10cSrcweir //***************************************************************************************************************** 551*cdf0e10cSrcweir sal_Bool SvtInternalOptions::CrashMailEnabled() const 552*cdf0e10cSrcweir { 553*cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 554*cdf0e10cSrcweir return m_pDataContainer->CrashMailEnabled(); 555*cdf0e10cSrcweir } 556*cdf0e10cSrcweir 557*cdf0e10cSrcweir //***************************************************************************************************************** 558*cdf0e10cSrcweir // public method 559*cdf0e10cSrcweir //***************************************************************************************************************** 560*cdf0e10cSrcweir sal_Bool SvtInternalOptions::MailUIEnabled() const 561*cdf0e10cSrcweir { 562*cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 563*cdf0e10cSrcweir return m_pDataContainer->MailUIEnabled(); 564*cdf0e10cSrcweir } 565*cdf0e10cSrcweir 566*cdf0e10cSrcweir //***************************************************************************************************************** 567*cdf0e10cSrcweir // public methods 568*cdf0e10cSrcweir //***************************************************************************************************************** 569*cdf0e10cSrcweir sal_Bool SvtInternalOptions::IsRemoveMenuEntryClose() const 570*cdf0e10cSrcweir { 571*cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 572*cdf0e10cSrcweir return m_pDataContainer->IsRemoveMenuEntryClose(); 573*cdf0e10cSrcweir } 574*cdf0e10cSrcweir 575*cdf0e10cSrcweir sal_Bool SvtInternalOptions::IsRemoveMenuEntryBackToWebtop() const 576*cdf0e10cSrcweir { 577*cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 578*cdf0e10cSrcweir return m_pDataContainer->IsRemoveMenuEntryBackToWebtop(); 579*cdf0e10cSrcweir } 580*cdf0e10cSrcweir 581*cdf0e10cSrcweir sal_Bool SvtInternalOptions::IsRemoveMenuEntryNewWebtop() const 582*cdf0e10cSrcweir { 583*cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 584*cdf0e10cSrcweir return m_pDataContainer->IsRemoveMenuEntryNewWebtop(); 585*cdf0e10cSrcweir } 586*cdf0e10cSrcweir 587*cdf0e10cSrcweir sal_Bool SvtInternalOptions::IsRemoveMenuEntryLogout() const 588*cdf0e10cSrcweir { 589*cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 590*cdf0e10cSrcweir return m_pDataContainer->IsRemoveMenuEntryLogout(); 591*cdf0e10cSrcweir } 592*cdf0e10cSrcweir 593*cdf0e10cSrcweir OUString SvtInternalOptions::GetCurrentTempURL() const 594*cdf0e10cSrcweir { 595*cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 596*cdf0e10cSrcweir return m_pDataContainer->GetCurrentTempURL(); 597*cdf0e10cSrcweir } 598*cdf0e10cSrcweir 599*cdf0e10cSrcweir void SvtInternalOptions::SetCurrentTempURL( const OUString& aNewCurrentTempURL ) 600*cdf0e10cSrcweir { 601*cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 602*cdf0e10cSrcweir m_pDataContainer->SetCurrentTempURL( aNewCurrentTempURL ); 603*cdf0e10cSrcweir } 604*cdf0e10cSrcweir 605*cdf0e10cSrcweir //***************************************************************************************************************** 606*cdf0e10cSrcweir // private method 607*cdf0e10cSrcweir //***************************************************************************************************************** 608*cdf0e10cSrcweir Mutex& SvtInternalOptions::GetOwnStaticMutex() 609*cdf0e10cSrcweir { 610*cdf0e10cSrcweir // Initialize static mutex only for one time! 611*cdf0e10cSrcweir static Mutex* pMutex = NULL; 612*cdf0e10cSrcweir // If these method first called (Mutex not already exist!) ... 613*cdf0e10cSrcweir if( pMutex == NULL ) 614*cdf0e10cSrcweir { 615*cdf0e10cSrcweir // ... we must create a new one. Protect follow code with the global mutex - 616*cdf0e10cSrcweir // It must be - we create a static variable! 617*cdf0e10cSrcweir MutexGuard aGuard( Mutex::getGlobalMutex() ); 618*cdf0e10cSrcweir // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these! 619*cdf0e10cSrcweir if( pMutex == NULL ) 620*cdf0e10cSrcweir { 621*cdf0e10cSrcweir // Create the new mutex and set it for return on static variable. 622*cdf0e10cSrcweir static Mutex aMutex; 623*cdf0e10cSrcweir pMutex = &aMutex; 624*cdf0e10cSrcweir } 625*cdf0e10cSrcweir } 626*cdf0e10cSrcweir // Return new created or already existing mutex object. 627*cdf0e10cSrcweir return *pMutex; 628*cdf0e10cSrcweir } 629