1*b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*b3f79822SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*b3f79822SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*b3f79822SAndrew Rist * distributed with this work for additional information
6*b3f79822SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*b3f79822SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*b3f79822SAndrew Rist * "License"); you may not use this file except in compliance
9*b3f79822SAndrew Rist * with the License. You may obtain a copy of the License at
10*b3f79822SAndrew Rist *
11*b3f79822SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*b3f79822SAndrew Rist *
13*b3f79822SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*b3f79822SAndrew Rist * software distributed under the License is distributed on an
15*b3f79822SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b3f79822SAndrew Rist * KIND, either express or implied. See the License for the
17*b3f79822SAndrew Rist * specific language governing permissions and limitations
18*b3f79822SAndrew Rist * under the License.
19*b3f79822SAndrew Rist *
20*b3f79822SAndrew Rist *************************************************************/
21*b3f79822SAndrew Rist
22*b3f79822SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sc.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir
28cdf0e10cSrcweir
29cdf0e10cSrcweir #include <vcl/svapp.hxx>
30cdf0e10cSrcweir #include <svl/zforlist.hxx>
31cdf0e10cSrcweir
32cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx>
33cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
34cdf0e10cSrcweir
35cdf0e10cSrcweir #include "cfgids.hxx"
36cdf0e10cSrcweir #include "docoptio.hxx"
37cdf0e10cSrcweir #include "rechead.hxx"
38cdf0e10cSrcweir #include "scresid.hxx"
39cdf0e10cSrcweir #include "sc.hrc"
40cdf0e10cSrcweir #include "miscuno.hxx"
41cdf0e10cSrcweir
42cdf0e10cSrcweir using namespace utl;
43cdf0e10cSrcweir using namespace rtl;
44cdf0e10cSrcweir using namespace com::sun::star::uno;
45cdf0e10cSrcweir
46cdf0e10cSrcweir //------------------------------------------------------------------------
47cdf0e10cSrcweir
48cdf0e10cSrcweir #define SC_VERSION ((sal_uInt16)251)
49cdf0e10cSrcweir
50cdf0e10cSrcweir TYPEINIT1(ScTpCalcItem, SfxPoolItem);
51cdf0e10cSrcweir
52cdf0e10cSrcweir //------------------------------------------------------------------------
53cdf0e10cSrcweir
54cdf0e10cSrcweir //! these functions should be moved to some header file
TwipsToHMM(long nTwips)55cdf0e10cSrcweir inline long TwipsToHMM(long nTwips) { return (nTwips * 127 + 36) / 72; }
HMMToTwips(long nHMM)56cdf0e10cSrcweir inline long HMMToTwips(long nHMM) { return (nHMM * 72 + 63) / 127; }
57cdf0e10cSrcweir
TwipsToEvenHMM(long nTwips)58cdf0e10cSrcweir inline long TwipsToEvenHMM(long nTwips) { return ( (nTwips * 127 + 72) / 144 ) * 2; }
59cdf0e10cSrcweir
60cdf0e10cSrcweir //------------------------------------------------------------------------
61cdf0e10cSrcweir
lcl_GetDefaultTabDist()62cdf0e10cSrcweir sal_uInt16 lcl_GetDefaultTabDist()
63cdf0e10cSrcweir {
64cdf0e10cSrcweir if ( ScOptionsUtil::IsMetricSystem() )
65cdf0e10cSrcweir return 709; // 1,25 cm
66cdf0e10cSrcweir else
67cdf0e10cSrcweir return 720; // 1/2"
68cdf0e10cSrcweir }
69cdf0e10cSrcweir
70cdf0e10cSrcweir //========================================================================
71cdf0e10cSrcweir // ScDocOptions - Dokument-Optionen
72cdf0e10cSrcweir //========================================================================
73cdf0e10cSrcweir
ScDocOptions()74cdf0e10cSrcweir ScDocOptions::ScDocOptions()
75cdf0e10cSrcweir {
76cdf0e10cSrcweir ResetDocOptions();
77cdf0e10cSrcweir }
78cdf0e10cSrcweir
79cdf0e10cSrcweir //------------------------------------------------------------------------
80cdf0e10cSrcweir
ScDocOptions(const ScDocOptions & rCpy)81cdf0e10cSrcweir ScDocOptions::ScDocOptions( const ScDocOptions& rCpy )
82cdf0e10cSrcweir : fIterEps( rCpy.fIterEps ),
83cdf0e10cSrcweir nIterCount( rCpy.nIterCount ),
84cdf0e10cSrcweir nPrecStandardFormat( rCpy.nPrecStandardFormat ),
85cdf0e10cSrcweir nDay( rCpy.nDay ),
86cdf0e10cSrcweir nMonth( rCpy.nMonth ),
87cdf0e10cSrcweir nYear( rCpy.nYear ),
88cdf0e10cSrcweir nYear2000( rCpy.nYear2000 ),
89cdf0e10cSrcweir nTabDistance( rCpy.nTabDistance ),
90cdf0e10cSrcweir bIsIgnoreCase( rCpy.bIsIgnoreCase ),
91cdf0e10cSrcweir bIsIter( rCpy.bIsIter ),
92cdf0e10cSrcweir bCalcAsShown( rCpy.bCalcAsShown ),
93cdf0e10cSrcweir bMatchWholeCell( rCpy.bMatchWholeCell ),
94cdf0e10cSrcweir bDoAutoSpell( rCpy.bDoAutoSpell ),
95cdf0e10cSrcweir bLookUpColRowNames( rCpy.bLookUpColRowNames ),
96cdf0e10cSrcweir bFormulaRegexEnabled( rCpy.bFormulaRegexEnabled )
97cdf0e10cSrcweir {
98cdf0e10cSrcweir }
99cdf0e10cSrcweir
100cdf0e10cSrcweir //------------------------------------------------------------------------
101cdf0e10cSrcweir
~ScDocOptions()102cdf0e10cSrcweir ScDocOptions::~ScDocOptions()
103cdf0e10cSrcweir {
104cdf0e10cSrcweir }
105cdf0e10cSrcweir
106cdf0e10cSrcweir //------------------------------------------------------------------------
107cdf0e10cSrcweir
ResetDocOptions()108cdf0e10cSrcweir void ScDocOptions::ResetDocOptions()
109cdf0e10cSrcweir {
110cdf0e10cSrcweir bIsIgnoreCase = sal_False;
111cdf0e10cSrcweir bIsIter = sal_False;
112cdf0e10cSrcweir nIterCount = 100;
113cdf0e10cSrcweir fIterEps = 1.0E-3;
114cdf0e10cSrcweir nPrecStandardFormat = SvNumberFormatter::UNLIMITED_PRECISION;
115cdf0e10cSrcweir nDay = 30;
116cdf0e10cSrcweir nMonth = 12;
117cdf0e10cSrcweir nYear = 1899;
118cdf0e10cSrcweir nYear2000 = SvNumberFormatter::GetYear2000Default();
119cdf0e10cSrcweir nTabDistance = lcl_GetDefaultTabDist();
120cdf0e10cSrcweir bCalcAsShown = sal_False;
121cdf0e10cSrcweir bMatchWholeCell = sal_True;
122cdf0e10cSrcweir bDoAutoSpell = sal_False;
123cdf0e10cSrcweir bLookUpColRowNames = sal_True;
124cdf0e10cSrcweir bFormulaRegexEnabled= sal_True;
125cdf0e10cSrcweir }
126cdf0e10cSrcweir
127cdf0e10cSrcweir //========================================================================
128cdf0e10cSrcweir // ScTpCalcItem - Daten fuer die CalcOptions-TabPage
129cdf0e10cSrcweir //========================================================================
130cdf0e10cSrcweir
131cdf0e10cSrcweir //UNUSED2008-05 ScTpCalcItem::ScTpCalcItem( sal_uInt16 nWhichP ) : SfxPoolItem( nWhichP )
132cdf0e10cSrcweir //UNUSED2008-05 {
133cdf0e10cSrcweir //UNUSED2008-05 }
134cdf0e10cSrcweir
135cdf0e10cSrcweir //------------------------------------------------------------------------
136cdf0e10cSrcweir
ScTpCalcItem(sal_uInt16 nWhichP,const ScDocOptions & rOpt)137cdf0e10cSrcweir ScTpCalcItem::ScTpCalcItem( sal_uInt16 nWhichP, const ScDocOptions& rOpt )
138cdf0e10cSrcweir : SfxPoolItem ( nWhichP ),
139cdf0e10cSrcweir theOptions ( rOpt )
140cdf0e10cSrcweir {
141cdf0e10cSrcweir }
142cdf0e10cSrcweir
143cdf0e10cSrcweir //------------------------------------------------------------------------
144cdf0e10cSrcweir
ScTpCalcItem(const ScTpCalcItem & rItem)145cdf0e10cSrcweir ScTpCalcItem::ScTpCalcItem( const ScTpCalcItem& rItem )
146cdf0e10cSrcweir : SfxPoolItem ( rItem ),
147cdf0e10cSrcweir theOptions ( rItem.theOptions )
148cdf0e10cSrcweir {
149cdf0e10cSrcweir }
150cdf0e10cSrcweir
151cdf0e10cSrcweir //------------------------------------------------------------------------
152cdf0e10cSrcweir
~ScTpCalcItem()153cdf0e10cSrcweir __EXPORT ScTpCalcItem::~ScTpCalcItem()
154cdf0e10cSrcweir {
155cdf0e10cSrcweir }
156cdf0e10cSrcweir
157cdf0e10cSrcweir //------------------------------------------------------------------------
158cdf0e10cSrcweir
GetValueText() const159cdf0e10cSrcweir String __EXPORT ScTpCalcItem::GetValueText() const
160cdf0e10cSrcweir {
161cdf0e10cSrcweir return String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM("ScTpCalcItem") );
162cdf0e10cSrcweir }
163cdf0e10cSrcweir
164cdf0e10cSrcweir //------------------------------------------------------------------------
165cdf0e10cSrcweir
operator ==(const SfxPoolItem & rItem) const166cdf0e10cSrcweir int __EXPORT ScTpCalcItem::operator==( const SfxPoolItem& rItem ) const
167cdf0e10cSrcweir {
168cdf0e10cSrcweir DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal Which or Type" );
169cdf0e10cSrcweir
170cdf0e10cSrcweir const ScTpCalcItem& rPItem = (const ScTpCalcItem&)rItem;
171cdf0e10cSrcweir
172cdf0e10cSrcweir return ( theOptions == rPItem.theOptions );
173cdf0e10cSrcweir }
174cdf0e10cSrcweir
175cdf0e10cSrcweir //------------------------------------------------------------------------
176cdf0e10cSrcweir
Clone(SfxItemPool *) const177cdf0e10cSrcweir SfxPoolItem* __EXPORT ScTpCalcItem::Clone( SfxItemPool * ) const
178cdf0e10cSrcweir {
179cdf0e10cSrcweir return new ScTpCalcItem( *this );
180cdf0e10cSrcweir }
181cdf0e10cSrcweir
182cdf0e10cSrcweir //==================================================================
183cdf0e10cSrcweir // Config Item containing document options
184cdf0e10cSrcweir //==================================================================
185cdf0e10cSrcweir
186cdf0e10cSrcweir #define CFGPATH_CALC "Office.Calc/Calculate"
187cdf0e10cSrcweir
188cdf0e10cSrcweir #define SCCALCOPT_ITER_ITER 0
189cdf0e10cSrcweir #define SCCALCOPT_ITER_STEPS 1
190cdf0e10cSrcweir #define SCCALCOPT_ITER_MINCHG 2
191cdf0e10cSrcweir #define SCCALCOPT_DATE_DAY 3
192cdf0e10cSrcweir #define SCCALCOPT_DATE_MONTH 4
193cdf0e10cSrcweir #define SCCALCOPT_DATE_YEAR 5
194cdf0e10cSrcweir #define SCCALCOPT_DECIMALS 6
195cdf0e10cSrcweir #define SCCALCOPT_CASESENSITIVE 7
196cdf0e10cSrcweir #define SCCALCOPT_PRECISION 8
197cdf0e10cSrcweir #define SCCALCOPT_SEARCHCRIT 9
198cdf0e10cSrcweir #define SCCALCOPT_FINDLABEL 10
199cdf0e10cSrcweir #define SCCALCOPT_REGEX 11
200cdf0e10cSrcweir #define SCCALCOPT_COUNT 12
201cdf0e10cSrcweir
202cdf0e10cSrcweir #define CFGPATH_DOCLAYOUT "Office.Calc/Layout/Other"
203cdf0e10cSrcweir
204cdf0e10cSrcweir #define SCDOCLAYOUTOPT_TABSTOP 0
205cdf0e10cSrcweir #define SCDOCLAYOUTOPT_COUNT 1
206cdf0e10cSrcweir
207cdf0e10cSrcweir
GetCalcPropertyNames()208cdf0e10cSrcweir Sequence<OUString> ScDocCfg::GetCalcPropertyNames()
209cdf0e10cSrcweir {
210cdf0e10cSrcweir static const char* aPropNames[] =
211cdf0e10cSrcweir {
212cdf0e10cSrcweir "IterativeReference/Iteration", // SCCALCOPT_ITER_ITER
213cdf0e10cSrcweir "IterativeReference/Steps", // SCCALCOPT_ITER_STEPS
214cdf0e10cSrcweir "IterativeReference/MinimumChange", // SCCALCOPT_ITER_MINCHG
215cdf0e10cSrcweir "Other/Date/DD", // SCCALCOPT_DATE_DAY
216cdf0e10cSrcweir "Other/Date/MM", // SCCALCOPT_DATE_MONTH
217cdf0e10cSrcweir "Other/Date/YY", // SCCALCOPT_DATE_YEAR
218cdf0e10cSrcweir "Other/DecimalPlaces", // SCCALCOPT_DECIMALS
219cdf0e10cSrcweir "Other/CaseSensitive", // SCCALCOPT_CASESENSITIVE
220cdf0e10cSrcweir "Other/Precision", // SCCALCOPT_PRECISION
221cdf0e10cSrcweir "Other/SearchCriteria", // SCCALCOPT_SEARCHCRIT
222cdf0e10cSrcweir "Other/FindLabel", // SCCALCOPT_FINDLABEL
223cdf0e10cSrcweir "Other/RegularExpressions" // SCCALCOPT_REGEX
224cdf0e10cSrcweir };
225cdf0e10cSrcweir Sequence<OUString> aNames(SCCALCOPT_COUNT);
226cdf0e10cSrcweir OUString* pNames = aNames.getArray();
227cdf0e10cSrcweir for(int i = 0; i < SCCALCOPT_COUNT; i++)
228cdf0e10cSrcweir pNames[i] = OUString::createFromAscii(aPropNames[i]);
229cdf0e10cSrcweir
230cdf0e10cSrcweir return aNames;
231cdf0e10cSrcweir }
232cdf0e10cSrcweir
GetLayoutPropertyNames()233cdf0e10cSrcweir Sequence<OUString> ScDocCfg::GetLayoutPropertyNames()
234cdf0e10cSrcweir {
235cdf0e10cSrcweir static const char* aPropNames[] =
236cdf0e10cSrcweir {
237cdf0e10cSrcweir "TabStop/NonMetric" // SCDOCLAYOUTOPT_TABSTOP
238cdf0e10cSrcweir };
239cdf0e10cSrcweir Sequence<OUString> aNames(SCDOCLAYOUTOPT_COUNT);
240cdf0e10cSrcweir OUString* pNames = aNames.getArray();
241cdf0e10cSrcweir for(int i = 0; i < SCDOCLAYOUTOPT_COUNT; i++)
242cdf0e10cSrcweir pNames[i] = OUString::createFromAscii(aPropNames[i]);
243cdf0e10cSrcweir
244cdf0e10cSrcweir // adjust for metric system
245cdf0e10cSrcweir if (ScOptionsUtil::IsMetricSystem())
246cdf0e10cSrcweir pNames[SCDOCLAYOUTOPT_TABSTOP] = OUString::createFromAscii( "TabStop/Metric" );
247cdf0e10cSrcweir
248cdf0e10cSrcweir return aNames;
249cdf0e10cSrcweir }
250cdf0e10cSrcweir
ScDocCfg()251cdf0e10cSrcweir ScDocCfg::ScDocCfg() :
252cdf0e10cSrcweir aCalcItem( OUString::createFromAscii( CFGPATH_CALC ) ),
253cdf0e10cSrcweir aLayoutItem( OUString::createFromAscii( CFGPATH_DOCLAYOUT ) )
254cdf0e10cSrcweir {
255cdf0e10cSrcweir sal_Int32 nIntVal = 0;
256cdf0e10cSrcweir double fDoubleVal = 0;
257cdf0e10cSrcweir
258cdf0e10cSrcweir Sequence<OUString> aNames;
259cdf0e10cSrcweir Sequence<Any> aValues;
260cdf0e10cSrcweir const Any* pValues = NULL;
261cdf0e10cSrcweir
262cdf0e10cSrcweir sal_uInt16 nDateDay, nDateMonth, nDateYear;
263cdf0e10cSrcweir GetDate( nDateDay, nDateMonth, nDateYear );
264cdf0e10cSrcweir
265cdf0e10cSrcweir aNames = GetCalcPropertyNames();
266cdf0e10cSrcweir aValues = aCalcItem.GetProperties(aNames);
267cdf0e10cSrcweir aCalcItem.EnableNotification(aNames);
268cdf0e10cSrcweir pValues = aValues.getConstArray();
269cdf0e10cSrcweir DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed");
270cdf0e10cSrcweir if(aValues.getLength() == aNames.getLength())
271cdf0e10cSrcweir {
272cdf0e10cSrcweir for(int nProp = 0; nProp < aNames.getLength(); nProp++)
273cdf0e10cSrcweir {
274cdf0e10cSrcweir DBG_ASSERT(pValues[nProp].hasValue(), "property value missing");
275cdf0e10cSrcweir if(pValues[nProp].hasValue())
276cdf0e10cSrcweir {
277cdf0e10cSrcweir switch(nProp)
278cdf0e10cSrcweir {
279cdf0e10cSrcweir case SCCALCOPT_ITER_ITER:
280cdf0e10cSrcweir SetIter( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
281cdf0e10cSrcweir break;
282cdf0e10cSrcweir case SCCALCOPT_ITER_STEPS:
283cdf0e10cSrcweir if (pValues[nProp] >>= nIntVal) SetIterCount( (sal_uInt16) nIntVal );
284cdf0e10cSrcweir break;
285cdf0e10cSrcweir case SCCALCOPT_ITER_MINCHG:
286cdf0e10cSrcweir if (pValues[nProp] >>= fDoubleVal) SetIterEps( fDoubleVal );
287cdf0e10cSrcweir break;
288cdf0e10cSrcweir case SCCALCOPT_DATE_DAY:
289cdf0e10cSrcweir if (pValues[nProp] >>= nIntVal) nDateDay = (sal_uInt16) nIntVal;
290cdf0e10cSrcweir break;
291cdf0e10cSrcweir case SCCALCOPT_DATE_MONTH:
292cdf0e10cSrcweir if (pValues[nProp] >>= nIntVal) nDateMonth = (sal_uInt16) nIntVal;
293cdf0e10cSrcweir break;
294cdf0e10cSrcweir case SCCALCOPT_DATE_YEAR:
295cdf0e10cSrcweir if (pValues[nProp] >>= nIntVal) nDateYear = (sal_uInt16) nIntVal;
296cdf0e10cSrcweir break;
297cdf0e10cSrcweir case SCCALCOPT_DECIMALS:
298cdf0e10cSrcweir if (pValues[nProp] >>= nIntVal) SetStdPrecision( (sal_uInt16) nIntVal );
299cdf0e10cSrcweir break;
300cdf0e10cSrcweir case SCCALCOPT_CASESENSITIVE:
301cdf0e10cSrcweir // content is reversed
302cdf0e10cSrcweir SetIgnoreCase( !ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
303cdf0e10cSrcweir break;
304cdf0e10cSrcweir case SCCALCOPT_PRECISION:
305cdf0e10cSrcweir SetCalcAsShown( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
306cdf0e10cSrcweir break;
307cdf0e10cSrcweir case SCCALCOPT_SEARCHCRIT:
308cdf0e10cSrcweir SetMatchWholeCell( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
309cdf0e10cSrcweir break;
310cdf0e10cSrcweir case SCCALCOPT_FINDLABEL:
311cdf0e10cSrcweir SetLookUpColRowNames( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
312cdf0e10cSrcweir break;
313cdf0e10cSrcweir case SCCALCOPT_REGEX :
314cdf0e10cSrcweir SetFormulaRegexEnabled( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
315cdf0e10cSrcweir break;
316cdf0e10cSrcweir }
317cdf0e10cSrcweir }
318cdf0e10cSrcweir }
319cdf0e10cSrcweir }
320cdf0e10cSrcweir aCalcItem.SetCommitLink( LINK( this, ScDocCfg, CalcCommitHdl ) );
321cdf0e10cSrcweir
322cdf0e10cSrcweir SetDate( nDateDay, nDateMonth, nDateYear );
323cdf0e10cSrcweir
324cdf0e10cSrcweir aNames = GetLayoutPropertyNames();
325cdf0e10cSrcweir aValues = aLayoutItem.GetProperties(aNames);
326cdf0e10cSrcweir aLayoutItem.EnableNotification(aNames);
327cdf0e10cSrcweir pValues = aValues.getConstArray();
328cdf0e10cSrcweir DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed");
329cdf0e10cSrcweir if(aValues.getLength() == aNames.getLength())
330cdf0e10cSrcweir {
331cdf0e10cSrcweir for(int nProp = 0; nProp < aNames.getLength(); nProp++)
332cdf0e10cSrcweir {
333cdf0e10cSrcweir DBG_ASSERT(pValues[nProp].hasValue(), "property value missing");
334cdf0e10cSrcweir if(pValues[nProp].hasValue())
335cdf0e10cSrcweir {
336cdf0e10cSrcweir switch(nProp)
337cdf0e10cSrcweir {
338cdf0e10cSrcweir case SCDOCLAYOUTOPT_TABSTOP:
339cdf0e10cSrcweir // TabDistance in ScDocOptions is in twips
340cdf0e10cSrcweir if (pValues[nProp] >>= nIntVal)
341cdf0e10cSrcweir SetTabDistance( (sal_uInt16) HMMToTwips( nIntVal ) );
342cdf0e10cSrcweir break;
343cdf0e10cSrcweir }
344cdf0e10cSrcweir }
345cdf0e10cSrcweir }
346cdf0e10cSrcweir }
347cdf0e10cSrcweir aLayoutItem.SetCommitLink( LINK( this, ScDocCfg, LayoutCommitHdl ) );
348cdf0e10cSrcweir }
349cdf0e10cSrcweir
IMPL_LINK(ScDocCfg,CalcCommitHdl,void *,EMPTYARG)350cdf0e10cSrcweir IMPL_LINK( ScDocCfg, CalcCommitHdl, void *, EMPTYARG )
351cdf0e10cSrcweir {
352cdf0e10cSrcweir Sequence<OUString> aNames = GetCalcPropertyNames();
353cdf0e10cSrcweir Sequence<Any> aValues(aNames.getLength());
354cdf0e10cSrcweir Any* pValues = aValues.getArray();
355cdf0e10cSrcweir
356cdf0e10cSrcweir sal_uInt16 nDateDay, nDateMonth, nDateYear;
357cdf0e10cSrcweir GetDate( nDateDay, nDateMonth, nDateYear );
358cdf0e10cSrcweir
359cdf0e10cSrcweir for(int nProp = 0; nProp < aNames.getLength(); nProp++)
360cdf0e10cSrcweir {
361cdf0e10cSrcweir switch(nProp)
362cdf0e10cSrcweir {
363cdf0e10cSrcweir case SCCALCOPT_ITER_ITER:
364cdf0e10cSrcweir ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], IsIter() );
365cdf0e10cSrcweir break;
366cdf0e10cSrcweir case SCCALCOPT_ITER_STEPS:
367cdf0e10cSrcweir pValues[nProp] <<= (sal_Int32) GetIterCount();
368cdf0e10cSrcweir break;
369cdf0e10cSrcweir case SCCALCOPT_ITER_MINCHG:
370cdf0e10cSrcweir pValues[nProp] <<= (double) GetIterEps();
371cdf0e10cSrcweir break;
372cdf0e10cSrcweir case SCCALCOPT_DATE_DAY:
373cdf0e10cSrcweir pValues[nProp] <<= (sal_Int32) nDateDay;
374cdf0e10cSrcweir break;
375cdf0e10cSrcweir case SCCALCOPT_DATE_MONTH:
376cdf0e10cSrcweir pValues[nProp] <<= (sal_Int32) nDateMonth;
377cdf0e10cSrcweir break;
378cdf0e10cSrcweir case SCCALCOPT_DATE_YEAR:
379cdf0e10cSrcweir pValues[nProp] <<= (sal_Int32) nDateYear;
380cdf0e10cSrcweir break;
381cdf0e10cSrcweir case SCCALCOPT_DECIMALS:
382cdf0e10cSrcweir pValues[nProp] <<= (sal_Int32) GetStdPrecision();
383cdf0e10cSrcweir break;
384cdf0e10cSrcweir case SCCALCOPT_CASESENSITIVE:
385cdf0e10cSrcweir // content is reversed
386cdf0e10cSrcweir ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], !IsIgnoreCase() );
387cdf0e10cSrcweir break;
388cdf0e10cSrcweir case SCCALCOPT_PRECISION:
389cdf0e10cSrcweir ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], IsCalcAsShown() );
390cdf0e10cSrcweir break;
391cdf0e10cSrcweir case SCCALCOPT_SEARCHCRIT:
392cdf0e10cSrcweir ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], IsMatchWholeCell() );
393cdf0e10cSrcweir break;
394cdf0e10cSrcweir case SCCALCOPT_FINDLABEL:
395cdf0e10cSrcweir ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], IsLookUpColRowNames() );
396cdf0e10cSrcweir break;
397cdf0e10cSrcweir case SCCALCOPT_REGEX :
398cdf0e10cSrcweir ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], IsFormulaRegexEnabled() );
399cdf0e10cSrcweir }
400cdf0e10cSrcweir }
401cdf0e10cSrcweir aCalcItem.PutProperties(aNames, aValues);
402cdf0e10cSrcweir
403cdf0e10cSrcweir return 0;
404cdf0e10cSrcweir }
405cdf0e10cSrcweir
IMPL_LINK(ScDocCfg,LayoutCommitHdl,void *,EMPTYARG)406cdf0e10cSrcweir IMPL_LINK( ScDocCfg, LayoutCommitHdl, void *, EMPTYARG )
407cdf0e10cSrcweir {
408cdf0e10cSrcweir Sequence<OUString> aNames = GetLayoutPropertyNames();
409cdf0e10cSrcweir Sequence<Any> aValues(aNames.getLength());
410cdf0e10cSrcweir Any* pValues = aValues.getArray();
411cdf0e10cSrcweir
412cdf0e10cSrcweir for(int nProp = 0; nProp < aNames.getLength(); nProp++)
413cdf0e10cSrcweir {
414cdf0e10cSrcweir switch(nProp)
415cdf0e10cSrcweir {
416cdf0e10cSrcweir case SCDOCLAYOUTOPT_TABSTOP:
417cdf0e10cSrcweir // TabDistance in ScDocOptions is in twips
418cdf0e10cSrcweir // use only even numbers, so defaults don't get changed
419cdf0e10cSrcweir // by modifying other settings in the same config item
420cdf0e10cSrcweir pValues[nProp] <<= (sal_Int32) TwipsToEvenHMM( GetTabDistance() );
421cdf0e10cSrcweir break;
422cdf0e10cSrcweir }
423cdf0e10cSrcweir }
424cdf0e10cSrcweir aLayoutItem.PutProperties(aNames, aValues);
425cdf0e10cSrcweir
426cdf0e10cSrcweir return 0;
427cdf0e10cSrcweir }
428cdf0e10cSrcweir
429cdf0e10cSrcweir
SetOptions(const ScDocOptions & rNew)430cdf0e10cSrcweir void ScDocCfg::SetOptions( const ScDocOptions& rNew )
431cdf0e10cSrcweir {
432cdf0e10cSrcweir *(ScDocOptions*)this = rNew;
433cdf0e10cSrcweir
434cdf0e10cSrcweir aCalcItem.SetModified();
435cdf0e10cSrcweir aLayoutItem.SetModified();
436cdf0e10cSrcweir }
437cdf0e10cSrcweir
438cdf0e10cSrcweir
439