[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - sw/qa sw/source

Tünde Tóth (via logerrit) logerrit at kemper.freedesktop.org
Fri Jun 28 13:55:18 UTC 2019


 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 0151b1fe4ebb62a25dcb885a1b8d8c6540b16ee6
Author:     Tünde Tóth <tundeth at gmail.com>
AuthorDate: Mon Jun 24 17:19:30 2019 +0200
Commit:     Xisco Faulí <xiscofauli at libreoffice.org>
CommitDate: Fri Jun 28 15:54:40 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.
    
    Reviewed-on: https://gerrit.libreoffice.org/74653
    Tested-by: Jenkins
    Reviewed-by: László Németh <nemeth at 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 at libreoffice.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 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);


More information about the Libreoffice-commits mailing list