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 #include <unotools/fltrcfg.hxx> 32*cdf0e10cSrcweir #include <tools/debug.hxx> 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir #include <rtl/logfile.hxx> 35*cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx> 36*cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx> 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir using namespace utl; 39*cdf0e10cSrcweir using namespace rtl; 40*cdf0e10cSrcweir using namespace com::sun::star::uno; 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir #define C2U(cChar) OUString::createFromAscii(cChar) 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir // ----------------------------------------------------------------------- 45*cdf0e10cSrcweir #define FILTERCFG_WORD_CODE 0x0001 46*cdf0e10cSrcweir #define FILTERCFG_WORD_STORAGE 0x0002 47*cdf0e10cSrcweir #define FILTERCFG_EXCEL_CODE 0x0004 48*cdf0e10cSrcweir #define FILTERCFG_EXCEL_STORAGE 0x0008 49*cdf0e10cSrcweir #define FILTERCFG_PPOINT_CODE 0x0010 50*cdf0e10cSrcweir #define FILTERCFG_PPOINT_STORAGE 0x0020 51*cdf0e10cSrcweir #define FILTERCFG_MATH_LOAD 0x0100 52*cdf0e10cSrcweir #define FILTERCFG_MATH_SAVE 0x0200 53*cdf0e10cSrcweir #define FILTERCFG_WRITER_LOAD 0x0400 54*cdf0e10cSrcweir #define FILTERCFG_WRITER_SAVE 0x0800 55*cdf0e10cSrcweir #define FILTERCFG_CALC_LOAD 0x1000 56*cdf0e10cSrcweir #define FILTERCFG_CALC_SAVE 0x2000 57*cdf0e10cSrcweir #define FILTERCFG_IMPRESS_LOAD 0x4000 58*cdf0e10cSrcweir #define FILTERCFG_IMPRESS_SAVE 0x8000 59*cdf0e10cSrcweir #define FILTERCFG_EXCEL_EXECTBL 0x10000 60*cdf0e10cSrcweir #define FILTERCFG_ENABLE_PPT_PREVIEW 0x20000 61*cdf0e10cSrcweir #define FILTERCFG_ENABLE_EXCEL_PREVIEW 0x40000 62*cdf0e10cSrcweir #define FILTERCFG_ENABLE_WORD_PREVIEW 0x80000 63*cdf0e10cSrcweir #define FILTERCFG_USE_ENHANCED_FIELDS 0x100000 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir static SvtFilterOptions* pOptions=0; 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir /* -----------------------------22.01.01 10:23-------------------------------- 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 70*cdf0e10cSrcweir class SvtAppFilterOptions_Impl : public utl::ConfigItem 71*cdf0e10cSrcweir { 72*cdf0e10cSrcweir sal_Bool bLoadVBA; 73*cdf0e10cSrcweir sal_Bool bSaveVBA; 74*cdf0e10cSrcweir public: 75*cdf0e10cSrcweir SvtAppFilterOptions_Impl(const OUString& rRoot) : 76*cdf0e10cSrcweir utl::ConfigItem(rRoot), 77*cdf0e10cSrcweir bLoadVBA(sal_False), 78*cdf0e10cSrcweir bSaveVBA(sal_False) {} 79*cdf0e10cSrcweir ~SvtAppFilterOptions_Impl(); 80*cdf0e10cSrcweir virtual void Commit(); 81*cdf0e10cSrcweir virtual void Notify( const com::sun::star::uno::Sequence<rtl::OUString>& aPropertyNames); 82*cdf0e10cSrcweir void Load(); 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir sal_Bool IsLoad() const {return bLoadVBA;} 85*cdf0e10cSrcweir void SetLoad(sal_Bool bSet) 86*cdf0e10cSrcweir { 87*cdf0e10cSrcweir if(bSet != bLoadVBA) 88*cdf0e10cSrcweir SetModified(); 89*cdf0e10cSrcweir bLoadVBA = bSet; 90*cdf0e10cSrcweir } 91*cdf0e10cSrcweir sal_Bool IsSave() const {return bSaveVBA;} 92*cdf0e10cSrcweir void SetSave(sal_Bool bSet) 93*cdf0e10cSrcweir { 94*cdf0e10cSrcweir if(bSet != bSaveVBA) 95*cdf0e10cSrcweir SetModified(); 96*cdf0e10cSrcweir bSaveVBA = bSet; 97*cdf0e10cSrcweir } 98*cdf0e10cSrcweir }; 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir /* -----------------------------22.01.01 11:08-------------------------------- 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 103*cdf0e10cSrcweir SvtAppFilterOptions_Impl::~SvtAppFilterOptions_Impl() 104*cdf0e10cSrcweir { 105*cdf0e10cSrcweir if(IsModified()) 106*cdf0e10cSrcweir Commit(); 107*cdf0e10cSrcweir } 108*cdf0e10cSrcweir /* -----------------------------22.01.01 10:38-------------------------------- 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 111*cdf0e10cSrcweir void SvtAppFilterOptions_Impl::Commit() 112*cdf0e10cSrcweir { 113*cdf0e10cSrcweir Sequence<OUString> aNames(2); 114*cdf0e10cSrcweir OUString* pNames = aNames.getArray(); 115*cdf0e10cSrcweir pNames[0] = C2U("Load"); 116*cdf0e10cSrcweir pNames[1] = C2U("Save"); 117*cdf0e10cSrcweir Sequence<Any> aValues(aNames.getLength()); 118*cdf0e10cSrcweir Any* pValues = aValues.getArray(); 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir const Type& rType = ::getBooleanCppuType(); 121*cdf0e10cSrcweir pValues[0].setValue(&bLoadVBA, rType); 122*cdf0e10cSrcweir pValues[1].setValue(&bSaveVBA, rType); 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir PutProperties(aNames, aValues); 125*cdf0e10cSrcweir } 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir void SvtAppFilterOptions_Impl::Notify( const Sequence< rtl::OUString >& ) 128*cdf0e10cSrcweir { 129*cdf0e10cSrcweir // no listeners supported yet 130*cdf0e10cSrcweir } 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir /* -----------------------------22.01.01 10:38-------------------------------- 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 136*cdf0e10cSrcweir void SvtAppFilterOptions_Impl::Load() 137*cdf0e10cSrcweir { 138*cdf0e10cSrcweir Sequence<OUString> aNames(2); 139*cdf0e10cSrcweir OUString* pNames = aNames.getArray(); 140*cdf0e10cSrcweir pNames[0] = C2U("Load"); 141*cdf0e10cSrcweir pNames[1] = C2U("Save"); 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir Sequence<Any> aValues = GetProperties(aNames); 144*cdf0e10cSrcweir const Any* pValues = aValues.getConstArray(); 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir if(pValues[0].hasValue()) 147*cdf0e10cSrcweir bLoadVBA = *(sal_Bool*)pValues[0].getValue(); 148*cdf0e10cSrcweir if(pValues[1].hasValue()) 149*cdf0e10cSrcweir bSaveVBA = *(sal_Bool*)pValues[1].getValue(); 150*cdf0e10cSrcweir } 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir // ----------------------------------------------------------------------- 153*cdf0e10cSrcweir class SvtCalcFilterOptions_Impl : public SvtAppFilterOptions_Impl 154*cdf0e10cSrcweir { 155*cdf0e10cSrcweir sal_Bool bLoadExecutable; 156*cdf0e10cSrcweir public: 157*cdf0e10cSrcweir SvtCalcFilterOptions_Impl(const OUString& rRoot) : 158*cdf0e10cSrcweir SvtAppFilterOptions_Impl(rRoot), 159*cdf0e10cSrcweir bLoadExecutable(sal_False) 160*cdf0e10cSrcweir {} 161*cdf0e10cSrcweir virtual void Commit(); 162*cdf0e10cSrcweir void Load(); 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir sal_Bool IsLoadExecutable() const {return bLoadExecutable;} 165*cdf0e10cSrcweir void SetLoadExecutable(sal_Bool bSet) 166*cdf0e10cSrcweir { 167*cdf0e10cSrcweir if(bSet != bLoadExecutable) 168*cdf0e10cSrcweir SetModified(); 169*cdf0e10cSrcweir bLoadExecutable = bSet; 170*cdf0e10cSrcweir } 171*cdf0e10cSrcweir }; 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir void SvtCalcFilterOptions_Impl::Commit() 174*cdf0e10cSrcweir { 175*cdf0e10cSrcweir SvtAppFilterOptions_Impl::Commit(); 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir Sequence<OUString> aNames(1); 178*cdf0e10cSrcweir aNames[0] = C2U("Executable"); 179*cdf0e10cSrcweir Sequence<Any> aValues(1); 180*cdf0e10cSrcweir aValues[0] <<= bLoadExecutable; 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir PutProperties(aNames, aValues); 183*cdf0e10cSrcweir } 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir void SvtCalcFilterOptions_Impl::Load() 186*cdf0e10cSrcweir { 187*cdf0e10cSrcweir SvtAppFilterOptions_Impl::Load(); 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir Sequence<OUString> aNames(1); 190*cdf0e10cSrcweir aNames[0] = C2U("Executable"); 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir Sequence<Any> aValues = GetProperties(aNames); 193*cdf0e10cSrcweir const Any* pValues = aValues.getConstArray(); 194*cdf0e10cSrcweir if(pValues[0].hasValue()) 195*cdf0e10cSrcweir bLoadExecutable = *(sal_Bool*)pValues[0].getValue(); 196*cdf0e10cSrcweir } 197*cdf0e10cSrcweir 198*cdf0e10cSrcweir /* -----------------------------22.01.01 10:32-------------------------------- 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 201*cdf0e10cSrcweir struct SvtFilterOptions_Impl 202*cdf0e10cSrcweir { 203*cdf0e10cSrcweir sal_uLong nFlags; 204*cdf0e10cSrcweir SvtAppFilterOptions_Impl aWriterCfg; 205*cdf0e10cSrcweir SvtCalcFilterOptions_Impl aCalcCfg; 206*cdf0e10cSrcweir SvtAppFilterOptions_Impl aImpressCfg; 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir SvtFilterOptions_Impl() : 209*cdf0e10cSrcweir aWriterCfg(C2U("Office.Writer/Filter/Import/VBA")), 210*cdf0e10cSrcweir aCalcCfg(C2U("Office.Calc/Filter/Import/VBA")), 211*cdf0e10cSrcweir aImpressCfg(C2U("Office.Impress/Filter/Import/VBA")) 212*cdf0e10cSrcweir { 213*cdf0e10cSrcweir nFlags = FILTERCFG_WORD_CODE | 214*cdf0e10cSrcweir FILTERCFG_WORD_STORAGE | 215*cdf0e10cSrcweir FILTERCFG_EXCEL_CODE | 216*cdf0e10cSrcweir FILTERCFG_EXCEL_STORAGE | 217*cdf0e10cSrcweir FILTERCFG_PPOINT_CODE | 218*cdf0e10cSrcweir FILTERCFG_PPOINT_STORAGE | 219*cdf0e10cSrcweir FILTERCFG_MATH_LOAD | 220*cdf0e10cSrcweir FILTERCFG_MATH_SAVE | 221*cdf0e10cSrcweir FILTERCFG_WRITER_LOAD | 222*cdf0e10cSrcweir FILTERCFG_WRITER_SAVE | 223*cdf0e10cSrcweir FILTERCFG_CALC_LOAD | 224*cdf0e10cSrcweir FILTERCFG_CALC_SAVE | 225*cdf0e10cSrcweir FILTERCFG_IMPRESS_LOAD | 226*cdf0e10cSrcweir FILTERCFG_IMPRESS_SAVE | 227*cdf0e10cSrcweir FILTERCFG_USE_ENHANCED_FIELDS; 228*cdf0e10cSrcweir Load(); 229*cdf0e10cSrcweir } 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir void SetFlag( sal_uLong nFlag, sal_Bool bSet ); 232*cdf0e10cSrcweir sal_Bool IsFlag( sal_uLong nFlag ) const; 233*cdf0e10cSrcweir void Load() 234*cdf0e10cSrcweir { 235*cdf0e10cSrcweir aWriterCfg.Load(); 236*cdf0e10cSrcweir aCalcCfg.Load(); 237*cdf0e10cSrcweir aImpressCfg.Load(); 238*cdf0e10cSrcweir } 239*cdf0e10cSrcweir }; 240*cdf0e10cSrcweir /* -----------------------------22.01.01 10:34-------------------------------- 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 243*cdf0e10cSrcweir void SvtFilterOptions_Impl::SetFlag( sal_uLong nFlag, sal_Bool bSet ) 244*cdf0e10cSrcweir { 245*cdf0e10cSrcweir switch(nFlag) 246*cdf0e10cSrcweir { 247*cdf0e10cSrcweir case FILTERCFG_WORD_CODE: aWriterCfg.SetLoad(bSet);break; 248*cdf0e10cSrcweir case FILTERCFG_WORD_STORAGE: aWriterCfg.SetSave(bSet);break; 249*cdf0e10cSrcweir case FILTERCFG_EXCEL_CODE: aCalcCfg.SetLoad(bSet);break; 250*cdf0e10cSrcweir case FILTERCFG_EXCEL_STORAGE: aCalcCfg.SetSave(bSet);break; 251*cdf0e10cSrcweir case FILTERCFG_EXCEL_EXECTBL: aCalcCfg.SetLoadExecutable(bSet);break; 252*cdf0e10cSrcweir case FILTERCFG_PPOINT_CODE: aImpressCfg.SetLoad(bSet);break; 253*cdf0e10cSrcweir case FILTERCFG_PPOINT_STORAGE: aImpressCfg.SetSave(bSet);break; 254*cdf0e10cSrcweir default: 255*cdf0e10cSrcweir if( bSet ) 256*cdf0e10cSrcweir nFlags |= nFlag; 257*cdf0e10cSrcweir else 258*cdf0e10cSrcweir nFlags &= ~nFlag; 259*cdf0e10cSrcweir } 260*cdf0e10cSrcweir } 261*cdf0e10cSrcweir /* -----------------------------22.01.01 10:35-------------------------------- 262*cdf0e10cSrcweir 263*cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 264*cdf0e10cSrcweir sal_Bool SvtFilterOptions_Impl::IsFlag( sal_uLong nFlag ) const 265*cdf0e10cSrcweir { 266*cdf0e10cSrcweir sal_Bool bRet; 267*cdf0e10cSrcweir switch(nFlag) 268*cdf0e10cSrcweir { 269*cdf0e10cSrcweir case FILTERCFG_WORD_CODE : bRet = aWriterCfg.IsLoad();break; 270*cdf0e10cSrcweir case FILTERCFG_WORD_STORAGE : bRet = aWriterCfg.IsSave();break; 271*cdf0e10cSrcweir case FILTERCFG_EXCEL_CODE : bRet = aCalcCfg.IsLoad();break; 272*cdf0e10cSrcweir case FILTERCFG_EXCEL_STORAGE : bRet = aCalcCfg.IsSave();break; 273*cdf0e10cSrcweir case FILTERCFG_EXCEL_EXECTBL : bRet = aCalcCfg.IsLoadExecutable();break; 274*cdf0e10cSrcweir case FILTERCFG_PPOINT_CODE : bRet = aImpressCfg.IsLoad();break; 275*cdf0e10cSrcweir case FILTERCFG_PPOINT_STORAGE : bRet = aImpressCfg.IsSave();break; 276*cdf0e10cSrcweir default: 277*cdf0e10cSrcweir bRet = 0 != (nFlags & nFlag ); 278*cdf0e10cSrcweir } 279*cdf0e10cSrcweir return bRet; 280*cdf0e10cSrcweir } 281*cdf0e10cSrcweir 282*cdf0e10cSrcweir // ----------------------------------------------------------------------- 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir SvtFilterOptions::SvtFilterOptions() : 285*cdf0e10cSrcweir ConfigItem( C2U("Office.Common/Filter/Microsoft") ), 286*cdf0e10cSrcweir pImp(new SvtFilterOptions_Impl) 287*cdf0e10cSrcweir { 288*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT(aLog, "unotools SvtFilterOptions::SvtFilterOptions()"); 289*cdf0e10cSrcweir EnableNotification(GetPropertyNames()); 290*cdf0e10cSrcweir Load(); 291*cdf0e10cSrcweir } 292*cdf0e10cSrcweir // ----------------------------------------------------------------------- 293*cdf0e10cSrcweir SvtFilterOptions::~SvtFilterOptions() 294*cdf0e10cSrcweir { 295*cdf0e10cSrcweir delete pImp; 296*cdf0e10cSrcweir } 297*cdf0e10cSrcweir /* -----------------------------22.01.01 08:45-------------------------------- 298*cdf0e10cSrcweir 299*cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 300*cdf0e10cSrcweir const Sequence<OUString>& SvtFilterOptions::GetPropertyNames() 301*cdf0e10cSrcweir { 302*cdf0e10cSrcweir static Sequence<OUString> aNames; 303*cdf0e10cSrcweir if(!aNames.getLength()) 304*cdf0e10cSrcweir { 305*cdf0e10cSrcweir int nCount = 12; 306*cdf0e10cSrcweir aNames.realloc(nCount); 307*cdf0e10cSrcweir static const char* aPropNames[] = 308*cdf0e10cSrcweir { 309*cdf0e10cSrcweir "Import/MathTypeToMath", // 0 310*cdf0e10cSrcweir "Import/WinWordToWriter", // 1 311*cdf0e10cSrcweir "Import/PowerPointToImpress", // 2 312*cdf0e10cSrcweir "Import/ExcelToCalc", // 3 313*cdf0e10cSrcweir "Export/MathToMathType", // 4 314*cdf0e10cSrcweir "Export/WriterToWinWord", // 5 315*cdf0e10cSrcweir "Export/ImpressToPowerPoint", // 6 316*cdf0e10cSrcweir "Export/CalcToExcel", // 7 317*cdf0e10cSrcweir "Export/EnablePowerPointPreview", // 8 318*cdf0e10cSrcweir "Export/EnableExcelPreview", // 9 319*cdf0e10cSrcweir "Export/EnableWordPreview", // 10 320*cdf0e10cSrcweir "Import/ImportWWFieldsAsEnhancedFields" // 11 321*cdf0e10cSrcweir }; 322*cdf0e10cSrcweir OUString* pNames = aNames.getArray(); 323*cdf0e10cSrcweir for(int i = 0; i < nCount; i++) 324*cdf0e10cSrcweir pNames[i] = C2U(aPropNames[i]); 325*cdf0e10cSrcweir } 326*cdf0e10cSrcweir return aNames; 327*cdf0e10cSrcweir } 328*cdf0e10cSrcweir //----------------------------------------------------------------------- 329*cdf0e10cSrcweir static sal_uLong lcl_GetFlag(sal_Int32 nProp) 330*cdf0e10cSrcweir { 331*cdf0e10cSrcweir sal_uLong nFlag = 0; 332*cdf0e10cSrcweir switch(nProp) 333*cdf0e10cSrcweir { 334*cdf0e10cSrcweir case 0: nFlag = FILTERCFG_MATH_LOAD; break; 335*cdf0e10cSrcweir case 1: nFlag = FILTERCFG_WRITER_LOAD; break; 336*cdf0e10cSrcweir case 2: nFlag = FILTERCFG_IMPRESS_LOAD; break; 337*cdf0e10cSrcweir case 3: nFlag = FILTERCFG_CALC_LOAD; break; 338*cdf0e10cSrcweir case 4: nFlag = FILTERCFG_MATH_SAVE; break; 339*cdf0e10cSrcweir case 5: nFlag = FILTERCFG_WRITER_SAVE; break; 340*cdf0e10cSrcweir case 6: nFlag = FILTERCFG_IMPRESS_SAVE; break; 341*cdf0e10cSrcweir case 7: nFlag = FILTERCFG_CALC_SAVE; break; 342*cdf0e10cSrcweir case 8: nFlag = FILTERCFG_ENABLE_PPT_PREVIEW; break; 343*cdf0e10cSrcweir case 9: nFlag = FILTERCFG_ENABLE_EXCEL_PREVIEW; break; 344*cdf0e10cSrcweir case 10: nFlag = FILTERCFG_ENABLE_WORD_PREVIEW; break; 345*cdf0e10cSrcweir case 11: nFlag = FILTERCFG_USE_ENHANCED_FIELDS; break; 346*cdf0e10cSrcweir 347*cdf0e10cSrcweir default: DBG_ERROR("illegal value"); 348*cdf0e10cSrcweir } 349*cdf0e10cSrcweir return nFlag; 350*cdf0e10cSrcweir } 351*cdf0e10cSrcweir /*-- 22.01.01 08:53:03--------------------------------------------------- 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir -----------------------------------------------------------------------*/ 354*cdf0e10cSrcweir void SvtFilterOptions::Notify( const Sequence<OUString>& ) 355*cdf0e10cSrcweir { 356*cdf0e10cSrcweir Load(); 357*cdf0e10cSrcweir } 358*cdf0e10cSrcweir /*-- 22.01.01 08:53:04--------------------------------------------------- 359*cdf0e10cSrcweir 360*cdf0e10cSrcweir -----------------------------------------------------------------------*/ 361*cdf0e10cSrcweir void SvtFilterOptions::Commit() 362*cdf0e10cSrcweir { 363*cdf0e10cSrcweir const Sequence<OUString>& aNames = GetPropertyNames(); 364*cdf0e10cSrcweir Sequence<Any> aValues(aNames.getLength()); 365*cdf0e10cSrcweir Any* pValues = aValues.getArray(); 366*cdf0e10cSrcweir 367*cdf0e10cSrcweir const Type& rType = ::getBooleanCppuType(); 368*cdf0e10cSrcweir for(int nProp = 0; nProp < aNames.getLength(); nProp++) 369*cdf0e10cSrcweir { 370*cdf0e10cSrcweir sal_uLong nFlag = lcl_GetFlag(nProp); 371*cdf0e10cSrcweir sal_Bool bVal = pImp->IsFlag( nFlag); 372*cdf0e10cSrcweir pValues[nProp].setValue(&bVal, rType); 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir } 375*cdf0e10cSrcweir PutProperties(aNames, aValues); 376*cdf0e10cSrcweir } 377*cdf0e10cSrcweir /*-- 22.01.01 08:53:04--------------------------------------------------- 378*cdf0e10cSrcweir 379*cdf0e10cSrcweir -----------------------------------------------------------------------*/ 380*cdf0e10cSrcweir void SvtFilterOptions::Load() 381*cdf0e10cSrcweir { 382*cdf0e10cSrcweir pImp->Load(); 383*cdf0e10cSrcweir const Sequence<OUString>& rNames = GetPropertyNames(); 384*cdf0e10cSrcweir Sequence<Any> aValues = GetProperties(rNames); 385*cdf0e10cSrcweir const Any* pValues = aValues.getConstArray(); 386*cdf0e10cSrcweir DBG_ASSERT(aValues.getLength() == rNames.getLength(), "GetProperties failed"); 387*cdf0e10cSrcweir if(aValues.getLength() == rNames.getLength()) 388*cdf0e10cSrcweir { 389*cdf0e10cSrcweir for(int nProp = 0; nProp < rNames.getLength(); nProp++) 390*cdf0e10cSrcweir { 391*cdf0e10cSrcweir if(pValues[nProp].hasValue()) 392*cdf0e10cSrcweir { 393*cdf0e10cSrcweir sal_Bool bVal = *(sal_Bool*)pValues[nProp].getValue(); 394*cdf0e10cSrcweir sal_uLong nFlag = lcl_GetFlag(nProp); 395*cdf0e10cSrcweir pImp->SetFlag( nFlag, bVal); 396*cdf0e10cSrcweir } 397*cdf0e10cSrcweir } 398*cdf0e10cSrcweir } 399*cdf0e10cSrcweir } 400*cdf0e10cSrcweir // ----------------------------------------------------------------------- 401*cdf0e10cSrcweir 402*cdf0e10cSrcweir void SvtFilterOptions::SetLoadWordBasicCode( sal_Bool bFlag ) 403*cdf0e10cSrcweir { 404*cdf0e10cSrcweir pImp->SetFlag( FILTERCFG_WORD_CODE, bFlag ); 405*cdf0e10cSrcweir SetModified(); 406*cdf0e10cSrcweir } 407*cdf0e10cSrcweir 408*cdf0e10cSrcweir sal_Bool SvtFilterOptions::IsLoadWordBasicCode() const 409*cdf0e10cSrcweir { 410*cdf0e10cSrcweir return pImp->IsFlag( FILTERCFG_WORD_CODE ); 411*cdf0e10cSrcweir } 412*cdf0e10cSrcweir 413*cdf0e10cSrcweir void SvtFilterOptions::SetLoadWordBasicStorage( sal_Bool bFlag ) 414*cdf0e10cSrcweir { 415*cdf0e10cSrcweir pImp->SetFlag( FILTERCFG_WORD_STORAGE, bFlag ); 416*cdf0e10cSrcweir SetModified(); 417*cdf0e10cSrcweir } 418*cdf0e10cSrcweir 419*cdf0e10cSrcweir sal_Bool SvtFilterOptions::IsLoadWordBasicStorage() const 420*cdf0e10cSrcweir { 421*cdf0e10cSrcweir return pImp->IsFlag( FILTERCFG_WORD_STORAGE ); 422*cdf0e10cSrcweir } 423*cdf0e10cSrcweir 424*cdf0e10cSrcweir // ----------------------------------------------------------------------- 425*cdf0e10cSrcweir 426*cdf0e10cSrcweir void SvtFilterOptions::SetLoadExcelBasicCode( sal_Bool bFlag ) 427*cdf0e10cSrcweir { 428*cdf0e10cSrcweir pImp->SetFlag( FILTERCFG_EXCEL_CODE, bFlag ); 429*cdf0e10cSrcweir SetModified(); 430*cdf0e10cSrcweir } 431*cdf0e10cSrcweir 432*cdf0e10cSrcweir sal_Bool SvtFilterOptions::IsLoadExcelBasicCode() const 433*cdf0e10cSrcweir { 434*cdf0e10cSrcweir return pImp->IsFlag( FILTERCFG_EXCEL_CODE ); 435*cdf0e10cSrcweir } 436*cdf0e10cSrcweir 437*cdf0e10cSrcweir void SvtFilterOptions::SetLoadExcelBasicExecutable( sal_Bool bFlag ) 438*cdf0e10cSrcweir { 439*cdf0e10cSrcweir pImp->SetFlag( FILTERCFG_EXCEL_EXECTBL, bFlag ); 440*cdf0e10cSrcweir SetModified(); 441*cdf0e10cSrcweir } 442*cdf0e10cSrcweir 443*cdf0e10cSrcweir sal_Bool SvtFilterOptions::IsLoadExcelBasicExecutable() const 444*cdf0e10cSrcweir { 445*cdf0e10cSrcweir return pImp->IsFlag( FILTERCFG_EXCEL_EXECTBL ); 446*cdf0e10cSrcweir } 447*cdf0e10cSrcweir 448*cdf0e10cSrcweir void SvtFilterOptions::SetLoadExcelBasicStorage( sal_Bool bFlag ) 449*cdf0e10cSrcweir { 450*cdf0e10cSrcweir pImp->SetFlag( FILTERCFG_EXCEL_STORAGE, bFlag ); 451*cdf0e10cSrcweir SetModified(); 452*cdf0e10cSrcweir } 453*cdf0e10cSrcweir 454*cdf0e10cSrcweir sal_Bool SvtFilterOptions::IsLoadExcelBasicStorage() const 455*cdf0e10cSrcweir { 456*cdf0e10cSrcweir return pImp->IsFlag( FILTERCFG_EXCEL_STORAGE ); 457*cdf0e10cSrcweir } 458*cdf0e10cSrcweir 459*cdf0e10cSrcweir // ----------------------------------------------------------------------- 460*cdf0e10cSrcweir 461*cdf0e10cSrcweir void SvtFilterOptions::SetLoadPPointBasicCode( sal_Bool bFlag ) 462*cdf0e10cSrcweir { 463*cdf0e10cSrcweir pImp->SetFlag( FILTERCFG_PPOINT_CODE, bFlag ); 464*cdf0e10cSrcweir SetModified(); 465*cdf0e10cSrcweir } 466*cdf0e10cSrcweir 467*cdf0e10cSrcweir sal_Bool SvtFilterOptions::IsLoadPPointBasicCode() const 468*cdf0e10cSrcweir { 469*cdf0e10cSrcweir return pImp->IsFlag( FILTERCFG_PPOINT_CODE ); 470*cdf0e10cSrcweir } 471*cdf0e10cSrcweir 472*cdf0e10cSrcweir void SvtFilterOptions::SetLoadPPointBasicStorage( sal_Bool bFlag ) 473*cdf0e10cSrcweir { 474*cdf0e10cSrcweir pImp->SetFlag( FILTERCFG_PPOINT_STORAGE, bFlag ); 475*cdf0e10cSrcweir SetModified(); 476*cdf0e10cSrcweir } 477*cdf0e10cSrcweir 478*cdf0e10cSrcweir sal_Bool SvtFilterOptions::IsLoadPPointBasicStorage() const 479*cdf0e10cSrcweir { 480*cdf0e10cSrcweir return pImp->IsFlag( FILTERCFG_PPOINT_STORAGE ); 481*cdf0e10cSrcweir } 482*cdf0e10cSrcweir 483*cdf0e10cSrcweir // ----------------------------------------------------------------------- 484*cdf0e10cSrcweir 485*cdf0e10cSrcweir sal_Bool SvtFilterOptions::IsMathType2Math() const 486*cdf0e10cSrcweir { 487*cdf0e10cSrcweir return pImp->IsFlag( FILTERCFG_MATH_LOAD ); 488*cdf0e10cSrcweir } 489*cdf0e10cSrcweir 490*cdf0e10cSrcweir void SvtFilterOptions::SetMathType2Math( sal_Bool bFlag ) 491*cdf0e10cSrcweir { 492*cdf0e10cSrcweir pImp->SetFlag( FILTERCFG_MATH_LOAD, bFlag ); 493*cdf0e10cSrcweir SetModified(); 494*cdf0e10cSrcweir } 495*cdf0e10cSrcweir 496*cdf0e10cSrcweir sal_Bool SvtFilterOptions::IsMath2MathType() const 497*cdf0e10cSrcweir { 498*cdf0e10cSrcweir return pImp->IsFlag( FILTERCFG_MATH_SAVE ); 499*cdf0e10cSrcweir } 500*cdf0e10cSrcweir 501*cdf0e10cSrcweir void SvtFilterOptions::SetMath2MathType( sal_Bool bFlag ) 502*cdf0e10cSrcweir { 503*cdf0e10cSrcweir pImp->SetFlag( FILTERCFG_MATH_SAVE, bFlag ); 504*cdf0e10cSrcweir SetModified(); 505*cdf0e10cSrcweir } 506*cdf0e10cSrcweir 507*cdf0e10cSrcweir 508*cdf0e10cSrcweir // ----------------------------------------------------------------------- 509*cdf0e10cSrcweir sal_Bool SvtFilterOptions::IsWinWord2Writer() const 510*cdf0e10cSrcweir { 511*cdf0e10cSrcweir return pImp->IsFlag( FILTERCFG_WRITER_LOAD ); 512*cdf0e10cSrcweir } 513*cdf0e10cSrcweir 514*cdf0e10cSrcweir void SvtFilterOptions::SetWinWord2Writer( sal_Bool bFlag ) 515*cdf0e10cSrcweir { 516*cdf0e10cSrcweir pImp->SetFlag( FILTERCFG_WRITER_LOAD, bFlag ); 517*cdf0e10cSrcweir SetModified(); 518*cdf0e10cSrcweir } 519*cdf0e10cSrcweir 520*cdf0e10cSrcweir sal_Bool SvtFilterOptions::IsWriter2WinWord() const 521*cdf0e10cSrcweir { 522*cdf0e10cSrcweir return pImp->IsFlag( FILTERCFG_WRITER_SAVE ); 523*cdf0e10cSrcweir } 524*cdf0e10cSrcweir 525*cdf0e10cSrcweir void SvtFilterOptions::SetWriter2WinWord( sal_Bool bFlag ) 526*cdf0e10cSrcweir { 527*cdf0e10cSrcweir pImp->SetFlag( FILTERCFG_WRITER_SAVE, bFlag ); 528*cdf0e10cSrcweir SetModified(); 529*cdf0e10cSrcweir } 530*cdf0e10cSrcweir 531*cdf0e10cSrcweir sal_Bool SvtFilterOptions::IsUseEnhancedFields() const 532*cdf0e10cSrcweir { 533*cdf0e10cSrcweir return false; // disable for now; 534*cdf0e10cSrcweir // return pImp->IsFlag( FILTERCFG_USE_ENHANCED_FIELDS ); 535*cdf0e10cSrcweir } 536*cdf0e10cSrcweir 537*cdf0e10cSrcweir void SvtFilterOptions::SetUseEnhancedFields( sal_Bool bFlag ) 538*cdf0e10cSrcweir { 539*cdf0e10cSrcweir pImp->SetFlag( FILTERCFG_USE_ENHANCED_FIELDS, bFlag ); 540*cdf0e10cSrcweir SetModified(); 541*cdf0e10cSrcweir } 542*cdf0e10cSrcweir 543*cdf0e10cSrcweir // ----------------------------------------------------------------------- 544*cdf0e10cSrcweir sal_Bool SvtFilterOptions::IsExcel2Calc() const 545*cdf0e10cSrcweir { 546*cdf0e10cSrcweir return pImp->IsFlag( FILTERCFG_CALC_LOAD ); 547*cdf0e10cSrcweir } 548*cdf0e10cSrcweir 549*cdf0e10cSrcweir void SvtFilterOptions::SetExcel2Calc( sal_Bool bFlag ) 550*cdf0e10cSrcweir { 551*cdf0e10cSrcweir pImp->SetFlag( FILTERCFG_CALC_LOAD, bFlag ); 552*cdf0e10cSrcweir SetModified(); 553*cdf0e10cSrcweir } 554*cdf0e10cSrcweir 555*cdf0e10cSrcweir sal_Bool SvtFilterOptions::IsCalc2Excel() const 556*cdf0e10cSrcweir { 557*cdf0e10cSrcweir return pImp->IsFlag( FILTERCFG_CALC_SAVE ); 558*cdf0e10cSrcweir } 559*cdf0e10cSrcweir 560*cdf0e10cSrcweir void SvtFilterOptions::SetCalc2Excel( sal_Bool bFlag ) 561*cdf0e10cSrcweir { 562*cdf0e10cSrcweir pImp->SetFlag( FILTERCFG_CALC_SAVE, bFlag ); 563*cdf0e10cSrcweir SetModified(); 564*cdf0e10cSrcweir } 565*cdf0e10cSrcweir 566*cdf0e10cSrcweir 567*cdf0e10cSrcweir // ----------------------------------------------------------------------- 568*cdf0e10cSrcweir sal_Bool SvtFilterOptions::IsPowerPoint2Impress() const 569*cdf0e10cSrcweir { 570*cdf0e10cSrcweir return pImp->IsFlag( FILTERCFG_IMPRESS_LOAD ); 571*cdf0e10cSrcweir } 572*cdf0e10cSrcweir 573*cdf0e10cSrcweir void SvtFilterOptions::SetPowerPoint2Impress( sal_Bool bFlag ) 574*cdf0e10cSrcweir { 575*cdf0e10cSrcweir pImp->SetFlag( FILTERCFG_IMPRESS_LOAD, bFlag ); 576*cdf0e10cSrcweir SetModified(); 577*cdf0e10cSrcweir } 578*cdf0e10cSrcweir 579*cdf0e10cSrcweir sal_Bool SvtFilterOptions::IsImpress2PowerPoint() const 580*cdf0e10cSrcweir { 581*cdf0e10cSrcweir return pImp->IsFlag( FILTERCFG_IMPRESS_SAVE ); 582*cdf0e10cSrcweir } 583*cdf0e10cSrcweir 584*cdf0e10cSrcweir void SvtFilterOptions::SetImpress2PowerPoint( sal_Bool bFlag ) 585*cdf0e10cSrcweir { 586*cdf0e10cSrcweir pImp->SetFlag( FILTERCFG_IMPRESS_SAVE, bFlag ); 587*cdf0e10cSrcweir SetModified(); 588*cdf0e10cSrcweir } 589*cdf0e10cSrcweir 590*cdf0e10cSrcweir SvtFilterOptions* SvtFilterOptions::Get() 591*cdf0e10cSrcweir { 592*cdf0e10cSrcweir if ( !pOptions ) 593*cdf0e10cSrcweir pOptions = new SvtFilterOptions; 594*cdf0e10cSrcweir return pOptions; 595*cdf0e10cSrcweir } 596*cdf0e10cSrcweir 597*cdf0e10cSrcweir // ----------------------------------------------------------------------- 598*cdf0e10cSrcweir 599*cdf0e10cSrcweir sal_Bool SvtFilterOptions::IsEnablePPTPreview() const 600*cdf0e10cSrcweir { 601*cdf0e10cSrcweir return pImp->IsFlag( FILTERCFG_ENABLE_PPT_PREVIEW ); 602*cdf0e10cSrcweir } 603*cdf0e10cSrcweir 604*cdf0e10cSrcweir 605*cdf0e10cSrcweir sal_Bool SvtFilterOptions::IsEnableCalcPreview() const 606*cdf0e10cSrcweir { 607*cdf0e10cSrcweir return pImp->IsFlag( FILTERCFG_ENABLE_EXCEL_PREVIEW ); 608*cdf0e10cSrcweir } 609*cdf0e10cSrcweir 610*cdf0e10cSrcweir 611*cdf0e10cSrcweir sal_Bool SvtFilterOptions::IsEnableWordPreview() const 612*cdf0e10cSrcweir { 613*cdf0e10cSrcweir return pImp->IsFlag( FILTERCFG_ENABLE_WORD_PREVIEW ); 614*cdf0e10cSrcweir } 615*cdf0e10cSrcweir 616*cdf0e10cSrcweir 617