LibreOffice Module svx (master)  1
weldeditview.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  */
10 
11 #ifndef INCLUDED_SVX_WELDEDITVIEW_HXX
12 #define INCLUDED_SVX_WELDEDITVIEW_HXX
13 
14 #include <sal/config.h>
15 #include <svx/svxdllapi.h>
16 #include <editeng/editeng.hxx>
17 #include <editeng/editview.hxx>
18 #include <vcl/customweld.hxx>
19 #include <vcl/outdev.hxx>
20 
21 class WeldEditAccessible;
22 
23 class SVX_DLLPUBLIC WeldEditView : public weld::CustomWidgetController, public EditViewCallbacks
24 {
25 public:
26  WeldEditView();
27  virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
28  virtual int GetSurroundingText(OUString& rSurrounding) override;
29  virtual bool DeleteSurroundingText(const Selection& rRange) override;
30 
31  void SetText(const OUString& rStr) { m_xEditEngine->SetText(rStr); }
32 
33  OUString GetText() const { return m_xEditEngine->GetText(); }
34 
35  virtual FactoryFunction GetUITestFactory() const override;
36 
38  {
39  m_xEditEngine->SetModifyHdl(rLink);
40  }
41 
42  EditEngine& GetEditEngine() { return *m_xEditEngine; }
43 
44  bool HasSelection() const { return m_xEditView && m_xEditView->HasSelection(); }
45 
46  void Cut()
47  {
48  if (m_xEditView)
49  m_xEditView->Cut();
50  }
51  void Copy()
52  {
53  if (m_xEditView)
54  m_xEditView->Copy();
55  }
56  void Paste()
57  {
58  if (m_xEditView)
59  m_xEditView->Paste();
60  }
61 
62  virtual ~WeldEditView() override;
63 
64 protected:
65  std::unique_ptr<EditEngine> m_xEditEngine;
66  std::unique_ptr<EditView> m_xEditView;
68 
69  virtual void makeEditEngine();
70 
71  virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
72  virtual bool MouseMove(const MouseEvent& rMEvt) override;
73  virtual bool MouseButtonDown(const MouseEvent& rMEvt) override;
74  virtual bool MouseButtonUp(const MouseEvent& rMEvt) override;
75  virtual bool KeyInput(const KeyEvent& rKEvt) override;
76  virtual bool Command(const CommandEvent& rCEvt) override;
77  virtual void GetFocus() override;
78  virtual void LoseFocus() override;
79  virtual void Resize() override;
80 
81  virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override;
82 
83  virtual void EditViewInvalidate(const tools::Rectangle& rRect) override { Invalidate(rRect); }
84 
85  virtual void EditViewSelectionChange() override { Invalidate(); }
86 
87  virtual OutputDevice& EditViewOutputDevice() const override
88  {
89  return GetDrawingArea()->get_ref_device();
90  }
91 
92  virtual void EditViewInputContext(const InputContext& rInputContext) override
93  {
94  SetInputContext(rInputContext);
95  }
96 
97  virtual void EditViewCursorRect(const tools::Rectangle& rRect, int nExtTextInputWidth) override
98  {
99  OutputDevice& rRefDevice = EditViewOutputDevice();
100  SetCursorRect(rRefDevice.LogicToPixel(rRect),
101  rRefDevice.LogicToPixel(Size(nExtTextInputWidth, 0)).Width());
102  }
103 };
104 
105 #endif // INCLUDED_SVX_WELDEDITVIEW_HXX
106 
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString GetText() const
virtual FactoryFunction GetUITestFactory() const
virtual void EditViewSelectionChange() override
virtual bool MouseButtonUp(const MouseEvent &)
std::function< std::unique_ptr< UIObject >vcl::Window *)> FactoryFunction
virtual bool MouseMove(const MouseEvent &)
#define SVX_DLLPUBLIC
Definition: svxdllapi.h:28
void SetText(const OUString &rStr)
void SetModifyHdl(const Link< LinkParamNone *, void > &rLink)
virtual OutputDevice & get_ref_device()=0
void SetCursorRect(const tools::Rectangle &rCursorRect, int nExtTextInputWidth)
virtual void EditViewCursorRect(const tools::Rectangle &rRect, int nExtTextInputWidth) override
virtual bool DeleteSurroundingText(const Selection &)
void SetInputContext(const InputContext &rInputContext)
std::unique_ptr< EditView > m_xEditView
virtual bool KeyInput(const KeyEvent &)
virtual void EditViewInvalidate(const tools::Rectangle &rRect) override
Point LogicToPixel(const Point &rLogicPt) const
virtual void EditViewInputContext(const InputContext &rInputContext) override
weld::DrawingArea * GetDrawingArea() const
virtual int GetSurroundingText(OUString &)
virtual bool MouseButtonDown(const MouseEvent &)
EditEngine & GetEditEngine()
rtl::Reference< WeldEditAccessible > m_xAccessible
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea)
std::unique_ptr< EditEngine > m_xEditEngine
virtual OutputDevice & EditViewOutputDevice() const override
virtual bool Command(const CommandEvent &)
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)=0
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible()
bool HasSelection() const