sc/inc/scmatrix.hxx | 46 +++++++++++---------------------------- sc/qa/unit/ucalc.cxx | 2 - sc/source/core/data/cell.cxx | 8 +++--- sc/source/core/tool/scmatrix.cxx | 2 - 4 files changed, 20 insertions(+), 38 deletions(-)
New commits: commit 1e33865cac30a7cd7d9696bbc91519a95a264aa0 Author: Kohei Yoshida <[email protected]> Date: Tue Jul 17 15:55:38 2012 -0400 It's no longer possible to unionize value and string here... Thereby leaving a note to discourage use of ScMatrixValue. Incidentally, now all the unit test passes. Change-Id: I5d12f8ab654f985ef43b887a22abb6de45fea1fc diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx index 409fea5..034bc4d 100644 --- a/sc/inc/scmatrix.hxx +++ b/sc/inc/scmatrix.hxx @@ -49,16 +49,18 @@ const ScMatValType SC_MATVAL_EMPTY = SC_MATVAL_STRING | 0x04; // STRING plus const ScMatValType SC_MATVAL_EMPTYPATH = SC_MATVAL_EMPTY | 0x08; // EMPTY plus flag const ScMatValType SC_MATVAL_NONVALUE = SC_MATVAL_EMPTYPATH; // mask of all non-value bits +/** + * Try NOT to use this struct. This struct should go away in a hopefully + * not so distant futture. + */ struct ScMatrixValue { - union { - double fVal; - const ::rtl::OUString* pS; - }; + double fVal; + rtl::OUString aStr; ScMatValType nType; /// Only valid if ScMatrix methods indicate so! - const ::rtl::OUString& GetString() const { return pS ? *pS : EMPTY_OUSTRING; } + const ::rtl::OUString& GetString() const { return aStr; } /// Only valid if ScMatrix methods indicate that this is no string! sal_uInt16 GetError() const { return GetDoubleErrorValue( fVal); } @@ -68,12 +70,8 @@ struct ScMatrixValue ScMatrixValue() : fVal(0.0), nType(SC_MATVAL_EMPTY) {} - ScMatrixValue(const ScMatrixValue& r) : fVal(r.fVal), nType(r.nType) - { - if (nType == SC_MATVAL_STRING) - // This is probably not necessary but just in case... - pS = r.pS; - } + ScMatrixValue(const ScMatrixValue& r) : + fVal(r.fVal), aStr(r.aStr), nType(r.nType) {} bool operator== (const ScMatrixValue& r) const { @@ -89,10 +87,8 @@ struct ScMatrixValue default: ; } - if (!pS) - return r.pS == NULL; - return GetString().equals(r.GetString()); + return aStr == r.aStr; } bool operator!= (const ScMatrixValue& r) const @@ -102,13 +98,12 @@ struct ScMatrixValue ScMatrixValue& operator= (const ScMatrixValue& r) { + if (this == &r) + return *this; + nType = r.nType; fVal = r.fVal; - - if (nType == SC_MATVAL_STRING) - // This is probably not necessary but just in case... - pS = r.pS; - + aStr = r.aStr; return *this; } }; diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index ef7c916..8178a47 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -1209,7 +1209,7 @@ struct PartiallyFilledEmptyMatrix else if (nCol == 8 && nRow == 2) { CPPUNIT_ASSERT_MESSAGE("element is not of value type", rVal.nType == SC_MATVAL_STRING); - CPPUNIT_ASSERT_MESSAGE("element value is not what is expected", rVal.pS->equalsAscii("Test")); + CPPUNIT_ASSERT_MESSAGE("element value is not what is expected", rVal.aStr == "Test"); } else if (nCol == 8 && nRow == 11) { diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx index 6ab3d2d..0e34b35 100644 --- a/sc/source/core/data/cell.cxx +++ b/sc/source/core/data/cell.cxx @@ -1926,11 +1926,11 @@ void ScFormulaCell::GetURLResult( rtl::OUString& rURL, rtl::OUString& rCellText if (xMat) { // determine if the matrix result is a string or value. - ScMatrixValue nMatVal = xMat->Get(0, 1); - if (!ScMatrix::IsValueType( nMatVal.nType)) - rURL = nMatVal.GetString(); + if (!xMat->IsValue(0, 1)) + rURL = xMat->GetString(0, 1); else - pFormatter->GetOutputString( nMatVal.fVal, nURLFormat, rURL, &pColor ); + pFormatter->GetOutputString( + xMat->GetDouble(0, 1), nURLFormat, rURL, &pColor); } if(rURL.isEmpty()) diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx index 3b1aecb..4dfa738 100644 --- a/sc/source/core/tool/scmatrix.cxx +++ b/sc/source/core/tool/scmatrix.cxx @@ -740,7 +740,7 @@ ScMatrixValue ScMatrixImpl::Get(SCSIZE nC, SCSIZE nR) const break; case mdds::mtm::element_string: aVal.nType = SC_MATVAL_STRING; - aVal.pS = &EMPTY_OUSTRING; + aVal.aStr = maMat.get_string(nR, nC); break; case mdds::mtm::element_empty: // Empty path equals empty plus flag. commit 4e671bbcfc6b70ada37cf29a3bec7fbc6af20b5b Author: Kohei Yoshida <[email protected]> Date: Tue Jul 17 15:22:52 2012 -0400 We no longer need density types. Change-Id: I4a02e9e025b6004806350fc8c78f6080176df8d6 diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx index e1098c5..409fea5 100644 --- a/sc/inc/scmatrix.hxx +++ b/sc/inc/scmatrix.hxx @@ -131,14 +131,6 @@ class SC_DLLPUBLIC ScMatrix ScMatrix& operator=( const ScMatrix&); public: - enum DensityType - { - FILLED_ZERO, - FILLED_EMPTY, - SPARSE_ZERO, - SPARSE_EMPTY - }; - /** * When adding all numerical matrix elements for a scalar result such as * summation, the interpreter wants to separate the first non-zero value commit 1b081bc369032e13fecccf6737331afc824eff01 Author: Kohei Yoshida <[email protected]> Date: Tue Jul 17 15:15:32 2012 -0400 This is no longer true. Change-Id: Id132c4bb7455acbdaa2287666523f42c20172f37 diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx index 984561e..e1098c5 100644 --- a/sc/inc/scmatrix.hxx +++ b/sc/inc/scmatrix.hxx @@ -117,11 +117,6 @@ struct ScMatrixValue * Matrix data type that can store values of mixed types. Each element can * be one of the following types: numeric, string, boolean, empty, and empty * path. - * - * This class also supports four different density types: filled zero, - * filled empty, sparse zero, and sparse empty. The filled density type - * allocates memory for every single element at all times, whereas the - * sparse density types allocates memory only for non-default elements. */ class SC_DLLPUBLIC ScMatrix { _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
