include/svx/svdpage.hxx                      |    1 +
 sd/qa/unit/tiledrendering/tiledrendering.cxx |    3 +++
 svx/source/svdraw/svdmrkv.cxx                |   13 ++++++++++++-
 svx/source/svdraw/svdpage.cxx                |   19 +++++++++++++++++++
 4 files changed, 35 insertions(+), 1 deletion(-)

New commits:
commit 183078c3a4314f88c858cf0825ffa7bfcd384dd6
Author:     Gökay Şatır <gokaysa...@collabora.com>
AuthorDate: Thu Aug 1 15:07:39 2024 +0300
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Fri Aug 2 15:21:22 2024 +0200

    When a shape is selected, send other shapes' rectangles.
    
    GitHub issue link:
    * https://github.com/CollaboraOnline/online/issues/9689
    
    Also add OrdNum property to ExtraInfo in order to exclude the selected 
shape from the list.
    Check new properties in tiledrendering test.
    
    Signed-off-by: Gökay Şatır <gokaysa...@collabora.com>
    Change-Id: I544e2c8089510f47b0cc0f25e368cad6d459cb2e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171374
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/include/svx/svdpage.hxx b/include/svx/svdpage.hxx
index 0fcca5be701d..cd28cf8ab1ac 100644
--- a/include/svx/svdpage.hxx
+++ b/include/svx/svdpage.hxx
@@ -94,6 +94,7 @@ public:
     virtual SdrObject* getSdrObjectFromSdrObjList() const;
 
     void CopyObjects(const SdrObjList& rSrcList);
+    static OString GetObjectRectangles(const SdrObjList& rSrcList);
 
     // tdf#116879 clean up everything (without Undo), plus broadcasting
     // changes. Split to this call and a private one (impClearSdrObjList)
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx 
b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 39668614084b..3f91ad463f49 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -2693,6 +2693,9 @@ void lcl_extractHandleParameters(std::string_view 
selection, sal_uInt32& id, sal
     id = handle0.get_child("id").get_value<int>();
     x = handle0.get_child("point").get_child("x").get_value<int>();
     y = handle0.get_child("point").get_child("y").get_value<int>();
+
+    CPPUNIT_ASSERT(aTree.get_child("OrdNum").get_value<int>() >= 0);
+    CPPUNIT_ASSERT(aTree.get_child("ObjectRectangles").size() >= 1);
 }
 
 }
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index 43a803d8b4dd..fbbbfcac0cad 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -947,7 +947,9 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle 
const & rRect, const S
             aExtraInfo.append("{\"id\":\""
                 + OString::number(reinterpret_cast<sal_IntPtr>(pO))
                 + "\",\"type\":"
-                + 
OString::number(static_cast<sal_Int32>(pO->GetObjIdentifier())));
+                + 
OString::number(static_cast<sal_Int32>(pO->GetObjIdentifier()))
+                + ",\"OrdNum\":" + OString::number(pO->GetOrdNum())
+                );
 
             if (mpMarkedObj && !pOtherShell)
             {
@@ -1215,6 +1217,15 @@ void 
SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle const & rRect, const S
                         aExtraInfo.append(", \"url\": \"" + 
mediaObj->getTempURL().toUtf8() + "\"");
                 }
 
+                SdrPage *pPage = pPageView ? pPageView->GetPage(): nullptr;
+                if (pPage)
+                {
+                    // Send all objects' rectangles along with the selected 
object's information.
+                    // Other rectangles can be used for aligning the selected 
object referencing the others.
+                    OString objectRectangles = 
SdrObjList::GetObjectRectangles(*pPage);
+                    aExtraInfo.append(", \"ObjectRectangles\": "_ostr + 
objectRectangles);
+                }
+
                 aExtraInfo.append(handleArrayStr
                     + "}");
                 sSelectionText += ", " + aExtraInfo;
diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx
index b15a8438d56e..cbf15673b12c 100644
--- a/svx/source/svdraw/svdpage.cxx
+++ b/svx/source/svdraw/svdpage.cxx
@@ -134,6 +134,25 @@ SdrObject* SdrObjList::getSdrObjectFromSdrObjList() const
     return nullptr;
 }
 
+OString SdrObjList::GetObjectRectangles(const SdrObjList& rSrcList)
+{
+    OString result = "["_ostr;
+
+    for (const rtl::Reference<SdrObject>& item: rSrcList)
+    {
+        if (item->IsPrintable() && item->IsVisible())
+        {
+            tools::Rectangle rectangle = item->GetCurrentBoundRect();
+            OString ordNum(std::to_string(item->GetOrdNum()));
+            result += "["_ostr + rectangle.toString() + ", "_ostr + ordNum + 
"]"_ostr;
+        }
+    }
+
+    result = result.replaceAll("]["_ostr, "],["_ostr);
+
+    return result + "]"_ostr;
+}
+
 void SdrObjList::CopyObjects(const SdrObjList& rSrcList)
 {
     CloneList aCloneList;

Reply via email to