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