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

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Wed Dec 2 15:45:51 UTC 2020


 sc/source/ui/app/inputhdl.cxx |   37 ++++++++++++++++++-----------
 sc/source/ui/app/inputwin.cxx |   53 +++++++++++++++++++++++++++++++++++++++---
 sc/source/ui/inc/inputwin.hxx |   11 +++++++-
 3 files changed, 82 insertions(+), 19 deletions(-)

New commits:
commit c90c6c1316d6788601319c1bca8ac1ff1f869c83
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Dec 2 11:42:51 2020 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Dec 2 16:44:58 2020 +0100

    tdf#138540 formula popover in the wrong place
    
    since...
    
    commit e087e25f05e689091cbf1c4f91b6e93878ac17ec
    Date:   Mon Oct 5 14:19:05 2020 +0100
    
        weld InputBar
    
    Change-Id: Ib19aa088e9f593046e611d8ec4afe33b65c1b7fd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107069
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index b5f43ace6d15..5d802fd9d5f7 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -1244,15 +1244,19 @@ void ScInputHandler::ShowTip( const OUString& rText )
 
     Point aPos;
     if (pInputWin && pInputWin->GetEditView() == pActiveView)
-        pTipVisibleParent = pInputWin;
+    {
+        pTipVisibleParent = pInputWin->GetEditWindow();
+        aPos = pInputWin->GetCursorScreenPixelPos();
+    }
     else
+    {
         pTipVisibleParent = pActiveView->GetWindow();
-    vcl::Cursor* pCur = pActiveView->GetCursor();
-    if (pCur)
-        aPos = pTipVisibleParent->LogicToPixel( pCur->GetPos() );
-    aPos = pTipVisibleParent->OutputToScreenPixel( aPos );
-    tools::Rectangle aRect( aPos, aPos );
+        if (vcl::Cursor* pCur = pActiveView->GetCursor())
+            aPos = pTipVisibleParent->LogicToPixel( pCur->GetPos() );
+        aPos = pTipVisibleParent->OutputToScreenPixel( aPos );
+    }
 
+    tools::Rectangle aRect( aPos, aPos );
     QuickHelpFlags const nAlign = QuickHelpFlags::Left|QuickHelpFlags::Bottom;
     nTipVisible = Help::ShowPopover(pTipVisibleParent, aRect, rText, nAlign);
     pTipVisibleParent->AddEventListener( LINK( this, ScInputHandler, ShowHideTipVisibleParentListener ) );
@@ -1268,17 +1272,22 @@ void ScInputHandler::ShowTipBelow( const OUString& rText )
 
     Point aPos;
     if (pInputWin && pInputWin->GetEditView() == pActiveView)
-        pTipVisibleSecParent = pInputWin;
+    {
+        pTipVisibleSecParent = pInputWin->GetEditWindow();
+        aPos = pInputWin->GetCursorScreenPixelPos(true);
+    }
     else
-        pTipVisibleSecParent = pActiveView->GetWindow();
-    vcl::Cursor* pCur = pActiveView->GetCursor();
-    if ( pCur )
     {
-        Point aLogicPos = pCur->GetPos();
-        aLogicPos.AdjustY(pCur->GetHeight() );
-        aPos = pTipVisibleSecParent->LogicToPixel( aLogicPos );
+        pTipVisibleSecParent = pActiveView->GetWindow();
+        if (vcl::Cursor* pCur = pActiveView->GetCursor())
+        {
+            Point aLogicPos = pCur->GetPos();
+            aLogicPos.AdjustY(pCur->GetHeight() );
+            aPos = pTipVisibleSecParent->LogicToPixel( aLogicPos );
+        }
+        aPos = pTipVisibleSecParent->OutputToScreenPixel( aPos );
     }
-    aPos = pTipVisibleSecParent->OutputToScreenPixel( aPos );
+
     tools::Rectangle aRect( aPos, aPos );
     QuickHelpFlags const nAlign = QuickHelpFlags::Left | QuickHelpFlags::Top | QuickHelpFlags::NoEvadePointer;
     nTipVisibleSec = Help::ShowPopover(pTipVisibleSecParent, aRect, rText, nAlign);
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 90ef42a0be39..17a7c8160285 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -642,6 +642,16 @@ EditView* ScInputWindow::GetEditView()
     return mxTextWindow->GetEditView();
 }
 
+vcl::Window* ScInputWindow::GetEditWindow()
+{
+    return mxTextWindow;
+}
+
+Point ScInputWindow::GetCursorScreenPixelPos(bool bBelow)
+{
+    return mxTextWindow->GetCursorScreenPixelPos(bBelow);
+}
+
 void ScInputWindow::MakeDialogEditView()
 {
     mxTextWindow->MakeDialogEditView();
@@ -881,6 +891,11 @@ ScInputBarGroup::ScInputBarGroup(vcl::Window* pParent, ScTabViewShell* pViewSh)
         mxButtonDown->show();
 }
 
+Point ScInputBarGroup::GetCursorScreenPixelPos(bool bBelow)
+{
+    return mxTextWndGroup->GetCursorScreenPixelPos(bBelow);
+}
+
 ScInputBarGroup::~ScInputBarGroup()
 {
     disposeOnce();
@@ -1092,7 +1107,7 @@ void ScInputBarGroup::TextGrabFocus()
     mxTextWndGroup->TextGrabFocus();
 }
 
-constexpr tools::Long gnBorderWidth = INPUTLINE_INSET_MARGIN + 1;
+constexpr tools::Long gnBorderWidth = (INPUTLINE_INSET_MARGIN + 1) * 2;
 constexpr tools::Long gnBorderHeight = INPUTLINE_INSET_MARGIN + 1;
 
 ScTextWndGroup::ScTextWndGroup(ScInputBarGroup& rParent, ScTabViewShell* pViewSh)
@@ -1104,6 +1119,28 @@ ScTextWndGroup::ScTextWndGroup(ScInputBarGroup& rParent, ScTabViewShell* pViewSh
     mxScrollWin->connect_vadjustment_changed(LINK(this, ScTextWndGroup, Impl_ScrollHdl));
 }
 
+Point ScTextWndGroup::GetCursorScreenPixelPos(bool bBelow)
+{
+    Point aPos;
+    if (!HasEditView())
+        return aPos;
+    EditView* pEditView = GetEditView();
+    vcl::Cursor* pCur = pEditView->GetCursor();
+    if (!pCur)
+        return aPos;
+    Point aLogicPos = pCur->GetPos();
+    if (bBelow)
+        aLogicPos.AdjustY(pCur->GetHeight());
+    aPos = GetEditViewDevice().LogicToPixel(aLogicPos);
+    bool bRTL = mrParent.IsRTLEnabled();
+    if (bRTL)
+        aPos.setX(mxTextWnd->GetOutputSizePixel().Width() - aPos.X() + gnBorderWidth);
+    else
+        aPos.AdjustX(gnBorderWidth + 1);
+
+    return mrParent.OutputToScreenPixel(aPos);
+}
+
 ScTextWndGroup::~ScTextWndGroup()
 {
 }
@@ -1118,6 +1155,11 @@ EditView* ScTextWndGroup::GetEditView()
     return mxTextWnd->GetEditView();
 }
 
+const OutputDevice& ScTextWndGroup::GetEditViewDevice() const
+{
+    return mxTextWnd->GetEditViewDevice();
+}
+
 tools::Long ScTextWndGroup::GetLastNumExpandedLines() const
 {
     return mxTextWnd->GetLastNumExpandedLines();
@@ -1238,6 +1280,11 @@ EditView* ScTextWnd::GetEditView()
 
 bool ScTextWnd::HasEditView() const { return m_xEditView != nullptr; }
 
+const OutputDevice& ScTextWnd::GetEditViewDevice() const
+{
+    return EditViewOutputDevice();
+}
+
 int ScTextWnd::GetPixelHeightForLines(tools::Long nLines)
 {
     // add padding (for the borders of the window)
@@ -1984,8 +2031,8 @@ void ScTextWnd::SetDrawingArea(weld::DrawingArea* pDrawingArea)
     SetDragDataTransferrable(xHelper, DND_ACTION_COPY);
 
     OutputDevice& rDevice = pDrawingArea->get_ref_device();
-    pDrawingArea->set_margin_left(gnBorderWidth * 2);
-    pDrawingArea->set_margin_right(gnBorderWidth * 2);
+    pDrawingArea->set_margin_left(gnBorderWidth);
+    pDrawingArea->set_margin_right(gnBorderWidth);
     // leave 1 for the width of the scrolledwindow border
     pDrawingArea->set_margin_top(gnBorderHeight - 1);
     pDrawingArea->set_margin_bottom(gnBorderHeight - 1);
diff --git a/sc/source/ui/inc/inputwin.hxx b/sc/source/ui/inc/inputwin.hxx
index c0f37f644538..318c3986f521 100644
--- a/sc/source/ui/inc/inputwin.hxx
+++ b/sc/source/ui/inc/inputwin.hxx
@@ -79,6 +79,8 @@ public:
     virtual EditView*       GetEditView() override;
     virtual bool            HasEditView() const override;
 
+    const OutputDevice&     GetEditViewDevice() const;
+
                         // for function autopilots
     virtual void            MakeDialogEditView() override;
 
@@ -204,8 +206,10 @@ public:
 
     virtual void            InsertAccessibleTextData(ScAccessibleEditLineTextData& rTextData) override;
     virtual EditView*       GetEditView() override;
-    tools::Long                    GetLastNumExpandedLines() const;
-    virtual tools::Long            GetNumLines() const override;
+    const OutputDevice&     GetEditViewDevice() const;
+    Point                   GetCursorScreenPixelPos(bool bBelowLine);
+    tools::Long             GetLastNumExpandedLines() const;
+    virtual tools::Long     GetNumLines() const override;
     int                     GetPixelHeightForLines(tools::Long nLines);
     weld::ScrolledWindow&   GetScrollWin();
     virtual const OUString& GetTextString() const override;
@@ -245,6 +249,7 @@ public:
     void                    StartEditEngine() override;
     virtual EditView*       GetEditView() override;
     virtual bool            HasEditView() const override;
+    Point                   GetCursorScreenPixelPos(bool bBelowLine);
     virtual void            Resize() override;
     virtual const OUString& GetTextString() const override;
     virtual void            StopEditEngine(bool bAll) override;
@@ -301,6 +306,8 @@ public:
 
     bool            IsInputActive();
     EditView*       GetEditView();
+    vcl::Window*    GetEditWindow();
+    Point           GetCursorScreenPixelPos(bool bBelowLine = false);
 
     void            TextGrabFocus();
     void            TextInvalidate();


More information about the Libreoffice-commits mailing list