summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorTünde Tóth <tundeth@gmail.com>2019-09-25 10:23:52 +0200
committerLászló Németh <nemeth@numbertext.org>2019-09-30 13:00:32 +0200
commit7046846f840fb087cdda677a0e29461adca843aa (patch)
tree81e86d6e10d275e0b23079d465edbf9d72220a2b /sw
parent97fba7ebf350adcec6baa6c4a863d058fb90406a (diff)
tdf#127734 DOCX export: fix internal hyperlinks to section target
Hyperlinks with internal section targets didn't work after export. Change-Id: I355091193f9b7f92d3fec77ee7d8a27bfd981724 Reviewed-on: https://gerrit.libreoffice.org/79522 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/ooxmlexport/data/internal_hyperlink_region.odtbin0 -> 8744 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport13.cxx11
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx2
-rw-r--r--sw/source/filter/ww8/wrtw8nds.cxx2
-rw-r--r--sw/source/filter/ww8/wrtww8.cxx15
5 files changed, 28 insertions, 2 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/internal_hyperlink_region.odt b/sw/qa/extras/ooxmlexport/data/internal_hyperlink_region.odt
new file mode 100644
index 000000000000..abec2c5a8fc8
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/internal_hyperlink_region.odt
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
index b95f0083e10e..d13b7bf90144 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
@@ -793,6 +793,17 @@ DECLARE_OOXMLEXPORT_TEST(testTdf127733, "internal_hyperlink_ole.odt")
CPPUNIT_ASSERT_EQUAL(anchor, bookmarkName);
}
+DECLARE_OOXMLEXPORT_TEST(testTdf127734, "internal_hyperlink_region.odt")
+{
+ xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+ if (!pXmlDoc)
+ return;
+
+ OUString bookmarkName = getXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:bookmarkStart", "name");
+ OUString anchor = getXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:hyperlink", "anchor");
+ CPPUNIT_ASSERT_EQUAL(anchor, bookmarkName);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 3a7555ee305f..f9f7c3c94c14 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -2914,7 +2914,7 @@ bool DocxAttributeOutput::StartURL( const OUString& rUrl, const OUString& rTarge
}
}
}
- if (sMark.indexOf(' ') != -1 && !sMark.endsWith("|table") && !sMark.endsWith("|region"))
+ if (sMark.indexOf(' ') != -1 && !sMark.endsWith("|table"))
{
// Spaces are prohibited in bookmark name.
sMark = sMark.replace(' ', '_');
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx
index 7edf472786f1..b80f94656704 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -917,7 +917,7 @@ bool AttributeOutputBase::AnalyzeURL( const OUString& rUrl, const OUString& /*rT
OUString());
// #i21465# Only interested in outline references
- if ( !sRefType.isEmpty() && (sRefType == "outline" || sRefType == "graphic" || sRefType == "frame" || sRefType == "ole") )
+ if ( !sRefType.isEmpty() && (sRefType == "outline" || sRefType == "graphic" || sRefType == "frame" || sRefType == "ole" || sRefType == "region") )
{
for ( const auto& rBookmarkPair : GetExport().m_aImplicitBookmarks )
{
diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx
index bec217c60ddb..fcb168f68bf1 100644
--- a/sw/source/filter/ww8/wrtww8.cxx
+++ b/sw/source/filter/ww8/wrtww8.cxx
@@ -3115,6 +3115,21 @@ void MSWordExportBase::AddLinkTarget(const OUString& rURL)
noBookmark = true;
}
}
+ else if( sCmp == "region" )
+ {
+ SwNodeIndex* pIdx;
+ OUString aName(BookmarkToWriter(aURL.copy(0, nPos)));
+ for (const SwSectionFormat* pFormat : m_pDoc->GetSections())
+ {
+ if (aName == pFormat->GetSection()->GetSectionName()
+ && nullptr != (pIdx = const_cast<SwNodeIndex*>(pFormat->GetContent().GetContentIdx())))
+ {
+ nIdx = pIdx->GetIndex() + 1;
+ noBookmark = true;
+ break;
+ }
+ }
+ }
if (noBookmark)
{
aBookmarkPair aImplicitBookmark;