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 31*cdf0e10cSrcweir #ifndef GCC 32*cdf0e10cSrcweir #endif 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir #include <unotools/saveopt.hxx> 35*cdf0e10cSrcweir #include "rtl/instance.hxx" 36*cdf0e10cSrcweir #include <unotools/configmgr.hxx> 37*cdf0e10cSrcweir #include <unotools/configitem.hxx> 38*cdf0e10cSrcweir #include <tools/debug.hxx> 39*cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx> 40*cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx> 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir #include <osl/mutex.hxx> 43*cdf0e10cSrcweir #include <comphelper/configurationhelper.hxx> 44*cdf0e10cSrcweir #include <unotools/processfactory.hxx> 45*cdf0e10cSrcweir #include <rtl/logfile.hxx> 46*cdf0e10cSrcweir #include "itemholder1.hxx" 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir using namespace utl; 49*cdf0e10cSrcweir using namespace rtl; 50*cdf0e10cSrcweir using namespace com::sun::star::uno; 51*cdf0e10cSrcweir namespace css = ::com::sun::star; 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir class SvtSaveOptions_Impl; 54*cdf0e10cSrcweir class SvtLoadOptions_Impl; 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir #define CFG_READONLY_DEFAULT sal_False 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir struct SvtLoadSaveOptions_Impl 59*cdf0e10cSrcweir { 60*cdf0e10cSrcweir SvtSaveOptions_Impl* pSaveOpt; 61*cdf0e10cSrcweir SvtLoadOptions_Impl* pLoadOpt; 62*cdf0e10cSrcweir }; 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir static SvtLoadSaveOptions_Impl* pOptions = NULL; 65*cdf0e10cSrcweir static sal_Int32 nRefCount = 0; 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir class SvtSaveOptions_Impl : public utl::ConfigItem 68*cdf0e10cSrcweir { 69*cdf0e10cSrcweir sal_Int32 nAutoSaveTime; 70*cdf0e10cSrcweir sal_Bool bUseUserData, 71*cdf0e10cSrcweir bBackup, 72*cdf0e10cSrcweir bAutoSave, 73*cdf0e10cSrcweir bAutoSavePrompt, 74*cdf0e10cSrcweir bDocInfSave, 75*cdf0e10cSrcweir bSaveWorkingSet, 76*cdf0e10cSrcweir bSaveDocView, 77*cdf0e10cSrcweir bSaveRelINet, 78*cdf0e10cSrcweir bSaveRelFSys, 79*cdf0e10cSrcweir bSaveUnpacked, 80*cdf0e10cSrcweir bDoPrettyPrinting, 81*cdf0e10cSrcweir bWarnAlienFormat, 82*cdf0e10cSrcweir bLoadDocPrinter, 83*cdf0e10cSrcweir bUseSHA1InODF12, 84*cdf0e10cSrcweir bUseBlowfishInODF12; 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir SvtSaveOptions::ODFDefaultVersion eODFDefaultVersion; 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir sal_Bool bROAutoSaveTime, 89*cdf0e10cSrcweir bROUseUserData, 90*cdf0e10cSrcweir bROBackup, 91*cdf0e10cSrcweir bROAutoSave, 92*cdf0e10cSrcweir bROAutoSavePrompt, 93*cdf0e10cSrcweir bRODocInfSave, 94*cdf0e10cSrcweir bROSaveWorkingSet, 95*cdf0e10cSrcweir bROSaveDocView, 96*cdf0e10cSrcweir bROSaveRelINet, 97*cdf0e10cSrcweir bROSaveRelFSys, 98*cdf0e10cSrcweir bROSaveUnpacked, 99*cdf0e10cSrcweir bROWarnAlienFormat, 100*cdf0e10cSrcweir bRODoPrettyPrinting, 101*cdf0e10cSrcweir bROLoadDocPrinter, 102*cdf0e10cSrcweir bROODFDefaultVersion, 103*cdf0e10cSrcweir bROUseSHA1InODF12, 104*cdf0e10cSrcweir bROUseBlowfishInODF12; 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir public: 107*cdf0e10cSrcweir SvtSaveOptions_Impl(); 108*cdf0e10cSrcweir ~SvtSaveOptions_Impl(); 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames ); 111*cdf0e10cSrcweir virtual void Commit(); 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir sal_Int32 GetAutoSaveTime() const { return nAutoSaveTime; } 114*cdf0e10cSrcweir sal_Bool IsUseUserData() const { return bUseUserData; } 115*cdf0e10cSrcweir sal_Bool IsBackup() const { return bBackup; } 116*cdf0e10cSrcweir sal_Bool IsAutoSave() const { return bAutoSave; } 117*cdf0e10cSrcweir sal_Bool IsAutoSavePrompt() const { return bAutoSavePrompt; } 118*cdf0e10cSrcweir sal_Bool IsDocInfoSave() const { return bDocInfSave; } 119*cdf0e10cSrcweir sal_Bool IsSaveWorkingSet() const { return bSaveWorkingSet; } 120*cdf0e10cSrcweir sal_Bool IsSaveDocView() const { return bSaveDocView; } 121*cdf0e10cSrcweir sal_Bool IsSaveRelINet() const { return bSaveRelINet; } 122*cdf0e10cSrcweir sal_Bool IsSaveRelFSys() const { return bSaveRelFSys; } 123*cdf0e10cSrcweir sal_Bool IsSaveUnpacked() const { return bSaveUnpacked; } 124*cdf0e10cSrcweir sal_Bool IsPrettyPrintingEnabled( ) const { return bDoPrettyPrinting; } 125*cdf0e10cSrcweir sal_Bool IsWarnAlienFormat() const { return bWarnAlienFormat; } 126*cdf0e10cSrcweir sal_Bool IsLoadDocPrinter() const { return bLoadDocPrinter; } 127*cdf0e10cSrcweir sal_Bool IsUseSHA1InODF12() const { return bUseSHA1InODF12; } 128*cdf0e10cSrcweir sal_Bool IsUseBlowfishInODF12() const { return bUseBlowfishInODF12; } 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir SvtSaveOptions::ODFDefaultVersion 131*cdf0e10cSrcweir GetODFDefaultVersion() const { return eODFDefaultVersion; } 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir void SetAutoSaveTime( sal_Int32 n ); 134*cdf0e10cSrcweir void SetUseUserData( sal_Bool b ); 135*cdf0e10cSrcweir void SetBackup( sal_Bool b ); 136*cdf0e10cSrcweir void SetAutoSave( sal_Bool b ); 137*cdf0e10cSrcweir void SetAutoSavePrompt( sal_Bool b ); 138*cdf0e10cSrcweir void SetDocInfoSave( sal_Bool b ); 139*cdf0e10cSrcweir void SetSaveWorkingSet( sal_Bool b ); 140*cdf0e10cSrcweir void SetSaveDocView( sal_Bool b ); 141*cdf0e10cSrcweir void SetSaveRelINet( sal_Bool b ); 142*cdf0e10cSrcweir void SetSaveRelFSys( sal_Bool b ); 143*cdf0e10cSrcweir void SetSaveUnpacked( sal_Bool b ); 144*cdf0e10cSrcweir void EnablePrettyPrinting( sal_Bool _bDoPP ); 145*cdf0e10cSrcweir void SetWarnAlienFormat( sal_Bool _bDoPP ); 146*cdf0e10cSrcweir void SetLoadDocPrinter( sal_Bool bNew ); 147*cdf0e10cSrcweir void SetUseSHA1InODF12( sal_Bool bUse ); 148*cdf0e10cSrcweir void SetUseBlowfishInODF12( sal_Bool bUse ); 149*cdf0e10cSrcweir void SetODFDefaultVersion( SvtSaveOptions::ODFDefaultVersion eNew ); 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir sal_Bool IsReadOnly( SvtSaveOptions::EOption eOption ) const; 152*cdf0e10cSrcweir }; 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir void SvtSaveOptions_Impl::SetAutoSaveTime( sal_Int32 n ) 155*cdf0e10cSrcweir { 156*cdf0e10cSrcweir if (!bROAutoSaveTime && nAutoSaveTime!=n) 157*cdf0e10cSrcweir { 158*cdf0e10cSrcweir nAutoSaveTime = n; 159*cdf0e10cSrcweir SetModified(); 160*cdf0e10cSrcweir Commit(); 161*cdf0e10cSrcweir } 162*cdf0e10cSrcweir } 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir void SvtSaveOptions_Impl::SetUseUserData( sal_Bool b ) 165*cdf0e10cSrcweir { 166*cdf0e10cSrcweir if (!bROUseUserData && bUseUserData!=b) 167*cdf0e10cSrcweir { 168*cdf0e10cSrcweir bUseUserData = b; 169*cdf0e10cSrcweir SetModified(); 170*cdf0e10cSrcweir } 171*cdf0e10cSrcweir } 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir void SvtSaveOptions_Impl::SetBackup( sal_Bool b ) 174*cdf0e10cSrcweir { 175*cdf0e10cSrcweir if (!bROBackup && bBackup!=b) 176*cdf0e10cSrcweir { 177*cdf0e10cSrcweir bBackup = b; 178*cdf0e10cSrcweir SetModified(); 179*cdf0e10cSrcweir } 180*cdf0e10cSrcweir } 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir void SvtSaveOptions_Impl::SetAutoSave( sal_Bool b ) 183*cdf0e10cSrcweir { 184*cdf0e10cSrcweir if (!bROAutoSave && bAutoSave!=b) 185*cdf0e10cSrcweir { 186*cdf0e10cSrcweir bAutoSave = b; 187*cdf0e10cSrcweir SetModified(); 188*cdf0e10cSrcweir Commit(); 189*cdf0e10cSrcweir } 190*cdf0e10cSrcweir } 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir void SvtSaveOptions_Impl::SetAutoSavePrompt( sal_Bool b ) 193*cdf0e10cSrcweir { 194*cdf0e10cSrcweir if (!bROAutoSavePrompt && bAutoSavePrompt!=b) 195*cdf0e10cSrcweir { 196*cdf0e10cSrcweir bAutoSavePrompt = b; 197*cdf0e10cSrcweir SetModified(); 198*cdf0e10cSrcweir } 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir void SvtSaveOptions_Impl::SetDocInfoSave(sal_Bool b) 202*cdf0e10cSrcweir { 203*cdf0e10cSrcweir if (!bRODocInfSave && bDocInfSave!=b) 204*cdf0e10cSrcweir { 205*cdf0e10cSrcweir bDocInfSave = b; 206*cdf0e10cSrcweir SetModified(); 207*cdf0e10cSrcweir } 208*cdf0e10cSrcweir } 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir void SvtSaveOptions_Impl::SetSaveWorkingSet( sal_Bool b ) 211*cdf0e10cSrcweir { 212*cdf0e10cSrcweir if (!bROSaveWorkingSet && bSaveWorkingSet!=b) 213*cdf0e10cSrcweir { 214*cdf0e10cSrcweir bSaveWorkingSet = b; 215*cdf0e10cSrcweir SetModified(); 216*cdf0e10cSrcweir } 217*cdf0e10cSrcweir } 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir void SvtSaveOptions_Impl::SetSaveDocView( sal_Bool b ) 220*cdf0e10cSrcweir { 221*cdf0e10cSrcweir if (!bROSaveDocView && bSaveDocView!=b) 222*cdf0e10cSrcweir { 223*cdf0e10cSrcweir bSaveDocView = b; 224*cdf0e10cSrcweir SetModified(); 225*cdf0e10cSrcweir } 226*cdf0e10cSrcweir } 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir void SvtSaveOptions_Impl::SetSaveRelINet( sal_Bool b ) 229*cdf0e10cSrcweir { 230*cdf0e10cSrcweir if (!bROSaveRelINet && bSaveRelINet!=b) 231*cdf0e10cSrcweir { 232*cdf0e10cSrcweir bSaveRelINet = b; 233*cdf0e10cSrcweir SetModified(); 234*cdf0e10cSrcweir } 235*cdf0e10cSrcweir } 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir void SvtSaveOptions_Impl::SetSaveRelFSys( sal_Bool b ) 238*cdf0e10cSrcweir { 239*cdf0e10cSrcweir if (!bROSaveRelFSys && bSaveRelFSys!=b) 240*cdf0e10cSrcweir { 241*cdf0e10cSrcweir bSaveRelFSys = b; 242*cdf0e10cSrcweir SetModified(); 243*cdf0e10cSrcweir } 244*cdf0e10cSrcweir } 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir void SvtSaveOptions_Impl::SetSaveUnpacked( sal_Bool b ) 247*cdf0e10cSrcweir { 248*cdf0e10cSrcweir if (!bROSaveUnpacked && bSaveUnpacked!=b) 249*cdf0e10cSrcweir { 250*cdf0e10cSrcweir bSaveUnpacked = b; 251*cdf0e10cSrcweir SetModified(); 252*cdf0e10cSrcweir } 253*cdf0e10cSrcweir } 254*cdf0e10cSrcweir 255*cdf0e10cSrcweir void SvtSaveOptions_Impl::EnablePrettyPrinting( sal_Bool _bDoPP ) 256*cdf0e10cSrcweir { 257*cdf0e10cSrcweir if (!bRODoPrettyPrinting && bDoPrettyPrinting!=_bDoPP) 258*cdf0e10cSrcweir { 259*cdf0e10cSrcweir bDoPrettyPrinting = _bDoPP; 260*cdf0e10cSrcweir SetModified(); 261*cdf0e10cSrcweir } 262*cdf0e10cSrcweir } 263*cdf0e10cSrcweir 264*cdf0e10cSrcweir void SvtSaveOptions_Impl::SetWarnAlienFormat( sal_Bool _bDoPP ) 265*cdf0e10cSrcweir { 266*cdf0e10cSrcweir if (!bROWarnAlienFormat && bWarnAlienFormat!=_bDoPP) 267*cdf0e10cSrcweir { 268*cdf0e10cSrcweir bWarnAlienFormat = _bDoPP; 269*cdf0e10cSrcweir SetModified(); 270*cdf0e10cSrcweir } 271*cdf0e10cSrcweir } 272*cdf0e10cSrcweir 273*cdf0e10cSrcweir void SvtSaveOptions_Impl::SetLoadDocPrinter( sal_Bool bNew ) 274*cdf0e10cSrcweir { 275*cdf0e10cSrcweir if ( !bROLoadDocPrinter && bLoadDocPrinter != bNew ) 276*cdf0e10cSrcweir { 277*cdf0e10cSrcweir bLoadDocPrinter = bNew; 278*cdf0e10cSrcweir SetModified(); 279*cdf0e10cSrcweir } 280*cdf0e10cSrcweir } 281*cdf0e10cSrcweir 282*cdf0e10cSrcweir void SvtSaveOptions_Impl::SetODFDefaultVersion( SvtSaveOptions::ODFDefaultVersion eNew ) 283*cdf0e10cSrcweir { 284*cdf0e10cSrcweir if ( !bROODFDefaultVersion && eODFDefaultVersion != eNew ) 285*cdf0e10cSrcweir { 286*cdf0e10cSrcweir eODFDefaultVersion = eNew; 287*cdf0e10cSrcweir SetModified(); 288*cdf0e10cSrcweir } 289*cdf0e10cSrcweir } 290*cdf0e10cSrcweir 291*cdf0e10cSrcweir void SvtSaveOptions_Impl::SetUseSHA1InODF12( sal_Bool bUse ) 292*cdf0e10cSrcweir { 293*cdf0e10cSrcweir if ( !bROUseSHA1InODF12 && bUseSHA1InODF12 != bUse ) 294*cdf0e10cSrcweir { 295*cdf0e10cSrcweir bUseSHA1InODF12 = bUse; 296*cdf0e10cSrcweir SetModified(); 297*cdf0e10cSrcweir } 298*cdf0e10cSrcweir } 299*cdf0e10cSrcweir 300*cdf0e10cSrcweir void SvtSaveOptions_Impl::SetUseBlowfishInODF12( sal_Bool bUse ) 301*cdf0e10cSrcweir { 302*cdf0e10cSrcweir if ( !bROUseBlowfishInODF12 && bUseBlowfishInODF12 != bUse ) 303*cdf0e10cSrcweir { 304*cdf0e10cSrcweir bUseBlowfishInODF12 = bUse; 305*cdf0e10cSrcweir SetModified(); 306*cdf0e10cSrcweir } 307*cdf0e10cSrcweir } 308*cdf0e10cSrcweir 309*cdf0e10cSrcweir sal_Bool SvtSaveOptions_Impl::IsReadOnly( SvtSaveOptions::EOption eOption ) const 310*cdf0e10cSrcweir { 311*cdf0e10cSrcweir sal_Bool bReadOnly = CFG_READONLY_DEFAULT; 312*cdf0e10cSrcweir switch(eOption) 313*cdf0e10cSrcweir { 314*cdf0e10cSrcweir case SvtSaveOptions::E_AUTOSAVETIME : 315*cdf0e10cSrcweir bReadOnly = bROAutoSaveTime; 316*cdf0e10cSrcweir break; 317*cdf0e10cSrcweir case SvtSaveOptions::E_USEUSERDATA : 318*cdf0e10cSrcweir bReadOnly = bROUseUserData; 319*cdf0e10cSrcweir break; 320*cdf0e10cSrcweir case SvtSaveOptions::E_BACKUP : 321*cdf0e10cSrcweir bReadOnly = bROBackup; 322*cdf0e10cSrcweir break; 323*cdf0e10cSrcweir case SvtSaveOptions::E_AUTOSAVE : 324*cdf0e10cSrcweir bReadOnly = bROAutoSave; 325*cdf0e10cSrcweir break; 326*cdf0e10cSrcweir case SvtSaveOptions::E_AUTOSAVEPROMPT : 327*cdf0e10cSrcweir bReadOnly = bROAutoSavePrompt; 328*cdf0e10cSrcweir break; 329*cdf0e10cSrcweir case SvtSaveOptions::E_DOCINFSAVE : 330*cdf0e10cSrcweir bReadOnly = bRODocInfSave; 331*cdf0e10cSrcweir break; 332*cdf0e10cSrcweir case SvtSaveOptions::E_SAVEWORKINGSET : 333*cdf0e10cSrcweir bReadOnly = bROSaveWorkingSet; 334*cdf0e10cSrcweir break; 335*cdf0e10cSrcweir case SvtSaveOptions::E_SAVEDOCVIEW : 336*cdf0e10cSrcweir bReadOnly = bROSaveDocView; 337*cdf0e10cSrcweir break; 338*cdf0e10cSrcweir case SvtSaveOptions::E_SAVERELINET : 339*cdf0e10cSrcweir bReadOnly = bROSaveRelINet; 340*cdf0e10cSrcweir break; 341*cdf0e10cSrcweir case SvtSaveOptions::E_SAVERELFSYS : 342*cdf0e10cSrcweir bReadOnly = bROSaveRelFSys; 343*cdf0e10cSrcweir break; 344*cdf0e10cSrcweir case SvtSaveOptions::E_SAVEUNPACKED : 345*cdf0e10cSrcweir bReadOnly = bROSaveUnpacked; 346*cdf0e10cSrcweir break; 347*cdf0e10cSrcweir case SvtSaveOptions::E_DOPRETTYPRINTING : 348*cdf0e10cSrcweir bReadOnly = bRODoPrettyPrinting; 349*cdf0e10cSrcweir break; 350*cdf0e10cSrcweir case SvtSaveOptions::E_WARNALIENFORMAT : 351*cdf0e10cSrcweir bReadOnly = bROWarnAlienFormat; 352*cdf0e10cSrcweir break; 353*cdf0e10cSrcweir case SvtSaveOptions::E_LOADDOCPRINTER : 354*cdf0e10cSrcweir bReadOnly = bROLoadDocPrinter; 355*cdf0e10cSrcweir break; 356*cdf0e10cSrcweir case SvtSaveOptions::E_ODFDEFAULTVERSION : 357*cdf0e10cSrcweir bReadOnly = bROLoadDocPrinter; 358*cdf0e10cSrcweir break; 359*cdf0e10cSrcweir case SvtSaveOptions::E_USESHA1INODF12: 360*cdf0e10cSrcweir bReadOnly = bROUseSHA1InODF12; 361*cdf0e10cSrcweir break; 362*cdf0e10cSrcweir case SvtSaveOptions::E_USEBLOWFISHINODF12: 363*cdf0e10cSrcweir bReadOnly = bROUseBlowfishInODF12; 364*cdf0e10cSrcweir break; 365*cdf0e10cSrcweir } 366*cdf0e10cSrcweir return bReadOnly; 367*cdf0e10cSrcweir } 368*cdf0e10cSrcweir 369*cdf0e10cSrcweir #define FORMAT 0 370*cdf0e10cSrcweir #define TIMEINTERVALL 1 371*cdf0e10cSrcweir #define USEUSERDATA 2 372*cdf0e10cSrcweir #define CREATEBACKUP 3 373*cdf0e10cSrcweir #define AUTOSAVE 4 374*cdf0e10cSrcweir #define PROMPT 5 375*cdf0e10cSrcweir #define EDITPROPERTY 6 376*cdf0e10cSrcweir #define SAVEVIEWINFO 7 377*cdf0e10cSrcweir #define UNPACKED 8 378*cdf0e10cSrcweir #define PRETTYPRINTING 9 379*cdf0e10cSrcweir #define WARNALIENFORMAT 10 380*cdf0e10cSrcweir #define LOADDOCPRINTER 11 381*cdf0e10cSrcweir #define FILESYSTEM 12 382*cdf0e10cSrcweir #define INTERNET 13 383*cdf0e10cSrcweir #define SAVEWORKINGSET 14 384*cdf0e10cSrcweir #define ODFDEFAULTVERSION 15 385*cdf0e10cSrcweir #define USESHA1INODF12 16 386*cdf0e10cSrcweir #define USEBLOWFISHINODF12 17 387*cdf0e10cSrcweir 388*cdf0e10cSrcweir Sequence< OUString > GetPropertyNames() 389*cdf0e10cSrcweir { 390*cdf0e10cSrcweir static const char* aPropNames[] = 391*cdf0e10cSrcweir { 392*cdf0e10cSrcweir "Graphic/Format", 393*cdf0e10cSrcweir "Document/AutoSaveTimeIntervall", 394*cdf0e10cSrcweir "Document/UseUserData", 395*cdf0e10cSrcweir "Document/CreateBackup", 396*cdf0e10cSrcweir "Document/AutoSave", 397*cdf0e10cSrcweir "Document/AutoSavePrompt", 398*cdf0e10cSrcweir "Document/EditProperty", 399*cdf0e10cSrcweir "Document/ViewInfo", 400*cdf0e10cSrcweir "Document/Unpacked", 401*cdf0e10cSrcweir "Document/PrettyPrinting", 402*cdf0e10cSrcweir "Document/WarnAlienFormat", 403*cdf0e10cSrcweir "Document/LoadPrinter", 404*cdf0e10cSrcweir "URL/FileSystem", 405*cdf0e10cSrcweir "URL/Internet", 406*cdf0e10cSrcweir "WorkingSet", 407*cdf0e10cSrcweir "ODF/DefaultVersion", 408*cdf0e10cSrcweir "ODF/UseSHA1InODF12", 409*cdf0e10cSrcweir "ODF/UseBlowfishInODF12" 410*cdf0e10cSrcweir }; 411*cdf0e10cSrcweir 412*cdf0e10cSrcweir const int nCount = sizeof( aPropNames ) / sizeof( const char* ); 413*cdf0e10cSrcweir Sequence< OUString > aNames( nCount ); 414*cdf0e10cSrcweir OUString* pNames = aNames.getArray(); 415*cdf0e10cSrcweir for ( int i = 0; i < nCount; i++ ) 416*cdf0e10cSrcweir pNames[i] = OUString::createFromAscii( aPropNames[i] ); 417*cdf0e10cSrcweir 418*cdf0e10cSrcweir return aNames; 419*cdf0e10cSrcweir } 420*cdf0e10cSrcweir 421*cdf0e10cSrcweir // ----------------------------------------------------------------------- 422*cdf0e10cSrcweir 423*cdf0e10cSrcweir SvtSaveOptions_Impl::SvtSaveOptions_Impl() 424*cdf0e10cSrcweir : ConfigItem( OUString::createFromAscii("Office.Common/Save") ) 425*cdf0e10cSrcweir , nAutoSaveTime( 0 ) 426*cdf0e10cSrcweir , bUseUserData( sal_False ) 427*cdf0e10cSrcweir , bBackup( sal_False ) 428*cdf0e10cSrcweir , bAutoSave( sal_False ) 429*cdf0e10cSrcweir , bAutoSavePrompt( sal_False ) 430*cdf0e10cSrcweir , bDocInfSave( sal_False ) 431*cdf0e10cSrcweir , bSaveWorkingSet( sal_False ) 432*cdf0e10cSrcweir , bSaveDocView( sal_False ) 433*cdf0e10cSrcweir , bSaveRelINet( sal_False ) 434*cdf0e10cSrcweir , bSaveRelFSys( sal_False ) 435*cdf0e10cSrcweir , bSaveUnpacked( sal_False ) 436*cdf0e10cSrcweir , bDoPrettyPrinting( sal_False ) 437*cdf0e10cSrcweir , bWarnAlienFormat( sal_True ) 438*cdf0e10cSrcweir , bLoadDocPrinter( sal_True ) 439*cdf0e10cSrcweir , bUseSHA1InODF12( sal_False ) 440*cdf0e10cSrcweir , bUseBlowfishInODF12( sal_False ) 441*cdf0e10cSrcweir , eODFDefaultVersion( SvtSaveOptions::ODFVER_LATEST ) 442*cdf0e10cSrcweir , bROAutoSaveTime( CFG_READONLY_DEFAULT ) 443*cdf0e10cSrcweir , bROUseUserData( CFG_READONLY_DEFAULT ) 444*cdf0e10cSrcweir , bROBackup( CFG_READONLY_DEFAULT ) 445*cdf0e10cSrcweir , bROAutoSave( CFG_READONLY_DEFAULT ) 446*cdf0e10cSrcweir , bROAutoSavePrompt( CFG_READONLY_DEFAULT ) 447*cdf0e10cSrcweir , bRODocInfSave( CFG_READONLY_DEFAULT ) 448*cdf0e10cSrcweir , bROSaveWorkingSet( CFG_READONLY_DEFAULT ) 449*cdf0e10cSrcweir , bROSaveDocView( CFG_READONLY_DEFAULT ) 450*cdf0e10cSrcweir , bROSaveRelINet( CFG_READONLY_DEFAULT ) 451*cdf0e10cSrcweir , bROSaveRelFSys( CFG_READONLY_DEFAULT ) 452*cdf0e10cSrcweir , bROSaveUnpacked( CFG_READONLY_DEFAULT ) 453*cdf0e10cSrcweir , bROWarnAlienFormat( CFG_READONLY_DEFAULT ) 454*cdf0e10cSrcweir , bRODoPrettyPrinting( CFG_READONLY_DEFAULT ) 455*cdf0e10cSrcweir , bROLoadDocPrinter( CFG_READONLY_DEFAULT ) 456*cdf0e10cSrcweir , bROODFDefaultVersion( CFG_READONLY_DEFAULT ) 457*cdf0e10cSrcweir , bROUseSHA1InODF12( CFG_READONLY_DEFAULT ) 458*cdf0e10cSrcweir , bROUseBlowfishInODF12( CFG_READONLY_DEFAULT ) 459*cdf0e10cSrcweir { 460*cdf0e10cSrcweir Sequence< OUString > aNames = GetPropertyNames(); 461*cdf0e10cSrcweir Sequence< Any > aValues = GetProperties( aNames ); 462*cdf0e10cSrcweir Sequence< sal_Bool > aROStates = GetReadOnlyStates( aNames ); 463*cdf0e10cSrcweir EnableNotification( aNames ); 464*cdf0e10cSrcweir const Any* pValues = aValues.getConstArray(); 465*cdf0e10cSrcweir const sal_Bool* pROStates = aROStates.getConstArray(); 466*cdf0e10cSrcweir DBG_ASSERT( aValues.getLength() == aNames.getLength(), "GetProperties failed" ); 467*cdf0e10cSrcweir DBG_ASSERT( aROStates.getLength() == aNames.getLength(), "GetReadOnlyStates failed" ); 468*cdf0e10cSrcweir if ( aValues.getLength() == aNames.getLength() && aROStates.getLength() == aNames.getLength() ) 469*cdf0e10cSrcweir { 470*cdf0e10cSrcweir for ( int nProp = 0; nProp < aNames.getLength(); nProp++ ) 471*cdf0e10cSrcweir { 472*cdf0e10cSrcweir DBG_ASSERT( pValues[nProp].hasValue(), "property value missing" ); 473*cdf0e10cSrcweir if ( pValues[nProp].hasValue() ) 474*cdf0e10cSrcweir { 475*cdf0e10cSrcweir sal_Int32 nTemp = 0; 476*cdf0e10cSrcweir switch ( nProp ) 477*cdf0e10cSrcweir { 478*cdf0e10cSrcweir case FORMAT: 479*cdf0e10cSrcweir // not supported anymore 480*cdf0e10cSrcweir break; 481*cdf0e10cSrcweir 482*cdf0e10cSrcweir case TIMEINTERVALL : 483*cdf0e10cSrcweir if ( pValues[nProp] >>= nTemp ) 484*cdf0e10cSrcweir nAutoSaveTime = nTemp; 485*cdf0e10cSrcweir else { 486*cdf0e10cSrcweir DBG_ERROR( "Wrong Type!" ); 487*cdf0e10cSrcweir }; 488*cdf0e10cSrcweir bROAutoSaveTime = pROStates[nProp]; 489*cdf0e10cSrcweir break; 490*cdf0e10cSrcweir 491*cdf0e10cSrcweir case ODFDEFAULTVERSION : 492*cdf0e10cSrcweir { 493*cdf0e10cSrcweir sal_Int16 nTmp = 0; 494*cdf0e10cSrcweir if ( pValues[nProp] >>= nTmp ) 495*cdf0e10cSrcweir { 496*cdf0e10cSrcweir if( nTmp == 3 ) 497*cdf0e10cSrcweir eODFDefaultVersion = SvtSaveOptions::ODFVER_LATEST; 498*cdf0e10cSrcweir else 499*cdf0e10cSrcweir eODFDefaultVersion = SvtSaveOptions::ODFDefaultVersion( nTmp ); 500*cdf0e10cSrcweir } 501*cdf0e10cSrcweir else { 502*cdf0e10cSrcweir DBG_ERRORFILE( "SvtSaveOptions_Impl::SvtSaveOptions_Impl(): Wrong Type!" ); 503*cdf0e10cSrcweir }; 504*cdf0e10cSrcweir bROODFDefaultVersion = pROStates[nProp]; 505*cdf0e10cSrcweir break; 506*cdf0e10cSrcweir } 507*cdf0e10cSrcweir 508*cdf0e10cSrcweir default: 509*cdf0e10cSrcweir { 510*cdf0e10cSrcweir sal_Bool bTemp = sal_Bool(); 511*cdf0e10cSrcweir if ( pValues[nProp] >>= bTemp ) 512*cdf0e10cSrcweir { 513*cdf0e10cSrcweir switch ( nProp ) 514*cdf0e10cSrcweir { 515*cdf0e10cSrcweir case USEUSERDATA : 516*cdf0e10cSrcweir bUseUserData = bTemp; 517*cdf0e10cSrcweir bROUseUserData = pROStates[nProp]; 518*cdf0e10cSrcweir break; 519*cdf0e10cSrcweir case CREATEBACKUP : 520*cdf0e10cSrcweir bBackup = bTemp; 521*cdf0e10cSrcweir bROBackup = pROStates[nProp]; 522*cdf0e10cSrcweir break; 523*cdf0e10cSrcweir case AUTOSAVE : 524*cdf0e10cSrcweir bAutoSave = bTemp; 525*cdf0e10cSrcweir bROAutoSave = pROStates[nProp]; 526*cdf0e10cSrcweir break; 527*cdf0e10cSrcweir case PROMPT : 528*cdf0e10cSrcweir bAutoSavePrompt = bTemp; 529*cdf0e10cSrcweir bROAutoSavePrompt = pROStates[nProp]; 530*cdf0e10cSrcweir break; 531*cdf0e10cSrcweir case EDITPROPERTY : 532*cdf0e10cSrcweir bDocInfSave = bTemp; 533*cdf0e10cSrcweir bRODocInfSave = pROStates[nProp]; 534*cdf0e10cSrcweir break; 535*cdf0e10cSrcweir case SAVEWORKINGSET : 536*cdf0e10cSrcweir bSaveWorkingSet = bTemp; 537*cdf0e10cSrcweir bROSaveWorkingSet = pROStates[nProp]; 538*cdf0e10cSrcweir break; 539*cdf0e10cSrcweir case SAVEVIEWINFO : 540*cdf0e10cSrcweir bSaveDocView = bTemp; 541*cdf0e10cSrcweir bROSaveDocView = pROStates[nProp]; 542*cdf0e10cSrcweir break; 543*cdf0e10cSrcweir case FILESYSTEM : 544*cdf0e10cSrcweir bSaveRelFSys = bTemp; 545*cdf0e10cSrcweir bROSaveRelFSys = pROStates[nProp]; 546*cdf0e10cSrcweir break; 547*cdf0e10cSrcweir case INTERNET : 548*cdf0e10cSrcweir bSaveRelINet = bTemp; 549*cdf0e10cSrcweir bROSaveRelINet = pROStates[nProp]; 550*cdf0e10cSrcweir break; 551*cdf0e10cSrcweir case UNPACKED : 552*cdf0e10cSrcweir bSaveUnpacked = bTemp; 553*cdf0e10cSrcweir bROSaveUnpacked = pROStates[nProp]; 554*cdf0e10cSrcweir break; 555*cdf0e10cSrcweir 556*cdf0e10cSrcweir case PRETTYPRINTING: 557*cdf0e10cSrcweir bDoPrettyPrinting = bTemp; 558*cdf0e10cSrcweir bRODoPrettyPrinting = pROStates[nProp]; 559*cdf0e10cSrcweir break; 560*cdf0e10cSrcweir 561*cdf0e10cSrcweir case WARNALIENFORMAT: 562*cdf0e10cSrcweir bWarnAlienFormat = bTemp; 563*cdf0e10cSrcweir bROWarnAlienFormat = pROStates[nProp]; 564*cdf0e10cSrcweir break; 565*cdf0e10cSrcweir 566*cdf0e10cSrcweir case LOADDOCPRINTER: 567*cdf0e10cSrcweir bLoadDocPrinter = bTemp; 568*cdf0e10cSrcweir bROLoadDocPrinter = pROStates[nProp]; 569*cdf0e10cSrcweir break; 570*cdf0e10cSrcweir 571*cdf0e10cSrcweir case USESHA1INODF12: 572*cdf0e10cSrcweir bUseSHA1InODF12 = bTemp; 573*cdf0e10cSrcweir bROUseSHA1InODF12 = pROStates[nProp]; 574*cdf0e10cSrcweir break; 575*cdf0e10cSrcweir 576*cdf0e10cSrcweir case USEBLOWFISHINODF12: 577*cdf0e10cSrcweir bUseBlowfishInODF12 = bTemp; 578*cdf0e10cSrcweir bROUseBlowfishInODF12 = pROStates[nProp]; 579*cdf0e10cSrcweir break; 580*cdf0e10cSrcweir 581*cdf0e10cSrcweir default : 582*cdf0e10cSrcweir DBG_ERRORFILE( "invalid index to load a path" ); 583*cdf0e10cSrcweir } 584*cdf0e10cSrcweir } 585*cdf0e10cSrcweir else 586*cdf0e10cSrcweir { 587*cdf0e10cSrcweir DBG_ERROR( "Wrong Type!" ); 588*cdf0e10cSrcweir } 589*cdf0e10cSrcweir } 590*cdf0e10cSrcweir } 591*cdf0e10cSrcweir } 592*cdf0e10cSrcweir } 593*cdf0e10cSrcweir } 594*cdf0e10cSrcweir 595*cdf0e10cSrcweir try 596*cdf0e10cSrcweir { 597*cdf0e10cSrcweir css::uno::Reference< css::uno::XInterface > xCFG = ::comphelper::ConfigurationHelper::openConfig( 598*cdf0e10cSrcweir ::utl::getProcessServiceFactory(), 599*cdf0e10cSrcweir ::rtl::OUString::createFromAscii("org.openoffice.Office.Recovery"), 600*cdf0e10cSrcweir ::comphelper::ConfigurationHelper::E_READONLY); 601*cdf0e10cSrcweir 602*cdf0e10cSrcweir ::comphelper::ConfigurationHelper::readRelativeKey( 603*cdf0e10cSrcweir xCFG, 604*cdf0e10cSrcweir ::rtl::OUString::createFromAscii("AutoSave"), 605*cdf0e10cSrcweir ::rtl::OUString::createFromAscii("Enabled")) >>= bAutoSave; 606*cdf0e10cSrcweir 607*cdf0e10cSrcweir ::comphelper::ConfigurationHelper::readRelativeKey( 608*cdf0e10cSrcweir xCFG, 609*cdf0e10cSrcweir ::rtl::OUString::createFromAscii("AutoSave"), 610*cdf0e10cSrcweir ::rtl::OUString::createFromAscii("TimeIntervall")) >>= nAutoSaveTime; 611*cdf0e10cSrcweir } 612*cdf0e10cSrcweir catch(const css::uno::Exception&) 613*cdf0e10cSrcweir { DBG_ERROR("Could not find needed informations for AutoSave feature."); } 614*cdf0e10cSrcweir } 615*cdf0e10cSrcweir 616*cdf0e10cSrcweir SvtSaveOptions_Impl::~SvtSaveOptions_Impl() 617*cdf0e10cSrcweir {} 618*cdf0e10cSrcweir 619*cdf0e10cSrcweir void SvtSaveOptions_Impl::Commit() 620*cdf0e10cSrcweir { 621*cdf0e10cSrcweir Sequence< OUString > aOrgNames = GetPropertyNames(); 622*cdf0e10cSrcweir OUString* pOrgNames = aOrgNames.getArray(); 623*cdf0e10cSrcweir sal_Int32 nOrgCount = aOrgNames.getLength(); 624*cdf0e10cSrcweir 625*cdf0e10cSrcweir Sequence< OUString > aNames( nOrgCount ); 626*cdf0e10cSrcweir Sequence< Any > aValues( nOrgCount ); 627*cdf0e10cSrcweir OUString* pNames = aNames.getArray(); 628*cdf0e10cSrcweir Any* pValues = aValues.getArray(); 629*cdf0e10cSrcweir sal_Int32 nRealCount = 0; 630*cdf0e10cSrcweir 631*cdf0e10cSrcweir for (sal_Int32 i=0; i<nOrgCount; ++i) 632*cdf0e10cSrcweir { 633*cdf0e10cSrcweir switch (i) 634*cdf0e10cSrcweir { 635*cdf0e10cSrcweir case FORMAT: 636*cdf0e10cSrcweir // not supported anymore 637*cdf0e10cSrcweir break; 638*cdf0e10cSrcweir case TIMEINTERVALL : 639*cdf0e10cSrcweir if (!bROAutoSaveTime) 640*cdf0e10cSrcweir { 641*cdf0e10cSrcweir pValues[nRealCount] <<= nAutoSaveTime; 642*cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[i]; 643*cdf0e10cSrcweir ++nRealCount; 644*cdf0e10cSrcweir } 645*cdf0e10cSrcweir break; 646*cdf0e10cSrcweir case USEUSERDATA : 647*cdf0e10cSrcweir if (!bROUseUserData) 648*cdf0e10cSrcweir { 649*cdf0e10cSrcweir pValues[nRealCount] <<= bUseUserData; 650*cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[i]; 651*cdf0e10cSrcweir ++nRealCount; 652*cdf0e10cSrcweir } 653*cdf0e10cSrcweir break; 654*cdf0e10cSrcweir case CREATEBACKUP : 655*cdf0e10cSrcweir if (!bROBackup) 656*cdf0e10cSrcweir { 657*cdf0e10cSrcweir pValues[nRealCount] <<= bBackup; 658*cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[i]; 659*cdf0e10cSrcweir ++nRealCount; 660*cdf0e10cSrcweir } 661*cdf0e10cSrcweir break; 662*cdf0e10cSrcweir case AUTOSAVE : 663*cdf0e10cSrcweir if (!bROAutoSave) 664*cdf0e10cSrcweir { 665*cdf0e10cSrcweir pValues[nRealCount] <<= bAutoSave; 666*cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[i]; 667*cdf0e10cSrcweir ++nRealCount; 668*cdf0e10cSrcweir } 669*cdf0e10cSrcweir break; 670*cdf0e10cSrcweir case PROMPT : 671*cdf0e10cSrcweir if (!bROAutoSavePrompt) 672*cdf0e10cSrcweir { 673*cdf0e10cSrcweir pValues[nRealCount] <<= bAutoSavePrompt; 674*cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[i]; 675*cdf0e10cSrcweir ++nRealCount; 676*cdf0e10cSrcweir } 677*cdf0e10cSrcweir break; 678*cdf0e10cSrcweir case EDITPROPERTY : 679*cdf0e10cSrcweir if (!bRODocInfSave) 680*cdf0e10cSrcweir { 681*cdf0e10cSrcweir pValues[nRealCount] <<= bDocInfSave; 682*cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[i]; 683*cdf0e10cSrcweir ++nRealCount; 684*cdf0e10cSrcweir } 685*cdf0e10cSrcweir break; 686*cdf0e10cSrcweir case SAVEWORKINGSET : 687*cdf0e10cSrcweir if (!bROSaveWorkingSet) 688*cdf0e10cSrcweir { 689*cdf0e10cSrcweir pValues[nRealCount] <<= bSaveWorkingSet; 690*cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[i]; 691*cdf0e10cSrcweir ++nRealCount; 692*cdf0e10cSrcweir } 693*cdf0e10cSrcweir break; 694*cdf0e10cSrcweir case SAVEVIEWINFO : 695*cdf0e10cSrcweir if (!bROSaveDocView) 696*cdf0e10cSrcweir { 697*cdf0e10cSrcweir pValues[nRealCount] <<= bSaveDocView; 698*cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[i]; 699*cdf0e10cSrcweir ++nRealCount; 700*cdf0e10cSrcweir } 701*cdf0e10cSrcweir break; 702*cdf0e10cSrcweir case FILESYSTEM : 703*cdf0e10cSrcweir if (!bROSaveRelFSys) 704*cdf0e10cSrcweir { 705*cdf0e10cSrcweir pValues[nRealCount] <<= bSaveRelFSys; 706*cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[i]; 707*cdf0e10cSrcweir ++nRealCount; 708*cdf0e10cSrcweir } 709*cdf0e10cSrcweir break; 710*cdf0e10cSrcweir case INTERNET : 711*cdf0e10cSrcweir if (!bROSaveRelINet) 712*cdf0e10cSrcweir { 713*cdf0e10cSrcweir pValues[nRealCount] <<= bSaveRelINet; 714*cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[i]; 715*cdf0e10cSrcweir ++nRealCount; 716*cdf0e10cSrcweir } 717*cdf0e10cSrcweir break; 718*cdf0e10cSrcweir case UNPACKED : 719*cdf0e10cSrcweir if (!bROSaveUnpacked) 720*cdf0e10cSrcweir { 721*cdf0e10cSrcweir pValues[nRealCount] <<= bSaveUnpacked; 722*cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[i]; 723*cdf0e10cSrcweir ++nRealCount; 724*cdf0e10cSrcweir } 725*cdf0e10cSrcweir break; 726*cdf0e10cSrcweir case PRETTYPRINTING: 727*cdf0e10cSrcweir if (!bRODoPrettyPrinting) 728*cdf0e10cSrcweir { 729*cdf0e10cSrcweir pValues[nRealCount] <<= bDoPrettyPrinting; 730*cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[i]; 731*cdf0e10cSrcweir ++nRealCount; 732*cdf0e10cSrcweir } 733*cdf0e10cSrcweir break; 734*cdf0e10cSrcweir case WARNALIENFORMAT: 735*cdf0e10cSrcweir if (!bROWarnAlienFormat) 736*cdf0e10cSrcweir { 737*cdf0e10cSrcweir pValues[nRealCount] <<= bWarnAlienFormat; 738*cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[i]; 739*cdf0e10cSrcweir ++nRealCount; 740*cdf0e10cSrcweir } 741*cdf0e10cSrcweir break; 742*cdf0e10cSrcweir case LOADDOCPRINTER: 743*cdf0e10cSrcweir if (!bROLoadDocPrinter) 744*cdf0e10cSrcweir { 745*cdf0e10cSrcweir pValues[nRealCount] <<= bLoadDocPrinter; 746*cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[i]; 747*cdf0e10cSrcweir ++nRealCount; 748*cdf0e10cSrcweir } 749*cdf0e10cSrcweir break; 750*cdf0e10cSrcweir case ODFDEFAULTVERSION: 751*cdf0e10cSrcweir if (!bROODFDefaultVersion) 752*cdf0e10cSrcweir { 753*cdf0e10cSrcweir pValues[nRealCount] <<= (eODFDefaultVersion == SvtSaveOptions::ODFVER_LATEST) ? sal_Int16( 3 ) : sal_Int16( eODFDefaultVersion ); 754*cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[i]; 755*cdf0e10cSrcweir ++nRealCount; 756*cdf0e10cSrcweir } 757*cdf0e10cSrcweir break; 758*cdf0e10cSrcweir case USESHA1INODF12: 759*cdf0e10cSrcweir if (!bROUseSHA1InODF12) 760*cdf0e10cSrcweir { 761*cdf0e10cSrcweir pValues[nRealCount] <<= bUseSHA1InODF12; 762*cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[i]; 763*cdf0e10cSrcweir ++nRealCount; 764*cdf0e10cSrcweir } 765*cdf0e10cSrcweir break; 766*cdf0e10cSrcweir case USEBLOWFISHINODF12: 767*cdf0e10cSrcweir if (!bROUseBlowfishInODF12) 768*cdf0e10cSrcweir { 769*cdf0e10cSrcweir pValues[nRealCount] <<= bUseBlowfishInODF12; 770*cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[i]; 771*cdf0e10cSrcweir ++nRealCount; 772*cdf0e10cSrcweir } 773*cdf0e10cSrcweir break; 774*cdf0e10cSrcweir 775*cdf0e10cSrcweir default: 776*cdf0e10cSrcweir DBG_ERRORFILE( "invalid index to save a path" ); 777*cdf0e10cSrcweir } 778*cdf0e10cSrcweir } 779*cdf0e10cSrcweir 780*cdf0e10cSrcweir aNames.realloc(nRealCount); 781*cdf0e10cSrcweir aValues.realloc(nRealCount); 782*cdf0e10cSrcweir PutProperties( aNames, aValues ); 783*cdf0e10cSrcweir 784*cdf0e10cSrcweir css::uno::Reference< css::uno::XInterface > xCFG = ::comphelper::ConfigurationHelper::openConfig( 785*cdf0e10cSrcweir ::utl::getProcessServiceFactory(), 786*cdf0e10cSrcweir ::rtl::OUString::createFromAscii("org.openoffice.Office.Recovery"), 787*cdf0e10cSrcweir ::comphelper::ConfigurationHelper::E_STANDARD); 788*cdf0e10cSrcweir 789*cdf0e10cSrcweir ::comphelper::ConfigurationHelper::writeRelativeKey( 790*cdf0e10cSrcweir xCFG, 791*cdf0e10cSrcweir ::rtl::OUString::createFromAscii("AutoSave"), 792*cdf0e10cSrcweir ::rtl::OUString::createFromAscii("TimeIntervall"), 793*cdf0e10cSrcweir css::uno::makeAny(nAutoSaveTime)); 794*cdf0e10cSrcweir 795*cdf0e10cSrcweir ::comphelper::ConfigurationHelper::writeRelativeKey( 796*cdf0e10cSrcweir xCFG, 797*cdf0e10cSrcweir ::rtl::OUString::createFromAscii("AutoSave"), 798*cdf0e10cSrcweir ::rtl::OUString::createFromAscii("Enabled"), 799*cdf0e10cSrcweir css::uno::makeAny(bAutoSave)); 800*cdf0e10cSrcweir 801*cdf0e10cSrcweir ::comphelper::ConfigurationHelper::flush(xCFG); 802*cdf0e10cSrcweir } 803*cdf0e10cSrcweir 804*cdf0e10cSrcweir // ----------------------------------------------------------------------- 805*cdf0e10cSrcweir 806*cdf0e10cSrcweir void SvtSaveOptions_Impl::Notify( const Sequence<rtl::OUString>& ) 807*cdf0e10cSrcweir { 808*cdf0e10cSrcweir } 809*cdf0e10cSrcweir 810*cdf0e10cSrcweir 811*cdf0e10cSrcweir class SvtLoadOptions_Impl : public utl::ConfigItem 812*cdf0e10cSrcweir { 813*cdf0e10cSrcweir 814*cdf0e10cSrcweir sal_Bool bLoadUserDefinedSettings; 815*cdf0e10cSrcweir 816*cdf0e10cSrcweir public: 817*cdf0e10cSrcweir SvtLoadOptions_Impl(); 818*cdf0e10cSrcweir ~SvtLoadOptions_Impl(); 819*cdf0e10cSrcweir 820*cdf0e10cSrcweir virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames ); 821*cdf0e10cSrcweir virtual void Commit(); 822*cdf0e10cSrcweir 823*cdf0e10cSrcweir void SetLoadUserSettings(sal_Bool b){bLoadUserDefinedSettings = b; SetModified();} 824*cdf0e10cSrcweir sal_Bool IsLoadUserSettings() const {return bLoadUserDefinedSettings;} 825*cdf0e10cSrcweir }; 826*cdf0e10cSrcweir // ----------------------------------------------------------------------- 827*cdf0e10cSrcweir const sal_Char cUserDefinedSettings[] = "UserDefinedSettings"; 828*cdf0e10cSrcweir 829*cdf0e10cSrcweir SvtLoadOptions_Impl::SvtLoadOptions_Impl() 830*cdf0e10cSrcweir : ConfigItem( OUString::createFromAscii("Office.Common/Load") ) 831*cdf0e10cSrcweir , bLoadUserDefinedSettings( sal_False ) 832*cdf0e10cSrcweir { 833*cdf0e10cSrcweir Sequence< OUString > aNames(1); 834*cdf0e10cSrcweir aNames[0] = OUString::createFromAscii(cUserDefinedSettings); 835*cdf0e10cSrcweir Sequence< Any > aValues = GetProperties( aNames ); 836*cdf0e10cSrcweir EnableNotification( aNames ); 837*cdf0e10cSrcweir const Any* pValues = aValues.getConstArray(); 838*cdf0e10cSrcweir DBG_ASSERT( aValues.getLength() == aNames.getLength(), "GetProperties failed" ); 839*cdf0e10cSrcweir if (pValues[0].getValueTypeClass() == ::com::sun::star::uno::TypeClass_BOOLEAN) 840*cdf0e10cSrcweir bLoadUserDefinedSettings = *(sal_Bool *)pValues[0].getValue(); 841*cdf0e10cSrcweir } 842*cdf0e10cSrcweir // ----------------------------------------------------------------------- 843*cdf0e10cSrcweir SvtLoadOptions_Impl::~SvtLoadOptions_Impl() 844*cdf0e10cSrcweir { 845*cdf0e10cSrcweir } 846*cdf0e10cSrcweir // ----------------------------------------------------------------------- 847*cdf0e10cSrcweir void SvtLoadOptions_Impl::Commit() 848*cdf0e10cSrcweir { 849*cdf0e10cSrcweir Sequence< OUString > aNames(1); 850*cdf0e10cSrcweir aNames[0] = OUString::createFromAscii(cUserDefinedSettings); 851*cdf0e10cSrcweir Sequence< Any > aValues( 1 ); 852*cdf0e10cSrcweir aValues[0].setValue(&bLoadUserDefinedSettings, ::getBooleanCppuType()); 853*cdf0e10cSrcweir PutProperties( aNames, aValues ); 854*cdf0e10cSrcweir } 855*cdf0e10cSrcweir // ----------------------------------------------------------------------- 856*cdf0e10cSrcweir void SvtLoadOptions_Impl::Notify( const Sequence<rtl::OUString>& ) 857*cdf0e10cSrcweir { 858*cdf0e10cSrcweir DBG_ERRORFILE( "properties have been changed" ); 859*cdf0e10cSrcweir } 860*cdf0e10cSrcweir // ----------------------------------------------------------------------- 861*cdf0e10cSrcweir 862*cdf0e10cSrcweir namespace 863*cdf0e10cSrcweir { 864*cdf0e10cSrcweir class LocalSingleton : public rtl::Static< osl::Mutex, LocalSingleton > 865*cdf0e10cSrcweir { 866*cdf0e10cSrcweir }; 867*cdf0e10cSrcweir } 868*cdf0e10cSrcweir 869*cdf0e10cSrcweir // ----------------------------------------------------------------------- 870*cdf0e10cSrcweir SvtSaveOptions::SvtSaveOptions() 871*cdf0e10cSrcweir { 872*cdf0e10cSrcweir // Global access, must be guarded (multithreading) 873*cdf0e10cSrcweir ::osl::MutexGuard aGuard( LocalSingleton::get() ); 874*cdf0e10cSrcweir if ( !pOptions ) 875*cdf0e10cSrcweir { 876*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT(aLog, "unotools ( ??? ) ::SvtSaveOptions_Impl::ctor()"); 877*cdf0e10cSrcweir pOptions = new SvtLoadSaveOptions_Impl; 878*cdf0e10cSrcweir pOptions->pSaveOpt = new SvtSaveOptions_Impl; 879*cdf0e10cSrcweir pOptions->pLoadOpt = new SvtLoadOptions_Impl; 880*cdf0e10cSrcweir 881*cdf0e10cSrcweir ItemHolder1::holdConfigItem(E_SAVEOPTIONS); 882*cdf0e10cSrcweir } 883*cdf0e10cSrcweir ++nRefCount; 884*cdf0e10cSrcweir pImp = pOptions; 885*cdf0e10cSrcweir } 886*cdf0e10cSrcweir 887*cdf0e10cSrcweir // ----------------------------------------------------------------------- 888*cdf0e10cSrcweir 889*cdf0e10cSrcweir SvtSaveOptions::~SvtSaveOptions() 890*cdf0e10cSrcweir { 891*cdf0e10cSrcweir // Global access, must be guarded (multithreading) 892*cdf0e10cSrcweir ::osl::MutexGuard aGuard( LocalSingleton::get() ); 893*cdf0e10cSrcweir if ( !--nRefCount ) 894*cdf0e10cSrcweir { 895*cdf0e10cSrcweir if ( pOptions->pSaveOpt->IsModified() ) 896*cdf0e10cSrcweir pOptions->pSaveOpt->Commit(); 897*cdf0e10cSrcweir if ( pOptions->pLoadOpt->IsModified() ) 898*cdf0e10cSrcweir pOptions->pLoadOpt->Commit(); 899*cdf0e10cSrcweir 900*cdf0e10cSrcweir DELETEZ( pOptions->pLoadOpt ); 901*cdf0e10cSrcweir DELETEZ( pOptions->pSaveOpt ); 902*cdf0e10cSrcweir DELETEZ( pOptions ); 903*cdf0e10cSrcweir } 904*cdf0e10cSrcweir } 905*cdf0e10cSrcweir 906*cdf0e10cSrcweir void SvtSaveOptions::SetAutoSaveTime( sal_Int32 n ) 907*cdf0e10cSrcweir { 908*cdf0e10cSrcweir pImp->pSaveOpt->SetAutoSaveTime( n ); 909*cdf0e10cSrcweir } 910*cdf0e10cSrcweir 911*cdf0e10cSrcweir sal_Int32 SvtSaveOptions::GetAutoSaveTime() const 912*cdf0e10cSrcweir { 913*cdf0e10cSrcweir return pImp->pSaveOpt->GetAutoSaveTime(); 914*cdf0e10cSrcweir } 915*cdf0e10cSrcweir 916*cdf0e10cSrcweir void SvtSaveOptions::SetUseUserData( sal_Bool b ) 917*cdf0e10cSrcweir { 918*cdf0e10cSrcweir pImp->pSaveOpt->SetUseUserData( b ); 919*cdf0e10cSrcweir } 920*cdf0e10cSrcweir 921*cdf0e10cSrcweir sal_Bool SvtSaveOptions::IsUseUserData() const 922*cdf0e10cSrcweir { 923*cdf0e10cSrcweir return pImp->pSaveOpt->IsUseUserData(); 924*cdf0e10cSrcweir } 925*cdf0e10cSrcweir 926*cdf0e10cSrcweir void SvtSaveOptions::SetBackup( sal_Bool b ) 927*cdf0e10cSrcweir { 928*cdf0e10cSrcweir pImp->pSaveOpt->SetBackup( b ); 929*cdf0e10cSrcweir } 930*cdf0e10cSrcweir 931*cdf0e10cSrcweir sal_Bool SvtSaveOptions::IsBackup() const 932*cdf0e10cSrcweir { 933*cdf0e10cSrcweir return pImp->pSaveOpt->IsBackup(); 934*cdf0e10cSrcweir } 935*cdf0e10cSrcweir 936*cdf0e10cSrcweir void SvtSaveOptions::SetAutoSave( sal_Bool b ) 937*cdf0e10cSrcweir { 938*cdf0e10cSrcweir pImp->pSaveOpt->SetAutoSave( b ); 939*cdf0e10cSrcweir } 940*cdf0e10cSrcweir 941*cdf0e10cSrcweir sal_Bool SvtSaveOptions::IsAutoSave() const 942*cdf0e10cSrcweir { 943*cdf0e10cSrcweir return pImp->pSaveOpt->IsAutoSave(); 944*cdf0e10cSrcweir } 945*cdf0e10cSrcweir 946*cdf0e10cSrcweir void SvtSaveOptions::SetAutoSavePrompt( sal_Bool b ) 947*cdf0e10cSrcweir { 948*cdf0e10cSrcweir pImp->pSaveOpt->SetAutoSavePrompt( b ); 949*cdf0e10cSrcweir } 950*cdf0e10cSrcweir 951*cdf0e10cSrcweir sal_Bool SvtSaveOptions::IsAutoSavePrompt() const 952*cdf0e10cSrcweir { 953*cdf0e10cSrcweir return pImp->pSaveOpt->IsAutoSavePrompt(); 954*cdf0e10cSrcweir } 955*cdf0e10cSrcweir 956*cdf0e10cSrcweir void SvtSaveOptions::SetDocInfoSave(sal_Bool b) 957*cdf0e10cSrcweir { 958*cdf0e10cSrcweir pImp->pSaveOpt->SetDocInfoSave( b ); 959*cdf0e10cSrcweir } 960*cdf0e10cSrcweir 961*cdf0e10cSrcweir sal_Bool SvtSaveOptions::IsDocInfoSave() const 962*cdf0e10cSrcweir { 963*cdf0e10cSrcweir return pImp->pSaveOpt->IsDocInfoSave(); 964*cdf0e10cSrcweir } 965*cdf0e10cSrcweir 966*cdf0e10cSrcweir void SvtSaveOptions::SetSaveWorkingSet( sal_Bool b ) 967*cdf0e10cSrcweir { 968*cdf0e10cSrcweir pImp->pSaveOpt->SetSaveWorkingSet( b ); 969*cdf0e10cSrcweir } 970*cdf0e10cSrcweir 971*cdf0e10cSrcweir sal_Bool SvtSaveOptions::IsSaveWorkingSet() const 972*cdf0e10cSrcweir { 973*cdf0e10cSrcweir return pImp->pSaveOpt->IsSaveWorkingSet(); 974*cdf0e10cSrcweir } 975*cdf0e10cSrcweir 976*cdf0e10cSrcweir void SvtSaveOptions::SetSaveDocView( sal_Bool b ) 977*cdf0e10cSrcweir { 978*cdf0e10cSrcweir pImp->pSaveOpt->SetSaveDocView( b ); 979*cdf0e10cSrcweir } 980*cdf0e10cSrcweir 981*cdf0e10cSrcweir sal_Bool SvtSaveOptions::IsSaveDocView() const 982*cdf0e10cSrcweir { 983*cdf0e10cSrcweir return pImp->pSaveOpt->IsSaveDocView(); 984*cdf0e10cSrcweir } 985*cdf0e10cSrcweir 986*cdf0e10cSrcweir void SvtSaveOptions::SetSaveRelINet( sal_Bool b ) 987*cdf0e10cSrcweir { 988*cdf0e10cSrcweir pImp->pSaveOpt->SetSaveRelINet( b ); 989*cdf0e10cSrcweir } 990*cdf0e10cSrcweir 991*cdf0e10cSrcweir sal_Bool SvtSaveOptions::IsSaveRelINet() const 992*cdf0e10cSrcweir { 993*cdf0e10cSrcweir return pImp->pSaveOpt->IsSaveRelINet(); 994*cdf0e10cSrcweir } 995*cdf0e10cSrcweir 996*cdf0e10cSrcweir void SvtSaveOptions::SetSaveRelFSys( sal_Bool b ) 997*cdf0e10cSrcweir { 998*cdf0e10cSrcweir pImp->pSaveOpt->SetSaveRelFSys( b ); 999*cdf0e10cSrcweir } 1000*cdf0e10cSrcweir 1001*cdf0e10cSrcweir sal_Bool SvtSaveOptions::IsSaveRelFSys() const 1002*cdf0e10cSrcweir { 1003*cdf0e10cSrcweir return pImp->pSaveOpt->IsSaveRelFSys(); 1004*cdf0e10cSrcweir } 1005*cdf0e10cSrcweir 1006*cdf0e10cSrcweir void SvtSaveOptions::SetSaveUnpacked( sal_Bool b ) 1007*cdf0e10cSrcweir { 1008*cdf0e10cSrcweir pImp->pSaveOpt->SetSaveUnpacked( b ); 1009*cdf0e10cSrcweir } 1010*cdf0e10cSrcweir 1011*cdf0e10cSrcweir sal_Bool SvtSaveOptions::IsSaveUnpacked() const 1012*cdf0e10cSrcweir { 1013*cdf0e10cSrcweir return pImp->pSaveOpt->IsSaveUnpacked(); 1014*cdf0e10cSrcweir } 1015*cdf0e10cSrcweir 1016*cdf0e10cSrcweir void SvtSaveOptions::SetLoadUserSettings(sal_Bool b) 1017*cdf0e10cSrcweir { 1018*cdf0e10cSrcweir pImp->pLoadOpt->SetLoadUserSettings(b); 1019*cdf0e10cSrcweir } 1020*cdf0e10cSrcweir 1021*cdf0e10cSrcweir sal_Bool SvtSaveOptions::IsLoadUserSettings() const 1022*cdf0e10cSrcweir { 1023*cdf0e10cSrcweir return pImp->pLoadOpt->IsLoadUserSettings(); 1024*cdf0e10cSrcweir } 1025*cdf0e10cSrcweir 1026*cdf0e10cSrcweir void SvtSaveOptions::SetPrettyPrinting( sal_Bool _bEnable ) 1027*cdf0e10cSrcweir { 1028*cdf0e10cSrcweir pImp->pSaveOpt->EnablePrettyPrinting( _bEnable ); 1029*cdf0e10cSrcweir } 1030*cdf0e10cSrcweir 1031*cdf0e10cSrcweir sal_Bool SvtSaveOptions::IsPrettyPrinting() const 1032*cdf0e10cSrcweir { 1033*cdf0e10cSrcweir return pImp->pSaveOpt->IsPrettyPrintingEnabled(); 1034*cdf0e10cSrcweir } 1035*cdf0e10cSrcweir 1036*cdf0e10cSrcweir void SvtSaveOptions::SetWarnAlienFormat( sal_Bool _bEnable ) 1037*cdf0e10cSrcweir { 1038*cdf0e10cSrcweir pImp->pSaveOpt->SetWarnAlienFormat( _bEnable ); 1039*cdf0e10cSrcweir } 1040*cdf0e10cSrcweir 1041*cdf0e10cSrcweir sal_Bool SvtSaveOptions::IsWarnAlienFormat() const 1042*cdf0e10cSrcweir { 1043*cdf0e10cSrcweir return pImp->pSaveOpt->IsWarnAlienFormat(); 1044*cdf0e10cSrcweir } 1045*cdf0e10cSrcweir 1046*cdf0e10cSrcweir void SvtSaveOptions::SetLoadDocumentPrinter( sal_Bool _bEnable ) 1047*cdf0e10cSrcweir { 1048*cdf0e10cSrcweir pImp->pSaveOpt->SetLoadDocPrinter( _bEnable ); 1049*cdf0e10cSrcweir } 1050*cdf0e10cSrcweir 1051*cdf0e10cSrcweir sal_Bool SvtSaveOptions::IsLoadDocumentPrinter() const 1052*cdf0e10cSrcweir { 1053*cdf0e10cSrcweir return pImp->pSaveOpt->IsLoadDocPrinter(); 1054*cdf0e10cSrcweir } 1055*cdf0e10cSrcweir 1056*cdf0e10cSrcweir void SvtSaveOptions::SetODFDefaultVersion( SvtSaveOptions::ODFDefaultVersion eVersion ) 1057*cdf0e10cSrcweir { 1058*cdf0e10cSrcweir pImp->pSaveOpt->SetODFDefaultVersion( eVersion ); 1059*cdf0e10cSrcweir } 1060*cdf0e10cSrcweir 1061*cdf0e10cSrcweir SvtSaveOptions::ODFDefaultVersion SvtSaveOptions::GetODFDefaultVersion() const 1062*cdf0e10cSrcweir { 1063*cdf0e10cSrcweir return pImp->pSaveOpt->GetODFDefaultVersion(); 1064*cdf0e10cSrcweir } 1065*cdf0e10cSrcweir 1066*cdf0e10cSrcweir void SvtSaveOptions::SetUseSHA1InODF12( sal_Bool bUse ) 1067*cdf0e10cSrcweir { 1068*cdf0e10cSrcweir pImp->pSaveOpt->SetUseSHA1InODF12( bUse ); 1069*cdf0e10cSrcweir } 1070*cdf0e10cSrcweir 1071*cdf0e10cSrcweir sal_Bool SvtSaveOptions::IsUseSHA1InODF12() const 1072*cdf0e10cSrcweir { 1073*cdf0e10cSrcweir return pImp->pSaveOpt->IsUseSHA1InODF12(); 1074*cdf0e10cSrcweir } 1075*cdf0e10cSrcweir 1076*cdf0e10cSrcweir void SvtSaveOptions::SetUseBlowfishInODF12( sal_Bool bUse ) 1077*cdf0e10cSrcweir { 1078*cdf0e10cSrcweir pImp->pSaveOpt->SetUseBlowfishInODF12( bUse ); 1079*cdf0e10cSrcweir } 1080*cdf0e10cSrcweir 1081*cdf0e10cSrcweir sal_Bool SvtSaveOptions::IsUseBlowfishInODF12() const 1082*cdf0e10cSrcweir { 1083*cdf0e10cSrcweir return pImp->pSaveOpt->IsUseBlowfishInODF12(); 1084*cdf0e10cSrcweir } 1085*cdf0e10cSrcweir 1086*cdf0e10cSrcweir sal_Bool SvtSaveOptions::IsReadOnly( SvtSaveOptions::EOption eOption ) const 1087*cdf0e10cSrcweir { 1088*cdf0e10cSrcweir return pImp->pSaveOpt->IsReadOnly(eOption); 1089*cdf0e10cSrcweir } 1090*cdf0e10cSrcweir 1091