Coverage Report

Created: 2026-10-14 09:33

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/editeng/editobj.hxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
 * This file is part of the LibreOffice project.
4
 *
5
 * This Source Code Form is subject to the terms of the Mozilla Public
6
 * License, v. 2.0. If a copy of the MPL was not distributed with this
7
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
 *
9
 * This file incorporates work covered by the following license notice:
10
 *
11
 *   Licensed to the Apache Software Foundation (ASF) under one or more
12
 *   contributor license agreements. See the NOTICE file distributed
13
 *   with this work for additional information regarding copyright
14
 *   ownership. The ASF licenses this file to you under the Apache
15
 *   License, Version 2.0 (the "License"); you may not use this file
16
 *   except in compliance with the License. You may obtain a copy of
17
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18
 */
19
20
#ifndef INCLUDED_EDITENG_EDITOBJ_HXX
21
#define INCLUDED_EDITENG_EDITOBJ_HXX
22
23
#include <svl/style.hxx>
24
#include <editeng/editengdllapi.h>
25
#include <editeng/macros.hxx>
26
#include <svl/itempool.hxx>
27
#include <svl/languageoptions.hxx>
28
#include <tools/lineend.hxx>
29
#include <tools/mapunit.hxx>
30
31
#include <com/sun/star/text/textfield/Type.hpp>
32
33
#include <vector>
34
#include <memory>
35
36
class SfxItemPool;
37
class SfxItemSet;
38
class SvxFieldItem;
39
class SvxFieldData;
40
enum class OutlinerMode;
41
struct EECharAttrib;
42
typedef struct _xmlTextWriter* xmlTextWriterPtr;
43
class EditTextObjectParagraph;
44
class XParaPortionList;
45
46
namespace editeng {
47
class FieldUpdater;
48
struct Section;
49
}
50
51
namespace svl {
52
class SharedString;
53
class SharedStringPool;
54
}
55
56
enum class TextRotation { NONE, TOPTOBOTTOM, BOTTOMTOTOP };
57
58
/**
59
  This object is used to copy document/text info in and out of EditEngine.
60
  It is not used internally to editeng as storage mechanism, just a means
61
  of extracting and inserting data.
62
*/
63
class EDITENG_DLLPUBLIC EditTextObject final
64
{
65
public:
66
    typedef std::vector<std::unique_ptr<EditTextObjectParagraph> > EditTextObjectParagraphs;
67
68
    EditTextObject(SfxItemPool* pPool, MapUnit eDefaultMetric, bool bVertical,
69
                   TextRotation eRotation, SvtScriptType eScriptType);
70
    EditTextObject( const EditTextObject& r );
71
    EditTextObject( EditTextObject&& r ) noexcept;
72
    ~EditTextObject();
73
74
    EditTextObject& operator=(EditTextObject&&);
75
76
    /**
77
     * Set paragraph strings to the shared string pool.
78
     *
79
     * @param rPool shared string pool.
80
     */
81
    void NormalizeString( svl::SharedStringPool& rPool );
82
83
    std::vector<svl::SharedString> GetSharedStrings() const;
84
85
0
    const SfxItemPool* GetPool() const { return mpPool.get(); }
86
11.1M
    SfxItemPool*       GetPool()       { return mpPool.get(); }
87
88
3.13M
    OutlinerMode GetUserType() const { return meUserType;} // For OutlinerMode, it can however not save in compatible format
89
    void SetUserType( OutlinerMode n );
90
91
    bool IsEffectivelyVertical() const;
92
    bool GetVertical() const;
93
    bool IsTopToBottom() const;
94
    void SetVertical( bool bVertical );
95
    void SetRotation( TextRotation nRotation );
96
    TextRotation    GetRotation() const;
97
98
0
    SvtScriptType GetScriptType() const { return meScriptType;}
99
100
    sal_Int32 GetParagraphCount() const;
101
102
    OUString GetText(sal_Int32 nPara) const;
103
104
    OUString GetText(LineEnd eEnd = LINEEND_LF) const;
105
106
    sal_Int32 GetTextLen(sal_Int32 nPara) const;
107
108
335k
    bool HasText(sal_Int32 nPara) const { return GetTextLen(nPara) > 0; }
109
110
1.08M
    XParaPortionList*       GetPortionInfo() const  { return mpPortionInfo.get(); }
111
    void                    SetPortionInfo( std::unique_ptr<XParaPortionList> pP );
112
    void ClearPortionInfo();
113
114
    sal_Int16 GetNumberingDepth(sal_Int32 nPara) const;
115
    void SetNumberingDepth(sal_Int32 nPara, sal_Int16 nDepth);
116
    sal_Int16 GetNumberingStartValue(sal_Int32 nPara) const;
117
    void SetNumberingStartValue(sal_Int32 nPara, sal_Int16 nStartValue);
118
    bool IsNumberingRestart(sal_Int32 nPara) const;
119
    void SetNumberingRestart(sal_Int32 nPara, bool bRestart);
120
121
    bool HasOnlineSpellErrors() const;
122
123
    void GetCharAttribs( sal_Int32 nPara, std::vector<EECharAttrib>& rLst ) const;
124
125
    bool RemoveCharAttribs( sal_uInt16 nWhich );
126
127
    /**
128
     * Get all text sections in this content.  Sections are non-overlapping
129
     * segments of text split either by paragraph boundaries or format
130
     * boundaries.  Each section object contains all applied formats and/or a
131
     * field item.
132
     */
133
    void GetAllSections( std::vector<editeng::Section>& rAttrs ) const;
134
135
    bool IsFieldObject() const;
136
    const SvxFieldItem* GetField() const;
137
    const SvxFieldData* GetFieldData(sal_Int32 nPara, size_t nPos, sal_Int32 nType) const;
138
    bool HasField( sal_Int32 nType = css::text::textfield::Type::UNSPECIFIED ) const;
139
140
    const SfxItemSet& GetParaAttribs(sal_Int32 nPara) const;
141
142
    void GetStyleSheet(sal_Int32 nPara, OUString& rName, SfxStyleFamily& eFamily) const;
143
    void SetStyleSheet(sal_Int32 nPara, const OUString& rName, const SfxStyleFamily& eFamily);
144
    bool ChangeStyleSheets(
145
        std::u16string_view rOldName, SfxStyleFamily eOldFamily, const OUString& rNewName, SfxStyleFamily eNewFamily);
146
    void ChangeStyleSheetName(SfxStyleFamily eFamily, std::u16string_view rOldName, const OUString& rNewName);
147
148
    editeng::FieldUpdater GetFieldUpdater();
149
150
    bool operator==( const EditTextObject& rCompare ) const;
151
152
    /** Compare, ignoring SfxItemPool pointer.
153
     */
154
    bool Equals( const EditTextObject& rCompare ) const;
155
156
    bool Equals( const EditTextObject& rCompare, bool bComparePool ) const;
157
158
    // #i102062#
159
    bool isWrongListEqual(const EditTextObject& rCompare) const;
160
161
    EditTextObjectParagraph*    CreateAndInsertParagraph();
162
525k
    EditTextObjectParagraphs&       GetParagraphs() { return maParagraphs;}
163
4.06M
    const EditTextObjectParagraphs& GetParagraphs() const { return maParagraphs;}
164
165
1.08M
    bool                    HasMetric() const { return meMetric != MapUnit::LASTENUMDUMMY; }
166
1.08M
    MapUnit                 GetMetric() const { return meMetric; }
167
168
#if DEBUG_EDIT_ENGINE
169
    void Dump() const;
170
#endif
171
    void dumpAsXml(xmlTextWriterPtr pWriter) const;
172
173
private:
174
    bool ImpChangeStyleSheets( std::u16string_view rOldName, SfxStyleFamily eOldFamily,
175
                               const OUString& rNewName, SfxStyleFamily eNewFamily );
176
177
    EditTextObjectParagraphs    maParagraphs;
178
    rtl::Reference<SfxItemPool>       mpPool;
179
    std::unique_ptr<XParaPortionList> mpPortionInfo;
180
    OutlinerMode            meUserType;
181
    SvtScriptType           meScriptType;
182
    TextRotation            meRotation;
183
    MapUnit                 meMetric;
184
    bool                    mbVertical;
185
};
186
187
#endif // INCLUDED_EDITENG_EDITOBJ_HXX
188
189
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */