summaryrefslogtreecommitdiff
path: root/sc/qa/unit
diff options
context:
space:
mode:
authorBartosz Kosiorek <gang65@poczta.onet.pl>2016-10-15 14:36:28 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-10-16 11:33:24 +0000
commit5239cefff56875c7bb45c046977f1724aace0cfb (patch)
treed57e3059486700b56ec92854b3aed275a161fa53 /sc/qa/unit
parent842e503a03bb0f27eb4799ba4a8cb91ab07c3174 (diff)
tdf#46738 Fix exporting .xlsx of coloured empty cells
When spreadsheet contains more that 84 cells, and these cells are empty, but contains additional data (border color, text color, specific formatting), the remaining rows are ignored during export to .xlsx and .xls As a result such empty rows are not saved during export. This patch is fixing most cases and make sure that at least first 84 empty cells will be preserved. It is not impacting the performance as it is still notchecking next columns when the visible cells are more that 84 characters. This patch improve exporting empty cells, but not impacts performance. Change-Id: Ia7027e2c8a2fd48ab4a0e840f970d57167454451 Reviewed-on: https://gerrit.libreoffice.org/29899 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'sc/qa/unit')
-rw-r--r--sc/qa/unit/data/ods/empty_cells_with_background.odsbin0 -> 11058 bytes
-rw-r--r--sc/qa/unit/subsequent_export-test.cxx28
2 files changed, 28 insertions, 0 deletions
diff --git a/sc/qa/unit/data/ods/empty_cells_with_background.ods b/sc/qa/unit/data/ods/empty_cells_with_background.ods
new file mode 100644
index 000000000000..1301bca84489
--- /dev/null
+++ b/sc/qa/unit/data/ods/empty_cells_with_background.ods
Binary files differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 9c451752d3cb..693990dafd69 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -111,6 +111,7 @@ public:
void testXfDefaultValuesXLSX();
void testOutlineExportXLSX();
void testHiddenEmptyRowsXLSX();
+ void testEmptyRowsWithBackgroundColorXLSX();
void testLandscapeOrientationXLSX();
void testInlineArrayXLS();
@@ -202,6 +203,7 @@ public:
CPPUNIT_TEST(testXfDefaultValuesXLSX);
CPPUNIT_TEST(testOutlineExportXLSX);
CPPUNIT_TEST(testHiddenEmptyRowsXLSX);
+ CPPUNIT_TEST(testEmptyRowsWithBackgroundColorXLSX);
CPPUNIT_TEST(testLandscapeOrientationXLSX);
CPPUNIT_TEST(testInlineArrayXLS);
CPPUNIT_TEST(testEmbeddedChartXLS);
@@ -753,6 +755,32 @@ void ScExportTest::testOutlineExportXLSX()
assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row", 30);
}
+void ScExportTest::testEmptyRowsWithBackgroundColorXLSX()
+{
+ // tdf#46738 FILESAVE: Cell background and border color formatting information of empty cells
+ // lost in particular document after FILESAVE as xls and xlsx
+ ScDocShellRef xShell = loadDoc("empty_cells_with_background.", FORMAT_ODS);
+ CPPUNIT_ASSERT(xShell.Is());
+
+ std::shared_ptr<utl::TempFile> pXPathFile = ScBootstrapFixture::exportTo(&(*xShell), FORMAT_XLSX);
+ xmlDocPtr pSheet = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/worksheets/sheet1.xml");
+ CPPUNIT_ASSERT(pSheet);
+
+ // Check if all 100 rows are saved into .xlsx file,
+ // as it contains information about background color information (style)
+ assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[1]", "r", "1");
+ assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[2]", "r", "2");
+ assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[3]", "r", "3");
+ assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[100]", "r", "100");
+ assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row", 100);
+
+ // Check if all 4 column were created
+ assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[100]/x:c[1]", "r", "A100");
+ assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[100]/x:c[2]", "r", "B100");
+ assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[100]/x:c[3]", "r", "C100");
+ assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[100]/x:c[4]", "r", "D100");
+ assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[100]/x:c", 4);
+}
void ScExportTest::testHiddenEmptyRowsXLSX()
{