diff options
author | Tünde Tóth <tundeth@gmail.com> | 2019-09-25 12:10:16 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2019-09-30 13:00:51 +0200 |
commit | 5d5ec2a1ffe3862cc9689e667cebf1f9c1a5f330 (patch) | |
tree | aef3d4dfae101c19b257396ec4f9816e1a9af7f5 | |
parent | 7046846f840fb087cdda677a0e29461adca843aa (diff) |
tdf#127735 DOCX export: fix internal hyperlinks to table target
Hyperlinks with internal table targets didn't work in Microsoft Word.
Change-Id: I93b2b38d3d0196939f7aa5021811d2a9d5e482f5
Reviewed-on: https://gerrit.libreoffice.org/79524
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/internal_hyperlink_table.odt | bin | 0 -> 8866 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport13.cxx | 11 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 7 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8nds.cxx | 3 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtww8.cxx | 14 |
5 files changed, 29 insertions, 6 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/internal_hyperlink_table.odt b/sw/qa/extras/ooxmlexport/data/internal_hyperlink_table.odt Binary files differnew file mode 100644 index 000000000000..f3144a30e5a3 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/internal_hyperlink_table.odt diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx index d13b7bf90144..ec8635943f4d 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx @@ -804,6 +804,17 @@ DECLARE_OOXMLEXPORT_TEST(testTdf127734, "internal_hyperlink_region.odt") CPPUNIT_ASSERT_EQUAL(anchor, bookmarkName); } +DECLARE_OOXMLEXPORT_TEST(testTdf127735, "internal_hyperlink_table.odt") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + + OUString bookmarkName = getXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:p/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 f9f7c3c94c14..79d82b72c7a6 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -2914,11 +2914,8 @@ bool DocxAttributeOutput::StartURL( const OUString& rUrl, const OUString& rTarge } } } - if (sMark.indexOf(' ') != -1 && !sMark.endsWith("|table")) - { - // Spaces are prohibited in bookmark name. - sMark = sMark.replace(' ', '_'); - } + // Spaces are prohibited in bookmark name. + sMark = sMark.replace(' ', '_'); m_pHyperlinkAttrList->add( FSNS( XML_w, XML_anchor ), OUStringToOString( sMark, RTL_TEXTENCODING_UTF8 ).getStr( ) ); } diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index b80f94656704..b722b22621d3 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -917,7 +917,8 @@ 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" || sRefType == "region") ) + if ( !sRefType.isEmpty() && + (sRefType == "outline" || sRefType == "graphic" || sRefType == "frame" || sRefType == "ole" || sRefType == "region" || sRefType == "table") ) { for ( const auto& rBookmarkPair : GetExport().m_aImplicitBookmarks ) { diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index fcb168f68bf1..542d24d7a64b 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -3130,6 +3130,20 @@ void MSWordExportBase::AddLinkTarget(const OUString& rURL) } } } + else if( sCmp == "table" ) + { + OUString aName(BookmarkToWriter(aURL.copy(0, nPos))); + const SwTable* pTable = SwTable::FindTable(m_pDoc->FindTableFormatByName(aName)); + if (pTable) + { + SwTableNode* pTableNode = const_cast<SwTableNode*>(pTable->GetTabSortBoxes()[1]->GetSttNd()->FindTableNode()); + if (pTableNode) + { + nIdx = pTableNode->GetIndex() + 2; + noBookmark = true; + } + } + } if (noBookmark) { aBookmarkPair aImplicitBookmark; |