sw/qa/extras/ooxmlexport/data/tdf78657_picture_hyperlink.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport13.cxx | 11 +++ sw/source/filter/ww8/docxattributeoutput.cxx | 30 +++++++--- 3 files changed, 34 insertions(+), 7 deletions(-)
New commits: commit 100f43ab871bedda6b427645cbfc2c8083da98b5 Author: Tünde Tóth <tund...@gmail.com> AuthorDate: Mon Jun 24 17:19:30 2019 +0200 Commit: László Németh <nem...@numbertext.org> CommitDate: Wed Jun 26 11:03:12 2019 +0200 tdf#78657 DOCX export: fix hyperlink inserted to image Hyperlink inserted to image lost after export. tdf78657_picture_hyperlink.docx: Test file from Microsoft Word 2016. Change-Id: I1b2b9fe023aea3f46848a9d616374f7c08598756 Reviewed-on: https://gerrit.libreoffice.org/74653 Tested-by: Jenkins Reviewed-by: László Németh <nem...@numbertext.org> diff --git a/sw/qa/extras/ooxmlexport/data/tdf78657_picture_hyperlink.docx b/sw/qa/extras/ooxmlexport/data/tdf78657_picture_hyperlink.docx new file mode 100644 index 000000000000..bc4759ecc342 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf78657_picture_hyperlink.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx index 408590660b82..4da5d109324a 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx @@ -398,6 +398,17 @@ DECLARE_OOXMLEXPORT_TEST(testTdf125324, "tdf125324.docx") assertXPath(pXmlDoc, "/root/page/body/txt[2]/anchored/fly/tab/infos/bounds", "top", "4193"); } +DECLARE_OOXMLEXPORT_TEST(testTdf78657, "tdf78657_picture_hyperlink.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + xmlDocPtr pXmlRels = parseExport("word/_rels/document.xml.rels"); + if (!pXmlDoc || !pXmlRels) + return; + assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:drawing/wp:inline/wp:docPr/a:hlinkClick", 1); + assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:drawing/wp:inline/a:graphic/a:graphicData/pic:pic/pic:nvPicPr/pic:cNvPr/a:hlinkClick", 1); + assertXPath(pXmlRels, "/rels:Relationships/rels:Relationship[@Target='http://www.google.com']", "TargetMode", "External"); +} + 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 cf6f5f2e8ab8..5733823ed24a 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -4821,10 +4821,25 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size docPrattrList->add( XML_title, OUStringToOString( pGrfNode ? pGrfNode->GetTitle() : pOLEFrameFormat->GetObjTitle(), RTL_TEXTENCODING_UTF8 ).getStr()); XFastAttributeListRef docPrAttrListRef( docPrattrList ); m_pSerializer->startElementNS( XML_wp, XML_docPr, docPrAttrListRef ); - // TODO hyperlink - // m_pSerializer->singleElementNS( XML_a, XML_hlinkClick, - // FSNS( XML_xmlns, XML_a ), "http://schemas.openxmlformats.org/drawingml/2006/main", - // FSNS( XML_r, XML_id ), "rId4"); + + //TODO: internal hyperlink + OUString sURL, sRelId; + if(pSdrObj) + { + uno::Reference< drawing::XShape > xShape( const_cast<SdrObject*>(pSdrObj)->getUnoShape(), uno::UNO_QUERY ); + uno::Reference< beans::XPropertySet > xPropSet( xShape, uno::UNO_QUERY ); + xPropSet->getPropertyValue("HyperLinkURL") >>= sURL; + if(!sURL.isEmpty()) + { + sRelId = GetExport().GetFilter().addRelation( m_pSerializer->getOutputStream(), + oox::getRelationship(Relationship::HYPERLINK), + sURL, true ); + m_pSerializer->singleElementNS( XML_a, XML_hlinkClick, + FSNS( XML_xmlns, XML_a ), "http://schemas.openxmlformats.org/drawingml/2006/main", + FSNS( XML_r, XML_id ), sRelId.toUtf8()); + } + } + m_pSerializer->endElementNS( XML_wp, XML_docPr ); m_pSerializer->startElementNS(XML_wp, XML_cNvGraphicFramePr); @@ -4846,9 +4861,10 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size // It seems pic:cNvpr and wp:docPr are pretty much the same thing with the same attributes m_pSerializer->startElementNS(XML_pic, XML_cNvPr, docPrAttrListRef); - // TODO hyperlink - // m_pSerializer->singleElementNS( XML_a, XML_hlinkClick, - // FSNS( XML_r, XML_id ), "rId4"); + if(!sURL.isEmpty()) + m_pSerializer->singleElementNS( XML_a, XML_hlinkClick, + FSNS( XML_r, XML_id ), sRelId.toUtf8()); + m_pSerializer->endElementNS( XML_pic, XML_cNvPr ); m_pSerializer->startElementNS(XML_pic, XML_cNvPicPr); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits