summaryrefslogtreecommitdiff
path: root/editeng/source/editeng
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2016-05-27 21:59:31 -0400
committerAndras Timar <andras.timar@collabora.com>2016-06-26 14:00:42 +0200
commit2216e720d10bf3dce656d955762f02cca7d3f98e (patch)
treec22309cd66d2937e4139e593f3aedcb038aa1c9f /editeng/source/editeng
parente4542f83834e9d92f490433c364f37c82ccd4d2b (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> (cherry picked from commit 8915919b57473fd88e338e874652d0b87e0c2482)
Diffstat (limited to 'editeng/source/editeng')
-rw-r--r--editeng/source/editeng/impedit.cxx49
1 files changed, 49 insertions, 0 deletions
diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index bcbbf45fb244..b77dab41c68f 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -187,6 +187,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 )
{
@@ -342,6 +370,25 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, Ou
if (isTiledRendering() && !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;
@@ -385,6 +432,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;