sc/qa/unit/subsequent_export-test.cxx | 43 ++++++++++++++++++++++++++++++++++ sc/source/filter/excel/xetable.cxx | 7 ----- 2 files changed, 44 insertions(+), 6 deletions(-)
New commits: commit 6599bdfd7a108617e7b920a7ebe30cd1da585718 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Tue Dec 31 15:31:41 2019 +0300 Commit: Xisco Faulí <xiscofa...@libreoffice.org> CommitDate: Thu Jan 9 10:00:13 2020 +0100 tdf#120502: Excel doesn't increment max column for OOXML This is obviously a result of copy-paste from XclExpColinfo::WriteBody (where that increment existed at least since commit 92d8c6d6c4dc2a2824a0e24e22485361c3b65b54 from 2004). Implementing OOXML export, authors of commit 64274b38f6cc50a8bb49f114f1ac9e7c1c3b3c4f likely forgot to remove this after copying the code to XclExpColinfo::SaveXml. This change removes the copy-pasted code incrementing column number for the last possible column. Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86046 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> (cherry picked from commit f1aec2392dba32e90f2cb0e4ad3c84bcbbd9f305) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86428 Reviewed-by: Xisco Faulí <xiscofa...@libreoffice.org> (cherry picked from commit 925be88167868798c97ff1f66dcdb9bd3bbec1e2) Change-Id: Ie2f043c4910568731cac90d89ec791ecbc8565b5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86439 Tested-by: Jenkins Reviewed-by: Xisco Faulí <xiscofa...@libreoffice.org> diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index f47b5670e803..3d6c6522c7ef 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -69,6 +69,7 @@ #include <test/xmltesttools.hxx> #include <com/sun/star/drawing/XDrawPageSupplier.hpp> #include <com/sun/star/awt/XBitmap.hpp> +#include <com/sun/star/frame/Desktop.hpp> #include <com/sun/star/graphic/GraphicType.hpp> #include <com/sun/star/sheet/GlobalSheetSettings.hpp> #include <comphelper/storagehelper.hxx> @@ -232,6 +233,7 @@ public: void testXltxExport(); void testRotatedImageODS(); void testTdf128976(); + void testTdf120502(); CPPUNIT_TEST_SUITE(ScExportTest); CPPUNIT_TEST(test); @@ -365,6 +367,7 @@ public: CPPUNIT_TEST(testXltxExport); CPPUNIT_TEST(testRotatedImageODS); CPPUNIT_TEST(testTdf128976); + CPPUNIT_TEST(testTdf120502); CPPUNIT_TEST_SUITE_END(); @@ -4519,6 +4522,46 @@ void ScExportTest::testTdf128976() xDocSh->DoClose(); } +void ScExportTest::testTdf120502() +{ + // Create an empty worksheet; resize last column on its first sheet; export to XLSX, and check + // that the last exportd column number is correct + css::uno::Reference<css::frame::XDesktop2> xDesktop + = css::frame::Desktop::create(comphelper::getProcessComponentContext()); + CPPUNIT_ASSERT(xDesktop); + + css::uno::Sequence<css::beans::PropertyValue> args(1); + args[0].Name = "Hidden"; + args[0].Value <<= true; + + css::uno::Reference<css::lang::XComponent> xComponent + = xDesktop->loadComponentFromURL("private:factory/scalc", "_blank", 0, args); + CPPUNIT_ASSERT(xComponent); + + // Get the document model + SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(xComponent); + CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell); + + ScDocShellRef xShell = dynamic_cast<ScDocShell*>(pFoundShell); + CPPUNIT_ASSERT(xShell); + + ScDocument& rDoc = xShell->GetDocument(); + const SCCOL nMaxCol = MAXCOL; // 0-based + + const auto nOldWidth = rDoc.GetColWidth(nMaxCol, 0); + rDoc.SetColWidth(nMaxCol, 0, nOldWidth + 100); + + std::shared_ptr<utl::TempFile> pXPathFile + = ScBootstrapFixture::exportTo(&(*xShell), FORMAT_XLSX); + xShell->DoClose(); + const xmlDocPtr pSheet1 + = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/worksheets/sheet1.xml"); + CPPUNIT_ASSERT(pSheet1); + + // This was 1025 when nMaxCol+1 was 1024 + assertXPath(pSheet1, "/x:worksheet/x:cols/x:col", "max", OUString::number(nMaxCol + 1)); +} + CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx index 8a42c9ea380f..9b06778e421f 100644 --- a/sc/source/filter/excel/xetable.cxx +++ b/sc/source/filter/excel/xetable.cxx @@ -1680,11 +1680,6 @@ void XclExpColinfo::WriteBody( XclExpStream& rStrm ) void XclExpColinfo::SaveXml( XclExpXmlStream& rStrm ) { - // if last column is equal to last possible column, Excel adds one more - sal_uInt16 nLastXclCol = mnLastXclCol; - if( nLastXclCol == static_cast< sal_uInt16 >( rStrm.GetRoot().GetMaxPos().Col() ) ) - ++nLastXclCol; - const double nExcelColumnWidth = mnScWidth / static_cast< double >( sc::TwipsToHMM( GetCharWidth() ) ); // tdf#101363 In MS specification the output value is set with double precision after delimiter: @@ -1702,7 +1697,7 @@ void XclExpColinfo::SaveXml( XclExpXmlStream& rStrm ) XML_customWidth, ToPsz( mbCustomWidth ), XML_hidden, ToPsz( ::get_flag( mnFlags, EXC_COLINFO_HIDDEN ) ), XML_outlineLevel, OString::number(mnOutlineLevel), - XML_max, OString::number(nLastXclCol + 1), + XML_max, OString::number(mnLastXclCol + 1), XML_min, OString::number(mnFirstXclCol + 1), // OOXTODO: XML_phonetic, XML_style, lcl_GetStyleId(rStrm, maXFId.mnXFIndex), _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits