/src/libreoffice/sw/source/uibase/inc/edtwin.hxx
Line | Count | Source |
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 | | #include <viewsh.hxx> |
32 | | |
33 | | class SwWrtShell; |
34 | | class SwView; |
35 | | class SwAnchorMarker; |
36 | | class SdrObject; |
37 | | class SwShadowCursor; |
38 | | class SvxAutoCorrect; |
39 | | class SwPaM; |
40 | | struct SwApplyTemplate; |
41 | | struct QuickHelpData; |
42 | | class SdrDropMarkerOverlay; |
43 | | class SwFrameControlsManager; |
44 | | enum class SdrHitKind; |
45 | | class SwTextFrame; |
46 | | |
47 | | namespace Move { |
48 | | enum class Size { |
49 | | Small, |
50 | | Big, |
51 | | Huge |
52 | | }; |
53 | | |
54 | | enum class Direction { |
55 | | Left, |
56 | | Up, |
57 | | Right, |
58 | | Down |
59 | | }; |
60 | | }; |
61 | | |
62 | | // input window |
63 | | |
64 | | /** Window class for the Writer edit area, this is the one handling mouse |
65 | | and keyboard events and doing the final painting of the document from |
66 | | the buffered layout. |
67 | | |
68 | | To translate the pixel positions from the buffer OutputDevice to the real |
69 | | pixel positions, use the PixelToLogic methods of this class. |
70 | | */ |
71 | | class SAL_DLLPUBLIC_RTTI SwEditWin final : public vcl::DocWindow, |
72 | | public DropTargetHelper, public DragSourceHelper |
73 | | { |
74 | | static QuickHelpData* s_pQuickHlpData; |
75 | | |
76 | | static tools::Long s_nDDStartPosX; |
77 | | static tools::Long s_nDDStartPosY; |
78 | | |
79 | | Color m_aWaterCanTextColor; // text color; for the watering can |
80 | | Color m_aWaterCanTextBackColor; // text background; for the watering can |
81 | | |
82 | | /* |
83 | | * timer and handler for scrolling on when the mousepointer |
84 | | * stops outside of EditWin during a drag-operation. |
85 | | * The selection is increased towards the mouse position |
86 | | * regularly. |
87 | | */ |
88 | | AutoTimer m_aTimer; |
89 | | sal_uInt32 m_nTimerCalls; |
90 | | // timer for ANY-KeyInput question without a following KeyInputEvent |
91 | | Timer m_aKeyInputFlushTimer; |
92 | | |
93 | | OUString m_aInBuffer; |
94 | | LanguageType m_eBufferLanguage; |
95 | | Point m_aStartPos; |
96 | | Point m_aMovePos; |
97 | | ScrollSizeMode m_eScrollSizeMode; |
98 | | Point m_aRszMvHdlPt; |
99 | | Timer m_aTemplateTimer; |
100 | | |
101 | | // type/object where the mouse pointer is |
102 | | SwCallMouseEvent m_aSaveCallEvent; |
103 | | |
104 | | std::unique_ptr<SwApplyTemplate> m_pApplyTempl; |
105 | | std::unique_ptr<SwAnchorMarker> m_pAnchorMarker; // for relocating the anchor |
106 | | |
107 | | std::unique_ptr<SdrDropMarkerOverlay> m_pUserMarker; |
108 | | SdrObject *m_pUserMarkerObj; |
109 | | std::unique_ptr<SwShadowCursor, o3tl::default_delete<SwShadowCursor>> m_pShadCursor; |
110 | | sal_Int16 m_eOrient; |
111 | | std::optional<Point> m_xRowColumnSelectionStart; // save position where table row/column selection has been started |
112 | | |
113 | | SwView &m_rView; |
114 | | |
115 | | SdrHitKind m_aActHitType; // current mouse pointer |
116 | | |
117 | | SotClipboardFormatId m_nDropFormat; // format from the last QueryDrop |
118 | | sal_uInt8 m_nDropAction; // action from the last QueryDrop |
119 | | SotExchangeDest m_nDropDestination; // destination from the last QueryDrop |
120 | | |
121 | | sal_uInt16 m_eBezierMode; |
122 | | sal_uInt16 m_nInsFrameColCount; // column number for interactive frame |
123 | | SdrObjKind m_eDrawMode; |
124 | | bool m_bMBPressed : 1, |
125 | | m_bInsDraw : 1, |
126 | | m_bInsFrame : 1, |
127 | | m_bIsInMove : 1, |
128 | | m_bIsInDrag : 1, // don't execute StartExecuteDrag twice |
129 | | m_bOldIdle : 1, // to stop to idle |
130 | | m_bOldIdleSet : 1, // during QeueryDrop |
131 | | m_bChainMode : 1, // connect frames |
132 | | m_bWasShdwCursor : 1, // ShadowCursor was on in MouseButtonDown |
133 | | m_bLockInput : 1, // lock while calc panel is active |
134 | | m_bIsRowDrag : 1, //selection of rows is used, in combination with m_pRowColumnSelectionStart |
135 | | /** #i42732# display status of font size/name depending on either the input language or the |
136 | | selection position depending on what has changed lately |
137 | | */ |
138 | | m_bUseInputLanguage: 1, |
139 | | m_bObjectSelect : 1, |
140 | | mbIsDragSidebar : 1, |
141 | | m_bMaybeShowTooltipAfterBufferFlush : 1 = false; |
142 | | |
143 | | sal_uInt16 m_nKS_NUMDOWN_Count; // #i23725# |
144 | | sal_uInt16 m_nKS_NUMINDENTINC_Count; |
145 | | |
146 | | std::unique_ptr<SwFrameControlsManager> m_pFrameControlsManager; |
147 | | |
148 | | SwTextFrame* m_pSavedOutlineFrame = nullptr; |
149 | | |
150 | | void LeaveArea(const Point &); |
151 | | void JustifyAreaTimer(bool bStart = false); |
152 | | inline void EnterArea(); |
153 | | |
154 | | void ResetMouseButtonDownFlags(); |
155 | | |
156 | | void ChangeFly(Move::Direction eDir, Move::Size eDirSize, bool bWeb); |
157 | | void ChangeDrawing(Move::Direction eDir, Move::Size eDirSize); |
158 | | |
159 | | bool EnterDrawMode(const MouseEvent& rMEvt, const Point& aDocPos); |
160 | | bool RulerColumnDrag( const MouseEvent& rMEvt, bool bVerticalMode); |
161 | | |
162 | | // helper function for D&D |
163 | | void DropCleanup(); |
164 | | void CleanupDropUserMarker(); |
165 | | SotExchangeDest GetDropDestination( const Point& rPixPnt, |
166 | | SdrObject ** ppObj = nullptr ); |
167 | | //select the object/cursor at the mouse position of the context menu request |
168 | | void SelectMenuPosition(SwWrtShell& rSh, const Point& rMousePos ); |
169 | | |
170 | | /* |
171 | | * handler for scrolling on when the mousepointer |
172 | | * stops outside of EditWin during a drag-operation. |
173 | | * The selection is regularly increased towards the mouse |
174 | | * position. |
175 | | */ |
176 | | DECL_LINK( TimerHandler, Timer *, void ); |
177 | | void StartDDTimer(); |
178 | | void StopDDTimer(SwWrtShell *, const Point &); |
179 | | DECL_LINK( DDHandler, Timer *, void ); |
180 | | |
181 | | // timer for ANY-KeyInut question without a following KeyInputEvent |
182 | | DECL_LINK( KeyInputFlushHandler, Timer *, void ); |
183 | | |
184 | | // timer for ApplyTemplates via mouse (in disguise Drag&Drop) |
185 | | DECL_LINK( TemplateTimerHdl, Timer *, void ); |
186 | | |
187 | | void MoveCursor( SwWrtShell &rSh, const Point& rDocPos, |
188 | | const bool bOnlyText, bool bLockView); |
189 | | |
190 | | virtual void DataChanged( const DataChangedEvent& ) override; |
191 | | virtual void PrePaint(vcl::RenderContext& rRenderContext) override; |
192 | | virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; |
193 | | |
194 | | virtual void GetFocus() override; |
195 | | virtual void LoseFocus() override; |
196 | | |
197 | | bool changeMousePointer(Point const & rDocPoint); |
198 | | |
199 | | virtual void MouseMove(const MouseEvent& rMEvt) override; |
200 | | virtual void MouseButtonDown(const MouseEvent& rMEvt) override; |
201 | | virtual void MouseButtonUp(const MouseEvent& rMEvt) override; |
202 | | virtual void RequestHelp(const HelpEvent& rEvt) override; |
203 | | |
204 | | // Drag & Drop Interface |
205 | | virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override; |
206 | | virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override; |
207 | | virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ) override; |
208 | | |
209 | | virtual OUString GetSurroundingText() const override; |
210 | | virtual Selection GetSurroundingTextSelection() const override; |
211 | | virtual bool DeleteSurroundingText(const Selection& rSelection) override; |
212 | | |
213 | | void ShowAutoCorrectQuickHelp(const OUString& rWord, SvxAutoCorrect& rACorr); |
214 | | bool ShowAutoText(const std::vector<OUString>& rChunkCandidates); |
215 | | |
216 | | /// Returns true if in header/footer area, or in the header/footer control. |
217 | | bool IsInHeaderFooter( const Point &rDocPt, FrameControlType &rControl ) const; |
218 | | |
219 | | bool IsOverHeaderFooterFly( const Point& rDocPos, FrameControlType& rControl, bool& bOverFly, bool& bPageAnchored ) const; |
220 | | |
221 | | public: |
222 | | SW_DLLPUBLIC virtual void KeyInput(const KeyEvent &rKEvt) override; |
223 | | void UpdatePointer(const Point &, sal_uInt16 nButtons = 0); |
224 | | |
225 | | bool IsDrawSelMode() const; |
226 | 0 | bool IsDrawAction() const { return m_bInsDraw; } |
227 | 0 | void SetDrawAction(bool bFlag) { m_bInsDraw = bFlag; } |
228 | | |
229 | 0 | void SetObjectSelect( bool bVal ) { m_bObjectSelect = bVal; } |
230 | 0 | bool IsObjectSelect() const { return m_bObjectSelect; } |
231 | | |
232 | 0 | SdrObjKind GetSdrDrawMode() const { return m_eDrawMode; } |
233 | 0 | void SetSdrDrawMode( SdrObjKind eSdrObjectKind ) { m_eDrawMode = eSdrObjectKind; SetObjectSelect( false ); } |
234 | | void StdDrawMode( SdrObjKind eSdrObjectKind, bool bObjSelect ); |
235 | | |
236 | 11.1k | bool IsFrameAction() const { return m_bInsFrame; } |
237 | 0 | sal_uInt16 GetBezierMode() const { return m_eBezierMode; } |
238 | 0 | void SetBezierMode(sal_uInt16 eBezMode) { m_eBezierMode = eBezMode; } |
239 | | void EnterDrawTextMode(const Point& aDocPos); // turn on DrawTextEditMode |
240 | | void InsFrame(sal_uInt16 nCols); |
241 | | void StopInsFrame(); |
242 | 0 | sal_uInt16 GetFrameColCount() const {return m_nInsFrameColCount;} // column number for interactive frame |
243 | | |
244 | | void SetChainMode( bool bOn ); |
245 | 7.87k | bool IsChainMode() const { return m_bChainMode; } |
246 | | |
247 | | void FlushInBuffer(); |
248 | | static bool IsInputSequenceCheckingRequired( const OUString &rText, const SwPaM& rCursor ); |
249 | | |
250 | | void SetApplyTemplate(const SwApplyTemplate &); |
251 | 0 | SwApplyTemplate* GetApplyTemplate() const { return m_pApplyTempl.get(); } |
252 | | |
253 | | void StartExecuteDrag(); |
254 | | void DragFinished(); |
255 | | |
256 | 0 | void SetWaterCanTextColor(const Color& rCol ) { m_aWaterCanTextColor = rCol; } |
257 | | |
258 | 0 | void SetWaterCanTextBackColor(const Color& rCol ) { m_aWaterCanTextBackColor = rCol; } |
259 | | |
260 | 0 | void LockKeyInput(bool bSet){m_bLockInput = bSet;} |
261 | | |
262 | 0 | const SwView &GetView() const { return m_rView; } |
263 | 692 | SwView &GetView() { return m_rView; } |
264 | | |
265 | | virtual rtl::Reference<comphelper::OAccessible> CreateAccessible() override; |
266 | | |
267 | 0 | static tools::Long GetDDStartPosX() { return s_nDDStartPosX; } |
268 | 0 | static tools::Long GetDDStartPosY() { return s_nDDStartPosY; } |
269 | | |
270 | | static void InitStaticData(); |
271 | | static void FinitStaticData(); |
272 | | |
273 | | //#i3370# remove quick help to prevent saving of autocorrection suggestions |
274 | | void StopQuickHelp(); |
275 | | |
276 | | // #i42921# - add parameter <bVerticalMode> |
277 | | bool RulerMarginDrag( const MouseEvent& rMEvt, |
278 | | const bool bVerticalMode ); |
279 | | |
280 | | /** #i42732# display status of font size/name depending on either the input |
281 | | language or the selection position depending on what has changed lately |
282 | | */ |
283 | | void SetUseInputLanguage( bool bNew ); |
284 | 0 | bool IsUseInputLanguage() const { return m_bUseInputLanguage; } |
285 | | |
286 | | /** fdo#55546 cut very long tooltips to 2/3 of the width of the screen |
287 | | via center ellipsis |
288 | | */ |
289 | | OUString ClipLongToolTip(const OUString& rText); |
290 | | |
291 | | SwFrameControlsManager& GetFrameControlsManager(); |
292 | | |
293 | | SwEditWin(vcl::Window *pParent, SwView &); |
294 | | virtual ~SwEditWin() override; |
295 | | virtual void dispose() override; |
296 | | |
297 | | virtual void Command( const CommandEvent& rCEvt ) override; |
298 | | |
299 | | /// @see Window::LogicInvalidate(). |
300 | | void LogicInvalidate(const tools::Rectangle* pRectangle) override; |
301 | | /// Allows adjusting the point or mark of the selection to a document coordinate. |
302 | | void SetCursorTwipPosition(const Point& rPosition, bool bPoint, bool bClearMark); |
303 | | /// Allows starting or ending a graphic move or resize action. |
304 | | void SetGraphicTwipPosition(bool bStart, const Point& rPosition); |
305 | | |
306 | | bool IsViewReadonly() const; |
307 | | |
308 | 0 | const SwTextFrame* GetSavedOutlineFrame() const { return m_pSavedOutlineFrame; } |
309 | 0 | void SetSavedOutlineFrame(SwTextFrame* pFrame) { m_pSavedOutlineFrame = pFrame; } |
310 | | // bSubs set true, sets all sub level outline content to same visibility as nOutlinePos. |
311 | | // It is only applicable when not treating sub outline levels as content. |
312 | | void ToggleOutlineContentVisibility(const size_t nOutlinePos, const bool bSubs); |
313 | | |
314 | | virtual FactoryFunction GetUITestFactory() const override; |
315 | | |
316 | | // Draws a guide line at the specified position |
317 | | void DrawCommentGuideLine(Point aPointPixel); |
318 | | // Stops drawing the guide line |
319 | | void ReleaseCommentGuideLine(); |
320 | | void SetSidebarWidth(const Point& rPointPixel); |
321 | | }; |
322 | | |
323 | | extern bool g_bModePushed; |
324 | | extern bool g_bFrameDrag; |
325 | | extern bool g_bDDTimerStarted; |
326 | | extern bool g_bDDINetAttr; |
327 | | |
328 | | #endif |
329 | | |
330 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |