summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kyoshida@novell.com>2011-05-13 08:35:27 +0300
committerTor Lillqvist <tlillqvist@novell.com>2011-05-13 08:36:01 +0300
commitd8787c0212b6abde83e8ee4557e492172e20ae74 (patch)
tree7c2be20855864c3fdf78948df1bfd5de7c23bbde
parent12e9a40eeb216915f06d296af92d838f4230d827 (diff)
Properly initialize and copy fVal
This fixes the empty value check during unit test for the debug build on (32-bit) Windows. Signed-off-by: Tor Lillqvist <tlillqvist@novell.com>
-rw-r--r--sc/inc/scmatrix.hxx31
1 files changed, 11 insertions, 20 deletions
diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx
index 1568f2a57..bf695225e 100644
--- a/sc/inc/scmatrix.hxx
+++ b/sc/inc/scmatrix.hxx
@@ -67,19 +67,13 @@ struct ScMatrixValue
/// Only valid if ScMatrix methods indicate that this is a boolean
bool GetBoolean() const { return fVal != 0.0; }
- ScMatrixValue() : pS(NULL), nType(SC_MATVAL_EMPTY) {}
+ ScMatrixValue() : fVal(0.0), nType(SC_MATVAL_EMPTY) {}
- ScMatrixValue(const ScMatrixValue& r) : nType(r.nType)
+ ScMatrixValue(const ScMatrixValue& r) : fVal(r.fVal), nType(r.nType)
{
- switch (nType)
- {
- case SC_MATVAL_VALUE:
- case SC_MATVAL_BOOLEAN:
- fVal = r.fVal;
- break;
- default:
- pS = r.pS;
- }
+ if (nType == SC_MATVAL_STRING)
+ // This is probably not necessary but just in case...
+ pS = r.pS;
}
bool operator== (const ScMatrixValue& r) const
@@ -110,15 +104,12 @@ struct ScMatrixValue
ScMatrixValue& operator= (const ScMatrixValue& r)
{
nType = r.nType;
- switch (nType)
- {
- case SC_MATVAL_VALUE:
- case SC_MATVAL_BOOLEAN:
- fVal = r.fVal;
- break;
- default:
- pS = r.pS;
- }
+ fVal = r.fVal;
+
+ if (nType == SC_MATVAL_STRING)
+ // This is probably not necessary but just in case...
+ pS = r.pS;
+
return *this;
}
};