diff options
-rw-r--r-- | sc/qa/unit/data/ods/empty_cells_with_background.ods | bin | 0 -> 11058 bytes | |||
-rw-r--r-- | sc/qa/unit/subsequent_export-test.cxx | 28 | ||||
-rw-r--r-- | sc/source/core/data/attarray.cxx | 11 |
3 files changed, 35 insertions, 4 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 Binary files differnew file mode 100644 index 000000000000..1301bca84489 --- /dev/null +++ b/sc/qa/unit/data/ods/empty_cells_with_background.ods 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() { diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx index fb90fb435cb4..cf5426266de2 100644 --- a/sc/source/core/data/attarray.cxx +++ b/sc/source/core/data/attarray.cxx @@ -1815,7 +1815,7 @@ bool ScAttrArray::GetFirstVisibleAttr( SCROW& rFirstRow ) const return bFound; } -// size (rows) of a range of attributes after cell content where the search is stopped +// Number of rows after the search will be stopped // (more than a default page size, 2*42 because it's as good as any number) const SCROW SC_VISATTR_STOP = 84; @@ -1860,13 +1860,16 @@ bool ScAttrArray::GetLastVisibleAttr( SCROW& rLastRow, SCROW nLastData ) const if ( nAttrStartRow <= nLastData ) nAttrStartRow = nLastData + 1; SCROW nAttrSize = pData[nEndPos].nRow + 1 - nAttrStartRow; - if ( nAttrSize >= SC_VISATTR_STOP ) - break; // while, ignore this range and below - else if ( pData[nEndPos].pPattern->IsVisible() ) + if ( pData[nEndPos].pPattern->IsVisible() ) { rLastRow = pData[nEndPos].nRow; bFound = true; } + // We are not ignoring range for current column, + // if it is larger than SC_VISATTR_STOP, because it is still in default page size range. + // We are not checking next columns, due to performance reasons. + if ( nAttrSize >= SC_VISATTR_STOP ) + break; nPos = nEndPos + 1; } |