Coverage Report

Created: 2026-08-14 10:22

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