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 <nemeth@numbertext.org>
Tested-by: László Németh <nemeth@numbertext.org>
(cherry picked from commit b5a0fa42adf68b33970da93c2b04f935f72cffde)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149608
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index fad591a..4e4836f 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 0000000..8c5657b
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/grouped_link.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
index 04d23a4..532ad03 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();