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

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Wed Dec 9 09:16:31 UTC 2020


 dbaccess/source/ui/control/sqledit.cxx |    8 +-
 include/svx/weldeditview.hxx           |   39 +++---------
 sc/source/ui/app/inputwin.cxx          |    8 +-
 sc/source/ui/inc/inputwin.hxx          |    8 +-
 sc/source/ui/inc/tphfedit.hxx          |    4 -
 svx/source/dialog/weldeditview.cxx     |  104 ++++++++++++++++++++++++---------
 6 files changed, 104 insertions(+), 67 deletions(-)

New commits:
commit ac398a5d419dc77ad50d2ddbc10cb53edf5fb492
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue Dec 8 16:18:43 2020 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Dec 9 10:15:58 2020 +0100

    restructure WeldEditView for reuse in SwAnnotationWin
    
    Change-Id: I9474553e595780fa61bac955d2d5ebf691408ede
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107437
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/dbaccess/source/ui/control/sqledit.cxx b/dbaccess/source/ui/control/sqledit.cxx
index dd0560daca8c..5caefbc517ba 100644
--- a/dbaccess/source/ui/control/sqledit.cxx
+++ b/dbaccess/source/ui/control/sqledit.cxx
@@ -75,7 +75,7 @@ SQLEditView::SQLEditView()
 
 void SQLEditView::DisableInternalUndo()
 {
-    GetEditEngine().EnableUndo(false);
+    GetEditEngine()->EnableUndo(false);
     m_bDisableInternalUndo = true;
 }
 
@@ -122,7 +122,7 @@ void SQLEditView::SetDrawingArea(weld::DrawingArea* pDrawingArea)
 {
     WeldEditView::SetDrawingArea(pDrawingArea);
 
-    EditEngine& rEditEngine = GetEditEngine();
+    EditEngine& rEditEngine = *GetEditEngine();
 
     rEditEngine.SetDefaultHorizontalTextDirection(EEHorizontalTextDirection::L2R);
     rEditEngine.SetModifyHdl(LINK(this, SQLEditView, ModifyHdl));
@@ -191,7 +191,7 @@ Color SQLEditView::GetColorValue(TokenType aToken)
 void SQLEditView::UpdateData()
 {
     m_bInUpdate = true;
-    EditEngine& rEditEngine = GetEditEngine();
+    EditEngine& rEditEngine = *GetEditEngine();
 
     bool bUndoEnabled = rEditEngine.IsUndoEnabled();
     rEditEngine.EnableUndo(false);
@@ -368,7 +368,7 @@ void SQLEditView::ImplSetFont()
     // see SmEditWindow::DataChanged for a similar case
     SetItemPoolFont(m_pItemPool); // change default font
     // re-create with the new font
-    EditEngine& rEditEngine = GetEditEngine();
+    EditEngine& rEditEngine = *GetEditEngine();
     OUString aTxt(rEditEngine.GetText());
     rEditEngine.Clear();
     SetTextAndUpdate(aTxt);
diff --git a/include/svx/weldeditview.hxx b/include/svx/weldeditview.hxx
index 11f35c2e7164..1fca83df4c70 100644
--- a/include/svx/weldeditview.hxx
+++ b/include/svx/weldeditview.hxx
@@ -8,8 +8,7 @@
  *
  */
 
-#ifndef INCLUDED_SVX_WELDEDITVIEW_HXX
-#define INCLUDED_SVX_WELDEDITVIEW_HXX
+#pragma once
 
 #include <sal/config.h>
 #include <svx/svxdllapi.h>
@@ -28,36 +27,22 @@ public:
     virtual int GetSurroundingText(OUString& rSurrounding) override;
     virtual bool DeleteSurroundingText(const Selection& rRange) override;
 
-    void SetText(const OUString& rStr) { m_xEditEngine->SetText(rStr); }
+    void SetText(const OUString& rStr);
 
-    OUString GetText() const { return m_xEditEngine->GetText(); }
+    OUString GetText() const;
 
     virtual FactoryFunction GetUITestFactory() const override;
 
-    void SetModifyHdl(const Link<LinkParamNone*, void>& rLink)
-    {
-        m_xEditEngine->SetModifyHdl(rLink);
-    }
+    void SetModifyHdl(const Link<LinkParamNone*, void>& rLink);
 
-    EditEngine& GetEditEngine() { return *m_xEditEngine; }
+    virtual EditView* GetEditView() const;
+    virtual EditEngine* GetEditEngine() const;
 
-    bool HasSelection() const { return m_xEditView && m_xEditView->HasSelection(); }
+    bool HasSelection() const;
 
-    void Cut()
-    {
-        if (m_xEditView)
-            m_xEditView->Cut();
-    }
-    void Copy()
-    {
-        if (m_xEditView)
-            m_xEditView->Copy();
-    }
-    void Paste()
-    {
-        if (m_xEditView)
-            m_xEditView->Paste();
-    }
+    void Cut();
+    void Copy();
+    void Paste();
 
     virtual ~WeldEditView() override;
 
@@ -68,6 +53,8 @@ protected:
 
     virtual void makeEditEngine();
 
+    void InitAccessible();
+
     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;
@@ -102,6 +89,4 @@ protected:
     }
 };
 
-#endif // INCLUDED_SVX_WELDEDITVIEW_HXX
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 17a7c8160285..6776662ac5a5 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -951,7 +951,7 @@ void ScInputBarGroup::MakeDialogEditView()
     mxTextWndGroup->MakeDialogEditView();
 }
 
-EditView* ScInputBarGroup::GetEditView()
+EditView* ScInputBarGroup::GetEditView() const
 {
     return mxTextWndGroup->GetEditView();
 }
@@ -1150,7 +1150,7 @@ void ScTextWndGroup::InsertAccessibleTextData(ScAccessibleEditLineTextData& rTex
     mxTextWnd->InsertAccessibleTextData(rTextData);
 }
 
-EditView* ScTextWndGroup::GetEditView()
+EditView* ScTextWndGroup::GetEditView() const
 {
     return mxTextWnd->GetEditView();
 }
@@ -1271,10 +1271,10 @@ void ScTextWnd::Paint( vcl::RenderContext& rRenderContext, const tools::Rectangl
     WeldEditView::Paint(rRenderContext, rRect);
 }
 
-EditView* ScTextWnd::GetEditView()
+EditView* ScTextWnd::GetEditView() const
 {
     if ( !m_xEditView )
-        InitEditEngine();
+        const_cast<ScTextWnd&>(*this).InitEditEngine();
     return m_xEditView.get();
 }
 
diff --git a/sc/source/ui/inc/inputwin.hxx b/sc/source/ui/inc/inputwin.hxx
index 318c3986f521..32717bf17cba 100644
--- a/sc/source/ui/inc/inputwin.hxx
+++ b/sc/source/ui/inc/inputwin.hxx
@@ -54,7 +54,7 @@ public:
     virtual const OUString& GetTextString() const = 0;
     virtual void            StartEditEngine() = 0;
     virtual void            StopEditEngine( bool bAll ) = 0;
-    virtual EditView*       GetEditView() = 0;
+    virtual EditView*       GetEditView() const = 0;
     virtual bool            HasEditView() const = 0;
     virtual void            MakeDialogEditView() = 0;
     virtual void            SetFormulaMode( bool bSet ) = 0;
@@ -76,7 +76,7 @@ public:
     virtual const OUString& GetTextString() const override;
 
     bool                    IsInputActive() override;
-    virtual EditView*       GetEditView() override;
+    virtual EditView*       GetEditView() const override;
     virtual bool            HasEditView() const override;
 
     const OutputDevice&     GetEditViewDevice() const;
@@ -205,7 +205,7 @@ public:
     virtual ~ScTextWndGroup() override;
 
     virtual void            InsertAccessibleTextData(ScAccessibleEditLineTextData& rTextData) override;
-    virtual EditView*       GetEditView() override;
+    virtual EditView*       GetEditView() const override;
     const OutputDevice&     GetEditViewDevice() const;
     Point                   GetCursorScreenPixelPos(bool bBelowLine);
     tools::Long             GetLastNumExpandedLines() const;
@@ -247,7 +247,7 @@ public:
     virtual void            RemoveAccessibleTextData(ScAccessibleEditLineTextData& rTextData) override;
     void                    SetTextString(const OUString& rString) override;
     void                    StartEditEngine() override;
-    virtual EditView*       GetEditView() override;
+    virtual EditView*       GetEditView() const override;
     virtual bool            HasEditView() const override;
     Point                   GetCursorScreenPixelPos(bool bBelowLine);
     virtual void            Resize() override;
diff --git a/sc/source/ui/inc/tphfedit.hxx b/sc/source/ui/inc/tphfedit.hxx
index 7d5a9ca521a3..7d67a7500297 100644
--- a/sc/source/ui/inc/tphfedit.hxx
+++ b/sc/source/ui/inc/tphfedit.hxx
@@ -21,6 +21,7 @@
 #define INCLUDED_SC_SOURCE_UI_INC_TPHFEDIT_HXX
 
 #include <scdllapi.h>
+#include <editutil.hxx>
 #include <cppuhelper/weakref.hxx>
 #include <svx/weldeditview.hxx>
 #include <editeng/svxenum.hxx>
@@ -29,7 +30,6 @@
 
 namespace com::sun::star::accessibility { class XAccessible; }
 
-class ScHeaderEditEngine;
 class ScPatternAttr;
 class EditView;
 class EditTextObject;
@@ -62,7 +62,7 @@ public:
 
     virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override;
 
-    ScHeaderEditEngine* GetEditEngine() const;
+    ScHeaderEditEngine* GetEditEngine() const override;
     void SetObjectSelectHdl( const Link<ScEditWindow&,void>& aLink) { aObjectSelectLink = aLink; }
     void SetGetFocusHdl(const std::function<void (ScEditWindow&)>& rLink) { m_GetFocusLink = rLink; }
 
diff --git a/svx/source/dialog/weldeditview.cxx b/svx/source/dialog/weldeditview.cxx
index f62a3df178dc..61c258a3730a 100644
--- a/svx/source/dialog/weldeditview.cxx
+++ b/svx/source/dialog/weldeditview.cxx
@@ -45,6 +45,43 @@
 #include <vcl/svapp.hxx>
 #include <vcl/uitest/uiobject.hxx>
 
+void WeldEditView::SetText(const OUString& rStr) { GetEditEngine()->SetText(rStr); }
+
+OUString WeldEditView::GetText() const { return GetEditEngine()->GetText(); }
+
+void WeldEditView::SetModifyHdl(const Link<LinkParamNone*, void>& rLink)
+{
+    GetEditEngine()->SetModifyHdl(rLink);
+}
+
+EditView* WeldEditView::GetEditView() const { return m_xEditView.get(); }
+
+EditEngine* WeldEditView::GetEditEngine() const { return m_xEditEngine.get(); }
+
+bool WeldEditView::HasSelection() const
+{
+    EditView* pEditView = GetEditView();
+    return pEditView && pEditView->HasSelection();
+}
+
+void WeldEditView::Cut()
+{
+    if (EditView* pEditView = GetEditView())
+        pEditView->Cut();
+}
+
+void WeldEditView::Copy()
+{
+    if (EditView* pEditView = GetEditView())
+        pEditView->Copy();
+}
+
+void WeldEditView::Paste()
+{
+    if (EditView* pEditView = GetEditView())
+        pEditView->Paste();
+}
+
 WeldEditView::WeldEditView() {}
 
 // tdf#127033 want to use UI font so override makeEditEngine to enable that
@@ -76,13 +113,13 @@ void WeldEditView::makeEditEngine()
 
 void WeldEditView::Resize()
 {
-    if (m_xEditView)
+    if (EditView* pEditView = GetEditView())
     {
         OutputDevice& rDevice = GetDrawingArea()->get_ref_device();
         Size aOutputSize(rDevice.PixelToLogic(GetOutputSizePixel()));
         Size aSize(aOutputSize);
-        m_xEditEngine->SetPaperSize(aSize);
-        m_xEditView->SetOutputArea(tools::Rectangle(Point(0, 0), aOutputSize));
+        GetEditEngine()->SetPaperSize(aSize);
+        pEditView->SetOutputArea(tools::Rectangle(Point(0, 0), aOutputSize));
     }
     weld::CustomWidgetController::Resize();
 }
@@ -99,21 +136,21 @@ void WeldEditView::Paint(vcl::RenderContext& rRenderContext, const tools::Rectan
 
     std::vector<tools::Rectangle> aLogicRects;
 
-    if (m_xEditView)
+    if (EditView* pEditView = GetEditView())
     {
-        m_xEditView->SetBackgroundColor(aBgColor);
+        pEditView->SetBackgroundColor(aBgColor);
 
-        m_xEditView->Paint(rRect, &rRenderContext);
+        pEditView->Paint(rRect, &rRenderContext);
 
         if (HasFocus())
         {
-            m_xEditView->ShowCursor(false);
-            vcl::Cursor* pCursor = m_xEditView->GetCursor();
+            pEditView->ShowCursor(false);
+            vcl::Cursor* pCursor = pEditView->GetCursor();
             pCursor->DrawToDevice(rRenderContext);
         }
 
         // get logic selection
-        m_xEditView->GetSelectionRectangles(aLogicRects);
+        pEditView->GetSelectionRectangles(aLogicRects);
     }
 
     rRenderContext.SetLineColor();
@@ -128,7 +165,8 @@ void WeldEditView::Paint(vcl::RenderContext& rRenderContext, const tools::Rectan
 
 bool WeldEditView::MouseMove(const MouseEvent& rMEvt)
 {
-    return m_xEditView && m_xEditView->MouseMove(rMEvt);
+    EditView* pEditView = GetEditView();
+    return pEditView && pEditView->MouseMove(rMEvt);
 }
 
 bool WeldEditView::MouseButtonDown(const MouseEvent& rMEvt)
@@ -139,35 +177,40 @@ bool WeldEditView::MouseButtonDown(const MouseEvent& rMEvt)
     if (!HasFocus())
         GrabFocus();
 
-    return m_xEditView && m_xEditView->MouseButtonDown(rMEvt);
+    EditView* pEditView = GetEditView();
+    return pEditView && pEditView->MouseButtonDown(rMEvt);
 }
 
 bool WeldEditView::MouseButtonUp(const MouseEvent& rMEvt)
 {
     if (IsMouseCaptured())
         ReleaseMouse();
-    return m_xEditView && m_xEditView->MouseButtonUp(rMEvt);
+    EditView* pEditView = GetEditView();
+    return pEditView && pEditView->MouseButtonUp(rMEvt);
 }
 
 bool WeldEditView::KeyInput(const KeyEvent& rKEvt)
 {
+    EditView* pEditView = GetEditView();
+
     sal_uInt16 nKey = rKEvt.GetKeyCode().GetCode();
 
     if (nKey == KEY_TAB)
     {
         return false;
     }
-    else if (m_xEditView && !m_xEditView->PostKeyEvent(rKEvt))
+    else if (pEditView && !pEditView->PostKeyEvent(rKEvt))
     {
         if (rKEvt.GetKeyCode().IsMod1() && !rKEvt.GetKeyCode().IsMod2())
         {
             if (nKey == KEY_A)
             {
-                sal_Int32 nPar = m_xEditEngine->GetParagraphCount();
+                EditEngine* pEditEngine = GetEditEngine();
+                sal_Int32 nPar = pEditEngine->GetParagraphCount();
                 if (nPar)
                 {
-                    sal_Int32 nLen = m_xEditEngine->GetTextLen(nPar - 1);
-                    m_xEditView->SetSelection(ESelection(0, 0, nPar - 1, nLen));
+                    sal_Int32 nLen = pEditEngine->GetTextLen(nPar - 1);
+                    pEditView->SetSelection(ESelection(0, 0, nPar - 1, nLen));
                 }
                 return true;
             }
@@ -181,9 +224,10 @@ bool WeldEditView::KeyInput(const KeyEvent& rKEvt)
 
 bool WeldEditView::Command(const CommandEvent& rCEvt)
 {
-    if (!m_xEditView)
+    EditView* pEditView = GetEditView();
+    if (!pEditView)
         return false;
-    m_xEditView->Command(rCEvt);
+    pEditView->Command(rCEvt);
     return true;
 }
 
@@ -1434,29 +1478,37 @@ void WeldEditView::SetDrawingArea(weld::DrawingArea* pDrawingArea)
 
     pDrawingArea->set_cursor(PointerStyle::Text);
 
+    InitAccessible();
+}
+
+void WeldEditView::InitAccessible()
+{
     if (m_xAccessible.is())
-        m_xAccessible->Init(m_xEditEngine.get(), m_xEditView.get());
+        m_xAccessible->Init(GetEditEngine(), GetEditView());
 }
 
 int WeldEditView::GetSurroundingText(OUString& rSurrounding)
 {
-    if (!m_xEditView)
+    EditView* pEditView = GetEditView();
+    if (!pEditView)
         return -1;
-    rSurrounding = m_xEditView->GetSurroundingText();
-    return m_xEditView->GetSurroundingTextSelection().Min();
+    rSurrounding = pEditView->GetSurroundingText();
+    return pEditView->GetSurroundingTextSelection().Min();
 }
 
 bool WeldEditView::DeleteSurroundingText(const Selection& rRange)
 {
-    if (!m_xEditView)
+    EditView* pEditView = GetEditView();
+    if (!pEditView)
         return false;
-    return m_xEditView->DeleteSurroundingText(rRange);
+    return pEditView->DeleteSurroundingText(rRange);
 }
 
 void WeldEditView::GetFocus()
 {
-    if (m_xEditView)
-        m_xEditView->ShowCursor(false);
+    EditView* pEditView = GetEditView();
+    if (pEditView)
+        pEditView->ShowCursor(false);
 
     weld::CustomWidgetController::GetFocus();
 


More information about the Libreoffice-commits mailing list