Coverage Report

Created: 2026-03-31 11:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/editeng/outliner.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_EDITENG_OUTLINER_HXX
20
#define INCLUDED_EDITENG_OUTLINER_HXX
21
22
#include <sot/formats.hxx>
23
#include <editeng/editdata.hxx>
24
#include <editeng/editstat.hxx>
25
#include <editeng/overflowingtxt.hxx>
26
#include <i18nlangtag/lang.h>
27
#include <rtl/ustring.hxx>
28
#include <svl/SfxBroadcaster.hxx>
29
#include <svl/languageoptions.hxx>
30
#include <svl/undo.hxx>
31
#include <tools/gen.hxx>
32
#include <tools/color.hxx>
33
#include <utility>
34
#include <vcl/outdev.hxx>
35
#include <comphelper/errcode.hxx>
36
#include <comphelper/lok.hxx>
37
#include <tools/link.hxx>
38
#include <editeng/editengdllapi.h>
39
#include <editeng/svxfont.hxx>
40
#include <editeng/paragraphdata.hxx>
41
#include <o3tl/typed_flags_set.hxx>
42
43
#include <optional>
44
#include <functional>
45
#include <memory>
46
#include <vector>
47
48
class OutlinerEditEng;
49
class Outliner;
50
class EditView;
51
class EditUndo;
52
class EditUndoManager;
53
class ParagraphList;
54
class OutlinerParaObject;
55
class SvStream;
56
class SvxSearchItem;
57
class SvxFieldItem;
58
namespace vcl { class Window; }
59
namespace weld { class Widget; }
60
class KeyEvent;
61
class MouseEvent;
62
class CommandEvent;
63
class MapMode;
64
class SfxStyleSheetPool;
65
class SfxStyleSheet;
66
class SfxItemPool;
67
class SfxItemSet;
68
class SvxNumberFormat;
69
class EditEngine;
70
class SvKeyValueIterator;
71
class SvxForbiddenCharactersTable;
72
class OutlinerViewShell;
73
enum class CharCompressType;
74
enum class TransliterationFlags;
75
class SvxFieldData;
76
enum class PointerStyle;
77
class SvxNumRule;
78
enum class TextRotation;
79
enum class SdrCompatibilityFlag;
80
class DrawPortionInfo;
81
class DrawBulletInfo;
82
class StripPortionsHelper;
83
84
namespace com::sun::star::linguistic2 {
85
    class XSpellChecker1;
86
    class XHyphenator;
87
}
88
namespace svx{
89
    struct SpellPortion;
90
    typedef std::vector<SpellPortion> SpellPortions;
91
}
92
namespace basegfx { class B2DPolyPolygon; }
93
namespace com::sun::star::lang { struct Locale; }
94
95
96
97
// internal use only!
98
enum class ParaFlag
99
{
100
    NONE               = 0x0000,
101
    HOLDDEPTH          = 0x4000,
102
    ISPAGE             = 0x0100,
103
};
104
namespace o3tl
105
{
106
    template<> struct typed_flags<ParaFlag> : is_typed_flags<ParaFlag, 0xc100> {};
107
}
108
109
// Undo-Action-Ids
110
13.9k
#define OLUNDO_DEPTH            EDITUNDO_USER
111
// #define OLUNDO_HEIGHT           EDITUNDO_USER+1
112
0
#define OLUNDO_EXPAND           EDITUNDO_USER+2
113
0
#define OLUNDO_COLLAPSE         EDITUNDO_USER+3
114
// #define OLUNDO_REMOVE           EDITUNDO_USER+4
115
5.90M
#define OLUNDO_ATTR             EDITUNDO_USER+5
116
0
#define OLUNDO_INSERT           EDITUNDO_USER+6
117
// #define OLUNDO_MOVEPARAGRAPHS    EDITUNDO_USER+7
118
119
/** Information about the bullet in the paragraph*/
120
struct BulletInfo
121
{
122
public:
123
    OUString maText;
124
    Size maSize = Size(-1, -1);
125
    ScalingParameters maScalingParameters;
126
};
127
128
class Paragraph : protected ParagraphData
129
{
130
private:
131
    friend class Outliner;
132
    friend class ParagraphList;
133
    friend class OutlinerView;
134
    friend class OutlinerParaObject;
135
    friend class OutlinerEditEng;
136
    friend class OutlinerUndoCheckPara;
137
    friend class OutlinerUndoChangeParaFlags;
138
139
    Paragraph& operator=(const Paragraph& rPara ) = delete;
140
141
    BulletInfo maBullet;
142
    ParaFlag nFlags = ParaFlag::NONE;
143
    bool bVisible = true;
144
145
0
    bool                IsVisible() const { return bVisible; }
146
147
    void SetText(const OUString& rText)
148
2.30M
    {
149
2.30M
        maBullet.maText = rText;
150
2.30M
        Invalidate();
151
2.30M
    }
152
153
    /// Sets the bullet size as well as the scaling parameters used to calculate the size
154
    void SetBulletSize(Size const& rSize, ScalingParameters const& rScalingParameters)
155
763k
    {
156
763k
        maBullet.maSize = rSize;
157
763k
        maBullet.maScalingParameters = rScalingParameters;
158
763k
    }
159
160
    /// Current size of the bullet
161
    Size const& GetBulletSize()
162
765k
    {
163
765k
        return maBullet.maSize;
164
765k
    }
165
166
    /// Is the bullet size invalid for the current scaling parameters
167
    bool IsBulletInvalid(ScalingParameters const& rCurrentScalingParameters)
168
765k
    {
169
765k
        return rCurrentScalingParameters != maBullet.maScalingParameters
170
765k
            || maBullet.maSize.Width() == -1
171
1.76k
            || maBullet.maSize.Height() == -1;
172
765k
    }
173
174
    /// Invalidate paragraph calculated information: bullet size
175
    void Invalidate()
176
605M
    {
177
605M
        maBullet.maSize.setWidth(-1);
178
605M
        maBullet.maSize.setHeight(-1);
179
605M
    }
180
181
    void SetDepth(sal_Int16 nNewDepth)
182
20.0M
    {
183
20.0M
        nDepth = nNewDepth;
184
20.0M
        Invalidate();
185
20.0M
    }
186
187
    const OUString& GetText() const
188
559M
    {
189
559M
        return maBullet.maText;
190
559M
    }
191
192
                        Paragraph( sal_Int16 nDepth );
193
                        Paragraph( const Paragraph& ) = delete;
194
                        Paragraph( const ParagraphData& );
195
196
583M
    sal_Int16           GetDepth() const { return nDepth; }
197
198
11.2k
    sal_Int16           GetNumberingStartValue() const { return mnNumberingStartValue; }
199
    void                SetNumberingStartValue( sal_Int16 nNumberingStartValue );
200
201
11.2k
    bool                IsParaIsNumberingRestart() const { return mbParaIsNumberingRestart; }
202
    void                SetParaIsNumberingRestart( bool bParaIsNumberingRestart );
203
204
0
    void                SetFlag( ParaFlag nFlag ) { nFlags |= nFlag; }
205
0
    void                RemoveFlag( ParaFlag nFlag ) { nFlags &= ~nFlag; }
206
835
    bool                HasFlag( ParaFlag nFlag ) const { return bool(nFlags & nFlag); }
207
208
public:
209
    void dumpAsXml(xmlTextWriterPtr pWriter) const;
210
};
211
212
struct ParaRange
213
{
214
    sal_Int32  nStartPara;
215
    sal_Int32  nEndPara;
216
217
0
            ParaRange( sal_Int32 nS, sal_Int32 nE ) : nStartPara(nS), nEndPara(nE) {}
218
219
    void    Adjust();
220
};
221
222
inline void ParaRange::Adjust()
223
0
{
224
0
    if ( nStartPara > nEndPara )
225
0
    {
226
0
        std::swap(nStartPara, nEndPara);
227
0
    }
228
0
}
229
230
class EDITENG_DLLPUBLIC OutlinerView final
231
{
232
    friend class Outliner;
233
234
    Outliner&                   rOwner;
235
    std::unique_ptr<EditView>   pEditView;
236
237
    enum class MouseTarget {
238
        Text = 0,
239
        Bullet = 1,
240
        Hypertext = 2,  // Outside OutputArea
241
        Outside = 3     // Outside OutputArea
242
    };
243
244
    SAL_DLLPRIVATE void         ImplExpandOrCollaps( sal_Int32 nStartPara, sal_Int32 nEndPara, bool bExpand );
245
246
    SAL_DLLPRIVATE sal_Int32    ImpCheckMousePos( const Point& rPosPixel, MouseTarget& reTarget);
247
    SAL_DLLPRIVATE void         ImpToggleExpand( Paragraph const * pParentPara );
248
    SAL_DLLPRIVATE ParaRange    ImpGetSelectedParagraphs( bool bIncludeHiddenChildren );
249
250
    SAL_DLLPRIVATE sal_Int32    ImpInitPaste( sal_Int32& rStart );
251
    SAL_DLLPRIVATE void         ImpPasted( sal_Int32 nStart, sal_Int32 nPrevParaCount, sal_Int32 nSize);
252
    SAL_DLLPRIVATE sal_Int32    ImpCalcSelectedPages( bool bIncludeFirstSelected );
253
254
    Link<LinkParamNone*,void> aEndCutPasteLink;
255
256
public:
257
    OutlinerView(Outliner& rOutliner, vcl::Window* pWindow);
258
    ~OutlinerView();
259
260
0
    EditView&   GetEditView() const { return *pEditView; }
261
262
    void        Scroll( tools::Long nHorzScroll, tools::Long nVertScroll );
263
264
    void        DrawText_ToEditView( const tools::Rectangle& rRect, OutputDevice* pTargetDevice = nullptr );
265
    bool        PostKeyEvent( const KeyEvent& rKEvt, vcl::Window const * pFrameWin = nullptr );
266
    bool        MouseButtonDown( const MouseEvent& );
267
    bool        MouseButtonUp( const MouseEvent& );
268
    void        ReleaseMouse();
269
    bool        MouseMove( const MouseEvent& );
270
271
    void        ShowCursor( bool bGotoCursor = true, bool bActivate = false );
272
    void        HideCursor( bool bDeactivate = false );
273
    bool IsCursorVisible() const;
274
275
0
    Outliner&   GetOutliner() const { return rOwner; }
276
277
    void        SetWindow( vcl::Window* pWindow );
278
    vcl::Window*     GetWindow() const;
279
280
    void        SetReadOnly( bool bReadOnly );
281
    bool        IsReadOnly() const;
282
283
    void        SetOutputArea( const tools::Rectangle& rRect );
284
    tools::Rectangle const & GetOutputArea() const;
285
286
    tools::Rectangle GetVisArea() const;
287
288
    void        CreateSelectionList (std::vector<Paragraph*> &aSelList) ;
289
290
    void        Select( Paragraph const * pParagraph, bool bSelect = true);
291
292
    OUString    GetSelected() const;
293
    void        SelectRange( sal_Int32 nFirst, sal_Int32 nCount );
294
    void        SetAttribs( const SfxItemSet& );
295
    void        Indent( short nDiff );
296
    sal_Int16   GetDepth() const;
297
    void        SetDepth(sal_Int32 nParagraph, sal_Int16 nDepth);
298
    void        AdjustDepth( short nDX );   // Later replace with Indent!
299
300
    void        AdjustHeight( tools::Long nDY );
301
302
    void        Read( SvStream& rInput, EETextFormat eFormat, SvKeyValueIterator* pHTTPHeaderAttrs );
303
304
    void        InsertText( const OUString& rNew, bool bSelect = false );
305
    void        InsertText( const OutlinerParaObject& rParaObj );
306
    void        Expand();
307
    void        Collapse();
308
    void        ExpandAll();
309
    void        CollapseAll();
310
311
    void        SetBackgroundColor( const Color& rColor );
312
    Color const & GetBackgroundColor() const;
313
314
    /// Informs this edit view about which view shell contains it.
315
    void RegisterViewShell(OutlinerViewShell* pViewShell);
316
317
    SfxItemSet  GetAttribs();
318
319
    void        Cut();
320
    void        Copy();
321
    void        Paste( bool bUseSpecial = false, SotClipboardFormatId format = SotClipboardFormatId::NONE );
322
    void        PasteSpecial(SotClipboardFormatId format = SotClipboardFormatId::NONE);
323
324
    void SetStyleSheet(const OUString& rStyleName);
325
326
    const SfxStyleSheet*  GetStyleSheet() const;
327
    SfxStyleSheet*  GetStyleSheet();
328
329
    void            SetControlWord( EVControlBits nWord );
330
    EVControlBits   GetControlWord() const;
331
332
    void            SetAnchorMode( EEAnchorMode eMode );
333
    EEAnchorMode    GetAnchorMode() const;
334
335
    PointerStyle    GetPointer( const Point& rPosPixel );
336
    bool            Command(const CommandEvent& rCEvt);
337
338
    void            StartSpeller(weld::Widget* pDialogParent);
339
    EESpellState    StartThesaurus(weld::Widget* pDialogParent);
340
    sal_Int32       StartSearchAndReplace( const SvxSearchItem& rSearchItem );
341
342
    // for text conversion
343
    void            StartTextConversion(weld::Widget* pDialogParent, LanguageType nSrcLang, LanguageType nDestLang, const vcl::Font *pDestFont, sal_Int32 nOptions, bool bIsInteractive, bool bMultipleDoc);
344
345
    void            TransliterateText( TransliterationFlags nTransliterationMode );
346
347
    ESelection      GetSelection() const;
348
349
    SvtScriptType   GetSelectedScriptType() const;
350
351
    void        SetVisArea( const tools::Rectangle& rRect );
352
    void        SetSelection( const ESelection& );
353
    void GetSelectionRectangles(std::vector<tools::Rectangle>& rLogicRects) const;
354
355
    void        RemoveAttribs( bool bRemoveParaAttribs, bool bKeepLanguages = false );
356
    void        RemoveAttribsKeepLanguages( bool bRemoveParaAttribs );
357
    bool        HasSelection() const;
358
359
    void                InsertField( const SvxFieldItem& rFld );
360
    const SvxFieldItem* GetFieldUnderMousePointer() const;
361
    const SvxFieldItem* GetFieldAtSelection(bool bAlsoCheckBeforeCursor = false) const;
362
    /// if no selection, select the field immediately after or before the current cursor
363
    void SelectFieldAtCursor();
364
365
    /** enables bullets for the selected paragraphs if the bullets/numbering of the first paragraph is off
366
        or disables bullets/numbering for the selected paragraphs if the bullets/numbering of the first paragraph is on
367
    */
368
    void ToggleBullets();
369
    bool IsBulletOrNumbering(bool& bBullets, bool& bNumbering);
370
371
    void ToggleBulletsNumbering(
372
        const bool bToggle,
373
        const bool bHandleBullets,
374
        const SvxNumRule* pNumRule );
375
376
    /** apply bullets/numbering for paragraphs
377
378
        @param boolean bHandleBullets
379
        true: handle bullets
380
        false: handle numbering
381
382
        @param pNewNumRule
383
        numbering rule which needs to be applied. can be 0.
384
385
        @param boolean bAtSelection
386
        true: apply bullets/numbering at selected paragraphs
387
        false: apply bullets/numbering at all paragraphs
388
    */
389
    void ApplyBulletsNumbering(
390
        const bool bHandleBullets,
391
        const SvxNumRule* pNewNumRule,
392
        const bool bCheckCurrentNumRuleBeforeApplyingNewNumRule,
393
        const bool bAtSelection = false );
394
395
    /** switch off bullets/numbering for paragraphs
396
397
        @param boolean bAtSelection
398
        true: switch off bullets/numbering at selected paragraphs
399
        false: switch off bullets/numbering at all paragraphs
400
    */
401
    void SwitchOffBulletsNumbering(
402
        const bool bAtSelection = false );
403
404
    /** enables numbering for the selected paragraphs that are not enabled and ignore all selected
405
        paragraphs that already have numbering enabled.
406
    */
407
    void        EnsureNumberingIsOn();
408
409
    bool        IsCursorAtWrongSpelledWord();
410
    bool        IsWrongSpelledWordAtPos( const Point& rPosPixel );
411
    bool        ExecuteSpellPopup(const Point& rPosPixel, const Link<SpellCallbackInfo&,void>& rCallBack);
412
413
    void        SetInvalidateMore( sal_uInt16 nPixel );
414
    sal_uInt16  GetInvalidateMore() const;
415
416
    OUString    GetSurroundingText() const;
417
    Selection   GetSurroundingTextSelection() const;
418
    bool        DeleteSurroundingText(const Selection& rRange);
419
420
0
    void        SetEndCutPasteLinkHdl(const Link<LinkParamNone*,void> &rLink) { aEndCutPasteLink = rLink; }
421
};
422
423
/// Interface class to not depend on SfxViewShell in editeng.
424
class SAL_NO_VTABLE SAL_DLLPUBLIC_RTTI OutlinerViewShell
425
{
426
public:
427
    virtual void libreOfficeKitViewCallback(int nType, const OString& pPayload) const = 0;
428
    virtual void libreOfficeKitViewCallbackWithViewId(int nType, const OString& pPayload, int nViewId) const = 0;
429
    virtual void libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle* pRect, int nPart, int nMode) const = 0;
430
    virtual void libreOfficeKitViewUpdatedCallback(int nType) const = 0;
431
    virtual void libreOfficeKitViewUpdatedCallbackPerViewId(int nType, int nViewId, int nSourceViewId) const = 0;
432
    virtual void libreOfficeKitViewAddPendingInvalidateTiles() = 0;
433
    virtual ViewShellId GetViewShellId() const = 0;
434
    virtual ViewShellDocId GetDocId() const = 0;
435
    /// Wrapper around SfxLokHelper::notifyOtherViews().
436
    virtual void NotifyOtherViews(int nType, const OString& rKey, const OString& rPayload) = 0;
437
    /// Wrapper around SfxLokHelper::notifyOtherView().
438
    virtual void NotifyOtherView(OutlinerViewShell* pOtherShell, int nType, const OString& rKey, const OString& rPayload) = 0;
439
    virtual vcl::Window* GetEditWindowForActiveOLEObj() const = 0;
440
441
protected:
442
4.08k
    ~OutlinerViewShell() noexcept {}
443
};
444
445
// some thesaurus functionality to avoid code duplication in different projects...
446
bool EDITENG_DLLPUBLIC  GetStatusValueForThesaurusFromContext( OUString &rStatusVal, LanguageType &rLang, const EditView &rEditView );
447
void EDITENG_DLLPUBLIC  ReplaceTextWithSynonym( EditView &rEditView, const OUString &rSynonmText );
448
449
typedef ::std::vector< OutlinerView* > ViewList;
450
451
struct EDITENG_DLLPUBLIC PaintFirstLineInfo
452
{
453
    sal_Int32 mnPara;
454
    const Point& mrStartPos;
455
    VclPtr<OutputDevice> mpOutDev;
456
    StripPortionsHelper& mrStripPortionsHelper;
457
458
    PaintFirstLineInfo( sal_Int32 nPara, const Point& rStartPos, OutputDevice* pOutDev, StripPortionsHelper& rStripPortionsHelper )
459
0
        : mnPara( nPara ), mrStartPos( rStartPos ), mpOutDev( pOutDev ), mrStripPortionsHelper( rStripPortionsHelper )
460
0
    {}
461
};
462
463
class SdrPage;
464
465
class EditFieldInfo
466
{
467
private:
468
    Outliner*           pOutliner;
469
    const SvxFieldItem& rFldItem;
470
471
    std::optional<Color> mxTxtColor;
472
    std::optional<Color> mxFldColor;
473
    std::optional<FontLineStyle> mxFldLineStyle;
474
475
    OUString            aRepresentation;
476
477
    sal_Int32           nPara;
478
    sal_Int32           nPos;
479
480
                        EditFieldInfo( const EditFieldInfo& ) = delete;
481
482
    SdrPage*            mpSdrPage;
483
484
public:
485
                    EditFieldInfo( Outliner* pOutl, const SvxFieldItem& rFItem, sal_Int32 nPa, sal_Int32 nPo )
486
3.29M
                        : rFldItem( rFItem )
487
3.29M
                    {
488
3.29M
                        pOutliner = pOutl;
489
3.29M
                        nPara = nPa; nPos = nPo;
490
3.29M
                        mpSdrPage = nullptr;
491
3.29M
                    }
492
493
6.56M
    Outliner*       GetOutliner() const { return pOutliner; }
494
495
3.29M
    const SvxFieldItem& GetField() const { return rFldItem; }
496
497
3.31M
    std::optional<Color> const & GetTextColor() const { return mxTxtColor; }
498
21.1k
    void            SetTextColor( std::optional<Color> xCol ) { mxTxtColor = xCol; }
499
500
3.75M
    std::optional<Color> const & GetFieldColor() const { return mxFldColor; }
501
461k
    void            SetFieldColor( std::optional<Color> xCol ) { mxFldColor = xCol; }
502
503
3.29M
    std::optional<FontLineStyle> const& GetFontLineStyle() const { return mxFldLineStyle; }
504
0
    void            SetFontLineStyle( std::optional<FontLineStyle> xLineStyle ) { mxFldLineStyle = xLineStyle; }
505
506
193k
    sal_Int32       GetPara() const { return nPara; }
507
193k
    sal_Int32       GetPos() const { return nPos; }
508
509
0
    const OUString&     GetRepresentation() const                { return aRepresentation; }
510
3.29M
    OUString&           GetRepresentation()                      { return aRepresentation; }
511
3.29M
    void                SetRepresentation( const OUString& rStr ){ aRepresentation = rStr; }
512
513
0
    void            SetSdrPage( SdrPage* pPage ) { mpSdrPage = pPage; }
514
3.07M
    SdrPage*        GetSdrPage() const { return mpSdrPage; }
515
};
516
517
 struct EBulletInfo
518
{
519
    SvxFont           aFont;
520
    tools::Rectangle  aBounds;
521
    OUString          aText;
522
    sal_Int32         nParagraph;
523
    sal_uInt16        nType;          // see SvxNumberType
524
    bool              bVisible;
525
526
418
    EBulletInfo() : nParagraph( EE_PARA_MAX ), nType( 0 ), bVisible( false ) {}
527
};
528
529
enum class OutlinerMode {
530
    DontKnow       = 0x0000,
531
    TextObject     = 0x0001,
532
    TitleObject    = 0x0002,
533
    OutlineObject  = 0x0003,
534
    OutlineView    = 0x0004
535
};
536
537
enum class SdrCompatibilityFlag;
538
539
typedef std::vector<EENotify> NotifyList;
540
541
class EDITENG_DLLPUBLIC Outliner : public SfxBroadcaster
542
{
543
public:
544
    struct ParagraphHdlParam { Outliner* pOutliner; Paragraph* pPara; };
545
    struct DepthChangeHdlParam { Outliner* pOutliner; Paragraph* pPara; ParaFlag nPrevFlags; };
546
private:
547
    friend class OutlinerView;
548
    friend class OutlinerEditEng;
549
    friend class OutlinerParaObject;
550
    friend class OLUndoExpand;
551
    friend class OutlinerUndoChangeDepth;
552
    friend class OutlinerUndoCheckPara;
553
    friend class OutlinerUndoChangeParaFlags;
554
555
    friend class TextChainingUtils;
556
557
    std::unique_ptr<OutlinerEditEng> pEditEngine;
558
559
    std::unique_ptr<ParagraphList>   pParaList;
560
    ViewList            aViewList;
561
562
    sal_Int32           mnFirstSelPage;
563
    Link<ParagraphHdlParam,void>   aParaInsertedHdl;
564
    Link<ParagraphHdlParam,void>   aParaRemovingHdl;
565
    Link<DepthChangeHdlParam,void> aDepthChangedHdl;
566
    Link<Outliner*,void>           aBeginMovingHdl;
567
    Link<Outliner*,void>           aEndMovingHdl;
568
    Link<OutlinerView*,bool>       aIndentingPagesHdl;
569
    Link<OutlinerView*,bool>       aRemovingPagesHdl;
570
    Link<EditFieldInfo*,void>      aCalcFieldValueHdl;
571
    Link<PaintFirstLineInfo*,void> maPaintFirstLineHdl;
572
    Link<PasteOrDropInfos*,void>   maBeginPasteOrDropHdl;
573
    Link<PasteOrDropInfos*,void>   maEndPasteOrDropHdl;
574
575
    sal_Int32           nDepthChangedHdlPrevDepth;
576
    sal_Int16           nMaxDepth;
577
    static constexpr sal_Int16 gnMinDepth = -1;
578
579
    OutlinerMode        nOutlinerMode;
580
581
    bool                bFirstParaIsEmpty;
582
    sal_uInt8           nBlockInsCallback;
583
    bool                bPasting;
584
585
    Link<EENotify&,void> aOutlinerNotifyHdl;
586
    NotifyList          aNotifyCache;
587
588
    DECL_DLLPRIVATE_LINK(    ParaVisibleStateChangedHdl, Paragraph&, void );
589
    DECL_DLLPRIVATE_LINK(    BeginMovingParagraphsHdl, MoveParagraphsInfo&, void );
590
    DECL_DLLPRIVATE_LINK(    EndMovingParagraphsHdl, MoveParagraphsInfo&, void );
591
    DECL_DLLPRIVATE_LINK(    BeginPasteOrDropHdl, PasteOrDropInfos&, void );
592
    DECL_DLLPRIVATE_LINK(    EndPasteOrDropHdl, PasteOrDropInfos&, void );
593
    DECL_DLLPRIVATE_LINK(    EditEngineNotifyHdl, EENotify&, void );
594
    SAL_DLLPRIVATE void                ImplCheckParagraphs( sal_Int32 nStart, sal_Int32 nEnd );
595
    SAL_DLLPRIVATE bool                ImplHasNumberFormat( sal_Int32 nPara ) const;
596
    SAL_DLLPRIVATE Size                ImplGetBulletSize( sal_Int32 nPara );
597
    SAL_DLLPRIVATE sal_uInt16          ImplGetNumbering( sal_Int32 nPara, const SvxNumberFormat* pParaFmt );
598
    SAL_DLLPRIVATE void                ImplCalcBulletText( sal_Int32 nPara, bool bRecalcLevel, bool bRecalcChildren );
599
    SAL_DLLPRIVATE OUString            ImplGetBulletText( sal_Int32 nPara );
600
    SAL_DLLPRIVATE void                ImplCheckNumBulletItem( sal_Int32 nPara );
601
    SAL_DLLPRIVATE void                ImplInitDepth( sal_Int32 nPara, sal_Int16 nDepth, bool bCreateUndo );
602
    SAL_DLLPRIVATE void                ImplSetLevelDependentStyleSheet( sal_Int32 nPara );
603
604
    SAL_DLLPRIVATE void                ImplBlockInsertionCallbacks( bool b );
605
606
    SAL_DLLPRIVATE void        ImpFilterIndents( sal_Int32 nFirstPara, sal_Int32 nLastPara );
607
    SAL_DLLPRIVATE bool        ImpConvertEdtToOut( sal_Int32 nPara );
608
609
    SAL_DLLPRIVATE void        ImpTextPasted( sal_Int32 nStartPara, sal_Int32 nCount );
610
    SAL_DLLPRIVATE vcl::Font   ImpCalcBulletFont( sal_Int32 nPara ) const;
611
    SAL_DLLPRIVATE tools::Rectangle   ImpCalcBulletArea( sal_Int32 nPara, bool bAdjust, bool bReturnPaperPos );
612
    SAL_DLLPRIVATE bool        ImpCanIndentSelectedPages( OutlinerView* pCurView );
613
    SAL_DLLPRIVATE bool        ImpCanDeleteSelectedPages( OutlinerView* pCurView );
614
    SAL_DLLPRIVATE bool        ImpCanDeleteSelectedPages( OutlinerView* pCurView, sal_Int32 nFirstPage, sal_Int32 nPages );
615
616
    SAL_DLLPRIVATE void        ImplCheckDepth( sal_Int16& rnDepth ) const;
617
618
0
    SAL_DLLPRIVATE OutlinerEditEng& getOutlinerEditEng() { return *pEditEngine; }
619
620
protected:
621
    SAL_DLLPRIVATE void            ParagraphInserted( sal_Int32 nParagraph );
622
    SAL_DLLPRIVATE void            ParagraphDeleted( sal_Int32 nParagraph );
623
    SAL_DLLPRIVATE void            ParaAttribsChanged( sal_Int32 nParagraph );
624
625
    SAL_DLLPRIVATE void            StyleSheetChanged( SfxStyleSheet const * pStyle );
626
627
    SAL_DLLPRIVATE void            InvalidateBullet(sal_Int32 nPara);
628
    SAL_DLLPRIVATE void            StripBullet(
629
        sal_Int32 nPara, const Point& rStartPos, OutputDevice& rOutDev, StripPortionsHelper& rStripPortionsHelper);
630
631
    // used by OutlinerEditEng. Allows Outliner objects to provide
632
    // bullet access to the EditEngine.
633
    SAL_DLLPRIVATE const SvxNumberFormat*  GetNumberFormat( sal_Int32 nPara ) const;
634
635
public:
636
637
                    Outliner( SfxItemPool* pPool, OutlinerMode nMode );
638
    virtual         ~Outliner() override;
639
640
    void            dumpAsXml(xmlTextWriterPtr pWriter) const;
641
642
    void            Init( OutlinerMode nMode );
643
644
    void            SetVertical( bool bVertical);
645
    void            SetRotation(TextRotation nRotation);
646
    bool            IsVertical() const;
647
    bool            IsTopToBottom() const;
648
649
    void SetTextColumns(sal_Int16 nColumns, sal_Int32 nSpacing);
650
651
    void            SetFixedCellHeight( bool bUseFixedCellHeight );
652
653
    void                        SetDefaultHorizontalTextDirection( EEHorizontalTextDirection eHTextDir );
654
    EEHorizontalTextDirection   GetDefaultHorizontalTextDirection() const;
655
656
    LanguageType    GetLanguage( sal_Int32 nPara, sal_Int32 nPos ) const;
657
658
    void            SetAsianCompressionMode( CharCompressType nCompressionMode );
659
660
    void            SetKernAsianPunctuation( bool bEnabled );
661
662
    void            SetAddExtLeading( bool b );
663
664
    size_t          InsertView( OutlinerView* pView, size_t nIndex = size_t(-1) );
665
    void            RemoveView( OutlinerView const * pView );
666
    void            RemoveView( size_t nIndex );
667
    OutlinerView*   GetView( size_t nIndex ) const;
668
    size_t          GetViewCount() const;
669
670
    Paragraph*      Insert( const OUString& rText, sal_Int32 nAbsPos = EE_PARA_MAX, sal_Int16 nDepth = 0 );
671
    void            SetText( const OutlinerParaObject& );
672
    void            AddText( const OutlinerParaObject&, bool bAppend = false );
673
    void            SetText( const OUString& rText, Paragraph* pParagraph );
674
    OUString        GetText( Paragraph const * pPara, sal_Int32 nParaCount=1 ) const;
675
676
    void            SetToEmptyText();
677
678
    std::optional<OutlinerParaObject> CreateParaObject( sal_Int32 nStartPara = 0, sal_Int32 nParaCount = EE_PARA_MAX ) const;
679
680
    const SfxItemSet& GetEmptyItemSet() const;
681
682
    void            SetRefMapMode( const MapMode& );
683
    MapMode const & GetRefMapMode() const;
684
685
    void            SetBackgroundColor( const Color& rColor );
686
    Color const &   GetBackgroundColor() const;
687
688
    SAL_DLLPRIVATE void            SetMaxDepth( sal_Int16 nDepth );
689
0
    SAL_DLLPRIVATE sal_Int16       GetMaxDepth() const { return nMaxDepth; }
690
691
    /// @return previous value of bUpdateLayout state
692
    bool            SetUpdateLayout( bool bUpdate );
693
    bool            IsUpdateLayout() const;
694
695
    void            Clear();
696
697
    void            RemoveAttribs( const ESelection& rSelection, bool bRemoveParaAttribs, sal_uInt16 nWhich );
698
699
    sal_Int32       GetParagraphCount() const;
700
    Paragraph*      GetParagraph( sal_Int32 nAbsPos ) const;
701
702
    bool            HasChildren( Paragraph const * pParagraph ) const;
703
    sal_Int32       GetChildCount( Paragraph const * pParent ) const;
704
    bool            IsExpanded( Paragraph const * pPara ) const;
705
    Paragraph*      GetParent( Paragraph const * pParagraph ) const;
706
    sal_Int32       GetAbsPos( Paragraph const * pPara ) const;
707
708
    sal_Int16       GetDepth( sal_Int32 nPara ) const;
709
    void            SetDepth( Paragraph* pParagraph, sal_Int16 nNewDepth );
710
711
    void            EnableUndo( bool bEnable );
712
    bool            IsUndoEnabled() const;
713
    void            UndoActionStart( sal_uInt16 nId );
714
    void            UndoActionEnd();
715
    SAL_DLLPRIVATE void            InsertUndo( std::unique_ptr<EditUndo> pUndo );
716
    bool            IsInUndo() const;
717
718
    void            ClearModifyFlag();
719
    bool            IsModified() const;
720
721
    SAL_DLLPRIVATE void            ParagraphInsertedHdl(Paragraph*);
722
0
    SAL_DLLPRIVATE void            SetParaInsertedHdl(const Link<ParagraphHdlParam,void>& rLink){aParaInsertedHdl=rLink;}
723
0
    SAL_DLLPRIVATE const Link<ParagraphHdlParam,void>& GetParaInsertedHdl() const { return aParaInsertedHdl; }
724
725
0
    SAL_DLLPRIVATE void            SetParaRemovingHdl(const Link<ParagraphHdlParam,void>& rLink){aParaRemovingHdl=rLink;}
726
0
    SAL_DLLPRIVATE const Link<ParagraphHdlParam,void>& GetParaRemovingHdl() const { return aParaRemovingHdl; }
727
728
    SAL_DLLPRIVATE std::optional<NonOverflowingText> GetNonOverflowingText() const;
729
    SAL_DLLPRIVATE std::optional<OverflowingText> GetOverflowingText() const;
730
    void ClearOverflowingParaNum();
731
    bool IsPageOverflow();
732
733
    OutlinerParaObject GetEmptyParaObject() const;
734
735
736
    SAL_DLLPRIVATE void            DepthChangedHdl(Paragraph*, ParaFlag nPrevFlags);
737
0
    SAL_DLLPRIVATE void            SetDepthChangedHdl(const Link<DepthChangeHdlParam,void>& rLink){aDepthChangedHdl=rLink;}
738
0
    SAL_DLLPRIVATE const Link<DepthChangeHdlParam,void>& GetDepthChangedHdl() const { return aDepthChangedHdl; }
739
0
    SAL_DLLPRIVATE sal_Int16       GetPrevDepth() const { return static_cast<sal_Int16>(nDepthChangedHdlPrevDepth); }
740
741
    SAL_DLLPRIVATE bool            RemovingPagesHdl( OutlinerView* );
742
0
    SAL_DLLPRIVATE void            SetRemovingPagesHdl(const Link<OutlinerView*,bool>& rLink){aRemovingPagesHdl=rLink;}
743
    SAL_DLLPRIVATE bool            IndentingPagesHdl( OutlinerView* );
744
0
    SAL_DLLPRIVATE void            SetIndentingPagesHdl(const Link<OutlinerView*,bool>& rLink){aIndentingPagesHdl=rLink;}
745
    // valid only in the two upper handlers
746
0
    SAL_DLLPRIVATE sal_Int32       GetSelPageCount() const { return nDepthChangedHdlPrevDepth; }
747
748
487k
    SAL_DLLPRIVATE void            SetCalcFieldValueHdl(const Link<EditFieldInfo*,void>& rLink ) { aCalcFieldValueHdl= rLink; }
749
179k
    SAL_DLLPRIVATE const Link<EditFieldInfo*,void>& GetCalcFieldValueHdl() const { return aCalcFieldValueHdl; }
750
751
0
    SAL_DLLPRIVATE void            SetPaintFirstLineHdl(const Link<PaintFirstLineInfo*,void>& rLink) { maPaintFirstLineHdl = rLink; }
752
753
    void            SetModifyHdl( const Link<LinkParamNone*,void>& rLink );
754
755
    void            SetNotifyHdl( const Link<EENotify&,void>& rLink );
756
757
    void            SetStatusEventHdl( const Link<EditStatus&, void>& rLink );
758
    Link<EditStatus&, void> const & GetStatusEventHdl() const;
759
760
    void            DrawText_ToRectangle( OutputDevice& rOutDev, const tools::Rectangle& rOutRect );
761
    void            DrawText_ToPosition( OutputDevice& rOutDev, const Point& rStartPos );
762
763
    const Size&     GetPaperSize() const;
764
    void            SetPaperSize( const Size& rSize );
765
766
    void            SetPolygon( const basegfx::B2DPolyPolygon& rPolyPolygon );
767
    void            SetPolygon( const basegfx::B2DPolyPolygon& rPolyPolygon, const basegfx::B2DPolyPolygon* pLinePolyPolygon);
768
    void            ClearPolygon();
769
770
    const Size&     GetMinAutoPaperSize() const;
771
    void            SetMinAutoPaperSize( const Size& rSz );
772
773
    const Size&     GetMaxAutoPaperSize() const;
774
    void            SetMaxAutoPaperSize( const Size& rSz );
775
776
    void SetMinColumnWrapHeight(tools::Long nVal);
777
778
    void            SetDefTab( sal_uInt16 nTab );
779
780
    bool            IsFlatMode() const;
781
    void            SetFlatMode( bool bFlat );
782
783
    void            EnableAutoColor( bool b );
784
785
    void            ForceAutoColor( bool b );
786
    SAL_DLLPRIVATE bool            IsForceAutoColor() const;
787
788
    EBulletInfo     GetBulletInfo( sal_Int32 nPara );
789
790
    void            SetWordDelimiters( const OUString& rDelimiters );
791
    OUString const & GetWordDelimiters() const;
792
    OUString        GetWord( const EPaM& rPos );
793
794
    void StripPortions(StripPortionsHelper& rStripPortionsHelper);
795
796
    Size            CalcTextSize();
797
798
    void                SetStyleSheetPool( SfxStyleSheetPool* pSPool );
799
    SfxStyleSheetPool*  GetStyleSheetPool();
800
801
    bool            IsInSelectionMode() const;
802
803
    void            SetStyleSheet( sal_Int32 nPara, SfxStyleSheet* pStyle );
804
    SfxStyleSheet*  GetStyleSheet( sal_Int32 nPara );
805
806
    void            SetParaAttribs( sal_Int32 nPara, const SfxItemSet& );
807
    SfxItemSet const & GetParaAttribs( sal_Int32 nPara ) const;
808
809
    void            Remove( Paragraph const * pPara, sal_Int32 nParaCount );
810
    SAL_DLLPRIVATE bool            Expand( Paragraph const * );
811
    SAL_DLLPRIVATE bool            Collapse( Paragraph const * );
812
813
    void            SetParaFlag( Paragraph* pPara,  ParaFlag nFlag );
814
    static bool     HasParaFlag( const Paragraph* pPara, ParaFlag nFlag );
815
816
817
    void            SetControlWord( EEControlBits nWord );
818
    EEControlBits   GetControlWord() const;
819
820
0
    SAL_DLLPRIVATE const Link<Outliner*,void>& GetBeginMovingHdl() const { return aBeginMovingHdl; }
821
0
    SAL_DLLPRIVATE void            SetBeginMovingHdl(const Link<Outliner*,void>& rLink) {aBeginMovingHdl=rLink;}
822
0
    SAL_DLLPRIVATE const Link<Outliner*,void>& GetEndMovingHdl() const {return aEndMovingHdl;}
823
0
    SAL_DLLPRIVATE void            SetEndMovingHdl( const Link<Outliner*,void>& rLink){aEndMovingHdl=rLink;}
824
825
    sal_Int32       GetLineCount( sal_Int32 nParagraph ) const;
826
    sal_Int32           GetLineLen( sal_Int32 nParagraph, sal_Int32 nLine ) const;
827
    sal_uInt32           GetLineHeight( sal_Int32 nParagraph, sal_Int32 nLine = 0 );
828
829
    ErrCode             Read( SvStream& rInput, const OUString& rBaseURL, EETextFormat, SvKeyValueIterator* pHTTPHeaderAttrs = nullptr );
830
831
    EditUndoManager& GetUndoManager();
832
    EditUndoManager* SetUndoManager(EditUndoManager* pNew);
833
834
    void            QuickSetAttribs( const SfxItemSet& rSet, const ESelection& rSel );
835
    void            QuickInsertField( const SvxFieldItem& rFld, const ESelection& rSel );
836
    void            QuickInsertLineBreak( const ESelection& rSel );
837
838
    // Only for EditEngine mode
839
    void            QuickInsertText( const OUString& rText, const ESelection& rSel );
840
    void            QuickDelete( const ESelection& rSel );
841
    /// Set attributes from rSet an all characters of nPara.
842
    void SetCharAttribs(sal_Int32 nPara, const SfxItemSet& rSet);
843
    void            RemoveCharAttribs( sal_Int32 nPara, sal_uInt16 nWhich = 0 );
844
    void QuickFormatDoc();
845
846
    bool            UpdateFields();
847
0
    void            RemoveFields( const std::function<bool ( const SvxFieldData* )>& isFieldData = [] (const SvxFieldData* ){return true;} );
848
849
    virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, std::optional<Color>& rTxtColor, std::optional<Color>& rFldColor, std::optional<FontLineStyle>& rFldLineStyle );
850
851
    void            SetSpeller( css::uno::Reference< css::linguistic2::XSpellChecker1 > const &xSpeller );
852
    css::uno::Reference< css::linguistic2::XSpellChecker1 > const &
853
                    GetSpeller();
854
    void            SetHyphenator( css::uno::Reference< css::linguistic2::XHyphenator > const & xHyph );
855
856
    static void     SetForbiddenCharsTable(const std::shared_ptr<SvxForbiddenCharactersTable>& xForbiddenChars);
857
858
    // Deprecated
859
    void            SetDefaultLanguage( LanguageType eLang );
860
861
    void            CompleteOnlineSpelling();
862
863
    EESpellState    HasSpellErrors();
864
    bool            HasText( const SvxSearchItem& rSearchItem );
865
    virtual bool    SpellNextDocument();
866
867
    // for text conversion
868
    bool            HasConvertibleTextPortion( LanguageType nLang );
869
    virtual bool    ConvertNextDocument();
870
871
    void            SetEditEnginePool( SfxItemPool* pPool );
872
    SfxItemPool*    GetEditEnginePool() const;
873
874
    void            SetRefDevice( OutputDevice* pRefDev );
875
    OutputDevice*   GetRefDevice() const;
876
877
    sal_uInt32      GetTextHeight() const;
878
    SAL_DLLPRIVATE tools::Rectangle GetParaBounds( sal_Int32 nParagraph ) const;
879
    SAL_DLLPRIVATE Point           GetDocPos( const Point& rPaperPos ) const;
880
    bool            IsTextPos( const Point& rPaperPos, sal_uInt16 nBorder );
881
    SAL_DLLPRIVATE bool            IsTextPos( const Point& rPaperPos, sal_uInt16 nBorder, bool* pbBulletPos );
882
883
    const ScalingParameters & getScalingParameters() const;
884
    void setScalingParameters(ScalingParameters const& rScalingParameters);
885
    void resetScalingParameters()
886
3.71M
    {
887
3.71M
        setScalingParameters(ScalingParameters());
888
3.71M
    }
889
890
    void setRoundFontSizeToPt(bool bRound) const;
891
892
    void            EraseVirtualDevice();
893
894
    bool            ShouldCreateBigTextObject() const;
895
896
    const EditEngine& GetEditEngine() const;
897
898
    // this is needed for StarOffice Api
899
    SAL_DLLPRIVATE void            SetLevelDependentStyleSheet( sal_Int32 nPara );
900
901
19.3M
    SAL_DLLPRIVATE OutlinerMode    GetOutlinerMode() const { return nOutlinerMode; }
902
903
    // spell and return a sentence
904
    bool            SpellSentence(EditView const & rEditView, svx::SpellPortions& rToFill );
905
    // put spell position to start of current sentence
906
    void            PutSpellingToSentenceStart( EditView const & rEditView );
907
    // applies a changed sentence
908
    void            ApplyChangedSentence(EditView const & rEditView, const svx::SpellPortions& rNewPortions, bool bRecheck );
909
910
    /** sets a link that is called at the beginning of a drag operation at an edit view */
911
    void            SetBeginDropHdl( const Link<EditView*,void>& rLink );
912
913
    /** sets a link that is called at the end of a drag operation at an edit view */
914
    void            SetEndDropHdl( const Link<EditView*,void>& rLink );
915
916
    /** sets a link that is called before a drop or paste operation. */
917
    void            SetBeginPasteOrDropHdl( const Link<PasteOrDropInfos*,void>& rLink );
918
919
    /** sets a link that is called after a drop or paste operation. */
920
    void            SetEndPasteOrDropHdl( const Link<PasteOrDropInfos*,void>& rLink );
921
922
    sal_Int16 GetNumberingStartValue( sal_Int32 nPara ) const;
923
    void SetNumberingStartValue( sal_Int32 nPara, sal_Int16 nNumberingStartValue );
924
925
    bool IsParaIsNumberingRestart( sal_Int32 nPara ) const;
926
    void SetParaIsNumberingRestart( sal_Int32 nPara, bool bParaIsNumberingRestart );
927
928
    /** determine the bullets/numbering status of the given paragraphs
929
930
        @param nParaStart
931
        index of paragraph at which the check starts
932
933
        @param nParaEnd
934
        index of paragraph at which the check ends
935
936
        @returns
937
        0 : all paragraphs have bullets
938
        1 : all paragraphs have numbering
939
        2 : otherwise
940
    */
941
    sal_Int32 GetBulletsNumberingStatus(
942
        const sal_Int32 nParaStart,
943
        const sal_Int32 nParaEnd ) const;
944
945
    // convenient method to determine the bullets/numbering status for all paragraphs
946
    sal_Int32 GetBulletsNumberingStatus() const;
947
948
    // overridden in SdrOutliner
949
0
    SAL_DLLPRIVATE virtual std::optional<bool> GetCompatFlag(SdrCompatibilityFlag /*eFlag*/) const { return {}; };
950
951
    // return FirstParaIsEmpty state
952
0
    bool getFirstParaIsEmpty() const { return bFirstParaIsEmpty; }
953
};
954
955
#endif
956
957
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */