sc/qa/unit/data/ods/tdf128895_emptyHiddenCols.ods |binary sc/qa/unit/subsequent_export-test.cxx | 18 ++++++++++++++++++ sc/source/filter/xml/xmlcoli.cxx | 1 + 3 files changed, 19 insertions(+)
New commits: commit 5e76c14d20799a2cbecdccc2e8b71961a0696f15 Author: Justin Luth <justin_l...@sil.org> AuthorDate: Wed Dec 8 14:22:01 2021 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Mon Dec 13 16:00:52 2021 +0100 tdf#128895 sc xmlimport: create enough dynamic cols if props Since LO 6.3, only 64 columns are created by default, where previously it was a fixed 1024. A common user practice is to hide all columns not used, but this collapsed property was lost because only part of the columns were actually created and thus exported. In this example, import specifies 1017 hidden columns (H-AMJ), but since only 64 columns are created, export only specified 57. So ensure that on import, any column with defined properties is created - even if they don't contain any content. Change-Id: If928880baf5585613715a1f4361a9059584d1ad2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126540 Tested-by: Jenkins Reviewed-by: Justin Luth <jl...@mail.com> Reviewed-by: Bartosz Kosiorek <gan...@poczta.onet.pl> (cherry picked from commit 297ab561c6754f89326a1e8ce1751233669578d7) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126668 Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126728 diff --git a/sc/qa/unit/data/ods/tdf128895_emptyHiddenCols.ods b/sc/qa/unit/data/ods/tdf128895_emptyHiddenCols.ods new file mode 100644 index 000000000000..fa016369f206 Binary files /dev/null and b/sc/qa/unit/data/ods/tdf128895_emptyHiddenCols.ods differ diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index 31c0aae3dd71..431a03ebca65 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -142,6 +142,7 @@ public: #endif void testOutlineExportXLSX(); void testHiddenEmptyRowsXLSX(); + void testHiddenEmptyColsODS(); void testAllRowsHiddenXLSX(); void testLandscapeOrientationXLSX(); @@ -258,6 +259,7 @@ public: #endif CPPUNIT_TEST(testOutlineExportXLSX); CPPUNIT_TEST(testHiddenEmptyRowsXLSX); + CPPUNIT_TEST(testHiddenEmptyColsODS); CPPUNIT_TEST(testAllRowsHiddenXLSX); CPPUNIT_TEST(testLandscapeOrientationXLSX); CPPUNIT_TEST(testInlineArrayXLS); @@ -1411,6 +1413,22 @@ void ScExportTest::testHiddenEmptyRowsXLSX() xShell->DoClose(); } +void ScExportTest::testHiddenEmptyColsODS() +{ + //tdf#98106 FILESAVE: Hidden and empty rows became visible when export to .XLSX + ScDocShellRef xShell = loadDoc(u"tdf128895_emptyHiddenCols.", FORMAT_ODS); + CPPUNIT_ASSERT(xShell.is()); + + std::shared_ptr<utl::TempFile> pXPathFile + = ScBootstrapFixture::exportTo(&(*xShell), FORMAT_ODS); + xmlDocUniquePtr pSheet = XPathHelper::parseExport(pXPathFile, m_xSFactory, "content.xml"); + CPPUNIT_ASSERT(pSheet); + assertXPath(pSheet, "//table:table/table:table-column[2]"); + assertXPath(pSheet, "//table:table/table:table-column[2]", "number-columns-repeated", "1017"); + + xShell->DoClose(); +} + void ScExportTest::testLandscapeOrientationXLSX() { //tdf#48767 - Landscape page orientation is not loaded from .xlsx format with MS Excel, after export with Libre Office diff --git a/sc/source/filter/xml/xmlcoli.cxx b/sc/source/filter/xml/xmlcoli.cxx index 8bec39546541..0e4af7bb9a9a 100644 --- a/sc/source/filter/xml/xmlcoli.cxx +++ b/sc/source/filter/xml/xmlcoli.cxx @@ -93,6 +93,7 @@ void SAL_CALL ScXMLTableColContext::endFastElement( sal_Int32 /*nElement*/ ) nLastColumn = pDoc->MaxCol(); if (nCurrentColumn > pDoc->MaxCol()) nCurrentColumn = pDoc->MaxCol(); + pDoc->CreateColumnIfNotExists(nSheet, nLastColumn); uno::Reference<table::XColumnRowRange> xColumnRowRange (xSheet->getCellRangeByPosition(nCurrentColumn, 0, nLastColumn, 0), uno::UNO_QUERY); if (xColumnRowRange.is()) {