diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2016-05-27 21:59:31 -0400 |
---|---|---|
committer | Ashod Nakashian <ashnakash@gmail.com> | 2016-05-29 01:58:52 +0000 |
commit | 8915919b57473fd88e338e874652d0b87e0c2482 (patch) | |
tree | 1864463f9e2d726be74a66d38fc1a073d9f291fd /editeng | |
parent | 33d4f7e5624d77ef1ce51aece1c8a0ef7ea21603 (diff) |
bccu#1851 - CTRL+A in Writer comments shows selection at top-left corner
Change-Id: Ia87b86a45a38449d59eb7bcea7f8cb4068655a17
Reviewed-on: https://gerrit.libreoffice.org/25571
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
(cherry picked from commit b736ea1b02346ba190f280f254714bb6e1983858)
Reviewed-on: https://gerrit.libreoffice.org/25572
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/source/editeng/impedit.cxx | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx index 59f20a4587b3..c3b605810c96 100644 --- a/editeng/source/editeng/impedit.cxx +++ b/editeng/source/editeng/impedit.cxx @@ -160,6 +160,34 @@ void ImpEditView::SetEditSelection( const EditSelection& rEditSelection ) } } +/// Translate absolute <-> relative twips: LOK wants absolute coordinates as output and gives absolute coordinates as input. +void lcl_translateTwips(vcl::Window& rParent, vcl::Window& rChild) +{ + // Don't translate if we already have a non-zero origin. + // This prevents multiple translate calls that negate + // one another. + const Point aOrigin = rChild.GetMapMode().GetOrigin(); + if (aOrigin.getX() == 0 && aOrigin.getY() == 0) + { + // Set map mode, so that callback payloads will contain absolute coordinates instead of relative ones. + Point aOffset(rChild.GetOutOffXPixel() - rParent.GetOutOffXPixel(), rChild.GetOutOffYPixel() - rParent.GetOutOffYPixel()); + if (!rChild.IsMapModeEnabled()) + { + MapMode aMapMode(rChild.GetMapMode()); + aMapMode.SetMapUnit(MAP_TWIP); + aMapMode.SetScaleX(rParent.GetMapMode().GetScaleX()); + aMapMode.SetScaleY(rParent.GetMapMode().GetScaleY()); + rChild.SetMapMode(aMapMode); + rChild.EnableMapMode(); + } + aOffset = rChild.PixelToLogic(aOffset); + MapMode aMapMode(rChild.GetMapMode()); + aMapMode.SetOrigin(aOffset); + aMapMode.SetMapUnit(rParent.GetMapMode().GetMapUnit()); + rChild.SetMapMode(aMapMode); + rChild.EnableMapMode(false); + } +} void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, OutputDevice* pTargetDevice ) { @@ -317,6 +345,25 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, Ou if (comphelper::LibreOfficeKit::isActive() && !pOldRegion) { + pOutWin->Push(PushFlags::MAPMODE); + if (pOutWin->GetMapMode().GetMapUnit() == MAP_TWIP) + { + // Find the parent that is not right + // on top of us to use its offset. + vcl::Window* parent = pOutWin->GetParent(); + while (parent && + parent->GetOutOffXPixel() == pOutWin->GetOutOffXPixel() && + parent->GetOutOffYPixel() == pOutWin->GetOutOffYPixel()) + { + parent = parent->GetParent(); + } + + if (parent) + { + lcl_translateTwips(*parent, *pOutWin); + } + } + bool bMm100ToTwip = pOutWin->GetMapMode().GetMapUnit() == MAP_100TH_MM; Point aOrigin; @@ -359,6 +406,8 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, Ou sRectangle = comphelper::string::join("; ", v); } libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION, sRectangle.getStr()); + + pOutWin->Pop(); } delete pPolyPoly; |