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
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
59class SW_DLLPUBLIC SwEditWin final : public vcl::Window,
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,
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
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
204public:
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
302extern bool g_bFrameDrag;
303extern bool g_bDDTimerStarted;
304extern bool g_bDDINetAttr;
305
306#endif
307
308/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void StartDrag(sal_Int8 nAction, const Point &rPosPixel)
virtual sal_Int8 ExecuteDrop(const ExecuteDropEvent &rEvt)
virtual sal_Int8 AcceptDrop(const AcceptDropEvent &rEvt)
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:112
void SetWaterCanTextColor(const Color &rCol)
Definition: edtwin.hxx:239
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:116
SwView & m_rView
Definition: edtwin.hxx:98
static tools::Long GetDDStartPosX()
Definition: edtwin.hxx:250
sal_uInt16 GetFrameColCount() const
Definition: edtwin.hxx:225
bool m_bIsRowDrag
Definition: edtwin.hxx:119
static tools::Long s_nDDStartPosX
Definition: edtwin.hxx:64
OUString m_aInBuffer
Definition: edtwin.hxx:80
SotClipboardFormatId m_nDropFormat
Definition: edtwin.hxx:102
SdrObjKind m_eDrawMode
Definition: edtwin.hxx:108
static tools::Long GetDDStartPosY()
Definition: edtwin.hxx:251
LanguageType m_eBufferLanguage
Definition: edtwin.hxx:81
sal_uInt16 GetBezierMode() const
Definition: edtwin.hxx:220
void SetWaterCanTextBackColor(const Color &rCol)
Definition: edtwin.hxx:241
bool IsDrawAction() const
Definition: edtwin.hxx:209
SwView & GetView()
Definition: edtwin.hxx:246
bool IsChainMode() const
Definition: edtwin.hxx:228
bool m_bMBPressed
Definition: edtwin.hxx:109
std::optional< Point > m_xRowColumnSelectionStart
Definition: edtwin.hxx:96
bool m_bInsFrame
Definition: edtwin.hxx:111
DECL_DLLPRIVATE_LINK(KeyInputFlushHandler, Timer *, void)
bool IsObjectSelect() const
Definition: edtwin.hxx:213
Timer m_aKeyInputFlushTimer
Definition: edtwin.hxx:78
void SetObjectSelect(bool bVal)
Definition: edtwin.hxx:212
Timer m_aTemplateTimer
Definition: edtwin.hxx:85
Color m_aWaterCanTextBackColor
Definition: edtwin.hxx:68
SwApplyTemplate * GetApplyTemplate() const
Definition: edtwin.hxx:234
bool m_bIsInDrag
Definition: edtwin.hxx:113
SotExchangeDest m_nDropDestination
Definition: edtwin.hxx:104
sal_uInt16 m_nInsFrameColCount
Definition: edtwin.hxx:107
SdrObjKind GetSdrDrawMode() const
Definition: edtwin.hxx:215
const SwView & GetView() const
Definition: edtwin.hxx:245
bool m_bOldIdleSet
Definition: edtwin.hxx:115
void SetDrawAction(bool bFlag)
Definition: edtwin.hxx:210
SdrHitKind m_aActHitType
Definition: edtwin.hxx:100
sal_uInt16 m_nKS_NUMDOWN_Count
Definition: edtwin.hxx:126
SwCallMouseEvent m_aSaveCallEvent
Definition: edtwin.hxx:88
void LockKeyInput(bool bSet)
Definition: edtwin.hxx:243
bool m_bOldIdle
Definition: edtwin.hxx:114
SdrObject * m_pUserMarkerObj
Definition: edtwin.hxx:94
bool m_bInsDraw
Definition: edtwin.hxx:110
void SetSavedOutlineFrame(SwTextFrame *pFrame)
Definition: edtwin.hxx:296
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:295
std::unique_ptr< SwAnchorMarker > m_pAnchorMarker
Definition: edtwin.hxx:91
static QuickHelpData * s_pQuickHlpData
Definition: edtwin.hxx:62
bool m_bLockInput
Definition: edtwin.hxx:118
bool m_bUseInputLanguage
#i42732# display status of font size/name depending on either the input language or the selection pos...
Definition: edtwin.hxx:123
bool m_bWasShdwCursor
Definition: edtwin.hxx:117
bool IsFrameAction() const
Definition: edtwin.hxx:219
sal_uInt16 m_nKS_NUMINDENTINC_Count
Definition: edtwin.hxx:127
Point m_aStartPos
Definition: edtwin.hxx:82
bool m_bObjectSelect
Definition: edtwin.hxx:124
Point m_aRszMvHdlPt
Definition: edtwin.hxx:84
Point m_aMovePos
Definition: edtwin.hxx:83
void SetSdrDrawMode(SdrObjKind eSdrObjectKind)
Definition: edtwin.hxx:216
sal_uInt8 m_nDropAction
Definition: edtwin.hxx:103
std::unique_ptr< SwFrameControlsManager > m_pFrameControlsManager
Definition: edtwin.hxx:129
DECL_DLLPRIVATE_LINK(TimerHandler, Timer *, void)
std::unique_ptr< SwApplyTemplate > m_pApplyTempl
Definition: edtwin.hxx:90
sal_uInt16 m_eBezierMode
Definition: edtwin.hxx:106
bool IsUseInputLanguage() const
Definition: edtwin.hxx:267
void SetBezierMode(sal_uInt16 eBezMode)
Definition: edtwin.hxx:221
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:187
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:165
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 LogicMouseMove(const MouseEvent &)
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 LogicMouseButtonUp(const MouseEvent &)
virtual void MouseMove(const MouseEvent &rMEvt)
virtual void DataChanged(const DataChangedEvent &rDCEvt)
virtual void LoseFocus()
virtual void LogicMouseButtonDown(const MouseEvent &)
virtual FactoryFunction GetUITestFactory() const
bool g_bDDTimerStarted
Definition: edtwin.cxx:175
bool g_bDDINetAttr
Definition: edtwin.cxx:176
bool g_bFrameDrag
Definition: edtwin.cxx:172
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:256
SdrHitKind
SdrObjKind
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
FrameControlType
Definition: swtypes.hxx:244
unsigned char sal_uInt8
signed char sal_Int8