[Libreoffice-commits] core.git: editeng/source

Ashod Nakashian ashod.nakashian at collabora.co.uk
Sun May 29 01:59:24 UTC 2016


 editeng/source/editeng/impedit.cxx |   49 +++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

New commits:
commit 8915919b57473fd88e338e874652d0b87e0c2482
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Fri May 27 21:59:31 2016 -0400

    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 at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>
    (cherry picked from commit b736ea1b02346ba190f280f254714bb6e1983858)
    Reviewed-on: https://gerrit.libreoffice.org/25572
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index 59f20a4..c3b6058 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;


More information about the Libreoffice-commits mailing list