Kaydet (Commit) 21a3d78c authored tarafından Jan-Marek Glogowski's avatar Jan-Marek Glogowski Kaydeden (comit) Markus Mohrhard

tdf#100458 Don't forcefully change cell type

Just quoting the source comment from the breaking commit
61c39eae.

// 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/>.

Ok

// 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.

This seems to be wrong.

Forcing the cell to a util::NumberFormat::TEXT actually kills
the cell value, if the text is a result of the formular.

I'm not sure if forcefully changing the cell format at this point is
correct at any time, if a cell type was already determinated.

I imagine that an undefined cell type should probably be fixed at the
end of the row import, if Calc detected an error case, or even generally,

This patch is just a minimalistic initial fix. If it's correct, it
probably needs an additional code comment.

Change-Id: If7d9d69467d56c7d8fd2444f9e8b3ae906285264
Reviewed-on: https://gerrit.libreoffice.org/26435Reviewed-by: 's avatarEike Rathke <erack@redhat.com>
Reviewed-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
Tested-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
üst bb01a353
......@@ -215,6 +215,8 @@ public:
void testBnc762542();
void testTdf100458();
CPPUNIT_TEST_SUITE(ScFiltersTest);
CPPUNIT_TEST(testBooleanFormatXLSX);
CPPUNIT_TEST(testBasicCellContentODS);
......@@ -318,6 +320,8 @@ public:
CPPUNIT_TEST(testHiddenSheetsXLSX);
CPPUNIT_TEST(testTdf100458);
CPPUNIT_TEST_SUITE_END();
private:
......@@ -3328,6 +3332,16 @@ void ScFiltersTest::testRelFormulaValidationXLS()
xDocSh->DoClose();
}
void ScFiltersTest::testTdf100458()
{
ScDocShellRef xDocSh = loadDoc("tdf100458_lost_zero_value.", FORMAT_ODS);
CPPUNIT_ASSERT_MESSAGE("Failed to open doc", xDocSh.Is());
ScDocument& rDoc = xDocSh->GetDocument();
CPPUNIT_ASSERT(rDoc.HasValueData(0, 0, 0));
CPPUNIT_ASSERT_EQUAL(double(0.0), rDoc.GetValue(0,0,0));
CPPUNIT_ASSERT(!rDoc.HasStringData(0, 0, 0));
}
ScFiltersTest::ScFiltersTest()
: ScBootstrapFixture( "sc/qa/unit/data" )
{
......
......@@ -1511,7 +1511,6 @@ void ScXMLTableRowCellContext::EndElement()
if( bFormulaTextResult && (mbPossibleErrorCell || mbCheckWithCompilerForError) )
{
maStringValue.reset(GetFirstParagraph());
nCellType = util::NumberFormat::TEXT;
}
ScAddress aCellPos = rXMLImport.GetTables().GetCurrentCellPos();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment