summaryrefslogtreecommitdiff
path: root/sc/inc/scmatrix.hxx
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 /sc/inc/scmatrix.hxx
parentd13804609737114f30dbc7580e4bc76e66cb02a8 (diff)
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
Diffstat (limited to 'sc/inc/scmatrix.hxx')
-rw-r--r--sc/inc/scmatrix.hxx33
1 files changed, 14 insertions, 19 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;
}
};