Coverage Report

Created: 2026-07-10 11:04

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