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 
49 // input window
50 
58 class SW_DLLPUBLIC SwEditWin final : public vcl::Window,
59  public DropTargetHelper, public DragSourceHelper
60 {
62 
63  static long m_nDDStartPosX;
64  static long m_nDDStartPosY;
65 
66  Color m_aWaterCanTextColor; // text color; for the watering can
67  Color m_aWaterCanTextBackColor; // text background; for the watering can
68 
69  /*
70  * timer and handler for scrolling on when the mousepointer
71  * stops outside of EditWin during a drag-operation.
72  * The selection is increased towards the mouse position
73  * regularly.
74  */
76  // timer for ANY-KeyInput question without a following KeyInputEvent
78 
79  OUString m_aInBuffer;
85 
86  // type/object where the mouse pointer is
88 
89  std::unique_ptr<SwApplyTemplate> m_pApplyTempl;
90  std::unique_ptr<SwAnchorMarker> m_pAnchorMarker; // for relocating the anchor
91 
92  std::unique_ptr<SdrDropMarkerOverlay> m_pUserMarker;
94  std::unique_ptr<SwShadowCursor, o3tl::default_delete<SwShadowCursor>> m_pShadCursor;
95  boost::optional<Point> m_xRowColumnSelectionStart; // save position where table row/column selection has been started
96 
98 
99  SdrHitKind m_aActHitType; // current mouse pointer
100 
101  SotClipboardFormatId m_nDropFormat; // format from the last QueryDrop
102  sal_uInt8 m_nDropAction; // action from the last QueryDrop
103  SotExchangeDest m_nDropDestination; // destination from the last QueryDrop
104 
105  sal_uInt16 m_eBezierMode;
106  sal_uInt16 m_nInsFrameColCount; // column number for interactive frame
108  bool m_bMBPressed : 1,
109  m_bInsDraw : 1,
110  m_bInsFrame : 1,
111  m_bIsInMove : 1,
112  m_bIsInDrag : 1, // don't execute StartExecuteDrag twice
113  m_bOldIdle : 1, // to stop to idle
114  m_bOldIdleSet : 1, // during QeueryDrop
115  m_bChainMode : 1, // connect frames
116  m_bWasShdwCursor : 1, // ShadowCursor was on in MouseButtonDown
117  m_bLockInput : 1, // lock while calc panel is active
118  m_bIsRowDrag : 1, //selection of rows is used, in combination with m_pRowColumnSelectionStart
122  m_bUseInputLanguage: 1,
123  m_bObjectSelect : 1;
124 
125  sal_uInt16 m_nKS_NUMDOWN_Count; // #i23725#
127 
128  std::unique_ptr<SwFrameControlsManager> m_pFrameControlsManager;
129 
130  void LeaveArea(const Point &);
131  void JustifyAreaTimer();
132  inline void EnterArea();
133 
134  void RstMBDownFlags();
135 
136  void ChangeFly( sal_uInt8 nDir, bool bWeb );
137  void ChangeDrawing( sal_uInt8 nDir );
138 
139  bool EnterDrawMode(const MouseEvent& rMEvt, const Point& aDocPos);
140  bool RulerColumnDrag( const MouseEvent& rMEvt, bool bVerticalMode);
141 
142  // helper function for D&D
143  void DropCleanup();
144  void CleanupDropUserMarker();
145  SotExchangeDest GetDropDestination( const Point& rPixPnt,
146  SdrObject ** ppObj = nullptr );
147  //select the object/cursor at the mouse position of the context menu request
148  void SelectMenuPosition(SwWrtShell& rSh, const Point& rMousePos );
149 
150  /*
151  * handler for scrolling on when the mousepointer
152  * stops outside of EditWin during a drag-operation.
153  * The selection is regularly increased towards the mouse
154  * position.
155  */
156  DECL_LINK( TimerHandler, Timer *, void );
157  void StartDDTimer();
158  void StopDDTimer(SwWrtShell *, const Point &);
159  DECL_LINK( DDHandler, Timer *, void );
160 
161  // timer for ANY-KeyInut question without a following KeyInputEvent
162  DECL_LINK( KeyInputFlushHandler, Timer *, void );
163 
164  // timer for ApplyTemplates via mouse (in disguise Drag&Drop)
165  DECL_LINK( TemplateTimerHdl, Timer *, void );
166 
167  void MoveCursor( SwWrtShell &rSh, const Point& rDocPos,
168  const bool bOnlyText, bool bLockView );
169 
170  virtual void DataChanged( const DataChangedEvent& ) override;
171  virtual void PrePaint(vcl::RenderContext& rRenderContext) override;
172  virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
173 
174  virtual void GetFocus() override;
175  virtual void LoseFocus() override;
176 
177  virtual void MouseMove(const MouseEvent& rMEvt) override;
178  virtual void MouseButtonDown(const MouseEvent& rMEvt) override;
179  virtual void MouseButtonUp(const MouseEvent& rMEvt) override;
180  virtual void RequestHelp(const HelpEvent& rEvt) override;
181 
182  // Drag & Drop Interface
183  virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override;
184  virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override;
185  virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ) override;
186 
187  virtual OUString GetSurroundingText() const override;
188  virtual Selection GetSurroundingTextSelection() const override;
189 
190  void ShowAutoTextCorrectQuickHelp( const OUString& rWord, SvxAutoCorrCfg const * pACfg,
191  SvxAutoCorrect* pACorr, bool bFromIME = false );
192 
194  bool IsInHeaderFooter( const Point &rDocPt, FrameControlType &rControl ) const;
195 
196  bool IsOverHeaderFooterFly( const Point& rDocPos, FrameControlType& rControl, bool& bOverFly, bool& bPageAnchored ) const;
197 
198 public:
199  virtual void KeyInput(const KeyEvent &rKEvt) override;
200  void UpdatePointer(const Point &, sal_uInt16 nButtons = 0);
201 
202  bool IsDrawSelMode();
203  bool IsDrawAction() { return m_bInsDraw; }
204  void SetDrawAction(bool bFlag) { m_bInsDraw = bFlag; }
205 
206  void SetObjectSelect( bool bVal ) { m_bObjectSelect = bVal; }
207  bool IsObjectSelect() const { return m_bObjectSelect; }
208 
209  SdrObjKind GetSdrDrawMode() const { return m_eDrawMode; }
210  void SetSdrDrawMode( SdrObjKind eSdrObjectKind ) { m_eDrawMode = eSdrObjectKind; SetObjectSelect( false ); }
211  void StdDrawMode( SdrObjKind eSdrObjectKind, bool bObjSelect );
212 
213  bool IsFrameAction() const { return m_bInsFrame; }
214  sal_uInt16 GetBezierMode() const { return m_eBezierMode; }
215  void SetBezierMode(sal_uInt16 eBezMode) { m_eBezierMode = eBezMode; }
216  void EnterDrawTextMode(const Point& aDocPos); // turn on DrawTextEditMode
217  void InsFrame(sal_uInt16 nCols);
218  void StopInsFrame();
219  sal_uInt16 GetFrameColCount() const {return m_nInsFrameColCount;} // column number for interactive frame
220 
221  void SetChainMode( bool bOn );
222  bool IsChainMode() const { return m_bChainMode; }
223 
224  void FlushInBuffer();
225  static bool IsInputSequenceCheckingRequired( const OUString &rText, const SwPaM& rCursor );
226 
227  void SetApplyTemplate(const SwApplyTemplate &);
228  SwApplyTemplate* GetApplyTemplate() const { return m_pApplyTempl.get(); }
229 
230  void StartExecuteDrag();
231  void DragFinished();
232 
233  void SetWaterCanTextColor(const Color& rCol ) { m_aWaterCanTextColor = rCol; }
234 
235  void SetWaterCanTextBackColor(const Color& rCol ) { m_aWaterCanTextBackColor = rCol; }
236 
237  void LockKeyInput(bool bSet){m_bLockInput = bSet;}
238 
239  const SwView &GetView() const { return m_rView; }
240  SwView &GetView() { return m_rView; }
241 
242  virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override;
243 
244  static long GetDDStartPosX() { return m_nDDStartPosX; }
245  static long GetDDStartPosY() { return m_nDDStartPosY; }
246 
247  static void InitStaticData();
248  static void FinitStaticData();
249 
250  //#i3370# remove quick help to prevent saving of autocorrection suggestions
251  void StopQuickHelp();
252 
253  // #i42921# - add parameter <bVerticalMode>
254  bool RulerMarginDrag( const MouseEvent& rMEvt,
255  const bool bVerticalMode );
256 
260  void SetUseInputLanguage( bool bNew );
261  bool IsUseInputLanguage() const { return m_bUseInputLanguage; }
262 
266  OUString ClipLongToolTip(const OUString& rText);
267 
268  SwFrameControlsManager& GetFrameControlsManager();
269 
270  SwEditWin(vcl::Window *pParent, SwView &);
271  virtual ~SwEditWin() override;
272  virtual void dispose() override;
273 
274  virtual void Command( const CommandEvent& rCEvt ) override;
275 
277  void LogicInvalidate(const tools::Rectangle* pRectangle) override;
279  virtual void LogicMouseButtonDown(const MouseEvent& rMouseEvent) override;
281  virtual void LogicMouseButtonUp(const MouseEvent& rMouseEvent) override;
283  virtual void LogicMouseMove(const MouseEvent& rMouseEvent) override;
285  void SetCursorTwipPosition(const Point& rPosition, bool bPoint, bool bClearMark);
287  void SetGraphicTwipPosition(bool bStart, const Point& rPosition);
288 
289  virtual FactoryFunction GetUITestFactory() const override;
290 };
291 
292 extern bool g_bFrameDrag;
293 extern bool g_bDDTimerStarted;
294 extern bool g_bFlushCharBuffer;
295 extern bool g_bDDINetAttr;
296 
297 #endif
298 
299 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
boost::optional< Point > m_xRowColumnSelectionStart
Definition: edtwin.hxx:95
virtual FactoryFunction GetUITestFactory() const
Color m_aWaterCanTextColor
Definition: edtwin.hxx:66
void SetWaterCanTextBackColor(const Color &rCol)
Definition: edtwin.hxx:235
std::unique_ptr< SwFrameControlsManager > m_pFrameControlsManager
Definition: edtwin.hxx:128
virtual void MouseButtonDown(const MouseEvent &rMEvt)
signed char sal_Int8
const SwView & GetView() const
Definition: edtwin.hxx:239
AutoTimer m_aTimer
Definition: edtwin.hxx:75
bool g_bDDTimerStarted
Definition: edtwin.cxx:184
void SetWaterCanTextColor(const Color &rCol)
Definition: edtwin.hxx:233
SdrObjKind m_eDrawMode
Definition: edtwin.hxx:107
std::function< std::unique_ptr< UIObject >vcl::Window *)> FactoryFunction
SdrObject * m_pUserMarkerObj
Definition: edtwin.hxx:93
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:82
static long m_nDDStartPosY
Definition: edtwin.hxx:64
sal_uInt16 GetBezierMode() const
Definition: edtwin.hxx:214
std::unique_ptr< SdrDropMarkerOverlay > m_pUserMarker
Definition: edtwin.hxx:92
Used by the UI to modify the document model.
Definition: wrtsh.hxx:88
static long m_nDDStartPosX
Definition: edtwin.hxx:63
std::unique_ptr< SwAnchorMarker > m_pAnchorMarker
Definition: edtwin.hxx:90
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible()
sal_uInt8 m_nDropAction
Definition: edtwin.hxx:102
bool g_bFlushCharBuffer
Definition: edtwin.cxx:185
void SetSdrDrawMode(SdrObjKind eSdrObjectKind)
Definition: edtwin.hxx:210
SotClipboardFormatId
Timer m_aKeyInputFlushTimer
Definition: edtwin.hxx:77
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:89
static long GetDDStartPosX()
Definition: edtwin.hxx:244
void LockKeyInput(bool bSet)
Definition: edtwin.hxx:237
sal_uInt16 GetFrameColCount() const
Definition: edtwin.hxx:219
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:101
SwApplyTemplate * GetApplyTemplate() const
Definition: edtwin.hxx:228
Point m_aStartPos
Definition: edtwin.hxx:81
virtual OUString GetSurroundingText() const
virtual sal_Int8 AcceptDrop(const AcceptDropEvent &rEvt)
bool IsFrameAction() const
Definition: edtwin.hxx:213
std::unique_ptr< SwShadowCursor, o3tl::default_delete< SwShadowCursor > > m_pShadCursor
Definition: edtwin.hxx:94
Window class for the Writer edit area, this is the one handling mouse and keyboard events and doing t...
Definition: edtwin.hxx:58
Timer m_aTemplateTimer
Definition: edtwin.hxx:84
sal_uInt16 m_nInsFrameColCount
Definition: edtwin.hxx:106
SwCallMouseEvent m_aSaveCallEvent
Definition: edtwin.hxx:87
SotExchangeDest m_nDropDestination
Definition: edtwin.hxx:103
sal_uInt16 m_eBezierMode
Definition: edtwin.hxx:105
SwView & GetView()
Definition: edtwin.hxx:240
static long GetDDStartPosY()
Definition: edtwin.hxx:245
bool IsUseInputLanguage() const
Definition: edtwin.hxx:261
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
virtual void LoseFocus()
SdrObjKind GetSdrDrawMode() const
Definition: edtwin.hxx:209
virtual void KeyInput(const KeyEvent &rKEvt)
void SetObjectSelect(bool bVal)
Definition: edtwin.hxx:206
SdrHitKind m_aActHitType
Definition: edtwin.hxx:99
FrameControlType
Definition: swtypes.hxx:246
virtual void LogicMouseButtonUp(const MouseEvent &)
SdrObjKind
bool IsObjectSelect() const
Definition: edtwin.hxx:207
sal_uInt16 m_nKS_NUMDOWN_Count
Definition: edtwin.hxx:125
virtual void GetFocus()
unsigned char sal_uInt8
Color m_aWaterCanTextBackColor
Definition: edtwin.hxx:67
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)
Point m_aRszMvHdlPt
Definition: edtwin.hxx:83
SwView & m_rView
Definition: edtwin.hxx:97
bool g_bDDINetAttr
Definition: edtwin.cxx:186
virtual void LogicMouseButtonDown(const MouseEvent &)
void SetDrawAction(bool bFlag)
Definition: edtwin.hxx:204
virtual void MouseMove(const MouseEvent &rMEvt)
void SetBezierMode(sal_uInt16 eBezMode)
Definition: edtwin.hxx:215
bool IsDrawAction()
Definition: edtwin.hxx:203
LanguageType m_eBufferLanguage
Definition: edtwin.hxx:80
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:79
virtual void RequestHelp(const HelpEvent &rHEvt)
sal_uInt16 m_nKS_NUMINDENTINC_Count
Definition: edtwin.hxx:126
Definition: view.hxx:146
virtual void DataChanged(const DataChangedEvent &rDCEvt)
static QuickHelpData * m_pQuickHlpData
Definition: edtwin.hxx:61
bool IsChainMode() const
Definition: edtwin.hxx:222