summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorGökay Şatır <gokaysatir@collabora.com>2024-08-07 17:41:21 +0300
committerMiklos Vajna <vmiklos@collabora.com>2024-08-09 08:45:11 +0200
commit7f259891ed8d7f20466280df7a2ddbc2dfab9ad8 (patch)
treea0a082881524598e605c96b5e56c10ebfc03a25d /svx
parent1fd9f1a62b1a5f0ab5d7d7a6612dd5e87d98d66e (diff)
Simplify GetObjectRectangles function with JSonWriter.
This is a follow up for: * https://gerrit.libreoffice.org/c/core/+/171374 Signed-off-by: Gökay Şatır <gokaysatir@collabora.com> Change-Id: I66bf8c100053907a0e2999730a6ef19e1144ae58 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171598 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/svdraw/svdmrkv.cxx3
-rw-r--r--svx/source/svdraw/svdpage.cxx24
2 files changed, 17 insertions, 10 deletions
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index 1c78c9dab9e9..67df22bd05ad 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -1223,7 +1223,8 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle const & rRect, const S
{
// 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);
+ // Replace curly braces with empty string in order to merge it with the resulting string.
+ OString objectRectangles = SdrObjList::GetObjectRectangles(*pPage).replaceAll("{"_ostr, ""_ostr).replaceAll("}"_ostr, ""_ostr);
aExtraInfo.append(", \"ObjectRectangles\": "_ostr + objectRectangles);
}
diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx
index cbf15673b12c..eefed8094632 100644
--- a/svx/source/svdraw/svdpage.cxx
+++ b/svx/source/svdraw/svdpage.cxx
@@ -30,6 +30,7 @@
#include <string.h>
#include <tools/debug.hxx>
+#include <tools/json_writer.hxx>
#include <comphelper/diagnose_ex.hxx>
#include <comphelper/lok.hxx>
@@ -136,21 +137,26 @@ SdrObject* SdrObjList::getSdrObjectFromSdrObjList() const
OString SdrObjList::GetObjectRectangles(const SdrObjList& rSrcList)
{
- OString result = "["_ostr;
+ tools::JsonWriter jsWriter;
- for (const rtl::Reference<SdrObject>& item: rSrcList)
{
- if (item->IsPrintable() && item->IsVisible())
+ auto array = jsWriter.startAnonArray();
+
+ for (const rtl::Reference<SdrObject>& item: rSrcList)
{
- tools::Rectangle rectangle = item->GetCurrentBoundRect();
- OString ordNum(std::to_string(item->GetOrdNum()));
- result += "["_ostr + rectangle.toString() + ", "_ostr + ordNum + "]"_ostr;
+ if (item->IsPrintable() && item->IsVisible())
+ {
+ tools::Rectangle rectangle = item->GetCurrentBoundRect();
+ OString value(std::to_string(item->GetOrdNum()));
+ value = rectangle.toString() + ", "_ostr + value;
+
+ auto subArray = jsWriter.startAnonArray();
+ jsWriter.putRaw(value);
+ }
}
}
- result = result.replaceAll("]["_ostr, "],["_ostr);
-
- return result + "]"_ostr;
+ return jsWriter.finishAndGetAsOString();
}
void SdrObjList::CopyObjects(const SdrObjList& rSrcList)