diff options
-rw-r--r-- | sc/qa/unit/subsequent_export-test.cxx | 43 | ||||
-rw-r--r-- | sc/source/filter/excel/xetable.cxx | 7 |
2 files changed, 44 insertions, 6 deletions
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index e6a5af86a65e..f4a603749633 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> @@ -230,6 +231,7 @@ public: void testXltxExport(); void testRotatedImageODS(); void testTdf128976(); + void testTdf120502(); CPPUNIT_TEST_SUITE(ScExportTest); CPPUNIT_TEST(test); @@ -361,6 +363,7 @@ public: CPPUNIT_TEST(testXltxExport); CPPUNIT_TEST(testRotatedImageODS); CPPUNIT_TEST(testTdf128976); + CPPUNIT_TEST(testTdf120502); CPPUNIT_TEST_SUITE_END(); @@ -4661,6 +4664,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 = rDoc.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 f1c597843945..e1f190d3c89b 100644 --- a/sc/source/filter/excel/xetable.cxx +++ b/sc/source/filter/excel/xetable.cxx @@ -1681,11 +1681,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: @@ -1703,7 +1698,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), |