From 2321375a0afaeebdc58bf21de56c81a956f3eb81 Mon Sep 17 00:00:00 2001
Message-Id: <2321375a0afaeebdc58bf21de56c81a956f3eb81.1434503702.git.erack@redhat.com>
From: Eike Rathke <erack@redhat.com>
Date: Wed, 17 Jun 2015 00:04:30 +0200
Subject: [PATCH] Resolves: tdf#86305 clone upper left of matrix result if
double token
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------erAck-patch-parts"
This is a multi-part message in MIME format.
--------------erAck-patch-parts
Content-Type: text/plain; charset=UTF-8; format=fixed
Content-Transfer-Encoding: 8bit
(cherry picked from commit ffc1ffed11dc63a69fc2db04f12b3ea266b580fe)
Change-Id: I541577e0b99b0144a755e5755adc890c0ca8d204
---
sc/inc/token.hxx | 6 ++++++
sc/source/core/tool/token.cxx | 19 ++++++++++++++-----
2 files changed, 20 insertions(+), 5 deletions(-)
--------------erAck-patch-parts
Content-Type: text/x-patch; name="0001-Resolves-tdf-86305-clone-upper-left-of-matrix-result.patch"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="0001-Resolves-tdf-86305-clone-upper-left-of-matrix-result.patch"
diff --git a/sc/inc/token.hxx b/sc/inc/token.hxx
index 6c15cbd..2c90350 100644
--- a/sc/inc/token.hxx
+++ b/sc/inc/token.hxx
@@ -404,6 +404,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();
};
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index c4d53c7..4c7edd8 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1082,7 +1082,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) {}
@@ -1090,10 +1093,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();
}
bool ScMatrixFormulaCellToken::operator==( const FormulaToken& r ) const
@@ -1103,9 +1103,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 )
@@ -1127,6 +1135,7 @@ void ScMatrixFormulaCellToken::Assign( const formula::FormulaToken& r )
{
xUpperLeft = &r;
xMatrix = NULL;
+ CloneUpperLeftIfNecessary();
}
}
}
--------------erAck-patch-parts--