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

Miklos Vajna vmiklos at collabora.co.uk
Fri Nov 13 08:31:25 PST 2015


 editeng/source/editeng/impedit.cxx    |    9 +++++++++
 sw/source/uibase/docvw/SidebarWin.cxx |   28 ++++++++++++++++++++++------
 2 files changed, 31 insertions(+), 6 deletions(-)

New commits:
commit 57972554b58a680f47a05f4d6711c99106f80523
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Nov 13 17:30:22 2015 +0100

    sw lok comments: fix position of blinking cursor after mouse click
    
    LOK always works in absolute twips (origo being the top left corner of
    SwEditWin), so not only the callbacks have to translate relative twips
    to absolute ones, but the opposite have to be done for mouse event
    coordinates.
    
    With this, clicking at a random position inside a comment places the
    blinking cursor at a reasonable position, not always at 0,0.
    
    Change-Id: Ic8d20f177acd9e1908acf17698c53a1470bd4aec

diff --git a/sw/source/uibase/docvw/SidebarWin.cxx b/sw/source/uibase/docvw/SidebarWin.cxx
index 304e214..1877e70 100644
--- a/sw/source/uibase/docvw/SidebarWin.cxx
+++ b/sw/source/uibase/docvw/SidebarWin.cxx
@@ -357,14 +357,25 @@ void SwSidebarWin::Draw(OutputDevice* pDev, const Point& rPt, const Size& rSz, D
     }
 }
 
-/// We want to work in absolute twips: so set delta between rChild and rParent as origin on rChild, then disable map mode on rChild.
-static void lcl_setAbsoluteTwips(vcl::Window& rParent, vcl::Window& rChild)
+/// Translate absolute <-> relative twips: LOK wants absolute coordinates as output and gives absolute coordinates as input.
+static void lcl_translateTwips(vcl::Window& rParent, vcl::Window& rChild, MouseEvent* pMouseEvent)
 {
+    // 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());
+    aOffset = rChild.PixelToLogic(aOffset);
     MapMode aMapMode(rChild.GetMapMode());
-    aMapMode.SetOrigin(rChild.PixelToLogic(aOffset));
+    aMapMode.SetOrigin(aOffset);
     rChild.SetMapMode(aMapMode);
     rChild.EnableMapMode(false);
+
+    if (pMouseEvent)
+    {
+        // Set event coordinates, so they contain relative coordinates instead of absolute ones.
+        Point aPos = pMouseEvent->GetPosPixel();
+        aPos.Move(-aOffset.getX(), -aOffset.getY());
+        MouseEvent aMouseEvent(aPos, pMouseEvent->GetClicks(), pMouseEvent->GetMode(), pMouseEvent->GetButtons(), pMouseEvent->GetModifier());
+        *pMouseEvent = aMouseEvent;
+    }
 }
 
 void SwSidebarWin::KeyInput(const KeyEvent& rKeyEvent)
@@ -372,7 +383,7 @@ void SwSidebarWin::KeyInput(const KeyEvent& rKeyEvent)
     if (mpSidebarTextControl)
     {
         mpSidebarTextControl->Push(PushFlags::MAPMODE);
-        lcl_setAbsoluteTwips(EditWin(), *mpSidebarTextControl);
+        lcl_translateTwips(EditWin(), *mpSidebarTextControl, nullptr);
 
         mpSidebarTextControl->KeyInput(rKeyEvent);
 
@@ -385,9 +396,10 @@ void SwSidebarWin::MouseButtonDown(const MouseEvent& rMouseEvent)
     if (mpSidebarTextControl)
     {
         mpSidebarTextControl->Push(PushFlags::MAPMODE);
-        lcl_setAbsoluteTwips(EditWin(), *mpSidebarTextControl);
+        MouseEvent aMouseEvent(rMouseEvent);
+        lcl_translateTwips(EditWin(), *mpSidebarTextControl, &aMouseEvent);
 
-        mpSidebarTextControl->MouseButtonDown(rMouseEvent);
+        mpSidebarTextControl->MouseButtonDown(aMouseEvent);
 
         mpSidebarTextControl->Pop();
     }
commit 022c716fc89c7315a7c454c01e2fe70d5aece289
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Nov 13 14:51:13 2015 +0100

    sw lok: disable comment menu button for now
    
    Change-Id: Ic052544b2835181652732b8de9eaf79572a9db6e

diff --git a/sw/source/uibase/docvw/SidebarWin.cxx b/sw/source/uibase/docvw/SidebarWin.cxx
index 876800d..304e214 100644
--- a/sw/source/uibase/docvw/SidebarWin.cxx
+++ b/sw/source/uibase/docvw/SidebarWin.cxx
@@ -252,6 +252,10 @@ void SwSidebarWin::PaintTile(vcl::RenderContext& rRenderContext, const Rectangle
         if (pChild == mpVScrollbar.get())
             continue;
 
+        // No point in showing this button till click on it are not handled.
+        if (pChild == mpMenuButton.get())
+            continue;
+
         rRenderContext.Push(PushFlags::MAPMODE);
         Point aOffset(PixelToLogic(pChild->GetPosPixel()));
         MapMode aMapMode(rRenderContext.GetMapMode());
commit 22e97c130868fe7d7529cfcfb2a240f775bd8916
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Nov 13 14:42:35 2015 +0100

    editeng lok: respect origin of map mode for TEXT_SELECTION
    
    With this, selections of Writer comment text show up at the correct
    position, not at the top left corner of the window.
    
    Change-Id: If865503d9a02a27730e382d65c42c706dd533a93

diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index eb68e31..df875ed 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -327,6 +327,12 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, Ou
         if (isTiledRendering() && !pOldRegion)
         {
             bool bMm100ToTwip = pOutWin->GetMapMode().GetMapUnit() == MAP_100TH_MM;
+
+            Point aOrigin;
+            if (pOutWin->GetMapMode().GetMapUnit() == MAP_TWIP)
+                // Writer comments: they use editeng, but are separate widgets.
+                aOrigin = pOutWin->GetMapMode().GetOrigin();
+
             OString sRectangle;
             // If we are not in selection mode, then the exported selection should be empty.
             if (pEditEngine->pImpEditEngine->IsInSelectionMode())
@@ -340,12 +346,14 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, Ou
                     Rectangle aStart = Rectangle(rStart.Left(), rStart.Top(), rStart.Left() + 1, rStart.Bottom());
                     if (bMm100ToTwip)
                         aStart = OutputDevice::LogicToLogic(aStart, MAP_100TH_MM, MAP_TWIP);
+                    aStart.Move(aOrigin.getX(), aOrigin.getY());
                     libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION_START, aStart.toString().getStr());
 
                     Rectangle& rEnd = aRectangles.back();
                     Rectangle aEnd = Rectangle(rEnd.Right() - 1, rEnd.Top(), rEnd.Right(), rEnd.Bottom());
                     if (bMm100ToTwip)
                         aEnd = OutputDevice::LogicToLogic(aEnd, MAP_100TH_MM, MAP_TWIP);
+                    aEnd.Move(aOrigin.getX(), aOrigin.getY());
                     libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION_END, aEnd.toString().getStr());
                 }
 
@@ -355,6 +363,7 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, Ou
                     Rectangle& rRectangle = aRectangles[i];
                     if (bMm100ToTwip)
                         rRectangle = OutputDevice::LogicToLogic(rRectangle, MAP_100TH_MM, MAP_TWIP);
+                    rRectangle.Move(aOrigin.getX(), aOrigin.getY());
                     v.push_back(rRectangle.toString().getStr());
                 }
                 sRectangle = comphelper::string::join("; ", v);


More information about the Libreoffice-commits mailing list