Coverage Report

Created: 2025-12-08 09:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sw/inc/fesh.hxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
 * This file is part of the LibreOffice project.
4
 *
5
 * This Source Code Form is subject to the terms of the Mozilla Public
6
 * License, v. 2.0. If a copy of the MPL was not distributed with this
7
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
 *
9
 * This file incorporates work covered by the following license notice:
10
 *
11
 *   Licensed to the Apache Software Foundation (ASF) under one or more
12
 *   contributor license agreements. See the NOTICE file distributed
13
 *   with this work for additional information regarding copyright
14
 *   ownership. The ASF licenses this file to you under the Apache
15
 *   License, Version 2.0 (the "License"); you may not use this file
16
 *   except in compliance with the License. You may obtain a copy of
17
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18
 */
19
#ifndef INCLUDED_SW_INC_FESH_HXX
20
#define INCLUDED_SW_INC_FESH_HXX
21
22
#include <com/sun/star/text/RelOrientation.hpp>
23
#include <com/sun/star/text/XPasteListener.hpp>
24
25
#include <svx/svdobj.hxx>
26
#include "swdllapi.h"
27
#include "editsh.hxx"
28
#include "flyenum.hxx"
29
30
#include <svx/svdtypes.hxx>
31
#include <sot/formats.hxx>
32
#include <rtl/ustring.hxx>
33
#include <o3tl/typed_flags_set.hxx>
34
#include <comphelper/interfacecontainer3.hxx>
35
36
#include <vector>
37
#include <memory>
38
39
namespace editeng { class SvxBorderLine; }
40
41
class SwFlyFrame;
42
class SwTabCols;
43
class SvxBrushItem;
44
class SvxFrameDirectionItem;
45
class SwTableAutoFormat;
46
class SwFrame;
47
class SwFormatFrameSize;
48
class SwFormatRowSplit;
49
class Outliner;
50
class SwFrameFormat;
51
struct SwSortOptions;
52
class SdrMarkList;
53
enum class RndStdIds;
54
55
namespace svx
56
{
57
    class ISdrObjectFilter;
58
}
59
namespace com::sun::star::embed { class XEmbeddedObject; }
60
61
// return values for GetFrameType() and GetSelFrameType().
62
//! values can be combined via logical or
63
enum class FrameTypeFlags {
64
    NONE            =     0,
65
    PAGE            =     1,
66
    HEADER          =     2,
67
    FOOTER          =     4,
68
    BODY            =     8,
69
    COLUMN          =    16,
70
    TABLE           =    32,
71
    FLY_FREE        =    64,
72
    FLY_ATCNT       =   128,
73
    FLY_INCNT       =   256,
74
    FOOTNOTE        =   512,
75
    FTNPAGE         =  1024,
76
    FLY_ANY         =  2048,
77
    DRAWOBJ         =  4096,
78
    COLSECT         =  8192,
79
    COLSECTOUTTAB   = 16384
80
};
81
namespace o3tl
82
{
83
    template<> struct typed_flags<FrameTypeFlags> : is_typed_flags<FrameTypeFlags, 0x7fff> {};
84
}
85
86
//! values can be combined via logical or
87
enum class GotoObjFlags
88
{
89
    NONE           =  0,
90
    DrawControl    =  1,
91
    DrawSimple     =  2,
92
    DrawAny        = DrawControl | DrawSimple,
93
    FlyFrame         =  4,
94
    FlyGrf         =  8,
95
    FlyOLE         = 16,
96
    FlyAny         = FlyOLE | FlyGrf | FlyFrame,
97
    Any            = FlyAny | DrawAny,
98
};
99
namespace o3tl
100
{
101
    template<> struct typed_flags<GotoObjFlags> : is_typed_flags<GotoObjFlags, 31> {};
102
}
103
104
//! values can be combined via logical or
105
enum class FlyProtectFlags
106
{
107
    NONE         = 0,
108
    Content      = 1,
109
    Size         = 2,
110
    Pos          = 4,
111
    Parent       = 8,      ///< Check only parents.
112
    Fixed        = 16,    /**< Only protection that cannot be withdrawn
113
                                                    e.g. by OLE-server; also relevant for dialog. */
114
};
115
namespace o3tl
116
{
117
    template<> struct typed_flags<FlyProtectFlags> : is_typed_flags<FlyProtectFlags, 31> {};
118
}
119
120
// For figuring out contents by position (D&D)
121
enum ObjCntType
122
{
123
    OBJCNT_NONE,
124
    OBJCNT_FLY,
125
    OBJCNT_GRF,
126
    OBJCNT_OLE,
127
    OBJCNT_SIMPLE,
128
    OBJCNT_CONTROL,
129
    OBJCNT_URLBUTTON,
130
131
    OBJCNT_GROUPOBJ,
132
    OBJCNT_DONTCARE     ///< Not determinable - different objects are selected.
133
};
134
135
//For GetAnyCurRect
136
enum class CurRectType
137
{
138
    Page,                 ///< Rect of current page.
139
    PageCalc,             ///< ... page will be formatted if required.
140
    PagePrt,              ///< Rect of current PrtArea of page.
141
    Frame,                ///< Rect of current frame.
142
    FlyEmbedded,          ///< Rect of current FlyFrame.
143
    FlyEmbeddedPrt,       ///< Rect of PrtArea of FlyFrame
144
    Section,              ///< Rect of current section.
145
    SectionOutsideTable,  ///< Rect of current section but outside of table.
146
    SectionPrt,           ///< Rect of current PrtArea of section.
147
    HeaderFooter,         ///< Rect of current header/footer
148
    PagesArea             ///< Rect covering the pages area
149
};
150
151
struct SwGetCurColNumPara
152
{
153
    const SwFrameFormat* pFrameFormat;
154
    const SwRect* pPrtRect;
155
0
    SwGetCurColNumPara() : pFrameFormat( nullptr ), pPrtRect( nullptr ) {}
156
};
157
158
enum class SwPasteSdr
159
{
160
    NONE        = 0,
161
    Insert      = 1,
162
    Replace     = 2,
163
    SetAttr     = 3
164
};
165
166
0
#define SW_ADD_SELECT   1
167
0
#define SW_ENTER_GROUP  2
168
0
#define SW_LEAVE_FRAME  4
169
/// Allow SwFEShell::SelectObj() to select the TextBox of a shape.
170
0
#define SW_ALLOW_TEXTBOX  8
171
172
enum class SwMove
173
{
174
    UP      = 0,
175
    DOWN    = 1,
176
    LEFT    = 2,
177
    RIGHT   = 3
178
};
179
180
// return values for WhichMouseTabCol
181
enum class SwTab
182
{
183
    COL_NONE          = 0,
184
    COL_HORI          = 1,
185
    COL_VERT          = 2,
186
    ROW_HORI          = 3,
187
    ROW_VERT          = 4,
188
    SEL_HORI          = 5,
189
    SEL_HORI_RTL      = 6,
190
    ROWSEL_HORI       = 7,
191
    ROWSEL_HORI_RTL   = 8,
192
    COLSEL_HORI       = 9,
193
    SEL_VERT          = 10,
194
    ROWSEL_VERT       = 11,
195
    COLSEL_VERT       = 12
196
};
197
198
class SdrDropMarkerOverlay;
199
struct SwColCache;
200
201
class SAL_DLLPUBLIC_RTTI SwFEShell : public SwEditShell
202
{
203
private:
204
    mutable std::unique_ptr<SwColCache> m_pColumnCache;
205
    mutable std::unique_ptr<SwColCache> m_pRowCache;
206
    std::unique_ptr<SdrDropMarkerOverlay> m_pChainTo;
207
    std::unique_ptr<SdrDropMarkerOverlay> m_pChainFrom;
208
    bool m_bCheckForOLEInCaption;
209
    comphelper::OInterfaceContainerHelper3<css::text::XPasteListener> m_aPasteListeners;
210
    /// insert table rows or columns instead of overwriting the existing table cells
211
    SwTable::SearchType m_eTableInsertMode;
212
    /// table copied to the clipboard by the last private copy
213
    bool m_bTableCopied;
214
215
    SwFlyFrame *FindFlyFrame( const css::uno::Reference < css::embed::XEmbeddedObject >&  ) const;
216
217
    /// Terminate actions for all shells and call ChangeLink.
218
    void EndAllActionAndCall();
219
220
    void ScrollTo( const Point &rPt );
221
222
    void ChangeOpaque( SdrLayerID nLayerId );
223
224
    /** Used for mouse operations on a table:
225
     @return a cell frame that is 'close' to rPt. */
226
    const SwFrame *GetBox( const Point &rPt, bool* pbRow = nullptr, bool* pbCol = nullptr ) const;
227
228
    // 0 == not in any column.
229
    static sal_uInt16 GetCurColNum_( const SwFrame *pFrame,
230
                          SwGetCurColNumPara* pPara );
231
232
    void GetTabCols_(SwTabCols &rToFill, const SwFrame *pBox) const;
233
    void GetTabRows_(SwTabCols &rToFill, const SwFrame *pBox) const;
234
235
    bool ImpEndCreate();
236
237
    /// Methods for copying of draw objects.
238
    bool CopyDrawSel( SwFEShell& rDestShell, const Point& rSttPt,
239
                                const Point& rInsPt, bool bIsMove,
240
                                bool bSelectInsert );
241
242
    /// Get list of marked SdrObjects;
243
    /// helper method for GetSelFrameType, IsSelContainsControl.
244
    const SdrMarkList* GetMarkList_() const;
245
246
    bool CheckHeadline( bool bRepeat ) const;
247
248
    using SwEditShell::Copy;
249
250
public:
251
252
    using SwEditShell::Insert;
253
254
    SwFEShell( SwDoc& rDoc, vcl::Window *pWin, const SwViewOption *pOpt );
255
    SwFEShell( SwEditShell& rShell, vcl::Window *pWin );
256
    virtual ~SwFEShell() override;
257
258
    /// Copy and Paste methods for internal clipboard.
259
    /// bDeleteRedlines: if content inside a delete redline should be stripped away in rClpDoc.
260
    SW_DLLPUBLIC void Copy( SwDoc& rClpDoc, const OUString* pNewClpText = nullptr, bool bDeleteRedlines = true );
261
    // @return possibly a pasted fly frame to be captioned
262
    SW_DLLPUBLIC ::std::pair<bool, SwFrameFormat const*>
263
        Paste(SwDoc& rClpDoc, bool bNestedTable = false);
264
265
    /// Paste some pages into another doc - used in mailmerge.
266
    SW_DLLPUBLIC void PastePages( SwFEShell& rToFill, sal_uInt16 nStartPage, sal_uInt16 nEndPage);
267
268
    /// Copy-Method for Drag&Drop
269
    SW_DLLPUBLIC bool Copy( SwFEShell&, const Point& rSttPt, const Point& rInsPt,
270
               bool bIsMove = false, bool bSelectInsert = true );
271
272
    void SelectFlyFrame( SwFlyFrame& rFrame );
273
274
    SW_DLLPUBLIC void UnfloatFlyFrame();
275
276
    /// Is selected frame within another frame?
277
    SW_DLLPUBLIC const SwFrameFormat* IsFlyInFly();
278
279
    /** If an object has been given, exactly this object is selected
280
     (instead of searching over position). */
281
    SW_DLLPUBLIC bool SelectObj( const Point& rSelPt, sal_uInt8 nFlag = 0, SdrObject *pObj = nullptr );
282
    SW_DLLPUBLIC void DelSelectedObj();
283
284
    /** Move selection upwards or downwards (Z-Order).
285
     TRUE = to top or bottom.
286
     FALSE = run past one other. */
287
    void SelectionToTop   ( bool bTop = true );
288
    void SelectionToBottom( bool bBottom = true );
289
290
    SdrLayerID GetLayerId() const;   ///< 1 Heaven, 0 Hell, SDRLAYER_NOTFOUND Ambiguous.
291
    void  SelectionToHeaven();  ///< Above document.
292
    void  SelectionToHell();    ///< Below document.
293
294
    /** The following two methods return enum SdrHdlKind.
295
     Declared as int in order to spare including SVDRAW.HXX. */
296
    bool IsObjSelectable( const Point& rPt );
297
    /// Same as IsObjSelectable(), but return the object as well.
298
    SdrObject* GetObjAt(const Point& rPt);
299
    bool IsInsideSelectedObj( const Point& rPt );    ///< returns enum values
300
    /** Test if there is a draw object at that position and if it should be selected.
301
     The 'should' is aimed at Writer text fly frames which may be in front of
302
     the draw object. */
303
    bool ShouldObjectBeSelected(const Point& rPt, bool *pSelectFrameInsteadOfCroppedImage = nullptr);
304
305
    bool MoveAnchor( SwMove nDir );
306
307
    /** @return if Upper of frame at current position is section frame
308
     Currently only used by the rules. To be replaced by something more
309
     sophisticated one day. */
310
    SW_DLLPUBLIC bool IsDirectlyInSection() const;
311
312
    /** For return values see above FrameType.
313
     pPt: Cursr or DocPos respectively; bStopAtFly: Stop at flys or continue over anchor.
314
     Although (0,TRUE) is kind of a standard, the parameters are not defaulted here
315
     in order to force more conscious use especially of bStopAtFly. */
316
    SW_DLLPUBLIC FrameTypeFlags GetFrameType( const Point *pPt, bool bStopAtFly ) const;
317
    FrameTypeFlags GetSelFrameType() const;               //Selection (Drawing)
318
319
    /** check whether selected frame contains a control;
320
     * companion method to GetSelFrameType, used for preventing
321
     * drag&drop of controls into header */
322
    bool IsSelContainsControl() const;
323
324
    static ObjCntType GetObjCntType( const SdrObject& rObj );
325
    ObjCntType GetObjCntType( const Point &rPt, SdrObject *&rpObj ) const;
326
    ObjCntType GetObjCntTypeOfSelection() const;
327
328
    /// For adjustment of PosAttr when anchor changes.
329
    SwRect  GetObjRect() const;
330
331
    /// For moving flys with keyboard.
332
    SW_DLLPUBLIC SwRect  GetFlyRect() const;
333
    /** i#17567 - adjustments to allow negative vertical positions for fly frames anchored
334
              to paragraph or to character.
335
     i#18732 - adjustments for new option 'FollowTextFlow'
336
     i#22341 - adjustments for new vertical alignment at top of line */
337
    SW_DLLPUBLIC void CalcBoundRect( SwRect& _orRect,
338
                        const RndStdIds _nAnchorId,
339
                        const sal_Int16 _eHoriRelOrient = css::text::RelOrientation::FRAME,
340
                        const sal_Int16 _eVertRelOrient = css::text::RelOrientation::FRAME,
341
                        const SwFormatAnchor* _pToCharContentPos = nullptr,
342
                        const bool _bFollowTextFlow = false,
343
                        bool _bMirror = false,
344
                        Point* _opRef = nullptr,
345
                        Size* _opPercent = nullptr,
346
                        const SwFormatFrameSize* pFormatFrameSize = nullptr ) const;
347
348
    /// Set size of draw objects.
349
    void SetObjRect( const SwRect& rRect );
350
351
    void BeginDrag( const Point *pPt, bool bProp );
352
    void Drag     ( const Point *pPt, bool bProp );
353
    void EndDrag  ();
354
    void BreakDrag();
355
356
    /// Methods for status line.
357
    Point GetAnchorObjDiff() const;
358
    Point GetObjAbsPos()     const;
359
    Size  GetObjSize()       const;
360
361
    /// SS for envelopes: get all page-bound objects and set them to new page.
362
    void GetPageObjs( std::vector<SwFrameFormat*>& rFillArr );
363
    void SetPageObjsNewPage( std::vector<SwFrameFormat*>& rFillArr );
364
365
    /// Show current selection (frame / draw object as required).
366
    virtual void MakeSelVisible(ScrollSizeMode eScrollSizeMode = ScrollSizeMode::ScrollSizeDefault) override;
367
368
    /** @return FrameFormat of object that may be under Point.
369
     Object does not become selected! */
370
    const SwFrameFormat* GetFormatFromObj( const Point& rPt, SwRect** pRectToFill = nullptr ) const;
371
372
    /// @return a format too, if the point is over the text of any fly.
373
    const SwFrameFormat* GetFormatFromAnyObj( const Point& rPt ) const;
374
375
    /** Which Protection is set at selected object? */
376
    SW_DLLPUBLIC FlyProtectFlags IsSelObjProtected( FlyProtectFlags eType ) const;
377
378
    /** Deliver graphic in rName besides graphic name. If graphic is
379
     linked give name with path. rbLink is TRUE if graphic is linked. */
380
    const Graphic *GetGrfAtPos( const Point &rDocPos,
381
                                OUString &rName, bool &rbLink ) const;
382
383
    OUString GetObjTitle() const;
384
    void SetObjTitle( const OUString& rTitle );
385
    OUString GetObjDescription() const;
386
    void SetObjDescription( const OUString& rDescription );
387
    bool IsObjDecorative() const;
388
    void SetObjDecorative(bool isDecorative);
389
390
    SW_DLLPUBLIC bool IsFrameSelected() const;
391
    bool GetFlyFrameAttr( SfxItemSet &rSet ) const;
392
    SW_DLLPUBLIC bool SetFlyFrameAttr( SfxItemSet &rSet );
393
    static SfxItemSet makeItemSetFromFormatAnchor(SfxItemPool& rPool, const SwFormatAnchor &rAnchor);
394
    void ResetFlyFrameAttr( const SfxItemSet* pSet );
395
    SW_DLLPUBLIC const SwFrameFormat *NewFlyFrame( const SfxItemSet &rSet, bool bAnchValid = false,
396
                         SwFrameFormat *pParent = nullptr );
397
    SW_DLLPUBLIC void SetFlyPos( const Point &rAbsPos);
398
    SW_DLLPUBLIC Point FindAnchorPos( const Point &rAbsPos, bool bMoveIt = false );
399
400
    /** Determines whether a frame or its environment is vertically formatted and right-to-left.
401
     also determines, if frame or its environment is in Mongolian layout (vertical left-to-right)
402
     - add output parameter <bVertL2R> */
403
    SW_DLLPUBLIC bool IsFrameVertical(const bool bEnvironment, bool& bRightToLeft, bool& bVertL2R) const;
404
405
    SwFrameFormat* GetSelectedFrameFormat() const; ///< If frame then frame style, else 0.
406
    void SetFrameFormat( SwFrameFormat *pFormat, bool bKeepOrient = false, Point const * pDocPos = nullptr ); ///< If frame then set frame style.
407
408
    // Get selected fly
409
    SW_DLLPUBLIC SwFlyFrame* GetSelectedFlyFrame() const;
410
411
    // Get current fly in which the cursor is positioned
412
    SW_DLLPUBLIC SwFlyFrame* GetCurrFlyFrame(const bool bCalcFrame = true) const;
413
414
    // Get selected fly, but if none Get current fly in which the cursor is positioned
415
    SwFlyFrame* GetSelectedOrCurrFlyFrame() const;
416
417
    /// Find/delete fly containing the cursor.
418
    SwFrameFormat* WizardGetFly();
419
420
    /// Independent selecting of flys.
421
    bool GotoNextFly( GotoObjFlags eType = GotoObjFlags::FlyAny )
422
0
                                { return GotoObj( true, eType ); }
423
    bool GotoPrevFly( GotoObjFlags eType = GotoObjFlags::FlyAny)
424
0
                                { return GotoObj( false, eType); }
425
426
    /// Iterate over flys  - for Basic-collections.
427
    SW_DLLPUBLIC size_t GetFlyCount( FlyCntType eType, bool bIgnoreTextBoxes = false ) const;
428
429
    std::vector<SwFrameFormat const*> GetFlyFrameFormats(
430
            FlyCntType eType, bool bIgnoreTextBoxes);
431
432
    /// If a fly is selected, it draws cursor into the first ContentFrame.
433
    SW_DLLPUBLIC const SwFrameFormat* SelFlyGrabCursor();
434
435
    /// Get FlyFrameFormat; for UI macro linkage at Flys
436
    const SwFrameFormat* GetFlyFrameFormat() const;
437
    SW_DLLPUBLIC SwFrameFormat* GetFlyFrameFormat();
438
439
    /** OLE. Server requires new size. Desired values are adjusted as frame attributes.
440
     If the values are not allowed, the formatting clips and determines scaling.
441
     See CalcAndSetScale().
442
     The @return value is the applied size. */
443
    Size RequestObjectResize( const SwRect &rRect, const css::uno::Reference < css::embed::XEmbeddedObject >& );
444
445
    /// The layout has been changed, so the active object has to be moved after that
446
    virtual void MoveObjectIfActive( svt::EmbeddedObjectRef& xObj, const Point& rOffset );
447
448
    /** Client for OleObject has to be up-to-date regarding scaling.
449
     Implemented in WrtShell.
450
     If a pointer is passed on a size, this is the object's current core-size.
451
     Else the size is provided via GetCurFlyRect(). */
452
    virtual void CalcAndSetScale( svt::EmbeddedObjectRef& xObj,
453
                                  const SwRect *pFlyPrtRect = nullptr,
454
                                  const SwRect *pFlyFrameRect = nullptr,
455
                                  const bool bNoTextFramePrtAreaChanged = false ) = 0;
456
457
    /** Connect objects with ActivateWhenVisible at Paint.
458
     Called by notxtfrm::Paint, implemented in wrtsh. */
459
    virtual void ConnectObj( svt::EmbeddedObjectRef&,
460
                             const SwRect &rPrt,
461
                             const SwRect &rFrame ) = 0;
462
463
    /// Check resize of OLE-Object.
464
0
    bool IsCheckForOLEInCaption() const         { return m_bCheckForOLEInCaption; }
465
0
    void SetCheckForOLEInCaption( bool bFlag )  { m_bCheckForOLEInCaption = bFlag; }
466
467
    /// Set name at selected FlyFrame.
468
    SW_DLLPUBLIC void SetFlyName( const UIName& rName );
469
    UIName GetFlyName() const;
470
471
    /// get reference to OLE object (if there is one) for selected FlyFrame
472
    css::uno::Reference < css::embed::XEmbeddedObject > GetOleRef() const;
473
474
    /// Created unique name for frame.
475
    SW_DLLPUBLIC UIName GetUniqueGrfName() const;
476
    SW_DLLPUBLIC UIName GetUniqueOLEName() const;
477
    SW_DLLPUBLIC UIName GetUniqueFrameName() const;
478
479
    /// Jump to named Fly (graphic/OLE).
480
    bool GotoFly( const UIName& rName, FlyCntType eType,
481
                  bool bSelFrame );
482
483
    /// Position is a graphic with URL?
484
    const SwFrameFormat* IsURLGrfAtPos( const Point& rPt, OUString* pURL = nullptr,
485
                                    OUString *pTargetFrameName = nullptr,
486
                                    OUString *pURLDescription = nullptr ) const;
487
488
    /** For Chain always connect Fly specified by format with that hit by point.
489
     rRect contains rect of Fly (for its highlight). */
490
    SwChainRet Chainable( SwRect &rRect, const SwFrameFormat &rSource, const Point &rPt ) const;
491
    SwChainRet Chain( SwFrameFormat &rSource, const Point &rPt );
492
    void       Chain( SwFrameFormat &rSource, const SwFrameFormat &rDest );
493
    void Unchain( SwFrameFormat &rFormat );
494
    void HideChainMarker();
495
    void SetChainMarker();
496
497
    Size GetGraphicDefaultSize() const;
498
499
    /// Temporary work around for bug.
500
    void CheckUnboundObjects();
501
502
    /// Attention: Ambiguities if multiple selections.
503
    bool GetObjAttr( SfxItemSet &rSet ) const;
504
    void SetObjAttr( const SfxItemSet &rSet );
505
506
    const SdrObject* GetBestObject(bool bNext, GotoObjFlags eType, bool bFlat = true,
507
                                   const svx::ISdrObjectFilter* pFilter = nullptr,
508
                                   bool* pbWrapped = nullptr);
509
    SW_DLLPUBLIC bool GotoObj( bool bNext, GotoObjFlags eType = GotoObjFlags::DrawAny);
510
511
    /// Set DragMode (e.g. Rotate), but do nothing when frame is selected.
512
    void SetDragMode( SdrDragMode eSdrDragMode );
513
514
    // Get the current drag mode
515
    SdrDragMode GetDragMode() const;
516
517
    // Start cropping the selected image
518
    void StartCropImage();
519
520
    // RotGrfFlyFrame: check if RotationMode is possible
521
    bool IsRotationOfSwGrfNodePossible() const;
522
523
    /// @return object count, but doesn't count the objects in groups.
524
    SW_DLLPUBLIC size_t GetSelectedObjCount() const;
525
526
    bool IsObjSelected( const SdrObject& rObj ) const;
527
    bool IsObjSameLevelWithMarked(const SdrObject* pObj) const;
528
0
    const SdrMarkList* GetMarkList() const{ return GetMarkList_(); };
529
530
    SW_DLLPUBLIC void EndTextEdit();             ///< Deletes object if required.
531
532
    /** Anchor type of selected object, RndStdIds::UNKNOWN if ambiguous or in case of frame selection.
533
     Else RndStdIds::FLY_AT_PAGE or RndStdIds::FLY_AT_PARA. */
534
    RndStdIds GetAnchorId() const;
535
536
    /** Process of creating draw objects. At the beginning object type is passed.
537
     At the end a Cmd can be passed. Here, SDRCREATE_RESTRAINTEND for end
538
     or SdrCreateCmd::NextPoint for a polygon may be relevant.
539
     After RESTRAINTEND the object is created and selected.
540
     BreakCreate interrupts the process. In this case no object is selected. */
541
    SW_DLLPUBLIC bool BeginCreate( SdrObjKind eSdrObjectKind, const Point &rPos );
542
    bool BeginCreate( SdrObjKind eSdrObjectKind, SdrInventor eObjInventor, const Point &);
543
    SW_DLLPUBLIC void MoveCreate ( const Point &rPos );
544
    SW_DLLPUBLIC bool EndCreate  ( SdrCreateCmd eSdrCreateCmd );
545
    void BreakCreate();
546
    bool IsDrawCreate() const;
547
    void CreateDefaultShape(SdrObjKind eSdrObjectKind, const tools::Rectangle& rRect, sal_uInt16 nSlotId);
548
549
    /// Functions for Rubberbox, it selects Draw-Objects
550
    bool BeginMark( const Point &rPos );
551
    void MoveMark ( const Point &rPos );
552
    bool EndMark  ();
553
554
    /// Create and destroy group, don't when frame is selected.
555
    bool IsGroupSelected(bool bAllowDiagams);     ///< Can be a mixed selection!
556
    void GroupSelection();          ///< Afterwards the group is selected.
557
    void UnGroupSelection();        /**< The individual objects are selected, but
558
                                    it is possible that there are groups included. */
559
560
    bool IsGroupAllowed() const;
561
    bool IsUnGroupAllowed() const;
562
563
    void MirrorSelection( bool bHorizontal );   ///< Vertical if FALSE.
564
565
    /** frmatr.hxx. Here no enum because of dependencies.
566
     bool value only for internal use! Anchor is newly set according
567
     to current document position. Anchor is not re-set. */
568
    SW_DLLPUBLIC void ChgAnchor( RndStdIds eAnchorId, bool bSameOnly = false,
569
                                   bool bPosCorr = true );
570
571
    bool SetDrawingAttr( SfxItemSet &rSet );
572
573
    /** Get selected DrawObj as graphics (MetaFile/Bitmap).
574
     Return value indicates if it was converted. */
575
    bool GetDrawObjGraphic( SotClipboardFormatId nFormat, Graphic& rGrf ) const;
576
577
    SwPasteSdr PasteStream(SvStream& rStm, SwPasteSdr nAction, const Point* pPt);
578
    bool Paste( const Graphic &rGrf, const OUString& rURL );
579
580
    comphelper::OInterfaceContainerHelper3<css::text::XPasteListener>& GetPasteListeners();
581
582
    bool IsAlignPossible() const;
583
    void SetCalcFieldValueHdl(Outliner* pOutliner);
584
585
    SW_DLLPUBLIC void Insert(const OUString& rGrfName,
586
                const OUString& rFltName,
587
                const Graphic* pGraphic,
588
                const SfxItemSet* pFlyAttrSet );
589
590
    /// Insertion of a drawing object which have to be already inserted in the DrawModel.
591
    void InsertDrawObj( SdrObject& rDrawObj,
592
                        const Point& rInsertPosition );
593
594
    void ReplaceSdrObj( const OUString& rGrfName, const Graphic* pGrf );
595
596
    // --> #i972#
597
    /** for starmath formulas anchored 'as char' it aligns it baseline to baseline
598
     changing the previous vertical orientation */
599
    void AlignFormulaToBaseline( const css::uno::Reference < css::embed::XEmbeddedObject >& xObj );
600
601
    /// aligns all formulas with anchor 'as char' to baseline
602
    void AlignAllFormulasToBaseline();
603
604
    /// Provide information about content situated closes to given Point.
605
    Point GetContentPos( const Point& rPoint, bool bNext ) const;
606
607
    /// Convert document position into position relative to the current page.
608
    Point GetRelativePagePosition(const Point& rDocPos);
609
610
    /// Hide or show layout-selection and pass call to CursorSh.
611
    SW_DLLPUBLIC void ShellLoseFocus();
612
    void ShellGetFocus();
613
614
    /// PageDescriptor-interface
615
    void   ChgCurPageDesc( const SwPageDesc& );
616
    SW_DLLPUBLIC size_t GetCurPageDesc( const bool bCalcFrame = true ) const;
617
    size_t GetMousePageDesc( const Point &rPt ) const;
618
    SW_DLLPUBLIC size_t GetPageDescCnt() const;
619
    SW_DLLPUBLIC SwPageDesc* FindPageDescByName( const UIName& rName,
620
                                    bool bGetFromPool = false,
621
                                    size_t* pPos = nullptr );
622
623
    SW_DLLPUBLIC const SwPageDesc& GetPageDesc( size_t i ) const;
624
    SW_DLLPUBLIC void  ChgPageDesc( size_t i, const SwPageDesc& );
625
    /** if inside all selection only one PageDesc, @return this.
626
     Otherwise @return 0 pointer */
627
    SW_DLLPUBLIC const SwPageDesc* GetSelectedPageDescs() const;
628
629
    SW_DLLPUBLIC const SwRect& GetAnyCurRect( CurRectType eType,
630
                                 const Point* pPt = nullptr,
631
                                 const css::uno::Reference < css::embed::XEmbeddedObject >& =
632
                                 css::uno::Reference < css::embed::XEmbeddedObject >() ) const;
633
634
    /// Page number of the page containing Point, O if no page.
635
    sal_uInt16 GetPageNumber( const Point &rPoint ) const;
636
    SW_DLLPUBLIC bool GetPageNumber( tools::Long nYPos, bool bAtCursorPos, sal_uInt16& rPhyNum, sal_uInt16& rVirtNum, OUString &rDisplay ) const;
637
638
    SwFlyFrameFormat* InsertObject( const svt::EmbeddedObjectRef&,
639
                SfxItemSet* pFlyAttrSet );
640
    bool    FinishOLEObj(); ///< Shutdown server.
641
642
    void GetTableAttr( SfxItemSet & ) const;
643
    SW_DLLPUBLIC void SetTableAttr( const SfxItemSet & );
644
645
    bool HasWholeTabSelection() const;
646
647
    /// Is content of a table cell or at least a table cell completely selected?
648
    bool HasBoxSelection() const;
649
650
    SW_DLLPUBLIC void InsertRow( sal_uInt16 nCnt, bool bBehind );
651
    SW_DLLPUBLIC void InsertCol( sal_uInt16 nCnt, bool bBehind );  // 0 == at the end.
652
    SW_DLLPUBLIC bool DeleteCol();
653
    void DeleteTable();
654
    SW_DLLPUBLIC bool DeleteRow(bool bCompleteTable = false);
655
656
0
    SwTable::SearchType GetTableInsertMode() const         { return m_eTableInsertMode; }
657
0
    void SetTableInsertMode( SwTable::SearchType eFlag )  { m_eTableInsertMode = eFlag; }
658
659
0
    bool GetTableCopied() const { return m_bTableCopied; }
660
0
    void SetTableCopied( bool bCopied )  { m_bTableCopied = bCopied; }
661
662
    bool DeleteTableSel();        ///< Current selection, may be whole table.
663
664
    TableMergeErr MergeTab();          /**< Merge selected parts of table */
665
666
    /// Split cell vertically or horizontally.
667
    void SplitTab( bool bVert, sal_uInt16 nCnt, bool bSameHeight );
668
    SW_DLLPUBLIC bool Sort(const SwSortOptions&);    // sorting
669
670
    SW_DLLPUBLIC void SetRowHeight( const SwFormatFrameSize &rSz );
671
672
    /// Pointer must be destroyed by caller != 0.
673
    SW_DLLPUBLIC std::unique_ptr<SwFormatFrameSize> GetRowHeight() const;
674
675
    void SetRowSplit( const SwFormatRowSplit &rSz );
676
    std::unique_ptr<SwFormatRowSplit> GetRowSplit() const;
677
678
    SW_DLLPUBLIC void SetBoxAlign(sal_uInt16 nOrient);
679
    sal_uInt16 GetBoxAlign() const;         ///< USHRT_MAX if ambiguous.
680
681
    bool BalanceRowHeight( bool bTstOnly, const bool bOptimize = false );
682
683
    void SetTabBorders( const SfxItemSet& rSet );
684
    void GetTabBorders(       SfxItemSet& rSet) const;
685
    void SetTabLineStyle(const Color* pColor, bool bSetLine = false, const editeng::SvxBorderLine* pBorderLine = nullptr);
686
687
    SW_DLLPUBLIC void SetTabBackground( const SvxBrushItem &rNew );
688
    void GetTabBackground( std::unique_ptr<SvxBrushItem>& rToFill ) const;
689
690
    SW_DLLPUBLIC void SetBoxBackground( const SvxBrushItem &rNew );
691
    bool GetBoxBackground( std::unique_ptr<SvxBrushItem>& rToFill ) const; ///< FALSE ambiguous.
692
693
    void SetBoxDirection( const SvxFrameDirectionItem& rNew );
694
    bool GetBoxDirection( std::unique_ptr<SvxFrameDirectionItem>& rToFill ) const; ///< FALSE ambiguous.
695
696
    SW_DLLPUBLIC void SetRowBackground( const SvxBrushItem &rNew );
697
    bool GetRowBackground( std::unique_ptr<SvxBrushItem>& rToFill ) const; ///< FALSE ambiguous.
698
699
    SwTab WhichMouseTabCol( const Point &rPt ) const;
700
    void GetTabCols( SwTabCols &rToFill ) const; ///< Info about columns and margins.
701
    void SetTabCols( const SwTabCols &rNew, bool bCurRowOnly );
702
    void GetMouseTabCols( SwTabCols &rToFill, const Point &rPt ) const;
703
    void SetMouseTabCols( const SwTabCols &rNew, bool bCurRowOnly,
704
                          const Point &rPt );
705
706
    /// pEnd will be used during MouseMove
707
    bool SelTableRowCol( const Point& rPt, const Point* pEnd, bool bRowDrag );
708
709
    void GetTabRows( SwTabCols &rToFill ) const;
710
    void SetTabRows( const SwTabCols &rNew, bool bCurColOnly );
711
    void GetMouseTabRows( SwTabCols &rToFill, const Point &rPt ) const;
712
    void SetMouseTabRows( const SwTabCols &rNew, bool bCurColOnly, const Point &rPt );
713
714
    SW_DLLPUBLIC void ProtectCells();    /**< If a table selection exists it is destroyed in case
715
                             cursor is not allowed in readonly. */
716
    SW_DLLPUBLIC void UnProtectCells();  ///< Refers to table selection.
717
    void UnProtectTables();   ///< Unprotect all tables in selection.
718
    bool HasTableAnyProtection( const UIName* pTableName,
719
                              bool* pFullTableProtection );
720
    bool CanUnProtectCells() const;
721
722
    sal_uInt16 GetRowsToRepeat() const;
723
    SW_DLLPUBLIC void SetRowsToRepeat( sal_uInt16 nNumOfRows );
724
    sal_uInt16 GetVirtPageNum() const;
725
726
    /** @return the number of table rows currently selected
727
    if the selection start at the top of the table. */
728
    sal_uInt16    GetRowSelectionFromTop() const;
729
730
0
    bool IsInRepeatedHeadline() const { return CheckHeadline( true ); }
731
0
    bool IsInHeadline() const { return CheckHeadline( false ); }
732
733
    void AdjustCellWidth( const bool bBalance, const bool bNoShrink );
734
735
    /// Not allowed if only empty cells are selected.
736
    bool IsAdjustCellWidthAllowed( bool bBalance = false ) const;
737
738
    /// Set table style of the current table.
739
    void SetTableStyle(const TableStyleName& rStyleName);
740
    SW_DLLPUBLIC bool SetTableStyle(const SwTableAutoFormat& rNew);
741
    SW_DLLPUBLIC bool ResetTableStyle();
742
743
    /// Update the direct formatting according to the current table style.
744
    /// @param pTableNode Table node to update.  When nullptr, current cursor position is used.
745
    /// @param bResetDirect Reset direct formatting that might be applied to the cells.
746
    /// @param pStyleName new style to apply
747
    bool UpdateTableStyleFormatting(SwTableNode *pTableNode = nullptr, bool bResetDirect = false, TableStyleName const* pStyleName = nullptr);
748
749
    SW_DLLPUBLIC bool GetTableAutoFormat( SwTableAutoFormat& rGet );
750
751
    void SetColRowWidthHeight( TableChgWidthHeightType eType, sal_uInt16 nDiff );
752
753
    void GetAutoSum( OUString& rFormula ) const;
754
755
    /** Phy: real page count.
756
     Virt: consider offset that may have been set by user. */
757
    SW_DLLPUBLIC sal_uInt16 GetPhyPageNum() const;
758
759
    void SetNewPageOffset( sal_uInt16 nOffset );
760
    void SetPageOffset( sal_uInt16 nOffset );   ///< Changes last page offset.
761
    sal_uInt16 GetPageOffset() const;           ///< @return last page offset.
762
763
    void InsertLabel( const SwLabelType eType, const OUString &rText, const OUString& rSeparator,
764
                      const OUString& rNumberSeparator,
765
                      const bool bBefore, const sal_uInt16 nId,
766
                      const UIName& rCharacterStyle,
767
                      const bool bCpyBrd );
768
769
    /// The ruler needs some information too.
770
    SW_DLLPUBLIC sal_uInt16 GetCurColNum( SwGetCurColNumPara* pPara = nullptr ) const; //0 == not in any column.
771
    sal_uInt16 GetCurMouseColNum( const Point &rPt ) const;
772
    size_t GetCurTabColNum() const;     //0 == not in any table.
773
    size_t GetCurMouseTabColNum( const Point &rPt ) const;
774
    sal_uInt16 GetCurOutColNum() const;  ///< Current outer column.
775
776
    bool IsColRightToLeft() const;
777
    SW_DLLPUBLIC bool IsTableRightToLeft() const;
778
    bool IsMouseTableRightToLeft( const Point &rPt ) const;
779
    bool IsTableVertical() const;
780
781
    bool IsLastCellInRow() const;
782
783
    /// Width of current range for column-dialog.
784
    SW_DLLPUBLIC tools::Long GetSectionWidth( SwFormat const & rFormat ) const;
785
786
    SW_DLLPUBLIC void GetConnectableFrameFormats
787
    (SwFrameFormat & rFormat, std::u16string_view rReference, bool bSuccessors,
788
     std::vector< UIName > & aPrevPageVec,
789
     std::vector< UIName > & aThisPageVec,
790
     std::vector< UIName > & aNextPageVec,
791
     std::vector< UIName > & aRestVec);
792
793
    /** SwFEShell::GetShapeBackground
794
795
        method determines background color of the page the selected drawing
796
        object is on and returns this color.
797
        If no color is found, because no drawing object is selected or ...,
798
        color COL_BLACK (default color on constructing object of class Color)
799
        is returned.
800
801
        @returns an object of class Color
802
    */
803
    Color GetShapeBackground() const;
804
805
    /** Is default horizontal text direction for selected drawing object right-to-left
806
807
        Because drawing objects only painted for each page only, the default
808
        horizontal text direction of a drawing object is given by the corresponding
809
        page property.
810
811
        @returns boolean, indicating, if the horizontal text direction of the
812
        page, the selected drawing object is on, is right-to-left.
813
    */
814
    bool IsShapeDefaultHoriTextDirR2L() const;
815
816
    void ParkCursorInTab();
817
818
    SwTextNode * GetNumRuleNodeAtPos(const Point &rPot);
819
    bool IsNumLabel( const Point &rPt, int nMaxOffset = -1 );
820
821
    static bool IsVerticalModeAtNdAndPos( const SwTextNode& _rTextNode,
822
                                   const Point& _rDocPos );
823
824
    void ToggleHeaderFooterEdit( );
825
    static void SetLineEnds(SfxItemSet& rAttr, SdrObject const & rObj, sal_uInt16 nSlotId);
826
827
    void ClearColumnRowCache(SwTabFrame const*);
828
};
829
830
void ClearFEShellTabCols(SwDoc & rDoc, SwTabFrame const*const pFrame);
831
832
#endif
833
834
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */