sc/inc/calcconfig.hxx                  |   10 +++++-----
 sc/inc/formulacell.hxx                 |    7 ++++++-
 sc/inc/formulagroup.hxx                |   11 +++++++++--
 sc/qa/unit/ucalc.cxx                   |   12 ++++++------
 sc/source/core/data/formulacell.cxx    |    5 +++++
 sc/source/core/tool/calcconfig.cxx     |   20 ++++++++++++++++++--
 sc/source/core/tool/formulagroup.cxx   |    6 ++++++
 sc/source/core/tool/formulaopt.cxx     |   16 ++++++++--------
 sc/source/core/tool/interpr4.cxx       |   14 +++++++-------
 sc/source/ui/optdlg/calcoptionsdlg.cxx |   10 +++++-----
 10 files changed, 75 insertions(+), 36 deletions(-)

New commits:
commit 9429cf24675ae6b3a954db560ca567c9413d0ab6
Author: Tor Lillqvist <t...@collabora.com>
Date:   Sat Feb 7 15:38:55 2015 +0200

    We (will) need ScCalcConfig also for formula groups
    
    The settings for interpretation of text (string) cells as numbers affect
    whether OpenCL can be used or not to get expected results, when operating on
    vectors that contain also text cells.
    
    Change-Id: I0a7fd657038846ba762aa6ee6a95c001aea8f124

diff --git a/sc/inc/formulagroup.hxx b/sc/inc/formulagroup.hxx
index aa6699a..a7dba2b 100644
--- a/sc/inc/formulagroup.hxx
+++ b/sc/inc/formulagroup.hxx
@@ -13,6 +13,7 @@
 #include <config_features.h>
 
 #include "address.hxx"
+#include "calcconfig.hxx"
 #include "types.hxx"
 #include "stlalgorithm.hxx"
 
@@ -120,11 +121,17 @@ public:
 class SC_DLLPUBLIC FormulaGroupInterpreter
 {
     static FormulaGroupInterpreter *msInstance;
- protected:
+
+protected:
+    ScCalcConfig maCalcConfig;
+
     FormulaGroupInterpreter() {}
     virtual ~FormulaGroupInterpreter() {}
 
- public:
+    /// Merge global and document specific settings.
+    void MergeCalcConfig(const ScDocument& rDoc);
+
+public:
     static FormulaGroupInterpreter *getStatic();
 #if HAVE_FEATURE_OPENCL
     static void fillOpenCLInfo(std::vector<OpenCLPlatformInfo>& rPlatforms);
diff --git a/sc/source/core/tool/formulagroup.cxx 
b/sc/source/core/tool/formulagroup.cxx
index 306a3ea..dfa3689 100644
--- a/sc/source/core/tool/formulagroup.cxx
+++ b/sc/source/core/tool/formulagroup.cxx
@@ -464,6 +464,12 @@ bool 
FormulaGroupInterpreterSoftware::interpret(ScDocument& rDoc, const ScAddres
 
 FormulaGroupInterpreter *FormulaGroupInterpreter::msInstance = NULL;
 
+void FormulaGroupInterpreter::MergeCalcConfig(const ScDocument& rDoc)
+{
+    maCalcConfig = ScInterpreter::GetGlobalConfig();
+    maCalcConfig.MergeDocumentSpecific(rDoc.GetCalcConfig());
+}
+
 /// load and/or configure the correct formula group interpreter
 FormulaGroupInterpreter *FormulaGroupInterpreter::getStatic()
 {
commit 0608c2cbfe8697f9912397afce2987bee23fd1ce
Author: Tor Lillqvist <t...@collabora.com>
Date:   Sat Feb 7 14:04:53 2015 +0200

    Turn StringConversion into a C++11 scoped enumeration
    
    Change-Id: I353a62bac6c8bf00b20c93d9778fc45ade5d502c

diff --git a/sc/inc/calcconfig.hxx b/sc/inc/calcconfig.hxx
index 7cc8fad..314aa95 100644
--- a/sc/inc/calcconfig.hxx
+++ b/sc/inc/calcconfig.hxx
@@ -33,12 +33,12 @@ enum ScRecalcOptions
 struct SC_DLLPUBLIC ScCalcConfig
 {
     // from most stringent to most relaxed
-    enum StringConversion
+    enum class StringConversion
     {
-        STRING_CONVERSION_AS_ERROR = 0,     ///<  =1+"1" or =1+"x" give #VALUE!
-        STRING_CONVERSION_AS_ZERO,          ///<  =1+"1" or =1+"x" give 1
-        STRING_CONVERSION_UNAMBIGUOUS,      ///<  =1+"1" gives 2, but 
=1+"1.000" or =1+"x" give #VALUE!
-        STRING_CONVERSION_LOCALE_DEPENDENT  ///<  =1+"1.000" may be 2 or 1001 
... =1+"x" gives #VALUE!
+        ERROR,            ///<  =1+"1" or =1+"x" give #VALUE!
+        ZERO,             ///<  =1+"1" or =1+"x" give 1
+        UNAMBIGUOUS,      ///<  =1+"1" gives 2, but =1+"1.000" or =1+"x" give 
#VALUE!
+        LOCALE            ///<  =1+"1.000" may be 2 or 1001 ... =1+"x" gives 
#VALUE!
     };
     formula::FormulaGrammar::AddressConvention meStringRefAddressSyntax;
     StringConversion meStringConversion;
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index b839816..df258bc 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -1534,7 +1534,7 @@ void Test::testFuncParam()
     ScCalcConfig aConfig;
 
     // With "Convert also locale dependent" and "Empty string as zero"=True 
option.
-    aConfig.meStringConversion = 
ScCalcConfig::STRING_CONVERSION_LOCALE_DEPENDENT;
+    aConfig.meStringConversion = ScCalcConfig::StringConversion::LOCALE;
     aConfig.mbEmptyStringAsZero = true;
     m_pDoc->SetCalcConfig(aConfig);
     m_pDoc->CalcAll();
@@ -1550,7 +1550,7 @@ void Test::testFuncParam()
     CPPUNIT_ASSERT_MESSAGE("incorrect result", val == 7.4);
 
     // With "Convert also locale dependent" and "Empty string as zero"=False 
option.
-    aConfig.meStringConversion = 
ScCalcConfig::STRING_CONVERSION_LOCALE_DEPENDENT;
+    aConfig.meStringConversion = ScCalcConfig::StringConversion::LOCALE;
     aConfig.mbEmptyStringAsZero = false;
     m_pDoc->SetCalcConfig(aConfig);
     m_pDoc->CalcAll();
@@ -1566,7 +1566,7 @@ void Test::testFuncParam()
     CPPUNIT_ASSERT_MESSAGE("incorrect result", val == 7.4);
 
     // With "Convert only unambiguous" and "Empty string as zero"=True option.
-    aConfig.meStringConversion = ScCalcConfig::STRING_CONVERSION_UNAMBIGUOUS;
+    aConfig.meStringConversion = ScCalcConfig::StringConversion::UNAMBIGUOUS;
     aConfig.mbEmptyStringAsZero = true;
     m_pDoc->SetCalcConfig(aConfig);
     m_pDoc->CalcAll();
@@ -1582,7 +1582,7 @@ void Test::testFuncParam()
     CPPUNIT_ASSERT_MESSAGE("incorrect result", aVal == "#VALUE!");
 
     // With "Convert only unambiguous" and "Empty string as zero"=False option.
-    aConfig.meStringConversion = ScCalcConfig::STRING_CONVERSION_UNAMBIGUOUS;
+    aConfig.meStringConversion = ScCalcConfig::StringConversion::UNAMBIGUOUS;
     aConfig.mbEmptyStringAsZero = false;
     m_pDoc->SetCalcConfig(aConfig);
     m_pDoc->CalcAll();
@@ -1598,7 +1598,7 @@ void Test::testFuncParam()
     CPPUNIT_ASSERT_MESSAGE("incorrect result", aVal == "#VALUE!");
 
     // With "Treat as zero" ("Empty string as zero" is ignored).
-    aConfig.meStringConversion = ScCalcConfig::STRING_CONVERSION_AS_ZERO;
+    aConfig.meStringConversion = ScCalcConfig::StringConversion::ZERO;
     aConfig.mbEmptyStringAsZero = true;
     m_pDoc->SetCalcConfig(aConfig);
     m_pDoc->CalcAll();
@@ -1614,7 +1614,7 @@ void Test::testFuncParam()
     CPPUNIT_ASSERT_MESSAGE("incorrect result", val == 3);
 
     // With "Generate #VALUE! error" ("Empty string as zero" is ignored).
-    aConfig.meStringConversion = ScCalcConfig::STRING_CONVERSION_AS_ERROR;
+    aConfig.meStringConversion = ScCalcConfig::StringConversion::ERROR;
     aConfig.mbEmptyStringAsZero = false;
     m_pDoc->SetCalcConfig(aConfig);
     m_pDoc->CalcAll();
diff --git a/sc/source/core/tool/calcconfig.cxx 
b/sc/source/core/tool/calcconfig.cxx
index b4cdb8c..bcea83f 100644
--- a/sc/source/core/tool/calcconfig.cxx
+++ b/sc/source/core/tool/calcconfig.cxx
@@ -22,7 +22,7 @@
 
 ScCalcConfig::ScCalcConfig() :
     meStringRefAddressSyntax(formula::FormulaGrammar::CONV_UNSPECIFIED),
-    meStringConversion(STRING_CONVERSION_LOCALE_DEPENDENT),     // old 
LibreOffice behavior
+    meStringConversion(StringConversion::LOCALE),     // old LibreOffice 
behavior
     mbEmptyStringAsZero(false)
 {
     setOpenCLConfigToDefault();
@@ -105,10 +105,10 @@ std::string 
StringConversionToString(ScCalcConfig::StringConversion eConv)
 {
     switch (eConv)
     {
-    case ScCalcConfig::STRING_CONVERSION_AS_ERROR: return "ERROR";
-    case ScCalcConfig::STRING_CONVERSION_AS_ZERO: return "ZERO";
-    case ScCalcConfig::STRING_CONVERSION_UNAMBIGUOUS: return "UNAMBIGUOUS";
-    case ScCalcConfig::STRING_CONVERSION_LOCALE_DEPENDENT: return "LOCALE";
+    case ScCalcConfig::StringConversion::ERROR: return "ERROR";
+    case ScCalcConfig::StringConversion::ZERO: return "ZERO";
+    case ScCalcConfig::StringConversion::UNAMBIGUOUS: return "UNAMBIGUOUS";
+    case ScCalcConfig::StringConversion::LOCALE: return "LOCALE";
     default: return std::to_string((int) eConv);
     }
 }
diff --git a/sc/source/core/tool/formulaopt.cxx 
b/sc/source/core/tool/formulaopt.cxx
index cd12d0a..e9e4748 100644
--- a/sc/source/core/tool/formulaopt.cxx
+++ b/sc/source/core/tool/formulaopt.cxx
@@ -387,16 +387,16 @@ void ScFormulaCfg::UpdateFromProperties( const 
Sequence<OUString>& aNames )
                         switch (nIntVal)
                         {
                             case 0:
-                                eConv = 
ScCalcConfig::STRING_CONVERSION_AS_ERROR;
+                                eConv = ScCalcConfig::StringConversion::ERROR;
                             break;
                             case 1:
-                                eConv = 
ScCalcConfig::STRING_CONVERSION_AS_ZERO;
+                                eConv = ScCalcConfig::StringConversion::ZERO;
                             break;
                             case 2:
-                                eConv = 
ScCalcConfig::STRING_CONVERSION_UNAMBIGUOUS;
+                                eConv = 
ScCalcConfig::StringConversion::UNAMBIGUOUS;
                             break;
                             case 3:
-                                eConv = 
ScCalcConfig::STRING_CONVERSION_LOCALE_DEPENDENT;
+                                eConv = ScCalcConfig::StringConversion::LOCALE;
                             break;
                             default:
                                 SAL_WARN("sc", "unknown string conversion 
option!");
@@ -558,10 +558,10 @@ void ScFormulaCfg::Commit()
                 sal_Int32 nVal = 3;
                 switch (GetCalcConfig().meStringConversion)
                 {
-                    case ScCalcConfig::STRING_CONVERSION_AS_ERROR:          
nVal = 0; break;
-                    case ScCalcConfig::STRING_CONVERSION_AS_ZERO:           
nVal = 1; break;
-                    case ScCalcConfig::STRING_CONVERSION_UNAMBIGUOUS:       
nVal = 2; break;
-                    case ScCalcConfig::STRING_CONVERSION_LOCALE_DEPENDENT:  
nVal = 3; break;
+                case ScCalcConfig::StringConversion::ERROR:       nVal = 0; 
break;
+                case ScCalcConfig::StringConversion::ZERO:        nVal = 1; 
break;
+                case ScCalcConfig::StringConversion::UNAMBIGUOUS: nVal = 2; 
break;
+                case ScCalcConfig::StringConversion::LOCALE:      nVal = 3; 
break;
                 }
                 pValues[nProp] <<= nVal;
             }
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 81ec490..70a6b87 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -207,7 +207,7 @@ bool isEmptyString( const OUString& rStr )
 /** Convert string content to numeric value.
 
     Depending on the string conversion configuration different approaches are
-    taken. For ScCalcConfig::STRING_CONVERSION_UNAMBIGUOUS if the string is not
+    taken. For ScCalcConfig::StringConversion::UNAMBIGUOUS if the string is not
     empty the following conversion rules are applied:
 
     Converted are only integer numbers including exponent, and ISO 8601 dates
@@ -240,7 +240,7 @@ bool isEmptyString( const OUString& rStr )
 
 double ScInterpreter::ConvertStringToValue( const OUString& rStr )
 {
-    // We keep ScCalcConfig::STRING_CONVERSION_LOCALE_DEPENDENT default until
+    // We keep ScCalcConfig::StringConversion::LOCALE default until
     // we provide a friendly way to convert string numbers into numbers in the 
UI.
 
     double fValue = 0.0;
@@ -253,19 +253,19 @@ double ScInterpreter::ConvertStringToValue( const 
OUString& rStr )
 
     switch (maCalcConfig.meStringConversion)
     {
-        case ScCalcConfig::STRING_CONVERSION_AS_ERROR:
+        case ScCalcConfig::StringConversion::ERROR:
             SetError( mnStringNoValueError);
             return fValue;
-        case ScCalcConfig::STRING_CONVERSION_AS_ZERO:
+        case ScCalcConfig::StringConversion::ZERO:
             return fValue;
-        case ScCalcConfig::STRING_CONVERSION_LOCALE_DEPENDENT:
+        case ScCalcConfig::StringConversion::LOCALE:
             {
                 if (maCalcConfig.mbEmptyStringAsZero)
                 {
                     // 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
-                    // STRING_CONVERSION_UNAMBIGUOUS branch) and convert to 0 
to prevent
+                    // StringConversion::UNAMBIGUOUS branch) and convert to 0 
to prevent
                     // interoperability nightmares.
 
                     if (isEmptyString( rStr))
@@ -281,7 +281,7 @@ double ScInterpreter::ConvertStringToValue( const OUString& 
rStr )
                 return fValue;
             }
             break;
-        case ScCalcConfig::STRING_CONVERSION_UNAMBIGUOUS:
+        case ScCalcConfig::StringConversion::UNAMBIGUOUS:
             {
                 if (!maCalcConfig.mbEmptyStringAsZero)
                 {
diff --git a/sc/source/ui/optdlg/calcoptionsdlg.cxx 
b/sc/source/ui/optdlg/calcoptionsdlg.cxx
index 0eada39..7db6ae8 100644
--- a/sc/source/ui/optdlg/calcoptionsdlg.cxx
+++ b/sc/source/ui/optdlg/calcoptionsdlg.cxx
@@ -71,7 +71,7 @@ ScCalcOptionsDialog::ScCalcOptionsDialog(vcl::Window* 
pParent, const ScCalcConfi
     get(mpFtMemory, "memory");
 
     get(mpConversion,"comboConversion");
-    mpConversion->SelectEntryPos(rConfig.meStringConversion, true);
+    
mpConversion->SelectEntryPos(static_cast<sal_Int32>(rConfig.meStringConversion),
 true);
     mpConversion->SetSelectHdl(LINK(this, ScCalcOptionsDialog, 
ConversionModifiedHdl));
 
     get(mpEmptyAsZero,"checkEmptyAsZero");
@@ -168,18 +168,18 @@ IMPL_LINK(ScCalcOptionsDialog, ConversionModifiedHdl, 
ListBox*, pConv )
   maConfig.meStringConversion = 
(ScCalcConfig::StringConversion)pConv->GetSelectEntryPos();
     switch (maConfig.meStringConversion)
     {
-         case ScCalcConfig::STRING_CONVERSION_AS_ERROR:
+         case ScCalcConfig::StringConversion::ERROR:
                     maConfig.mbEmptyStringAsZero = false;
                     mpEmptyAsZero->Check(false);
                     mpEmptyAsZero->Enable(false);
          break;
-         case ScCalcConfig::STRING_CONVERSION_AS_ZERO:
+         case ScCalcConfig::StringConversion::ZERO:
                     maConfig.mbEmptyStringAsZero = true;
                     mpEmptyAsZero->Check(true);
                     mpEmptyAsZero->Enable(false);
          break;
-         case ScCalcConfig::STRING_CONVERSION_UNAMBIGUOUS:
-         case ScCalcConfig::STRING_CONVERSION_LOCALE_DEPENDENT:
+         case ScCalcConfig::StringConversion::UNAMBIGUOUS:
+         case ScCalcConfig::StringConversion::LOCALE:
                     // Reset to the value the user selected before.
                     maConfig.mbEmptyStringAsZero = mbSelectedEmptyStringAsZero;
                     mpEmptyAsZero->Enable(true);
commit 590624fb2ba1daaa2730c5b1d633c089565f6e8f
Author: Tor Lillqvist <t...@collabora.com>
Date:   Sat Feb 7 13:49:51 2015 +0200

    Output meStringConversion symbolically
    
    Change-Id: Ibcd8cb12525fbce33fbfd208ee8e357c904ffd4f

diff --git a/sc/source/core/tool/calcconfig.cxx 
b/sc/source/core/tool/calcconfig.cxx
index 0023910..b4cdb8c 100644
--- a/sc/source/core/tool/calcconfig.cxx
+++ b/sc/source/core/tool/calcconfig.cxx
@@ -99,11 +99,27 @@ bool ScCalcConfig::operator!= (const ScCalcConfig& r) const
     return !operator==(r);
 }
 
+namespace {
+
+std::string StringConversionToString(ScCalcConfig::StringConversion eConv)
+{
+    switch (eConv)
+    {
+    case ScCalcConfig::STRING_CONVERSION_AS_ERROR: return "ERROR";
+    case ScCalcConfig::STRING_CONVERSION_AS_ZERO: return "ZERO";
+    case ScCalcConfig::STRING_CONVERSION_UNAMBIGUOUS: return "UNAMBIGUOUS";
+    case ScCalcConfig::STRING_CONVERSION_LOCALE_DEPENDENT: return "LOCALE";
+    default: return std::to_string((int) eConv);
+    }
+}
+
+} // anonymous namespace
+
 std::ostream& operator<<(std::ostream& rStream, const ScCalcConfig& rConfig)
 {
     rStream << "{"
         "StringRefAddressSyntax=" << rConfig.meStringRefAddressSyntax << ","
-        "StringConversion=" << rConfig.meStringConversion << ","
+        "StringConversion=" << 
StringConversionToString(rConfig.meStringConversion) << ","
         "EmptyStringAsZero=" << (rConfig.mbEmptyStringAsZero?"Y":"N") << ","
         "OpenCLSubsetOnly=" << (rConfig.mbOpenCLSubsetOnly?"Y":"N") << ","
         "OpenCLAutoSelect=" << (rConfig.mbOpenCLAutoSelect?"Y":"N") << ","
commit 4f4daf163e92d113b62cc19fb0b7f5ec05dce48a
Author: Tor Lillqvist <t...@collabora.com>
Date:   Fri Feb 6 20:53:59 2015 +0200

    Introduce SetResultError()
    
    Change-Id: I0645b7a58e9f3dfc6c431844805ab87add8745ad

diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index 143ae29..7b7ed09 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -376,7 +376,12 @@ public:
 
     svl::SharedString GetResultString() const;
 
-    void            SetErrCode( sal_uInt16 n );
+    /* Sets the shared code array to error state in addition to the cell 
result */
+    void SetErrCode( sal_uInt16 n );
+
+    /* Sets just the result to error */
+    void SetResultError( sal_uInt16 n );
+
     bool IsHyperLinkCell() const;
     EditTextObject* CreateURLObject();
     void GetURLResult( OUString& rURL, OUString& rCellText );
diff --git a/sc/source/core/data/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index 938fd4d..d37b177 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -2249,6 +2249,11 @@ void ScFormulaCell::SetErrCode( sal_uInt16 n )
     aResult.SetResultError( n );
 }
 
+void ScFormulaCell::SetResultError( sal_uInt16 n )
+{
+    aResult.SetResultError( n );
+}
+
 void ScFormulaCell::AddRecalcMode( ScRecalcMode nBits )
 {
     if ( (nBits & RECALCMODE_EMASK) != RECALCMODE_NORMAL )
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to