summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTünde Tóth <tundeth@gmail.com>2019-06-24 17:19:30 +0200
committerXisco Faulí <xiscofauli@libreoffice.org>2019-06-28 15:54:40 +0200
commit0151b1fe4ebb62a25dcb885a1b8d8c6540b16ee6 (patch)
tree96eacaf36a28a06c4db9b5dabea192b261b1c93d
parenttdf#119388 calc, slow removing column, improve ScChildrenShapes (diff)
downloadcore-0151b1fe4ebb62a25dcb885a1b8d8c6540b16ee6.tar.gz
core-0151b1fe4ebb62a25dcb885a1b8d8c6540b16ee6.zip
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. Reviewed-on: https://gerrit.libreoffice.org/74653 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org> Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport13.cxx Change-Id: I1b2b9fe023aea3f46848a9d616374f7c08598756 Reviewed-on: https://gerrit.libreoffice.org/74841 Tested-by: Jenkins Reviewed-by: Xisco Faulí <xiscofauli@libreoffice.org>
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf78657_picture_hyperlink.docxbin0 -> 21039 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport13.cxx11
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx30
3 files changed, 34 insertions, 7 deletions
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
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf78657_picture_hyperlink.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
index ce6871b45df5..f7d09f590363 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
@@ -355,6 +355,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");
+}
+
DECLARE_OOXMLEXPORT_TEST(testTdf125518, "tdf125518.odt")
{
xmlDocPtr pXmlDoc = parseExport("word/document.xml");
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index b7316b003745..2bdbc30c7aa1 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -4820,10 +4820,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);
@@ -4845,9 +4860,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);