summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-12-08 09:16:22 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-12-08 09:17:56 +0100
commit4517c94000153eab6c034ea548698953dd93f794 (patch)
tree34b6704d2e9e8be5b6d6d5a62269e693a3e78f8e
parent193c7ba9be48f00b46f9e789f233db577e7b3303 (diff)
fdo#86750 RTF import: fix table of contents links
Change-Id: I0f3d35a0e64c9ce5646fa63eda317bee42de5540
-rw-r--r--sw/qa/extras/rtfimport/data/fdo86750.rtf4
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx6
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx9
3 files changed, 19 insertions, 0 deletions
diff --git a/sw/qa/extras/rtfimport/data/fdo86750.rtf b/sw/qa/extras/rtfimport/data/fdo86750.rtf
new file mode 100644
index 000000000000..29f0b84ca995
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/fdo86750.rtf
@@ -0,0 +1,4 @@
+{\rtf1
+{\field{\*\fldinst { HYPERLINK \\l "anchor" }}{\fldrslt click}}\par
+{\*\bkmkstart anchor}target{\*\bkmkend anchor}\par
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index e0b5100fc34b..08290570e03b 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -2213,6 +2213,12 @@ DECLARE_RTFIMPORT_TEST(testFdo72031, "fdo72031.rtf")
CPPUNIT_ASSERT_EQUAL(aExpected, getRun(getParagraph(1), 1)->getString());
}
+DECLARE_RTFIMPORT_TEST(testFdo86750, "fdo86750.rtf")
+{
+ // This was 'HYPERLINK#anchor', the URL of the hyperlink had the field type as a prefix, leading to broken links.
+ CPPUNIT_ASSERT_EQUAL(OUString("#anchor"), getProperty<OUString>(getRun(getParagraph(1), 1), "HyperLinkURL"));
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index ac7af0d2fc4d..7176485c047a 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -3656,6 +3656,15 @@ void DomainMapper_Impl::CloseFieldCommand()
case FIELD_HYPERLINK:
{
::std::vector<OUString> aParts = pContext->GetCommandParts();
+
+ // Syntax is either:
+ // HYPERLINK "" \l "link"
+ // or
+ // HYPERLINK \l "link"
+ // Make sure "HYPERLINK" doesn't end up as part of link in the second case.
+ if (!aParts.empty() && aParts[0] == "HYPERLINK")
+ aParts.erase(aParts.begin());
+
::std::vector<OUString>::const_iterator aItEnd = aParts.end();
::std::vector<OUString>::const_iterator aPartIt = aParts.begin();