summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/inc/token.hxx6
-rw-r--r--sc/source/core/tool/token.cxx19
2 files changed, 20 insertions, 5 deletions
diff --git a/sc/inc/token.hxx b/sc/inc/token.hxx
index 4662074ce089..63584c70aa43 100644
--- a/sc/inc/token.hxx
+++ b/sc/inc/token.hxx
@@ -381,6 +381,12 @@ public:
/** Reset matrix and upper left, keep matrix
formula dimension. */
void ResetResult();
+
+private:
+
+ /** xUpperLeft is modifiable through SetUpperLeftDouble(), so clone it
+ whenever an svDouble token is assigned to. */
+ void CloneUpperLeftIfNecessary();
};
class SC_DLLPUBLIC ScHybridCellToken : public formula::FormulaToken
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index f9e0cc058cfe..00f1d459613e 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1022,7 +1022,10 @@ void ScMatrixCellResultToken::Assign( const ScMatrixCellResultToken & r )
ScMatrixFormulaCellToken::ScMatrixFormulaCellToken(
SCCOL nC, SCROW nR, const ScConstMatrixRef& pMat, formula::FormulaToken* pUL ) :
- ScMatrixCellResultToken(pMat, pUL), nRows(nR), nCols(nC) {}
+ ScMatrixCellResultToken(pMat, pUL), nRows(nR), nCols(nC)
+{
+ CloneUpperLeftIfNecessary();
+}
ScMatrixFormulaCellToken::ScMatrixFormulaCellToken( SCCOL nC, SCROW nR ) :
ScMatrixCellResultToken(NULL, NULL), nRows(nR), nCols(nC) {}
@@ -1030,10 +1033,7 @@ ScMatrixFormulaCellToken::ScMatrixFormulaCellToken( SCCOL nC, SCROW nR ) :
ScMatrixFormulaCellToken::ScMatrixFormulaCellToken( const ScMatrixFormulaCellToken& r ) :
ScMatrixCellResultToken(r), nRows(r.nRows), nCols(r.nCols)
{
- // xUpperLeft is modifiable through
- // SetUpperLeftDouble(), so clone it.
- if (xUpperLeft)
- xUpperLeft = xUpperLeft->Clone();
+ CloneUpperLeftIfNecessary();
}
ScMatrixFormulaCellToken::~ScMatrixFormulaCellToken() {}
@@ -1045,9 +1045,17 @@ bool ScMatrixFormulaCellToken::operator==( const FormulaToken& r ) const
nCols == p->nCols && nRows == p->nRows;
}
+void ScMatrixFormulaCellToken::CloneUpperLeftIfNecessary()
+{
+ if (xUpperLeft && xUpperLeft->GetType() == svDouble)
+ xUpperLeft = xUpperLeft->Clone();
+}
+
void ScMatrixFormulaCellToken::Assign( const ScMatrixCellResultToken & r )
{
ScMatrixCellResultToken::Assign( r);
+
+ CloneUpperLeftIfNecessary();
}
void ScMatrixFormulaCellToken::Assign( const formula::FormulaToken& r )
@@ -1069,6 +1077,7 @@ void ScMatrixFormulaCellToken::Assign( const formula::FormulaToken& r )
{
xUpperLeft = &r;
xMatrix = NULL;
+ CloneUpperLeftIfNecessary();
}
}
}