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