diff options
author | mert <mert.tumer@collabora.com> | 2021-01-04 22:39:56 +0300 |
---|---|---|
committer | Mert Tumer <mert.tumer@collabora.com> | 2021-02-26 03:26:19 +0100 |
commit | 389cfb583f3a18d9921f2ca9e4dfae22c01c754e (patch) | |
tree | 930b197c8e4f0221a24ea67c1cd0acb9127dfa8e /svx | |
parent | e60bebd4c5257b0f592d27c74399de1498ac725b (diff) |
Send handle information of selected shapes to LOK
Include the handle information to the callback for
the new uno command for interactive dragging/resizing
operations.
Change-Id: I57c03abc22d3831606da2b698f1de080e9b4da78
Signed-off-by: mert <mert.tumer@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108686
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111506
Tested-by: Jenkins
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/svdraw/svdmrkv.cxx | 84 |
1 files changed, 76 insertions, 8 deletions
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx index 446020ef48d5..fb8fbc0ec4db 100644 --- a/svx/source/svdraw/svdmrkv.cxx +++ b/svx/source/svdraw/svdmrkv.cxx @@ -62,6 +62,8 @@ #include <com/sun/star/view/XSelectionSupplier.hpp> #include <boost/property_tree/json_parser.hpp> +#include <boost/optional/optional.hpp> +#include <tools/UnitConversion.hxx> using namespace com::sun::star; @@ -726,6 +728,7 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle const & rRect, const S { OString sSelectionText; + OString sSelectionTextView; boost::property_tree::ptree aTableJsonTree; bool bTableSelection = false; @@ -744,6 +747,7 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle const & rRect, const S bool bWriterGraphic = pO->HasLimitedRotation(); OStringBuffer aExtraInfo; + OString handleArrayStr; aExtraInfo.append("{\"id\":\""); aExtraInfo.append(OString::number(reinterpret_cast<sal_IntPtr>(pO))); @@ -880,18 +884,82 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle const & rRect, const S } } } - aExtraInfo.append("}"); + if (!pOtherShell && maHdlList.GetHdlCount()) + { + boost::property_tree::ptree responseJSON; + boost::property_tree::ptree others; + boost::property_tree::ptree rectangle; + boost::property_tree::ptree poly; + boost::property_tree::ptree custom; + boost::property_tree::ptree nodes; + for (size_t i = 0; i < maHdlList.GetHdlCount(); i++) + { + SdrHdl *pHdl = maHdlList.GetHdl(i); + boost::property_tree::ptree child; + boost::property_tree::ptree point; + sal_Int32 kind = static_cast<sal_Int32>(pHdl->GetKind()); + child.put("id", pHdl->GetObjHdlNum()); + child.put("kind", kind); + child.put("pointer", static_cast<sal_Int32>(pHdl->GetPointer())); + point.put("x", convertMm100ToTwip(pHdl->GetPos().getX())); + point.put("y", convertMm100ToTwip(pHdl->GetPos().getY())); + child.add_child("point", point); + const auto node = std::make_pair("", child); + boost::property_tree::ptree* selectedNode = nullptr; + if (kind >= static_cast<sal_Int32>(SdrHdlKind::UpperLeft) && kind <= static_cast<sal_Int32>(SdrHdlKind::LowerRight)) + { + selectedNode = &rectangle; + } + else if (kind == static_cast<sal_Int32>(SdrHdlKind::Poly)) + { + selectedNode = &poly; + } + else if (kind == static_cast<sal_Int32>(SdrHdlKind::CustomShape1)) + { + selectedNode = &custom; + } + else + { + selectedNode = &others; + } + std::string sKind = std::to_string(kind); + boost::optional< boost::property_tree::ptree& > kindNode = selectedNode->get_child_optional(sKind.c_str()); + if (!kindNode) + { + boost::property_tree::ptree newChild; + newChild.push_back(node); + selectedNode->add_child(sKind.c_str(), newChild); + } + else + kindNode.get().push_back(node); + } + nodes.add_child("rectangle", rectangle); + nodes.add_child("poly", poly); + nodes.add_child("custom", custom); + nodes.add_child("others", others); + responseJSON.add_child("kinds", nodes); + std::stringstream aStream; + boost::property_tree::write_json(aStream, responseJSON, /*pretty=*/ false); + handleArrayStr = ", \"handles\":"; + handleArrayStr = handleArrayStr + aStream.str().c_str(); + } sSelectionText = aSelection.toString() + ", " + OString::number(nRotAngle.get()); if (!aExtraInfo.isEmpty()) { + sSelectionTextView = sSelectionText + ", " + aExtraInfo.toString() + "}"; + aExtraInfo.append(handleArrayStr); + aExtraInfo.append("}"); sSelectionText += ", " + aExtraInfo.makeStringAndClear(); } } if (sSelectionText.isEmpty()) + { sSelectionText = "EMPTY"; + sSelectionTextView = "EMPTY"; + } if (bTableSelection) { @@ -916,14 +984,14 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle const & rRect, const S // Another shell wants to know about our existing // selection. if (pViewShell != pOtherShell) - SfxLokHelper::notifyOtherView(pViewShell, pOtherShell, LOK_CALLBACK_GRAPHIC_VIEW_SELECTION, "selection", sSelectionText); + SfxLokHelper::notifyOtherView(pViewShell, pOtherShell, LOK_CALLBACK_GRAPHIC_VIEW_SELECTION, "selection", sSelectionTextView); } else { // We have a new selection, so both pViewShell and the // other views want to know about it. pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_GRAPHIC_SELECTION, sSelectionText.getStr()); - SfxLokHelper::notifyOtherViews(pViewShell, LOK_CALLBACK_GRAPHIC_VIEW_SELECTION, "selection", sSelectionText); + SfxLokHelper::notifyOtherViews(pViewShell, LOK_CALLBACK_GRAPHIC_VIEW_SELECTION, "selection", sSelectionTextView); } } } @@ -1042,11 +1110,6 @@ void SdrMarkView::SetMarkHandles(SfxViewShell* pOtherShell) tools::Rectangle aRect(GetMarkedObjRect()); - if (bTiledRendering && pViewShell) - { - SetMarkHandlesForLOKit(aRect, pOtherShell); - } - if (bFrmHdl) { if(!aRect.IsEmpty()) @@ -1224,6 +1287,11 @@ void SdrMarkView::SetMarkHandles(SfxViewShell* pOtherShell) } } + // moved it here to access all the handles for callback. + if (bTiledRendering && pViewShell) + { + SetMarkHandlesForLOKit(aRect, pOtherShell); + } // rotation point/axis of reflection if(!bLimitedRotation) { |