[Libreoffice-commits] core.git: Branch 'libreoffice-6-4' - sc/qa sc/source

Mike Kaganski (via logerrit) logerrit at kemper.freedesktop.org
Wed Jan 8 15:06:48 UTC 2020


 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 925be88167868798c97ff1f66dcdb9bd3bbec1e2
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Tue Dec 31 15:31:41 2019 +0300
Commit:     Xisco Faulí <xiscofauli at libreoffice.org>
CommitDate: Wed Jan 8 16:05:50 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.
    
    Change-Id: Ie2f043c4910568731cac90d89ec791ecbc8565b5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86046
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    (cherry picked from commit f1aec2392dba32e90f2cb0e4ad3c84bcbbd9f305)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86428
    Reviewed-by: Xisco Faulí <xiscofauli at libreoffice.org>

diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 90f2c85720be..e220803967cb 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();
 
@@ -4585,6 +4588,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 3e8ffb13bdef..0a7e5cbfbbed 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),


More information about the Libreoffice-commits mailing list