diff options
author | merttumer <mert.tumer@collabora.com> | 2021-03-11 12:16:51 +0300 |
---|---|---|
committer | Mert Tumer <mert.tumer@collabora.com> | 2021-04-20 04:33:35 +0200 |
commit | 415622a523a783fc3494bc09a52ee870a6458e2c (patch) | |
tree | 57ca38fe0450119e0b744e9ae89ee5f2006782c5 | |
parent | 611130065625650adad4e2e2204ca5b42b9f65c0 (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>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114030
Tested-by: Jenkins
-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 17e9ad2b15f9..bbe0e8eb2446 100644 --- a/include/svx/svdmrkv.hxx +++ b/include/svx/svdmrkv.hxx @@ -148,6 +148,7 @@ private: void UndirtyMrkPnt() const; void SetMarkHandlesForLOKit(tools::Rectangle const & rRect, const 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 f42214daf8ad..c0ccd27d070f 100644 --- a/svx/source/svdraw/svdmrkv.cxx +++ b/svx/source/svdraw/svdmrkv.cxx @@ -685,6 +685,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, const SfxViewShell* pOtherShell) { SfxViewShell* pViewShell = GetSfxViewShell(); @@ -737,13 +783,19 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle const & rRect, const S OString sSelectionText; OString sSelectionTextView; boost::property_tree::ptree aTableJsonTree; + boost::property_tree::ptree aGluePointsTree; bool bTableSelection = false; + bool 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); @@ -971,6 +1023,13 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle const & rRect, const S boost::property_tree::write_json(aStream, responseJSON, /*pretty=*/ false); handleArrayStr = ", \"handles\":"; handleArrayStr = handleArrayStr + aStream.str().c_str(); + if (bConnectorSelection) + { + aStream.str(""); + boost::property_tree::write_json(aStream, aGluePointsTree, /*pretty=*/ false); + handleArrayStr = handleArrayStr + ", \"GluePoints\":"; + handleArrayStr = handleArrayStr + aStream.str().c_str(); + } } sSelectionText = aSelection.toString() + ", " + OString::number(nRotAngle.get()); |