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/idle.hxx>
28 #include <vcl/window.hxx>
29 #include <vcl/transfer.hxx>
30 #include <swevent.hxx>
31 #include <swtypes.hxx>
32 
33 class SwWrtShell;
34 class SwView;
35 class SwRect;
36 class SwViewShell;
37 class SwAnchorMarker;
38 class SdrObject;
39 class SwShadowCursor;
40 class DataChangedEvent;
41 class SvxAutoCorrCfg;
42 class SvxAutoCorrect;
43 class SwPaM;
44 struct SwApplyTemplate;
45 struct QuickHelpData;
48 enum class SdrHitKind;
49 
50 // input window
51 
59 class SW_DLLPUBLIC SwEditWin final : public vcl::Window,
60  public DropTargetHelper, public DragSourceHelper
61 {
63 
64  static long m_nDDStartPosX;
65  static long m_nDDStartPosY;
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  boost::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  void LeaveArea(const Point &);
132  void JustifyAreaTimer();
133  inline void EnterArea();
134 
135  void RstMBDownFlags();
136 
137  void ChangeFly( sal_uInt8 nDir, bool bWeb );
138  void ChangeDrawing( sal_uInt8 nDir );
139 
140  bool EnterDrawMode(const MouseEvent& rMEvt, const Point& aDocPos);
141  bool RulerColumnDrag( const MouseEvent& rMEvt, bool bVerticalMode);
142 
143  // helper function for D&D
144  void DropCleanup();
145  void CleanupDropUserMarker();
146  SotExchangeDest GetDropDestination( const Point& rPixPnt,
147  SdrObject ** ppObj = nullptr );
148  //select the object/cursor at the mouse position of the context menu request
149  void SelectMenuPosition(SwWrtShell& rSh, const Point& rMousePos );
150 
151  /*
152  * handler for scrolling on when the mousepointer
153  * stops outside of EditWin during a drag-operation.
154  * The selection is regularly increased towards the mouse
155  * position.
156  */
157  DECL_LINK( TimerHandler, Timer *, void );
158  void StartDDTimer();
159  void StopDDTimer(SwWrtShell *, const Point &);
160  DECL_LINK( DDHandler, Timer *, void );
161 
162  // timer for ANY-KeyInut question without a following KeyInputEvent
163  DECL_LINK( KeyInputFlushHandler, Timer *, void );
164 
165  // timer for ApplyTemplates via mouse (in disguise Drag&Drop)
166  DECL_LINK( TemplateTimerHdl, Timer *, void );
167 
168  void MoveCursor( SwWrtShell &rSh, const Point& rDocPos,
169  const bool bOnlyText, bool bLockView );
170 
171  virtual void DataChanged( const DataChangedEvent& ) override;
172  virtual void PrePaint(vcl::RenderContext& rRenderContext) override;
173  virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
174 
175  virtual void GetFocus() override;
176  virtual void LoseFocus() override;
177 
178  virtual void MouseMove(const MouseEvent& rMEvt) override;
179  virtual void MouseButtonDown(const MouseEvent& rMEvt) override;
180  virtual void MouseButtonUp(const MouseEvent& rMEvt) override;
181  virtual void RequestHelp(const HelpEvent& rEvt) override;
182 
183  // Drag & Drop Interface
184  virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override;
185  virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override;
186  virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ) override;
187 
188  virtual OUString GetSurroundingText() const override;
189  virtual Selection GetSurroundingTextSelection() const override;
190 
191  void ShowAutoTextCorrectQuickHelp( const OUString& rWord, SvxAutoCorrCfg const * pACfg,
192  SvxAutoCorrect* pACorr, bool bFromIME = false );
193 
195  bool IsInHeaderFooter( const Point &rDocPt, FrameControlType &rControl ) const;
196 
197  bool IsOverHeaderFooterFly( const Point& rDocPos, FrameControlType& rControl, bool& bOverFly, bool& bPageAnchored ) const;
198 
199 public:
200  virtual void KeyInput(const KeyEvent &rKEvt) override;
201  void UpdatePointer(const Point &, sal_uInt16 nButtons = 0);
202 
203  bool IsDrawSelMode();
204  bool IsDrawAction() { return m_bInsDraw; }
205  void SetDrawAction(bool bFlag) { m_bInsDraw = bFlag; }
206 
207  void SetObjectSelect( bool bVal ) { m_bObjectSelect = bVal; }
208  bool IsObjectSelect() const { return m_bObjectSelect; }
209 
210  SdrObjKind GetSdrDrawMode() const { return m_eDrawMode; }
211  void SetSdrDrawMode( SdrObjKind eSdrObjectKind ) { m_eDrawMode = eSdrObjectKind; SetObjectSelect( false ); }
212  void StdDrawMode( SdrObjKind eSdrObjectKind, bool bObjSelect );
213 
214  bool IsFrameAction() const { return m_bInsFrame; }
215  sal_uInt16 GetBezierMode() const { return m_eBezierMode; }
216  void SetBezierMode(sal_uInt16 eBezMode) { m_eBezierMode = eBezMode; }
217  void EnterDrawTextMode(const Point& aDocPos); // turn on DrawTextEditMode
218  void InsFrame(sal_uInt16 nCols);
219  void StopInsFrame();
220  sal_uInt16 GetFrameColCount() const {return m_nInsFrameColCount;} // column number for interactive frame
221 
222  void SetChainMode( bool bOn );
223  bool IsChainMode() const { return m_bChainMode; }
224 
225  void FlushInBuffer();
226  static bool IsInputSequenceCheckingRequired( const OUString &rText, const SwPaM& rCursor );
227 
228  void SetApplyTemplate(const SwApplyTemplate &);
229  SwApplyTemplate* GetApplyTemplate() const { return m_pApplyTempl.get(); }
230 
231  void StartExecuteDrag();
232  void DragFinished();
233 
234  void SetWaterCanTextColor(const Color& rCol ) { m_aWaterCanTextColor = rCol; }
235 
236  void SetWaterCanTextBackColor(const Color& rCol ) { m_aWaterCanTextBackColor = rCol; }
237 
238  void LockKeyInput(bool bSet){m_bLockInput = bSet;}
239 
240  const SwView &GetView() const { return m_rView; }
241  SwView &GetView() { return m_rView; }
242 
243  virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override;
244 
245  static long GetDDStartPosX() { return m_nDDStartPosX; }
246  static long GetDDStartPosY() { return m_nDDStartPosY; }
247 
248  static void InitStaticData();
249  static void FinitStaticData();
250 
251  //#i3370# remove quick help to prevent saving of autocorrection suggestions
252  void StopQuickHelp();
253 
254  // #i42921# - add parameter <bVerticalMode>
255  bool RulerMarginDrag( const MouseEvent& rMEvt,
256  const bool bVerticalMode );
257 
261  void SetUseInputLanguage( bool bNew );
262  bool IsUseInputLanguage() const { return m_bUseInputLanguage; }
263 
267  OUString ClipLongToolTip(const OUString& rText);
268 
269  SwFrameControlsManager& GetFrameControlsManager();
270 
271  SwEditWin(vcl::Window *pParent, SwView &);
272  virtual ~SwEditWin() override;
273  virtual void dispose() override;
274 
275  virtual void Command( const CommandEvent& rCEvt ) override;
276 
278  void LogicInvalidate(const tools::Rectangle* pRectangle) override;
280  virtual void LogicMouseButtonDown(const MouseEvent& rMouseEvent) override;
282  virtual void LogicMouseButtonUp(const MouseEvent& rMouseEvent) override;
284  virtual void LogicMouseMove(const MouseEvent& rMouseEvent) override;
286  void SetCursorTwipPosition(const Point& rPosition, bool bPoint, bool bClearMark);
288  void SetGraphicTwipPosition(bool bStart, const Point& rPosition);
289 
290  virtual FactoryFunction GetUITestFactory() const override;
291 };
292 
293 extern bool g_bFrameDrag;
294 extern bool g_bDDTimerStarted;
295 extern bool g_bFlushCharBuffer;
296 extern bool g_bDDINetAttr;
297 
298 #endif
299 
300 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
boost::optional< Point > m_xRowColumnSelectionStart
Definition: edtwin.hxx:96
virtual FactoryFunction GetUITestFactory() const
Color m_aWaterCanTextColor
Definition: edtwin.hxx:67
void SetWaterCanTextBackColor(const Color &rCol)
Definition: edtwin.hxx:236
std::unique_ptr< SwFrameControlsManager > m_pFrameControlsManager
Definition: edtwin.hxx:129
virtual void MouseButtonDown(const MouseEvent &rMEvt)
signed char sal_Int8
const SwView & GetView() const
Definition: edtwin.hxx:240
AutoTimer m_aTimer
Definition: edtwin.hxx:76
bool g_bDDTimerStarted
Definition: edtwin.cxx:184
void SetWaterCanTextColor(const Color &rCol)
Definition: edtwin.hxx:234
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)
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
static long m_nDDStartPosY
Definition: edtwin.hxx:65
sal_uInt16 GetBezierMode() const
Definition: edtwin.hxx:215
std::unique_ptr< SdrDropMarkerOverlay > m_pUserMarker
Definition: edtwin.hxx:93
Used by the UI to modify the document model.
Definition: wrtsh.hxx:86
static long m_nDDStartPosX
Definition: edtwin.hxx:64
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
bool g_bFlushCharBuffer
Definition: edtwin.cxx:185
void SetSdrDrawMode(SdrObjKind eSdrObjectKind)
Definition: edtwin.hxx:211
SotClipboardFormatId
Timer m_aKeyInputFlushTimer
Definition: edtwin.hxx:78
Assists with auto-completion of AutoComplete words and AutoText names.
Definition: edtwin.cxx:265
virtual Selection GetSurroundingTextSelection() const
bool g_bFrameDrag
Definition: edtwin.cxx:181
std::unique_ptr< SwApplyTemplate > m_pApplyTempl
Definition: edtwin.hxx:90
static long GetDDStartPosX()
Definition: edtwin.hxx:245
void LockKeyInput(bool bSet)
Definition: edtwin.hxx:238
sal_uInt16 GetFrameColCount() const
Definition: edtwin.hxx:220
virtual sal_Int8 ExecuteDrop(const ExecuteDropEvent &rEvt)
SdrHitKind
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
virtual void PrePaint(vcl::RenderContext &rRenderContext)
SotClipboardFormatId m_nDropFormat
Definition: edtwin.hxx:102
SwApplyTemplate * GetApplyTemplate() const
Definition: edtwin.hxx:229
Point m_aStartPos
Definition: edtwin.hxx:82
virtual OUString GetSurroundingText() const
virtual sal_Int8 AcceptDrop(const AcceptDropEvent &rEvt)
bool IsFrameAction() const
Definition: edtwin.hxx:214
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:241
static long GetDDStartPosY()
Definition: edtwin.hxx:246
bool IsUseInputLanguage() const
Definition: edtwin.hxx:262
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
virtual void LoseFocus()
SdrObjKind GetSdrDrawMode() const
Definition: edtwin.hxx:210
virtual void KeyInput(const KeyEvent &rKEvt)
void SetObjectSelect(bool bVal)
Definition: edtwin.hxx:207
SdrHitKind m_aActHitType
Definition: edtwin.hxx:100
FrameControlType
Definition: swtypes.hxx:246
virtual void LogicMouseButtonUp(const MouseEvent &)
SdrObjKind
bool IsObjectSelect() const
Definition: edtwin.hxx:208
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:186
virtual void LogicMouseButtonDown(const MouseEvent &)
void SetDrawAction(bool bFlag)
Definition: edtwin.hxx:205
virtual void MouseMove(const MouseEvent &rMEvt)
void SetBezierMode(sal_uInt16 eBezMode)
Definition: edtwin.hxx:216
bool IsDrawAction()
Definition: edtwin.hxx:204
LanguageType m_eBufferLanguage
Definition: edtwin.hxx:81
virtual void LogicInvalidate(const tools::Rectangle *pRectangle)
A container for the Header/Footer, or PageBreak controls.
virtual void LogicMouseMove(const MouseEvent &)
virtual void Command(const CommandEvent &rCEvt)
OUString m_aInBuffer
Definition: edtwin.hxx:80
virtual void RequestHelp(const HelpEvent &rHEvt)
sal_uInt16 m_nKS_NUMINDENTINC_Count
Definition: edtwin.hxx:127
Definition: view.hxx:146
virtual void DataChanged(const DataChangedEvent &rDCEvt)
static QuickHelpData * m_pQuickHlpData
Definition: edtwin.hxx:62
bool IsChainMode() const
Definition: edtwin.hxx:223