[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - cui/source editeng/source include/editeng include/svx sc/source svx/source
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Fri Sep 13 13:11:13 UTC 2019
cui/source/dialogs/SpellDialog.cxx | 116 +-------------------
cui/source/inc/SpellDialog.hxx | 31 -----
editeng/source/misc/weldeditview.cxx | 62 ++++++----
include/editeng/weldeditview.hxx | 10 +
include/svx/ClassificationEditView.hxx | 46 +------
sc/source/ui/inc/tphfedit.hxx | 39 +-----
sc/source/ui/pagedlg/tphfedit.cxx | 156 +++++----------------------
svx/source/dialog/ClassificationDialog.cxx | 23 ++-
svx/source/dialog/ClassificationEditView.cxx | 140 +-----------------------
9 files changed, 125 insertions(+), 498 deletions(-)
New commits:
commit 6d2efae662a57bf49fd4367e603f307b50885620
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue Jun 25 15:21:40 2019 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Fri Sep 13 15:10:34 2019 +0200
use common WeldEditView
Reviewed-on: https://gerrit.libreoffice.org/74705
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
(cherry picked from commit 2cebba0e4042ca2cab37cf38874c2576c2ac6a6f)
Change-Id: I873cb64a167027030c9eeef61344e6f6f885a924
Reviewed-on: https://gerrit.libreoffice.org/78544
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
diff --git a/cui/source/dialogs/SpellDialog.cxx b/cui/source/dialogs/SpellDialog.cxx
index 6d77aebe8d07..74af6f7d2a57 100644
--- a/cui/source/dialogs/SpellDialog.cxx
+++ b/cui/source/dialogs/SpellDialog.cxx
@@ -1120,108 +1120,8 @@ void SentenceEditWindow_Impl::SetDrawingArea(weld::DrawingArea* pDrawingArea)
{
Size aSize(pDrawingArea->get_approximate_digit_width() * 60,
pDrawingArea->get_text_height() * 6);
-
pDrawingArea->set_size_request(aSize.Width(), aSize.Height());
- SetOutputSizePixel(aSize);
-
- weld::CustomWidgetController::SetDrawingArea(pDrawingArea);
-
- EnableRTL(false);
-
- const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
- Color aBgColor = rStyleSettings.GetWindowColor();
-
- OutputDevice& rDevice = pDrawingArea->get_ref_device();
-
- rDevice.SetMapMode(MapMode(MapUnit::MapTwip));
- rDevice.SetBackground(aBgColor);
-
- Size aOutputSize(rDevice.PixelToLogic(aSize));
- aSize = aOutputSize;
- aSize.setHeight( aSize.Height() * 4 );
-
- m_xEditEngine.reset(new EditEngine(EditEngine::CreatePool()));
- m_xEditEngine->SetPaperSize( aSize );
- m_xEditEngine->SetRefDevice( &rDevice );
-
- m_xEditEngine->SetControlWord(m_xEditEngine->GetControlWord() | EEControlBits::MARKFIELDS);
-
- m_xEdView.reset(new EditView(m_xEditEngine.get(), nullptr));
- m_xEdView->setEditViewCallbacks(this);
- m_xEdView->SetOutputArea(tools::Rectangle(Point(0,0), aOutputSize));
-
- m_xEdView->SetBackgroundColor(aBgColor);
- m_xEditEngine->InsertView(m_xEdView.get());
-
- pDrawingArea->set_cursor(PointerStyle::Text);
-}
-
-void SentenceEditWindow_Impl::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect)
-{
- //note: ClassificationEditView::Paint is similar
-
- rRenderContext.Push(PushFlags::ALL);
- rRenderContext.SetClipRegion();
-
- const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
- Color aBgColor = rStyleSettings.GetWindowColor();
-
- m_xEdView->SetBackgroundColor(aBgColor);
-
- rRenderContext.SetBackground(aBgColor);
-
- tools::Rectangle aLogicRect(rRenderContext.PixelToLogic(rRect));
- m_xEdView->Paint(aLogicRect, &rRenderContext);
-
- if (HasFocus())
- {
- m_xEdView->ShowCursor();
- vcl::Cursor* pCursor = m_xEdView->GetCursor();
- pCursor->DrawToDevice(rRenderContext);
- }
-
- std::vector<tools::Rectangle> aLogicRects;
-
- // get logic selection
- m_xEdView->GetSelectionRectangles(aLogicRects);
-
- rRenderContext.SetLineColor();
- rRenderContext.SetFillColor(COL_BLACK);
- rRenderContext.SetRasterOp(RasterOp::Invert);
-
- for (const auto &rSelectionRect : aLogicRects)
- rRenderContext.DrawRect(rSelectionRect);
-
- rRenderContext.Pop();
-}
-
-bool SentenceEditWindow_Impl::MouseMove(const MouseEvent& rMEvt)
-{
- return m_xEdView->MouseMove(rMEvt);
-}
-
-bool SentenceEditWindow_Impl::MouseButtonDown(const MouseEvent& rMEvt)
-{
- if (!HasFocus())
- GrabFocus();
-
- return m_xEdView->MouseButtonDown(rMEvt);
-}
-
-bool SentenceEditWindow_Impl::MouseButtonUp(const MouseEvent& rMEvt)
-{
- return m_xEdView->MouseButtonUp(rMEvt);
-}
-
-void SentenceEditWindow_Impl::Resize()
-{
- OutputDevice& rDevice = GetDrawingArea()->get_ref_device();
- Size aOutputSize(rDevice.PixelToLogic(GetOutputSizePixel()));
- Size aSize(aOutputSize);
- aSize.setHeight( aSize.Height() * 4 );
- m_xEditEngine->SetPaperSize(aSize);
- m_xEdView->SetOutputArea(tools::Rectangle(Point(0,0), aOutputSize));
- weld::CustomWidgetController::Resize();
+ WeldEditView::SetDrawingArea(pDrawingArea);
}
SentenceEditWindow_Impl::~SentenceEditWindow_Impl()
@@ -1338,7 +1238,7 @@ bool SentenceEditWindow_Impl::KeyInput(const KeyEvent& rKeyEvt)
{
bConsumed = true;
- ESelection aCurrentSelection(m_xEdView->GetSelection());
+ ESelection aCurrentSelection(m_xEditView->GetSelection());
aCurrentSelection.Adjust();
//determine if the selection contains a field
@@ -1498,13 +1398,13 @@ bool SentenceEditWindow_Impl::KeyInput(const KeyEvent& rKeyEvt)
sal_Int32 nCurrentLen = m_xEditEngine->GetText().getLength();
if (nAction != ACTION_SELECTFIELD)
{
- m_xEdView->PostKeyEvent(rKeyEvt);
+ m_xEditView->PostKeyEvent(rKeyEvt);
}
else
{
const EECharAttrib* pCharAttr = pBackAttr ? pBackAttr : pBackAttrLeft;
if (pCharAttr)
- m_xEdView->SetSelection(ESelection(0, pCharAttr->nStart, 0, pCharAttr->nEnd));
+ m_xEditView->SetSelection(ESelection(0, pCharAttr->nStart, 0, pCharAttr->nEnd));
}
if(nAction == ACTION_EXPAND)
{
@@ -1591,7 +1491,7 @@ bool SentenceEditWindow_Impl::KeyInput(const KeyEvent& rKeyEvt)
CallModifyLink();
}
else
- bConsumed = m_xEdView->PostKeyEvent(rKeyEvt);
+ bConsumed = m_xEditView->PostKeyEvent(rKeyEvt);
return bConsumed;
}
@@ -1606,7 +1506,7 @@ IMPL_LINK(SentenceEditWindow_Impl, ToolbarHdl, const OString&, rCurItemId, void)
{
if (rCurItemId == "paste")
{
- m_xEdView->Paste();
+ m_xEditView->Paste();
CallModifyLink();
}
else if (rCurItemId == "insert")
@@ -1616,7 +1516,7 @@ IMPL_LINK(SentenceEditWindow_Impl, ToolbarHdl, const OString&, rCurItemId, void)
OUString aChars = Edit::GetGetSpecialCharsFunction()(GetDrawingArea(), m_xEditEngine->GetStandardFont(0));
if (!aChars.isEmpty())
{
- ESelection aCurrentSelection(m_xEdView->GetSelection());
+ ESelection aCurrentSelection(m_xEditView->GetSelection());
m_xEditEngine->QuickInsertText(aChars, aCurrentSelection);
CallModifyLink();
}
@@ -1759,7 +1659,7 @@ void SentenceEditWindow_Impl::MoveErrorMarkTo(sal_Int32 nStart, sal_Int32 nEnd,
m_xEditEngine->QuickSetAttribs(aSet, ESelection(0, nStart, 0, nEnd));
// so the editview will autoscroll to make this visible
- m_xEdView->SetSelection(ESelection(0, nStart));
+ m_xEditView->SetSelection(ESelection(0, nStart));
Invalidate();
m_nErrorStart = nStart;
diff --git a/cui/source/inc/SpellDialog.hxx b/cui/source/inc/SpellDialog.hxx
index ee6d477ec279..943d19b50dd8 100644
--- a/cui/source/inc/SpellDialog.hxx
+++ b/cui/source/inc/SpellDialog.hxx
@@ -39,8 +39,7 @@
#include <vcl/xtextedt.hxx>
#include <vcl/txtattr.hxx>
#include <vcl/customweld.hxx>
-#include <editeng/editeng.hxx>
-#include <editeng/editview.hxx>
+#include <editeng/weldeditview.hxx>
#include <editeng/SpellPortions.hxx>
#include <set>
@@ -59,13 +58,9 @@ namespace svx{
class SpellDialog;
struct SpellErrorDescription;
-class SentenceEditWindow_Impl : public weld::CustomWidgetController
- , public EditViewCallbacks
+class SentenceEditWindow_Impl : public WeldEditView
{
private:
- std::unique_ptr<EditEngine> m_xEditEngine;
- std::unique_ptr<EditView> m_xEdView;
-
std::set<sal_Int32> m_aIgnoreErrorsAt;
SpellDialog* m_pSpellDialog;
weld::Toolbar* m_pToolbar;
@@ -84,29 +79,7 @@ private:
DECL_LINK(ToolbarHdl, const OString&, void);
protected:
- 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;
- virtual bool MouseButtonUp( const MouseEvent& rMEvt ) override;
virtual bool KeyInput( const KeyEvent& rKEvt ) override;
- virtual void Resize() override;
-
- virtual void EditViewInvalidate(const tools::Rectangle& rRect) const override
- {
- weld::DrawingArea* pDrawingArea = GetDrawingArea();
- pDrawingArea->queue_draw_area(rRect.Left(), rRect.Top(), rRect.GetWidth(), rRect.GetHeight());
- }
-
- virtual void EditViewSelectionChange() const override
- {
- weld::DrawingArea* pDrawingArea = GetDrawingArea();
- pDrawingArea->queue_draw();
- }
-
- virtual OutputDevice& EditViewOutputDevice() const override
- {
- return GetDrawingArea()->get_ref_device();
- }
public:
SentenceEditWindow_Impl();
diff --git a/editeng/source/misc/weldeditview.cxx b/editeng/source/misc/weldeditview.cxx
index dab3796f9b17..38c253d5e6d3 100644
--- a/editeng/source/misc/weldeditview.cxx
+++ b/editeng/source/misc/weldeditview.cxx
@@ -15,12 +15,22 @@
#include <vcl/settings.hxx>
#include <vcl/svapp.hxx>
-Size WeldEditView::GetPreferredSize() const { return Size(500, 100); }
+WeldEditView::WeldEditView() {}
+
+void WeldEditView::makeEditEngine()
+{
+ m_xEditEngine.reset(new EditEngine(EditEngine::CreatePool()));
+}
void WeldEditView::SetDrawingArea(weld::DrawingArea* pDrawingArea)
{
- Size aSize(GetPreferredSize());
+ Size aSize(pDrawingArea->get_size_request());
+ if (aSize.Width() == -1)
+ aSize.setWidth(500);
+ if (aSize.Height() == -1)
+ aSize.setHeight(100);
pDrawingArea->set_size_request(aSize.Width(), aSize.Height());
+
SetOutputSizePixel(aSize);
weld::CustomWidgetController::SetDrawingArea(pDrawingArea);
@@ -39,18 +49,18 @@ void WeldEditView::SetDrawingArea(weld::DrawingArea* pDrawingArea)
aSize = aOutputSize;
aSize.setHeight(aSize.Height());
- m_xEdEngine.reset(new EditEngine(EditEngine::CreatePool()));
- m_xEdEngine->SetPaperSize(aSize);
- m_xEdEngine->SetRefDevice(&rDevice);
+ makeEditEngine();
+ m_xEditEngine->SetPaperSize(aSize);
+ m_xEditEngine->SetRefDevice(&rDevice);
- m_xEdEngine->SetControlWord(m_xEdEngine->GetControlWord() | EEControlBits::MARKFIELDS);
+ m_xEditEngine->SetControlWord(m_xEditEngine->GetControlWord() | EEControlBits::MARKFIELDS);
- m_xEdView.reset(new EditView(m_xEdEngine.get(), nullptr));
- m_xEdView->setEditViewCallbacks(this);
- m_xEdView->SetOutputArea(tools::Rectangle(Point(0, 0), aOutputSize));
+ m_xEditView.reset(new EditView(m_xEditEngine.get(), nullptr));
+ m_xEditView->setEditViewCallbacks(this);
+ m_xEditView->SetOutputArea(tools::Rectangle(Point(0, 0), aOutputSize));
- m_xEdView->SetBackgroundColor(aBgColor);
- m_xEdEngine->InsertView(m_xEdView.get());
+ m_xEditView->SetBackgroundColor(aBgColor);
+ m_xEditEngine->InsertView(m_xEditView.get());
pDrawingArea->set_cursor(PointerStyle::Text);
}
@@ -62,8 +72,8 @@ void WeldEditView::Resize()
OutputDevice& rDevice = GetDrawingArea()->get_ref_device();
Size aOutputSize(rDevice.PixelToLogic(GetOutputSizePixel()));
Size aSize(aOutputSize);
- m_xEdEngine->SetPaperSize(aSize);
- m_xEdView->SetOutputArea(tools::Rectangle(Point(0, 0), aOutputSize));
+ m_xEditEngine->SetPaperSize(aSize);
+ m_xEditView->SetOutputArea(tools::Rectangle(Point(0, 0), aOutputSize));
weld::CustomWidgetController::Resize();
}
@@ -77,24 +87,24 @@ void WeldEditView::Paint(vcl::RenderContext& rRenderContext, const tools::Rectan
const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
Color aBgColor = rStyleSettings.GetWindowColor();
- m_xEdView->SetBackgroundColor(aBgColor);
+ m_xEditView->SetBackgroundColor(aBgColor);
rRenderContext.SetBackground(aBgColor);
tools::Rectangle aLogicRect(rRenderContext.PixelToLogic(rRect));
- m_xEdView->Paint(aLogicRect, &rRenderContext);
+ m_xEditView->Paint(aLogicRect, &rRenderContext);
if (HasFocus())
{
- m_xEdView->ShowCursor();
- vcl::Cursor* pCursor = m_xEdView->GetCursor();
+ m_xEditView->ShowCursor();
+ vcl::Cursor* pCursor = m_xEditView->GetCursor();
pCursor->DrawToDevice(rRenderContext);
}
std::vector<tools::Rectangle> aLogicRects;
// get logic selection
- m_xEdView->GetSelectionRectangles(aLogicRects);
+ m_xEditView->GetSelectionRectangles(aLogicRects);
rRenderContext.SetLineColor();
rRenderContext.SetFillColor(COL_BLACK);
@@ -106,19 +116,19 @@ void WeldEditView::Paint(vcl::RenderContext& rRenderContext, const tools::Rectan
rRenderContext.Pop();
}
-bool WeldEditView::MouseMove(const MouseEvent& rMEvt) { return m_xEdView->MouseMove(rMEvt); }
+bool WeldEditView::MouseMove(const MouseEvent& rMEvt) { return m_xEditView->MouseMove(rMEvt); }
bool WeldEditView::MouseButtonDown(const MouseEvent& rMEvt)
{
if (!HasFocus())
GrabFocus();
- return m_xEdView->MouseButtonDown(rMEvt);
+ return m_xEditView->MouseButtonDown(rMEvt);
}
bool WeldEditView::MouseButtonUp(const MouseEvent& rMEvt)
{
- return m_xEdView->MouseButtonUp(rMEvt);
+ return m_xEditView->MouseButtonUp(rMEvt);
}
bool WeldEditView::KeyInput(const KeyEvent& rKEvt)
@@ -129,7 +139,7 @@ bool WeldEditView::KeyInput(const KeyEvent& rKEvt)
{
return false;
}
- else if (!m_xEdView->PostKeyEvent(rKEvt))
+ else if (!m_xEditView->PostKeyEvent(rKEvt))
{
return false;
}
@@ -139,9 +149,15 @@ bool WeldEditView::KeyInput(const KeyEvent& rKEvt)
void WeldEditView::GetFocus()
{
- m_xEdView->ShowCursor();
+ m_xEditView->ShowCursor();
weld::CustomWidgetController::GetFocus();
}
+void WeldEditView::LoseFocus()
+{
+ weld::CustomWidgetController::LoseFocus();
+ Invalidate(); // redraw without cursor
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/editeng/weldeditview.hxx b/include/editeng/weldeditview.hxx
index 3d31f589d14f..d14873258d0f 100644
--- a/include/editeng/weldeditview.hxx
+++ b/include/editeng/weldeditview.hxx
@@ -25,17 +25,19 @@ public:
virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
virtual ~WeldEditView() override;
- std::unique_ptr<EditEngine> m_xEdEngine;
- std::unique_ptr<EditView> m_xEdView;
-
protected:
- virtual Size GetPreferredSize() const;
+ std::unique_ptr<EditEngine> m_xEditEngine;
+ std::unique_ptr<EditView> m_xEditView;
+
+ virtual void makeEditEngine();
+
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;
virtual bool MouseButtonUp(const MouseEvent& rMEvt) override;
virtual bool KeyInput(const KeyEvent& rKEvt) override;
virtual void GetFocus() override;
+ virtual void LoseFocus() override;
virtual void Resize() override;
virtual void EditViewInvalidate(const tools::Rectangle& rRect) const override
diff --git a/include/svx/ClassificationEditView.hxx b/include/svx/ClassificationEditView.hxx
index f3ce3b9cb58e..0e6d5ed354b6 100644
--- a/include/svx/ClassificationEditView.hxx
+++ b/include/svx/ClassificationEditView.hxx
@@ -13,8 +13,7 @@
#include <sal/config.h>
#include <svx/svxdllapi.h>
-#include <editeng/editeng.hxx>
-#include <editeng/editview.hxx>
+#include <editeng/weldeditview.hxx>
#include <editeng/svxenum.hxx>
#include <vcl/customweld.hxx>
@@ -28,14 +27,14 @@ public:
virtual OUString CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rTxtColor, boost::optional<Color>& rFldColor) override;
};
-class SVX_DLLPUBLIC ClassificationEditView : public weld::CustomWidgetController
- , public EditViewCallbacks
+class SVX_DLLPUBLIC ClassificationEditView : public WeldEditView
{
public:
ClassificationEditView();
- virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
virtual ~ClassificationEditView() override;
+ virtual void makeEditEngine() override;
+
void SetCharAttributes();
void InsertField(const SvxFieldItem& rField);
@@ -44,44 +43,19 @@ public:
void SetNumType(SvxNumType eNumType);
- std::unique_ptr<ClassificationEditEngine> pEdEngine;
- std::unique_ptr<EditView> pEdView;
-
- const ClassificationEditEngine& getEditEngine()
- {
- return *pEdEngine;
- }
-
- void SetModifyHdl(const Link<LinkParamNone*,void>& rLink)
- {
- pEdEngine->SetModifyHdl(rLink);
- }
-
-protected:
- 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;
- virtual bool MouseButtonUp( const MouseEvent& rMEvt ) override;
- virtual bool KeyInput( const KeyEvent& rKEvt ) override;
- virtual void GetFocus() override;
- virtual void Resize() override;
-
-
- virtual void EditViewInvalidate(const tools::Rectangle& rRect) const override
+ ClassificationEditEngine& getEditEngine()
{
- weld::DrawingArea* pDrawingArea = GetDrawingArea();
- pDrawingArea->queue_draw_area(rRect.Left(), rRect.Top(), rRect.GetWidth(), rRect.GetHeight());
+ return *static_cast<ClassificationEditEngine*>(m_xEditEngine.get());
}
- virtual void EditViewSelectionChange() const override
+ EditView& getEditView()
{
- weld::DrawingArea* pDrawingArea = GetDrawingArea();
- pDrawingArea->queue_draw();
+ return *m_xEditView.get();
}
- virtual OutputDevice& EditViewOutputDevice() const override
+ void SetModifyHdl(const Link<LinkParamNone*,void>& rLink)
{
- return GetDrawingArea()->get_ref_device();
+ m_xEditEngine->SetModifyHdl(rLink);
}
};
diff --git a/sc/source/ui/inc/tphfedit.hxx b/sc/source/ui/inc/tphfedit.hxx
index 87deb5f7a94b..ce47f287a6c4 100644
--- a/sc/source/ui/inc/tphfedit.hxx
+++ b/sc/source/ui/inc/tphfedit.hxx
@@ -23,7 +23,7 @@
#include <scdllapi.h>
#include <cppuhelper/weakref.hxx>
#include <tools/wintypes.hxx>
-#include <editeng/editview.hxx>
+#include <editeng/weldeditview.hxx>
#include <editeng/svxenum.hxx>
#include <vcl/customweld.hxx>
@@ -46,8 +46,7 @@ enum ScEditWindowLocation
Right
};
-class SC_DLLPUBLIC ScEditWindow : public weld::CustomWidgetController
- , public EditViewCallbacks
+class SC_DLLPUBLIC ScEditWindow : public WeldEditView
{
public:
ScEditWindow(ScEditWindowLocation eLoc, weld::Window* pParent);
@@ -65,40 +64,17 @@ public:
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override;
- ScHeaderEditEngine* GetEditEngine() const { return pEdEngine.get(); }
+ ScHeaderEditEngine* GetEditEngine() const;
void SetObjectSelectHdl( const Link<ScEditWindow&,void>& aLink) { aObjectSelectLink = aLink; }
void SetGetFocusHdl(const std::function<void (ScEditWindow&)>& rLink) { m_GetFocusLink = rLink; }
protected:
- 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;
- virtual bool MouseButtonUp( const MouseEvent& rMEvt ) override;
- virtual bool KeyInput( const KeyEvent& rKEvt ) override;
- virtual void GetFocus() override;
- virtual void LoseFocus() override;
- virtual void Resize() override;
-
- virtual void EditViewInvalidate(const tools::Rectangle& rRect) const override
- {
- weld::DrawingArea* pDrawingArea = GetDrawingArea();
- pDrawingArea->queue_draw_area(rRect.Left(), rRect.Top(), rRect.GetWidth(), rRect.GetHeight());
- }
-
- virtual void EditViewSelectionChange() const override
- {
- weld::DrawingArea* pDrawingArea = GetDrawingArea();
- pDrawingArea->queue_draw();
- }
-
- virtual OutputDevice& EditViewOutputDevice() const override
- {
- return GetDrawingArea()->get_ref_device();
- }
+ virtual void makeEditEngine() override;
+ virtual bool KeyInput( const KeyEvent& rKEvt ) override;
+ virtual void GetFocus() override;
+ virtual void LoseFocus() override;
private:
- std::unique_ptr<ScHeaderEditEngine> pEdEngine;
- std::unique_ptr<EditView> pEdView;
ScEditWindowLocation eLocation;
bool mbRTL;
weld::Window* mpDialog;
@@ -108,6 +84,7 @@ private:
Link<ScEditWindow&,void> aObjectSelectLink;
std::function<void (ScEditWindow&)> m_GetFocusLink;
+
};
#endif // INCLUDED_SC_SOURCE_UI_INC_TPHFEDIT_HXX
diff --git a/sc/source/ui/pagedlg/tphfedit.cxx b/sc/source/ui/pagedlg/tphfedit.cxx
index ff01ce68e606..9a41ffdd5476 100644
--- a/sc/source/ui/pagedlg/tphfedit.cxx
+++ b/sc/source/ui/pagedlg/tphfedit.cxx
@@ -68,49 +68,30 @@ ScEditWindow::ScEditWindow(ScEditWindowLocation eLoc, weld::Window* pDialog)
{
}
+void ScEditWindow::makeEditEngine()
+{
+ m_xEditEngine.reset(new ScHeaderEditEngine(EditEngine::CreatePool()));
+}
+
+ScHeaderEditEngine* ScEditWindow::GetEditEngine() const
+{
+ return static_cast<ScHeaderEditEngine*>(m_xEditEngine.get());
+}
+
void ScEditWindow::SetDrawingArea(weld::DrawingArea* pDrawingArea)
{
OutputDevice& rDevice = pDrawingArea->get_ref_device();
-
Size aSize = rDevice.LogicToPixel(Size(80, 120), MapMode(MapUnit::MapAppFont));
pDrawingArea->set_size_request(aSize.Width(), aSize.Height());
- SetOutputSizePixel(aSize);
-
- weld::CustomWidgetController::SetDrawingArea(pDrawingArea);
-
- EnableRTL(false);
-
- const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
- Color aBgColor = rStyleSettings.GetWindowColor();
-
- rDevice.SetMapMode(MapMode(MapUnit::MapTwip));
- rDevice.SetBackground(aBgColor);
-
- Size aOutputSize(rDevice.PixelToLogic(aSize));
- aSize = aOutputSize;
- aSize.setHeight( aSize.Height() * 4 );
- pEdEngine.reset( new ScHeaderEditEngine( EditEngine::CreatePool() ) );
- pEdEngine->SetPaperSize( aSize );
- pEdEngine->SetRefDevice( &rDevice );
+ WeldEditView::SetDrawingArea(pDrawingArea);
ScHeaderFieldData aData;
- lcl_GetFieldData( aData );
-
+ lcl_GetFieldData(aData);
// fields
- pEdEngine->SetData( aData );
- pEdEngine->SetControlWord( pEdEngine->GetControlWord() | EEControlBits::MARKFIELDS );
+ GetEditEngine()->SetData(aData);
if (mbRTL)
- pEdEngine->SetDefaultHorizontalTextDirection(EEHorizontalTextDirection::R2L);
-
- pEdView.reset(new EditView(pEdEngine.get(), nullptr));
- pEdView->setEditViewCallbacks(this);
- pEdView->SetOutputArea(tools::Rectangle(Point(0,0), aOutputSize));
-
- pEdView->SetBackgroundColor( aBgColor );
- pEdEngine->InsertView( pEdView.get() );
-
- pDrawingArea->set_cursor(PointerStyle::Text);
+ m_xEditEngine->SetDefaultHorizontalTextDirection(EEHorizontalTextDirection::R2L);
if (pAcc)
{
@@ -128,22 +109,11 @@ void ScEditWindow::SetDrawingArea(weld::DrawingArea* pDrawingArea)
break;
}
- pAcc->InitAcc(nullptr, pEdView.get(), nullptr,
+ pAcc->InitAcc(nullptr, m_xEditView.get(), nullptr,
sName, pDrawingArea->get_tooltip_text());
}
}
-void ScEditWindow::Resize()
-{
- OutputDevice& rDevice = GetDrawingArea()->get_ref_device();
- Size aOutputSize(rDevice.PixelToLogic(GetOutputSizePixel()));
- Size aSize(aOutputSize);
- aSize.setHeight( aSize.Height() * 4 );
- pEdEngine->SetPaperSize(aSize);
- pEdView->SetOutputArea(tools::Rectangle(Point(0,0), aOutputSize));
- weld::CustomWidgetController::Resize();
-}
-
ScEditWindow::~ScEditWindow()
{
// delete Accessible object before deleting EditEngine and EditView
@@ -153,14 +123,13 @@ ScEditWindow::~ScEditWindow()
if (xTemp.is())
pAcc->dispose();
}
- pEdEngine.reset();
- pEdView.reset();
}
void ScEditWindow::SetNumType(SvxNumType eNumType)
{
- pEdEngine->SetNumType(eNumType);
- pEdEngine->UpdateFields();
+ ScHeaderEditEngine* pEditEngine = GetEditEngine();
+ pEditEngine->SetNumType(eNumType);
+ pEditEngine->UpdateFields();
}
std::unique_ptr<EditTextObject> ScEditWindow::CreateTextObject()
@@ -168,17 +137,17 @@ std::unique_ptr<EditTextObject> ScEditWindow::CreateTextObject()
// reset paragraph attributes
// (GetAttribs at creation of format dialog always returns the set items)
- const SfxItemSet& rEmpty = pEdEngine->GetEmptyItemSet();
- sal_Int32 nParCnt = pEdEngine->GetParagraphCount();
+ const SfxItemSet& rEmpty = m_xEditEngine->GetEmptyItemSet();
+ sal_Int32 nParCnt = m_xEditEngine->GetParagraphCount();
for (sal_Int32 i=0; i<nParCnt; i++)
- pEdEngine->SetParaAttribs( i, rEmpty );
+ m_xEditEngine->SetParaAttribs( i, rEmpty );
- return pEdEngine->CreateTextObject();
+ return m_xEditEngine->CreateTextObject();
}
void ScEditWindow::SetFont( const ScPatternAttr& rPattern )
{
- auto pSet = std::make_unique<SfxItemSet>( pEdEngine->GetEmptyItemSet() );
+ auto pSet = std::make_unique<SfxItemSet>( m_xEditEngine->GetEmptyItemSet() );
rPattern.FillEditItemSet( pSet.get() );
// FillEditItemSet adjusts font height to 1/100th mm,
// but for header/footer twips is needed, as in the PatternAttr:
@@ -187,17 +156,17 @@ void ScEditWindow::SetFont( const ScPatternAttr& rPattern )
pSet->Put( rPattern.GetItem(ATTR_CTL_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CTL) );
if (mbRTL)
pSet->Put( SvxAdjustItem( SvxAdjust::Right, EE_PARA_JUST ) );
- pEdEngine->SetDefaults( std::move(pSet) );
+ GetEditEngine()->SetDefaults( std::move(pSet) );
}
void ScEditWindow::SetText( const EditTextObject& rTextObject )
{
- pEdEngine->SetText( rTextObject );
+ m_xEditEngine->SetText( rTextObject );
}
void ScEditWindow::InsertField( const SvxFieldItem& rFld )
{
- pEdView->InsertField( rFld );
+ m_xEditView->InsertField( rFld );
}
void ScEditWindow::SetCharAttributes()
@@ -215,7 +184,7 @@ void ScEditWindow::SetCharAttributes()
{
if(pTabViewSh!=nullptr) pTabViewSh->SetInFormatDialog(true);
- SfxItemSet aSet( pEdView->GetAttribs() );
+ SfxItemSet aSet( m_xEditView->GetAttribs() );
ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
@@ -226,73 +195,13 @@ void ScEditWindow::SetCharAttributes()
{
aSet.ClearItem();
aSet.Put( *pDlg->GetOutputItemSet() );
- pEdView->SetAttribs( aSet );
+ m_xEditView->SetAttribs( aSet );
}
if(pTabViewSh!=nullptr) pTabViewSh->SetInFormatDialog(false);
}
}
-void ScEditWindow::Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect )
-{
- //note: ClassificationEditView::Paint is similar
-
- rRenderContext.Push(PushFlags::ALL);
- rRenderContext.SetClipRegion();
-
- const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
- Color aBgColor = rStyleSettings.GetWindowColor();
-
- pEdView->SetBackgroundColor( aBgColor );
-
- rRenderContext.SetBackground( aBgColor );
-
- tools::Rectangle aLogicRect(rRenderContext.PixelToLogic(rRect));
- pEdView->Paint(aLogicRect, &rRenderContext);
-
- if (HasFocus())
- {
- pEdView->ShowCursor();
- vcl::Cursor* pCursor = pEdView->GetCursor();
- pCursor->DrawToDevice(rRenderContext);
- }
-
- std::vector<tools::Rectangle> aLogicRects;
-
- // get logic selection
- pEdView->GetSelectionRectangles(aLogicRects);
-
- rRenderContext.SetLineColor();
- rRenderContext.SetFillColor(COL_BLACK);
- rRenderContext.SetRasterOp(RasterOp::Invert);
-
- for (const auto &rSelectionRect : aLogicRects)
- rRenderContext.DrawRect(rSelectionRect);
-
- rRenderContext.Pop();
-}
-
-bool ScEditWindow::MouseMove( const MouseEvent& rMEvt )
-{
- return pEdView->MouseMove( rMEvt );
-}
-
-bool ScEditWindow::MouseButtonDown( const MouseEvent& rMEvt )
-{
- if (!HasFocus())
- {
- GrabFocus();
- GetFocus();
- }
-
- return pEdView->MouseButtonDown( rMEvt );
-}
-
-bool ScEditWindow::MouseButtonUp( const MouseEvent& rMEvt )
-{
- return pEdView->MouseButtonUp( rMEvt );
-}
-
bool ScEditWindow::KeyInput( const KeyEvent& rKEvt )
{
sal_uInt16 nKey = rKEvt.GetKeyCode().GetModifier()
@@ -302,7 +211,7 @@ bool ScEditWindow::KeyInput( const KeyEvent& rKEvt )
{
return false;
}
- else if ( !pEdView->PostKeyEvent( rKEvt ) )
+ else if ( !m_xEditView->PostKeyEvent( rKEvt ) )
{
return false;
}
@@ -317,8 +226,6 @@ bool ScEditWindow::KeyInput( const KeyEvent& rKEvt )
void ScEditWindow::GetFocus()
{
- pEdView->ShowCursor();
-
assert(m_GetFocusLink);
m_GetFocusLink(*this);
@@ -330,7 +237,7 @@ void ScEditWindow::GetFocus()
else
pAcc = nullptr;
- weld::CustomWidgetController::GetFocus();
+ WeldEditView::GetFocus();
}
void ScEditWindow::LoseFocus()
@@ -342,8 +249,7 @@ void ScEditWindow::LoseFocus()
}
else
pAcc = nullptr;
- weld::CustomWidgetController::LoseFocus();
- Invalidate(); // redraw without cursor
+ WeldEditView::LoseFocus();
}
css::uno::Reference< css::accessibility::XAccessible > ScEditWindow::CreateAccessible()
diff --git a/svx/source/dialog/ClassificationDialog.cxx b/svx/source/dialog/ClassificationDialog.cxx
index 3c61c5399c47..0c0b9c7c6f07 100644
--- a/svx/source/dialog/ClassificationDialog.cxx
+++ b/svx/source/dialog/ClassificationDialog.cxx
@@ -426,7 +426,7 @@ void ClassificationDialog::readIn(std::vector<ClassificationResult> const & rInp
{
case svx::ClassificationType::TEXT:
{
- m_xEditWindow->pEdView->InsertText(rClassificationResult.msName);
+ m_xEditWindow->getEditView().InsertText(rClassificationResult.msName);
}
break;
@@ -468,13 +468,15 @@ void ClassificationDialog::readIn(std::vector<ClassificationResult> const & rInp
nParagraph++;
if (nParagraph != 0)
- m_xEditWindow->pEdView->InsertParaBreak();
+ m_xEditWindow->getEditView().InsertParaBreak();
// Set paragraph font weight
FontWeight eWeight = (rClassificationResult.msName == "BOLD") ? WEIGHT_BOLD : WEIGHT_NORMAL;
- std::unique_ptr<SfxItemSet> pSet(new SfxItemSet(m_xEditWindow->pEdEngine->GetParaAttribs(nParagraph)));
+
+ ClassificationEditEngine& rEdEngine = m_xEditWindow->getEditEngine();
+ std::unique_ptr<SfxItemSet> pSet(new SfxItemSet(rEdEngine.GetParaAttribs(nParagraph)));
pSet->Put(SvxWeightItem(eWeight, EE_CHAR_WEIGHT));
- m_xEditWindow->pEdEngine->SetParaAttribs(nParagraph, *pSet);
+ rEdEngine.SetParaAttribs(nParagraph, *pSet);
}
break;
@@ -517,7 +519,8 @@ std::vector<ClassificationResult> ClassificationDialog::getResult()
{
std::vector<ClassificationResult> aClassificationResults;
- std::unique_ptr<EditTextObject> pEditText(m_xEditWindow->pEdEngine->CreateTextObject());
+ ClassificationEditEngine& rEdEngine = m_xEditWindow->getEditEngine();
+ std::unique_ptr<EditTextObject> pEditText(rEdEngine.CreateTextObject());
sal_Int32 nCurrentParagraph = -1;
@@ -531,7 +534,7 @@ std::vector<ClassificationResult> ClassificationDialog::getResult()
// Get Weight of current paragraph
FontWeight eFontWeight = WEIGHT_NORMAL;
- SfxItemSet aItemSet(m_xEditWindow->pEdEngine->GetParaAttribs(nCurrentParagraph));
+ SfxItemSet aItemSet(rEdEngine.GetParaAttribs(nCurrentParagraph));
if (const SfxPoolItem* pItem = aItemSet.GetItem(EE_CHAR_WEIGHT, false))
{
const SvxWeightItem* pWeightItem = dynamic_cast<const SvxWeightItem*>(pItem);
@@ -550,7 +553,7 @@ std::vector<ClassificationResult> ClassificationDialog::getResult()
const SvxFieldItem* pFieldItem = findField(rSection);
ESelection aSelection(rSection.mnParagraph, rSection.mnStart, rSection.mnParagraph, rSection.mnEnd);
- const OUString sDisplayString = m_xEditWindow->pEdEngine->GetText(aSelection);
+ const OUString sDisplayString = rEdEngine.GetText(aSelection);
if (!sDisplayString.isEmpty())
{
const ClassificationField* pClassificationField = pFieldItem ? dynamic_cast<const ClassificationField*>(pFieldItem->GetField()) : nullptr;
@@ -576,7 +579,7 @@ IMPL_LINK(ClassificationDialog, SelectClassificationHdl, weld::ComboBox&, rBox,
if (nSelected < 0 || m_nCurrentSelectedCategory == nSelected)
return;
- std::unique_ptr<EditTextObject> pEditText(m_xEditWindow->pEdEngine->CreateTextObject());
+ std::unique_ptr<EditTextObject> pEditText(m_xEditWindow->getEditEngine().CreateTextObject());
std::vector<editeng::Section> aSections;
pEditText->GetAllSections(aSections);
@@ -601,7 +604,7 @@ IMPL_LINK(ClassificationDialog, SelectClassificationHdl, weld::ComboBox&, rBox,
}
if (bReplaceExisting)
- m_xEditWindow->pEdView->SetSelection(aExistingFieldSelection);
+ m_xEditWindow->getEditView().SetSelection(aExistingFieldSelection);
insertCategoryField(nSelected);
@@ -637,7 +640,7 @@ IMPL_LINK(ClassificationDialog, SelectRecentlyUsedHdl, weld::ComboBox&, rBox, vo
sal_Int32 nSelected = rBox.get_active();
if (nSelected >= 0)
{
- m_xEditWindow->pEdEngine->Clear();
+ m_xEditWindow->getEditEngine().Clear();
readIn(m_aRecentlyUsedValuesCollection[nSelected]);
}
}
diff --git a/svx/source/dialog/ClassificationEditView.cxx b/svx/source/dialog/ClassificationEditView.cxx
index 2972f1b227d9..bc2266626c35 100644
--- a/svx/source/dialog/ClassificationEditView.cxx
+++ b/svx/source/dialog/ClassificationEditView.cxx
@@ -45,74 +45,30 @@ ClassificationEditView::ClassificationEditView()
{
}
-void ClassificationEditView::SetDrawingArea(weld::DrawingArea* pDrawingArea)
+void ClassificationEditView::makeEditEngine()
{
- Size aSize(500, 100);
- pDrawingArea->set_size_request(aSize.Width(), aSize.Height());
- SetOutputSizePixel(aSize);
-
- weld::CustomWidgetController::SetDrawingArea(pDrawingArea);
-
- EnableRTL(false);
-
- const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
- Color aBgColor = rStyleSettings.GetWindowColor();
-
- OutputDevice& rDevice = pDrawingArea->get_ref_device();
-
- rDevice.SetMapMode(MapMode(MapUnit::MapTwip));
- rDevice.SetBackground(aBgColor);
-
- Size aOutputSize(rDevice.PixelToLogic(aSize));
- aSize = aOutputSize;
- aSize.setHeight( aSize.Height() * 4 );
-
- pEdEngine.reset(new ClassificationEditEngine(EditEngine::CreatePool()));
- pEdEngine->SetPaperSize( aSize );
- pEdEngine->SetRefDevice( &rDevice );
-
- pEdEngine->SetControlWord(pEdEngine->GetControlWord() | EEControlBits::MARKFIELDS);
-
- pEdView.reset(new EditView(pEdEngine.get(), nullptr));
- pEdView->setEditViewCallbacks(this);
- pEdView->SetOutputArea(tools::Rectangle(Point(0,0), aOutputSize));
-
- pEdView->SetBackgroundColor(aBgColor);
- pEdEngine->InsertView(pEdView.get());
-
- pDrawingArea->set_cursor(PointerStyle::Text);
+ m_xEditEngine.reset(new ClassificationEditEngine(EditEngine::CreatePool()));
}
ClassificationEditView::~ClassificationEditView()
{
}
-void ClassificationEditView::Resize()
-{
- OutputDevice& rDevice = GetDrawingArea()->get_ref_device();
- Size aOutputSize(rDevice.PixelToLogic(GetOutputSizePixel()));
- Size aSize(aOutputSize);
- aSize.setHeight( aSize.Height() * 4 );
- pEdEngine->SetPaperSize(aSize);
- pEdView->SetOutputArea(tools::Rectangle(Point(0,0), aOutputSize));
- weld::CustomWidgetController::Resize();
-}
-
void ClassificationEditView::InsertField(const SvxFieldItem& rFieldItem)
{
- pEdView->InsertField(rFieldItem);
- pEdView->Invalidate();
+ m_xEditView->InsertField(rFieldItem);
+ m_xEditView->Invalidate();
}
void ClassificationEditView::InvertSelectionWeight()
{
- ESelection aSelection = pEdView->GetSelection();
+ ESelection aSelection = m_xEditView->GetSelection();
for (sal_Int32 nParagraph = aSelection.nStartPara; nParagraph <= aSelection.nEndPara; ++nParagraph)
{
FontWeight eFontWeight = WEIGHT_BOLD;
- std::unique_ptr<SfxItemSet> pSet(new SfxItemSet(pEdEngine->GetParaAttribs(nParagraph)));
+ std::unique_ptr<SfxItemSet> pSet(new SfxItemSet(m_xEditEngine->GetParaAttribs(nParagraph)));
if (const SfxPoolItem* pItem = pSet->GetItem(EE_CHAR_WEIGHT, false))
{
const SvxWeightItem* pWeightItem = dynamic_cast<const SvxWeightItem*>(pItem);
@@ -121,90 +77,10 @@ void ClassificationEditView::InvertSelectionWeight()
}
SvxWeightItem aWeight(eFontWeight, EE_CHAR_WEIGHT);
pSet->Put(aWeight);
- pEdEngine->SetParaAttribs(nParagraph, *pSet);
+ m_xEditEngine->SetParaAttribs(nParagraph, *pSet);
}
- pEdView->Invalidate();
-}
-
-void ClassificationEditView::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();
-
- pEdView->SetBackgroundColor(aBgColor);
-
- rRenderContext.SetBackground(aBgColor);
-
- tools::Rectangle aLogicRect(rRenderContext.PixelToLogic(rRect));
- pEdView->Paint(aLogicRect, &rRenderContext);
-
- if (HasFocus())
- {
- pEdView->ShowCursor();
- vcl::Cursor* pCursor = pEdView->GetCursor();
- pCursor->DrawToDevice(rRenderContext);
- }
-
- std::vector<tools::Rectangle> aLogicRects;
-
- // get logic selection
- pEdView->GetSelectionRectangles(aLogicRects);
-
- rRenderContext.SetLineColor();
- rRenderContext.SetFillColor(COL_BLACK);
- rRenderContext.SetRasterOp(RasterOp::Invert);
-
- for (const auto &rSelectionRect : aLogicRects)
- rRenderContext.DrawRect(rSelectionRect);
-
- rRenderContext.Pop();
-}
-
-bool ClassificationEditView::MouseMove(const MouseEvent& rMEvt)
-{
- return pEdView->MouseMove(rMEvt);
-}
-
-bool ClassificationEditView::MouseButtonDown(const MouseEvent& rMEvt)
-{
- if (!HasFocus())
- GrabFocus();
-
- return pEdView->MouseButtonDown(rMEvt);
-}
-
-bool ClassificationEditView::MouseButtonUp(const MouseEvent& rMEvt)
-{
- return pEdView->MouseButtonUp(rMEvt);
-}
-
-bool ClassificationEditView::KeyInput(const KeyEvent& rKEvt)
-{
- sal_uInt16 nKey = rKEvt.GetKeyCode().GetModifier() + rKEvt.GetKeyCode().GetCode();
-
- if (nKey == KEY_TAB || nKey == KEY_TAB + KEY_SHIFT)
- {
- return false;
- }
- else if (!pEdView->PostKeyEvent(rKEvt))
- {
- return false;
- }
-
- return true;
-}
-
-void ClassificationEditView::GetFocus()
-{
- pEdView->ShowCursor();
-
- weld::CustomWidgetController::GetFocus();
+ m_xEditView->Invalidate();
}
} // end sfx2
More information about the Libreoffice-commits
mailing list