[Libreoffice-commits] core.git: sc/qa sc/source
Bartosz Kosiorek
gang65 at poczta.onet.pl
Fri Aug 19 03:12:36 UTC 2016
sc/qa/unit/data/xlsx/xf_default_values.xlsx |binary
sc/qa/unit/subsequent_export-test.cxx | 26 +++++++++++++++++++++++++-
sc/source/filter/oox/stylesbuffer.cxx | 17 ++++++++++++++++-
3 files changed, 41 insertions(+), 2 deletions(-)
New commits:
commit 9b9bcef5ef1858c63c8708bfae2ecea3d398eeb8
Author: Bartosz Kosiorek <gang65 at poczta.onet.pl>
Date: Fri Aug 12 10:51:11 2016 +0200
tdf#70565 Set correct default values to "0" of xfId attribute
When xfId is not exist during .xlsx import
it must have values set to "0".
It is not impacts spreadsheets created with MS Excel,
as xfId attribute is always created during export to .xlsx
Not setting "0" value is causing wrong .xlsx import by LibreOffice,
for spreadsheets created by external applications (ex. SAP BI).
Change-Id: Ia4986236d5e902d0ff6f7a7a8da8f142b2c5061f
Reviewed-on: https://gerrit.libreoffice.org/28069
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
diff --git a/sc/qa/unit/data/xlsx/xf_default_values.xlsx b/sc/qa/unit/data/xlsx/xf_default_values.xlsx
new file mode 100644
index 0000000..79aaea7
Binary files /dev/null and b/sc/qa/unit/data/xlsx/xf_default_values.xlsx differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 8cbb1fa..848fbb8 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -107,6 +107,7 @@ public:
void testFormatExportODS();
void testCustomColumnWidthExportXLSX();
+ void testXfDefaultValuesXLSX();
void testOutlineExportXLSX();
void testHiddenEmptyRowsXLSX();
void testLandscapeOrientationXLSX();
@@ -193,6 +194,7 @@ public:
CPPUNIT_TEST(testFormatExportODS);
CPPUNIT_TEST(testCustomColumnWidthExportXLSX);
+ CPPUNIT_TEST(testXfDefaultValuesXLSX);
CPPUNIT_TEST(testOutlineExportXLSX);
CPPUNIT_TEST(testHiddenEmptyRowsXLSX);
CPPUNIT_TEST(testLandscapeOrientationXLSX);
@@ -471,7 +473,6 @@ void ScExportTest::testFormatExportODS()
xDocSh->DoClose();
}
-
void ScExportTest::testCustomColumnWidthExportXLSX()
{
//tdf#100946 FILESAVE Excel on OS X ignored column widths in XLSX last saved by LO
@@ -564,6 +565,29 @@ void ScExportTest::testCustomColumnWidthExportXLSX()
assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[1]", "customHeight", "false");
}
+void ScExportTest::testXfDefaultValuesXLSX()
+{
+ //tdf#70565 FORMATTING: User Defined Custom Formatting is not applied during importing XLSX documents
+ ScDocShellRef xShell = loadDoc("xf_default_values.", FORMAT_XLSX);
+ CPPUNIT_ASSERT(xShell.Is());
+
+ std::shared_ptr<utl::TempFile> pXPathFile = ScBootstrapFixture::exportTo(&(*xShell), FORMAT_XLSX);
+ xmlDocPtr pSheet = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/styles.xml");
+ CPPUNIT_ASSERT(pSheet);
+
+ // cellStyleXfs don't need xfId, so we need to make sure it is not saved
+ assertXPathNoAttribute(pSheet, "/x:styleSheet/x:cellStyleXfs/x:xf[1]", "xfId");
+
+ // Because numFmtId fontId fillId borderId xfId are not existing during import
+ // it should be created during export, with values set to "0"
+ assertXPath(pSheet, "/x:styleSheet/x:cellXfs/x:xf[1]", "xfId", "0");
+ assertXPath(pSheet, "/x:styleSheet/x:cellXfs/x:xf[2]", "xfId", "0");
+ assertXPath(pSheet, "/x:styleSheet/x:cellXfs/x:xf[3]", "xfId", "0");
+ assertXPath(pSheet, "/x:styleSheet/x:cellXfs/x:xf[4]", "xfId", "0");
+
+ // We expected that exactly 15 cellXfs:xf Nodes will be produced
+ assertXPath(pSheet, "/x:styleSheet/x:cellXfs/x:xf", 14);
+}
void ScExportTest::testOutlineExportXLSX()
{
diff --git a/sc/source/filter/oox/stylesbuffer.cxx b/sc/source/filter/oox/stylesbuffer.cxx
index 456e2a5..f6c765f 100644
--- a/sc/source/filter/oox/stylesbuffer.cxx
+++ b/sc/source/filter/oox/stylesbuffer.cxx
@@ -1982,12 +1982,27 @@ Xf::Xf( const WorkbookHelper& rHelper ) :
void Xf::importXf( const AttributeList& rAttribs, bool bCellXf )
{
maModel.mbCellXf = bCellXf;
- maModel.mnStyleXfId = rAttribs.getInteger( XML_xfId, -1 );
+ // tdf#70565 Set proper default value to "0" of xfId attribute
+ // When xfId is not exist during .xlsx import
+ // it must have values set to "0".
+ // Is is not impacts spreadsheets created with MS Excel,
+ // as xfId attribute is always created during export to .xlsx
+ // Not setting "0" value is causing wrong .xlsx import by LibreOffice,
+ // for spreadsheets created by external applications (ex. SAP BI).
+ if ( maModel.mbCellXf )
+ {
+ maModel.mnStyleXfId = rAttribs.getInteger( XML_xfId, 0 );
+ }
+ else
+ {
+ maModel.mnStyleXfId = rAttribs.getInteger( XML_xfId, -1 );
+ }
maModel.mnFontId = rAttribs.getInteger( XML_fontId, -1 );
maModel.mnNumFmtId = rAttribs.getInteger( XML_numFmtId, -1 );
maModel.mnBorderId = rAttribs.getInteger( XML_borderId, -1 );
maModel.mnFillId = rAttribs.getInteger( XML_fillId, -1 );
+
/* Default value of the apply*** attributes is dependent on context:
true in cellStyleXfs element, false in cellXfs element... */
maModel.mbAlignUsed = rAttribs.getBool( XML_applyAlignment, !maModel.mbCellXf );
More information about the Libreoffice-commits
mailing list