ooo-build r14840 - in trunk: . patches/dev300



Author: kyoshida
Date: Fri Dec 12 20:33:01 2008
New Revision: 14840
URL: http://svn.gnome.org/viewvc/ooo-build?rev=14840&view=rev

Log:
2008-12-12  Kohei Yoshida  <kyoshida novell com>
	
	* patches/dev300/sc-formula-syntax-ui.diff: removed, as combined with 
	the patches below.

	* patches/dev300/calc-formula-variable-separators-officecfg.diff:
	* patches/dev300/calc-formula-variable-separators-svx.diff: added to 
	insert a new tab page in the Options dialog for formula options. 
	(i#92056, n#447164)
	
	* patches/dev300/calc-formula-variable-separators-sc.diff: implemented 
	the Formula option tab page for formula grammar and separator 
	configurations. (i#92056, n#447164)
	
	* patches/dev300/apply: added/removed patches.




Added:
   trunk/patches/dev300/calc-formula-variable-separators-officecfg.diff
   trunk/patches/dev300/calc-formula-variable-separators-svx.diff
Removed:
   trunk/patches/dev300/sc-formula-syntax-ui.diff
Modified:
   trunk/ChangeLog
   trunk/patches/dev300/apply
   trunk/patches/dev300/calc-formula-variable-separators-sc.diff

Modified: trunk/patches/dev300/apply
==============================================================================
--- trunk/patches/dev300/apply	(original)
+++ trunk/patches/dev300/apply	Fri Dec 12 20:33:01 2008
@@ -1788,11 +1788,6 @@
 
 [ CalcFixes ]
 
-# Support several different formula syntax, and add a formula syntax
-# configuration option in the Options page.
-
-sc-formula-syntax-ui.diff, n#358558, i#72191, kohei
-
 # Toggle gridline display per sheet.
 sc-sheet-gridline-toggle.diff, i#14893, kohei
 
@@ -1800,8 +1795,11 @@
 # navigating through cells.
 sc-skip-overlapped-cells.diff, i#86943, n#362674, kohei
 
-# Make the formula separators changeable per locale setting.
-calc-formula-variable-separators-sc.diff, i#92056, kohei
+# Make the formula separators changeable per locale setting, and add new 
+# configuration page for formula syntax and separators.
+calc-formula-variable-separators-sc.diff,        n#447164, i#92056, kohei
+calc-formula-variable-separators-svx.diff,       n#447164, i#92056, kohei
+calc-formula-variable-separators-officecfg.diff, n#447164, i#92056, kohei
 
 # Fix parse failure on non-ASCII sheet names in Excel A1 and R1C1 modes.
 calc-xls-parser-sheet-name-fix-sc.diff, n#407807, i#92379, kohei

Added: trunk/patches/dev300/calc-formula-variable-separators-officecfg.diff
==============================================================================
--- (empty file)
+++ trunk/patches/dev300/calc-formula-variable-separators-officecfg.diff	Fri Dec 12 20:33:01 2008
@@ -0,0 +1,69 @@
+diff --git officecfg/registry/schema/org/openoffice/Office/Calc.xcs officecfg/registry/schema/org/openoffice/Office/Calc.xcs
+index 8f02c5f..e6e2ec6 100644
+--- officecfg/registry/schema/org/openoffice/Office/Calc.xcs
++++ officecfg/registry/schema/org/openoffice/Office/Calc.xcs
+@@ -1202,6 +1202,64 @@
+ 				</node-ref>
+ 			</group>
+ 		</group>
++		<group oor:name="Formula">
++			<info>
++				<desc>Contains settings that affect formula handling.</desc>
++			</info>
++			<group oor:name="Syntax">
++				<info>
++					<desc>Contains settings for formula syntax.</desc>
++				</info>
++				<prop oor:name="Grammar" oor:type="xs:int">
++					<!-- UIHints: Tools - Options  Spreadsheet  Formula -->
++					<info>
++						<author>kyoshida</author>
++						<desc>Specifies what formula syntax type to use.</desc>
++					</info>
++					<constraints>
++						<enumeration oor:value="0">
++							<info>
++								<desc>Calc A1</desc>
++							</info>
++						</enumeration>
++						<enumeration oor:value="1">
++							<info>
++								<desc>Excel A1</desc>
++							</info>
++						</enumeration>
++						<enumeration oor:value="2">
++							<info>
++								<desc>Excel R1C1</desc>
++							</info>
++						</enumeration>
++					</constraints>
++				</prop>
++				<prop oor:name="SeparatorArg" oor:type="xs:string">
++					<!-- UIHints: Tools - Options  Spreadsheet  Formula -->
++					<info>
++						<author>kyoshida</author>
++						<desc>Argument separator in worksheet function</desc>
++					</info>
++					<value></value>
++				</prop>
++				<prop oor:name="SeparatorArrayRow" oor:type="xs:string">
++					<!-- UIHints: Tools - Options  Spreadsheet  Formula -->
++					<info>
++						<author>kyoshida</author>
++						<desc>Row separator in array constant</desc>
++					</info>
++					<value></value>
++				</prop>
++				<prop oor:name="SeparatorArrayCol" oor:type="xs:string">
++					<!-- UIHints: Tools - Options  Spreadsheet  Formula -->
++					<info>
++						<author>kyoshida</author>
++						<desc>Column separator in array constant</desc>
++					</info>
++					<value></value>
++				</prop>
++			</group>
++		</group>
+ 		<group oor:name="Revision">
+ 			<info>
+ 				<desc>Contains settings that affect revision marking.</desc>

Modified: trunk/patches/dev300/calc-formula-variable-separators-sc.diff
==============================================================================
--- trunk/patches/dev300/calc-formula-variable-separators-sc.diff	(original)
+++ trunk/patches/dev300/calc-formula-variable-separators-sc.diff	Fri Dec 12 20:33:01 2008
@@ -1,9 +1,9 @@
 diff --git sc/inc/compiler.hxx sc/inc/compiler.hxx
-index 33dbde0..2d816d1 100644
+index a4d5d16..333d4e2 100644
 --- sc/inc/compiler.hxx
 +++ sc/inc/compiler.hxx
-@@ -418,7 +418,7 @@ private:
-     ScGrammar::Grammar  meGrammar;          // The grammar used, language plus convention.
+@@ -457,7 +457,7 @@ private:
+     bool        mbExtendedErrorDetection;
  
      BOOL   GetToken();
 -    BOOL   NextNewToken(bool bAllowBooleans = false);
@@ -11,7 +11,7 @@
      OpCode NextToken();
      void PutCode( ScTokenRef& );
      void Factor();
-@@ -436,9 +436,9 @@ private:
+@@ -475,9 +475,9 @@ private:
      OpCode Expression();
  
      void SetError(USHORT nError);
@@ -23,184 +23,171 @@
      BOOL IsOpCode2( const String& );
      BOOL IsString();
      BOOL IsReference( const String& );
-diff --git sc/source/core/tool/compiler.cxx sc/source/core/tool/compiler.cxx
-index a47a64f..084f533 100644
---- sc/source/core/tool/compiler.cxx
-+++ sc/source/core/tool/compiler.cxx
-@@ -42,6 +42,7 @@
- #include <tools/rc.hxx>
- #include <tools/solar.h>
- #include <unotools/charclass.hxx>
-+#include <com/sun/star/i18n/LocaleDataItem.hpp>
- #include <com/sun/star/lang/Locale.hpp>
- #include <com/sun/star/sheet/FormulaOpCodeMapEntry.hpp>
- #include <com/sun/star/sheet/FormulaLanguage.hpp>
-@@ -219,16 +220,16 @@ private:
-     void putDefaultOpCode( ScCompiler::NonConstOpCodeMapPtr xMap, USHORT nOp );
- 
+@@ -517,6 +517,8 @@ public:
+     }
+     static void InitSymbolsNative();    /// only SymbolsNative, on first document creation
+     static void InitSymbolsEnglish();   /// only SymbolsEnglish, maybe later
++
++    static void UpdateSeparatorsNative( const String& rSep, const String& rArrayColSep, const String& rArrayRowSep );
  private:
--    enum SeparatorType
--    {
--        SEMICOLON_BASE,
--        COMMA_BASE
--    };
--    SeparatorType meSepType;
-+    sal_Unicode mcParamSep;
-+    sal_Unicode mcArrayRowSep;
-+    sal_Unicode mcArrayColSep;
- };
+     static void InitSymbolsPODF();      /// only SymbolsPODF, on demand
+     static void InitSymbolsODFF();      /// only SymbolsODFF, on demand
+diff --git sc/inc/docoptio.hxx sc/inc/docoptio.hxx
+index 51a6405..bbd92e8 100644
+--- sc/inc/docoptio.hxx
++++ sc/inc/docoptio.hxx
+@@ -36,6 +36,8 @@
+ #include "scdllapi.h"
+ #include "optutil.hxx"
  
- ScOpCodeList::ScOpCodeList( USHORT nRID, ScCompiler::NonConstOpCodeMapPtr xMap ) :
--    Resource( ScResId(nRID) )
-+    Resource( ScResId(nRID) ),
-+    mcParamSep(sal_Unicode(';')),
-+    mcArrayRowSep(sal_Unicode('|')),
-+    mcArrayColSep(sal_Unicode(';'))
- {
-     init(xMap->getGrammar());
- 
-@@ -244,21 +245,69 @@ ScOpCodeList::ScOpCodeList( USHORT nRID, ScCompiler::NonConstOpCodeMapPtr xMap )
-     FreeResource();
- }
- 
--void ScOpCodeList::init( ScGrammar::Grammar /*eGrammar*/ )
-+void ScOpCodeList::init( ScGrammar::Grammar eGrammar )
- {
-     using namespace ::com::sun::star::sheet;
- 
--    meSepType = SEMICOLON_BASE;
--#if 0
--    if (ScGrammar::extractFormulaLanguage(eGrammar) == FormulaLanguage::NATIVE)
--    {
--        // Use localized separators.
--        const lang::Locale& rLocale = *ScGlobal::pLocale;
--        if (rLocale.Language.equalsAscii("en"))
--            meSepType = COMMA_BASE;
-+    if (eGrammar == ScGrammar::GRAM_NATIVE || 
-+        ScGrammar::extractFormulaLanguage(eGrammar) != FormulaLanguage::NATIVE)
-+        return;
++#include "grammar.hxx"
++
+ class SC_DLLPUBLIC ScDocOptions
+ {
+ 	double fIterEps;				// Epsilon-Wert dazu
+@@ -53,6 +55,11 @@ class SC_DLLPUBLIC ScDocOptions
+ 	BOOL   bDoAutoSpell;			// Auto-Spelling
+ 	BOOL   bLookUpColRowNames;		// Spalten-/Zeilenbeschriftungen automagisch suchen
+     BOOL   bFormulaRegexEnabled;    // regular expressions in formulas enabled
++    ScGrammar::Grammar eFormulaGrammar;  // formula grammar used to switch different formula syntax
++
++    ::rtl::OUString aFormulaSepArg;
++    ::rtl::OUString aFormulaSepArrayRow;
++    ::rtl::OUString aFormulaSepArrayCol;
  
--        // TODO: Check for more locales.
--    }
-+    if (!ScGlobal::pLocaleData || !ScGlobal::pLocale)
-+        return;
+ public:
+ 				ScDocOptions();
+@@ -99,6 +106,20 @@ public:
+ 
+     void    SetFormulaRegexEnabled( BOOL bVal ) { bFormulaRegexEnabled = bVal; }
+     BOOL    IsFormulaRegexEnabled() const       { return bFormulaRegexEnabled; }
 +
-+    const LocaleDataWrapper& rLocaleData = *ScGlobal::pLocaleData;
-+    const lang::Locale& rLocale = *ScGlobal::pLocale;
-+    const i18n::LocaleDataItem& aItem = rLocaleData.getLocaleItem();
-+    const String& rDecSep  = rLocaleData.getNumDecimalSep();
-+    const String& rListSep = rLocaleData.getListSep();
-+    if (rListSep.Len() != 1 || rDecSep.Len() != 1)
-+        // Something is wrong.  Stick with the default separators.
-+        return;
++    void SetFormulaSyntax( ScGrammar::Grammar eGram ) { eFormulaGrammar = eGram; }
++    ScGrammar::Grammar GetFormulaSyntax() const { return eFormulaGrammar; }
 +
-+    sal_Unicode cDecSep  = rDecSep.GetChar(0);
-+    sal_Unicode cListSep = rListSep.GetChar(0);
++    void SetFormulaSepArg(const ::rtl::OUString& rSep) { aFormulaSepArg = rSep; }
++    ::rtl::OUString GetFormulaSepArg() const { return aFormulaSepArg; }
 +
-+    // TODO: Excel by default uses system's list separator as the parameter 
-+    // separator, which in English locales is a comma.  However, OOo's list
-+    // separator value is set to ';' for all English locales.  Because of this
-+    // discrepancy, we will hardcode the separator value here, for now.
-+    if (cDecSep == sal_Unicode('.'))
-+        cListSep = sal_Unicode(',');
-+
-+    // Special case for de_CH locale.
-+    if (rLocale.Language.equalsAsciiL("de", 2) && rLocale.Country.equalsAsciiL("CH", 2))
-+        cListSep = sal_Unicode(';');
-+
-+    // by default, the parameter separator equals the locale-specific
-+    // list separator.
-+    mcParamSep = cListSep;
-+
-+    if (cDecSep == cListSep && cDecSep != sal_Unicode(';'))
-+        // if the decimal and list separators are equal, set the
-+        // parameter separator to be ';', unless they are both
-+        // semicolon in which case don't change the decimal separator.
-+        mcParamSep = sal_Unicode(';');
-+
-+    mcArrayColSep = sal_Unicode(',');
-+    if (cDecSep == sal_Unicode(','))
-+        mcArrayColSep = sal_Unicode('.');
-+    mcArrayRowSep = sal_Unicode(';');
-+
-+    // TODO: Excel also has its own internal decimal separator which may 
-+    // be different from the system's, and if one of the array separators
-+    // equals this internal value, Excel changes it to a backslash '/'.
-+    // I don't think we have to go that far to emulate that odd behavior,
-+    // so for now we just stop here.
-+#if 0
-+    fprintf(stdout, "ScOpCodeList::init:   language = '%s'; country = '%s'\n", 
-+            rtl::OUStringToOString(rLocale.Language, RTL_TEXTENCODING_UTF8).getStr(),
-+            rtl::OUStringToOString(rLocale.Country, RTL_TEXTENCODING_UTF8).getStr());
-+    
-+    fprintf(stdout, "ScOpCodeList::init:   arg sep = '%s'; array col sep = '%s'; array row sep = '%s'\n",
-+            rtl::OUStringToOString(String(mcParamSep), RTL_TEXTENCODING_UTF8).getStr(),
-+            rtl::OUStringToOString(String(mcArrayColSep), RTL_TEXTENCODING_UTF8).getStr(),
-+            rtl::OUStringToOString(String(mcArrayRowSep), RTL_TEXTENCODING_UTF8).getStr());
- #endif
++    void SetFormulaSepArrayRow(const ::rtl::OUString& rSep) { aFormulaSepArrayRow = rSep; }
++    ::rtl::OUString GetFormulaSepArrayRow() const { return aFormulaSepArrayRow; }
++
++    void SetFormulaSepArrayCol(const ::rtl::OUString& rSep) { aFormulaSepArrayCol = rSep; }
++    ::rtl::OUString GetFormulaSepArrayCol() const { return aFormulaSepArrayCol; }
++
++    const LocaleDataWrapper& GetLocaleDataWrapper() const;
+ };
+ 
+ 
+@@ -119,6 +140,10 @@ inline void ScDocOptions::CopyTo(ScDocOptions& rOpt)
+ 	rOpt.bDoAutoSpell			= bDoAutoSpell;
+ 	rOpt.bLookUpColRowNames		= bLookUpColRowNames;
+     rOpt.bFormulaRegexEnabled   = bFormulaRegexEnabled;
++    rOpt.eFormulaGrammar        = eFormulaGrammar;
++    rOpt.aFormulaSepArg         = aFormulaSepArg;
++    rOpt.aFormulaSepArrayRow    = aFormulaSepArrayRow;
++    rOpt.aFormulaSepArrayCol    = aFormulaSepArrayCol;
+ }
+ 
+ inline const ScDocOptions& ScDocOptions::operator=( const ScDocOptions& rCpy )
+@@ -138,6 +163,10 @@ inline const ScDocOptions& ScDocOptions::operator=( const ScDocOptions& rCpy )
+ 	bDoAutoSpell		= rCpy.bDoAutoSpell;
+ 	bLookUpColRowNames	= rCpy.bLookUpColRowNames;
+     bFormulaRegexEnabled= rCpy.bFormulaRegexEnabled;
++    eFormulaGrammar     = rCpy.eFormulaGrammar;
++    aFormulaSepArg      = rCpy.aFormulaSepArg;
++    aFormulaSepArrayRow = rCpy.aFormulaSepArrayRow;
++    aFormulaSepArrayCol = rCpy.aFormulaSepArrayCol;
+ 
+ 	return *this;
+ }
+@@ -160,6 +189,10 @@ inline int ScDocOptions::operator==( const ScDocOptions& rOpt ) const
+ 			&&	rOpt.bDoAutoSpell			== bDoAutoSpell
+ 			&&	rOpt.bLookUpColRowNames		== bLookUpColRowNames
+             &&  rOpt.bFormulaRegexEnabled   == bFormulaRegexEnabled
++            &&  rOpt.eFormulaGrammar        == eFormulaGrammar
++            &&  rOpt.aFormulaSepArg         == aFormulaSepArg
++            &&  rOpt.aFormulaSepArrayRow    == aFormulaSepArrayRow
++            &&  rOpt.aFormulaSepArrayCol    == aFormulaSepArrayCol
+ 			);
  }
  
-@@ -266,50 +315,16 @@ bool ScOpCodeList::getOpCodeString( String& rStr, USHORT nOp )
+@@ -199,12 +232,15 @@ private:
+ class ScDocCfg : public ScDocOptions
  {
-     switch (nOp)
-     {
--        case SC_OPCODE_SEP:
--        {
--            if (meSepType == COMMA_BASE)
--            {
--                rStr = String::CreateFromAscii(",");
--                return true;
--            }
--            else if (meSepType == SEMICOLON_BASE)
--            {
--                rStr = String::CreateFromAscii(";");
--                return true;
--            }
--        }
--        break;
--        case SC_OPCODE_ARRAY_COL_SEP:
--        {
--            if (meSepType == COMMA_BASE)
--            {
--                rStr = String::CreateFromAscii(",");
--                return true;
--            }
--            else if (meSepType == SEMICOLON_BASE)
--            {
--                rStr = String::CreateFromAscii(";");
--                return true;
--            }
--        }
--        break;
--        case SC_OPCODE_ARRAY_ROW_SEP:
--        {
--            if (meSepType == COMMA_BASE)
--            {
--                rStr = String::CreateFromAscii(";");
--                return true;
--            }
--            else if (meSepType == SEMICOLON_BASE)
--            {
--                rStr = String::CreateFromAscii("|");
--                return true;
--            }
--        }
--        break;
-+        case SC_OPCODE_SEP:   
-+            rStr = mcParamSep;        
-+            return true;
-+        case SC_OPCODE_ARRAY_ROW_SEP: 
-+            rStr = mcArrayRowSep;
-+            return true;
-+        case SC_OPCODE_ARRAY_COL_SEP: 
-+            rStr = mcArrayColSep;
-+            return true;
-     }
+ 	ScLinkConfigItem	aCalcItem;
++    ScLinkConfigItem    aFormulaItem;
+ 	ScLinkConfigItem	aLayoutItem;
+ 
+ 	DECL_LINK( CalcCommitHdl, void* );
++    DECL_LINK( FormulaCommitHdl, void* );
+ 	DECL_LINK( LayoutCommitHdl, void* );
+ 
+ 	com::sun::star::uno::Sequence<rtl::OUString> GetCalcPropertyNames();
++	com::sun::star::uno::Sequence<rtl::OUString> GetFormulaPropertyNames();
+ 	com::sun::star::uno::Sequence<rtl::OUString> GetLayoutPropertyNames();
+ 
+ public:
+diff --git sc/inc/sc.hrc sc/inc/sc.hrc
+index 3260a26..d17a59c 100644
+--- sc/inc/sc.hrc
++++ sc/inc/sc.hrc
+@@ -1658,7 +1658,9 @@
+ // Autoformat for DataPilot
+ #define SID_PIVOT_AFMT              (SC_OOO_BUILD_START + 4)
+ 
 -
-     return false;
++// Formula options page
++#define RID_SCPAGE_FORMULA          (SC_OOO_BUILD_START + 5)
++#define HID_SCPAGE_FORMULA          (SC_OOO_BUILD_START + 6)
+ 
+ #endif
+ 
+diff --git sc/source/core/data/documen3.cxx sc/source/core/data/documen3.cxx
+index 484ed97..c092c9c 100644
+--- sc/source/core/data/documen3.cxx
++++ sc/source/core/data/documen3.cxx
+@@ -54,6 +54,7 @@
+ #include "rangelst.hxx"
+ #include "chartarr.hxx"
+ #include "chartlock.hxx"
++#include "compiler.hxx"
+ #include "refupdat.hxx"
+ #include "docoptio.hxx"
+ #include "viewopti.hxx"
+@@ -1808,6 +1809,11 @@ void ScDocument::SetDocOptions( const ScDocOptions& rOpt )
+ 	pFormatter->ChangeNullDate( d,m,y );
+ 	pFormatter->ChangeStandardPrec( (USHORT)rOpt.GetStdPrecision() );
+ 	pFormatter->SetYear2000( rOpt.GetYear2000() );
++    SetGrammar( rOpt.GetFormulaSyntax() );
++
++    // Update the separators.
++    ScCompiler::UpdateSeparatorsNative(
++        rOpt.GetFormulaSepArg(), rOpt.GetFormulaSepArrayCol(), rOpt.GetFormulaSepArrayRow());
+ }
+ 
+ const ScViewOptions& ScDocument::GetViewOptions() const
+diff --git sc/source/core/tool/compiler.cxx sc/source/core/tool/compiler.cxx
+index 44cd1b8..b552a85 100644
+--- sc/source/core/tool/compiler.cxx
++++ sc/source/core/tool/compiler.cxx
+@@ -428,6 +428,16 @@ void ScCompiler::InitSymbolsEnglish()
  }
  
-@@ -1881,7 +1896,7 @@ sal_Unicode* lcl_UnicodeStrNCpy( sal_Unicode* pDst, const sal_Unicode* pSrc, xub
+ // static
++void ScCompiler::UpdateSeparatorsNative( 
++    const String& rSep, const String& rArrayColSep, const String& rArrayRowSep )
++{
++    InitSymbolsNative();
++    mxSymbolsNative->putOpCode(rSep, ocSep);
++    mxSymbolsNative->putOpCode(rArrayColSep, ocArrayColSep);
++    mxSymbolsNative->putOpCode(rArrayRowSep, ocArrayRowSep);
++}
++
++// static
+ void ScCompiler::InitSymbolsPODF()
+ {
+     if (mxSymbolsPODF.get())
+@@ -2565,7 +2575,7 @@ sal_Unicode* lcl_UnicodeStrNCpy( sal_Unicode* pDst, const sal_Unicode* pSrc, xub
  //               | Sonst             | Symbol=Symbol+Zeichen | GetString
  //---------------+-------------------+-----------------------+---------------
  
@@ -209,7 +196,7 @@
  {
      cSymbol[MAXSTRLEN-1] = 0;       // Stopper
      sal_Unicode* pSym = cSymbol;
-@@ -1894,6 +1909,8 @@ xub_StrLen ScCompiler::NextSymbol()
+@@ -2578,6 +2588,8 @@ xub_StrLen ScCompiler::NextSymbol()
      ScanState eState = ssGetChar;
      xub_StrLen nSpaces = 0;
      sal_Unicode cSep = mxSymbols->getSymbol( ocSep).GetChar(0);
@@ -218,7 +205,7 @@
      sal_Unicode cDecSep = (mxSymbols->isEnglish() ? '.' :
              ScGlobal::pLocaleData->getNumDecimalSep().GetChar(0));
  
-@@ -1910,9 +1927,9 @@ xub_StrLen ScCompiler::NextSymbol()
+@@ -2594,9 +2606,9 @@ xub_StrLen ScCompiler::NextSymbol()
      {
          pSrc++;
          ULONG nMask = GetCharTableFlags( c );
@@ -231,7 +218,7 @@
          {
              switch (eState)
              {
-@@ -2287,14 +2304,22 @@ xub_StrLen ScCompiler::NextSymbol()
+@@ -2994,14 +3006,22 @@ Label_MaskStateMachine:
  // Convert symbol to token
  //---------------------------------------------------------------------------
  
@@ -256,7 +243,7 @@
          pRawToken = aToken.Clone();
      }
      else
-@@ -3163,9 +3188,10 @@ void ScCompiler::AutoCorrectParsedSymbol()
+@@ -3917,9 +3937,10 @@ void ScCompiler::AutoCorrectParsedSymbol()
      }
  }
  
@@ -269,7 +256,7 @@
  
  #if 0
      fprintf( stderr, "NextNewToken '%s' (spaces = %d)\n",
-@@ -3246,7 +3272,7 @@ BOOL ScCompiler::NextNewToken( bool bAllowBooleans )
+@@ -4000,7 +4021,7 @@ BOOL ScCompiler::NextNewToken( bool bAllowBooleans )
              // IsReference().
              // IsBoolean before isValue to catch inline bools without the kludge
              //    for inline arrays.
@@ -278,3 +265,882 @@
                && !IsReference( aOrg )
                && !(bAllowBooleans && IsBoolean( aUpper ))
                && !IsValue( aUpper )
+diff --git sc/source/core/tool/docoptio.cxx sc/source/core/tool/docoptio.cxx
+index ffbb2d9..4338af6 100644
+--- sc/source/core/tool/docoptio.cxx
++++ sc/source/core/tool/docoptio.cxx
+@@ -38,6 +38,8 @@
+ 
+ #include <com/sun/star/uno/Any.hxx>
+ #include <com/sun/star/uno/Sequence.hxx>
++#include <com/sun/star/lang/Locale.hpp>
++#include <com/sun/star/i18n/LocaleDataItem.hpp>
+ 
+ #include "cfgids.hxx"
+ #include "docoptio.hxx"
+@@ -45,10 +47,13 @@
+ #include "scresid.hxx"
+ #include "sc.hrc"
+ #include "miscuno.hxx"
++#include "global.hxx"
+ 
+ using namespace utl;
+ using namespace rtl;
+ using namespace com::sun::star::uno;
++using ::com::sun::star::lang::Locale;
++using ::com::sun::star::i18n::LocaleDataItem;
+ 
+ //------------------------------------------------------------------------
+ 
+@@ -100,7 +105,11 @@ ScDocOptions::ScDocOptions( const ScDocOptions& rCpy )
+ 			bMatchWholeCell( rCpy.bMatchWholeCell ),
+ 			bDoAutoSpell( rCpy.bDoAutoSpell ),
+             bLookUpColRowNames( rCpy.bLookUpColRowNames ),
+-            bFormulaRegexEnabled( rCpy.bFormulaRegexEnabled )
++            bFormulaRegexEnabled( rCpy.bFormulaRegexEnabled ),
++            eFormulaGrammar( rCpy.eFormulaGrammar ),
++            aFormulaSepArg( rCpy.aFormulaSepArg ),
++            aFormulaSepArrayRow( rCpy.aFormulaSepArrayRow ),
++            aFormulaSepArrayCol( rCpy.aFormulaSepArrayCol )
+ {
+ }
+ 
+@@ -129,6 +138,67 @@ void ScDocOptions::ResetDocOptions()
+ 	bDoAutoSpell		= FALSE;
+ 	bLookUpColRowNames	= TRUE;
+     bFormulaRegexEnabled= TRUE;
++    eFormulaGrammar     = ScGrammar::GRAM_NATIVE;
++
++    do
++    {
++        const Locale& rLocale = *ScGlobal::pLocale;
++        const OUString& rLang = rLocale.Language;
++        if (rLang.equalsAscii("ru"))
++            // Don't do automatic guess for these languages, and fall back to 
++            // the old separator set.
++            break;
++
++        const LocaleDataWrapper& rLocaleData = GetLocaleDataWrapper();
++        const OUString& rDecSep  = rLocaleData.getNumDecimalSep();
++        const OUString& rListSep = rLocaleData.getListSep();
++
++        if (!rDecSep.getLength() || !rListSep.getLength())
++            // Something is wrong.  Stick with the default separators.
++            break;
++
++        sal_Unicode cDecSep  = rDecSep.getStr()[0];
++        sal_Unicode cListSep = rListSep.getStr()[0];
++        
++        // Excel by default uses system's list separator as the parameter
++        // separator, which in English locales is a comma.  However, OOo's list
++        // separator value is set to ';' for all English locales.  Because of this
++        // discrepancy, we will hardcode the separator value here, for now.
++        if (cDecSep == sal_Unicode('.'))
++            cListSep = sal_Unicode(',');
++
++        // Special case for de_CH locale.
++        if (rLocale.Language.equalsAsciiL("de", 2) && rLocale.Country.equalsAsciiL("CH", 2))
++            cListSep = sal_Unicode(';');
++
++        // by default, the parameter separator equals the locale-specific
++        // list separator.
++        aFormulaSepArg = OUString(cListSep);
++
++        if (cDecSep == cListSep && cDecSep != sal_Unicode(';'))
++            // if the decimal and list separators are equal, set the
++            // parameter separator to be ';', unless they are both
++            // semicolon in which case don't change the decimal separator.
++            aFormulaSepArg = OUString::createFromAscii(";");
++
++        aFormulaSepArrayCol = OUString::createFromAscii(",");
++        if (cDecSep == sal_Unicode(','))
++            aFormulaSepArrayCol = OUString::createFromAscii(".");
++        aFormulaSepArrayRow = OUString::createFromAscii(";");
++
++        return;
++    }
++    while (false);
++
++    // Defaults to the old separator values.
++    aFormulaSepArg      = OUString::createFromAscii(";");
++    aFormulaSepArrayCol = OUString::createFromAscii(";");
++    aFormulaSepArrayRow = OUString::createFromAscii("|");
++}
++
++const LocaleDataWrapper& ScDocOptions::GetLocaleDataWrapper() const
++{
++    return *ScGlobal::pLocaleData;
+ }
+ 
+ //========================================================================
+@@ -206,6 +276,13 @@ SfxPoolItem* __EXPORT ScTpCalcItem::Clone( SfxItemPool * ) const
+ #define SCCALCOPT_REGEX             11
+ #define SCCALCOPT_COUNT             12
+ 
++#define CFGPATH_FORMULA     "Office.Calc/Formula"
++#define SCFORMULAOPT_GRAMMAR           0
++#define SCFORMULAOPT_SEP_ARG           1
++#define SCFORMULAOPT_SEP_ARRAY_ROW     2
++#define SCFORMULAOPT_SEP_ARRAY_COL     3
++#define SCFORMULAOPT_COUNT             4
++
+ #define CFGPATH_DOCLAYOUT	"Office.Calc/Layout/Other"
+ 
+ #define SCDOCLAYOUTOPT_TABSTOP		0
+@@ -227,7 +304,7 @@ Sequence<OUString> ScDocCfg::GetCalcPropertyNames()
+ 		"Other/Precision",					// SCCALCOPT_PRECISION
+ 		"Other/SearchCriteria",				// SCCALCOPT_SEARCHCRIT
+         "Other/FindLabel",                  // SCCALCOPT_FINDLABEL
+-        "Other/RegularExpressions"          // SCCALCOPT_REGEX
++        "Other/RegularExpressions",         // SCCALCOPT_REGEX
+ 	};
+ 	Sequence<OUString> aNames(SCCALCOPT_COUNT);
+ 	OUString* pNames = aNames.getArray();
+@@ -237,6 +314,23 @@ Sequence<OUString> ScDocCfg::GetCalcPropertyNames()
+ 	return aNames;
+ }
+ 
++Sequence<OUString> ScDocCfg::GetFormulaPropertyNames()
++{
++	static const char* aPropNames[] =
++	{
++        "Syntax/Grammar",             // SCFORMULAOPT_GRAMMAR       
++        "Syntax/SeparatorArg",        // SCFORMULAOPT_SEP_ARG      
++        "Syntax/SeparatorArrayRow",   // SCFORMULAOPT_SEP_ARRAY_ROW
++        "Syntax/SeparatorArrayCol",   // SCFORMULAOPT_SEP_ARRAY_COL
++	};
++	Sequence<OUString> aNames(SCFORMULAOPT_COUNT);
++	OUString* pNames = aNames.getArray();
++	for (int i = 0; i < SCFORMULAOPT_COUNT; ++i)
++		pNames[i] = OUString::createFromAscii(aPropNames[i]);
++
++	return aNames;
++}
++
+ Sequence<OUString> ScDocCfg::GetLayoutPropertyNames()
+ {
+ 	static const char* aPropNames[] =
+@@ -257,6 +351,7 @@ Sequence<OUString> ScDocCfg::GetLayoutPropertyNames()
+ 
+ ScDocCfg::ScDocCfg() :
+ 	aCalcItem( OUString::createFromAscii( CFGPATH_CALC ) ),
++    aFormulaItem(OUString::createFromAscii(CFGPATH_FORMULA)),
+ 	aLayoutItem( OUString::createFromAscii( CFGPATH_DOCLAYOUT ) )
+ {
+ 	sal_Int32 nIntVal = 0;
+@@ -328,6 +423,69 @@ ScDocCfg::ScDocCfg() :
+ 
+ 	SetDate( nDateDay, nDateMonth, nDateYear );
+ 
++    aNames = GetFormulaPropertyNames();
++    aValues = aFormulaItem.GetProperties(aNames);
++    aFormulaItem.EnableNotification(aNames);
++    pValues = aValues.getConstArray();
++    if (aValues.getLength() == aNames.getLength())
++    {
++        for (int nProp = 0; nProp < aNames.getLength(); ++nProp)
++        {
++            switch (nProp)
++            {
++                case SCFORMULAOPT_GRAMMAR:
++                {
++                    ScGrammar::Grammar eGram = ScGrammar::GRAM_DEFAULT;
++
++                    do
++                    {
++                        if (!(pValues[nProp] >>= nIntVal))
++                            // extractino failed.
++                            break;
++
++                        switch (nIntVal)
++                        {
++                            case 0: // Calc A1
++                                eGram = ScGrammar::GRAM_NATIVE;
++                            break;
++                            case 1: // Excel A1
++                                eGram = ScGrammar::GRAM_NATIVE_XL_A1;
++                            break;
++                            case 2: // Excel R1C1
++                                eGram = ScGrammar::GRAM_NATIVE_XL_R1C1;
++                            break;
++                        }
++                    }
++                    while (false);
++                    SetFormulaSyntax(eGram);
++                }
++                break;
++                case SCFORMULAOPT_SEP_ARG:
++                {
++                    OUString aSep;
++                    if ((pValues[nProp] >>= aSep) && aSep.getLength())
++                        SetFormulaSepArg(aSep);
++                }
++                break;
++                case SCFORMULAOPT_SEP_ARRAY_ROW:
++                {
++                    OUString aSep;
++                    if ((pValues[nProp] >>= aSep) && aSep.getLength())
++                        SetFormulaSepArrayRow(aSep);
++                }
++                break;
++                case SCFORMULAOPT_SEP_ARRAY_COL:
++                {
++                    OUString aSep;
++                    if ((pValues[nProp] >>= aSep) && aSep.getLength())
++                        SetFormulaSepArrayCol(aSep);
++                }
++                break;
++            }
++        }
++    }
++    aFormulaItem.SetCommitLink( LINK(this, ScDocCfg, FormulaCommitHdl) );
++
+ 	aNames = GetLayoutPropertyNames();
+ 	aValues = aLayoutItem.GetProperties(aNames);
+ 	aLayoutItem.EnableNotification(aNames);
+@@ -410,6 +568,43 @@ IMPL_LINK( ScDocCfg, CalcCommitHdl, void *, EMPTYARG )
+ 	return 0;
+ }
+ 
++IMPL_LINK( ScDocCfg, FormulaCommitHdl, void *, EMPTYARG )
++{
++    Sequence<OUString> aNames = GetFormulaPropertyNames();
++    Sequence<Any> aValues(aNames.getLength());
++    Any* pValues = aValues.getArray();
++
++    for (int nProp = 0; nProp < aNames.getLength(); ++nProp)
++    {
++        switch (nProp)
++        {
++            case SCFORMULAOPT_GRAMMAR :
++            {
++                sal_Int32 nVal = 0;
++                switch (GetFormulaSyntax())
++                {
++                    case ScGrammar::GRAM_NATIVE_XL_A1:    nVal = 1; break;
++                    case ScGrammar::GRAM_NATIVE_XL_R1C1:  nVal = 2; break;
++                }
++                pValues[nProp] <<= nVal;
++            }
++            break;
++            case SCFORMULAOPT_SEP_ARG:
++                pValues[nProp] <<= GetFormulaSepArg();
++            break;
++            case SCFORMULAOPT_SEP_ARRAY_ROW:
++                pValues[nProp] <<= GetFormulaSepArrayRow();
++            break;
++            case SCFORMULAOPT_SEP_ARRAY_COL:
++                pValues[nProp] <<= GetFormulaSepArrayCol();
++            break;
++        }
++    }
++    aFormulaItem.PutProperties(aNames, aValues);
++
++    return 0;
++}
++
+ IMPL_LINK( ScDocCfg, LayoutCommitHdl, void *, EMPTYARG )
+ {
+ 	Sequence<OUString> aNames = GetLayoutPropertyNames();
+@@ -439,6 +634,7 @@ void ScDocCfg::SetOptions( const ScDocOptions& rNew )
+ 	*(ScDocOptions*)this = rNew;
+ 
+ 	aCalcItem.SetModified();
++    aFormulaItem.SetModified();
+ 	aLayoutItem.SetModified();
+ }
+ 
+diff --git sc/source/ui/app/scmod.cxx sc/source/ui/app/scmod.cxx
+index 12776dd..52e87b4 100644
+--- sc/source/ui/app/scmod.cxx
++++ sc/source/ui/app/scmod.cxx
+@@ -2207,6 +2207,13 @@ SfxTabPage*	 ScModule::CreateTabPage( USHORT nId, Window* pParent, const SfxItem
+ 														pRet = (*ScTpCalcOptionsCreate)(pParent, rSet);
+ 								}
+ 								break;
++        case SID_SC_TP_FORMULA:
++        {
++            ::CreateTabPage ScTpFormulaOptionsCreate = pFact->GetTabPageCreatorFunc (RID_SCPAGE_FORMULA);
++            if (ScTpFormulaOptionsCreate)
++                pRet = (*ScTpFormulaOptionsCreate)(pParent, rSet);
++        }
++        break;
+ 		case SID_SC_TP_CHANGES:
+ 								{			//CHINA001 pRet = ScRedlineOptionsTabPage::Create(pParent, rSet);
+ 											::CreateTabPage ScRedlineOptionsTabPageCreate =	pFact->GetTabPageCreatorFunc( RID_SCPAGE_OPREDLINE );
+diff --git sc/source/ui/attrdlg/scdlgfact.cxx sc/source/ui/attrdlg/scdlgfact.cxx
+index de9b284..7e6e248 100644
+--- sc/source/ui/attrdlg/scdlgfact.cxx
++++ sc/source/ui/attrdlg/scdlgfact.cxx
+@@ -76,6 +76,7 @@
+ #include "tpstat.hxx" //add for ScDocStatPage
+ #include "tpusrlst.hxx" //add for ScTpUserLists
+ #include "tpview.hxx" //add for ScTpContentOptions
++#include "tpformula.hxx"
+ //for dataform
+ #include "datafdlg.hxx" //add for ScDataFormDlg
+ 
+@@ -1432,6 +1433,8 @@ CreateTabPage ScAbstractDialogFactory_Impl::GetTabPageCreatorFunc( USHORT nId )
+ 		case	RID_SCPAGE_CALC :
+ 			return ScTpCalcOptions::Create;
+             //break;
++        case RID_SCPAGE_FORMULA:
++            return ScTpFormulaOptions::Create;
+ 		case	RID_SCPAGE_PRINT :
+ 			return ScTpPrintOptions::Create;
+             //break;
+diff --git sc/source/ui/inc/optdlg.hrc sc/source/ui/inc/optdlg.hrc
+index e834a11..aaeb33d 100644
+--- sc/source/ui/inc/optdlg.hrc
++++ sc/source/ui/inc/optdlg.hrc
+@@ -52,6 +52,7 @@
+ #define TP_LAYOUT           12
+ #define TP_INPUT            13
+ #define TP_CHANGES			14
++#define TP_FORMULA          15
+ 
+ // TP_CALC:
+ #define BTN_ITERATE			1
+@@ -192,3 +193,16 @@
+ #define CB_TEXTFMT		78
+ #define CB_REPLWARN     79
+ 
++
++// TP_FORMULA
++#define FL_FORMULA_OPTIONS        80
++#define FT_FORMULA_SYNTAX         81
++#define LB_FORMULA_SYNTAX         82
++#define FL_FORMULA_SEPS           83
++#define FT_FORMULA_SEP_ARG        84
++#define ED_FORMULA_SEP_ARG        85
++#define FT_FORMULA_SEP_ARRAY_R    86
++#define ED_FORMULA_SEP_ARRAY_R    87
++#define FT_FORMULA_SEP_ARRAY_C    88
++#define ED_FORMULA_SEP_ARRAY_C    89
++#define BTN_FORMULA_SEP_RESET     90
+diff --git sc/source/ui/inc/tpformula.hxx sc/source/ui/inc/tpformula.hxx
+new file mode 100644
+index 0000000..054655e
+--- /dev/null
++++ sc/source/ui/inc/tpformula.hxx
+@@ -0,0 +1,96 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: tpcalc.hxx,v $
++ * $Revision: 1.9 $
++ *
++ * This file is part of OpenOffice.org.
++ *
++ * OpenOffice.org is free software: you can redistribute it and/or modify
++ * it under the terms of the GNU Lesser General Public License version 3
++ * only, as published by the Free Software Foundation.
++ *
++ * OpenOffice.org is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ * GNU Lesser General Public License version 3 for more details
++ * (a copy is included in the LICENSE file that accompanied this code).
++ *
++ * You should have received a copy of the GNU Lesser General Public License
++ * version 3 along with OpenOffice.org.  If not, see
++ * <http://www.openoffice.org/license.html>
++ * for a copy of the LGPLv3 License.
++ *
++ ************************************************************************/
++
++#ifndef SC_TPFORMULA_HXX
++#define SC_TPFORMULA_HXX
++
++#include <sfx2/tabdlg.hxx>
++#include <vcl/fixed.hxx>
++#include <vcl/lstbox.hxx>
++#include <vcl/edit.hxx>
++#include <vcl/button.hxx>
++
++#include <memory>
++
++class ScDocOptions;
++class SfxItemSet;
++class Window;
++
++class ScTpFormulaOptions : public SfxTabPage
++{
++public:
++    static  SfxTabPage* Create (Window* pParent, const SfxItemSet& rCoreSet);
++
++//  static  USHORT*     GetRanges();
++    virtual BOOL FillItemSet(SfxItemSet& rCoreSet);
++    virtual void Reset( const SfxItemSet& rCoreSet );
++    virtual int DeactivatePage(SfxItemSet* pSet = NULL);
++
++private:
++    explicit ScTpFormulaOptions(Window* pParent, const SfxItemSet& rCoreSet);
++    virtual ~ScTpFormulaOptions();
++
++    void Init();
++    void ResetSeparators();
++    void OnFocusSeparatorInput(Edit* pEdit);
++
++    bool IsValidSeparator(const ::rtl::OUString& rSep) const;
++    bool IsValidSeparatorSet() const;
++
++    DECL_LINK( ButtonHdl, PushButton* );
++    DECL_LINK( SepModifyHdl, Edit* );
++    DECL_LINK( SepEditOnFocusHdl, Edit* );
++
++private:
++    FixedLine maFlFormulaOpt;
++    FixedText maFtFormulaSyntax;
++    ListBox   maLbFormulaSyntax;
++
++    FixedLine  maFlFormulaSeps;
++    FixedText  maFtSepFuncArg;  
++    Edit       maEdSepFuncArg;
++    FixedText  maFtSepArrayCol;
++    Edit       maEdSepArrayCol;
++    FixedText  maFtSepArrayRow;
++    Edit       maEdSepArrayRow;
++    PushButton maBtnSepReset;
++
++    ::std::auto_ptr<ScDocOptions> mpOldOptions;
++    ::std::auto_ptr<ScDocOptions> mpNewOptions;
++
++    /** Stores old separator value of currently focused separator edit box.
++        This value is used to revert undesired value change. */
++    ::rtl::OUString maOldSepValue;
++
++    sal_Unicode mnDecSep;
++};
++
++
++#endif
+diff --git sc/source/ui/optdlg/makefile.mk sc/source/ui/optdlg/makefile.mk
+index e8a6d20..cb43db7 100644
+--- sc/source/ui/optdlg/makefile.mk
++++ sc/source/ui/optdlg/makefile.mk
+@@ -47,6 +47,7 @@ CXXFILES = \
+         tpusrlst.cxx    \
+         tpview.cxx      \
+         tpcalc.cxx      \
++        tpformula.cxx   \
+         tpprint.cxx     \
+         opredlin.cxx
+ 
+@@ -54,6 +55,7 @@ SLOFILES =  \
+         $(SLO)$/tpusrlst.obj \
+         $(SLO)$/tpview.obj   \
+         $(SLO)$/tpcalc.obj	\
++        $(SLO)$/tpformula.obj	\
+         $(SLO)$/tpprint.obj	\
+         $(SLO)$/opredlin.obj
+ 
+diff --git sc/source/ui/optdlg/tpformula.cxx sc/source/ui/optdlg/tpformula.cxx
+new file mode 100644
+index 0000000..1eb4aac
+--- /dev/null
++++ sc/source/ui/optdlg/tpformula.cxx
+@@ -0,0 +1,288 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: tpcalc.hxx,v $
++ * $Revision: 1.9 $
++ *
++ * This file is part of OpenOffice.org.
++ *
++ * OpenOffice.org is free software: you can redistribute it and/or modify
++ * it under the terms of the GNU Lesser General Public License version 3
++ * only, as published by the Free Software Foundation.
++ *
++ * OpenOffice.org is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ * GNU Lesser General Public License version 3 for more details
++ * (a copy is included in the LICENSE file that accompanied this code).
++ *
++ * You should have received a copy of the GNU Lesser General Public License
++ * version 3 along with OpenOffice.org.  If not, see
++ * <http://www.openoffice.org/license.html>
++ * for a copy of the LGPLv3 License.
++ *
++ ************************************************************************/
++
++// MARKER(update_precomp.py): autogen include statement, do not remove
++#include "precompiled_sc.hxx"
++
++
++
++
++//------------------------------------------------------------------
++
++#include "tpformula.hxx"
++#include "optdlg.hrc"
++#include "scresid.hxx"
++#include "grammar.hxx"
++#include "docoptio.hxx"
++#include "global.hxx"
++
++#include <unotools/localedatawrapper.hxx>
++
++#include <com/sun/star/lang/Locale.hpp>
++#include <com/sun/star/i18n/LocaleDataItem.hpp>
++
++using ::rtl::OUString;
++using ::com::sun::star::lang::Locale;
++using ::com::sun::star::i18n::LocaleDataItem;
++
++ScTpFormulaOptions::ScTpFormulaOptions(Window* pParent, const SfxItemSet& rCoreAttrs) :
++    SfxTabPage(pParent, ScResId(RID_SCPAGE_FORMULA), rCoreAttrs),
++
++    maFlFormulaOpt(this, ScResId(FL_FORMULA_OPTIONS)),
++    maFtFormulaSyntax(this, ScResId(FT_FORMULA_SYNTAX)),
++    maLbFormulaSyntax(this, ScResId(LB_FORMULA_SYNTAX)),
++    maFlFormulaSeps(this, ScResId(FL_FORMULA_SEPS)),
++    maFtSepFuncArg(this, ScResId(FT_FORMULA_SEP_ARG)),
++    maEdSepFuncArg(this, ScResId(ED_FORMULA_SEP_ARG)),
++    maFtSepArrayCol(this, ScResId(FT_FORMULA_SEP_ARRAY_C)),
++    maEdSepArrayCol(this, ScResId(ED_FORMULA_SEP_ARRAY_C)),
++    maFtSepArrayRow(this, ScResId(FT_FORMULA_SEP_ARRAY_R)),
++    maEdSepArrayRow(this, ScResId(ED_FORMULA_SEP_ARRAY_R)),
++    maBtnSepReset(this, ScResId(BTN_FORMULA_SEP_RESET)),
++
++    mpOldOptions(NULL),
++    mpNewOptions(NULL),
++    mnDecSep(0)
++{
++    FreeResource();
++
++    const ScTpCalcItem& rItem = static_cast<const ScTpCalcItem&>(
++        rCoreAttrs.Get(GetWhich(SID_SCDOCOPTIONS)));
++    mpOldOptions.reset(new ScDocOptions(rItem.GetDocOptions()));
++    mpNewOptions.reset(new ScDocOptions(rItem.GetDocOptions()));
++
++    Init();
++}
++
++ScTpFormulaOptions::~ScTpFormulaOptions()
++{
++}
++
++void ScTpFormulaOptions::Init()
++{
++    Link aLink = LINK( this, ScTpFormulaOptions, ButtonHdl );
++    maBtnSepReset.SetClickHdl(aLink);
++
++    aLink = LINK( this, ScTpFormulaOptions, SepModifyHdl );
++    maEdSepFuncArg.SetModifyHdl(aLink);
++    maEdSepArrayCol.SetModifyHdl(aLink);
++    maEdSepArrayRow.SetModifyHdl(aLink);
++
++    aLink = LINK( this, ScTpFormulaOptions, SepEditOnFocusHdl );
++    maEdSepFuncArg.SetGetFocusHdl(aLink);
++    maEdSepArrayCol.SetGetFocusHdl(aLink);
++    maEdSepArrayRow.SetGetFocusHdl(aLink);
++
++    // Get the decimal separator for current locale.
++    String aSep = mpOldOptions->GetLocaleDataWrapper().getNumDecimalSep();
++    mnDecSep = aSep.Len() ? aSep.GetChar(0) : sal_Unicode('.');
++}
++
++void ScTpFormulaOptions::ResetSeparators()
++{
++    ScDocOptions aOpt;
++    maEdSepFuncArg.SetText(aOpt.GetFormulaSepArg());
++    maEdSepArrayCol.SetText(aOpt.GetFormulaSepArrayCol());
++    maEdSepArrayRow.SetText(aOpt.GetFormulaSepArrayRow());
++}
++
++void ScTpFormulaOptions::OnFocusSeparatorInput(Edit* pEdit)
++{
++    if (!pEdit)
++        return;
++
++    // Make sure the entire text is selected.
++    xub_StrLen nLen = pEdit->GetText().Len();
++    Selection aSel(0, nLen);
++    pEdit->SetSelection(aSel);
++    maOldSepValue = pEdit->GetText();
++}
++
++bool ScTpFormulaOptions::IsValidSeparator(const OUString& rSep) const
++{
++    if (rSep.getLength() != 1)
++        // Must be one-character long.
++        return false;
++
++    if (rSep.compareToAscii("a") >= 0 && rSep.compareToAscii("z") <= 0)
++        return false;
++
++    if (rSep.compareToAscii("A") >= 0 && rSep.compareToAscii("Z") <= 0)
++        return false;
++
++    sal_Unicode c = rSep.getStr()[0];
++    switch (c)
++    {
++        case '+':
++        case '-':
++        case '/':
++        case '*':
++        case '<':
++        case '>':
++        case '[':
++        case ']':
++        case '(':
++        case ')':
++        case '"':
++        case '\'':
++            // Disallowed characters.  Anything else we want to disallow ?
++            return false;
++    }
++
++    if (c == mnDecSep)
++        // decimal separator is not allowed.
++        return false;
++
++    return true;
++}
++
++bool ScTpFormulaOptions::IsValidSeparatorSet() const
++{
++    // Make sure the column and row separators are different.
++    String aColStr = maEdSepArrayCol.GetText();
++    String aRowStr = maEdSepArrayRow.GetText();
++    if (aColStr == aRowStr)
++        return false;
++
++    return true;
++}
++
++IMPL_LINK( ScTpFormulaOptions, ButtonHdl, PushButton*, pBtn )
++{
++    if (pBtn == &maBtnSepReset)
++        ResetSeparators();
++
++    return 0;
++}
++
++IMPL_LINK( ScTpFormulaOptions, SepModifyHdl, Edit*, pEdit )
++{
++    if (!pEdit)
++        return 0;
++
++    String aStr = pEdit->GetText();
++    if (aStr.Len() > 1)
++    {
++        // In case the string is more than one character long, only grab the 
++        // first character.
++        aStr = aStr.Copy(0, 1);
++        pEdit->SetText(aStr);
++    }
++
++    if ((!IsValidSeparator(aStr) || !IsValidSeparatorSet()) && maOldSepValue.getLength())
++        // Invalid separator.  Restore the old value.
++        pEdit->SetText(maOldSepValue);
++
++    OnFocusSeparatorInput(pEdit);
++    return 0;
++}
++
++IMPL_LINK( ScTpFormulaOptions, SepEditOnFocusHdl, Edit*, pEdit )
++{
++    OnFocusSeparatorInput(pEdit);
++    return 0;
++}
++
++// static
++SfxTabPage* ScTpFormulaOptions::Create(Window* pParent, const SfxItemSet& rCoreSet)
++{
++    return new ScTpFormulaOptions(pParent, rCoreSet);
++}
++
++BOOL ScTpFormulaOptions::FillItemSet(SfxItemSet& rCoreSet)
++{
++    ScGrammar::Grammar eGram = ScGrammar::GRAM_DEFAULT;
++    switch (maLbFormulaSyntax.GetSelectEntryPos())
++    {
++        case 0:
++            eGram = ScGrammar::GRAM_NATIVE;
++        break;
++        case 1:
++            eGram = ScGrammar::GRAM_NATIVE_XL_A1;
++        break;
++        case 2:
++            eGram = ScGrammar::GRAM_NATIVE_XL_R1C1;
++        break;
++    }
++
++    mpNewOptions->SetFormulaSyntax(eGram);
++
++    mpNewOptions->SetFormulaSepArg(maEdSepFuncArg.GetText());
++    mpNewOptions->SetFormulaSepArrayCol(maEdSepArrayCol.GetText());
++    mpNewOptions->SetFormulaSepArrayRow(maEdSepArrayRow.GetText());
++
++    if (*mpNewOptions != *mpOldOptions)
++    {
++        rCoreSet.Put(ScTpCalcItem(GetWhich(SID_SCDOCOPTIONS), *mpNewOptions));
++        return true;
++    }
++    else 
++        return false;
++}
++
++void ScTpFormulaOptions::Reset(const SfxItemSet& /*rCoreSet*/)
++{
++    ScGrammar::Grammar eGram = mpNewOptions->GetFormulaSyntax();
++    switch (eGram)
++    {
++        case ScGrammar::GRAM_NATIVE:
++            maLbFormulaSyntax.SelectEntryPos(0);
++        break;
++        case ScGrammar::GRAM_NATIVE_XL_A1:
++            maLbFormulaSyntax.SelectEntryPos(1);
++        break;
++        case ScGrammar::GRAM_NATIVE_XL_R1C1:
++            maLbFormulaSyntax.SelectEntryPos(2);
++        break;
++        default:
++            maLbFormulaSyntax.SelectEntryPos(0);
++    }
++    
++    OUString aSep = mpNewOptions->GetFormulaSepArg();
++    OUString aSepArrayRow = mpNewOptions->GetFormulaSepArrayRow();
++    OUString aSepArrayCol = mpNewOptions->GetFormulaSepArrayCol();
++
++    if (aSep.getLength() == 1 && aSepArrayRow.getLength() == 1 && aSepArrayCol.getLength() == 1)
++    {
++        // Each separator must be one character long.
++        maEdSepFuncArg.SetText(aSep);
++        maEdSepArrayCol.SetText(aSepArrayCol);
++        maEdSepArrayRow.SetText(aSepArrayRow);
++    }
++    else
++        ResetSeparators();    
++}
++
++int ScTpFormulaOptions::DeactivatePage(SfxItemSet* /*pSet*/)
++{
++    // What's this method for ?
++    return KEEP_PAGE;
++}
++
+diff --git sc/source/ui/src/optdlg.src sc/source/ui/src/optdlg.src
+index 82a1161..2ea00b8 100644
+--- sc/source/ui/src/optdlg.src
++++ sc/source/ui/src/optdlg.src
+@@ -176,6 +176,105 @@ TabPage RID_SCPAGE_CALC
+ /*                                                                        */
+ /**************************************************************************/
+ 
++TabPage RID_SCPAGE_FORMULA
++{
++    HelpId = HID_SCPAGE_FORMULA ;
++    SVLook = TRUE ;
++    Hide = TRUE ;
++    Pos = MAP_APPFONT ( 0 , 0 ) ;
++    Size = MAP_APPFONT ( 260 , 185 ) ;
++
++    FixedLine FL_FORMULA_OPTIONS
++    {
++        Pos = MAP_APPFONT ( 6 , 3 ) ;
++        Size = MAP_APPFONT ( 248 , 8 ) ;
++        Text [ en-US ] = "Formula options";
++    };
++
++    FixedText FT_FORMULA_SYNTAX
++    {
++        Pos = MAP_APPFONT ( 21, 16 ) ;
++        Size = MAP_APPFONT ( 80, 8 ) ;
++        Text [ en-US ] = "Formula ~syntax" ;
++    };
++
++    ListBox LB_FORMULA_SYNTAX
++    {
++        Border = TRUE ;
++        Pos = MAP_APPFONT ( 85, 14 ) ;
++        Size = MAP_APPFONT ( 60, 46 ) ;
++        DropDown = TRUE ;
++        StringList [ en-US ] =
++        {
++            < "Calc A1" ; Default ; > ;
++            < "Excel A1" ; Default ; > ;
++            < "Excel R1C1" ; Default ; > ;
++        };
++    };
++
++    FixedLine FL_FORMULA_SEPS
++    {
++        Pos = MAP_APPFONT ( 6 , 32 ) ;
++        Size = MAP_APPFONT ( 248 , 8 ) ;
++        Text [ en-US ] = "Separators";
++    };
++
++    FixedText FT_FORMULA_SEP_ARG
++    {
++        Pos = MAP_APPFONT ( 21, 45 );
++        Size = MAP_APPFONT ( 40, 8 );
++        Text [ en-US ] = "~Function";
++    };
++
++    Edit ED_FORMULA_SEP_ARG
++    {
++        Border = TRUE;
++        Pos = MAP_APPFONT ( 65, 43 );
++        Size = MAP_APPFONT ( 10, 12 );
++    };
++
++    FixedText FT_FORMULA_SEP_ARRAY_C
++    {
++        Pos = MAP_APPFONT ( 21, 63 );
++        Size = MAP_APPFONT ( 40, 8 );
++        Text [ en-US ] = "Array co~lumn";
++    };
++
++    Edit ED_FORMULA_SEP_ARRAY_C
++    {
++        Border = TRUE;
++        Pos = MAP_APPFONT ( 65, 61 );
++        Size = MAP_APPFONT ( 10, 12 );
++    };
++
++    FixedText FT_FORMULA_SEP_ARRAY_R
++    {
++        Pos = MAP_APPFONT ( 21, 81 );
++        Size = MAP_APPFONT ( 40, 8 );
++        Text [ en-US ] = "Array ~row";
++    };
++
++    Edit ED_FORMULA_SEP_ARRAY_R
++    {
++        Border = TRUE;
++        Pos = MAP_APPFONT ( 65, 79 );
++        Size = MAP_APPFONT ( 10, 12 );
++    };
++
++    PushButton BTN_FORMULA_SEP_RESET
++    {
++        Pos = MAP_APPFONT ( 21, 99 );
++        Size = MAP_APPFONT ( 40, 14 );
++        Text [ en-US ] = "Rese~t";
++    };
++};
++
++/**************************************************************************/
++/*                                                                        */
++/*                                                                        */
++/*                                                                        */
++/**************************************************************************/
++
+ TabPage RID_SCPAGE_USERLISTS
+ {
+ 	HelpId = HID_SCPAGE_USERLISTS ;

Added: trunk/patches/dev300/calc-formula-variable-separators-svx.diff
==============================================================================
--- (empty file)
+++ trunk/patches/dev300/calc-formula-variable-separators-svx.diff	Fri Dec 12 20:33:01 2008
@@ -0,0 +1,37 @@
+diff --git svx/inc/svx/dialogs.hrc svx/inc/svx/dialogs.hrc
+index 716e7eb..a7bbc93 100644
+--- svx/inc/svx/dialogs.hrc
++++ svx/inc/svx/dialogs.hrc
+@@ -1562,7 +1562,7 @@
+ 
+ #define SVX_OOO_BUILD_START             (RID_SVX_START + 1200)
+ 
+-
++#define SID_SC_TP_FORMULA               (SVX_OOO_BUILD_START + 1)
+ 
+ 
+ #endif
+diff --git svx/source/dialog/treeopt.cxx svx/source/dialog/treeopt.cxx
+index cacb4cf..ad44eda 100644
+--- svx/source/dialog/treeopt.cxx
++++ svx/source/dialog/treeopt.cxx
+@@ -453,6 +453,7 @@ static OptionsMapping_Impl __READONLY_DATA OptionsMap_Impl[] =
+     { "Calc",               "View",                 SID_SC_TP_CONTENT },
+     { "Calc",               "International",        RID_OFA_TP_INTERNATIONAL },
+     { "Calc",               "Calculate",            SID_SC_TP_CALC },
++    { "Calc",               "Formula",              SID_SC_TP_FORMULA },
+     { "Calc",               "SortLists",            SID_SC_TP_USERLISTS },
+     { "Calc",               "Changes",              SID_SC_TP_CHANGES },
+     { "Calc",               "Grid",                 SID_SC_TP_GRID },
+diff --git svx/source/dialog/treeopt.src svx/source/dialog/treeopt.src
+index bc96c6a..fcf418a 100644
+--- svx/source/dialog/treeopt.src
++++ svx/source/dialog/treeopt.src
+@@ -241,6 +241,7 @@ Resource RID_OFADLG_OPTIONS_TREE_PAGES
+ 			< "View" ;			SID_SC_TP_CONTENT			;> ;
+ 			< "International" ;		RID_OFA_TP_INTERNATIONAL	;> ;
+ 			< "Calculate" ;			SID_SC_TP_CALC				;> ;
++			< "Formula" ;       SID_SC_TP_FORMULA ;> ;
+ 			< "Sort Lists" ;		SID_SC_TP_USERLISTS			;> ;
+ 			< "Changes" ;		SID_SC_TP_CHANGES			;> ;
+ 			< "Grid" ;			SID_SC_TP_GRID				;> ;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]