[Libreoffice-commits] .: Branch 'feature/calc-empty-string-config' - 5 commits - officecfg/registry sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Mon Jul 23 18:17:02 PDT 2012


 officecfg/registry/schema/org/openoffice/Office/Calc.xcs |    8 +++
 sc/source/core/tool/formulaopt.cxx                       |   33 +++++++++++----
 sc/source/core/tool/interpr4.cxx                         |   29 +++++++------
 sc/source/ui/optdlg/calcoptionsdlg.cxx                   |    3 -
 sc/source/ui/optdlg/calcoptionsdlg.hxx                   |    2 
 5 files changed, 54 insertions(+), 21 deletions(-)

New commits:
commit 1a37fe6ac99b8520ee2f47dfcb0d8eadcfbe6802
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 e439191345627ff2178387e0ebf5938484714192
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 06fdef1658f35bf1ef331c592fd58bf59d378e84
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 3bc73056876b0554f83a08353817f4f1a484f81f
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 37a6664d1aa612b9fdd244f2bd31cd7280db5562
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">


More information about the Libreoffice-commits mailing list