/src/libreoffice/sw/source/uibase/inc/wrtsh.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 | | |
20 | | #pragma once |
21 | | |
22 | | #include <swdllapi.h> |
23 | | #include <fesh.hxx> |
24 | | #include <swurl.hxx> |
25 | | #include <IMark.hxx> |
26 | | #include "navmgr.hxx" |
27 | | #include <optional> |
28 | | #include <com/sun/star/embed/EmbedVerbs.hpp> |
29 | | #include <o3tl/typed_flags_set.hxx> |
30 | | #include <svx/swframetypes.hxx> |
31 | | #include <vcl/weld/weld.hxx> |
32 | | #include <sfx2/redlinerecordingmode.hxx> |
33 | | |
34 | | #include <doc.hxx> |
35 | | #include <docsh.hxx> |
36 | | #include <viewopt.hxx> |
37 | | #include <reffldsubtype.hxx> |
38 | | |
39 | | namespace vcl { class Window; } |
40 | | class SbxArray; |
41 | | class SwFlyFrameAttrMgr; |
42 | | class SwField; |
43 | | class SwTOXBase; |
44 | | class SwView; |
45 | | class SvGlobalName; |
46 | | class SwInputFieldList; |
47 | | class SwSectionData; |
48 | | class SvxMacro; |
49 | | class SwFormatINetFormat; |
50 | | class SvxAutoCorrect; |
51 | | class NaviContentBookmark; |
52 | | struct SwCallMouseEvent; |
53 | | class SfxStringListItem; |
54 | | enum class SvMacroItemId : sal_uInt16; |
55 | | class SwFieldMgr; |
56 | | class SfxRequest; |
57 | | enum class SwLineBreakClear; |
58 | | enum class SwContentControlType; |
59 | | |
60 | | namespace i18nutil { |
61 | | struct SearchOptions2; |
62 | | } |
63 | | |
64 | | enum class SelectionType : sal_Int32 |
65 | | { |
66 | | NONE = 0x000000, |
67 | | Text = CNT_TXT, // text, never frames too 0x0001 |
68 | | Graphic = CNT_GRF, // graphic 0x0002 |
69 | | Ole = CNT_OLE, // OLE 0x0010 |
70 | | Frame = 0x000020, // frame, no content type |
71 | | NumberList = 0x000040, // NumList |
72 | | Table = 0x000080, // cursor is in table |
73 | | TableCell = 0x000100, // table cells are selected |
74 | | DrawObject = 0x000200, // drawing objects (rectangle, circle...) |
75 | | DrawObjectEditMode = 0x000400, // draw-textobjects in edit mode |
76 | | Ornament = 0x000800, // edit ornament objects |
77 | | DbForm = 0x001000, // drawing objects: DB-Forms |
78 | | FormControl = 0x002000, // a form control is focused. Neither set nor evaluated by the SwWrtShell itself, only by its clients. |
79 | | Media = 0x004000, // Media object |
80 | | ExtrudedCustomShape = 0x008000, // extruded custom shape |
81 | | FontWork = 0x010000, // fontwork |
82 | | PostIt = 0x020000, // annotation |
83 | | TableRow = 0x040000, // table rows are selected |
84 | | TableCol = 0x080000, // table columns are selected |
85 | | All = 0x0ffff3, |
86 | | }; |
87 | | namespace o3tl { |
88 | | template<> struct typed_flags<SelectionType> : is_typed_flags<SelectionType, 0x0ffff3> {}; |
89 | | } |
90 | | |
91 | | /** Used by the UI to modify the document model. |
92 | | |
93 | | Eg. the Insert() method will take the current cursor position, insert the |
94 | | string, and take care of undo etc. |
95 | | */ |
96 | | class SAL_DLLPUBLIC_RTTI SwWrtShell final : public SwFEShell |
97 | | { |
98 | | private: |
99 | | using SwCursorShell::Left; |
100 | | using SwCursorShell::Right; |
101 | | using SwCursorShell::Up; |
102 | | using SwCursorShell::Down; |
103 | | using SwCursorShell::LeftMargin; |
104 | | using SwCursorShell::RightMargin; |
105 | | using SwCursorShell::SelectTextAttr; |
106 | | using SwCursorShell::GotoPage; |
107 | | using SwFEShell::InsertObject; |
108 | | using SwEditShell::AutoCorrect; |
109 | | using SwCursorShell::GotoMark; |
110 | | |
111 | | typedef tools::Long (SwWrtShell::*SELECTFUNC)(const Point *, bool bProp, ScrollSizeMode eScrollSizeMode ); |
112 | | typedef void (SwWrtShell::*SELECTFUNC2)(const Point *, bool bProp ); |
113 | | |
114 | | SELECTFUNC2 m_fnDrag = &SwWrtShell::BeginDrag; |
115 | | SELECTFUNC m_fnSetCursor = &SwWrtShell::SetCursor; |
116 | | SELECTFUNC2 m_fnEndDrag = &SwWrtShell::DefaultEndDrag; |
117 | | SELECTFUNC m_fnKillSel = &SwWrtShell::Ignore; |
118 | | |
119 | | public: |
120 | | using SwCursorShell::GotoFootnoteAnchor; |
121 | | using SwEditShell::Insert; |
122 | | |
123 | | tools::Long CallSetCursor(const Point* pPt, bool bProp, |
124 | | ScrollSizeMode eScrollSizeMode = ScrollSizeMode::ScrollSizeDefault) |
125 | 0 | { return (this->*m_fnSetCursor)(pPt, bProp, eScrollSizeMode); } |
126 | 0 | void Drag (const Point* pPt, bool bProp) { (this->*m_fnDrag)(pPt, bProp); } |
127 | 0 | void EndDrag (const Point* pPt, bool bProp) { (this->*m_fnEndDrag)(pPt, bProp); } |
128 | | tools::Long KillSelection(const Point* pPt, bool bProp, |
129 | | ScrollSizeMode eScrollSizeMode = ScrollSizeMode::ScrollSizeDefault) |
130 | 0 | { return (this->*m_fnKillSel)(pPt, bProp, eScrollSizeMode ); } |
131 | | |
132 | | bool IsSplitVerticalByDefault() const; |
133 | | void SetSplitVerticalByDefault(bool value); |
134 | | |
135 | | // reset all selections |
136 | | SW_DLLPUBLIC tools::Long ResetSelect( const Point *, bool, ScrollSizeMode ); |
137 | | |
138 | | // resets the cursorstack after movement with PageUp/-Down if a stack is built up |
139 | | inline void ResetCursorStack(); |
140 | | SW_DLLPUBLIC SelectionType GetSelectionType() const; |
141 | | |
142 | | // checks if the section is editable in read-only mode |
143 | | bool IsSectionEditableInReadonly() const; |
144 | | |
145 | 4.08k | bool IsModePushed() const { return nullptr != m_pModeStack; } |
146 | | void PushMode(); |
147 | | void PopMode(); |
148 | | |
149 | | void SttSelect(); |
150 | | SW_DLLPUBLIC void EndSelect(); |
151 | 0 | bool IsInSelect() const { return m_bInSelect; } |
152 | 0 | void SetInSelect() { m_bInSelect = true; } |
153 | | // is there a text- or frameselection? |
154 | 4.08k | bool HasSelection() const { return SwCursorShell::HasSelection() || |
155 | 4.08k | IsMultiSelection() || IsSelFrameMode() || GetSelectedObjCount(); } |
156 | | bool Pop(SwCursorShell::PopMode, ::std::optional<SwCallLink>& roLink); |
157 | | SW_DLLPUBLIC bool Pop(SwCursorShell::PopMode = SwCursorShell::PopMode::DeleteStack); |
158 | | |
159 | | SW_DLLPUBLIC void EnterStdMode(); |
160 | 0 | bool IsStdMode() const { return !m_bExtMode && !m_bAddMode && !m_bBlockMode; } |
161 | | |
162 | | void AssureStdMode(); |
163 | | |
164 | | void EnterExtMode(); |
165 | | void LeaveExtMode(); |
166 | | void ToggleExtMode(); |
167 | 0 | bool IsExtMode() const { return m_bExtMode; } |
168 | | |
169 | | SW_DLLPUBLIC void EnterAddMode(); |
170 | | void LeaveAddMode(); |
171 | | void ToggleAddMode(); |
172 | 0 | bool IsAddMode() const { return m_bAddMode; } |
173 | | |
174 | | void EnterBlockMode(); |
175 | | void LeaveBlockMode(); |
176 | | void ToggleBlockMode(); |
177 | 0 | bool IsBlockMode() const { return m_bBlockMode; } |
178 | | |
179 | | void SetInsMode( bool bOn = true ); |
180 | 0 | void ToggleInsMode() { SetInsMode( !m_bIns ); } |
181 | 0 | bool IsInsMode() const { return m_bIns; } |
182 | | SW_DLLPUBLIC void SetRedlineFlagsAndCheckInsMode( RedlineFlags eMode, SfxRedlineRecordingMode eRedlineRecordingMode = SfxRedlineRecordingMode::ViewAgnostic); |
183 | | |
184 | | SW_DLLPUBLIC void EnterSelFrameMode(const Point *pStartDrag = nullptr); |
185 | | SW_DLLPUBLIC void LeaveSelFrameMode(); |
186 | 4.08k | bool IsSelFrameMode() const { return m_bLayoutMode; } |
187 | | // reset selection of frames |
188 | | SW_DLLPUBLIC void UnSelectFrame(); |
189 | | |
190 | | void Invalidate(); |
191 | | |
192 | | // select table cells for editing of formulas in the ribbonbar |
193 | | inline void SelTableCells( const Link<SwWrtShell&,void> &rLink ); |
194 | | inline void EndSelTableCells(); |
195 | | |
196 | | // leave per word or per line selection mode. Is usually called in MB-Up. |
197 | 0 | bool IsExtSel() const { return m_bSelWrd || m_bSelLn; } |
198 | | |
199 | | // query whether the active m_fnDrag pointer is set to BeginDrag |
200 | | // is needed for MouseMove to work around bugs 55592/55931 |
201 | | inline bool Is_FnDragEQBeginDrag() const; |
202 | | |
203 | | // base requests |
204 | | bool IsEndWrd(); |
205 | 0 | bool IsSttOfPara() const { return IsSttPara(); } |
206 | 0 | bool IsEndOfPara() const { return IsEndPara(); } |
207 | | |
208 | | // select word / sentence |
209 | | bool SelNearestWrd(); |
210 | | SW_DLLPUBLIC bool SelWrd(const Point * = nullptr, sal_Int16 nWordType = i18n::WordType::ANYWORD_IGNOREWHITESPACES ); |
211 | | // #i32329# Enhanced selection |
212 | | void SelSentence (const Point *); |
213 | | SW_DLLPUBLIC void SelPara (const Point *); |
214 | | SW_DLLPUBLIC void SelAll(); |
215 | | |
216 | | // basecursortravelling |
217 | | typedef bool (SwWrtShell::*FNSimpleMove)(); |
218 | | SW_DLLPUBLIC bool SimpleMove( FNSimpleMove, bool bSelect ); |
219 | | |
220 | | SW_DLLPUBLIC bool Left( SwCursorSkipMode nMode, bool bSelect, |
221 | | sal_uInt16 nCount, bool bBasicCall, bool bVisual = false ); |
222 | | SW_DLLPUBLIC bool Right( SwCursorSkipMode nMode, bool bSelect, |
223 | | sal_uInt16 nCount, bool bBasicCall, bool bVisual = false ); |
224 | | SW_DLLPUBLIC bool Up ( bool bSelect, sal_uInt16 nCount = 1, bool bBasicCall = false ); |
225 | | SW_DLLPUBLIC bool Down( bool bSelect, sal_uInt16 nCount = 1, bool bBasicCall = false ); |
226 | 0 | void NxtWrd ( bool bSelect = false ) { SimpleMove( &SwWrtShell::NxtWrd_, bSelect ); } |
227 | 0 | bool PrvWrd ( bool bSelect = false ) { return SimpleMove( &SwWrtShell::PrvWrd_, bSelect ); } |
228 | | |
229 | | bool LeftMargin ( bool bSelect, bool bBasicCall ); |
230 | | SW_DLLPUBLIC bool RightMargin( bool bSelect, bool bBasicCall ); |
231 | | |
232 | | SW_DLLPUBLIC bool StartOfSection( bool bSelect = false ); |
233 | | SW_DLLPUBLIC bool EndOfSection ( bool bSelect = false ); |
234 | | |
235 | | SW_DLLPUBLIC bool SttNxtPg ( bool bSelect = false ); |
236 | | void SttPrvPg ( bool bSelect = false ); |
237 | | void EndNxtPg ( bool bSelect = false ); |
238 | | SW_DLLPUBLIC bool EndPrvPg ( bool bSelect = false ); |
239 | | SW_DLLPUBLIC bool SttPg ( bool bSelect = false ); |
240 | | SW_DLLPUBLIC bool EndPg ( bool bSelect = false ); |
241 | | SW_DLLPUBLIC bool SttPara ( bool bSelect = false ); |
242 | | SW_DLLPUBLIC void EndPara ( bool bSelect = false ); |
243 | | bool FwdPara () |
244 | 0 | { return SimpleMove( &SwWrtShell::FwdPara_, false/*bSelect*/ ); } |
245 | | void BwdPara () |
246 | 0 | { SimpleMove( &SwWrtShell::BwdPara_, false/*bSelect*/ ); } |
247 | | void FwdSentence( bool bSelect = false ) |
248 | 0 | { SimpleMove( &SwWrtShell::FwdSentence_, bSelect ); } |
249 | | void BwdSentence( bool bSelect = false ) |
250 | 0 | { SimpleMove( &SwWrtShell::BwdSentence_, bSelect ); } |
251 | | |
252 | | // #i20126# Enhanced table selection |
253 | | SW_DLLPUBLIC bool SelectTableRowCol( const Point& rPt, const Point* pEnd = nullptr, bool bRowDrag = false ); |
254 | | void SelectTableRow(); |
255 | | void SelectTableCol(); |
256 | | void SelectTableCell(); |
257 | | |
258 | | SW_DLLPUBLIC bool SelectTextAttr( sal_uInt16 nWhich, const SwTextAttr* pAttr = nullptr ); |
259 | | |
260 | | // per column jumps |
261 | | void StartOfColumn (); |
262 | | void EndOfColumn (); |
263 | | void StartOfNextColumn (); |
264 | | void EndOfNextColumn (); |
265 | | void StartOfPrevColumn (); |
266 | | void EndOfPrevColumn (); |
267 | | |
268 | | // set the cursor to page "nPage" at the beginning |
269 | | // additionally to an identically named implementation in crsrsh.hxx |
270 | | // here all existing selections are being reset before setting the |
271 | | // cursor |
272 | | SW_DLLPUBLIC bool GotoPage( sal_uInt16 nPage, bool bRecord ); |
273 | | |
274 | | // setting the cursor; remember the old position for turning back |
275 | | DECL_LINK( ExecFlyMac, const SwFlyFrameFormat*, void ); |
276 | | |
277 | | bool PageCursor(SwTwips lOffset, bool bSelect); |
278 | | |
279 | | // update fields |
280 | | void UpdateInputFields( SwInputFieldList* pLst = nullptr ); |
281 | | |
282 | | void NoEdit(bool bHideCursor = true); |
283 | | void Edit(); |
284 | | |
285 | 0 | bool IsRetainSelection() const { return m_bRetainSelection; } |
286 | 0 | void SetRetainSelection( bool bRet ) { m_bRetainSelection = bRet; } |
287 | | |
288 | | // change current data base and notify |
289 | | SW_DLLPUBLIC void ChgDBData(const SwDBData& SwDBData); |
290 | | |
291 | | // delete |
292 | | void DelToEndOfLine(); |
293 | | SW_DLLPUBLIC void DelToStartOfLine(); |
294 | | SW_DLLPUBLIC void DelLine(); |
295 | | SW_DLLPUBLIC bool DelLeft(); |
296 | | |
297 | | // also deletes the frame or sets the cursor in the frame when bDelFrame == false |
298 | | SW_DLLPUBLIC bool DelRight(bool isReplaceHeuristic = false); |
299 | | SW_DLLPUBLIC void DelToEndOfPara(); |
300 | | void DelToStartOfPara(); |
301 | | SW_DLLPUBLIC bool DelToEndOfSentence(); |
302 | | void DelToStartOfSentence(); |
303 | | void DelNxtWord(); |
304 | | void DelPrvWord(); |
305 | | |
306 | | // checks whether a word selection exists. |
307 | | // According to the rules for intelligent Cut / Paste |
308 | | // surrounding spaces are cut out. |
309 | | // returns type of word selection (see enum) |
310 | | enum word { |
311 | | NO_WORD = 0, |
312 | | WORD_SPACE_BEFORE = 1, |
313 | | WORD_SPACE_AFTER = 2, |
314 | | WORD_NO_SPACE = 3 |
315 | | }; |
316 | | int IntelligentCut(SelectionType nSelectionType, bool bCut = true); |
317 | | |
318 | | // edit |
319 | | bool InsertField2Impl(SwField const &, SwPaM* pAnnotationRange, |
320 | | ::std::optional<SwPosition> *const poAnchorStart); |
321 | | SW_DLLPUBLIC bool InsertField2(SwField const &, SwPaM* pAnnotationRange = nullptr, |
322 | | ::std::optional<SwPosition> *const poAnchorStart = nullptr); |
323 | | SW_DLLPUBLIC void Insert(const OUString &); |
324 | | // graphic |
325 | | void InsertGraphic( const OUString &rPath, const OUString &rFilter, |
326 | | const Graphic &, SwFlyFrameAttrMgr * = nullptr, |
327 | | RndStdIds nAnchorType = RndStdIds::FLY_AT_PARA); |
328 | | |
329 | | void InsertByWord( const OUString & ); |
330 | | SW_DLLPUBLIC void InsertPageBreak(const UIName *pPageDesc = nullptr, const ::std::optional<sal_uInt16>& rPgNum = std::nullopt); |
331 | | void InsertEnclosingChars(const OUString& sStartStr, const OUString& sEndStr); |
332 | | SW_DLLPUBLIC void InsertLineBreak(std::optional<SwLineBreakClear> oClear = std::nullopt); |
333 | | void InsertColumnBreak(); |
334 | | SW_DLLPUBLIC void InsertContentControl(SwContentControlType eType); |
335 | | SW_DLLPUBLIC void InsertFootnote(const OUString &, bool bEndNote = false, bool bEdit = true ); |
336 | | SW_DLLPUBLIC void SplitNode( bool bAutoFormat = false ); |
337 | | bool CanInsert(); |
338 | | |
339 | | // indexes |
340 | | void InsertTableOf(const SwTOXBase& rTOX, const SfxItemSet* pSet = nullptr); |
341 | | SW_DLLPUBLIC void UpdateTableOf(const SwTOXBase& rTOX, const SfxItemSet* pSet = nullptr); |
342 | | |
343 | | // numbering and bullets |
344 | | /** |
345 | | Turns on numbering or bullets. |
346 | | |
347 | | @param bNum true: turn on numbering |
348 | | false: turn on bullets |
349 | | */ |
350 | | void NumOrBulletOn(bool bNum); // #i29560# |
351 | | void NumOrBulletOff(); // #i29560# |
352 | | SW_DLLPUBLIC void NumOn(); |
353 | | SW_DLLPUBLIC void BulletOn(); |
354 | | |
355 | | //OLE |
356 | | SW_DLLPUBLIC void InsertObject( /*SvInPlaceObjectRef *pObj, */ // != 0 for clipboard |
357 | | const svt::EmbeddedObjectRef&, |
358 | | SvGlobalName const *pName, // != 0 create object accordingly |
359 | | sal_uInt16 nSlotId = 0); // SlotId for dialog |
360 | | |
361 | | bool InsertOleObject( const svt::EmbeddedObjectRef& xObj, SwFlyFrameFormat **pFlyFrameFormat = nullptr ); |
362 | | SW_DLLPUBLIC void LaunchOLEObj(sal_Int32 nVerb = css::embed::EmbedVerbs::MS_OLEVERB_PRIMARY); // start server |
363 | | bool IsOLEMath(); |
364 | | virtual void MoveObjectIfActive( svt::EmbeddedObjectRef& xObj, const Point& rOffset ) override; |
365 | | virtual void CalcAndSetScale( svt::EmbeddedObjectRef& xObj, |
366 | | const SwRect *pFlyPrtRect = nullptr, |
367 | | const SwRect *pFlyFrameRect = nullptr, |
368 | | const bool bNoTextFramePrtAreaChanged = false ) override; |
369 | | virtual void ConnectObj( svt::EmbeddedObjectRef& xIPObj, const SwRect &rPrt, |
370 | | const SwRect &rFrame ) override; |
371 | | |
372 | | // styles and formats |
373 | | |
374 | | // enum tells when should happen when the style was not found |
375 | | enum GetStyle { GETSTYLE_NOCREATE, // create none |
376 | | GETSTYLE_CREATESOME, // if on PoolId create mapt |
377 | | GETSTYLE_CREATEANY }; // return standard if applicable |
378 | | |
379 | | SW_DLLPUBLIC SwTextFormatColl* GetParaStyle(const UIName &rCollName, |
380 | | GetStyle eCreate = GETSTYLE_NOCREATE); |
381 | | SW_DLLPUBLIC SwCharFormat* GetCharStyle(const UIName &rFormatName, |
382 | | GetStyle eCreate = GETSTYLE_NOCREATE); |
383 | | SW_DLLPUBLIC SwFrameFormat* GetTableStyle(const UIName& rFormatName); |
384 | | |
385 | | void SetPageStyle(const UIName &rCollName); |
386 | | |
387 | | SW_DLLPUBLIC UIName const & GetCurPageStyle() const; |
388 | | |
389 | | // change current style using the attributes in effect |
390 | | void QuickUpdateStyle(); |
391 | | |
392 | | enum DoType { UNDO, REDO, REPEAT }; |
393 | | |
394 | | enum class FieldDialogPressedButton { NONE, Previous, Next }; |
395 | | |
396 | | SW_DLLPUBLIC void Do(DoType eDoType, sal_uInt16 nCnt = 1, sal_uInt16 nOffset = 0); |
397 | | OUString GetDoString( DoType eDoType ) const; |
398 | | OUString GetRepeatString() const; |
399 | | void GetDoStrings( DoType eDoType, SfxStringListItem& rStrLstItem ) const; |
400 | | |
401 | | // search and replace |
402 | | SW_DLLPUBLIC sal_Int32 SearchPattern(const i18nutil::SearchOptions2& rSearchOpt, |
403 | | bool bSearchInNotes, |
404 | | SwDocPositions eStart, SwDocPositions eEnd, |
405 | | FindRanges eFlags = FindRanges::InBody, |
406 | | bool bReplace = false ); |
407 | | |
408 | | sal_Int32 SearchTempl (const UIName &rTempl, |
409 | | SwDocPositions eStart, SwDocPositions eEnd, |
410 | | FindRanges eFlags = FindRanges::InBody, |
411 | | const UIName* pReplTempl = nullptr ); |
412 | | |
413 | | sal_Int32 SearchAttr (const SfxItemSet& rFindSet, |
414 | | bool bNoColls, |
415 | | SwDocPositions eStart, SwDocPositions eEnd, |
416 | | FindRanges eFlags = FindRanges::InBody, |
417 | | const i18nutil::SearchOptions2* pSearchOpt = nullptr, |
418 | | const SfxItemSet* pReplaceSet = nullptr); |
419 | | |
420 | | SW_DLLPUBLIC void AutoCorrect( SvxAutoCorrect& rACorr, sal_Unicode cChar ); |
421 | | |
422 | | // action ahead of cursor movement |
423 | | // resets selection if applicable, triggers timer and GCAttr() |
424 | | void MoveCursor( bool bWithSelect = false ); |
425 | | |
426 | | // update input fields |
427 | | bool StartInputFieldDlg(SwField*, bool bPrevButton, bool bNextButton, weld::Widget* pParentWin, FieldDialogPressedButton* pPressedButton = nullptr); |
428 | | // update DropDown fields |
429 | | bool StartDropDownFieldDlg(SwField*, bool bPrevButton, bool bNextButton, weld::Widget* pParentWin, FieldDialogPressedButton* pPressedButton = nullptr); |
430 | | // update single DropDown field |
431 | | void EditDropDownFieldDlg(SwField*, weld::Widget* pParentWin); |
432 | | |
433 | | //"Handler" for changes at DrawView - for controls. |
434 | | virtual void DrawSelChanged( ) override; |
435 | | |
436 | | // jump to bookmark and set the "selections-flags" correctly again |
437 | | SW_DLLPUBLIC void GotoMark( const ::sw::mark::MarkBase* const pMark ); |
438 | | bool GotoMark( const ::sw::mark::MarkBase* const pMark, bool bSelect ); |
439 | | SW_DLLPUBLIC void GotoMark( const SwMarkName& rName ); |
440 | | SW_DLLPUBLIC bool GoNextBookmark(); // true when there still was one |
441 | | bool GoPrevBookmark(); |
442 | | |
443 | | bool GotoFieldmark(::sw::mark::Fieldmark const * const pMark); |
444 | | |
445 | | SW_DLLPUBLIC bool GotoField( const SwFormatField& rField ); |
446 | | |
447 | | /** @param bOnlyRefresh: |
448 | | * false: run default actions (e.g. toggle checkbox, remove placeholder content) |
449 | | * true: do not alter the content control, just refresh the doc model |
450 | | */ |
451 | | SW_DLLPUBLIC bool GotoContentControl(const SwFormatContentControl& rContentControl, |
452 | | bool bOnlyRefresh = false); |
453 | | |
454 | | // jump to the next / previous hyperlink - inside text and also |
455 | | // on graphics |
456 | | void SelectNextPrevHyperlink( bool bNext ); |
457 | | |
458 | | // determine corresponding SwView |
459 | 14.9k | const SwView& GetView() const { return m_rView; } |
460 | 16.4k | SwView& GetView() { return m_rView; } |
461 | | |
462 | | // Because nobody else is doing it, here is an ExecMacro() |
463 | | void ExecMacro( const SvxMacro& rMacro, OUString* pRet = nullptr, SbxArray* pArgs = nullptr ); |
464 | | // call into the dark Basic/JavaScript |
465 | | sal_uInt16 CallEvent( SvMacroItemId nEvent, const SwCallMouseEvent& rCallEvent, |
466 | | bool bCheckPtr = false ); |
467 | | |
468 | | // a click at the given field. the cursor is on it. |
469 | | // execute the predefined actions. |
470 | | void ClickToField( const SwField& rField, bool bExecHyperlinks ); |
471 | | void ClickToINetAttr( const SwFormatINetFormat& rItem, LoadUrlFlags nFilter = LoadUrlFlags::NONE ); |
472 | | bool ClickToINetGrf( const Point& rDocPt, LoadUrlFlags nFilter ); |
473 | | inline bool IsInClickToEdit() const ; |
474 | | |
475 | | // if a URL-Button is selected, return its URL; otherwise an empty string |
476 | | bool GetURLFromButton( OUString& rURL, OUString& rDescr ) const; |
477 | | |
478 | | void NavigatorPaste(const NaviContentBookmark& rBkmk); |
479 | | |
480 | | SW_DLLPUBLIC virtual void ApplyViewOptions( const SwViewOption &rOpt ) override; |
481 | | SW_DLLPUBLIC virtual void SetReadonlyOption( bool bSet ) override; |
482 | | |
483 | | // automatic update of styles |
484 | | void AutoUpdateFrame(SwFrameFormat* pFormat, const SfxItemSet& rStyleSet); |
485 | | void AutoUpdatePara(SwTextFormatColl* pColl, const SfxItemSet& rStyleSet, SwPaM* pPaM = nullptr ); |
486 | | |
487 | | // starts dialog for inserting ranges via Drag&Drop/Clipboard |
488 | | void StartInsertRegionDialog(const SwSectionData&); |
489 | | |
490 | | // ctor, the first one is a kind of a controlled copy ctor for more views of a document |
491 | | SwWrtShell( SwWrtShell&, vcl::Window *pWin, SwView &rShell); |
492 | | SwWrtShell( SwDoc& rDoc, vcl::Window *pWin, SwView &rShell, |
493 | | const SwViewOption *pViewOpt); |
494 | | virtual ~SwWrtShell() override; |
495 | | |
496 | | SW_DLLPUBLIC virtual SwPostItMgr* GetPostItMgr() override; |
497 | | |
498 | | SW_DLLPUBLIC bool TryRemoveIndent(); // #i23725# |
499 | | |
500 | | OUString GetSelDescr() const; |
501 | | |
502 | 0 | SwNavigationMgr& GetNavigationMgr() { return m_aNavigationMgr; } |
503 | | |
504 | | void addCurrentPosition(); |
505 | | SW_DLLPUBLIC bool GotoFly( const UIName& rName, FlyCntType eType = FLYCNTTYPE_ALL, |
506 | | bool bSelFrame = true ); |
507 | | bool GotoINetAttr( const SwTextINetFormat& rAttr ); |
508 | | void GotoOutline( SwOutlineNodes::size_type nIdx ); |
509 | | bool GotoOutline( const OUString& rName ); |
510 | | bool GotoRegion( std::u16string_view rName ); |
511 | | bool GotoRefMark( const SwMarkName& rRefMark, ReferencesSubtype nSubType = ReferencesSubtype::SetRefAttr, |
512 | | sal_uInt16 nSeqNo = 0, sal_uInt16 nFlags = 0 ); |
513 | | SW_DLLPUBLIC bool GotoNextTOXBase( const UIName* pName = nullptr); |
514 | | SW_DLLPUBLIC bool GotoTable( const UIName& rName ); |
515 | | void GotoFormatField( const SwFormatField& rField ); |
516 | | const SwRangeRedline* GotoRedline( SwRedlineTable::size_type nArrPos, bool bSelect); |
517 | | bool GotoDrawingObject(const SdrObject *pObj); |
518 | | SW_DLLPUBLIC bool GotoDrawingObject(std::u16string_view rName); |
519 | | void GotoFootnoteAnchor(const SwTextFootnote& rTextFootnote); |
520 | | SW_DLLPUBLIC void ChangeHeaderOrFooter(const UIName& rStyleName, bool bHeader, bool bOn, bool bShowWarning); |
521 | | virtual void SetShowHeaderFooterSeparator( FrameControlType eControl, bool bShow ) override; |
522 | | |
523 | | /// Inserts a new annotation/comment at the current cursor position / selection. |
524 | | void InsertPostIt(SwFieldMgr& rFieldMgr, const SfxRequest& rReq); |
525 | | |
526 | | bool IsOutlineContentVisible(const size_t nPos); |
527 | | void MakeOutlineContentVisible(const size_t nPos, bool bMakeVisible = true, bool bSetAttrOutlineVisibility = true); |
528 | | SW_DLLPUBLIC void MakeAllFoldedOutlineContentVisible(bool bMakeVisible = true); |
529 | | void InvalidateOutlineContentVisibility(); |
530 | | bool GetAttrOutlineContentVisible(const size_t nPos) const; |
531 | | |
532 | | void MakeOutlineLevelsVisible(const int nLevel); |
533 | | |
534 | | bool HasFoldedOutlineContentSelected() const; |
535 | | virtual void InfoReadOnlyDialog(bool bAsync) const override; |
536 | | virtual bool WarnHiddenSectionDialog() const override; |
537 | | virtual bool WarnSwitchToDesignModeDialog() const override; |
538 | 0 | void SetEnteringStdMode(bool bEnteringStdMode) { m_bEnteringStdMode = bEnteringStdMode; } |
539 | 0 | bool IsEnteringStdMode() const { return m_bEnteringStdMode; } |
540 | | |
541 | | SW_DLLPUBLIC std::optional<OString> getLOKPayload(int nType, int nViewId) const; |
542 | | |
543 | | void SortChapters(const SwOutlineNodes::size_type nOutlineNodePos = SwOutlineNodes::npos); |
544 | | |
545 | | private: |
546 | | |
547 | | void OpenMark(); |
548 | | void CloseMark( bool bOkFlag ); |
549 | | |
550 | | struct ModeStack |
551 | | { |
552 | | ModeStack *pNext; |
553 | | bool bAdd, |
554 | | bBlock, |
555 | | bExt, |
556 | | bIns; |
557 | | ModeStack(ModeStack *pNextMode, bool _bIns, bool _bExt, bool _bAdd, bool _bBlock): |
558 | 0 | pNext(pNextMode), |
559 | 0 | bAdd(_bAdd), |
560 | 0 | bBlock(_bBlock), |
561 | 0 | bExt(_bExt), |
562 | 0 | bIns(_bIns) |
563 | 0 | {} |
564 | | } *m_pModeStack = nullptr; |
565 | | |
566 | | // carry cursor along when PageUp / -Down |
567 | | enum PageMove |
568 | | { |
569 | | MV_NO, |
570 | | MV_PAGE_UP, |
571 | | MV_PAGE_DOWN |
572 | | } m_ePageMove = MV_NO; |
573 | | |
574 | | struct CursorStack |
575 | | { |
576 | | Point aDocPos; |
577 | | std::unique_ptr<CursorStack> pNext; |
578 | | bool bValidCurPos : 1; |
579 | | bool bIsFrameSel : 1; |
580 | | SwTwips lOffset; |
581 | | |
582 | | CursorStack( bool bValid, bool bFrameSel, const Point &rDocPos, |
583 | | SwTwips lOff, std::unique_ptr<CursorStack> pN ) |
584 | 0 | : aDocPos(rDocPos), |
585 | 0 | pNext(std::move(pN)), |
586 | 0 | bValidCurPos( bValid ), |
587 | 0 | bIsFrameSel( bFrameSel ), |
588 | 0 | lOffset(lOff) |
589 | 0 | { |
590 | 0 | } |
591 | | |
592 | | }; |
593 | | std::unique_ptr<CursorStack> m_pCursorStack; |
594 | | |
595 | | SwView &m_rView; |
596 | | SwNavigationMgr m_aNavigationMgr; |
597 | | |
598 | | Point m_aDest; |
599 | | bool m_bDestOnStack = false; |
600 | 1 | bool HasCursorStack() const { return nullptr != m_pCursorStack; } |
601 | | bool PushCursor(SwTwips lOffset, bool bSelect); |
602 | | bool PopCursor(bool bUpdate, bool bSelect = false); |
603 | | |
604 | | // take END cursor along when PageUp / -Down |
605 | | void SttWrd(); |
606 | | void EndWrd(); |
607 | | bool NxtWrd_(); |
608 | | bool PrvWrd_(); |
609 | | // #i92468# |
610 | | bool NxtWrdForDelete(); |
611 | | bool PrvWrdForDelete(); |
612 | | bool FwdSentence_(); |
613 | | bool BwdSentence_(); |
614 | | SW_DLLPUBLIC bool FwdPara_(); |
615 | | bool BwdPara_(); |
616 | | |
617 | | // selections |
618 | | bool m_bIns :1; |
619 | | bool m_bInSelect :1; |
620 | | bool m_bExtMode :1; |
621 | | bool m_bAddMode :1; |
622 | | bool m_bBlockMode :1; |
623 | | bool m_bLayoutMode :1; |
624 | | bool m_bSelWrd :1; |
625 | | bool m_bSelLn :1; |
626 | | bool m_bIsInClickToEdit:1; |
627 | | bool m_bClearMark :1; // don't delete selection for ChartAutoPilot |
628 | | bool m_bRetainSelection :1; // Do not remove selections |
629 | | bool m_bEnteringStdMode = false; |
630 | | |
631 | | Point m_aStart; |
632 | | Link<SwWrtShell&,void> m_aSelTableLink; |
633 | | |
634 | | // resets the cursor stack after movement by PageUp/-Down |
635 | | void ResetCursorStack_(); |
636 | | |
637 | | using SwCursorShell::SetCursor; |
638 | | tools::Long SetCursor(const Point *, bool bProp=false, |
639 | | ScrollSizeMode eScrollSizeMode = ScrollSizeMode::ScrollSizeDefault ); |
640 | | |
641 | | tools::Long SetCursorKillSel(const Point *, bool bProp, |
642 | | ScrollSizeMode eScrollSizeMode = ScrollSizeMode::ScrollSizeDefault ); |
643 | | |
644 | | void BeginDrag(const Point *, bool bProp ); |
645 | | void DefaultDrag(const Point *, bool bProp ); |
646 | | void DefaultEndDrag(const Point *, bool bProp ); |
647 | | |
648 | | void ExtSelWrd(const Point *, bool bProp ); |
649 | | void ExtSelLn(const Point *, bool bProp ); |
650 | | |
651 | | void BeginFrameDrag(const Point *, bool bProp ); |
652 | | |
653 | | // after SSize/Move of a frame update; Point is destination. |
654 | | void UpdateLayoutFrame(const Point *, bool bProp ); |
655 | | |
656 | | void SttLeaveSelect(); |
657 | | void AddLeaveSelect(); |
658 | | tools::Long Ignore(const Point *, bool bProp, ScrollSizeMode eScrollSizeMode = ScrollSizeMode::ScrollSizeDefault ); |
659 | | |
660 | 0 | void LeaveExtSel() { m_bSelWrd = m_bSelLn = false;} |
661 | | |
662 | | bool GoStart(bool KeepArea, bool *, |
663 | | bool bSelect, bool bDontMoveRegion = false); |
664 | | bool GoEnd(bool KeepArea = false, const bool * = nullptr); |
665 | | |
666 | | SAL_DLLPRIVATE void ImplSetInsMode(bool bOn); |
667 | | |
668 | | enum BookMarkMove |
669 | | { |
670 | | BOOKMARK_INDEX, |
671 | | BOOKMARK_NEXT, |
672 | | BOOKMARK_PREV |
673 | | }; |
674 | | |
675 | | bool MoveBookMark(BookMarkMove eFuncId, const ::sw::mark::MarkBase* const pMark=nullptr); |
676 | | }; |
677 | | |
678 | | inline void SwWrtShell::ResetCursorStack() |
679 | 1 | { |
680 | 1 | if ( HasCursorStack() ) |
681 | 0 | ResetCursorStack_(); |
682 | 1 | } |
683 | | |
684 | | inline void SwWrtShell::SelTableCells(const Link<SwWrtShell&,void> &rLink ) |
685 | 0 | { |
686 | 0 | SetSelTableCells( true ); |
687 | 0 | m_bClearMark = true; |
688 | 0 | m_aSelTableLink = rLink; |
689 | 0 | } |
690 | | inline void SwWrtShell::EndSelTableCells() |
691 | 0 | { |
692 | 0 | SetSelTableCells( false ); |
693 | 0 | m_bClearMark = true; |
694 | 0 | } |
695 | | |
696 | 0 | inline bool SwWrtShell::IsInClickToEdit() const { return m_bIsInClickToEdit; } |
697 | | |
698 | | inline bool SwWrtShell::Is_FnDragEQBeginDrag() const |
699 | 0 | { |
700 | 0 | #ifdef __GNUC__ |
701 | 0 | SELECTFUNC2 fnTmp = &SwWrtShell::BeginDrag; |
702 | 0 | return m_fnDrag == fnTmp; |
703 | | #else |
704 | | return m_fnDrag == &SwWrtShell::BeginDrag; |
705 | | #endif |
706 | 0 | } |
707 | | |
708 | | class SW_DLLPUBLIC MakeAllOutlineContentTemporarilyVisible |
709 | | { |
710 | | private: |
711 | | SwWrtShell* m_pWrtSh = nullptr; |
712 | | bool m_bDone = false; |
713 | | bool m_bScrollToCursor = false; |
714 | | public: |
715 | | static sal_uInt32 nLock; |
716 | | MakeAllOutlineContentTemporarilyVisible(SwDoc* pDoc, bool bScrollToCursor = false) |
717 | 0 | { |
718 | 0 | ++nLock; |
719 | 0 | if (nLock > 1) |
720 | 0 | return; |
721 | 0 | if (SwDocShell* pDocSh = pDoc->GetDocShell()) |
722 | 0 | if ((m_pWrtSh = pDocSh->GetWrtShell()) && m_pWrtSh->GetViewOptions() && |
723 | 0 | m_pWrtSh->GetViewOptions()->IsShowOutlineContentVisibilityButton()) |
724 | 0 | { |
725 | 0 | m_pWrtSh->LockView(true); |
726 | 0 | m_pWrtSh->LockPaint(LockPaintReason::OutlineFolding); |
727 | 0 | m_pWrtSh->MakeAllFoldedOutlineContentVisible(); |
728 | 0 | m_bScrollToCursor = bScrollToCursor; |
729 | 0 | m_bDone = true; |
730 | 0 | } |
731 | 0 | } |
732 | | |
733 | | ~MakeAllOutlineContentTemporarilyVisible() COVERITY_NOEXCEPT_FALSE |
734 | 0 | { |
735 | 0 | --nLock; |
736 | 0 | if (nLock > 0) |
737 | 0 | return; |
738 | 0 | if (m_bDone && m_pWrtSh) |
739 | 0 | { |
740 | 0 | m_pWrtSh->MakeAllFoldedOutlineContentVisible(false); |
741 | 0 | m_pWrtSh->UnlockPaint(); |
742 | 0 | m_pWrtSh->LockView(false); |
743 | 0 | if (m_bScrollToCursor) |
744 | 0 | m_pWrtSh->UpdateCursor(SwCursorShell::SCROLLWIN); |
745 | 0 | } |
746 | 0 | } |
747 | | }; |
748 | | |
749 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |