sc/qa/unit/data/ods/tdf143220.ods |binary sc/qa/unit/subsequent_export_test2.cxx | 14 ++++++++++---- sc/source/filter/excel/xecontent.cxx | 6 +++++- 3 files changed, 15 insertions(+), 5 deletions(-)
New commits: commit 85a86ba6ba34ff0dfc92c3ce38cba86daf547121 Author: Tünde Tóth <toth.tu...@nisz.hu> AuthorDate: Tue Oct 19 14:15:37 2021 +0200 Commit: László Németh <nem...@numbertext.org> CommitDate: Thu Nov 4 08:58:42 2021 +0100 tdf#145079 XLSX export: fix regression of internal hyperlinks Hyperlinks with internal named range targets didn't work. Regression from commit 3c3b9ad8886da916027f0fb940a2df822d63d4d7 (tdf#143220 XLSX export: fix hyperlink to sheet target) Note: original test case of the unit test document of tdf#143220 wasn't changed. It's only extended with two new test cases for verifying the fix for the regression. Change-Id: I8128ebb977dba7304bc9c69e45f6c55c71f800cf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123816 Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> diff --git a/sc/qa/unit/data/ods/tdf143220.ods b/sc/qa/unit/data/ods/tdf143220.ods index 6aa1536eae8e..281c25626ed5 100644 Binary files a/sc/qa/unit/data/ods/tdf143220.ods and b/sc/qa/unit/data/ods/tdf143220.ods differ diff --git a/sc/qa/unit/subsequent_export_test2.cxx b/sc/qa/unit/subsequent_export_test2.cxx index 8144a3cb988e..681b05398fa4 100644 --- a/sc/qa/unit/subsequent_export_test2.cxx +++ b/sc/qa/unit/subsequent_export_test2.cxx @@ -208,7 +208,7 @@ public: void testTdf142929_filterLessThanXLSX(); void testInvalidNamedRange(); void testExternalDefinedNameXLSX(); - void testTdf143220XLSX(); + void testHyperlinkLocationXLSX(); void testTdf142264ManyChartsToXLSX(); void testTdf143929MultiColumnToODS(); void testTdf142578(); @@ -320,7 +320,7 @@ public: CPPUNIT_TEST(testTdf142929_filterLessThanXLSX); CPPUNIT_TEST(testInvalidNamedRange); CPPUNIT_TEST(testExternalDefinedNameXLSX); - CPPUNIT_TEST(testTdf143220XLSX); + CPPUNIT_TEST(testHyperlinkLocationXLSX); CPPUNIT_TEST(testTdf142264ManyChartsToXLSX); CPPUNIT_TEST(testTdf143929MultiColumnToODS); CPPUNIT_TEST(testTdf142578); @@ -2744,7 +2744,7 @@ void ScExportTest2::testExternalDefinedNameXLSX() xDocSh->DoClose(); } -void ScExportTest2::testTdf143220XLSX() +void ScExportTest2::testHyperlinkLocationXLSX() { ScDocShellRef xDocSh = loadDoc(u"tdf143220.", FORMAT_ODS); CPPUNIT_ASSERT(xDocSh.is()); @@ -2752,7 +2752,13 @@ void ScExportTest2::testTdf143220XLSX() xmlDocUniquePtr pDoc = XPathHelper::parseExport2(*this, *xDocSh, m_xSFactory, "xl/worksheets/sheet1.xml", FORMAT_XLSX); CPPUNIT_ASSERT(pDoc); - assertXPath(pDoc, "/x:worksheet/x:hyperlinks/x:hyperlink", "location", "Sheet2!A1"); + + // tdf#143220 link to sheet not valid without cell reference + assertXPath(pDoc, "/x:worksheet/x:hyperlinks/x:hyperlink[@ref='A1']", "location", "Sheet2!A1"); + + // tdf#145079 link with defined name target didn't work because Calc added "A1" at the end + assertXPath(pDoc, "/x:worksheet/x:hyperlinks/x:hyperlink[@ref='A2']", "location", "name"); + assertXPath(pDoc, "/x:worksheet/x:hyperlinks/x:hyperlink[@ref='A3']", "location", "db"); xDocSh->DoClose(); } diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx index 4baa6c00e9ad..006e3cb2c956 100644 --- a/sc/source/filter/excel/xecontent.cxx +++ b/sc/source/filter/excel/xecontent.cxx @@ -438,7 +438,11 @@ XclExpHyperlink::XclExpHyperlink( const XclExpRoot& rRoot, const SvxURLField& rU } } else - aTextMark += "!A1"; // tdf#143220 link to sheet not valid without cell reference + { + SCTAB nTab; + if (rRoot.GetDoc().GetTable(aTextMark, nTab)) + aTextMark += "!A1"; // tdf#143220 link to sheet not valid without cell reference + } mxTextMark.reset( new XclExpString( aTextMark, XclStrFlags::ForceUnicode, 255 ) ); }