summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2015-02-11 21:47:23 +0100
committerAndras Timar <andras.timar@collabora.com>2015-02-23 10:35:21 +0100
commit2f0c969bf89e11fbcfc16b5d52bfd3ef9548983f (patch)
treef391fa2572f6ea580e668a94ba453e9c0b7ecd75 /sc
parentde0412a496454b23d0c65e1bb8f9d4badfd953d7 (diff)
Resolves: tdf#39316 add matrix empty cells to ScInterpreter::QueryMatrixType()
(cherry picked from commit eccbc97c7c224269fe261b8924e7866c3758ec91) add ScMatrix::IsEmptyResult() for tdf#39316 fix preparation (cherry picked from commit cf3f1d8dfeb45249eb60a30dba3243fe9a4a65e5) 9f2a3e6fa9f4ef43df672661afef996269b90a7a Change-Id: Ifa5d59e90afcfff66f2e8683fac2a9090ed615da Reviewed-on: https://gerrit.libreoffice.org/14430 Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com> (cherry picked from commit 5b952ced5b2ae6151079206c3e397de653f0ced2)
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/scmatrix.hxx9
-rw-r--r--sc/source/core/tool/interpr4.cxx10
-rw-r--r--sc/source/core/tool/scmatrix.cxx23
3 files changed, 35 insertions, 7 deletions
diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx
index 851caa474373..aebe0e79a83c 100644
--- a/sc/inc/scmatrix.hxx
+++ b/sc/inc/scmatrix.hxx
@@ -322,13 +322,16 @@ public:
/// @return <TRUE/> if string or empty or empty path, in fact non-value.
bool IsString( SCSIZE nC, SCSIZE nR ) const;
- /// @return <TRUE/> if empty or empty path.
+ /// @return <TRUE/> if empty or empty cell or empty result, not empty path.
bool IsEmpty( SCSIZE nC, SCSIZE nR ) const;
- /// @return <TRUE/> if empty, not empty result or empty path.
+ /// @return <TRUE/> if empty cell, not empty or empty result or empty path.
bool IsEmptyCell( SCSIZE nC, SCSIZE nR ) const;
- /// @return <TRUE/> if empty path.
+ /// @return <TRUE/> if empty result, not empty or empty cell or empty path.
+ bool IsEmptyResult( SCSIZE nC, SCSIZE nR ) const;
+
+ /// @return <TRUE/> if empty path, not empty or empty cell or empty result.
bool IsEmptyPath( SCSIZE nC, SCSIZE nR ) const;
/// @return <TRUE/> if value or boolean.
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 58bc0046148a..473f40d6381c 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -1879,6 +1879,16 @@ void ScInterpreter::QueryMatrixType(ScMatrixRef& xMat, short& rRetTypeExpr, sal_
PushTempToken( new ScMatrixFormulaCellToken(nCols, nRows, xMat, xRes.get()));
rRetTypeExpr = NUMBERFORMAT_LOGICAL;
}
+ else if ( xMat->IsEmptyResult( 0, 0))
+ { // empty formula result
+ FormulaTokenRef xRes = new ScEmptyCellToken( true, true); // inherited, display empty
+ PushTempToken( new ScMatrixFormulaCellToken(nCols, nRows, xMat, xRes.get()));
+ }
+ else if ( xMat->IsEmpty( 0, 0))
+ { // empty or empty cell
+ FormulaTokenRef xRes = new ScEmptyCellToken( false, true); // not inherited, display empty
+ PushTempToken( new ScMatrixFormulaCellToken(nCols, nRows, xMat, xRes.get()));
+ }
else
{
svl::SharedString aStr( nMatVal.GetString());
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index b71cc1dd6e28..9afb2a6562b7 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -254,6 +254,7 @@ public:
bool IsString( SCSIZE nC, SCSIZE nR ) const;
bool IsEmpty( SCSIZE nC, SCSIZE nR ) const;
bool IsEmptyCell( SCSIZE nC, SCSIZE nR ) const;
+ bool IsEmptyResult( SCSIZE nC, SCSIZE nR ) const;
bool IsEmptyPath( SCSIZE nC, SCSIZE nR ) const;
bool IsValue( SCSIZE nIndex ) const;
bool IsValue( SCSIZE nC, SCSIZE nR ) const;
@@ -686,8 +687,8 @@ bool ScMatrixImpl::IsString( SCSIZE nC, SCSIZE nR ) const
bool ScMatrixImpl::IsEmpty( SCSIZE nC, SCSIZE nR ) const
{
- // Flag must indicate an empty element instead of an
- // 'empty path' element.
+ // Flag must indicate an 'empty' or 'empty cell' or 'empty result' element,
+ // but not an 'empty path' element.
ValidColRowReplicated( nC, nR );
return maMat.get_type(nR, nC) == mdds::mtm::element_empty &&
maMatFlag.get<TMatFlag>(nR, nC) != SC_MATFLAG_EMPTYPATH;
@@ -695,13 +696,22 @@ bool ScMatrixImpl::IsEmpty( SCSIZE nC, SCSIZE nR ) const
bool ScMatrixImpl::IsEmptyCell( SCSIZE nC, SCSIZE nR ) const
{
- // Flag must indicate an 'empty' element instead of an
- // 'empty result' or 'empty path' element.
+ // Flag must indicate an 'empty cell' element instead of an
+ // 'empty' or 'empty result' or 'empty path' element.
ValidColRowReplicated( nC, nR );
return maMat.get_type(nR, nC) == mdds::mtm::element_empty &&
maMatFlag.get<TMatFlag>(nR, nC) == SC_MATFLAG_EMPTYCELL;
}
+bool ScMatrixImpl::IsEmptyResult( SCSIZE nC, SCSIZE nR ) const
+{
+ // Flag must indicate an 'empty result' element instead of an
+ // 'empty' or 'empty cell' or 'empty path' element.
+ ValidColRowReplicated( nC, nR );
+ return maMat.get_type(nR, nC) == mdds::mtm::element_empty &&
+ maMatFlag.get<TMatFlag>(nR, nC) == SC_MATFLAG_EMPTYRESULT;
+}
+
bool ScMatrixImpl::IsEmptyPath( SCSIZE nC, SCSIZE nR ) const
{
// Flag must indicate an 'empty path' element.
@@ -2117,6 +2127,11 @@ bool ScMatrix::IsEmptyCell( SCSIZE nC, SCSIZE nR ) const
return pImpl->IsEmptyCell(nC, nR);
}
+bool ScMatrix::IsEmptyResult( SCSIZE nC, SCSIZE nR ) const
+{
+ return pImpl->IsEmptyResult(nC, nR);
+}
+
bool ScMatrix::IsEmptyPath( SCSIZE nC, SCSIZE nR ) const
{
return pImpl->IsEmptyPath(nC, nR);