summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBartosz Kosiorek <gang65@poczta.onet.pl>2016-08-12 10:51:11 +0200
committerEike Rathke <erack@redhat.com>2016-12-05 17:43:06 +0000
commitc88c3f66984df5ac4ca65431e7eacbeb93cb2217 (patch)
tree4cf7761d9959d344efeffcbfea89b84d1d6da24f
parent517eddcbfd8dd5d6da50210a12ba917998897bbf (diff)
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@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com> (cherry picked from commit 9b9bcef5ef1858c63c8708bfae2ecea3d398eeb8) Reviewed-on: https://gerrit.libreoffice.org/31647 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
-rw-r--r--sc/qa/unit/data/xlsx/xf_default_values.xlsxbin0 -> 11280 bytes
-rw-r--r--sc/qa/unit/subsequent_export-test.cxx26
-rw-r--r--sc/source/filter/oox/stylesbuffer.cxx1
3 files changed, 26 insertions, 1 deletions
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 000000000000..79aaea7c90fd
--- /dev/null
+++ b/sc/qa/unit/data/xlsx/xf_default_values.xlsx
Binary files differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 75ac9d3e8431..758c86bb3a80 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -111,6 +111,7 @@ public:
void testFormatExportODS();
void testCustomColumnWidthExportXLSX();
+ void testXfDefaultValuesXLSX();
void testOutlineExportXLSX();
void testHiddenEmptyRowsXLSX();
void testLandscapeOrientationXLSX();
@@ -198,6 +199,7 @@ public:
CPPUNIT_TEST(testFormatExportODS);
CPPUNIT_TEST(testCustomColumnWidthExportXLSX);
+ CPPUNIT_TEST(testXfDefaultValuesXLSX);
CPPUNIT_TEST(testOutlineExportXLSX);
CPPUNIT_TEST(testHiddenEmptyRowsXLSX);
CPPUNIT_TEST(testLandscapeOrientationXLSX);
@@ -479,7 +481,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
@@ -572,6 +573,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 3f73c091a5ea..6818f03ba454 100644
--- a/sc/source/filter/oox/stylesbuffer.cxx
+++ b/sc/source/filter/oox/stylesbuffer.cxx
@@ -2092,6 +2092,7 @@ void Xf::importXf( const AttributeList& rAttribs, bool bCellXf )
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 );