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

Miklos Vajna vmiklos at collabora.co.uk
Fri Nov 13 04:34:34 PST 2015


 editeng/source/editeng/impedit.cxx           |    7 +++++
 sw/inc/SidebarWin.hxx                        |    5 ++-
 sw/source/uibase/docvw/PostItMgr.cxx         |    4 +--
 sw/source/uibase/docvw/SidebarTxtControl.hxx |    2 -
 sw/source/uibase/docvw/SidebarWin.cxx        |   36 ++++++++++++++++++++++++---
 sw/source/uibase/docvw/edtwin.cxx            |    7 -----
 6 files changed, 45 insertions(+), 16 deletions(-)

New commits:
commit 5fb91dfd804cd6f3d585bb4113b9a68083ac71ee
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Nov 13 13:33:32 2015 +0100

    sw lok: fix blinking cursor position of comments
    
    With this, it is possible to click inside a comment (and get a blinking
    cursor inside a comment), and also possible to use the arrow keys to
    native around and still get correct blinking cursor position.
    
    Change-Id: I29eb1e60e4e571151f0b18bec8cf765ea09af09f

diff --git a/sw/inc/SidebarWin.hxx b/sw/inc/SidebarWin.hxx
index 9ddf149..cb49140 100644
--- a/sw/inc/SidebarWin.hxx
+++ b/sw/inc/SidebarWin.hxx
@@ -178,9 +178,10 @@ class SwSidebarWin : public vcl::Window
 
         virtual void    Draw(OutputDevice* pDev, const Point&, const Size&, DrawFlags) override;
         virtual void KeyInput(const KeyEvent& rKeyEvt) override;
+        virtual void MouseButtonDown(const MouseEvent& rMouseEvent) override;
         void PaintTile(vcl::RenderContext& rRenderContext, const Rectangle& rRect);
-        /// Get the matching sub-widget inside this sidebar widget for rPointLogic, if any.
-        vcl::Window* IsHitWindow(const Point& rPointLogic);
+        /// Is there a matching sub-widget inside this sidebar widget for rPointLogic?
+        bool IsHitWindow(const Point& rPointLogic);
 
     protected:
         virtual void    DataChanged( const DataChangedEvent& aEvent) override;
diff --git a/sw/source/uibase/docvw/PostItMgr.cxx b/sw/source/uibase/docvw/PostItMgr.cxx
index cba1999..662dd4a 100644
--- a/sw/source/uibase/docvw/PostItMgr.cxx
+++ b/sw/source/uibase/docvw/PostItMgr.cxx
@@ -1736,9 +1736,9 @@ vcl::Window* SwPostItMgr::IsHitSidebarWindow(const Point& rPointLogic)
             if (!pPostIt)
                 continue;
 
-            if (vcl::Window* pWindow = pPostIt->IsHitWindow(rPointLogic))
+            if (pPostIt->IsHitWindow(rPointLogic))
             {
-                pRet = pWindow;
+                pRet = pPostIt;
                 break;
             }
         }
diff --git a/sw/source/uibase/docvw/SidebarTxtControl.hxx b/sw/source/uibase/docvw/SidebarTxtControl.hxx
index 1258412..6741019 100644
--- a/sw/source/uibase/docvw/SidebarTxtControl.hxx
+++ b/sw/source/uibase/docvw/SidebarTxtControl.hxx
@@ -41,7 +41,6 @@ class SidebarTextControl : public Control
     protected:
         virtual void    Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect) override;
         virtual void    MouseMove( const MouseEvent& rMEvt ) override;
-        virtual void    MouseButtonDown( const MouseEvent& rMEvt ) override;
         virtual void    MouseButtonUp( const MouseEvent& rMEvt ) override;
         virtual void    Command( const CommandEvent& rCEvt ) override;
         virtual void    LoseFocus() override;
@@ -61,6 +60,7 @@ class SidebarTextControl : public Control
 
         virtual void GetFocus() override;
         virtual void KeyInput( const KeyEvent& rKeyEvt ) override;
+        virtual void MouseButtonDown(const MouseEvent& rMouseEvent) override;
 
         OutlinerView* GetTextView() const;
 
diff --git a/sw/source/uibase/docvw/SidebarWin.cxx b/sw/source/uibase/docvw/SidebarWin.cxx
index c2ffc06..876800d 100644
--- a/sw/source/uibase/docvw/SidebarWin.cxx
+++ b/sw/source/uibase/docvw/SidebarWin.cxx
@@ -279,12 +279,10 @@ void SwSidebarWin::PaintTile(vcl::RenderContext& rRenderContext, const Rectangle
     rRenderContext.Push(PushFlags::NONE);
 }
 
-vcl::Window* SwSidebarWin::IsHitWindow(const Point& rPointLogic)
+bool SwSidebarWin::IsHitWindow(const Point& rPointLogic)
 {
     Rectangle aRectangleLogic(EditWin().PixelToLogic(GetPosPixel()), EditWin().PixelToLogic(GetSizePixel()));
-    if (aRectangleLogic.IsInside(rPointLogic))
-        return mpSidebarTextControl;
-    return nullptr;
+    return aRectangleLogic.IsInside(rPointLogic);
 }
 
 void SwSidebarWin::Draw(OutputDevice* pDev, const Point& rPt, const Size& rSz, DrawFlags nInFlags)
@@ -355,10 +353,40 @@ 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)
+{
+    Point aOffset(rChild.GetOutOffXPixel() - rParent.GetOutOffXPixel(), rChild.GetOutOffYPixel() - rParent.GetOutOffYPixel());
+    MapMode aMapMode(rChild.GetMapMode());
+    aMapMode.SetOrigin(rChild.PixelToLogic(aOffset));
+    rChild.SetMapMode(aMapMode);
+    rChild.EnableMapMode(false);
+}
+
 void SwSidebarWin::KeyInput(const KeyEvent& rKeyEvent)
 {
     if (mpSidebarTextControl)
+    {
+        mpSidebarTextControl->Push(PushFlags::MAPMODE);
+        lcl_setAbsoluteTwips(EditWin(), *mpSidebarTextControl);
+
         mpSidebarTextControl->KeyInput(rKeyEvent);
+
+        mpSidebarTextControl->Pop();
+    }
+}
+
+void SwSidebarWin::MouseButtonDown(const MouseEvent& rMouseEvent)
+{
+    if (mpSidebarTextControl)
+    {
+        mpSidebarTextControl->Push(PushFlags::MAPMODE);
+        lcl_setAbsoluteTwips(EditWin(), *mpSidebarTextControl);
+
+        mpSidebarTextControl->MouseButtonDown(rMouseEvent);
+
+        mpSidebarTextControl->Pop();
+    }
 }
 
 void SwSidebarWin::SetPosSizePixelRect(long nX, long nY, long nWidth, long nHeight,
diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
index 3e90227..676a556 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -2778,14 +2778,7 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
     {
         if (vcl::Window* pWindow = m_rView.GetPostItMgr()->IsHitSidebarWindow(rMEvt.GetPosPixel()))
         {
-            bool bDisableMapMode = pWindow->IsMapModeEnabled();
-            if (bDisableMapMode)
-                pWindow->EnableMapMode(false);
-
             pWindow->MouseButtonDown(rMEvt);
-
-            if (bDisableMapMode)
-                pWindow->EnableMapMode();
             return;
         }
     }
commit e988ab84f1c32519bfca758086c749ba98a5a85f
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Nov 13 11:33:43 2015 +0100

    editeng lok: respect origin of map mode for INVALIDATE_VISIBLE_CURSOR
    
    Writer comments are separate widgets, but we want to have coordinates in
    absolutes twips, so give Writer a chance to inform us about the delta.
    
    For now only do this in case the map unit is twips, as Impress sets the
    origin already.
    
    Change-Id: Idf340944165e44b0888c00965d6be7798712ff76

diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index 11e78d5..eb68e31 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -945,6 +945,13 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor, sal_uInt16
             // LOK output is always in twips, convert from mm100 if necessary.
             if (pOutWin->GetMapMode().GetMapUnit() == MAP_100TH_MM)
                 aRect = OutputDevice::LogicToLogic(aRect, MAP_100TH_MM, MAP_TWIP);
+            else if (pOutWin->GetMapMode().GetMapUnit() == MAP_TWIP)
+            {
+                // Writer comments: they use editeng, but are separate widgets.
+                Point aOrigin = pOutWin->GetMapMode().GetOrigin();
+                // Move the rectangle, so that we output absolute twips.
+                aRect.Move(aOrigin.getX(), aOrigin.getY());
+            }
             // Let the LOK client decide the cursor width.
             aRect.setWidth(0);
 


More information about the Libreoffice-commits mailing list