[Libreoffice-commits] core.git: include/svx svx/source
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Wed Oct 7 14:20:17 UTC 2020
include/svx/weldeditview.hxx | 20 ++++++++++++---
svx/source/dialog/weldeditview.cxx | 49 +++++++++++++++++++++----------------
2 files changed, 45 insertions(+), 24 deletions(-)
New commits:
commit ac2369cf0369da191ac970a6ed47d634a7fae0e7
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Oct 7 10:16:41 2020 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Oct 7 16:19:32 2020 +0200
let a subclass destroy and recreate its EditView
Change-Id: I743592b0d6d864f3d72c2fd111ef8adf13a3eb4a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104052
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/include/svx/weldeditview.hxx b/include/svx/weldeditview.hxx
index d54f2c9404a7..00f49f6965a7 100644
--- a/include/svx/weldeditview.hxx
+++ b/include/svx/weldeditview.hxx
@@ -39,11 +39,23 @@ public:
EditEngine& GetEditEngine() { return *m_xEditEngine; }
- bool HasSelection() const { return m_xEditView->HasSelection(); }
+ bool HasSelection() const { return m_xEditView && m_xEditView->HasSelection(); }
- void Cut() { m_xEditView->Cut(); }
- void Copy() { m_xEditView->Copy(); }
- void Paste() { m_xEditView->Paste(); }
+ void Cut()
+ {
+ if (m_xEditView)
+ m_xEditView->Cut();
+ }
+ void Copy()
+ {
+ if (m_xEditView)
+ m_xEditView->Copy();
+ }
+ void Paste()
+ {
+ if (m_xEditView)
+ m_xEditView->Paste();
+ }
virtual ~WeldEditView() override;
diff --git a/svx/source/dialog/weldeditview.cxx b/svx/source/dialog/weldeditview.cxx
index d29316f9c9a9..18fc071702b5 100644
--- a/svx/source/dialog/weldeditview.cxx
+++ b/svx/source/dialog/weldeditview.cxx
@@ -88,32 +88,33 @@ void WeldEditView::Resize()
void WeldEditView::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect)
{
- //note: ScEditWindow::Paint is similar
-
rRenderContext.Push(PushFlags::ALL);
rRenderContext.SetClipRegion();
const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
Color aBgColor = rStyleSettings.GetWindowColor();
- m_xEditView->SetBackgroundColor(aBgColor);
-
rRenderContext.SetBackground(aBgColor);
- tools::Rectangle aLogicRect(rRenderContext.PixelToLogic(rRect));
- m_xEditView->Paint(aLogicRect, &rRenderContext);
+ std::vector<tools::Rectangle> aLogicRects;
- if (HasFocus())
+ if (m_xEditView)
{
- m_xEditView->ShowCursor();
- vcl::Cursor* pCursor = m_xEditView->GetCursor();
- pCursor->DrawToDevice(rRenderContext);
- }
+ m_xEditView->SetBackgroundColor(aBgColor);
- std::vector<tools::Rectangle> aLogicRects;
+ tools::Rectangle aLogicRect(rRenderContext.PixelToLogic(rRect));
+ m_xEditView->Paint(aLogicRect, &rRenderContext);
- // get logic selection
- m_xEditView->GetSelectionRectangles(aLogicRects);
+ if (HasFocus())
+ {
+ m_xEditView->ShowCursor();
+ vcl::Cursor* pCursor = m_xEditView->GetCursor();
+ pCursor->DrawToDevice(rRenderContext);
+ }
+
+ // get logic selection
+ m_xEditView->GetSelectionRectangles(aLogicRects);
+ }
rRenderContext.SetLineColor();
rRenderContext.SetFillColor(COL_BLACK);
@@ -125,7 +126,10 @@ void WeldEditView::Paint(vcl::RenderContext& rRenderContext, const tools::Rectan
rRenderContext.Pop();
}
-bool WeldEditView::MouseMove(const MouseEvent& rMEvt) { return m_xEditView->MouseMove(rMEvt); }
+bool WeldEditView::MouseMove(const MouseEvent& rMEvt)
+{
+ return m_xEditView && m_xEditView->MouseMove(rMEvt);
+}
bool WeldEditView::MouseButtonDown(const MouseEvent& rMEvt)
{
@@ -135,12 +139,12 @@ bool WeldEditView::MouseButtonDown(const MouseEvent& rMEvt)
GetFocus();
}
- return m_xEditView->MouseButtonDown(rMEvt);
+ return m_xEditView && m_xEditView->MouseButtonDown(rMEvt);
}
bool WeldEditView::MouseButtonUp(const MouseEvent& rMEvt)
{
- return m_xEditView->MouseButtonUp(rMEvt);
+ return m_xEditView && m_xEditView->MouseButtonUp(rMEvt);
}
bool WeldEditView::KeyInput(const KeyEvent& rKEvt)
@@ -151,7 +155,7 @@ bool WeldEditView::KeyInput(const KeyEvent& rKEvt)
{
return false;
}
- else if (!m_xEditView->PostKeyEvent(rKEvt))
+ else if (m_xEditView && !m_xEditView->PostKeyEvent(rKEvt))
{
if (rKEvt.GetKeyCode().IsMod1() && !rKEvt.GetKeyCode().IsMod2())
{
@@ -175,6 +179,8 @@ bool WeldEditView::KeyInput(const KeyEvent& rKEvt)
bool WeldEditView::Command(const CommandEvent& rCEvt)
{
+ if (!m_xEditView)
+ return false;
m_xEditView->Command(rCEvt);
return true;
}
@@ -1432,6 +1438,8 @@ void WeldEditView::SetDrawingArea(weld::DrawingArea* pDrawingArea)
int WeldEditView::GetSurroundingText(OUString& rSurrounding)
{
+ if (!m_xEditView)
+ return -1;
rSurrounding = m_xEditView->GetSurroundingText();
return m_xEditView->GetSurroundingTextSelection().Min();
}
@@ -1439,7 +1447,7 @@ int WeldEditView::GetSurroundingText(OUString& rSurrounding)
bool WeldEditView::DeleteSurroundingText(const Selection& rRange)
{
bool bRes(false);
- EditEngine* pEditEngine = m_xEditView->GetEditEngine();
+ EditEngine* pEditEngine = m_xEditView ? m_xEditView->GetEditEngine() : nullptr;
if (pEditEngine)
{
ESelection aSel(m_xEditView->GetSelection());
@@ -1455,7 +1463,8 @@ bool WeldEditView::DeleteSurroundingText(const Selection& rRange)
void WeldEditView::GetFocus()
{
- m_xEditView->ShowCursor();
+ if (m_xEditView)
+ m_xEditView->ShowCursor();
weld::CustomWidgetController::GetFocus();
More information about the Libreoffice-commits
mailing list