[ooo-build-commit] .: sc/inc sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Tue Oct 5 11:49:26 PDT 2010


 sc/inc/docoptio.hxx               |    7 +++++++
 sc/source/core/data/documen3.cxx  |   21 +++++++++++++++++++++
 sc/source/core/tool/docoptio.cxx  |   25 +++++++++++++++++++++----
 sc/source/ui/inc/optdlg.hrc       |   17 +++++++++--------
 sc/source/ui/inc/tpformula.hxx    |    1 +
 sc/source/ui/optdlg/tpformula.cxx |    5 ++++-
 sc/source/ui/src/optdlg.src       |   23 +++++++++++++++--------
 7 files changed, 78 insertions(+), 21 deletions(-)

New commits:
commit 612ed0cc35ff1a4724f519f6662468e142edb445
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Tue Oct 5 14:47:55 2010 -0400

    Ported calc-english-func-names-*.diff from ooo-build.
    
    Add option to switch to English function names instead of the
    localized ones.  In some locales (especially in Hungary) the users are
    more accustomed to the English function names rather other than
    translated names (i#38765).

diff --git a/sc/inc/docoptio.hxx b/sc/inc/docoptio.hxx
index ac0c0ae..3609eb4 100644
--- a/sc/inc/docoptio.hxx
+++ b/sc/inc/docoptio.hxx
@@ -53,6 +53,7 @@ class SC_DLLPUBLIC ScDocOptions
     BOOL   bDoAutoSpell;			// Auto-Spelling
     BOOL   bLookUpColRowNames;		// Spalten-/Zeilenbeschriftungen automagisch suchen
     BOOL   bFormulaRegexEnabled;    // regular expressions in formulas enabled
+    bool   bUseEnglishFuncName;     // use English function name even if the locale is not English.
     ::formula::FormulaGrammar::Grammar eFormulaGrammar;  // formula grammar used to switch different formula syntax
 
     ::rtl::OUString aFormulaSepArg;
@@ -108,6 +109,9 @@ public:
     void SetFormulaSyntax( ::formula::FormulaGrammar::Grammar eGram ) { eFormulaGrammar = eGram; }
     ::formula::FormulaGrammar::Grammar GetFormulaSyntax() const { return eFormulaGrammar; }
 
+    void SetUseEnglishFuncName( bool bVal ) { bUseEnglishFuncName = bVal; }
+    bool GetUseEnglishFuncName() const { return bUseEnglishFuncName; }
+
     void SetFormulaSepArg(const ::rtl::OUString& rSep) { aFormulaSepArg = rSep; }
     ::rtl::OUString GetFormulaSepArg() const { return aFormulaSepArg; }
 
@@ -139,6 +143,7 @@ inline void ScDocOptions::CopyTo(ScDocOptions& rOpt)
     rOpt.bDoAutoSpell			= bDoAutoSpell;
     rOpt.bLookUpColRowNames		= bLookUpColRowNames;
     rOpt.bFormulaRegexEnabled   = bFormulaRegexEnabled;
+    rOpt.bUseEnglishFuncName    = bUseEnglishFuncName;
     rOpt.eFormulaGrammar        = eFormulaGrammar;
     rOpt.aFormulaSepArg         = aFormulaSepArg;
     rOpt.aFormulaSepArrayRow    = aFormulaSepArrayRow;
@@ -162,6 +167,7 @@ inline const ScDocOptions& ScDocOptions::operator=( const ScDocOptions& rCpy )
     bDoAutoSpell		= rCpy.bDoAutoSpell;
     bLookUpColRowNames	= rCpy.bLookUpColRowNames;
     bFormulaRegexEnabled= rCpy.bFormulaRegexEnabled;
+    bUseEnglishFuncName = rCpy.bUseEnglishFuncName;
     eFormulaGrammar     = rCpy.eFormulaGrammar;
     aFormulaSepArg      = rCpy.aFormulaSepArg;
     aFormulaSepArrayRow = rCpy.aFormulaSepArrayRow;
@@ -188,6 +194,7 @@ inline int ScDocOptions::operator==( const ScDocOptions& rOpt ) const
             &&	rOpt.bDoAutoSpell			== bDoAutoSpell
             &&	rOpt.bLookUpColRowNames		== bLookUpColRowNames
             &&  rOpt.bFormulaRegexEnabled   == bFormulaRegexEnabled
+            &&  rOpt.bUseEnglishFuncName    == bUseEnglishFuncName
             &&  rOpt.eFormulaGrammar        == eFormulaGrammar
             &&  rOpt.aFormulaSepArg         == aFormulaSepArg
             &&  rOpt.aFormulaSepArrayRow    == aFormulaSepArrayRow
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index b5160a9..cba55d9 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -1848,12 +1848,33 @@ const ScDocOptions& ScDocument::GetDocOptions() const
 void ScDocument::SetDocOptions( const ScDocOptions& rOpt )
 {
     DBG_ASSERT( pDocOptions, "No DocOptions! :-(" );
+    bool bUpdateFuncNames = pDocOptions->GetUseEnglishFuncName() != rOpt.GetUseEnglishFuncName();
+
     *pDocOptions = rOpt;
 
     xPoolHelper->SetFormTableOpt(rOpt);
 
     SetGrammar( rOpt.GetFormulaSyntax() );
 
+    if (bUpdateFuncNames)
+    {
+        // This needs to be called first since it may re-initialize the entire
+        // opcode map.
+        if (rOpt.GetUseEnglishFuncName())
+        {
+            // switch native symbols to English.
+            ScCompiler aComp(NULL, ScAddress());
+            ScCompiler::OpCodeMapPtr xMap = aComp.GetOpCodeMap(::com::sun::star::sheet::FormulaLanguage::ENGLISH);
+            ScCompiler::SetNativeSymbols(xMap);
+        }
+        else
+            // re-initialize native symbols with localized function names.
+            ScCompiler::ResetNativeSymbols();
+
+        // Force re-population of function names for the function wizard, function tip etc.
+        ScGlobal::ResetFunctionList();
+    }
+
     // Update the separators.
     ScCompiler::UpdateSeparatorsNative(
         rOpt.GetFormulaSepArg(), rOpt.GetFormulaSepArrayCol(), rOpt.GetFormulaSepArrayRow());
diff --git a/sc/source/core/tool/docoptio.cxx b/sc/source/core/tool/docoptio.cxx
index 195f3fb..83c204c 100644
--- a/sc/source/core/tool/docoptio.cxx
+++ b/sc/source/core/tool/docoptio.cxx
@@ -103,6 +103,7 @@ ScDocOptions::ScDocOptions( const ScDocOptions& rCpy )
             bDoAutoSpell( rCpy.bDoAutoSpell ),
             bLookUpColRowNames( rCpy.bLookUpColRowNames ),
             bFormulaRegexEnabled( rCpy.bFormulaRegexEnabled ),
+            bUseEnglishFuncName( rCpy.bUseEnglishFuncName ),
             eFormulaGrammar( rCpy.eFormulaGrammar ),
             aFormulaSepArg( rCpy.aFormulaSepArg ),
             aFormulaSepArrayRow( rCpy.aFormulaSepArrayRow ),
@@ -135,6 +136,7 @@ void ScDocOptions::ResetDocOptions()
     bDoAutoSpell		= FALSE;
     bLookUpColRowNames	= TRUE;
     bFormulaRegexEnabled= TRUE;
+    bUseEnglishFuncName = false;
     eFormulaGrammar     = ::formula::FormulaGrammar::GRAM_NATIVE;
 
     ResetFormulaSeparators();
@@ -270,10 +272,11 @@ SfxPoolItem* __EXPORT ScTpCalcItem::Clone( SfxItemPool * ) const
 
 #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 SCFORMULAOPT_ENGLISH_FUNCNAME  1
+#define SCFORMULAOPT_SEP_ARG           2
+#define SCFORMULAOPT_SEP_ARRAY_ROW     3
+#define SCFORMULAOPT_SEP_ARRAY_COL     4
+#define SCFORMULAOPT_COUNT             5
 
 #define CFGPATH_DOCLAYOUT	"Office.Calc/Layout/Other"
 
@@ -311,6 +314,7 @@ Sequence<OUString> ScDocCfg::GetFormulaPropertyNames()
     static const char* aPropNames[] =
     {
         "Syntax/Grammar",             // SCFORMULAOPT_GRAMMAR
+        "Syntax/EnglishFunctionName", // SCFORMULAOPT_ENGLISH_FUNCNAME
         "Syntax/SeparatorArg",        // SCFORMULAOPT_SEP_ARG
         "Syntax/SeparatorArrayRow",   // SCFORMULAOPT_SEP_ARRAY_ROW
         "Syntax/SeparatorArrayCol",   // SCFORMULAOPT_SEP_ARRAY_COL
@@ -452,6 +456,13 @@ ScDocCfg::ScDocCfg() :
                     SetFormulaSyntax(eGram);
                 }
                 break;
+                case SCFORMULAOPT_ENGLISH_FUNCNAME:
+                {
+                    sal_Bool bEnglish;
+                    if (pValues[nProp] >>= bEnglish)
+                        SetUseEnglishFuncName(bEnglish);
+                }
+                break;
                 case SCFORMULAOPT_SEP_ARG:
                 {
                     OUString aSep;
@@ -581,6 +592,12 @@ IMPL_LINK( ScDocCfg, FormulaCommitHdl, void *, EMPTYARG )
                 pValues[nProp] <<= nVal;
             }
             break;
+            case SCFORMULAOPT_ENGLISH_FUNCNAME:
+            {
+                sal_Bool b = GetUseEnglishFuncName();
+                pValues[nProp] <<= b;
+            }
+            break;
             case SCFORMULAOPT_SEP_ARG:
                 pValues[nProp] <<= GetFormulaSepArg();
             break;
diff --git a/sc/source/ui/inc/optdlg.hrc b/sc/source/ui/inc/optdlg.hrc
index 7860ad3..821e71e 100644
--- a/sc/source/ui/inc/optdlg.hrc
+++ b/sc/source/ui/inc/optdlg.hrc
@@ -196,11 +196,12 @@
 #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
+#define CB_ENGLISH_FUNC_NAME      83
+#define FL_FORMULA_SEPS           84
+#define FT_FORMULA_SEP_ARG        85
+#define ED_FORMULA_SEP_ARG        86
+#define FT_FORMULA_SEP_ARRAY_R    87
+#define ED_FORMULA_SEP_ARRAY_R    88
+#define FT_FORMULA_SEP_ARRAY_C    89
+#define ED_FORMULA_SEP_ARRAY_C    90
+#define BTN_FORMULA_SEP_RESET     91
diff --git a/sc/source/ui/inc/tpformula.hxx b/sc/source/ui/inc/tpformula.hxx
index 623bbb5..62cc4a7 100644
--- a/sc/source/ui/inc/tpformula.hxx
+++ b/sc/source/ui/inc/tpformula.hxx
@@ -72,6 +72,7 @@ private:
     FixedLine maFlFormulaOpt;
     FixedText maFtFormulaSyntax;
     ListBox   maLbFormulaSyntax;
+    CheckBox  maCbEnglishFuncName;
 
     FixedLine  maFlFormulaSeps;
     FixedText  maFtSepFuncArg;
diff --git a/sc/source/ui/optdlg/tpformula.cxx b/sc/source/ui/optdlg/tpformula.cxx
index b6c5722..f793a05 100644
--- a/sc/source/ui/optdlg/tpformula.cxx
+++ b/sc/source/ui/optdlg/tpformula.cxx
@@ -59,6 +59,7 @@ ScTpFormulaOptions::ScTpFormulaOptions(Window* pParent, const SfxItemSet& rCoreA
     maFlFormulaOpt(this, ScResId(FL_FORMULA_OPTIONS)),
     maFtFormulaSyntax(this, ScResId(FT_FORMULA_SYNTAX)),
     maLbFormulaSyntax(this, ScResId(LB_FORMULA_SYNTAX)),
+    maCbEnglishFuncName(this, ScResId(CB_ENGLISH_FUNC_NAME)),
     maFlFormulaSeps(this, ScResId(FL_FORMULA_SEPS)),
     maFtSepFuncArg(this, ScResId(FT_FORMULA_SEP_ARG)),
     maEdSepFuncArg(this, ScResId(ED_FORMULA_SEP_ARG)),
@@ -234,7 +235,7 @@ BOOL ScTpFormulaOptions::FillItemSet(SfxItemSet& rCoreSet)
     }
 
     mpNewOptions->SetFormulaSyntax(eGram);
-
+    mpNewOptions->SetUseEnglishFuncName(maCbEnglishFuncName.IsChecked());
     mpNewOptions->SetFormulaSepArg(maEdSepFuncArg.GetText());
     mpNewOptions->SetFormulaSepArrayCol(maEdSepArrayCol.GetText());
     mpNewOptions->SetFormulaSepArrayRow(maEdSepArrayRow.GetText());
@@ -266,6 +267,8 @@ void ScTpFormulaOptions::Reset(const SfxItemSet& /*rCoreSet*/)
             maLbFormulaSyntax.SelectEntryPos(0);
     }
 
+    maCbEnglishFuncName.Check(mpNewOptions->GetUseEnglishFuncName());
+
     OUString aSep = mpNewOptions->GetFormulaSepArg();
     OUString aSepArrayRow = mpNewOptions->GetFormulaSepArrayRow();
     OUString aSepArrayCol = mpNewOptions->GetFormulaSepArrayCol();
diff --git a/sc/source/ui/src/optdlg.src b/sc/source/ui/src/optdlg.src
index 4f80ab7..3b07ff8 100644
--- a/sc/source/ui/src/optdlg.src
+++ b/sc/source/ui/src/optdlg.src
@@ -215,16 +215,23 @@ TabPage RID_SCPAGE_FORMULA
         };
     };
 
+    CheckBox CB_ENGLISH_FUNC_NAME
+    {
+        Pos = MAP_APPFONT ( 12, 31 ) ;
+        Size = MAP_APPFONT ( 120, 8 ) ;
+        Text [ en-US ] = "Use English function names" ;
+    };
+
     FixedLine FL_FORMULA_SEPS
     {
-        Pos = MAP_APPFONT ( 6 , 32 ) ;
+        Pos = MAP_APPFONT ( 6 , 46 ) ;
         Size = MAP_APPFONT ( 248 , 8 ) ;
         Text [ en-US ] = "Separators";
     };
 
     FixedText FT_FORMULA_SEP_ARG
     {
-        Pos = MAP_APPFONT ( 21, 45 );
+        Pos = MAP_APPFONT ( 21, 59 );
         Size = MAP_APPFONT ( 40, 8 );
         Text [ en-US ] = "~Function";
     };
@@ -232,13 +239,13 @@ TabPage RID_SCPAGE_FORMULA
     Edit ED_FORMULA_SEP_ARG
     {
         Border = TRUE;
-        Pos = MAP_APPFONT ( 65, 43 );
+        Pos = MAP_APPFONT ( 65, 57 );
         Size = MAP_APPFONT ( 10, 12 );
     };
 
     FixedText FT_FORMULA_SEP_ARRAY_C
     {
-        Pos = MAP_APPFONT ( 21, 63 );
+        Pos = MAP_APPFONT ( 21, 77 );
         Size = MAP_APPFONT ( 40, 8 );
         Text [ en-US ] = "Array co~lumn";
     };
@@ -246,13 +253,13 @@ TabPage RID_SCPAGE_FORMULA
     Edit ED_FORMULA_SEP_ARRAY_C
     {
         Border = TRUE;
-        Pos = MAP_APPFONT ( 65, 61 );
+        Pos = MAP_APPFONT ( 65, 75 );
         Size = MAP_APPFONT ( 10, 12 );
     };
 
     FixedText FT_FORMULA_SEP_ARRAY_R
     {
-        Pos = MAP_APPFONT ( 21, 81 );
+        Pos = MAP_APPFONT ( 21, 95 );
         Size = MAP_APPFONT ( 40, 8 );
         Text [ en-US ] = "Array ~row";
     };
@@ -260,13 +267,13 @@ TabPage RID_SCPAGE_FORMULA
     Edit ED_FORMULA_SEP_ARRAY_R
     {
         Border = TRUE;
-        Pos = MAP_APPFONT ( 65, 79 );
+        Pos = MAP_APPFONT ( 65, 93 );
         Size = MAP_APPFONT ( 10, 12 );
     };
 
     PushButton BTN_FORMULA_SEP_RESET
     {
-        Pos = MAP_APPFONT ( 21, 99 );
+        Pos = MAP_APPFONT ( 21, 113 );
         Size = MAP_APPFONT ( 40, 14 );
         Text [ en-US ] = "Rese~t";
     };


More information about the ooo-build-commit mailing list