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 7f4f88b883f81fbce975f72aea0f66a54e269ead Author: Tünde Tóth <toth.tu...@nisz.hu> AuthorDate: Thu Mar 9 16:01:03 2023 +0100 Commit: László Németh <nem...@numbertext.org> CommitDate: Mon Mar 27 14:22:05 2023 +0000 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> diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index b8cac0d8f385..e3923c1b647d 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -406,6 +406,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 6436d68ec89e..c201e585e997 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx @@ -1092,6 +1092,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();