diff options
author | Tünde Tóth <tundeth@gmail.com> | 2019-03-14 14:44:31 +0100 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2019-03-22 12:56:25 +0100 |
commit | 37a3af2413f9407639157caef67d7d5168230e49 (patch) | |
tree | 88343234178acb8863e65101dd8533a179678a95 | |
parent | 17fa95839c8942412c9fa2338eb271ae48401980 (diff) |
tdf#114969 XLSX export: fix 'sheet.name.with.dot'!A1-like links
When the sheet name/cell address separator was an exclamation mark,
bad conversion of the optional dot separator replaced the last dot
of the exported sheet name, resulting broken links:
'sheet.name.with!dot'!A1
Change-Id: I84fb6c8da345c144b04657ea350f1f96614071b7
Reviewed-on: https://gerrit.libreoffice.org/69272
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
-rwxr-xr-x | sc/qa/unit/data/ods/sheet_name_with_dots.ods | bin | 0 -> 7643 bytes | |||
-rw-r--r-- | sc/qa/unit/subsequent_export-test.cxx | 13 | ||||
-rwxr-xr-x[-rw-r--r--] | sc/source/filter/excel/xecontent.cxx | 13 |
3 files changed, 21 insertions, 5 deletions
diff --git a/sc/qa/unit/data/ods/sheet_name_with_dots.ods b/sc/qa/unit/data/ods/sheet_name_with_dots.ods Binary files differnew file mode 100755 index 000000000000..dc5b8193fe71 --- /dev/null +++ b/sc/qa/unit/data/ods/sheet_name_with_dots.ods diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index ccd6b16ad4db..d9f5a93a8ca2 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -210,6 +210,7 @@ public: void testTdf118990(); void testTdf121612(); void testPivotCacheAfterExportXLSX(); + void testTdf114969XLSX(); void testXltxExport(); @@ -327,6 +328,7 @@ public: CPPUNIT_TEST(testTdf118990); CPPUNIT_TEST(testTdf121612); CPPUNIT_TEST(testPivotCacheAfterExportXLSX); + CPPUNIT_TEST(testTdf114969XLSX); CPPUNIT_TEST(testXltxExport); @@ -4159,6 +4161,17 @@ void ScExportTest::testPivotCacheAfterExportXLSX() xDocSh->DoClose(); } +void ScExportTest::testTdf114969XLSX() +{ + ScDocShellRef xDocSh = loadDoc("sheet_name_with_dots.", FORMAT_ODS); + CPPUNIT_ASSERT(xDocSh.is()); + + xmlDocPtr pDoc = XPathHelper::parseExport2(*this, *xDocSh, m_xSFactory, "xl/worksheets/sheet1.xml", FORMAT_XLSX); + CPPUNIT_ASSERT(pDoc); + assertXPath(pDoc, "/x:worksheet/x:hyperlinks/x:hyperlink[1]", "location", "'1.1.1.1'!C1"); + assertXPath(pDoc, "/x:worksheet/x:hyperlinks/x:hyperlink[2]", "location", "'1.1.1.1'!C2"); +} + 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 84663591f51b..1bc2697aa518 100644..100755 --- a/sc/source/filter/excel/xecontent.cxx +++ b/sc/source/filter/excel/xecontent.cxx @@ -416,11 +416,14 @@ XclExpHyperlink::XclExpHyperlink( const XclExpRoot& rRoot, const SvxURLField& rU { OUString aTextMark( rUrl.copy( 1 ) ); - sal_Int32 nSepPos = aTextMark.lastIndexOf( '.' ); - if(nSepPos != -1) - aTextMark = aTextMark.replaceAt( nSepPos, 1, "!" ); - else - nSepPos = aTextMark.lastIndexOf( '!' ); + sal_Int32 nSepPos = aTextMark.lastIndexOf( '!' ); + sal_Int32 nPointPos = aTextMark.lastIndexOf( '.' ); + // last dot is the separator, if there is no ! after it + if(nSepPos < nPointPos) + { + nSepPos = nPointPos; + aTextMark = aTextMark.replaceAt( nSepPos, 1, "!" ); + } if(nSepPos != -1) { |