[Libreoffice-commits] .: 8 commits - officecfg/registry sc/inc sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Mon Jul 23 19:05:48 PDT 2012


 officecfg/registry/schema/org/openoffice/Office/Calc.xcs |    8 
 sc/inc/calcconfig.hxx                                    |    1 
 sc/inc/formulaopt.hxx                                    |    8 
 sc/source/core/tool/calcconfig.cxx                       |    6 
 sc/source/core/tool/formulaopt.cxx                       |   47 ++--
 sc/source/core/tool/interpr4.cxx                         |   29 +-
 sc/source/ui/docshell/docsh6.cxx                         |    4 
 sc/source/ui/optdlg/calcoptionsdlg.cxx                   |  169 +++++++++++----
 sc/source/ui/optdlg/calcoptionsdlg.hrc                   |    9 
 sc/source/ui/optdlg/calcoptionsdlg.hxx                   |   11 
 sc/source/ui/optdlg/calcoptionsdlg.src                   |   34 +++
 sc/source/ui/optdlg/tpformula.cxx                        |    6 
 12 files changed, 261 insertions(+), 71 deletions(-)

New commits:
commit 01ee7955fe6d0e25c325717fe7d5dbd56e28983c
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Mon Jul 23 21:32:47 2012 -0400

    More helpful description for this option.
    
    Change-Id: Ib9399719d3d055c98108811cfb29dfd6f6dd9095

diff --git a/sc/source/ui/optdlg/calcoptionsdlg.src b/sc/source/ui/optdlg/calcoptionsdlg.src
index 235ec0e..4c53229 100644
--- a/sc/source/ui/optdlg/calcoptionsdlg.src
+++ b/sc/source/ui/optdlg/calcoptionsdlg.src
@@ -125,7 +125,7 @@ ModalDialog RID_SCDLG_FORMULA_CALCOPTIONS
 
     String STR_EMPTY_STRING_AS_ZERO_DESC
     {
-        Text [ en-US ] = "Blah.";
+        Text [ en-US ] = "This option determines whether or not an empty string is to be treated as having a value of zero when used in arithmetic.";
     };
 
     String STR_TRUE
commit 9b2d4348e1659cebdf560626a3b6c00263c6b1f2
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Mon Jul 23 21:17:53 2012 -0400

    Unused parameter.
    
    Change-Id: Ie76561a2c8e5d6a8613e948620503f42ad73a207

diff --git a/sc/source/ui/optdlg/calcoptionsdlg.cxx b/sc/source/ui/optdlg/calcoptionsdlg.cxx
index 3b1f8da..69bd2a8 100644
--- a/sc/source/ui/optdlg/calcoptionsdlg.cxx
+++ b/sc/source/ui/optdlg/calcoptionsdlg.cxx
@@ -312,7 +312,7 @@ IMPL_LINK(ScCalcOptionsDialog, SettingsSelHdl, Control*, pCtrl)
     return 0;
 }
 
-IMPL_LINK(ScCalcOptionsDialog, BtnToggleHdl, RadioButton*, pBtn)
+IMPL_LINK_NOARG(ScCalcOptionsDialog, BtnToggleHdl)
 {
     RadioValueChanged();
     return 0;
diff --git a/sc/source/ui/optdlg/calcoptionsdlg.hxx b/sc/source/ui/optdlg/calcoptionsdlg.hxx
index 85a62db..a1a7222 100644
--- a/sc/source/ui/optdlg/calcoptionsdlg.hxx
+++ b/sc/source/ui/optdlg/calcoptionsdlg.hxx
@@ -43,7 +43,7 @@ public:
     virtual ~ScCalcOptionsDialog();
 
     DECL_LINK( SettingsSelHdl, Control* );
-    DECL_LINK( BtnToggleHdl, RadioButton* );
+    DECL_LINK( BtnToggleHdl, void* );
 
     const ScCalcConfig& GetConfig() const;
 
commit 3a8f10ddb4bfbbf76590102bbcaa10c9aa2c0af3
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Mon Jul 23 21:10:50 2012 -0400

    Honor the configuration option in the interpreter.
    
    Change-Id: I686d1f3703cbb122e1b3ed010a727163be2e942a

diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 566d0b3..c35cdfd 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -243,21 +243,26 @@ double ScInterpreter::ConvertStringToValue( const String& rStr )
         SetError( mnStringNoValueError);
         return fValue;
     }
-    // The number scanner does not accept empty strings or strings containing
-    // only spaces, be on par in these cases with what was accepted in OOo and
-    // is in AOO (see also the #else branch below) and convert to 0 to prevent
-    // interoperability nightmares.
-    if (!rStr.Len())
-        return fValue;
-    else if (rStr.GetChar(0) == ' ')
+
+    if (GetGlobalConfig().mbEmptyStringAsZero)
     {
-        const sal_Unicode* p = rStr.GetBuffer() + 1;
-        const sal_Unicode* const pStop = p - 1 + rStr.Len();
-        while (p < pStop && *p == ' ')
-            ++p;
-        if (p == pStop)
+        // The number scanner does not accept empty strings or strings
+        // containing only spaces, be on par in these cases with what was
+        // accepted in OOo and is in AOO (see also the else branch below) and
+        // convert to 0 to prevent interoperability nightmares.
+        if (!rStr.Len())
             return fValue;
+        else if (rStr.GetChar(0) == ' ')
+        {
+            const sal_Unicode* p = rStr.GetBuffer() + 1;
+            const sal_Unicode* const pStop = p - 1 + rStr.Len();
+            while (p < pStop && *p == ' ')
+                ++p;
+            if (p == pStop)
+                return fValue;
+        }
     }
+
     sal_uInt32 nFIndex = 0;
     if (!pFormatter->IsNumberFormat(rStr, nFIndex, fValue))
     {
commit 22cf0759547aa1803f77dbd3ee91774600dadc6f
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Mon Jul 23 21:05:00 2012 -0400

    Let's not forget to set the description for this option.
    
    Change-Id: I9441ef145b62b84c1b4b8dd6ce85d6c0744f3103

diff --git a/sc/source/ui/optdlg/calcoptionsdlg.cxx b/sc/source/ui/optdlg/calcoptionsdlg.cxx
index 4fdffb8..3b1f8da 100644
--- a/sc/source/ui/optdlg/calcoptionsdlg.cxx
+++ b/sc/source/ui/optdlg/calcoptionsdlg.cxx
@@ -214,6 +214,7 @@ void ScCalcOptionsDialog::SelectionChanged()
                 maBtnTrue.Check(false);
                 maBtnFalse.Check(true);
             }
+            maFtAnnotation.SetText(maDescEmptyStringAsZero);
         }
         break;
         default:
commit 3f4b517ce0a82c0015d6723dfb2f4c48cf981c90
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Mon Jul 23 21:02:46 2012 -0400

    Handle saving to and loading from user configuration.
    
    Change-Id: I81730077322b8890726da4d033f034c1266afa76

diff --git a/sc/source/core/tool/formulaopt.cxx b/sc/source/core/tool/formulaopt.cxx
index d3d4e89..b5989ad 100644
--- a/sc/source/core/tool/formulaopt.cxx
+++ b/sc/source/core/tool/formulaopt.cxx
@@ -207,13 +207,14 @@ SfxPoolItem* ScTpFormulaItem::Clone( SfxItemPool * ) const
 
 #define CFGPATH_FORMULA           "Office.Calc/Formula"
 
-#define SCFORMULAOPT_GRAMMAR           0
-#define SCFORMULAOPT_ENGLISH_FUNCNAME  1
-#define SCFORMULAOPT_SEP_ARG           2
-#define SCFORMULAOPT_SEP_ARRAY_ROW     3
-#define SCFORMULAOPT_SEP_ARRAY_COL     4
-#define SCFORMULAOPT_STRING_REF_SYNTAX 5
-#define SCFORMULAOPT_COUNT             6
+#define SCFORMULAOPT_GRAMMAR              0
+#define SCFORMULAOPT_ENGLISH_FUNCNAME     1
+#define SCFORMULAOPT_SEP_ARG              2
+#define SCFORMULAOPT_SEP_ARRAY_ROW        3
+#define SCFORMULAOPT_SEP_ARRAY_COL        4
+#define SCFORMULAOPT_STRING_REF_SYNTAX    5
+#define SCFORMULAOPT_EMPTY_STRING_AS_ZERO 6
+#define SCFORMULAOPT_COUNT                7
 
 Sequence<OUString> ScFormulaCfg::GetPropertyNames()
 {
@@ -225,6 +226,7 @@ Sequence<OUString> ScFormulaCfg::GetPropertyNames()
         "Syntax/SeparatorArrayRow",      // SCFORMULAOPT_SEP_ARRAY_ROW
         "Syntax/SeparatorArrayCol",      // SCFORMULAOPT_SEP_ARRAY_COL
         "Syntax/StringRefAddressSyntax", // SCFORMULAOPT_STRING_REF_SYNTAX
+        "Syntax/EmptyStringAsZero",      // SCFORMULAOPT_EMPTY_STRING_AS_ZERO
     };
     Sequence<OUString> aNames(SCFORMULAOPT_COUNT);
     OUString* pNames = aNames.getArray();
@@ -341,6 +343,15 @@ ScFormulaCfg::ScFormulaCfg() :
                     GetCalcConfig().meStringRefAddressSyntax = eConv;
                 }
                 break;
+                case SCFORMULAOPT_EMPTY_STRING_AS_ZERO:
+                {
+                    sal_Bool bVal = GetCalcConfig().mbEmptyStringAsZero;
+                    pValues[nProp] >>= bVal;
+                    GetCalcConfig().mbEmptyStringAsZero = bVal;
+                }
+                break;
+                default:
+                    ;
                 }
             }
         }
@@ -397,6 +408,14 @@ void ScFormulaCfg::Commit()
                 pValues[nProp] <<= nVal;
             }
             break;
+            case SCFORMULAOPT_EMPTY_STRING_AS_ZERO:
+            {
+                sal_Bool bVal = GetCalcConfig().mbEmptyStringAsZero;
+                pValues[nProp] <<= bVal;
+            }
+            break;
+            default:
+                ;
         }
     }
     PutProperties(aNames, aValues);
commit 253fad3580761d3d53e6b352aa3b7aeaa3810eee
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Mon Jul 23 20:16:46 2012 -0400

    Add a new configuration option.
    
    Change-Id: Ib9ba5a2b269a2e20f8ba3703e8efc496357911ef

diff --git a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
index 0f5898e..d9aaabd 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
@@ -1377,6 +1377,14 @@
                         </enumeration>
                     </constraints>
                 </prop>
+                <prop oor:name="EmptyStringAsZero" oor:type="xs:boolean" oor:nillable="false">
+                    <!-- UIHints: Tools - Options  Spreadsheet  Formula -->
+                    <info>
+                        <author>kyoshida</author>
+                        <desc>Whether to treat empty string formula result as equivalent of having a numeric zero value.</desc>
+                    </info>
+                    <value>false</value>
+                </prop>
             </group>
         </group>
 		<group oor:name="Revision">
commit 2ee9a0adacb6b163591ff0cbc1a0843c478403fb
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Mon Jul 23 18:10:08 2012 -0400

    Using ScCalcConfig throughout saves quite a bit of code.
    
    Change-Id: I697b03d603a99cdb58c31d78447bbed10230311e

diff --git a/sc/inc/formulaopt.hxx b/sc/inc/formulaopt.hxx
index 5ca55a3..7cc2dd8 100644
--- a/sc/inc/formulaopt.hxx
+++ b/sc/inc/formulaopt.hxx
@@ -35,13 +35,14 @@
 #include "formula/grammar.hxx"
 #include "scdllapi.h"
 #include "global.hxx"
+#include "calcconfig.hxx"
 
 class SC_DLLPUBLIC ScFormulaOptions
 {
 private:
     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
-    formula::FormulaGrammar::AddressConvention eStringRefSyntax;
+    ScCalcConfig aCalcConfig;
 
     ::rtl::OUString aFormulaSepArg;
     ::rtl::OUString aFormulaSepArrayRow;
@@ -57,8 +58,9 @@ public:
     void SetFormulaSyntax( ::formula::FormulaGrammar::Grammar eGram ) { eFormulaGrammar = eGram; }
     ::formula::FormulaGrammar::Grammar GetFormulaSyntax() const { return eFormulaGrammar; }
 
-    void SetStringRefAddressSyntax(formula::FormulaGrammar::AddressConvention eConv) { eStringRefSyntax = eConv; }
-    formula::FormulaGrammar::AddressConvention GetStringRefAddressSyntax() const { return eStringRefSyntax; }
+    ScCalcConfig& GetCalcConfig() { return aCalcConfig; }
+    const ScCalcConfig& GetCalcConfig() const { return aCalcConfig; }
+    void SetCalcConfig(const ScCalcConfig& rConfig) { aCalcConfig = rConfig; }
 
     void SetUseEnglishFuncName( bool bVal ) { bUseEnglishFuncName = bVal; }
     bool GetUseEnglishFuncName() const { return bUseEnglishFuncName; }
diff --git a/sc/source/core/tool/formulaopt.cxx b/sc/source/core/tool/formulaopt.cxx
index 7cb1687..d3d4e89 100644
--- a/sc/source/core/tool/formulaopt.cxx
+++ b/sc/source/core/tool/formulaopt.cxx
@@ -55,7 +55,7 @@ ScFormulaOptions::ScFormulaOptions()
 ScFormulaOptions::ScFormulaOptions( const ScFormulaOptions& rCpy ) :
     bUseEnglishFuncName ( rCpy.bUseEnglishFuncName ),
     eFormulaGrammar     ( rCpy.eFormulaGrammar ),
-    eStringRefSyntax(rCpy.eStringRefSyntax),
+    aCalcConfig(rCpy.aCalcConfig),
     aFormulaSepArg      ( rCpy.aFormulaSepArg ),
     aFormulaSepArrayRow ( rCpy.aFormulaSepArrayRow ),
     aFormulaSepArrayCol ( rCpy.aFormulaSepArrayCol )
@@ -72,7 +72,7 @@ void ScFormulaOptions::SetDefaults()
     eFormulaGrammar     = ::formula::FormulaGrammar::GRAM_NATIVE;
 
     // unspecified means use the current formula syntax.
-    eStringRefSyntax = formula::FormulaGrammar::CONV_UNSPECIFIED;
+    aCalcConfig.reset();
 
     ResetFormulaSeparators();
 }
@@ -144,7 +144,7 @@ ScFormulaOptions& ScFormulaOptions::operator=( const ScFormulaOptions& rCpy )
 {
     bUseEnglishFuncName = rCpy.bUseEnglishFuncName;
     eFormulaGrammar     = rCpy.eFormulaGrammar;
-    eStringRefSyntax = rCpy.eStringRefSyntax;
+    aCalcConfig = rCpy.aCalcConfig;
     aFormulaSepArg      = rCpy.aFormulaSepArg;
     aFormulaSepArrayRow = rCpy.aFormulaSepArrayRow;
     aFormulaSepArrayCol = rCpy.aFormulaSepArrayCol;
@@ -155,7 +155,7 @@ bool ScFormulaOptions::operator==( const ScFormulaOptions& rOpt ) const
 {
     return bUseEnglishFuncName == rOpt.bUseEnglishFuncName
         && eFormulaGrammar     == rOpt.eFormulaGrammar
-        && eStringRefSyntax == rOpt.eStringRefSyntax
+        && aCalcConfig == rOpt.aCalcConfig
         && aFormulaSepArg      == rOpt.aFormulaSepArg
         && aFormulaSepArrayRow == rOpt.aFormulaSepArrayRow
         && aFormulaSepArrayCol == rOpt.aFormulaSepArrayCol;
@@ -311,7 +311,7 @@ ScFormulaCfg::ScFormulaCfg() :
                 case SCFORMULAOPT_STRING_REF_SYNTAX:
                 {
                     // Get default value in case this option is not set.
-                    ::formula::FormulaGrammar::AddressConvention eConv = GetStringRefAddressSyntax();
+                    ::formula::FormulaGrammar::AddressConvention eConv = GetCalcConfig().meStringRefAddressSyntax;
 
                     do
                     {
@@ -338,7 +338,7 @@ ScFormulaCfg::ScFormulaCfg() :
                         }
                     }
                     while (false);
-                    SetStringRefAddressSyntax(eConv);
+                    GetCalcConfig().meStringRefAddressSyntax = eConv;
                 }
                 break;
                 }
@@ -387,7 +387,7 @@ void ScFormulaCfg::Commit()
             case SCFORMULAOPT_STRING_REF_SYNTAX:
             {
                 sal_Int32 nVal = -1;
-                switch (GetStringRefAddressSyntax())
+                switch (GetCalcConfig().meStringRefAddressSyntax)
                 {
                     case ::formula::FormulaGrammar::CONV_OOO:     nVal = 0; break;
                     case ::formula::FormulaGrammar::CONV_XL_A1:   nVal = 1; break;
diff --git a/sc/source/ui/docshell/docsh6.cxx b/sc/source/ui/docshell/docsh6.cxx
index cdf9756..94b9787 100644
--- a/sc/source/ui/docshell/docsh6.cxx
+++ b/sc/source/ui/docshell/docsh6.cxx
@@ -496,9 +496,7 @@ void ScDocShell::SetFormulaOptions(const ScFormulaOptions& rOpt )
         rOpt.GetFormulaSepArg(), rOpt.GetFormulaSepArrayCol(), rOpt.GetFormulaSepArrayRow());
 
     // Global interpreter settings.
-    ScCalcConfig aConfig;
-    aConfig.meStringRefAddressSyntax = rOpt.GetStringRefAddressSyntax();
-    ScInterpreter::SetGlobalConfig(aConfig);
+    ScInterpreter::SetGlobalConfig(rOpt.GetCalcConfig());
 }
 
 void ScDocShell::CheckConfigOptions()
diff --git a/sc/source/ui/optdlg/tpformula.cxx b/sc/source/ui/optdlg/tpformula.cxx
index 59c1d8c..9675fa0 100644
--- a/sc/source/ui/optdlg/tpformula.cxx
+++ b/sc/source/ui/optdlg/tpformula.cxx
@@ -291,7 +291,7 @@ sal_Bool ScTpFormulaOptions::FillItemSet(SfxItemSet& rCoreSet)
         aOpt.SetFormulaSepArg(aSep);
         aOpt.SetFormulaSepArrayCol(aSepArrayCol);
         aOpt.SetFormulaSepArrayRow(aSepArrayRow);
-        aOpt.SetStringRefAddressSyntax(maCurrentConfig.meStringRefAddressSyntax);
+        aOpt.SetCalcConfig(maCurrentConfig);
 
         rCoreSet.Put( ScTpFormulaItem( SID_SCFORMULAOPTIONS, aOpt ) );
         bRet = true;
@@ -353,8 +353,8 @@ void ScTpFormulaOptions::Reset(const SfxItemSet& rCoreSet)
     // detailed calc settings.
     ScFormulaOptions aDefaults;
 
-    maSavedConfig.meStringRefAddressSyntax = aOpt.GetStringRefAddressSyntax();
-    bool bDefault = aDefaults.GetStringRefAddressSyntax() == maSavedConfig.meStringRefAddressSyntax;
+    maSavedConfig = aOpt.GetCalcConfig();
+    bool bDefault = aDefaults.GetCalcConfig() == maSavedConfig;
     UpdateCustomCalcRadioButtons(bDefault);
 
     maCurrentConfig = maSavedConfig;
commit 4e8552993aed7caaa247bb1baf6168ddcfba159a
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Mon Jul 23 17:49:03 2012 -0400

    Add new formula config option in the UI for "treat empty string as zero."
    
    Change-Id: I116857ee8b377c80707efbc76fcfa06c3e46201d

diff --git a/sc/inc/calcconfig.hxx b/sc/inc/calcconfig.hxx
index 48d4746..2006ba2 100644
--- a/sc/inc/calcconfig.hxx
+++ b/sc/inc/calcconfig.hxx
@@ -38,6 +38,7 @@
 struct SC_DLLPUBLIC ScCalcConfig
 {
     formula::FormulaGrammar::AddressConvention meStringRefAddressSyntax;
+    bool mbEmptyStringAsZero:1;
 
     ScCalcConfig();
 
diff --git a/sc/source/core/tool/calcconfig.cxx b/sc/source/core/tool/calcconfig.cxx
index 660869a..eab1467 100644
--- a/sc/source/core/tool/calcconfig.cxx
+++ b/sc/source/core/tool/calcconfig.cxx
@@ -29,7 +29,8 @@
 #include "calcconfig.hxx"
 
 ScCalcConfig::ScCalcConfig() :
-    meStringRefAddressSyntax(formula::FormulaGrammar::CONV_UNSPECIFIED) {}
+    meStringRefAddressSyntax(formula::FormulaGrammar::CONV_UNSPECIFIED),
+    mbEmptyStringAsZero(false) {}
 
 void ScCalcConfig::reset()
 {
@@ -38,7 +39,8 @@ void ScCalcConfig::reset()
 
 bool ScCalcConfig::operator== (const ScCalcConfig& r) const
 {
-    return meStringRefAddressSyntax == r.meStringRefAddressSyntax;
+    return meStringRefAddressSyntax == r.meStringRefAddressSyntax &&
+        mbEmptyStringAsZero == r.mbEmptyStringAsZero;
 }
 
 bool ScCalcConfig::operator!= (const ScCalcConfig& r) const
diff --git a/sc/source/ui/optdlg/calcoptionsdlg.cxx b/sc/source/ui/optdlg/calcoptionsdlg.cxx
index 2b75082..4fdffb8 100644
--- a/sc/source/ui/optdlg/calcoptionsdlg.cxx
+++ b/sc/source/ui/optdlg/calcoptionsdlg.cxx
@@ -87,16 +87,22 @@ ScCalcOptionsDialog::ScCalcOptionsDialog(Window* pParent, const ScCalcConfig& rC
     maLbSettings(this, ScResId(LB_SETTINGS)),
     maFtOptionEditCaption(this, ScResId(FT_OPTION_EDIT_CAPTION)),
     maLbOptionEdit(this, ScResId(LB_OPTION_EDIT)),
+    maBtnTrue(this, ScResId(BTN_OPTION_TRUE)),
+    maBtnFalse(this, ScResId(BTN_OPTION_FALSE)),
     maFlAnnotation(this, ScResId(FL_ANNOTATION)),
     maFtAnnotation(this, ScResId(FT_ANNOTATION)),
     maBtnOK(this, ScResId(BTN_OK)),
     maBtnCancel(this, ScResId(BTN_CANCEL)),
+    maTrue(ScResId(STR_TRUE).toString()),
+    maFalse(ScResId(STR_FALSE).toString()),
     maCalcA1(ScResId(SCSTR_FORMULA_SYNTAX_CALC_A1).toString()),
     maExcelA1(ScResId(SCSTR_FORMULA_SYNTAX_XL_A1).toString()),
     maExcelR1C1(ScResId(SCSTR_FORMULA_SYNTAX_XL_R1C1).toString()),
     maCaptionStringRefSyntax(ScResId(STR_STRING_REF_SYNTAX_CAPTION).toString()),
     maDescStringRefSyntax(ScResId(STR_STRING_REF_SYNTAX_DESC).toString()),
     maUseFormulaSyntax(ScResId(STR_USE_FORMULA_SYNTAX).toString()),
+    maCaptionEmptyStringAsZero(ScResId(STR_EMPTY_STRING_AS_ZERO_CAPTION).toString()),
+    maDescEmptyStringAsZero(ScResId(STR_EMPTY_STRING_AS_ZERO_DESC).toString()),
     maConfig(rConfig)
 {
     maLbSettings.SetStyle(maLbSettings.GetStyle() | WB_CLIPCHILDREN | WB_FORCE_MAKEVISIBLE);
@@ -106,6 +112,12 @@ ScCalcOptionsDialog::ScCalcOptionsDialog(Window* pParent, const ScCalcConfig& rC
     maLbSettings.SetSelectHdl(aLink);
     maLbOptionEdit.SetSelectHdl(aLink);
 
+    aLink = LINK(this, ScCalcOptionsDialog, BtnToggleHdl);
+    maBtnTrue.SetToggleHdl(aLink); // Set handler only to the 'True' button.
+
+    maBtnTrue.SetText(maTrue);
+    maBtnFalse.SetText(maFalse);
+
     FillOptionsList();
     FreeResource();
     SelectionChanged();
@@ -136,58 +148,134 @@ void ScCalcOptionsDialog::FillOptionsList()
         pModel->Insert(pEntry);
     }
 
+    {
+        // Treat empty string as zero.
+        SvLBoxEntry* pEntry = new SvLBoxEntry;
+        pEntry->AddItem(new SvLBoxString(pEntry, 0, rtl::OUString()));
+        pEntry->AddItem(new SvLBoxContextBmp(pEntry, 0, Image(), Image(), 0));
+        OptionString* pItem = new OptionString(
+            maCaptionEmptyStringAsZero, toString(maConfig.mbEmptyStringAsZero));
+        pEntry->AddItem(pItem);
+        pModel->Insert(pEntry);
+    }
+
     maLbSettings.SetUpdateMode(true);
 }
 
 void ScCalcOptionsDialog::SelectionChanged()
 {
-    if (true)
+    sal_uInt16 nSelectedPos = maLbSettings.GetSelectEntryPos();
+    switch (nSelectedPos)
     {
-        // Formula syntax for INDIRECT function.
-        maLbOptionEdit.Clear();
-        maLbOptionEdit.InsertEntry(maUseFormulaSyntax);
-        maLbOptionEdit.InsertEntry(maCalcA1);
-        maLbOptionEdit.InsertEntry(maExcelA1);
-        maLbOptionEdit.InsertEntry(maExcelR1C1);
-        switch (maConfig.meStringRefAddressSyntax)
+        case 0:
         {
-            case formula::FormulaGrammar::CONV_OOO:
-                maLbOptionEdit.SelectEntryPos(1);
-            break;
-            case formula::FormulaGrammar::CONV_XL_A1:
-                maLbOptionEdit.SelectEntryPos(2);
-            break;
-            case formula::FormulaGrammar::CONV_XL_R1C1:
-                maLbOptionEdit.SelectEntryPos(3);
-            break;
-            case formula::FormulaGrammar::CONV_UNSPECIFIED:
-            default:
-                maLbOptionEdit.SelectEntryPos(0);
+            // Formula syntax for INDIRECT function.
+            maBtnTrue.Hide();
+            maBtnFalse.Hide();
+            maLbOptionEdit.Show();
+
+            maLbOptionEdit.Clear();
+            maLbOptionEdit.InsertEntry(maUseFormulaSyntax);
+            maLbOptionEdit.InsertEntry(maCalcA1);
+            maLbOptionEdit.InsertEntry(maExcelA1);
+            maLbOptionEdit.InsertEntry(maExcelR1C1);
+            switch (maConfig.meStringRefAddressSyntax)
+            {
+                case formula::FormulaGrammar::CONV_OOO:
+                    maLbOptionEdit.SelectEntryPos(1);
+                break;
+                case formula::FormulaGrammar::CONV_XL_A1:
+                    maLbOptionEdit.SelectEntryPos(2);
+                break;
+                case formula::FormulaGrammar::CONV_XL_R1C1:
+                    maLbOptionEdit.SelectEntryPos(3);
+                break;
+                case formula::FormulaGrammar::CONV_UNSPECIFIED:
+                default:
+                    maLbOptionEdit.SelectEntryPos(0);
+            }
+            maFtAnnotation.SetText(maDescStringRefSyntax);
+        }
+        break;
+        case 1:
+        {
+            // Treat empty string as zero.
+            maLbOptionEdit.Hide();
+            maBtnTrue.Show();
+            maBtnFalse.Show();
+
+            if (maConfig.mbEmptyStringAsZero)
+            {
+                maBtnTrue.Check(true);
+                maBtnFalse.Check(false);
+            }
+            else
+            {
+                maBtnTrue.Check(false);
+                maBtnFalse.Check(true);
+            }
         }
-        maFtAnnotation.SetText(maDescStringRefSyntax);
+        break;
+        default:
+            ;
     }
 }
 
 void ScCalcOptionsDialog::ListOptionValueChanged()
 {
-    if (true)
+    sal_uInt16 nSelected = maLbSettings.GetSelectEntryPos();
+    switch (nSelected)
     {
-        // Formula syntax for INDIRECT function.
-        sal_uInt16 nPos = maLbOptionEdit.GetSelectEntryPos();
-        maConfig.meStringRefAddressSyntax = toAddressConvention(nPos);
+        case 0:
+        {
+            // Formula syntax for INDIRECT function.
+            sal_uInt16 nPos = maLbOptionEdit.GetSelectEntryPos();
+            maConfig.meStringRefAddressSyntax = toAddressConvention(nPos);
 
-        maLbSettings.SetUpdateMode(false);
+            maLbSettings.SetUpdateMode(false);
 
-        SvLBoxTreeList* pModel = maLbSettings.GetModel();
-        SvLBoxEntry* pEntry = pModel->GetEntry(NULL, 0);
-        if (!pEntry)
-            return;
+            SvLBoxTreeList* pModel = maLbSettings.GetModel();
+            SvLBoxEntry* pEntry = pModel->GetEntry(NULL, 0);
+            if (!pEntry)
+                return;
 
-        OptionString* pItem = new OptionString(
-            maCaptionStringRefSyntax, toString(maConfig.meStringRefAddressSyntax));
-        pEntry->ReplaceItem(pItem, 2);
+            OptionString* pItem = new OptionString(
+                maCaptionStringRefSyntax, toString(maConfig.meStringRefAddressSyntax));
+            pEntry->ReplaceItem(pItem, 2);
 
-        maLbSettings.SetUpdateMode(true);
+            maLbSettings.SetUpdateMode(true);
+        }
+        break;
+        default:
+            ;
+    }
+}
+
+void ScCalcOptionsDialog::RadioValueChanged()
+{
+    sal_uInt16 nSelected = maLbSettings.GetSelectEntryPos();
+    switch (nSelected)
+    {
+        case 1:
+        {
+            // Treat empty string as zero.
+            maConfig.mbEmptyStringAsZero = maBtnTrue.IsChecked();
+            maLbSettings.SetUpdateMode(false);
+
+            SvLBoxTreeList* pModel = maLbSettings.GetModel();
+            SvLBoxEntry* pEntry = pModel->GetEntry(NULL, 1);
+            if (!pEntry)
+                return;
+
+            OptionString* pItem = new OptionString(
+                maCaptionEmptyStringAsZero, toString(maConfig.mbEmptyStringAsZero));
+            pEntry->ReplaceItem(pItem, 2);
+
+            maLbSettings.SetUpdateMode(true);
+        }
+        break;
+        default:
+            ;
     }
 }
 
@@ -208,6 +296,11 @@ rtl::OUString ScCalcOptionsDialog::toString(formula::FormulaGrammar::AddressConv
     return maUseFormulaSyntax;
 }
 
+rtl::OUString ScCalcOptionsDialog::toString(bool bVal) const
+{
+    return bVal ? maTrue : maFalse;
+}
+
 IMPL_LINK(ScCalcOptionsDialog, SettingsSelHdl, Control*, pCtrl)
 {
     if (pCtrl == &maLbSettings)
@@ -218,4 +311,11 @@ IMPL_LINK(ScCalcOptionsDialog, SettingsSelHdl, Control*, pCtrl)
     return 0;
 }
 
+IMPL_LINK(ScCalcOptionsDialog, BtnToggleHdl, RadioButton*, pBtn)
+{
+    RadioValueChanged();
+    return 0;
+}
+
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/optdlg/calcoptionsdlg.hrc b/sc/source/ui/optdlg/calcoptionsdlg.hrc
index 6d87868..401f32d 100644
--- a/sc/source/ui/optdlg/calcoptionsdlg.hrc
+++ b/sc/source/ui/optdlg/calcoptionsdlg.hrc
@@ -34,6 +34,8 @@
 
 #define FT_OPTION_EDIT_CAPTION 4
 #define LB_OPTION_EDIT 5
+#define BTN_OPTION_TRUE 6
+#define BTN_OPTION_FALSE 7
 
 #define FL_ANNOTATION 20
 #define FT_ANNOTATION 21
@@ -43,4 +45,11 @@
 
 #define STR_USE_FORMULA_SYNTAX 24
 
+#define STR_TRUE 25
+#define STR_FALSE 26
+
+#define STR_EMPTY_STRING_AS_ZERO_CAPTION 27
+#define STR_EMPTY_STRING_AS_ZERO_DESC 28
+
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/optdlg/calcoptionsdlg.hxx b/sc/source/ui/optdlg/calcoptionsdlg.hxx
index a1e3cfc..85a62db 100644
--- a/sc/source/ui/optdlg/calcoptionsdlg.hxx
+++ b/sc/source/ui/optdlg/calcoptionsdlg.hxx
@@ -43,6 +43,7 @@ public:
     virtual ~ScCalcOptionsDialog();
 
     DECL_LINK( SettingsSelHdl, Control* );
+    DECL_LINK( BtnToggleHdl, RadioButton* );
 
     const ScCalcConfig& GetConfig() const;
 
@@ -50,14 +51,18 @@ private:
     void FillOptionsList();
     void SelectionChanged();
     void ListOptionValueChanged();
+    void RadioValueChanged();
 
     rtl::OUString toString(formula::FormulaGrammar::AddressConvention eConv) const;
+    rtl::OUString toString(bool bVal) const;
 
 private:
     SvxCheckListBox maLbSettings;
 
     FixedText maFtOptionEditCaption;
     ListBox maLbOptionEdit;
+    RadioButton maBtnTrue;
+    RadioButton maBtnFalse;
 
     FixedLine maFlAnnotation;
     FixedText maFtAnnotation;
@@ -65,6 +70,9 @@ private:
     OKButton maBtnOK;
     CancelButton maBtnCancel;
 
+    rtl::OUString maTrue;
+    rtl::OUString maFalse;
+
     rtl::OUString maCalcA1;
     rtl::OUString maExcelA1;
     rtl::OUString maExcelR1C1;
@@ -73,6 +81,9 @@ private:
     rtl::OUString maDescStringRefSyntax;
     rtl::OUString maUseFormulaSyntax;
 
+    rtl::OUString maCaptionEmptyStringAsZero;
+    rtl::OUString maDescEmptyStringAsZero;
+
     ScCalcConfig maConfig;
 };
 
diff --git a/sc/source/ui/optdlg/calcoptionsdlg.src b/sc/source/ui/optdlg/calcoptionsdlg.src
index 58fa750..235ec0e 100644
--- a/sc/source/ui/optdlg/calcoptionsdlg.src
+++ b/sc/source/ui/optdlg/calcoptionsdlg.src
@@ -60,6 +60,20 @@ ModalDialog RID_SCDLG_FORMULA_CALCOPTIONS
         DropDown = TRUE ;
     };
 
+    RadioButton BTN_OPTION_TRUE
+    {
+        Pos = MAP_APPFONT ( 50, 83 ) ;
+        Size = MAP_APPFONT ( 50, 14 ) ;
+        TabStop = TRUE ;
+    };
+
+    RadioButton BTN_OPTION_FALSE
+    {
+        Pos = MAP_APPFONT ( 110, 83 ) ;
+        Size = MAP_APPFONT ( 50, 14 ) ;
+        TabStop = TRUE ;
+    };
+
     FixedLine FL_ANNOTATION
     {
         Pos = MAP_APPFONT ( 6 , 98 ) ;
@@ -103,4 +117,24 @@ ModalDialog RID_SCDLG_FORMULA_CALCOPTIONS
     {
         Text [ en-US ] = "Use formula syntax";
     };
+
+    String STR_EMPTY_STRING_AS_ZERO_CAPTION
+    {
+        Text [ en-US ] = "Treat empty string as zero";
+    };
+
+    String STR_EMPTY_STRING_AS_ZERO_DESC
+    {
+        Text [ en-US ] = "Blah.";
+    };
+
+    String STR_TRUE
+    {
+        Text [ en-US ] = "True";
+    };
+
+    String STR_FALSE
+    {
+        Text [ en-US ] = "False";
+    };
 };


More information about the Libreoffice-commits mailing list