From 316b7f90cb06b41e186a1a5a868e49693ba010cc Mon Sep 17 00:00:00 2001 From: Dennis Francis Date: Mon, 13 Dec 2021 11:36:53 +0530 Subject: lokCalcRTL: ensure +ve X coords in shape handles/selections msgs LOK client expects all coordinates to be in +ve document coordinates, so negate the negative X coordinates of LOK RTL shapes before sending the selection/handles messages. Change-Id: I683581370c5b115efbe315224d6218ec2e74c7f1 --- svx/source/svdraw/svdmrkv.cxx | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx index 6ca400399f5c..ba6a8d586d69 100644 --- a/svx/source/svdraw/svdmrkv.cxx +++ b/svx/source/svdraw/svdmrkv.cxx @@ -686,6 +686,7 @@ OUString lcl_getDragParameterString( const OUString& rCID ) bool SdrMarkView::dumpGluePointsToJSON(boost::property_tree::ptree& rTree) { bool result = false; + tools::Long nSignX = mbNegativeX ? -1 : 1; if (OutputDevice* rOutDev = mpMarkedPV->GetView().GetFirstOutputDevice()) { bool bConvertUnit = false; @@ -716,7 +717,7 @@ bool SdrMarkView::dumpGluePointsToJSON(boost::property_tree::ptree& rTree) Point rPoint = rGP.GetAbsolutePos(*pObj); if (bConvertUnit) rPoint = OutputDevice::LogicToLogic(rPoint, MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip)); - point.put("x", rPoint.getX()); + point.put("x", nSignX * rPoint.getX()); point.put("y", rPoint.getY()); node.add_child("point", point); points.push_back(std::make_pair("", node)); @@ -729,7 +730,7 @@ bool SdrMarkView::dumpGluePointsToJSON(boost::property_tree::ptree& rTree) if (bConvertUnit) p = OutputDevice::LogicToLogic(p, MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip)); boost::property_tree::ptree gridOffset; - gridOffset.put("x", p.getX()); + gridOffset.put("x", nSignX * p.getX()); gridOffset.put("y", p.getY()); object.add_child("gridoffset", gridOffset); } @@ -748,6 +749,7 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle const & rRect, const S SfxViewShell* pViewShell = GetSfxViewShell(); tools::Rectangle aSelection(rRect); + tools::Long nSignX = mbNegativeX ? -1 : 1; bool bIsChart = false; Point addLogicOffset(0, 0); bool convertMapMode = false; @@ -845,7 +847,7 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle const & rRect, const S if (convertMapMode) p = OutputDevice::LogicToLogic(p, MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip)); aExtraInfo.append(",\"gridOffsetX\":"); - aExtraInfo.append(OString::number(p.getX())); + aExtraInfo.append(OString::number(nSignX * p.getX())); aExtraInfo.append(",\"gridOffsetY\":"); aExtraInfo.append(OString::number(p.getY())); } @@ -948,6 +950,8 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle const & rRect, const S const basegfx::B2DPoint aB2Point = aPolygon.getB2DPoint(nIndex); Point aPoint(aB2Point.getX(), aB2Point.getY()); aPoint.Move(aLogicOffset.getX(), aLogicOffset.getY()); + if (mbNegativeX) + aPoint.setX(-aPoint.X()); if (nIndex > 0) sPolygonElem += " "; sPolygonElem += aPoint.toString(); @@ -1058,8 +1062,21 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle const & rRect, const S handleArrayStr = handleArrayStr + aStream.str().c_str(); } } - sSelectionText = aSelection.toString() + - ", " + OString::number(nRotAngle); + + if (mbNegativeX) + { + tools::Rectangle aNegatedRect(aSelection); + aNegatedRect.SetLeft(-aNegatedRect.Left()); + aNegatedRect.SetRight(-aNegatedRect.Right()); + aNegatedRect.Justify(); + sSelectionText = aNegatedRect.toString() + + ", " + OString::number(nRotAngle); + } + else + { + sSelectionText = aSelection.toString() + + ", " + OString::number(nRotAngle); + } if (!aExtraInfo.isEmpty()) { sSelectionTextView = sSelectionText + ", " + aExtraInfo.toString() + "}"; -- cgit