sw/qa/extras/ooxmlexport/data/internal_hyperlink_region.odt |binary sw/qa/extras/ooxmlexport/data/internal_hyperlink_table.odt |binary sw/qa/extras/ooxmlexport/ooxmlexport13.cxx | 22 +++++++++ sw/source/filter/ww8/docxattributeoutput.cxx | 7 -- sw/source/filter/ww8/wrtw8nds.cxx | 3 - sw/source/filter/ww8/wrtww8.cxx | 29 ++++++++++++ 6 files changed, 55 insertions(+), 6 deletions(-)
New commits: commit 5d5ec2a1ffe3862cc9689e667cebf1f9c1a5f330 Author: Tünde Tóth <tund...@gmail.com> AuthorDate: Wed Sep 25 12:10:16 2019 +0200 Commit: László Németh <nem...@numbertext.org> CommitDate: Mon Sep 30 13:00:51 2019 +0200 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 <nem...@numbertext.org> diff --git a/sw/qa/extras/ooxmlexport/data/internal_hyperlink_table.odt b/sw/qa/extras/ooxmlexport/data/internal_hyperlink_table.odt new file mode 100644 index 000000000000..f3144a30e5a3 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/internal_hyperlink_table.odt differ 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; commit 7046846f840fb087cdda677a0e29461adca843aa Author: Tünde Tóth <tund...@gmail.com> AuthorDate: Wed Sep 25 10:23:52 2019 +0200 Commit: László Németh <nem...@numbertext.org> CommitDate: Mon Sep 30 13:00:32 2019 +0200 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 <nem...@numbertext.org> 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 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/internal_hyperlink_region.odt 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; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits