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  bool changeMousePointer(Point const & rDocPoint);
178 
179  virtual void MouseMove(const MouseEvent& rMEvt) override;
180  virtual void MouseButtonDown(const MouseEvent& rMEvt) override;
181  virtual void MouseButtonUp(const MouseEvent& rMEvt) override;
182  virtual void RequestHelp(const HelpEvent& rEvt) override;
183 
184  // Drag & Drop Interface
185  virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override;
186  virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override;
187  virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ) override;
188 
189  virtual OUString GetSurroundingText() const override;
190  virtual Selection GetSurroundingTextSelection() const override;
191 
192  void ShowAutoTextCorrectQuickHelp( const OUString& rWord, SvxAutoCorrCfg const * pACfg,
193  SvxAutoCorrect* pACorr, bool bFromIME = false );
194 
196  bool IsInHeaderFooter( const Point &rDocPt, FrameControlType &rControl ) const;
197 
198  bool IsOverHeaderFooterFly( const Point& rDocPos, FrameControlType& rControl, bool& bOverFly, bool& bPageAnchored ) const;
199 
200 public:
201  virtual void KeyInput(const KeyEvent &rKEvt) override;
202  void UpdatePointer(const Point &, sal_uInt16 nButtons = 0);
203 
204  bool IsDrawSelMode();
205  bool IsDrawAction() { return m_bInsDraw; }
206  void SetDrawAction(bool bFlag) { m_bInsDraw = bFlag; }
207 
208  void SetObjectSelect( bool bVal ) { m_bObjectSelect = bVal; }
209  bool IsObjectSelect() const { return m_bObjectSelect; }
210 
211  SdrObjKind GetSdrDrawMode() const { return m_eDrawMode; }
212  void SetSdrDrawMode( SdrObjKind eSdrObjectKind ) { m_eDrawMode = eSdrObjectKind; SetObjectSelect( false ); }
213  void StdDrawMode( SdrObjKind eSdrObjectKind, bool bObjSelect );
214 
215  bool IsFrameAction() const { return m_bInsFrame; }
216  sal_uInt16 GetBezierMode() const { return m_eBezierMode; }
217  void SetBezierMode(sal_uInt16 eBezMode) { m_eBezierMode = eBezMode; }
218  void EnterDrawTextMode(const Point& aDocPos); // turn on DrawTextEditMode
219  void InsFrame(sal_uInt16 nCols);
220  void StopInsFrame();
221  sal_uInt16 GetFrameColCount() const {return m_nInsFrameColCount;} // column number for interactive frame
222 
223  void SetChainMode( bool bOn );
224  bool IsChainMode() const { return m_bChainMode; }
225 
226  void FlushInBuffer();
227  static bool IsInputSequenceCheckingRequired( const OUString &rText, const SwPaM& rCursor );
228 
229  void SetApplyTemplate(const SwApplyTemplate &);
230  SwApplyTemplate* GetApplyTemplate() const { return m_pApplyTempl.get(); }
231 
232  void StartExecuteDrag();
233  void DragFinished();
234 
235  void SetWaterCanTextColor(const Color& rCol ) { m_aWaterCanTextColor = rCol; }
236 
237  void SetWaterCanTextBackColor(const Color& rCol ) { m_aWaterCanTextBackColor = rCol; }
238 
239  void LockKeyInput(bool bSet){m_bLockInput = bSet;}
240 
241  const SwView &GetView() const { return m_rView; }
242  SwView &GetView() { return m_rView; }
243 
244  virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override;
245 
246  static long GetDDStartPosX() { return m_nDDStartPosX; }
247  static long GetDDStartPosY() { return m_nDDStartPosY; }
248 
249  static void InitStaticData();
250  static void FinitStaticData();
251 
252  //#i3370# remove quick help to prevent saving of autocorrection suggestions
253  void StopQuickHelp();
254 
255  // #i42921# - add parameter <bVerticalMode>
256  bool RulerMarginDrag( const MouseEvent& rMEvt,
257  const bool bVerticalMode );
258 
262  void SetUseInputLanguage( bool bNew );
263  bool IsUseInputLanguage() const { return m_bUseInputLanguage; }
264 
268  OUString ClipLongToolTip(const OUString& rText);
269 
270  SwFrameControlsManager& GetFrameControlsManager();
271 
272  SwEditWin(vcl::Window *pParent, SwView &);
273  virtual ~SwEditWin() override;
274  virtual void dispose() override;
275 
276  virtual void Command( const CommandEvent& rCEvt ) override;
277 
279  void LogicInvalidate(const tools::Rectangle* pRectangle) override;
281  virtual void LogicMouseButtonDown(const MouseEvent& rMouseEvent) override;
283  virtual void LogicMouseButtonUp(const MouseEvent& rMouseEvent) override;
285  virtual void LogicMouseMove(const MouseEvent& rMouseEvent) override;
287  void SetCursorTwipPosition(const Point& rPosition, bool bPoint, bool bClearMark);
289  void SetGraphicTwipPosition(bool bStart, const Point& rPosition);
290 
291  virtual FactoryFunction GetUITestFactory() const override;
292 };
293 
294 extern bool g_bFrameDrag;
295 extern bool g_bDDTimerStarted;
296 extern bool g_bFlushCharBuffer;
297 extern bool g_bDDINetAttr;
298 
299 #endif
300 
301 /* 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:237
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:241
AutoTimer m_aTimer
Definition: edtwin.hxx:75
bool g_bDDTimerStarted
Definition: edtwin.cxx:184
void SetWaterCanTextColor(const Color &rCol)
Definition: edtwin.hxx:235
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:216
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:212
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:246
void LockKeyInput(bool bSet)
Definition: edtwin.hxx:239
sal_uInt16 GetFrameColCount() const
Definition: edtwin.hxx:221
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:230
Point m_aStartPos
Definition: edtwin.hxx:81
virtual OUString GetSurroundingText() const
virtual sal_Int8 AcceptDrop(const AcceptDropEvent &rEvt)
bool IsFrameAction() const
Definition: edtwin.hxx:215
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:242
static long GetDDStartPosY()
Definition: edtwin.hxx:247
bool IsUseInputLanguage() const
Definition: edtwin.hxx:263
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
virtual void LoseFocus()
SdrObjKind GetSdrDrawMode() const
Definition: edtwin.hxx:211
virtual void KeyInput(const KeyEvent &rKEvt)
void SetObjectSelect(bool bVal)
Definition: edtwin.hxx:208
SdrHitKind m_aActHitType
Definition: edtwin.hxx:99
FrameControlType
Definition: swtypes.hxx:246
virtual void LogicMouseButtonUp(const MouseEvent &)
SdrObjKind
bool IsObjectSelect() const
Definition: edtwin.hxx:209
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:206
virtual void MouseMove(const MouseEvent &rMEvt)
void SetBezierMode(sal_uInt16 eBezMode)
Definition: edtwin.hxx:217
bool IsDrawAction()
Definition: edtwin.hxx:205
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:224