LibreOffice Module sw (master)  1
edtwin.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  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 #ifndef INCLUDED_SW_SOURCE_UIBASE_INC_EDTWIN_HXX
20 #define INCLUDED_SW_SOURCE_UIBASE_INC_EDTWIN_HXX
21 
22 #include <o3tl/deleter.hxx>
23 #include <sot/exchange.hxx>
24 #include <svx/svdobj.hxx>
25 #include <tools/link.hxx>
26 #include <vcl/timer.hxx>
27 #include <vcl/window.hxx>
28 #include <vcl/transfer.hxx>
29 #include <swevent.hxx>
30 #include <swtypes.hxx>
31 
32 class SwWrtShell;
33 class SwView;
34 class SwRect;
35 class SwViewShell;
36 class SwAnchorMarker;
37 class SdrObject;
38 class SwShadowCursor;
39 class DataChangedEvent;
40 class SvxAutoCorrCfg;
41 class SvxAutoCorrect;
42 class SwPaM;
43 struct SwApplyTemplate;
44 struct QuickHelpData;
47 enum class SdrHitKind;
48 class SwTextFrame;
49 
50 // input window
51 
59 class SW_DLLPUBLIC SwEditWin final : public vcl::Window,
60  public DropTargetHelper, public DragSourceHelper
61 {
63 
66 
67  Color m_aWaterCanTextColor; // text color; for the watering can
68  Color m_aWaterCanTextBackColor; // text background; for the watering can
69 
70  /*
71  * timer and handler for scrolling on when the mousepointer
72  * stops outside of EditWin during a drag-operation.
73  * The selection is increased towards the mouse position
74  * regularly.
75  */
77  // timer for ANY-KeyInput question without a following KeyInputEvent
79 
80  OUString m_aInBuffer;
86 
87  // type/object where the mouse pointer is
89 
90  std::unique_ptr<SwApplyTemplate> m_pApplyTempl;
91  std::unique_ptr<SwAnchorMarker> m_pAnchorMarker; // for relocating the anchor
92 
93  std::unique_ptr<SdrDropMarkerOverlay> m_pUserMarker;
95  std::unique_ptr<SwShadowCursor, o3tl::default_delete<SwShadowCursor>> m_pShadCursor;
96  std::optional<Point> m_xRowColumnSelectionStart; // save position where table row/column selection has been started
97 
99 
100  SdrHitKind m_aActHitType; // current mouse pointer
101 
102  SotClipboardFormatId m_nDropFormat; // format from the last QueryDrop
103  sal_uInt8 m_nDropAction; // action from the last QueryDrop
104  SotExchangeDest m_nDropDestination; // destination from the last QueryDrop
105 
106  sal_uInt16 m_eBezierMode;
107  sal_uInt16 m_nInsFrameColCount; // column number for interactive frame
109  bool m_bMBPressed : 1,
110  m_bInsDraw : 1,
111  m_bInsFrame : 1,
112  m_bIsInMove : 1,
113  m_bIsInDrag : 1, // don't execute StartExecuteDrag twice
114  m_bOldIdle : 1, // to stop to idle
115  m_bOldIdleSet : 1, // during QeueryDrop
116  m_bChainMode : 1, // connect frames
117  m_bWasShdwCursor : 1, // ShadowCursor was on in MouseButtonDown
118  m_bLockInput : 1, // lock while calc panel is active
119  m_bIsRowDrag : 1, //selection of rows is used, in combination with m_pRowColumnSelectionStart
123  m_bUseInputLanguage: 1,
124  m_bObjectSelect : 1;
125 
126  sal_uInt16 m_nKS_NUMDOWN_Count; // #i23725#
128 
129  std::unique_ptr<SwFrameControlsManager> m_pFrameControlsManager;
130 
131  SwTextFrame* m_pSavedOutlineFrame = nullptr;
132 
133  void LeaveArea(const Point &);
134  void JustifyAreaTimer();
135  inline void EnterArea();
136 
137  void RstMBDownFlags();
138 
139  void ChangeFly( sal_uInt8 nDir, bool bWeb );
140  void ChangeDrawing( sal_uInt8 nDir );
141 
142  bool EnterDrawMode(const MouseEvent& rMEvt, const Point& aDocPos);
143  bool RulerColumnDrag( const MouseEvent& rMEvt, bool bVerticalMode);
144 
145  // helper function for D&D
146  void DropCleanup();
147  void CleanupDropUserMarker();
148  SotExchangeDest GetDropDestination( const Point& rPixPnt,
149  SdrObject ** ppObj = nullptr );
150  //select the object/cursor at the mouse position of the context menu request
151  void SelectMenuPosition(SwWrtShell& rSh, const Point& rMousePos );
152 
153  /*
154  * handler for scrolling on when the mousepointer
155  * stops outside of EditWin during a drag-operation.
156  * The selection is regularly increased towards the mouse
157  * position.
158  */
159  DECL_DLLPRIVATE_LINK( TimerHandler, Timer *, void );
160  void StartDDTimer();
161  void StopDDTimer(SwWrtShell *, const Point &);
162  DECL_DLLPRIVATE_LINK( DDHandler, Timer *, void );
163 
164  // timer for ANY-KeyInut question without a following KeyInputEvent
165  DECL_DLLPRIVATE_LINK( KeyInputFlushHandler, Timer *, void );
166 
167  // timer for ApplyTemplates via mouse (in disguise Drag&Drop)
168  DECL_DLLPRIVATE_LINK( TemplateTimerHdl, Timer *, void );
169 
170  void MoveCursor( SwWrtShell &rSh, const Point& rDocPos,
171  const bool bOnlyText, bool bLockView );
172 
173  virtual void DataChanged( const DataChangedEvent& ) override;
174  virtual void PrePaint(vcl::RenderContext& rRenderContext) override;
175  virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
176 
177  virtual void GetFocus() override;
178  virtual void LoseFocus() override;
179 
180  bool changeMousePointer(Point const & rDocPoint);
181 
182  virtual void MouseMove(const MouseEvent& rMEvt) override;
183  virtual void MouseButtonDown(const MouseEvent& rMEvt) override;
184  virtual void MouseButtonUp(const MouseEvent& rMEvt) override;
185  virtual void RequestHelp(const HelpEvent& rEvt) override;
186 
187  // Drag & Drop Interface
188  virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override;
189  virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override;
190  virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ) override;
191 
192  virtual OUString GetSurroundingText() const override;
193  virtual Selection GetSurroundingTextSelection() const override;
194  virtual bool DeleteSurroundingText(const Selection& rSelection) override;
195 
196  void ShowAutoCorrectQuickHelp(const OUString& rWord, SvxAutoCorrect& rACorr);
197  bool ShowAutoText(const std::vector<OUString>& rChunkCandidates);
198 
200  bool IsInHeaderFooter( const Point &rDocPt, FrameControlType &rControl ) const;
201 
202  bool IsOverHeaderFooterFly( const Point& rDocPos, FrameControlType& rControl, bool& bOverFly, bool& bPageAnchored ) const;
203 
204 public:
205  virtual void KeyInput(const KeyEvent &rKEvt) override;
206  void UpdatePointer(const Point &, sal_uInt16 nButtons = 0);
207 
208  bool IsDrawSelMode() const;
209  bool IsDrawAction() const { return m_bInsDraw; }
210  void SetDrawAction(bool bFlag) { m_bInsDraw = bFlag; }
211 
212  void SetObjectSelect( bool bVal ) { m_bObjectSelect = bVal; }
213  bool IsObjectSelect() const { return m_bObjectSelect; }
214 
215  SdrObjKind GetSdrDrawMode() const { return m_eDrawMode; }
216  void SetSdrDrawMode( SdrObjKind eSdrObjectKind ) { m_eDrawMode = eSdrObjectKind; SetObjectSelect( false ); }
217  void StdDrawMode( SdrObjKind eSdrObjectKind, bool bObjSelect );
218 
219  bool IsFrameAction() const { return m_bInsFrame; }
220  sal_uInt16 GetBezierMode() const { return m_eBezierMode; }
221  void SetBezierMode(sal_uInt16 eBezMode) { m_eBezierMode = eBezMode; }
222  void EnterDrawTextMode(const Point& aDocPos); // turn on DrawTextEditMode
223  void InsFrame(sal_uInt16 nCols);
224  void StopInsFrame();
225  sal_uInt16 GetFrameColCount() const {return m_nInsFrameColCount;} // column number for interactive frame
226 
227  void SetChainMode( bool bOn );
228  bool IsChainMode() const { return m_bChainMode; }
229 
230  void FlushInBuffer();
231  static bool IsInputSequenceCheckingRequired( const OUString &rText, const SwPaM& rCursor );
232 
233  void SetApplyTemplate(const SwApplyTemplate &);
234  SwApplyTemplate* GetApplyTemplate() const { return m_pApplyTempl.get(); }
235 
236  void StartExecuteDrag();
237  void DragFinished();
238 
239  void SetWaterCanTextColor(const Color& rCol ) { m_aWaterCanTextColor = rCol; }
240 
241  void SetWaterCanTextBackColor(const Color& rCol ) { m_aWaterCanTextBackColor = rCol; }
242 
243  void LockKeyInput(bool bSet){m_bLockInput = bSet;}
244 
245  const SwView &GetView() const { return m_rView; }
246  SwView &GetView() { return m_rView; }
247 
248  virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override;
249 
250  static tools::Long GetDDStartPosX() { return s_nDDStartPosX; }
251  static tools::Long GetDDStartPosY() { return s_nDDStartPosY; }
252 
253  static void InitStaticData();
254  static void FinitStaticData();
255 
256  //#i3370# remove quick help to prevent saving of autocorrection suggestions
257  void StopQuickHelp();
258 
259  // #i42921# - add parameter <bVerticalMode>
260  bool RulerMarginDrag( const MouseEvent& rMEvt,
261  const bool bVerticalMode );
262 
266  void SetUseInputLanguage( bool bNew );
267  bool IsUseInputLanguage() const { return m_bUseInputLanguage; }
268 
272  OUString ClipLongToolTip(const OUString& rText);
273 
274  SwFrameControlsManager& GetFrameControlsManager();
275 
276  SwEditWin(vcl::Window *pParent, SwView &);
277  virtual ~SwEditWin() override;
278  virtual void dispose() override;
279 
280  virtual void Command( const CommandEvent& rCEvt ) override;
281 
283  void LogicInvalidate(const tools::Rectangle* pRectangle) override;
285  virtual void LogicMouseButtonDown(const MouseEvent& rMouseEvent) override;
287  virtual void LogicMouseButtonUp(const MouseEvent& rMouseEvent) override;
289  virtual void LogicMouseMove(const MouseEvent& rMouseEvent) override;
291  void SetCursorTwipPosition(const Point& rPosition, bool bPoint, bool bClearMark);
293  void SetGraphicTwipPosition(bool bStart, const Point& rPosition);
294 
295  const SwTextFrame* GetSavedOutlineFrame() const { return m_pSavedOutlineFrame; }
296  void SetSavedOutlineFrame(SwTextFrame* pFrame) { m_pSavedOutlineFrame = pFrame; }
297  void ToggleOutlineContentVisibility(const size_t nOutlinePos, const bool bSubs);
298 
299  virtual FactoryFunction GetUITestFactory() const override;
300 };
301 
302 extern bool g_bFrameDrag;
303 extern bool g_bDDTimerStarted;
304 extern bool g_bDDINetAttr;
305 
306 #endif
307 
308 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:162
static tools::Long s_nDDStartPosY
Definition: edtwin.hxx:65
static tools::Long GetDDStartPosX()
Definition: edtwin.hxx:250
virtual FactoryFunction GetUITestFactory() const
Color m_aWaterCanTextColor
Definition: edtwin.hxx:67
void SetWaterCanTextBackColor(const Color &rCol)
Definition: edtwin.hxx:241
std::unique_ptr< SwFrameControlsManager > m_pFrameControlsManager
Definition: edtwin.hxx:129
DECL_DLLPRIVATE_LINK(ImplHandlePaintHdl, Timer *, void)
virtual void MouseButtonDown(const MouseEvent &rMEvt)
signed char sal_Int8
const SwView & GetView() const
Definition: edtwin.hxx:245
long Long
AutoTimer m_aTimer
Definition: edtwin.hxx:76
bool g_bDDTimerStarted
Definition: edtwin.cxx:173
void SetWaterCanTextColor(const Color &rCol)
Definition: edtwin.hxx:239
SdrObjKind m_eDrawMode
Definition: edtwin.hxx:108
std::function< std::unique_ptr< UIObject >vcl::Window *)> FactoryFunction
SdrObject * m_pUserMarkerObj
Definition: edtwin.hxx:94
virtual void StartDrag(sal_Int8 nAction, const Point &rPosPixel)
std::optional< Point > m_xRowColumnSelectionStart
Definition: edtwin.hxx:96
SotExchangeDest
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
virtual void MouseButtonUp(const MouseEvent &rMEvt)
Point m_aMovePos
Definition: edtwin.hxx:83
sal_uInt16 GetBezierMode() const
Definition: edtwin.hxx:220
std::unique_ptr< SdrDropMarkerOverlay > m_pUserMarker
Definition: edtwin.hxx:93
SdrObjKind
Used by the UI to modify the document model.
Definition: wrtsh.hxx:96
std::unique_ptr< SwAnchorMarker > m_pAnchorMarker
Definition: edtwin.hxx:91
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible()
sal_uInt8 m_nDropAction
Definition: edtwin.hxx:103
static tools::Long GetDDStartPosY()
Definition: edtwin.hxx:251
void SetSdrDrawMode(SdrObjKind eSdrObjectKind)
Definition: edtwin.hxx:216
SotClipboardFormatId
Timer m_aKeyInputFlushTimer
Definition: edtwin.hxx:78
Assists with auto-completion of AutoComplete words and AutoText names.
Definition: edtwin.cxx:253
static QuickHelpData * s_pQuickHlpData
Definition: edtwin.hxx:62
virtual Selection GetSurroundingTextSelection() const
bool g_bFrameDrag
Definition: edtwin.cxx:170
std::unique_ptr< SwApplyTemplate > m_pApplyTempl
Definition: edtwin.hxx:90
void LockKeyInput(bool bSet)
Definition: edtwin.hxx:243
sal_uInt16 GetFrameColCount() const
Definition: edtwin.hxx:225
virtual sal_Int8 ExecuteDrop(const ExecuteDropEvent &rEvt)
SdrHitKind
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:137
virtual void PrePaint(vcl::RenderContext &rRenderContext)
SotClipboardFormatId m_nDropFormat
Definition: edtwin.hxx:102
virtual bool DeleteSurroundingText(const Selection &rSelection)
SwApplyTemplate * GetApplyTemplate() const
Definition: edtwin.hxx:234
Point m_aStartPos
Definition: edtwin.hxx:82
virtual OUString GetSurroundingText() const
virtual sal_Int8 AcceptDrop(const AcceptDropEvent &rEvt)
bool IsFrameAction() const
Definition: edtwin.hxx:219
std::unique_ptr< SwShadowCursor, o3tl::default_delete< SwShadowCursor > > m_pShadCursor
Definition: edtwin.hxx:95
Window class for the Writer edit area, this is the one handling mouse and keyboard events and doing t...
Definition: edtwin.hxx:59
Timer m_aTemplateTimer
Definition: edtwin.hxx:85
sal_uInt16 m_nInsFrameColCount
Definition: edtwin.hxx:107
SwCallMouseEvent m_aSaveCallEvent
Definition: edtwin.hxx:88
SotExchangeDest m_nDropDestination
Definition: edtwin.hxx:104
sal_uInt16 m_eBezierMode
Definition: edtwin.hxx:106
SwView & GetView()
Definition: edtwin.hxx:246
const SwTextFrame * GetSavedOutlineFrame() const
Definition: edtwin.hxx:295
bool IsUseInputLanguage() const
Definition: edtwin.hxx:267
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
virtual void LoseFocus()
SdrObjKind GetSdrDrawMode() const
Definition: edtwin.hxx:215
virtual void KeyInput(const KeyEvent &rKEvt)
void SetObjectSelect(bool bVal)
Definition: edtwin.hxx:212
SdrHitKind m_aActHitType
Definition: edtwin.hxx:100
FrameControlType
Definition: swtypes.hxx:233
virtual void LogicMouseButtonUp(const MouseEvent &)
bool IsObjectSelect() const
Definition: edtwin.hxx:213
sal_uInt16 m_nKS_NUMDOWN_Count
Definition: edtwin.hxx:126
virtual void GetFocus()
unsigned char sal_uInt8
Color m_aWaterCanTextBackColor
Definition: edtwin.hxx:68
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)
Point m_aRszMvHdlPt
Definition: edtwin.hxx:84
SwView & m_rView
Definition: edtwin.hxx:98
bool g_bDDINetAttr
Definition: edtwin.cxx:174
virtual void LogicMouseButtonDown(const MouseEvent &)
void SetDrawAction(bool bFlag)
Definition: edtwin.hxx:210
virtual void MouseMove(const MouseEvent &rMEvt)
void SetBezierMode(sal_uInt16 eBezMode)
Definition: edtwin.hxx:221
LanguageType m_eBufferLanguage
Definition: edtwin.hxx:81
virtual void LogicInvalidate(const tools::Rectangle *pRectangle)
A container for the Header/Footer, PageBreak, and Outline Content Visibility controls.
virtual void LogicMouseMove(const MouseEvent &)
bool IsDrawAction() const
Definition: edtwin.hxx:209
virtual void Command(const CommandEvent &rCEvt)
OUString m_aInBuffer
Definition: edtwin.hxx:80
void SetSavedOutlineFrame(SwTextFrame *pFrame)
Definition: edtwin.hxx:296
virtual void RequestHelp(const HelpEvent &rHEvt)
static tools::Long s_nDDStartPosX
Definition: edtwin.hxx:64
sal_uInt16 m_nKS_NUMINDENTINC_Count
Definition: edtwin.hxx:127
Definition: view.hxx:144
virtual void DataChanged(const DataChangedEvent &rDCEvt)
bool IsChainMode() const
Definition: edtwin.hxx:228