summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Luth <justin_luth@sil.org>2021-12-08 14:22:01 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2021-12-13 16:00:52 +0100
commit5e76c14d20799a2cbecdccc2e8b71961a0696f15 (patch)
tree2db82c3b7b1cf1f90ef52826166ed7ad2f7da01c
parentcf3672dd1803edd435acbcd6aaaf07e7a0e8c74c (diff)
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 <jluth@mail.com> Reviewed-by: Bartosz Kosiorek <gang65@poczta.onet.pl> (cherry picked from commit 297ab561c6754f89326a1e8ce1751233669578d7) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126668 Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126728
-rw-r--r--sc/qa/unit/data/ods/tdf128895_emptyHiddenCols.odsbin0 -> 7210 bytes
-rw-r--r--sc/qa/unit/subsequent_export-test.cxx18
-rw-r--r--sc/source/filter/xml/xmlcoli.cxx1
3 files changed, 19 insertions, 0 deletions
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
--- /dev/null
+++ b/sc/qa/unit/data/ods/tdf128895_emptyHiddenCols.ods
Binary files 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())
{