From 5da18620f07e9cf389a37794029fdef80aa8b431 Mon Sep 17 00:00:00 2001 From: merttumer Date: Thu, 25 Mar 2021 12:44:17 +0300 Subject: lok: Send gridOffset of the shape MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In core, the gridOffset is calculated based on the LogicRect's TopLeft coordinate In online, we have the SnapRect and we calculate it based on its TopLeft coordinate SnapRect's TopLeft and LogicRect's TopLeft match when there is no rotation but the rotation is not applied to the LogicRect. Therefore, what we calculate in online does not match in case of the rotated shape. Here we can send the correct gridOffset in the selection callback. whether the shape is rotated or not, we will always have the correct gridOffset Note that the gridOffset is always calculated from the first selected obj Change-Id: Icc62a94879367f9b55ad05887945393452021777 Signed-off-by: merttumer Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113078 Tested-by: Jenkins CollaboraOffice Reviewed-by: Szymon Kłos --- svx/source/svdraw/svdmrkv.cxx | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'svx') diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx index db05163b1ec4..a4af90341b25 100644 --- a/svx/source/svdraw/svdmrkv.cxx +++ b/svx/source/svdraw/svdmrkv.cxx @@ -710,6 +710,7 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle const & rRect, SfxView tools::Rectangle aSelection(rRect); bool bIsChart = false; Point addLogicOffset = Point(0,0); + bool convertMapMode = false; if (!rRect.IsEmpty()) { sal_uInt32 nTotalPaintWindows = this->PaintWindowCount(); @@ -739,7 +740,10 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle const & rRect, SfxView if (OutputDevice* pOutputDevice = mpMarkedPV->GetView().GetFirstOutputDevice()) { if (pOutputDevice->GetMapMode().GetMapUnit() == MapUnit::Map100thMM) + { aSelection = OutputDevice::LogicToLogic(aSelection, MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip)); + convertMapMode = true; + } } } @@ -780,6 +784,26 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle const & rRect, SfxView aExtraInfo.append("\",\"type\":"); aExtraInfo.append(OString::number(pO->GetObjIdentifier())); + // In core, the gridOffset is calculated based on the LogicRect's TopLeft coordinate + // In online, we have the SnapRect and we calculate it based on its TopLeft coordinate + // SnapRect's TopLeft and LogicRect's TopLeft match unless there is rotation + // but the rotation is not applied to the LogicRect. Therefore, + // what we calculate in online does not match with the core in case of the rotation. + // Here we can send the correct gridOffset in the selection callback, this way + // whether the shape is rotated or not, we will always have the correct gridOffset + // Note that the gridOffset is calculated from the first selected obj + basegfx::B2DVector aGridOffset(0.0, 0.0); + if(getPossibleGridOffsetForSdrObject(aGridOffset, GetMarkedObjectByIndex(0), GetSdrPageView())) + { + Point p(aGridOffset.getX(), aGridOffset.getY()); + if (convertMapMode) + p = OutputDevice::LogicToLogic(p, MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip)); + aExtraInfo.append(",\"gridOffsetX\":"); + aExtraInfo.append(OString::number(p.getX())); + aExtraInfo.append(",\"gridOffsetY\":"); + aExtraInfo.append(OString::number(p.getY())); + } + if (bWriterGraphic) { aExtraInfo.append(", \"isWriterGraphic\": true"); @@ -916,7 +940,6 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle const & rRect, SfxView boost::property_tree::ptree poly; boost::property_tree::ptree custom; boost::property_tree::ptree nodes; - const bool convertMapMode = mpMarkedPV->GetView().GetFirstOutputDevice()->GetMapMode().GetMapUnit() == MapUnit::Map100thMM; for (size_t i = 0; i < maHdlList.GetHdlCount(); i++) { SdrHdl *pHdl = maHdlList.GetHdl(i); -- cgit