diff options
author | merttumer <mert.tumer@collabora.com> | 2021-03-11 12:16:51 +0300 |
---|---|---|
committer | Mert Tumer <mert.tumer@collabora.com> | 2021-04-09 07:10:06 +0200 |
commit | 04c30909215141a1c405b0dcfb8032ee5fa345fe (patch) | |
tree | f29ebf9514bcc590893f2b28b660ba2e7e04bd00 | |
parent | dedd720cf7188bb1e70f977099c5cee76e83541d (diff) |
Get Glue Points in the selection callback
Change-Id: I0d038517710c68f80f8e35b8ebebd34f264434f3
Signed-off-by: merttumer <mert.tumer@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112324
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
-rw-r--r-- | include/svx/svdmrkv.hxx | 1 | ||||
-rw-r--r-- | svx/source/svdraw/svdmrkv.cxx | 59 |
2 files changed, 60 insertions, 0 deletions
diff --git a/include/svx/svdmrkv.hxx b/include/svx/svdmrkv.hxx index f080a57d1bbb..160f55fd8ad7 100644 --- a/include/svx/svdmrkv.hxx +++ b/include/svx/svdmrkv.hxx @@ -149,6 +149,7 @@ private: void UndirtyMrkPnt() const; void SetMarkHandlesForLOKit(tools::Rectangle const & rRect, SfxViewShell* pOtherShell); + bool dumpGluePointsToJSON(boost::property_tree::ptree& rTree); protected: virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override; diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx index a4af90341b25..c2d4c09282e3 100644 --- a/svx/source/svdraw/svdmrkv.cxx +++ b/svx/source/svdraw/svdmrkv.cxx @@ -703,6 +703,52 @@ OUString lcl_getDragParameterString( const OUString& rCID ) } } // anonymous namespace +bool SdrMarkView::dumpGluePointsToJSON(boost::property_tree::ptree& rTree) +{ + bool result = false; + if (OutputDevice* rOutDev = mpMarkedPV->GetView().GetFirstOutputDevice()) + { + bool bConvertUnit = false; + if (rOutDev->GetMapMode().GetMapUnit() == MapUnit::Map100thMM) + bConvertUnit = true; + const SdrObjList* pOL = mpMarkedPV->GetObjList(); + const size_t nObjCount = pOL->GetObjCount(); + boost::property_tree::ptree elements; + for (size_t nObjNum = 0; nObjNum < nObjCount; ++nObjNum) + { + const SdrObject* pObj = pOL->GetObj(nObjNum); + const SdrGluePointList* pGPL = pObj->GetGluePointList(); + if (pGPL != nullptr && pGPL->GetCount()) + { + boost::property_tree::ptree object; + boost::property_tree::ptree points; + for (size_t i = 0; i < pGPL->GetCount(); ++i) + { + boost::property_tree::ptree node; + boost::property_tree::ptree point; + const SdrGluePoint& rGP = (*pGPL)[i]; + // coordinates are relative to the OBJ snap rect + Point rPoint = pObj->GetSnapRect().TopLeft(); + rPoint.Move(rGP.GetPos().getX(), rGP.GetPos().getY()); + if (bConvertUnit) + rPoint = OutputDevice::LogicToLogic(rPoint, MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip)); + point.put("x", rPoint.getX()); + point.put("y", rPoint.getY()); + node.put("glueId", rGP.GetId()); + node.add_child("point", point); + points.push_back(std::make_pair("", node)); + } + object.put("id", reinterpret_cast<sal_IntPtr>(pObj)); + object.add_child("gluepoints", points); + elements.push_back(std::make_pair("", object)); + result = true; + } + } + rTree.add_child("shapes", elements); + } + return result; +} + void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle const & rRect, SfxViewShell* pOtherShell) { SfxViewShell* pViewShell = GetSfxViewShell(); @@ -755,13 +801,19 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle const & rRect, SfxView OString sSelectionText; OString sSelectionTextView; boost::property_tree::ptree aTableJsonTree; + boost::property_tree::ptree aGluePointsTree; bool bTableSelection = false; + size_t bConnectorSelection = false; if (mpMarkedObj && mpMarkedObj->GetObjIdentifier() == OBJ_TABLE) { auto& rTableObject = dynamic_cast<sdr::table::SdrTableObj&>(*mpMarkedObj); bTableSelection = rTableObject.createTableEdgesJson(aTableJsonTree); } + if (mpMarkedObj && mpMarkedObj->GetObjIdentifier() == OBJ_EDGE) + { + bConnectorSelection = dumpGluePointsToJSON(aGluePointsTree); + } if (GetMarkedObjectCount()) { SdrMark* pM = GetSdrMarkByIndex(0); @@ -994,6 +1046,13 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle const & rRect, SfxView boost::property_tree::write_json(aStream, responseJSON, /*pretty=*/ false); handleArrayStr = ", \"handles\":"; handleArrayStr += aStream.str().c_str(); + if (bConnectorSelection) + { + aStream.str(""); + boost::property_tree::write_json(aStream, aGluePointsTree, /*pretty=*/ false); + handleArrayStr += ", \"GluePoints\":"; + handleArrayStr += aStream.str().c_str(); + } } sSelectionText = aSelection.toString() + ", " + OString::number(nRotAngle); |