sd/source/ui/unoidl/unomodel.cxx |  110 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 110 insertions(+)

New commits:
commit d24439927081692ab8fe355a04264e8501c37a90
Author:     Hubert Figuière <h...@collabora.com>
AuthorDate: Mon Sep 9 11:31:50 2024 -0400
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Wed Nov 27 13:06:53 2024 +0100

    LOKit/impress: Send click actions for slideshow
    
    This will allow to implement the Interaction between slides
    in the slideshow.
    
    Change-Id: I0c4ca1858ab9935fd4926b776e96ba5b7a386e0b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177398
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Jenkins

diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index ecc9c0fb9645..5023b41a1996 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -4246,6 +4246,98 @@ void SdXImpressDocument::initializeDocument()
     }
 }
 
+static
+void getShapeClickAction(const uno::Reference<drawing::XShape> &xShape, 
::tools::JsonWriter& rJsonWriter)
+{
+    bool bIsShapeVisible = true;
+    uno::Reference<beans::XPropertySet> xShapeProps(xShape, uno::UNO_QUERY);
+    if (!xShapeProps)
+        return;
+    xShapeProps->getPropertyValue("Visible") >>= bIsShapeVisible;
+    if (!bIsShapeVisible)
+        return;
+
+    presentation::ClickAction eClickAction = presentation::ClickAction_NONE;
+    xShapeProps->getPropertyValue(u"OnClick"_ustr) >>= eClickAction;
+
+    if (eClickAction != presentation::ClickAction_NONE)
+    {
+        auto aShape = rJsonWriter.startStruct();
+
+        sal_Int32 nVerb = 0;
+        OUString sBookmark;
+
+        xShapeProps->getPropertyValue(u"Bookmark"_ustr) >>= sBookmark;
+        {
+            auto* pObject = SdrObject::getSdrObjectFromXShape(xShape);
+            auto const& rRectangle = pObject->GetLogicRect();
+            auto aRectangle = o3tl::convert(rRectangle, o3tl::Length::mm100, 
o3tl::Length::twip);
+            auto aRect = rJsonWriter.startNode("bounds");
+            rJsonWriter.put("x", aRectangle.Left());
+            rJsonWriter.put("y", aRectangle.Top());
+            rJsonWriter.put("width", aRectangle.GetWidth());
+            rJsonWriter.put("height", aRectangle.GetHeight());
+        }
+
+        {
+            auto aInteraction = rJsonWriter.startNode("clickAction");
+            switch (eClickAction)
+            {
+            case presentation::ClickAction_BOOKMARK:
+                rJsonWriter.put("action", "bookmark");
+                rJsonWriter.put("bookmark", sBookmark);
+                break;
+            case presentation::ClickAction_DOCUMENT:
+                rJsonWriter.put("action", "document");
+                rJsonWriter.put("document", sBookmark);
+                break;
+
+            case presentation::ClickAction_PREVPAGE:
+                rJsonWriter.put("action", "prevpage");
+                break;
+            case presentation::ClickAction_NEXTPAGE:
+                rJsonWriter.put("action", "nextpage");
+                break;
+
+            case presentation::ClickAction_FIRSTPAGE:
+                rJsonWriter.put("action", "firstpage");
+                break;
+            case presentation::ClickAction_LASTPAGE:
+                rJsonWriter.put("action", "lastpage");
+                break;
+
+            case presentation::ClickAction_SOUND:
+                rJsonWriter.put("action", "sound");
+                rJsonWriter.put("sound", sBookmark);
+                break;
+
+            case presentation::ClickAction_VERB:
+                rJsonWriter.put("action", "verb");
+                xShapeProps->getPropertyValue(u"Verb"_ustr) >>= nVerb;
+                rJsonWriter.put("verb", nVerb);
+                break;
+
+            case presentation::ClickAction_PROGRAM:
+                rJsonWriter.put("action", "program");
+                rJsonWriter.put("program", sBookmark);
+                break;
+
+            case presentation::ClickAction_MACRO:
+                rJsonWriter.put("action", "macro");
+                rJsonWriter.put("macro", sBookmark);
+                break;
+
+            case presentation::ClickAction_STOPPRESENTATION:
+                rJsonWriter.put("action", "stoppresentation");
+                break;
+
+            default:
+                break;
+            }
+        }
+    }
+}
+
 OString SdXImpressDocument::getPresentationInfo() const
 {
     ::tools::JsonWriter aJsonWriter;
@@ -4362,6 +4454,24 @@ OString SdXImpressDocument::getPresentationInfo() const
                     }
                 }
 
+                uno::Reference<drawing::XShapes> const 
xShapes(cppu::getXWeak(pSlide), uno::UNO_QUERY_THROW);
+                if (xShapes.is())
+                {
+                    auto aVideoList = aJsonWriter.startArray("interactions");
+                    auto count = xShapes->getCount();
+                    for (auto j = 0; j < count; j++)
+                    {
+                        auto xObject = xShapes->getByIndex(j);
+                        uno::Reference<drawing::XShape> xShape(xObject, 
uno::UNO_QUERY);
+                        if (!xShape.is())
+                        {
+                            continue;
+                        }
+
+                        getShapeClickAction(xShape, aJsonWriter);
+                    }
+                }
+
                 sal_Int32 nTransitionType = 0;
                 pSlide->getPropertyValue("TransitionType") >>= nTransitionType;
 

Reply via email to