[Libreoffice-commits] core.git: oox/source sd/qa

Tibor Nagy (via logerrit) logerrit at kemper.freedesktop.org
Mon Sep 27 15:04:52 UTC 2021


 oox/source/ppt/pptgraphicshapecontext.cxx  |    3 ++
 oox/source/ppt/pptshape.cxx                |    6 ++---
 sd/qa/unit/data/pptx/hyperlinkOnImage.pptx |binary
 sd/qa/unit/import-tests.cxx                |   30 +++++++++++++++++++++++++++++
 4 files changed, 36 insertions(+), 3 deletions(-)

New commits:
commit 6e200689eb309cdbe1e4f08311a400835de19bfb
Author:     Tibor Nagy <nagy.tibor2 at nisz.hu>
AuthorDate: Wed Sep 22 13:25:00 2021 +0200
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Mon Sep 27 17:04:13 2021 +0200

    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 at numbertext.org>
    Reviewed-by: László Németh <nemeth at numbertext.org>

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
new file mode 100644
index 000000000000..38832da5eb25
Binary files /dev/null and b/sd/qa/unit/data/pptx/hyperlinkOnImage.pptx differ
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


More information about the Libreoffice-commits mailing list