summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorTünde Tóth <tundeth@gmail.com>2019-03-14 14:44:31 +0100
committerLászló Németh <nemeth@numbertext.org>2019-03-25 10:35:56 +0100
commit5c0fa3265962373f36020f3ba8ddcdbc265e0acc (patch)
tree801ed4dca43e05b32f75a7ec58a699cc5c90144a /sc
parentb2e81e11e154b660172356969252f00ba63f3a2b (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> (cherry picked from commit 37a3af2413f9407639157caef67d7d5168230e49) Reviewed-on: https://gerrit.libreoffice.org/69583 Reviewed-by: Tünde Tóth <tundeth@gmail.com>
Diffstat (limited to 'sc')
-rwxr-xr-xsc/qa/unit/data/ods/sheet_name_with_dots.odsbin0 -> 7643 bytes
-rw-r--r--sc/qa/unit/subsequent_export-test.cxx13
-rwxr-xr-x[-rw-r--r--]sc/source/filter/excel/xecontent.cxx13
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
new file mode 100755
index 000000000000..dc5b8193fe71
--- /dev/null
+++ b/sc/qa/unit/data/ods/sheet_name_with_dots.ods
Binary files differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 04d26cd35d6d..22851e9b5f5f 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -220,6 +220,7 @@ public:
void testTdf118990();
void testTdf121612();
void testPivotCacheAfterExportXLSX();
+ void testTdf114969XLSX();
CPPUNIT_TEST_SUITE(ScExportTest);
CPPUNIT_TEST(test);
@@ -335,6 +336,7 @@ public:
CPPUNIT_TEST(testTdf118990);
CPPUNIT_TEST(testTdf121612);
CPPUNIT_TEST(testPivotCacheAfterExportXLSX);
+ CPPUNIT_TEST(testTdf114969XLSX);
CPPUNIT_TEST_SUITE_END();
@@ -4231,6 +4233,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 7d8341f5b3f8..9023a524b786 100644..100755
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -418,11 +418,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)
{