diff options
author | Tünde Tóth <toth.tunde@nisz.hu> | 2020-10-14 10:53:54 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2020-10-26 08:54:26 +0100 |
commit | fc58d7d65b9683db7b7632137126680b8483f6c5 (patch) | |
tree | 5ccd140b5d283ea5e33111cc3970035a7e5be587 | |
parent | 6bcdbb97b99369b20f6f1d2bdbc6eca1ff1f1150 (diff) |
tdf#129969 XLSX export: file URLs need IURI encoding
External hyperlinks with # in directory name didn't work
after XLSX export.
Change-Id: Ibdf4fcbb65d0c580841d24c1721454164e341424
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104272
Tested-by: Jenkins
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r-- | sc/qa/unit/data/ods/external_hyperlink.ods | bin | 0 -> 9928 bytes | |||
-rw-r--r-- | sc/qa/unit/subsequent_export-test.cxx | 25 | ||||
-rw-r--r-- | sc/source/filter/excel/xecontent.cxx | 5 |
3 files changed, 25 insertions, 5 deletions
diff --git a/sc/qa/unit/data/ods/external_hyperlink.ods b/sc/qa/unit/data/ods/external_hyperlink.ods Binary files differnew file mode 100644 index 000000000000..1e895b988497 --- /dev/null +++ b/sc/qa/unit/data/ods/external_hyperlink.ods diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index 71fa266a191e..62ebac829bb6 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 testTdf76047_externalLink(); + void testTdf129969(); CPPUNIT_TEST_SUITE(ScExportTest); CPPUNIT_TEST(test); @@ -438,6 +439,7 @@ public: CPPUNIT_TEST(testTdf137000_handle_upright); CPPUNIT_TEST(testTdf126305_DataValidatyErrorAlert); CPPUNIT_TEST(testTdf76047_externalLink); + CPPUNIT_TEST(testTdf129969); CPPUNIT_TEST_SUITE_END(); @@ -5516,8 +5518,10 @@ void ScExportTest::testTdf76047_externalLink() ScDocument& rDoc = pShell->GetDocument(); // compare the loaded data (from external links) to the data copied manually to the testfile - for (int nCol = 1; nCol <= 5; nCol++) { - for (int nRow = 3; nRow <= 5; nRow++) { + for (int nCol = 1; nCol <= 5; nCol++) + { + for (int nRow = 3; nRow <= 5; nRow++) + { OUString aStr1 = rDoc.GetString(ScAddress(nCol, nRow, 0)); OUString aStr2 = rDoc.GetString(ScAddress(nCol, nRow + 5, 0)); OUString aStr3 = rDoc.GetString(ScAddress(nCol, nRow + 11, 0)); @@ -5528,6 +5532,23 @@ void ScExportTest::testTdf76047_externalLink() } } +void ScExportTest::testTdf129969() +{ + ScDocShellRef xShell = loadDoc("external_hyperlink.", FORMAT_ODS); + CPPUNIT_ASSERT(xShell.is()); + + ScDocShellRef xDocSh = saveAndReload(&(*xShell), FORMAT_XLSX); + CPPUNIT_ASSERT(xDocSh.is()); + ScDocument& rDoc = xDocSh->GetDocument(); + ScAddress aPos(0, 0, 0); + const EditTextObject* pEditText = rDoc.GetEditText(aPos); + const SvxFieldData* pData = pEditText->GetFieldData(0, 0, text::textfield::Type::URL); + const SvxURLField* pURLData = static_cast<const SvxURLField*>(pData); + CPPUNIT_ASSERT(pURLData->GetURL().endsWith("/%23folder/test.ods#Sheet2.B10")); + + xDocSh->DoClose(); +} + 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 dbb28ec7b81c..27f07989c530 100644 --- a/sc/source/filter/excel/xecontent.cxx +++ b/sc/source/filter/excel/xecontent.cxx @@ -351,9 +351,8 @@ XclExpHyperlink::XclExpHyperlink( const XclExpRoot& rRoot, const SvxURLField& rU { sal_uInt16 nLevel; bool bRel; - /* TODO: should we differentiate between BIFF and OOXML and write IURI - * encoded for OOXML? */ - OUString aFileName( BuildFileName( nLevel, bRel, rUrl, rRoot, false ) ); + OUString aFileName( + BuildFileName(nLevel, bRel, rUrl, rRoot, rRoot.GetOutput() == EXC_OUTPUT_XML_2007)); if( eProtocol == INetProtocol::Smb ) { |