sc/qa/unit/data/xlsx/hyperlink_export.xlsx |binary sc/qa/unit/subsequent_export-test.cxx | 19 +++++++++++++++++++ sc/source/filter/excel/xecontent.cxx | 4 ++++ 3 files changed, 23 insertions(+)
New commits: commit 3cdc1b35b9d86bcfa1277e3e94925ae7b18b8fde Author: Tünde Tóth <tund...@gmail.com> AuthorDate: Tue Jul 2 10:07:24 2019 +0200 Commit: László Németh <nem...@numbertext.org> CommitDate: Wed Jul 3 11:14:57 2019 +0200 tdf#126177 XLSX export: fix hyperlinks to documents After export hyperlinks to documents didn't work, because the the hyperlink relationship targets contained also the anchor. Change-Id: I0bfc5bd1ef2b37f769d6a6b97e31c1b4bbfcb9aa Reviewed-on: https://gerrit.libreoffice.org/74988 Reviewed-by: László Németh <nem...@numbertext.org> Tested-by: László Németh <nem...@numbertext.org> diff --git a/sc/qa/unit/data/xlsx/hyperlink_export.xlsx b/sc/qa/unit/data/xlsx/hyperlink_export.xlsx new file mode 100644 index 000000000000..4c3952d96290 Binary files /dev/null and b/sc/qa/unit/data/xlsx/hyperlink_export.xlsx differ diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index 9d628f97faa9..06eaf398407f 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -225,6 +225,7 @@ public: void testTdf125173XLSX(); void testTdf79972XLSX(); void testTdf126024XLSX(); + void testTdf126177XLSX(); void testXltxExport(); @@ -355,6 +356,7 @@ public: CPPUNIT_TEST(testTdf125173XLSX); CPPUNIT_TEST(testTdf79972XLSX); CPPUNIT_TEST(testTdf126024XLSX); + CPPUNIT_TEST(testTdf126177XLSX); CPPUNIT_TEST(testXltxExport); @@ -4437,6 +4439,23 @@ void ScExportTest::testTdf126024XLSX() assertXPath(pXmlRels, "/r:Relationships/r:Relationship", "TargetMode", "External"); } +void ScExportTest::testTdf126177XLSX() +{ + ScDocShellRef xDocSh = loadDoc("hyperlink_export.", FORMAT_XLSX); + CPPUNIT_ASSERT(xDocSh.is()); + std::shared_ptr<utl::TempFile> pXPathFile = ScBootstrapFixture::exportTo(&(*xDocSh), FORMAT_XLSX); + + xmlDocPtr pDoc = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/worksheets/sheet1.xml"); + CPPUNIT_ASSERT(pDoc); + assertXPath(pDoc, "/x:worksheet/x:hyperlinks/x:hyperlink", "location", "Munka1!A5"); + + xmlDocPtr pXmlRels = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/worksheets/_rels/sheet1.xml.rels"); + CPPUNIT_ASSERT(pXmlRels); + OUString aTarget = getXPath(pXmlRels, "/r:Relationships/r:Relationship", "Target"); + CPPUNIT_ASSERT(aTarget.endsWith("test.xlsx")); + assertXPath(pXmlRels, "/r:Relationships/r:Relationship", "TargetMode", "External"); +} + CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx index 234c681c59c3..3237ff1fca75 100644 --- a/sc/source/filter/excel/xecontent.cxx +++ b/sc/source/filter/excel/xecontent.cxx @@ -445,6 +445,10 @@ XclExpHyperlink::XclExpHyperlink( const XclExpRoot& rRoot, const SvxURLField& rU aXclStrm << sal_uInt16( 0 ); mnFlags |= EXC_HLINK_MARK; + + OUString location = XclXmlUtils::ToOUString(*mxTextMark); + if (msTarget.endsWith(location)) + msTarget = msTarget.copy(0, msTarget.getLength() - location.getLength() - 1); } SetRecSize( 32 + mxVarData->Tell() ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits