[Libreoffice-commits] core.git: include/svx starmath/inc starmath/source starmath/uiconfig svx/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Mon May 3 19:09:37 UTC 2021


 include/svx/weldeditview.hxx             |    2 +
 starmath/inc/edit.hxx                    |    1 
 starmath/source/edit.cxx                 |   48 +------------------------------
 starmath/uiconfig/smath/ui/editwindow.ui |    2 -
 svx/source/dialog/weldeditview.cxx       |   17 ++++++++++
 5 files changed, 22 insertions(+), 48 deletions(-)

New commits:
commit 2de0eaf467715662e68b9429c9d5050f65ffcec9
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Sun May 2 20:15:42 2021 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon May 3 21:08:57 2021 +0200

    There's no longer a purpose to the math horizontal scrollbar
    
    since...
    
    commit f89860807baaa901629ce2a814b7a6c994318fe5
    Date:   Sat Feb 13 16:43:01 2021 +0100
    
        Resolves tdf#140221 auto-adjust Formula Editor width
    
    so remove that.
    
    And merge the starmath Resize logic into the baseclass, and emit
    EditViewScrollStateChange from there.
    
    The goal is that resizing the starmath window does not visually
    horizontally scroll content negatively outside the widget
    
    Change-Id: I1a79a0d5a194e8cfb0d2d2cb07b0b80172f1f66c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115012
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/svx/weldeditview.hxx b/include/svx/weldeditview.hxx
index c40a754a2fc8..65bc9c979bf3 100644
--- a/include/svx/weldeditview.hxx
+++ b/include/svx/weldeditview.hxx
@@ -61,6 +61,7 @@ protected:
 
     void DoPaint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect);
 
+public:
     virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
     virtual bool MouseMove(const MouseEvent& rMEvt) override;
     virtual bool MouseButtonDown(const MouseEvent& rMEvt) override;
@@ -78,6 +79,7 @@ protected:
 
     void SetAcceptsTab(bool bAcceptsTab) { m_bAcceptsTab = bAcceptsTab; }
 
+protected:
     virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override;
 
     virtual void EditViewInvalidate(const tools::Rectangle& rRect) override { Invalidate(rRect); }
diff --git a/starmath/inc/edit.hxx b/starmath/inc/edit.hxx
index 536885794c06..773355cfff14 100644
--- a/starmath/inc/edit.hxx
+++ b/starmath/inc/edit.hxx
@@ -110,7 +110,6 @@ public:
     // Window
     virtual void SetText(const OUString& rText) override;
     virtual OUString GetText() const override;
-    virtual void Resize() override;
     virtual void Command(const CommandEvent& rCEvt) override;
 
     ESelection GetSelection() const;
diff --git a/starmath/source/edit.cxx b/starmath/source/edit.cxx
index ae9b6b7c61da..5287eeca9664 100644
--- a/starmath/source/edit.cxx
+++ b/starmath/source/edit.cxx
@@ -41,9 +41,6 @@
 #include <cfgitem.hxx>
 #include "accessibility.hxx"
 
-#define SCROLL_LINE         24
-
-
 using namespace com::sun::star::accessibility;
 using namespace com::sun::star;
 
@@ -136,7 +133,6 @@ SmEditWindow::SmEditWindow(SmCmdBoxWindow &rMyCmdBoxWin)
     // compare DataChanged
     SetBackground( GetSettings().GetStyleSettings().GetWindowColor() );
 
-    mxScrolledWindow->connect_hadjustment_changed(LINK(this, SmEditWindow, ScrollHdl));
     mxScrolledWindow->connect_vadjustment_changed(LINK(this, SmEditWindow, ScrollHdl));
 
     CreateEditView();
@@ -234,8 +230,7 @@ void SmEditWindow::DataChanged( const DataChangedEvent& rDCEvt )
         pEditEngine->Clear();   //incorrect font size
         pEditEngine->SetText( aTxt );
 
-        AdjustScrollBars();
-        Resize();
+        mxTextControl->Resize();
     }
 }
 
@@ -270,34 +265,6 @@ IMPL_LINK_NOARG(SmEditTextWindow, CursorMoveTimerHdl, Timer *, void)
     aCursorMoveIdle.Stop();
 }
 
-void SmEditWindow::Resize()
-{
-    InterimItemWindow::Resize();
-
-    if (EditView* pEditView = GetEditView())
-    {
-        // Resizes the edit engine to adjust to the size of the output area
-        const Size aSize( pEditView->GetOutputArea().GetSize() );
-        pEditView->GetEditEngine()->SetPaperSize(aSize);
-
-        pEditView->SetOutputArea(AdjustScrollBars());
-        pEditView->ShowCursor();
-
-        OSL_ENSURE( pEditView->GetEditEngine(), "EditEngine missing" );
-        const tools::Long nMaxVisAreaStart = pEditView->GetEditEngine()->GetTextHeight() -
-                                      pEditView->GetOutputArea().GetHeight();
-        if (pEditView->GetVisArea().Top() > nMaxVisAreaStart)
-        {
-            tools::Rectangle aVisArea(pEditView->GetVisArea() );
-            aVisArea.SetTop( std::max<tools::Long>(nMaxVisAreaStart, 0) );
-            aVisArea.SetSize(pEditView->GetOutputArea().GetSize());
-            pEditView->SetVisArea(aVisArea);
-            pEditView->ShowCursor();
-        }
-        SetScrollBarRanges();
-    }
-}
-
 bool SmEditTextWindow::MouseButtonUp(const MouseEvent &rEvt)
 {
     bool bRet = WeldEditView::MouseButtonUp(rEvt);
@@ -488,8 +455,7 @@ void SmEditWindow::CreateEditView()
 
 IMPL_LINK_NOARG(SmEditTextWindow, EditStatusHdl, EditStatus&, void)
 {
-    if (GetEditView())
-        mrEditWindow.Resize();
+    Resize();
 }
 
 IMPL_LINK(SmEditWindow, ScrollHdl, weld::ScrolledWindow&, rScrolledWindow, void)
@@ -497,7 +463,7 @@ IMPL_LINK(SmEditWindow, ScrollHdl, weld::ScrolledWindow&, rScrolledWindow, void)
     if (EditView* pEditView = GetEditView())
     {
         pEditView->SetVisArea(tools::Rectangle(
-                    Point(rScrolledWindow.hadjustment_get_value(),
+                    Point(0,
                           rScrolledWindow.vadjustment_get_value()),
                     pEditView->GetVisArea().GetSize()));
         pEditView->Invalidate();
@@ -531,16 +497,11 @@ void SmEditWindow::SetScrollBarRanges()
         return;
 
     int nVUpper = pEditEngine->GetTextHeight();
-    int nHUpper = pEditEngine->GetPaperSize().Width();
     int nVCurrentDocPos = pEditView->GetVisArea().Top();
-    int nHCurrentDocPos = pEditView->GetVisArea().Left();
     const Size aOut(pEditView->GetOutputArea().GetSize());
     int nVStepIncrement = aOut.Height() * 2 / 10;
-    int nHStepIncrement = SCROLL_LINE;
     int nVPageIncrement = aOut.Height() * 8 / 10;
-    int nHPageIncrement = aOut.Width() * 8 / 10;
     int nVPageSize = aOut.Height();
-    int nHPageSize = aOut.Width();
 
     /* limit the page size to below nUpper because gtk's gtk_scrolled_window_start_deceleration has
        effectively...
@@ -551,12 +512,9 @@ void SmEditWindow::SetScrollBarRanges()
        and requires that upper > lower or the deceleration animation never ends
     */
     nVPageSize = std::min(nVPageSize, nVUpper);
-    nHPageSize = std::min(nHPageSize, nHUpper);
 
     mxScrolledWindow->vadjustment_configure(nVCurrentDocPos, 0, nVUpper,
                                             nVStepIncrement, nVPageIncrement, nVPageSize);
-    mxScrolledWindow->hadjustment_configure(nHCurrentDocPos, 0, nHUpper,
-                                            nHStepIncrement, nHPageIncrement, nHPageSize);
 }
 
 OUString SmEditWindow::GetText() const
diff --git a/starmath/uiconfig/smath/ui/editwindow.ui b/starmath/uiconfig/smath/ui/editwindow.ui
index 0907ff20cb2c..fc1300887fcf 100644
--- a/starmath/uiconfig/smath/ui/editwindow.ui
+++ b/starmath/uiconfig/smath/ui/editwindow.ui
@@ -13,7 +13,7 @@
         <property name="visible">True</property>
         <property name="can-focus">True</property>
         <property name="border-width">0</property>
-        <property name="hscrollbar-policy">always</property>
+        <property name="hscrollbar-policy">never</property>
         <property name="vscrollbar-policy">always</property>
         <property name="shadow-type">etched-out</property>
         <child>
diff --git a/svx/source/dialog/weldeditview.cxx b/svx/source/dialog/weldeditview.cxx
index 2ffa6b3b6670..4f035f67df6f 100644
--- a/svx/source/dialog/weldeditview.cxx
+++ b/svx/source/dialog/weldeditview.cxx
@@ -135,8 +135,23 @@ void WeldEditView::Resize()
     {
         OutputDevice& rDevice = GetDrawingArea()->get_ref_device();
         Size aOutputSize(rDevice.PixelToLogic(GetOutputSizePixel()));
-        GetEditEngine()->SetPaperSize(aOutputSize);
+        // Resizes the edit engine to adjust to the size of the output area
         pEditView->SetOutputArea(tools::Rectangle(Point(0, 0), aOutputSize));
+        GetEditEngine()->SetPaperSize(aOutputSize);
+        pEditView->ShowCursor();
+
+        const tools::Long nMaxVisAreaStart
+            = pEditView->GetEditEngine()->GetTextHeight() - aOutputSize.Height();
+        tools::Rectangle aVisArea(pEditView->GetVisArea());
+        if (aVisArea.Top() > nMaxVisAreaStart)
+        {
+            aVisArea.SetTop(std::max<tools::Long>(nMaxVisAreaStart, 0));
+            aVisArea.SetSize(aOutputSize);
+            pEditView->SetVisArea(aVisArea);
+            pEditView->ShowCursor();
+        }
+
+        EditViewScrollStateChange();
     }
     weld::CustomWidgetController::Resize();
 }


More information about the Libreoffice-commits mailing list