1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#pragma once
#include "editattr.hxx"
#include "edtspell.hxx"
#include <editeng/svxfont.hxx>
#include <svl/itemset.hxx>
#include <svl/style.hxx>
#include <svl/itempool.hxx>
#include <svl/languageoptions.hxx>
#include <tools/lineend.hxx>
#include <memory>
#include <string_view>
#include <vector>
class SvxTabStop;
class ContentAttribs
{
private:
SfxStyleSheet* mpStyle = nullptr;
SfxItemSetFixed<EE_PARA_START, EE_CHAR_END> maAttribSet;
public:
ContentAttribs(SfxItemPool& rItemPool);
void dumpAsXml(xmlTextWriterPtr pWriter) const;
SvxTabStop FindTabStop(sal_Int32 nCurPos, sal_uInt16 nDefTab);
SfxItemSet& GetItems() { return maAttribSet; }
const SfxItemSet& GetItems() const { return maAttribSet; }
const SfxStyleSheet* GetStyleSheet() const { return mpStyle; }
SfxStyleSheet* GetStyleSheet() { return mpStyle; }
void SetStyleSheet(SfxStyleSheet* pS);
const SfxPoolItem& GetItem(sal_uInt16 nWhich) const;
template <class T> const T& GetItem(TypedWhichId<T> nWhich) const
{
return static_cast<const T&>(GetItem(sal_uInt16(nWhich)));
}
bool HasItem(sal_uInt16 nWhich) const;
};
class CharAttribList
{
public:
typedef std::vector<std::unique_ptr<EditCharAttrib>> AttribsType;
private:
AttribsType maAttribs;
SvxFont maDefFont; // faster than ever from the pool!
bool mbHasEmptyAttribs = false;
public:
void dumpAsXml(xmlTextWriterPtr pWriter) const;
void DeleteEmptyAttribs();
const EditCharAttrib* FindAttrib(sal_uInt16 nWhich, sal_Int32 nPos) const;
EditCharAttrib* FindAttrib(sal_uInt16 nWhich, sal_Int32 nPos);
EditCharAttrib* FindAttribRightOpen(sal_uInt16 nWhich, sal_Int32 nPos);
const EditCharAttrib* FindNextAttrib(sal_uInt16 nWhich, sal_Int32 nFromPos) const;
EditCharAttrib* FindEmptyAttrib(sal_uInt16 nWhich, sal_Int32 nPos);
const EditCharAttrib* FindFeature(sal_Int32 nPos) const;
void ResortAttribs();
void OptimizeRanges();
sal_Int32 Count() const;
void InsertAttrib(EditCharAttrib* pAttrib);
SvxFont& GetDefFont() { return maDefFont; }
bool HasEmptyAttribs() const { return mbHasEmptyAttribs; }
void SetHasEmptyAttribs(bool b);
bool HasBoundingAttrib(sal_Int32 nBound) const;
bool HasAttrib(sal_Int32 nStartPos, sal_Int32 nEndPos) const;
AttribsType& GetAttribs() { return maAttribs; }
const AttribsType& GetAttribs() const { return maAttribs; }
void Remove(const EditCharAttrib* p);
void Remove(sal_Int32 nPos);
#if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
static void DbgCheckAttribs(CharAttribList const& rAttribs);
#endif
};
class ContentNode
{
private:
OUString maString;
ContentAttribs maContentAttribs;
CharAttribList maCharAttribList;
std::unique_ptr<WrongList> mpWrongList;
void UnExpandPosition(sal_Int32& rStartPos, bool bBiasStart);
public:
ContentNode(SfxItemPool& rItemPool);
ContentNode(const OUString& rStr, const ContentAttribs& rContentAttribs);
ContentNode(const ContentNode&) = delete;
ContentNode& operator=(const ContentNode&) = delete;
void dumpAsXml(xmlTextWriterPtr pWriter) const;
ContentAttribs& GetContentAttribs() { return maContentAttribs; }
const ContentAttribs& GetContentAttribs() const { return maContentAttribs; }
CharAttribList& GetCharAttribs() { return maCharAttribList; }
const CharAttribList& GetCharAttribs() const { return maCharAttribList; }
void ExpandAttribs(sal_Int32 nIndex, sal_Int32 nNewChars);
void CollapseAttribs(sal_Int32 nIndex, sal_Int32 nDelChars);
void AppendAttribs(ContentNode* pNextNode);
void CopyAndCutAttribs(ContentNode* pPrevNode, SfxItemPool& rPool, bool bKeepEndingAttribs);
void SetStyleSheet(SfxStyleSheet* pS, bool bRecalcFont = true);
void SetStyleSheet(SfxStyleSheet* pS, const SvxFont& rFontFromStyle);
SfxStyleSheet* GetStyleSheet() { return maContentAttribs.GetStyleSheet(); }
void CreateDefFont();
void EnsureWrongList();
WrongList* GetWrongList();
const WrongList* GetWrongList() const;
void SetWrongList(WrongList* p);
void CreateWrongList();
void DestroyWrongList();
bool IsFeature(sal_Int32 nPos) const;
sal_Int32 Len() const;
const OUString& GetString() const { return maString; }
/// return length including expanded fields
sal_Int32 GetExpandedLen() const;
/// return content including expanded fields
OUString GetExpandedText(sal_Int32 nStartPos = 0, sal_Int32 nEndPos = -1) const;
/// re-write offsets in the expanded text to string offsets
void UnExpandPositions(sal_Int32& rStartPos, sal_Int32& rEndPos);
void SetChar(sal_Int32 nPos, sal_Unicode c);
void Insert(std::u16string_view rStr, sal_Int32 nPos);
void Append(std::u16string_view rStr);
void Erase(sal_Int32 nPos);
void Erase(sal_Int32 nPos, sal_Int32 nCount);
OUString Copy(sal_Int32 nPos) const;
OUString Copy(sal_Int32 nPos, sal_Int32 nCount) const;
sal_Unicode GetChar(sal_Int32 nPos) const;
void checkAndDeleteEmptyAttribs() const;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|