[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-0' - sc/qa sc/source

Attila Szűcs (via logerrit) logerrit at kemper.freedesktop.org
Tue Mar 2 11:55:22 UTC 2021


 sc/qa/unit/data/xlsx/tdf138741_externalLinkSkipUnusedsCrash.xlsx |binary
 sc/qa/unit/subsequent_export-test.cxx                            |   13 ++++++++++
 sc/source/filter/excel/xelink.cxx                                |    2 +
 sc/source/ui/docshell/externalrefmgr.cxx                         |    2 -
 4 files changed, 16 insertions(+), 1 deletion(-)

New commits:
commit 623f68f6d8404d73f8bcfe9db798752efd36c79f
Author:     Attila Szűcs <szucs.attila3 at nisz.hu>
AuthorDate: Tue Dec 8 18:22:07 2020 +0100
Commit:     Gabor Kelemen <kelemen.gabor2 at nisz.hu>
CommitDate: Tue Mar 2 12:54:45 2021 +0100

    tdf#138741 XLSX export: fix crash in setSkipUnusedFileIds
    
    Changed size of maConvertFileIdToUsedFileId vector to the same as
    maSrcFiles size.
    
    Some external references was not inserted into maRefCells,
    that resulted a smaller maConvertFileIdToUsedFileId as was needed.
    
    This crash was caused by:
    tdf#87973 XLSX export: fix lost file names in modified links
    f85d860ccbebd99bc128218148e2992c9415f221
    
    Co-authored-by: Tibor Nagy (NISZ)
    Change-Id: I1501f5222483bf3e9e41c9e921a024320231dce8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107434
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    (cherry picked from commit 8cfe270258d914e154b9db8b6ad02cd923984435)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107481
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>
    (cherry picked from commit 172b81479451f0af2978dfa2eba1f9d105b946c9)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111781
    Tested-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
    Reviewed-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>

diff --git a/sc/qa/unit/data/xlsx/tdf138741_externalLinkSkipUnusedsCrash.xlsx b/sc/qa/unit/data/xlsx/tdf138741_externalLinkSkipUnusedsCrash.xlsx
new file mode 100644
index 000000000000..59102f2ab814
Binary files /dev/null and b/sc/qa/unit/data/xlsx/tdf138741_externalLinkSkipUnusedsCrash.xlsx differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 5b2ae8b3729b..f9290a8d5995 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -270,6 +270,7 @@ public:
     void testTdf137000_handle_upright();
     void testTdf126305_DataValidatyErrorAlert();
     void testTdf87973_externalLinkSkipUnuseds();
+    void testTdf138741_externalLinkSkipUnusedsCrash();
     void testTdf129969();
     void testTdf84874();
 
@@ -436,6 +437,7 @@ public:
     CPPUNIT_TEST(testTdf137000_handle_upright);
     CPPUNIT_TEST(testTdf126305_DataValidatyErrorAlert);
     CPPUNIT_TEST(testTdf87973_externalLinkSkipUnuseds);
+    CPPUNIT_TEST(testTdf138741_externalLinkSkipUnusedsCrash);
     CPPUNIT_TEST(testTdf129969);
     CPPUNIT_TEST(testTdf84874);
 
@@ -5489,6 +5491,17 @@ void ScExportTest::testTdf87973_externalLinkSkipUnuseds()
     pDocSh->DoClose();
 }
 
+void ScExportTest::testTdf138741_externalLinkSkipUnusedsCrash()
+{
+    ScDocShellRef xShell = loadDoc("tdf138741_externalLinkSkipUnusedsCrash.", FORMAT_XLSX);
+    CPPUNIT_ASSERT(xShell);
+
+    //without the fix in place, it would have crashed at export time
+    ScBootstrapFixture::exportTo(&(*xShell), FORMAT_XLSX);
+
+    xShell->DoClose();
+}
+
 void ScExportTest::testTdf129969()
 {
     ScDocShellRef xShell = loadDoc("external_hyperlink.", FORMAT_ODS);
diff --git a/sc/source/filter/excel/xelink.cxx b/sc/source/filter/excel/xelink.cxx
index d36bba70de9f..c0d37c44d60c 100644
--- a/sc/source/filter/excel/xelink.cxx
+++ b/sc/source/filter/excel/xelink.cxx
@@ -2083,6 +2083,8 @@ void XclExpSupbookBuffer::SaveXml( XclExpXmlStream& rStrm )
     for (size_t nPos = 0, nSize = maSupbookList.GetSize(); nPos < nSize; ++nPos)
     {
         XclExpSupbookRef xRef(maSupbookList.GetRecord(nPos));
+        // fileIDs are indexed from 1 in xlsx, and from 0 in ScExternalRefManager
+        // converting between them require a -1 or +1
         if (xRef->GetType() == XclSupbookType::Extern)
             aExternFileIds.push_back(xRef->GetFileId() - 1);
     }
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index 6591c4495e76..329da9dcc21a 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -2751,7 +2751,7 @@ sal_uInt16 ScExternalRefManager::convertFileIdToUsedFileId(sal_uInt16 nFileId)
 void ScExternalRefManager::setSkipUnusedFileIds(std::vector<sal_uInt16>& rExternFileIds)
 {
     mbSkipUnusedFileIds = true;
-    maConvertFileIdToUsedFileId.resize(maRefCells.size());
+    maConvertFileIdToUsedFileId.resize(maSrcFiles.size());
     std::fill(maConvertFileIdToUsedFileId.begin(), maConvertFileIdToUsedFileId.end(), 0);
     int nUsedCount = 0;
     for (auto nEntry : rExternFileIds)


More information about the Libreoffice-commits mailing list