diff options
author | merttumer <mert.tumer@collabora.com> | 2021-03-25 12:44:17 +0300 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2021-03-29 14:06:35 +0200 |
commit | 5da18620f07e9cf389a37794029fdef80aa8b431 (patch) | |
tree | eb5bbc8964914e656fc400d89f374ae5d38129ab /svx/source/svdraw | |
parent | a4081f31d3b058c0016adb8b2cb83a64221cb3bc (diff) |
lok: Send gridOffset of the shape
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 <mert.tumer@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113078
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'svx/source/svdraw')
-rw-r--r-- | svx/source/svdraw/svdmrkv.cxx | 25 |
1 files changed, 24 insertions, 1 deletions
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); |