oox/source/drawingml/shape.cxx                  |   12 ++++++++++++
 sw/qa/extras/ooxmlimport/data/grouped_link.docx |binary
 sw/qa/extras/ooxmlimport/ooxmlimport2.cxx       |   10 ++++++++++
 3 files changed, 22 insertions(+)

New commits:
commit e17a67735ffe8e0feeef8daddf2667d3e432f6cd
Author:     Tünde Tóth <toth.tu...@nisz.hu>
AuthorDate: Thu Mar 9 16:01:03 2023 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Thu Apr 6 11:35:43 2023 +0200

    tdf#145147 DOCX import: fix hyperlink in group shape
    
    Hyperlink inserted to shape lost, if the shape was
    inside a group shape.
    
    Test: ungroup the grouped shape and move the mouse
    over the shapes, or use Edit Hyperlink... in their
    context menu.
    
    Change-Id: I45d816f18a1e1bc1c442943b31c9e0ae7de199e6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148552
    Reviewed-by: László Németh <nem...@numbertext.org>
    Tested-by: László Németh <nem...@numbertext.org>
    (cherry picked from commit b5a0fa42adf68b33970da93c2b04f935f72cffde)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149608
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index fad591a93d04..4e4836fdf8b4 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -405,6 +405,18 @@ void Shape::addShape(
                                      ? 
*getTextBody()->getTextProperties().moInsets[3]
                                      : 0));
                 }
+
+                // tdf#145147 Set the Hyperlink property to the child wps 
shape.
+                if (getShapeProperties().hasProperty(PROP_URL)) try
+                {
+                    uno::Any aAny = getShapeProperties().getProperty(PROP_URL);
+                    OUString sUrl = aAny.get<OUString>();
+                    if (!sUrl.isEmpty())
+                        
xChildWPSProperties->setPropertyValue(UNO_NAME_HYPERLINK, aAny);
+                }
+                catch (const Exception&)
+                {
+                }
             }
 
             if( meFrameType == FRAMETYPE_DIAGRAM )
diff --git a/sw/qa/extras/ooxmlimport/data/grouped_link.docx 
b/sw/qa/extras/ooxmlimport/data/grouped_link.docx
new file mode 100644
index 000000000000..8c5657b708b4
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/grouped_link.docx 
differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
index 04d23a4c1bc0..532ad030b28d 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
@@ -1078,6 +1078,16 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf154319)
     }
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf145147)
+{
+    createSwDoc("grouped_link.docx");
+    uno::Reference<drawing::XShapes> xGroupShape(getShape(1), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(OUString("https://www.libreoffice.org";),
+                         getProperty<OUString>(xGroupShape->getByIndex(0), 
"Hyperlink"));
+    CPPUNIT_ASSERT_EQUAL(OUString("https://www.documentfoundation.org";),
+                         getProperty<OUString>(xGroupShape->getByIndex(1), 
"Hyperlink"));
+}
+
 // tests should only be added to ooxmlIMPORT *if* they fail round-tripping in 
ooxmlEXPORT
 
 CPPUNIT_PLUGIN_IMPLEMENT();

Reply via email to