diff options
author | Tibor Nagy <nagy.tibor2@nisz.hu> | 2021-09-22 13:25:00 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2021-09-27 17:04:13 +0200 |
commit | 6e200689eb309cdbe1e4f08311a400835de19bfb (patch) | |
tree | 262bfca86312a2ee0c0a0ea064961cd0a9e89b32 | |
parent | 82798029b1d89be07fb21eed081906460ba1cd08 (diff) |
tdf#141704 PPTX import: fix hyperlinks on images added via placeholder
Note: see "Interaction..." in the local menu of the image
of the first slide for manual checking of the fix.
See commit 9bb91441b46d677860530d8bf9597c96561a1b0a
"tdf#141704 PPTX import: fix hyperlinks on images"
Change-Id: Iba372c095f76b263575d261a7a0fc98eda449bce
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122429
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r-- | oox/source/ppt/pptgraphicshapecontext.cxx | 3 | ||||
-rw-r--r-- | oox/source/ppt/pptshape.cxx | 6 | ||||
-rw-r--r-- | sd/qa/unit/data/pptx/hyperlinkOnImage.pptx | bin | 0 -> 17576 bytes | |||
-rw-r--r-- | sd/qa/unit/import-tests.cxx | 30 |
4 files changed, 36 insertions, 3 deletions
diff --git a/oox/source/ppt/pptgraphicshapecontext.cxx b/oox/source/ppt/pptgraphicshapecontext.cxx index 296263762897..254f44809c85 100644 --- a/oox/source/ppt/pptgraphicshapecontext.cxx +++ b/oox/source/ppt/pptgraphicshapecontext.cxx @@ -27,6 +27,7 @@ #include <oox/helper/attributelist.hxx> #include <oox/token/namespaces.hxx> #include <oox/token/tokens.hxx> +#include <oox/token/properties.hxx> using namespace oox::core; using namespace ::com::sun::star; @@ -152,6 +153,8 @@ ContextHandlerRef PPTGraphicShapeContext::onCreateContext( sal_Int32 aElementTok case XML_pic : bUseText = false; } + pPlaceholder->getShapeProperties().setAnyProperty( + PROP_URL, mpShapePtr->getShapeProperties().getProperty(PROP_URL)); mpShapePtr->applyShapeReference( *pPlaceholder, bUseText ); PPTShape* pPPTShape = dynamic_cast< PPTShape* >( pPlaceholder.get() ); if ( pPPTShape ) diff --git a/oox/source/ppt/pptshape.cxx b/oox/source/ppt/pptshape.cxx index 757aab1bb3e0..bbc7d2585fd8 100644 --- a/oox/source/ppt/pptshape.cxx +++ b/oox/source/ppt/pptshape.cxx @@ -539,7 +539,9 @@ void PPTShape::addShape( syncDiagramFontHeights(); } - if (getShapeProperties().hasProperty(PROP_URL)) + OUString sURL; + getShapeProperties().getProperty(PROP_URL) >>= sURL; + if (!sURL.isEmpty()) { Reference<XEventsSupplier> xEventsSupplier(xShape, UNO_QUERY); if (!xEventsSupplier.is()) @@ -549,7 +551,6 @@ void PPTShape::addShape( if (!xEvents.is()) return; - OUString sURL; OUString sAPIEventName; sal_Int32 nPropertyCount = 2; css::presentation::ClickAction meClickAction; @@ -563,7 +564,6 @@ void PPTShape::addShape( { "#action?jump=endshow", ClickAction_STOPPRESENTATION }, }; - getShapeProperties().getProperty(PROP_URL) >>= sURL; std::map<OUString, css::presentation::ClickAction>::const_iterator aIt = ActionMap.find(sURL); aIt != ActionMap.end() ? meClickAction = aIt->second diff --git a/sd/qa/unit/data/pptx/hyperlinkOnImage.pptx b/sd/qa/unit/data/pptx/hyperlinkOnImage.pptx Binary files differnew file mode 100644 index 000000000000..38832da5eb25 --- /dev/null +++ b/sd/qa/unit/data/pptx/hyperlinkOnImage.pptx diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index 7bad28a80c86..edf69608092a 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -122,6 +122,7 @@ public: virtual void setUp() override; void testDocumentLayout(); + void testHyperlinkOnImage(); void testTdf142645(); void testTdf141704(); void testTdf142915(); @@ -246,6 +247,7 @@ public: CPPUNIT_TEST_SUITE(SdImportTest); CPPUNIT_TEST(testDocumentLayout); + CPPUNIT_TEST(testHyperlinkOnImage); CPPUNIT_TEST(testTdf142645); CPPUNIT_TEST(testTdf141704); CPPUNIT_TEST(testTdf142915); @@ -446,6 +448,34 @@ void SdImportTest::testDocumentLayout() } } +void SdImportTest::testHyperlinkOnImage() +{ + sd::DrawDocShellRef xDocShRef + = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/hyperlinkOnImage.pptx"), PPTX); + + uno::Reference< beans::XPropertySet > xShape1(getShapeFromPage(1, 0, xDocShRef)); + uno::Reference<document::XEventsSupplier> xEventsSupplier1(xShape1, uno::UNO_QUERY); + uno::Reference<container::XNameAccess> xEvents1(xEventsSupplier1->getEvents()); + uno::Sequence<beans::PropertyValue> props1; + xEvents1->getByName("OnClick") >>= props1; + comphelper::SequenceAsHashMap map1(props1); + auto iter1(map1.find("ClickAction")); + CPPUNIT_ASSERT_EQUAL(css::presentation::ClickAction_LASTPAGE, + iter1->second.get<css::presentation::ClickAction>()); + + uno::Reference< beans::XPropertySet > xShape2(getShapeFromPage(1, 1, xDocShRef)); + uno::Reference<document::XEventsSupplier> xEventsSupplier2(xShape2, uno::UNO_QUERY); + uno::Reference<container::XNameAccess> xEvents2(xEventsSupplier2->getEvents()); + uno::Sequence<beans::PropertyValue> props2; + xEvents2->getByName("OnClick") >>= props2; + comphelper::SequenceAsHashMap map2(props2); + auto iter2(map2.find("ClickAction")); + CPPUNIT_ASSERT_EQUAL(css::presentation::ClickAction_NONE, + iter2->second.get<css::presentation::ClickAction>()); + + xDocShRef->DoClose(); +} + void SdImportTest::testTdf142645() { sd::DrawDocShellRef xDocShRef |