1 diff --git formula/inc/formula/FormulaCompiler.hxx formula/inc/formula/FormulaCompiler.hxx
2 index 7da03fd..6df4898 100644
3 --- formula/inc/formula/FormulaCompiler.hxx
4 +++ formula/inc/formula/FormulaCompiler.hxx
5 @@ -237,6 +237,8 @@ public:
6 including an address reference convention. */
7 inline FormulaGrammar::Grammar GetGrammar() const { return meGrammar; }
9 + static void UpdateSeparatorsNative( const rtl::OUString& rSep, const rtl::OUString& rArrayColSep, const rtl::OUString& rArrayRowSep );
12 virtual String FindAddInFunction( const String& rUpperName, BOOL bLocalFirst ) const;
13 virtual void fillFromAddInCollectionUpperName( NonConstOpCodeMapPtr xMap ) const;
14 diff --git formula/source/core/api/FormulaCompiler.cxx formula/source/core/api/FormulaCompiler.cxx
15 index d031c9a..5834e9e 100644
16 --- formula/source/core/api/FormulaCompiler.cxx
17 +++ formula/source/core/api/FormulaCompiler.cxx
18 @@ -1681,6 +1681,17 @@ void FormulaCompiler::AppendString( rtl::OUStringBuffer& rBuffer, const String &
19 rBuffer.append(sal_Unicode('"'));
23 +void FormulaCompiler::UpdateSeparatorsNative(
24 + const rtl::OUString& rSep, const rtl::OUString& rArrayColSep, const rtl::OUString& rArrayRowSep )
26 + NonConstOpCodeMapPtr xSymbolsNative;
27 + lcl_fillNativeSymbols(xSymbolsNative);
28 + xSymbolsNative->putOpCode(rSep, ocSep);
29 + xSymbolsNative->putOpCode(rArrayColSep, ocArrayColSep);
30 + xSymbolsNative->putOpCode(rArrayRowSep, ocArrayRowSep);
33 // -----------------------------------------------------------------------------
34 OpCode FormulaCompiler::NextToken()
36 diff --git sc/inc/docoptio.hxx sc/inc/docoptio.hxx
37 index 51a6405..bbd92e8 100644
38 --- sc/inc/docoptio.hxx
39 +++ sc/inc/docoptio.hxx
42 #include "optutil.hxx"
44 +#include "formula/grammar.hxx"
46 class SC_DLLPUBLIC ScDocOptions
48 double fIterEps; // Epsilon-Wert dazu
49 @@ -53,6 +55,11 @@ class SC_DLLPUBLIC ScDocOptions
50 BOOL bDoAutoSpell; // Auto-Spelling
51 BOOL bLookUpColRowNames; // Spalten-/Zeilenbeschriftungen automagisch suchen
52 BOOL bFormulaRegexEnabled; // regular expressions in formulas enabled
53 + ::formula::FormulaGrammar::Grammar eFormulaGrammar; // formula grammar used to switch different formula syntax
55 + ::rtl::OUString aFormulaSepArg;
56 + ::rtl::OUString aFormulaSepArrayRow;
57 + ::rtl::OUString aFormulaSepArrayCol;
61 @@ -99,6 +106,20 @@ public:
63 void SetFormulaRegexEnabled( BOOL bVal ) { bFormulaRegexEnabled = bVal; }
64 BOOL IsFormulaRegexEnabled() const { return bFormulaRegexEnabled; }
66 + void SetFormulaSyntax( ::formula::FormulaGrammar::Grammar eGram ) { eFormulaGrammar = eGram; }
67 + ::formula::FormulaGrammar::Grammar GetFormulaSyntax() const { return eFormulaGrammar; }
69 + void SetFormulaSepArg(const ::rtl::OUString& rSep) { aFormulaSepArg = rSep; }
70 + ::rtl::OUString GetFormulaSepArg() const { return aFormulaSepArg; }
72 + void SetFormulaSepArrayRow(const ::rtl::OUString& rSep) { aFormulaSepArrayRow = rSep; }
73 + ::rtl::OUString GetFormulaSepArrayRow() const { return aFormulaSepArrayRow; }
75 + void SetFormulaSepArrayCol(const ::rtl::OUString& rSep) { aFormulaSepArrayCol = rSep; }
76 + ::rtl::OUString GetFormulaSepArrayCol() const { return aFormulaSepArrayCol; }
78 + const LocaleDataWrapper& GetLocaleDataWrapper() const;
82 @@ -119,6 +140,10 @@ inline void ScDocOptions::CopyTo(ScDocOptions& rOpt)
83 rOpt.bDoAutoSpell = bDoAutoSpell;
84 rOpt.bLookUpColRowNames = bLookUpColRowNames;
85 rOpt.bFormulaRegexEnabled = bFormulaRegexEnabled;
86 + rOpt.eFormulaGrammar = eFormulaGrammar;
87 + rOpt.aFormulaSepArg = aFormulaSepArg;
88 + rOpt.aFormulaSepArrayRow = aFormulaSepArrayRow;
89 + rOpt.aFormulaSepArrayCol = aFormulaSepArrayCol;
92 inline const ScDocOptions& ScDocOptions::operator=( const ScDocOptions& rCpy )
93 @@ -138,6 +163,10 @@ inline const ScDocOptions& ScDocOptions::operator=( const ScDocOptions& rCpy )
94 bDoAutoSpell = rCpy.bDoAutoSpell;
95 bLookUpColRowNames = rCpy.bLookUpColRowNames;
96 bFormulaRegexEnabled= rCpy.bFormulaRegexEnabled;
97 + eFormulaGrammar = rCpy.eFormulaGrammar;
98 + aFormulaSepArg = rCpy.aFormulaSepArg;
99 + aFormulaSepArrayRow = rCpy.aFormulaSepArrayRow;
100 + aFormulaSepArrayCol = rCpy.aFormulaSepArrayCol;
104 @@ -160,6 +189,10 @@ inline int ScDocOptions::operator==( const ScDocOptions& rOpt ) const
105 && rOpt.bDoAutoSpell == bDoAutoSpell
106 && rOpt.bLookUpColRowNames == bLookUpColRowNames
107 && rOpt.bFormulaRegexEnabled == bFormulaRegexEnabled
108 + && rOpt.eFormulaGrammar == eFormulaGrammar
109 + && rOpt.aFormulaSepArg == aFormulaSepArg
110 + && rOpt.aFormulaSepArrayRow == aFormulaSepArrayRow
111 + && rOpt.aFormulaSepArrayCol == aFormulaSepArrayCol
115 @@ -199,12 +232,15 @@ private:
116 class ScDocCfg : public ScDocOptions
118 ScLinkConfigItem aCalcItem;
119 + ScLinkConfigItem aFormulaItem;
120 ScLinkConfigItem aLayoutItem;
122 DECL_LINK( CalcCommitHdl, void* );
123 + DECL_LINK( FormulaCommitHdl, void* );
124 DECL_LINK( LayoutCommitHdl, void* );
126 com::sun::star::uno::Sequence<rtl::OUString> GetCalcPropertyNames();
127 + com::sun::star::uno::Sequence<rtl::OUString> GetFormulaPropertyNames();
128 com::sun::star::uno::Sequence<rtl::OUString> GetLayoutPropertyNames();
131 diff --git sc/inc/sc.hrc sc/inc/sc.hrc
132 index 7301766..2eba0d8 100644
135 @@ -1660,5 +1660,9 @@
136 // Autoformat for DataPilot
137 #define SID_PIVOT_AFMT (SC_OOO_BUILD_START + 4)
139 +// Formula options page
140 +#define RID_SCPAGE_FORMULA (SC_OOO_BUILD_START + 5)
141 +#define HID_SCPAGE_FORMULA (SC_OOO_BUILD_START + 6)
145 diff --git sc/source/core/data/documen3.cxx sc/source/core/data/documen3.cxx
146 index ec6c46c..27f9d36 100644
147 --- sc/source/core/data/documen3.cxx
148 +++ sc/source/core/data/documen3.cxx
150 #include "rangelst.hxx"
151 #include "chartarr.hxx"
152 #include "chartlock.hxx"
153 +#include "compiler.hxx"
154 #include "refupdat.hxx"
155 #include "docoptio.hxx"
156 #include "viewopti.hxx"
157 @@ -1771,7 +1772,13 @@ void ScDocument::SetDocOptions( const ScDocOptions& rOpt )
159 rOpt.GetDate( d,m,y );
161 xPoolHelper->SetFormTableOpt(rOpt);
163 + SetGrammar( rOpt.GetFormulaSyntax() );
165 + // Update the separators.
166 + ScCompiler::UpdateSeparatorsNative(
167 + rOpt.GetFormulaSepArg(), rOpt.GetFormulaSepArrayCol(), rOpt.GetFormulaSepArrayRow());
170 const ScViewOptions& ScDocument::GetViewOptions() const
171 diff --git sc/source/core/tool/docoptio.cxx sc/source/core/tool/docoptio.cxx
172 index ffbb2d9..4338af6 100644
173 --- sc/source/core/tool/docoptio.cxx
174 +++ sc/source/core/tool/docoptio.cxx
177 #include <com/sun/star/uno/Any.hxx>
178 #include <com/sun/star/uno/Sequence.hxx>
179 +#include <com/sun/star/lang/Locale.hpp>
180 +#include <com/sun/star/i18n/LocaleDataItem.hpp>
182 #include "cfgids.hxx"
183 #include "docoptio.hxx"
185 #include "scresid.hxx"
187 #include "miscuno.hxx"
188 +#include "global.hxx"
192 using namespace com::sun::star::uno;
193 +using ::com::sun::star::lang::Locale;
194 +using ::com::sun::star::i18n::LocaleDataItem;
196 //------------------------------------------------------------------------
198 @@ -100,7 +105,11 @@ ScDocOptions::ScDocOptions( const ScDocOptions& rCpy )
199 bMatchWholeCell( rCpy.bMatchWholeCell ),
200 bDoAutoSpell( rCpy.bDoAutoSpell ),
201 bLookUpColRowNames( rCpy.bLookUpColRowNames ),
202 - bFormulaRegexEnabled( rCpy.bFormulaRegexEnabled )
203 + bFormulaRegexEnabled( rCpy.bFormulaRegexEnabled ),
204 + eFormulaGrammar( rCpy.eFormulaGrammar ),
205 + aFormulaSepArg( rCpy.aFormulaSepArg ),
206 + aFormulaSepArrayRow( rCpy.aFormulaSepArrayRow ),
207 + aFormulaSepArrayCol( rCpy.aFormulaSepArrayCol )
211 @@ -129,6 +138,67 @@ void ScDocOptions::ResetDocOptions()
212 bDoAutoSpell = FALSE;
213 bLookUpColRowNames = TRUE;
214 bFormulaRegexEnabled= TRUE;
215 + eFormulaGrammar = ::formula::FormulaGrammar::GRAM_NATIVE;
219 + const Locale& rLocale = *ScGlobal::GetLocale();
220 + const OUString& rLang = rLocale.Language;
221 + if (rLang.equalsAscii("ru"))
222 + // Don't do automatic guess for these languages, and fall back to
223 + // the old separator set.
226 + const LocaleDataWrapper& rLocaleData = GetLocaleDataWrapper();
227 + const OUString& rDecSep = rLocaleData.getNumDecimalSep();
228 + const OUString& rListSep = rLocaleData.getListSep();
230 + if (!rDecSep.getLength() || !rListSep.getLength())
231 + // Something is wrong. Stick with the default separators.
234 + sal_Unicode cDecSep = rDecSep.getStr()[0];
235 + sal_Unicode cListSep = rListSep.getStr()[0];
237 + // Excel by default uses system's list separator as the parameter
238 + // separator, which in English locales is a comma. However, OOo's list
239 + // separator value is set to ';' for all English locales. Because of this
240 + // discrepancy, we will hardcode the separator value here, for now.
241 + if (cDecSep == sal_Unicode('.'))
242 + cListSep = sal_Unicode(',');
244 + // Special case for de_CH locale.
245 + if (rLocale.Language.equalsAsciiL("de", 2) && rLocale.Country.equalsAsciiL("CH", 2))
246 + cListSep = sal_Unicode(';');
248 + // by default, the parameter separator equals the locale-specific
250 + aFormulaSepArg = OUString(cListSep);
252 + if (cDecSep == cListSep && cDecSep != sal_Unicode(';'))
253 + // if the decimal and list separators are equal, set the
254 + // parameter separator to be ';', unless they are both
255 + // semicolon in which case don't change the decimal separator.
256 + aFormulaSepArg = OUString::createFromAscii(";");
258 + aFormulaSepArrayCol = OUString::createFromAscii(",");
259 + if (cDecSep == sal_Unicode(','))
260 + aFormulaSepArrayCol = OUString::createFromAscii(".");
261 + aFormulaSepArrayRow = OUString::createFromAscii(";");
267 + // Defaults to the old separator values.
268 + aFormulaSepArg = OUString::createFromAscii(";");
269 + aFormulaSepArrayCol = OUString::createFromAscii(";");
270 + aFormulaSepArrayRow = OUString::createFromAscii("|");
273 +const LocaleDataWrapper& ScDocOptions::GetLocaleDataWrapper() const
275 + return *ScGlobal::pLocaleData;
278 //========================================================================
279 @@ -206,6 +276,13 @@ SfxPoolItem* __EXPORT ScTpCalcItem::Clone( SfxItemPool * ) const
280 #define SCCALCOPT_REGEX 11
281 #define SCCALCOPT_COUNT 12
283 +#define CFGPATH_FORMULA "Office.Calc/Formula"
284 +#define SCFORMULAOPT_GRAMMAR 0
285 +#define SCFORMULAOPT_SEP_ARG 1
286 +#define SCFORMULAOPT_SEP_ARRAY_ROW 2
287 +#define SCFORMULAOPT_SEP_ARRAY_COL 3
288 +#define SCFORMULAOPT_COUNT 4
290 #define CFGPATH_DOCLAYOUT "Office.Calc/Layout/Other"
292 #define SCDOCLAYOUTOPT_TABSTOP 0
293 @@ -227,7 +304,7 @@ Sequence<OUString> ScDocCfg::GetCalcPropertyNames()
294 "Other/Precision", // SCCALCOPT_PRECISION
295 "Other/SearchCriteria", // SCCALCOPT_SEARCHCRIT
296 "Other/FindLabel", // SCCALCOPT_FINDLABEL
297 - "Other/RegularExpressions" // SCCALCOPT_REGEX
298 + "Other/RegularExpressions", // SCCALCOPT_REGEX
300 Sequence<OUString> aNames(SCCALCOPT_COUNT);
301 OUString* pNames = aNames.getArray();
302 @@ -237,6 +314,23 @@ Sequence<OUString> ScDocCfg::GetCalcPropertyNames()
306 +Sequence<OUString> ScDocCfg::GetFormulaPropertyNames()
308 + static const char* aPropNames[] =
310 + "Syntax/Grammar", // SCFORMULAOPT_GRAMMAR
311 + "Syntax/SeparatorArg", // SCFORMULAOPT_SEP_ARG
312 + "Syntax/SeparatorArrayRow", // SCFORMULAOPT_SEP_ARRAY_ROW
313 + "Syntax/SeparatorArrayCol", // SCFORMULAOPT_SEP_ARRAY_COL
315 + Sequence<OUString> aNames(SCFORMULAOPT_COUNT);
316 + OUString* pNames = aNames.getArray();
317 + for (int i = 0; i < SCFORMULAOPT_COUNT; ++i)
318 + pNames[i] = OUString::createFromAscii(aPropNames[i]);
323 Sequence<OUString> ScDocCfg::GetLayoutPropertyNames()
325 static const char* aPropNames[] =
326 @@ -257,6 +351,7 @@ Sequence<OUString> ScDocCfg::GetLayoutPropertyNames()
328 ScDocCfg::ScDocCfg() :
329 aCalcItem( OUString::createFromAscii( CFGPATH_CALC ) ),
330 + aFormulaItem(OUString::createFromAscii(CFGPATH_FORMULA)),
331 aLayoutItem( OUString::createFromAscii( CFGPATH_DOCLAYOUT ) )
333 sal_Int32 nIntVal = 0;
334 @@ -328,6 +423,69 @@ ScDocCfg::ScDocCfg() :
336 SetDate( nDateDay, nDateMonth, nDateYear );
338 + aNames = GetFormulaPropertyNames();
339 + aValues = aFormulaItem.GetProperties(aNames);
340 + aFormulaItem.EnableNotification(aNames);
341 + pValues = aValues.getConstArray();
342 + if (aValues.getLength() == aNames.getLength())
344 + for (int nProp = 0; nProp < aNames.getLength(); ++nProp)
348 + case SCFORMULAOPT_GRAMMAR:
350 + ::formula::FormulaGrammar::Grammar eGram = ::formula::FormulaGrammar::GRAM_DEFAULT;
354 + if (!(pValues[nProp] >>= nIntVal))
355 + // extractino failed.
361 + eGram = ::formula::FormulaGrammar::GRAM_NATIVE;
363 + case 1: // Excel A1
364 + eGram = ::formula::FormulaGrammar::GRAM_NATIVE_XL_A1;
366 + case 2: // Excel R1C1
367 + eGram = ::formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1;
372 + SetFormulaSyntax(eGram);
375 + case SCFORMULAOPT_SEP_ARG:
378 + if ((pValues[nProp] >>= aSep) && aSep.getLength())
379 + SetFormulaSepArg(aSep);
382 + case SCFORMULAOPT_SEP_ARRAY_ROW:
385 + if ((pValues[nProp] >>= aSep) && aSep.getLength())
386 + SetFormulaSepArrayRow(aSep);
389 + case SCFORMULAOPT_SEP_ARRAY_COL:
392 + if ((pValues[nProp] >>= aSep) && aSep.getLength())
393 + SetFormulaSepArrayCol(aSep);
399 + aFormulaItem.SetCommitLink( LINK(this, ScDocCfg, FormulaCommitHdl) );
401 aNames = GetLayoutPropertyNames();
402 aValues = aLayoutItem.GetProperties(aNames);
403 aLayoutItem.EnableNotification(aNames);
404 @@ -410,6 +568,43 @@ IMPL_LINK( ScDocCfg, CalcCommitHdl, void *, EMPTYARG )
408 +IMPL_LINK( ScDocCfg, FormulaCommitHdl, void *, EMPTYARG )
410 + Sequence<OUString> aNames = GetFormulaPropertyNames();
411 + Sequence<Any> aValues(aNames.getLength());
412 + Any* pValues = aValues.getArray();
414 + for (int nProp = 0; nProp < aNames.getLength(); ++nProp)
418 + case SCFORMULAOPT_GRAMMAR :
420 + sal_Int32 nVal = 0;
421 + switch (GetFormulaSyntax())
423 + case ::formula::FormulaGrammar::GRAM_NATIVE_XL_A1: nVal = 1; break;
424 + case ::formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1: nVal = 2; break;
426 + pValues[nProp] <<= nVal;
429 + case SCFORMULAOPT_SEP_ARG:
430 + pValues[nProp] <<= GetFormulaSepArg();
432 + case SCFORMULAOPT_SEP_ARRAY_ROW:
433 + pValues[nProp] <<= GetFormulaSepArrayRow();
435 + case SCFORMULAOPT_SEP_ARRAY_COL:
436 + pValues[nProp] <<= GetFormulaSepArrayCol();
440 + aFormulaItem.PutProperties(aNames, aValues);
445 IMPL_LINK( ScDocCfg, LayoutCommitHdl, void *, EMPTYARG )
447 Sequence<OUString> aNames = GetLayoutPropertyNames();
448 @@ -439,6 +634,7 @@ void ScDocCfg::SetOptions( const ScDocOptions& rNew )
449 *(ScDocOptions*)this = rNew;
451 aCalcItem.SetModified();
452 + aFormulaItem.SetModified();
453 aLayoutItem.SetModified();
456 diff --git sc/source/ui/app/scmod.cxx sc/source/ui/app/scmod.cxx
457 index bc0a91f..2362c23 100644
458 --- sc/source/ui/app/scmod.cxx
459 +++ sc/source/ui/app/scmod.cxx
460 @@ -2134,6 +2134,13 @@ SfxTabPage* ScModule::CreateTabPage( USHORT nId, Window* pParent, const SfxItem
461 pRet = (*ScTpCalcOptionsCreate)(pParent, rSet);
464 + case SID_SC_TP_FORMULA:
466 + ::CreateTabPage ScTpFormulaOptionsCreate = pFact->GetTabPageCreatorFunc (RID_SCPAGE_FORMULA);
467 + if (ScTpFormulaOptionsCreate)
468 + pRet = (*ScTpFormulaOptionsCreate)(pParent, rSet);
471 case SID_SC_TP_CHANGES:
472 { //CHINA001 pRet = ScRedlineOptionsTabPage::Create(pParent, rSet);
473 ::CreateTabPage ScRedlineOptionsTabPageCreate = pFact->GetTabPageCreatorFunc( RID_SCPAGE_OPREDLINE );
474 diff --git sc/source/ui/attrdlg/scdlgfact.cxx sc/source/ui/attrdlg/scdlgfact.cxx
475 index de9b284..7e6e248 100644
476 --- sc/source/ui/attrdlg/scdlgfact.cxx
477 +++ sc/source/ui/attrdlg/scdlgfact.cxx
479 #include "tpstat.hxx" //add for ScDocStatPage
480 #include "tpusrlst.hxx" //add for ScTpUserLists
481 #include "tpview.hxx" //add for ScTpContentOptions
482 +#include "tpformula.hxx"
486 @@ -1432,6 +1433,8 @@ CreateTabPage ScAbstractDialogFactory_Impl::GetTabPageCreatorFunc( USHORT nId )
487 case RID_SCPAGE_CALC :
488 return ScTpCalcOptions::Create;
490 + case RID_SCPAGE_FORMULA:
491 + return ScTpFormulaOptions::Create;
492 case RID_SCPAGE_PRINT :
493 return ScTpPrintOptions::Create;
495 diff --git sc/source/ui/inc/optdlg.hrc sc/source/ui/inc/optdlg.hrc
496 index e834a11..aaeb33d 100644
497 --- sc/source/ui/inc/optdlg.hrc
498 +++ sc/source/ui/inc/optdlg.hrc
502 #define TP_CHANGES 14
503 +#define TP_FORMULA 15
506 #define BTN_ITERATE 1
508 #define CB_TEXTFMT 78
509 #define CB_REPLWARN 79
513 +#define FL_FORMULA_OPTIONS 80
514 +#define FT_FORMULA_SYNTAX 81
515 +#define LB_FORMULA_SYNTAX 82
516 +#define FL_FORMULA_SEPS 83
517 +#define FT_FORMULA_SEP_ARG 84
518 +#define ED_FORMULA_SEP_ARG 85
519 +#define FT_FORMULA_SEP_ARRAY_R 86
520 +#define ED_FORMULA_SEP_ARRAY_R 87
521 +#define FT_FORMULA_SEP_ARRAY_C 88
522 +#define ED_FORMULA_SEP_ARRAY_C 89
523 +#define BTN_FORMULA_SEP_RESET 90
524 diff --git sc/source/ui/inc/tpformula.hxx sc/source/ui/inc/tpformula.hxx
526 index 0000000..054655e
528 +++ sc/source/ui/inc/tpformula.hxx
530 +/*************************************************************************
532 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
534 + * Copyright 2008 by Sun Microsystems, Inc.
536 + * OpenOffice.org - a multi-platform office productivity suite
538 + * $RCSfile: tpcalc.hxx,v $
541 + * This file is part of OpenOffice.org.
543 + * OpenOffice.org is free software: you can redistribute it and/or modify
544 + * it under the terms of the GNU Lesser General Public License version 3
545 + * only, as published by the Free Software Foundation.
547 + * OpenOffice.org is distributed in the hope that it will be useful,
548 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
549 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
550 + * GNU Lesser General Public License version 3 for more details
551 + * (a copy is included in the LICENSE file that accompanied this code).
553 + * You should have received a copy of the GNU Lesser General Public License
554 + * version 3 along with OpenOffice.org. If not, see
555 + * <http://www.openoffice.org/license.html>
556 + * for a copy of the LGPLv3 License.
558 + ************************************************************************/
560 +#ifndef SC_TPFORMULA_HXX
561 +#define SC_TPFORMULA_HXX
563 +#include <sfx2/tabdlg.hxx>
564 +#include <vcl/fixed.hxx>
565 +#include <vcl/lstbox.hxx>
566 +#include <vcl/edit.hxx>
567 +#include <vcl/button.hxx>
575 +class ScTpFormulaOptions : public SfxTabPage
578 + static SfxTabPage* Create (Window* pParent, const SfxItemSet& rCoreSet);
580 +// static USHORT* GetRanges();
581 + virtual BOOL FillItemSet(SfxItemSet& rCoreSet);
582 + virtual void Reset( const SfxItemSet& rCoreSet );
583 + virtual int DeactivatePage(SfxItemSet* pSet = NULL);
586 + explicit ScTpFormulaOptions(Window* pParent, const SfxItemSet& rCoreSet);
587 + virtual ~ScTpFormulaOptions();
590 + void ResetSeparators();
591 + void OnFocusSeparatorInput(Edit* pEdit);
593 + bool IsValidSeparator(const ::rtl::OUString& rSep) const;
594 + bool IsValidSeparatorSet() const;
596 + DECL_LINK( ButtonHdl, PushButton* );
597 + DECL_LINK( SepModifyHdl, Edit* );
598 + DECL_LINK( SepEditOnFocusHdl, Edit* );
601 + FixedLine maFlFormulaOpt;
602 + FixedText maFtFormulaSyntax;
603 + ListBox maLbFormulaSyntax;
605 + FixedLine maFlFormulaSeps;
606 + FixedText maFtSepFuncArg;
607 + Edit maEdSepFuncArg;
608 + FixedText maFtSepArrayCol;
609 + Edit maEdSepArrayCol;
610 + FixedText maFtSepArrayRow;
611 + Edit maEdSepArrayRow;
612 + PushButton maBtnSepReset;
614 + ::std::auto_ptr<ScDocOptions> mpOldOptions;
615 + ::std::auto_ptr<ScDocOptions> mpNewOptions;
617 + /** Stores old separator value of currently focused separator edit box.
618 + This value is used to revert undesired value change. */
619 + ::rtl::OUString maOldSepValue;
621 + sal_Unicode mnDecSep;
626 diff --git sc/source/ui/optdlg/makefile.mk sc/source/ui/optdlg/makefile.mk
627 index e8a6d20..cb43db7 100644
628 --- sc/source/ui/optdlg/makefile.mk
629 +++ sc/source/ui/optdlg/makefile.mk
630 @@ -47,6 +47,7 @@ CXXFILES = \
638 @@ -54,6 +55,7 @@ SLOFILES = \
639 $(SLO)$/tpusrlst.obj \
642 + $(SLO)$/tpformula.obj \
643 $(SLO)$/tpprint.obj \
646 diff --git sc/source/ui/optdlg/tpformula.cxx sc/source/ui/optdlg/tpformula.cxx
648 index 0000000..a27d5a7
650 +++ sc/source/ui/optdlg/tpformula.cxx
652 +/*************************************************************************
654 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
656 + * Copyright 2008 by Sun Microsystems, Inc.
658 + * OpenOffice.org - a multi-platform office productivity suite
660 + * $RCSfile: tpcalc.hxx,v $
663 + * This file is part of OpenOffice.org.
665 + * OpenOffice.org is free software: you can redistribute it and/or modify
666 + * it under the terms of the GNU Lesser General Public License version 3
667 + * only, as published by the Free Software Foundation.
669 + * OpenOffice.org is distributed in the hope that it will be useful,
670 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
671 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
672 + * GNU Lesser General Public License version 3 for more details
673 + * (a copy is included in the LICENSE file that accompanied this code).
675 + * You should have received a copy of the GNU Lesser General Public License
676 + * version 3 along with OpenOffice.org. If not, see
677 + * <http://www.openoffice.org/license.html>
678 + * for a copy of the LGPLv3 License.
680 + ************************************************************************/
682 +// MARKER(update_precomp.py): autogen include statement, do not remove
683 +#include "precompiled_sc.hxx"
685 +#undef SC_DLLIMPLEMENTATION
689 +//------------------------------------------------------------------
691 +#include "tpformula.hxx"
692 +#include "optdlg.hrc"
693 +#include "scresid.hxx"
694 +#include "formula/grammar.hxx"
695 +#include "docoptio.hxx"
696 +#include "global.hxx"
698 +#include <unotools/localedatawrapper.hxx>
700 +#include <com/sun/star/lang/Locale.hpp>
701 +#include <com/sun/star/i18n/LocaleDataItem.hpp>
703 +using ::rtl::OUString;
704 +using ::com::sun::star::lang::Locale;
705 +using ::com::sun::star::i18n::LocaleDataItem;
707 +ScTpFormulaOptions::ScTpFormulaOptions(Window* pParent, const SfxItemSet& rCoreAttrs) :
708 + SfxTabPage(pParent, ScResId(RID_SCPAGE_FORMULA), rCoreAttrs),
710 + maFlFormulaOpt(this, ScResId(FL_FORMULA_OPTIONS)),
711 + maFtFormulaSyntax(this, ScResId(FT_FORMULA_SYNTAX)),
712 + maLbFormulaSyntax(this, ScResId(LB_FORMULA_SYNTAX)),
713 + maFlFormulaSeps(this, ScResId(FL_FORMULA_SEPS)),
714 + maFtSepFuncArg(this, ScResId(FT_FORMULA_SEP_ARG)),
715 + maEdSepFuncArg(this, ScResId(ED_FORMULA_SEP_ARG)),
716 + maFtSepArrayCol(this, ScResId(FT_FORMULA_SEP_ARRAY_C)),
717 + maEdSepArrayCol(this, ScResId(ED_FORMULA_SEP_ARRAY_C)),
718 + maFtSepArrayRow(this, ScResId(FT_FORMULA_SEP_ARRAY_R)),
719 + maEdSepArrayRow(this, ScResId(ED_FORMULA_SEP_ARRAY_R)),
720 + maBtnSepReset(this, ScResId(BTN_FORMULA_SEP_RESET)),
722 + mpOldOptions(NULL),
723 + mpNewOptions(NULL),
728 + const ScTpCalcItem& rItem = static_cast<const ScTpCalcItem&>(
729 + rCoreAttrs.Get(GetWhich(SID_SCDOCOPTIONS)));
730 + mpOldOptions.reset(new ScDocOptions(rItem.GetDocOptions()));
731 + mpNewOptions.reset(new ScDocOptions(rItem.GetDocOptions()));
736 +ScTpFormulaOptions::~ScTpFormulaOptions()
740 +void ScTpFormulaOptions::Init()
742 + Link aLink = LINK( this, ScTpFormulaOptions, ButtonHdl );
743 + maBtnSepReset.SetClickHdl(aLink);
745 + aLink = LINK( this, ScTpFormulaOptions, SepModifyHdl );
746 + maEdSepFuncArg.SetModifyHdl(aLink);
747 + maEdSepArrayCol.SetModifyHdl(aLink);
748 + maEdSepArrayRow.SetModifyHdl(aLink);
750 + aLink = LINK( this, ScTpFormulaOptions, SepEditOnFocusHdl );
751 + maEdSepFuncArg.SetGetFocusHdl(aLink);
752 + maEdSepArrayCol.SetGetFocusHdl(aLink);
753 + maEdSepArrayRow.SetGetFocusHdl(aLink);
755 + // Get the decimal separator for current locale.
756 + String aSep = mpOldOptions->GetLocaleDataWrapper().getNumDecimalSep();
757 + mnDecSep = aSep.Len() ? aSep.GetChar(0) : sal_Unicode('.');
760 +void ScTpFormulaOptions::ResetSeparators()
763 + maEdSepFuncArg.SetText(aOpt.GetFormulaSepArg());
764 + maEdSepArrayCol.SetText(aOpt.GetFormulaSepArrayCol());
765 + maEdSepArrayRow.SetText(aOpt.GetFormulaSepArrayRow());
768 +void ScTpFormulaOptions::OnFocusSeparatorInput(Edit* pEdit)
773 + // Make sure the entire text is selected.
774 + xub_StrLen nLen = pEdit->GetText().Len();
775 + Selection aSel(0, nLen);
776 + pEdit->SetSelection(aSel);
777 + maOldSepValue = pEdit->GetText();
780 +bool ScTpFormulaOptions::IsValidSeparator(const OUString& rSep) const
782 + if (rSep.getLength() != 1)
783 + // Must be one-character long.
786 + if (rSep.compareToAscii("a") >= 0 && rSep.compareToAscii("z") <= 0)
789 + if (rSep.compareToAscii("A") >= 0 && rSep.compareToAscii("Z") <= 0)
792 + sal_Unicode c = rSep.getStr()[0];
807 + // Disallowed characters. Anything else we want to disallow ?
812 + // decimal separator is not allowed.
818 +bool ScTpFormulaOptions::IsValidSeparatorSet() const
820 + // Make sure the column and row separators are different.
821 + String aColStr = maEdSepArrayCol.GetText();
822 + String aRowStr = maEdSepArrayRow.GetText();
823 + if (aColStr == aRowStr)
829 +IMPL_LINK( ScTpFormulaOptions, ButtonHdl, PushButton*, pBtn )
831 + if (pBtn == &maBtnSepReset)
837 +IMPL_LINK( ScTpFormulaOptions, SepModifyHdl, Edit*, pEdit )
842 + String aStr = pEdit->GetText();
843 + if (aStr.Len() > 1)
845 + // In case the string is more than one character long, only grab the
846 + // first character.
847 + aStr = aStr.Copy(0, 1);
848 + pEdit->SetText(aStr);
851 + if ((!IsValidSeparator(aStr) || !IsValidSeparatorSet()) && maOldSepValue.getLength())
852 + // Invalid separator. Restore the old value.
853 + pEdit->SetText(maOldSepValue);
855 + OnFocusSeparatorInput(pEdit);
859 +IMPL_LINK( ScTpFormulaOptions, SepEditOnFocusHdl, Edit*, pEdit )
861 + OnFocusSeparatorInput(pEdit);
866 +SfxTabPage* ScTpFormulaOptions::Create(Window* pParent, const SfxItemSet& rCoreSet)
868 + return new ScTpFormulaOptions(pParent, rCoreSet);
871 +BOOL ScTpFormulaOptions::FillItemSet(SfxItemSet& rCoreSet)
873 + ::formula::FormulaGrammar::Grammar eGram = ::formula::FormulaGrammar::GRAM_DEFAULT;
874 + switch (maLbFormulaSyntax.GetSelectEntryPos())
877 + eGram = ::formula::FormulaGrammar::GRAM_NATIVE;
880 + eGram = ::formula::FormulaGrammar::GRAM_NATIVE_XL_A1;
883 + eGram = ::formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1;
887 + mpNewOptions->SetFormulaSyntax(eGram);
889 + mpNewOptions->SetFormulaSepArg(maEdSepFuncArg.GetText());
890 + mpNewOptions->SetFormulaSepArrayCol(maEdSepArrayCol.GetText());
891 + mpNewOptions->SetFormulaSepArrayRow(maEdSepArrayRow.GetText());
893 + if (*mpNewOptions != *mpOldOptions)
895 + rCoreSet.Put(ScTpCalcItem(GetWhich(SID_SCDOCOPTIONS), *mpNewOptions));
902 +void ScTpFormulaOptions::Reset(const SfxItemSet& /*rCoreSet*/)
904 + ::formula::FormulaGrammar::Grammar eGram = mpNewOptions->GetFormulaSyntax();
907 + case ::formula::FormulaGrammar::GRAM_NATIVE:
908 + maLbFormulaSyntax.SelectEntryPos(0);
910 + case ::formula::FormulaGrammar::GRAM_NATIVE_XL_A1:
911 + maLbFormulaSyntax.SelectEntryPos(1);
913 + case ::formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1:
914 + maLbFormulaSyntax.SelectEntryPos(2);
917 + maLbFormulaSyntax.SelectEntryPos(0);
920 + OUString aSep = mpNewOptions->GetFormulaSepArg();
921 + OUString aSepArrayRow = mpNewOptions->GetFormulaSepArrayRow();
922 + OUString aSepArrayCol = mpNewOptions->GetFormulaSepArrayCol();
924 + if (aSep.getLength() == 1 && aSepArrayRow.getLength() == 1 && aSepArrayCol.getLength() == 1)
926 + // Each separator must be one character long.
927 + maEdSepFuncArg.SetText(aSep);
928 + maEdSepArrayCol.SetText(aSepArrayCol);
929 + maEdSepArrayRow.SetText(aSepArrayRow);
935 +int ScTpFormulaOptions::DeactivatePage(SfxItemSet* /*pSet*/)
937 + // What's this method for ?
941 diff --git sc/source/ui/src/optdlg.src sc/source/ui/src/optdlg.src
942 index 82a1161..2ea00b8 100644
943 --- sc/source/ui/src/optdlg.src
944 +++ sc/source/ui/src/optdlg.src
945 @@ -176,6 +176,105 @@ TabPage RID_SCPAGE_CALC
947 /**************************************************************************/
949 +TabPage RID_SCPAGE_FORMULA
951 + HelpId = HID_SCPAGE_FORMULA ;
954 + Pos = MAP_APPFONT ( 0 , 0 ) ;
955 + Size = MAP_APPFONT ( 260 , 185 ) ;
957 + FixedLine FL_FORMULA_OPTIONS
959 + Pos = MAP_APPFONT ( 6 , 3 ) ;
960 + Size = MAP_APPFONT ( 248 , 8 ) ;
961 + Text [ en-US ] = "Formula options";
964 + FixedText FT_FORMULA_SYNTAX
966 + Pos = MAP_APPFONT ( 21, 16 ) ;
967 + Size = MAP_APPFONT ( 80, 8 ) ;
968 + Text [ en-US ] = "Formula ~syntax" ;
971 + ListBox LB_FORMULA_SYNTAX
974 + Pos = MAP_APPFONT ( 85, 14 ) ;
975 + Size = MAP_APPFONT ( 60, 46 ) ;
977 + StringList [ en-US ] =
979 + < "Calc A1" ; Default ; > ;
980 + < "Excel A1" ; Default ; > ;
981 + < "Excel R1C1" ; Default ; > ;
985 + FixedLine FL_FORMULA_SEPS
987 + Pos = MAP_APPFONT ( 6 , 32 ) ;
988 + Size = MAP_APPFONT ( 248 , 8 ) ;
989 + Text [ en-US ] = "Separators";
992 + FixedText FT_FORMULA_SEP_ARG
994 + Pos = MAP_APPFONT ( 21, 45 );
995 + Size = MAP_APPFONT ( 40, 8 );
996 + Text [ en-US ] = "~Function";
999 + Edit ED_FORMULA_SEP_ARG
1002 + Pos = MAP_APPFONT ( 65, 43 );
1003 + Size = MAP_APPFONT ( 10, 12 );
1006 + FixedText FT_FORMULA_SEP_ARRAY_C
1008 + Pos = MAP_APPFONT ( 21, 63 );
1009 + Size = MAP_APPFONT ( 40, 8 );
1010 + Text [ en-US ] = "Array co~lumn";
1013 + Edit ED_FORMULA_SEP_ARRAY_C
1016 + Pos = MAP_APPFONT ( 65, 61 );
1017 + Size = MAP_APPFONT ( 10, 12 );
1020 + FixedText FT_FORMULA_SEP_ARRAY_R
1022 + Pos = MAP_APPFONT ( 21, 81 );
1023 + Size = MAP_APPFONT ( 40, 8 );
1024 + Text [ en-US ] = "Array ~row";
1027 + Edit ED_FORMULA_SEP_ARRAY_R
1030 + Pos = MAP_APPFONT ( 65, 79 );
1031 + Size = MAP_APPFONT ( 10, 12 );
1034 + PushButton BTN_FORMULA_SEP_RESET
1036 + Pos = MAP_APPFONT ( 21, 99 );
1037 + Size = MAP_APPFONT ( 40, 14 );
1038 + Text [ en-US ] = "Rese~t";
1042 +/**************************************************************************/
1046 +/**************************************************************************/
1048 TabPage RID_SCPAGE_USERLISTS
1050 HelpId = HID_SCPAGE_USERLISTS ;