summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2012-07-17 15:55:38 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2012-07-19 14:05:11 -0400
commitd3629a3942b681fcff006967c50394b3a9c344ee (patch)
treedb2d942f7c334ce0b2180caf47361ec356e2b4be
parentWe no longer need density types. (diff)
downloadcore-d3629a3942b681fcff006967c50394b3a9c344ee.tar.gz
core-d3629a3942b681fcff006967c50394b3a9c344ee.zip
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
-rw-r--r--sc/inc/scmatrix.hxx33
-rw-r--r--sc/qa/unit/ucalc.cxx2
-rw-r--r--sc/source/core/data/cell.cxx8
-rw-r--r--sc/source/core/tool/scmatrix.cxx2
4 files changed, 20 insertions, 25 deletions
diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx
index 409fea56636a..034bc4dbe022 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 1450b845ff41..79cda88126ab 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -1224,7 +1224,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 6ab3d2d1c01a..0e34b3510ccb 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 3b1aecbe4b38..4dfa738ef58b 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.