[Libreoffice-commits] .: 2 commits - sc/qa sc/source
Daniel Bankston
dbank at kemper.freedesktop.org
Thu Jul 19 17:42:54 PDT 2012
sc/qa/unit/data/contentCSV/matrix2.csv | 1 +
sc/qa/unit/data/ods/matrix.ods |binary
sc/qa/unit/subsequent_filters-test.cxx | 11 ++++++++++-
sc/source/filter/xml/xmlcelli.cxx | 24 +++++++++++++++++++-----
4 files changed, 30 insertions(+), 6 deletions(-)
New commits:
commit 61c39eae570d6d6040b65bfe93127b30e6080cc8
Author: Daniel Bankston <daniel.e.bankston at gmail.com>
Date: Thu Jul 19 17:26:35 2012 -0500
Display blank cell instead of zero in matrix cells with blank text result
Change-Id: Id9d17403717e42b91b1f45b0a081e2fb5a27c06e
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index ede4131..26d01aa 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -189,7 +189,8 @@ ScXMLTableRowCellContext::ScXMLTableRowCellContext( ScXMLImport& rImport,
bIsEmpty = false;
//if office:value="0", treat like text in case the formula
- //result is "Err:###" or "#N/A" until we confirm otherwise
+ //result is "Err:###", "#N/A", or matrix reference cell with
+ //blank text result until we confirm otherwise.
if(fValue == 0.0)
bFormulaTextResult = true;
}
@@ -1109,9 +1110,21 @@ void ScXMLTableRowCellContext::AddFormulaCell( const ScAddress& rCellPos )
namespace{
-bool isErrOrNA(const rtl::OUString& rStr)
+bool isSpecialValue(const rtl::OUString& rStr, sal_Int16& rnCellType)
{
- return (rStr.indexOf("Err:") > -1) || (rStr.indexOf("#N/A") > -1);
+ if( (rStr.indexOf("Err:") > -1) || (rStr.indexOf("#N/A") > -1) )
+ return true;
+ //If a matrix formula has a matrix reference cell that is intended to have
+ //a blank text result, the matrix reference cell is actually saved(export)
+ //as a float cell with 0 as the value and empty <text:p/>.
+ //Import works around this by setting these cells as text cells so that
+ //the blank text is used for display instead of the number 0.
+ if( rStr.isEmpty() )
+ {
+ rnCellType = util::NumberFormat::TEXT;
+ return true;
+ }
+ return false;
}
}
@@ -1132,8 +1145,9 @@ void ScXMLTableRowCellContext::EndElement()
}
}
- //if this is an "Err:###" or "#N/A" then use text:p value
- if( bFormulaTextResult && pOUTextContent && isErrOrNA(*pOUTextContent) )
+ //if this is a blank matrix formula result, "Err:###", or "#N/A" then
+ //use text:p string because of the way export saves these types of cells.
+ if( bFormulaTextResult && pOUTextContent && isSpecialValue(*pOUTextContent, nCellType) )
pOUTextValue.reset(*pOUTextContent);
ScAddress aCellPos = rXMLImport.GetTables().GetCurrentCellPos();
commit abdffd2e442356782ee6bd947936afc7fb9e4287
Author: Daniel Bankston <daniel.e.bankston at gmail.com>
Date: Thu Jul 19 17:23:06 2012 -0500
Add test case for matrix reference cells with blank text result
Change-Id: If00d424ebe0d82284c3281c3362f2a9e52ee384e
diff --git a/sc/qa/unit/data/contentCSV/matrix2.csv b/sc/qa/unit/data/contentCSV/matrix2.csv
index 955d345..2effd61 100644
--- a/sc/qa/unit/data/contentCSV/matrix2.csv
+++ b/sc/qa/unit/data/contentCSV/matrix2.csv
@@ -3,3 +3,4 @@ Err:502,Err:502,Err:502,,error result
#N/A,#N/A,#N/A,,n/a
TRUE,TRUE,TRUE,,Display TRUE instead of 1
FALSE,FALSE,FALSE,,Display FALSE instead of 0
+42,,42,,Display blank cell instead of 0
diff --git a/sc/qa/unit/data/ods/matrix.ods b/sc/qa/unit/data/ods/matrix.ods
index 2a8c4ab..7d26c2f 100644
Binary files a/sc/qa/unit/data/ods/matrix.ods and b/sc/qa/unit/data/ods/matrix.ods differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 9a3c5dd..6688e0f 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -44,6 +44,7 @@
#include <editeng/borderline.hxx>
#include <dbdata.hxx>
#include "validat.hxx"
+#include "cell.hxx"
#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
#include <com/sun/star/drawing/XControlShape.hpp>
@@ -423,9 +424,17 @@ void ScFiltersTest::testCachedMatrixFormulaResultsODS()
rtl::OUString aCSVFileName;
createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("matrix.")), aCSVFileName);
testFile(aCSVFileName, pDoc, 0);
- //test matrix with errors
+ //test matrices with special cases
createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("matrix2.")), aCSVFileName);
testFile(aCSVFileName, pDoc, 1);
+ //The above testFile() does not catch the below case.
+ //If a matrix formula has a matrix reference cell that is intended to have
+ //a blank text result, the matrix reference cell is actually saved(export)
+ //as a float cell with 0 as the value and an empty <text:p/>.
+ //Import works around this by setting these cells as text cells so that
+ //the blank text is used for display instead of the number 0.
+ //If this is working properly, the following cell should NOT have value data.
+ CPPUNIT_ASSERT(!pDoc->GetCell(ScAddress(3,5,1))->HasValueData());
xDocSh->DoClose();
}
More information about the Libreoffice-commits
mailing list