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.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
CallSetCursor(const Point * pPt,bool bProp,ScrollSizeMode eScrollSizeMode=ScrollSizeMode::ScrollSizeDefault)123 tools::Long CallSetCursor(const Point* pPt, bool bProp,
124 ScrollSizeMode eScrollSizeMode = ScrollSizeMode::ScrollSizeDefault)
125 { return (this->*m_fnSetCursor)(pPt, bProp, eScrollSizeMode); }
Drag(const Point * pPt,bool bProp)126 void Drag (const Point* pPt, bool bProp) { (this->*m_fnDrag)(pPt, bProp); }
EndDrag(const Point * pPt,bool bProp)127 void EndDrag (const Point* pPt, bool bProp) { (this->*m_fnEndDrag)(pPt, bProp); }
KillSelection(const Point * pPt,bool bProp,ScrollSizeMode eScrollSizeMode=ScrollSizeMode::ScrollSizeDefault)128 tools::Long KillSelection(const Point* pPt, bool bProp,
129 ScrollSizeMode eScrollSizeMode = ScrollSizeMode::ScrollSizeDefault)
130 { 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
IsModePushed() const145 bool IsModePushed() const { return nullptr != m_pModeStack; }
146 void PushMode();
147 void PopMode();
148
149 void SttSelect();
150 SW_DLLPUBLIC void EndSelect();
IsInSelect() const151 bool IsInSelect() const { return m_bInSelect; }
SetInSelect()152 void SetInSelect() { m_bInSelect = true; }
153 // is there a text- or frameselection?
HasSelection() const154 bool HasSelection() const { return SwCursorShell::HasSelection() ||
155 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();
IsStdMode() const160 bool IsStdMode() const { return !m_bExtMode && !m_bAddMode && !m_bBlockMode; }
161
162 void AssureStdMode();
163
164 void EnterExtMode();
165 void LeaveExtMode();
166 void ToggleExtMode();
IsExtMode() const167 bool IsExtMode() const { return m_bExtMode; }
168
169 void EnterAddMode();
170 void LeaveAddMode();
171 void ToggleAddMode();
IsAddMode() const172 bool IsAddMode() const { return m_bAddMode; }
173
174 void EnterBlockMode();
175 void LeaveBlockMode();
176 void ToggleBlockMode();
IsBlockMode() const177 bool IsBlockMode() const { return m_bBlockMode; }
178
179 void SetInsMode( bool bOn = true );
ToggleInsMode()180 void ToggleInsMode() { SetInsMode( !m_bIns ); }
IsInsMode() const181 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();
IsSelFrameMode() const186 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.
IsExtSel() const197 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();
IsSttOfPara() const205 bool IsSttOfPara() const { return IsSttPara(); }
IsEndOfPara() const206 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 );
NxtWrd(bool bSelect=false)226 void NxtWrd ( bool bSelect = false ) { SimpleMove( &SwWrtShell::NxtWrd_, bSelect ); }
PrvWrd(bool bSelect=false)227 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 );
FwdPara()243 bool FwdPara ()
244 { return SimpleMove( &SwWrtShell::FwdPara_, false/*bSelect*/ ); }
BwdPara()245 void BwdPara ()
246 { SimpleMove( &SwWrtShell::BwdPara_, false/*bSelect*/ ); }
FwdSentence(bool bSelect=false)247 void FwdSentence( bool bSelect = false )
248 { SimpleMove( &SwWrtShell::FwdSentence_, bSelect ); }
BwdSentence(bool bSelect=false)249 void BwdSentence( bool bSelect = false )
250 { 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
IsRetainSelection() const285 bool IsRetainSelection() const { return m_bRetainSelection; }
SetRetainSelection(bool bRet)286 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 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 virtual void MoveObjectIfActive( svt::EmbeddedObjectRef& xObj, const Point& rOffset ) override;
364 virtual void CalcAndSetScale( svt::EmbeddedObjectRef& xObj,
365 const SwRect *pFlyPrtRect = nullptr,
366 const SwRect *pFlyFrameRect = nullptr,
367 const bool bNoTextFramePrtAreaChanged = false ) override;
368 virtual void ConnectObj( svt::EmbeddedObjectRef& xIPObj, const SwRect &rPrt,
369 const SwRect &rFrame ) override;
370
371 // styles and formats
372
373 // enum tells when should happen when the style was not found
374 enum GetStyle { GETSTYLE_NOCREATE, // create none
375 GETSTYLE_CREATESOME, // if on PoolId create mapt
376 GETSTYLE_CREATEANY }; // return standard if applicable
377
378 SW_DLLPUBLIC SwTextFormatColl* GetParaStyle(const UIName &rCollName,
379 GetStyle eCreate = GETSTYLE_NOCREATE);
380 SW_DLLPUBLIC SwCharFormat* GetCharStyle(const UIName &rFormatName,
381 GetStyle eCreate = GETSTYLE_NOCREATE);
382 SW_DLLPUBLIC SwFrameFormat* GetTableStyle(const UIName& rFormatName);
383
384 void SetPageStyle(const UIName &rCollName);
385
386 SW_DLLPUBLIC UIName const & GetCurPageStyle() const;
387
388 // change current style using the attributes in effect
389 void QuickUpdateStyle();
390
391 enum DoType { UNDO, REDO, REPEAT };
392
393 enum class FieldDialogPressedButton { NONE, Previous, Next };
394
395 void Do(DoType eDoType, sal_uInt16 nCnt = 1, sal_uInt16 nOffset = 0);
396 OUString GetDoString( DoType eDoType ) const;
397 OUString GetRepeatString() const;
398 void GetDoStrings( DoType eDoType, SfxStringListItem& rStrLstItem ) const;
399
400 // search and replace
401 SW_DLLPUBLIC sal_Int32 SearchPattern(const i18nutil::SearchOptions2& rSearchOpt,
402 bool bSearchInNotes,
403 SwDocPositions eStart, SwDocPositions eEnd,
404 FindRanges eFlags = FindRanges::InBody,
405 bool bReplace = false );
406
407 sal_Int32 SearchTempl (const UIName &rTempl,
408 SwDocPositions eStart, SwDocPositions eEnd,
409 FindRanges eFlags = FindRanges::InBody,
410 const UIName* pReplTempl = nullptr );
411
412 sal_Int32 SearchAttr (const SfxItemSet& rFindSet,
413 bool bNoColls,
414 SwDocPositions eStart, SwDocPositions eEnd,
415 FindRanges eFlags = FindRanges::InBody,
416 const i18nutil::SearchOptions2* pSearchOpt = nullptr,
417 const SfxItemSet* pReplaceSet = nullptr);
418
419 SW_DLLPUBLIC void AutoCorrect( SvxAutoCorrect& rACorr, sal_Unicode cChar );
420
421 // action ahead of cursor movement
422 // resets selection if applicable, triggers timer and GCAttr()
423 void MoveCursor( bool bWithSelect = false );
424
425 // update input fields
426 bool StartInputFieldDlg(SwField*, bool bPrevButton, bool bNextButton, weld::Widget* pParentWin, FieldDialogPressedButton* pPressedButton = nullptr);
427 // update DropDown fields
428 bool StartDropDownFieldDlg(SwField*, bool bPrevButton, bool bNextButton, weld::Widget* pParentWin, FieldDialogPressedButton* pPressedButton = nullptr);
429
430 //"Handler" for changes at DrawView - for controls.
431 virtual void DrawSelChanged( ) override;
432
433 // jump to bookmark and set the "selections-flags" correctly again
434 SW_DLLPUBLIC void GotoMark( const ::sw::mark::MarkBase* const pMark );
435 bool GotoMark( const ::sw::mark::MarkBase* const pMark, bool bSelect );
436 SW_DLLPUBLIC void GotoMark( const SwMarkName& rName );
437 bool GoNextBookmark(); // true when there still was one
438 bool GoPrevBookmark();
439
440 bool GotoFieldmark(::sw::mark::Fieldmark const * const pMark);
441
442 SW_DLLPUBLIC bool GotoField( const SwFormatField& rField );
443
444 /** @param bOnlyRefresh:
445 * false: run default actions (e.g. toggle checkbox, remove placeholder content)
446 * true: do not alter the content control, just refresh the doc model
447 */
448 SW_DLLPUBLIC bool GotoContentControl(const SwFormatContentControl& rContentControl,
449 bool bOnlyRefresh = false);
450
451 // jump to the next / previous hyperlink - inside text and also
452 // on graphics
453 void SelectNextPrevHyperlink( bool bNext );
454
455 // determine corresponding SwView
GetView() const456 const SwView& GetView() const { return m_rView; }
GetView()457 SwView& GetView() { return m_rView; }
458
459 // Because nobody else is doing it, here is an ExecMacro()
460 void ExecMacro( const SvxMacro& rMacro, OUString* pRet = nullptr, SbxArray* pArgs = nullptr );
461 // call into the dark Basic/JavaScript
462 sal_uInt16 CallEvent( SvMacroItemId nEvent, const SwCallMouseEvent& rCallEvent,
463 bool bCheckPtr = false );
464
465 // a click at the given field. the cursor is on it.
466 // execute the predefined actions.
467 void ClickToField( const SwField& rField, bool bExecHyperlinks );
468 void ClickToINetAttr( const SwFormatINetFormat& rItem, LoadUrlFlags nFilter = LoadUrlFlags::NONE );
469 bool ClickToINetGrf( const Point& rDocPt, LoadUrlFlags nFilter );
470 inline bool IsInClickToEdit() const ;
471
472 // if a URL-Button is selected, return its URL; otherwise an empty string
473 bool GetURLFromButton( OUString& rURL, OUString& rDescr ) const;
474
475 void NavigatorPaste(const NaviContentBookmark& rBkmk);
476
477 SW_DLLPUBLIC virtual void ApplyViewOptions( const SwViewOption &rOpt ) override;
478 SW_DLLPUBLIC virtual void SetReadonlyOption( bool bSet ) override;
479
480 // automatic update of styles
481 void AutoUpdateFrame(SwFrameFormat* pFormat, const SfxItemSet& rStyleSet);
482 void AutoUpdatePara(SwTextFormatColl* pColl, const SfxItemSet& rStyleSet, SwPaM* pPaM = nullptr );
483
484 // starts dialog for inserting ranges via Drag&Drop/Clipboard
485 void StartInsertRegionDialog(const SwSectionData&);
486
487 // ctor, the first one is a kind of a controlled copy ctor for more views of a document
488 SwWrtShell( SwWrtShell&, vcl::Window *pWin, SwView &rShell);
489 SwWrtShell( SwDoc& rDoc, vcl::Window *pWin, SwView &rShell,
490 const SwViewOption *pViewOpt);
491 virtual ~SwWrtShell() override;
492
493 SW_DLLPUBLIC virtual SwPostItMgr* GetPostItMgr() override;
494
495 SW_DLLPUBLIC bool TryRemoveIndent(); // #i23725#
496
497 OUString GetSelDescr() const;
498
GetNavigationMgr()499 SwNavigationMgr& GetNavigationMgr() { return m_aNavigationMgr; }
500
501 void addCurrentPosition();
502 SW_DLLPUBLIC bool GotoFly( const UIName& rName, FlyCntType eType = FLYCNTTYPE_ALL,
503 bool bSelFrame = true );
504 bool GotoINetAttr( const SwTextINetFormat& rAttr );
505 void GotoOutline( SwOutlineNodes::size_type nIdx );
506 bool GotoOutline( const OUString& rName );
507 bool GotoRegion( std::u16string_view rName );
508 bool GotoRefMark( const SwMarkName& rRefMark, ReferencesSubtype nSubType = ReferencesSubtype::SetRefAttr,
509 sal_uInt16 nSeqNo = 0, sal_uInt16 nFlags = 0 );
510 SW_DLLPUBLIC bool GotoNextTOXBase( const UIName* pName = nullptr);
511 SW_DLLPUBLIC bool GotoTable( const UIName& rName );
512 void GotoFormatField( const SwFormatField& rField );
513 const SwRangeRedline* GotoRedline( SwRedlineTable::size_type nArrPos, bool bSelect);
514 SW_DLLPUBLIC bool GotoDrawingObject(std::u16string_view rName);
515 void GotoFootnoteAnchor(const SwTextFootnote& rTextFootnote);
516 SW_DLLPUBLIC void ChangeHeaderOrFooter(const UIName& rStyleName, bool bHeader, bool bOn, bool bShowWarning);
517 virtual void SetShowHeaderFooterSeparator( FrameControlType eControl, bool bShow ) override;
518
519 /// Inserts a new annotation/comment at the current cursor position / selection.
520 void InsertPostIt(SwFieldMgr& rFieldMgr, const SfxRequest& rReq);
521
522 bool IsOutlineContentVisible(const size_t nPos);
523 void MakeOutlineContentVisible(const size_t nPos, bool bMakeVisible = true, bool bSetAttrOutlineVisibility = true);
524 void MakeAllFoldedOutlineContentVisible(bool bMakeVisible = true);
525 void InvalidateOutlineContentVisibility();
526 bool GetAttrOutlineContentVisible(const size_t nPos) const;
527
528 void MakeOutlineLevelsVisible(const int nLevel);
529
530 bool HasFoldedOutlineContentSelected() const;
531 virtual void InfoReadOnlyDialog(bool bAsync) const override;
532 virtual bool WarnHiddenSectionDialog() const override;
533 virtual bool WarnSwitchToDesignModeDialog() const override;
534
535 std::optional<OString> getLOKPayload(int nType, int nViewId) const;
536
537 private:
538
539 void OpenMark();
540 void CloseMark( bool bOkFlag );
541
542 struct ModeStack
543 {
544 ModeStack *pNext;
545 bool bAdd,
546 bBlock,
547 bExt,
548 bIns;
ModeStackSwWrtShell::ModeStack549 ModeStack(ModeStack *pNextMode, bool _bIns, bool _bExt, bool _bAdd, bool _bBlock):
550 pNext(pNextMode),
551 bAdd(_bAdd),
552 bBlock(_bBlock),
553 bExt(_bExt),
554 bIns(_bIns)
555 {}
556 } *m_pModeStack = nullptr;
557
558 // carry cursor along when PageUp / -Down
559 enum PageMove
560 {
561 MV_NO,
562 MV_PAGE_UP,
563 MV_PAGE_DOWN
564 } m_ePageMove = MV_NO;
565
566 struct CursorStack
567 {
568 Point aDocPos;
569 std::unique_ptr<CursorStack> pNext;
570 bool bValidCurPos : 1;
571 bool bIsFrameSel : 1;
572 SwTwips lOffset;
573
CursorStackSwWrtShell::CursorStack574 CursorStack( bool bValid, bool bFrameSel, const Point &rDocPos,
575 SwTwips lOff, std::unique_ptr<CursorStack> pN )
576 : aDocPos(rDocPos),
577 pNext(std::move(pN)),
578 bValidCurPos( bValid ),
579 bIsFrameSel( bFrameSel ),
580 lOffset(lOff)
581 {
582 }
583
584 };
585 std::unique_ptr<CursorStack> m_pCursorStack;
586
587 SwView &m_rView;
588 SwNavigationMgr m_aNavigationMgr;
589
590 Point m_aDest;
591 bool m_bDestOnStack = false;
HasCursorStack() const592 bool HasCursorStack() const { return nullptr != m_pCursorStack; }
593 bool PushCursor(SwTwips lOffset, bool bSelect);
594 bool PopCursor(bool bUpdate, bool bSelect = false);
595
596 // take END cursor along when PageUp / -Down
597 void SttWrd();
598 void EndWrd();
599 bool NxtWrd_();
600 bool PrvWrd_();
601 // #i92468#
602 bool NxtWrdForDelete();
603 bool PrvWrdForDelete();
604 bool FwdSentence_();
605 bool BwdSentence_();
606 SW_DLLPUBLIC bool FwdPara_();
607 bool BwdPara_();
608
609 // selections
610 bool m_bIns :1;
611 bool m_bInSelect :1;
612 bool m_bExtMode :1;
613 bool m_bAddMode :1;
614 bool m_bBlockMode :1;
615 bool m_bLayoutMode :1;
616 bool m_bSelWrd :1;
617 bool m_bSelLn :1;
618 bool m_bIsInClickToEdit:1;
619 bool m_bClearMark :1; // don't delete selection for ChartAutoPilot
620 bool m_bRetainSelection :1; // Do not remove selections
621
622 Point m_aStart;
623 Link<SwWrtShell&,void> m_aSelTableLink;
624
625 // resets the cursor stack after movement by PageUp/-Down
626 void ResetCursorStack_();
627
628 using SwCursorShell::SetCursor;
629 tools::Long SetCursor(const Point *, bool bProp=false,
630 ScrollSizeMode eScrollSizeMode = ScrollSizeMode::ScrollSizeDefault );
631
632 tools::Long SetCursorKillSel(const Point *, bool bProp,
633 ScrollSizeMode eScrollSizeMode = ScrollSizeMode::ScrollSizeDefault );
634
635 void BeginDrag(const Point *, bool bProp );
636 void DefaultDrag(const Point *, bool bProp );
637 void DefaultEndDrag(const Point *, bool bProp );
638
639 void ExtSelWrd(const Point *, bool bProp );
640 void ExtSelLn(const Point *, bool bProp );
641
642 void BeginFrameDrag(const Point *, bool bProp );
643
644 // after SSize/Move of a frame update; Point is destination.
645 void UpdateLayoutFrame(const Point *, bool bProp );
646
647 void SttLeaveSelect();
648 void AddLeaveSelect();
649 tools::Long Ignore(const Point *, bool bProp, ScrollSizeMode eScrollSizeMode = ScrollSizeMode::ScrollSizeDefault );
650
LeaveExtSel()651 void LeaveExtSel() { m_bSelWrd = m_bSelLn = false;}
652
653 bool GoStart(bool KeepArea, bool *,
654 bool bSelect, bool bDontMoveRegion = false);
655 bool GoEnd(bool KeepArea = false, const bool * = nullptr);
656
657 SAL_DLLPRIVATE void ImplSetInsMode(bool bOn);
658
659 enum BookMarkMove
660 {
661 BOOKMARK_INDEX,
662 BOOKMARK_NEXT,
663 BOOKMARK_PREV
664 };
665
666 bool MoveBookMark(BookMarkMove eFuncId, const ::sw::mark::MarkBase* const pMark=nullptr);
667 };
668
ResetCursorStack()669 inline void SwWrtShell::ResetCursorStack()
670 {
671 if ( HasCursorStack() )
672 ResetCursorStack_();
673 }
674
SelTableCells(const Link<SwWrtShell &,void> & rLink)675 inline void SwWrtShell::SelTableCells(const Link<SwWrtShell&,void> &rLink )
676 {
677 SetSelTableCells( true );
678 m_bClearMark = true;
679 m_aSelTableLink = rLink;
680 }
EndSelTableCells()681 inline void SwWrtShell::EndSelTableCells()
682 {
683 SetSelTableCells( false );
684 m_bClearMark = true;
685 }
686
IsInClickToEdit() const687 inline bool SwWrtShell::IsInClickToEdit() const { return m_bIsInClickToEdit; }
688
Is_FnDragEQBeginDrag() const689 inline bool SwWrtShell::Is_FnDragEQBeginDrag() const
690 {
691 #ifdef __GNUC__
692 SELECTFUNC2 fnTmp = &SwWrtShell::BeginDrag;
693 return m_fnDrag == fnTmp;
694 #else
695 return m_fnDrag == &SwWrtShell::BeginDrag;
696 #endif
697 }
698
699 class MakeAllOutlineContentTemporarilyVisible
700 {
701 private:
702 SwWrtShell* m_pWrtSh = nullptr;
703 bool m_bDone = false;
704 bool m_bScrollToCursor = false;
705 public:
706 static sal_uInt32 nLock;
MakeAllOutlineContentTemporarilyVisible(SwDoc * pDoc,bool bScrollToCursor=false)707 MakeAllOutlineContentTemporarilyVisible(SwDoc* pDoc, bool bScrollToCursor = false)
708 {
709 ++nLock;
710 if (nLock > 1)
711 return;
712 if (SwDocShell* pDocSh = pDoc->GetDocShell())
713 if ((m_pWrtSh = pDocSh->GetWrtShell()) && m_pWrtSh->GetViewOptions() &&
714 m_pWrtSh->GetViewOptions()->IsShowOutlineContentVisibilityButton())
715 {
716 m_pWrtSh->LockView(true);
717 m_pWrtSh->LockPaint(LockPaintReason::OutlineFolding);
718 m_pWrtSh->MakeAllFoldedOutlineContentVisible();
719 m_bScrollToCursor = bScrollToCursor;
720 m_bDone = true;
721 }
722 }
723
~MakeAllOutlineContentTemporarilyVisible()724 ~MakeAllOutlineContentTemporarilyVisible() COVERITY_NOEXCEPT_FALSE
725 {
726 --nLock;
727 if (nLock > 0)
728 return;
729 if (m_bDone && m_pWrtSh)
730 {
731 m_pWrtSh->MakeAllFoldedOutlineContentVisible(false);
732 m_pWrtSh->UnlockPaint();
733 m_pWrtSh->LockView(false);
734 if (m_bScrollToCursor)
735 m_pWrtSh->UpdateCursor(SwCursorShell::SCROLLWIN);
736 }
737 }
738 };
739
740 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
741