LibreOffice Module editeng (master) 1
editobj2.hxx
Go to the documentation of this file.
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#pragma once
21
22#include <editeng/editobj.hxx>
24#include <editeng/outliner.hxx>
25#include <editdoc.hxx>
26
27#include <svl/sharedstring.hxx>
29#include <tools/long.hxx>
30#include <tools/mapunit.hxx>
31
32#include <memory>
33#include <vector>
34
35namespace editeng {
36
37struct Section;
38
39}
40
41namespace svl {
42
43class SharedStringPool;
44
45}
46
48{
49private:
51 sal_Int32 nStart;
52 sal_Int32 nEnd;
53
54public:
55 XEditAttribute( const SfxPoolItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd );
56
57 const SfxPoolItem* GetItem() const { return pItem; }
58
59 sal_Int32& GetStart() { return nStart; }
60 sal_Int32& GetEnd() { return nEnd; }
61
62 sal_Int32 GetStart() const { return nStart; }
63 sal_Int32 GetEnd() const { return nEnd; }
64
65 sal_Int32 GetLen() const { return nEnd-nStart; }
66
67 bool IsFeature() const;
68 void SetItem(const SfxPoolItem& rNew);
69
70 inline bool operator==( const XEditAttribute& rCompare ) const;
71};
72
73inline bool XEditAttribute::operator==( const XEditAttribute& rCompare ) const
74{
75 return (nStart == rCompare.nStart) &&
76 (nEnd == rCompare.nEnd) &&
77 ((pItem == rCompare.pItem) ||
78 ((pItem->Which() == rCompare.pItem->Which()) &&
79 (*pItem == *rCompare.pItem)));
80}
81
83{
85 sal_uInt16 nFirstLineOffset;
86
89};
90
92{
93 typedef std::vector<std::unique_ptr<XParaPortion> > ListType;
95
101 sal_uInt32 nPaperWidth;
102
103public:
104 XParaPortionList(OutputDevice* pRefDev, sal_uInt32 nPW, double fFontScaleX, double fFontScaleY, double fSpacingScaleX, double fSpacingScaleY);
105
106 void push_back(XParaPortion* p);
107 const XParaPortion& operator[](size_t i) const;
108
110 sal_uInt32 GetPaperWidth() const { return nPaperWidth; }
111 bool RefDevIsVirtual() const {return pRefDevPtr->IsVirtual();}
112 const MapMode& GetRefMapMode() const { return pRefDevPtr->GetMapMode(); }
113 double getFontScaleX() const { return mfFontScaleX; }
114 double getFontScaleY() const { return mfFontScaleY; }
115 double getSpacingScaleX() const { return mfSpacingScaleX; }
116 double getSpacingScaleY() const { return mfSpacingScaleY; }
117};
118
120{
121 friend class EditTextObjectImpl;
122
123private:
125 OUString aStyle;
126
127 std::vector<XEditAttribute> maCharAttribs;
130 std::unique_ptr<WrongList>
132
133 ContentInfo( SfxItemPool& rPool );
134 ContentInfo( const ContentInfo& rCopyFrom, SfxItemPool& rPoolToUse );
135
136public:
137 ~ContentInfo();
138 ContentInfo(const ContentInfo&) = delete;
140
142 const svl::SharedString& GetSharedString() const { return maText;}
143 OUString GetText() const;
144 void SetText( const OUString& rStr );
145
146 void dumpAsXml(xmlTextWriterPtr pWriter) const;
147
148 const std::vector<XEditAttribute>& GetCharAttribs() const { return maCharAttribs; }
149 std::vector<XEditAttribute>& GetCharAttribs() { return maCharAttribs; }
150
151 const OUString& GetStyle() const { return aStyle; }
152 SfxStyleFamily GetFamily() const { return eFamily; }
153
154 void SetStyle(const OUString& rStyle) { aStyle = rStyle; }
155 void SetFamily(const SfxStyleFamily& rFamily) { eFamily = rFamily; }
156
157 const SfxItemSet& GetParaAttribs() const { return aParaAttribs; }
159
160 const WrongList* GetWrongList() const;
161 void SetWrongList( WrongList* p );
162 bool Equals( const ContentInfo& rCompare, bool bComparePool ) const;
163
164 // #i102062#
165 bool isWrongListEqual(const ContentInfo& rCompare) const;
166
167#if DEBUG_EDIT_ENGINE
168 void Dump() const;
169#endif
170};
171
173{
174public:
175 typedef std::vector<std::unique_ptr<ContentInfo> > ContentInfosType;
176
177private:
180 std::unique_ptr<XParaPortionList> mpPortionInfo;
181
186
188
189 bool ImpChangeStyleSheets( std::u16string_view rOldName, SfxStyleFamily eOldFamily,
190 const OUString& rNewName, SfxStyleFamily eNewFamily );
191
192public:
193 EditTextObjectImpl(SfxItemPool* pPool, MapUnit eDefaultMetric, bool bVertical,
194 TextRotation eRotation, SvtScriptType eScriptType);
196 virtual ~EditTextObjectImpl() override;
197
199
200 virtual OutlinerMode GetUserType() const override { return meUserType;}
201 virtual void SetUserType( OutlinerMode n ) override;
202
203 virtual void NormalizeString( svl::SharedStringPool& rPool ) override;
204 virtual std::vector<svl::SharedString> GetSharedStrings() const override;
205
206 virtual bool IsEffectivelyVertical() const override;
207 virtual bool GetVertical() const override;
208 virtual bool IsTopToBottom() const override;
209 virtual void SetVertical( bool bVert) override;
210 virtual void SetRotation(TextRotation nRotation) override;
211 virtual TextRotation GetRotation() const override;
212
213 virtual SvtScriptType GetScriptType() const override { return meScriptType;}
214
215 virtual std::unique_ptr<EditTextObject> Clone() const override;
216
218 XEditAttribute CreateAttrib( const SfxPoolItem& rItem, sal_Int32 nStart, sal_Int32 nEnd );
219 void DestroyAttrib( const XEditAttribute& rAttr );
220
222 const ContentInfosType& GetContents() const { return maContents;}
223 SfxItemPool* GetPool() { return mpPool.get(); }
224 virtual const SfxItemPool* GetPool() const override { return mpPool.get(); }
226 void SetPortionInfo( std::unique_ptr<XParaPortionList> pP )
227 { mpPortionInfo = std::move(pP); }
228
229 virtual sal_Int32 GetParagraphCount() const override;
230 virtual OUString GetText(sal_Int32 nParagraph) const override;
231
232 virtual void ClearPortionInfo() override;
233
234 virtual bool HasOnlineSpellErrors() const override;
235
236 virtual void GetCharAttribs( sal_Int32 nPara, std::vector<EECharAttrib>& rLst ) const override;
237
238 virtual bool RemoveCharAttribs( sal_uInt16 nWhich ) override;
239
240 virtual void GetAllSections( std::vector<editeng::Section>& rAttrs ) const override;
241
242 virtual bool IsFieldObject() const override;
243 virtual const SvxFieldItem* GetField() const override;
244 virtual const SvxFieldData* GetFieldData(sal_Int32 nPara, size_t nPos, sal_Int32 nType) const override;
245
246 virtual bool HasField( sal_Int32 nType = css::text::textfield::Type::UNSPECIFIED ) const override;
247
248 virtual const SfxItemSet& GetParaAttribs(sal_Int32 nPara) const override;
249
250 virtual void GetStyleSheet(sal_Int32 nPara, OUString& rName, SfxStyleFamily& eFamily) const override;
251 virtual void SetStyleSheet(sal_Int32 nPara, const OUString& rName, const SfxStyleFamily& eFamily) override;
252 virtual bool ChangeStyleSheets(
253 std::u16string_view rOldName, SfxStyleFamily eOldFamily, const OUString& rNewName, SfxStyleFamily eNewFamily) override;
254 virtual void ChangeStyleSheetName(SfxStyleFamily eFamily, std::u16string_view rOldName, const OUString& rNewName) override;
255
256 virtual editeng::FieldUpdater GetFieldUpdater() override { return editeng::FieldUpdater(*this); }
257
258 bool HasMetric() const { return meMetric != MapUnit::LASTENUMDUMMY; }
259 MapUnit GetMetric() const { return meMetric; }
260
261 virtual bool operator==( const EditTextObject& rCompare ) const override;
262 bool Equals( const EditTextObjectImpl& rCompare, bool bComparePool ) const;
263
264 // #i102062#
265 virtual bool isWrongListEqual(const EditTextObject& rCompare) const override;
266
267#if DEBUG_EDIT_ENGINE
268 virtual void Dump() const override;
269#endif
270 virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override;
271};
272
274{
275 assert(dynamic_cast<EditTextObjectImpl*>(&rObj));
276 return static_cast<EditTextObjectImpl&>(rObj);
277}
278
279inline const EditTextObjectImpl& toImpl(const EditTextObject& rObj)
280{
281 assert(dynamic_cast<const EditTextObjectImpl*>(&rObj));
282 return static_cast<const EditTextObjectImpl&>(rObj);
283}
284
285/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString GetText() const
Definition: editobj.cxx:135
ContentInfo(SfxItemPool &rPool)
Definition: editobj.cxx:95
void NormalizeString(svl::SharedStringPool &rPool)
Definition: editobj.cxx:129
OUString aStyle
Definition: editobj2.hxx:125
svl::SharedString maText
Definition: editobj2.hxx:124
SfxItemSet & GetParaAttribs()
Definition: editobj2.hxx:158
bool Equals(const ContentInfo &rCompare, bool bComparePool) const
Definition: editobj.cxx:205
ContentInfo & operator=(const ContentInfo &)=delete
const svl::SharedString & GetSharedString() const
Definition: editobj2.hxx:142
SfxStyleFamily GetFamily() const
Definition: editobj2.hxx:152
const SfxItemSet & GetParaAttribs() const
Definition: editobj2.hxx:157
SfxItemSetFixed< EE_PARA_START, EE_CHAR_END > aParaAttribs
Definition: editobj2.hxx:129
std::unique_ptr< WrongList > mpWrongs
Definition: editobj2.hxx:131
std::vector< XEditAttribute > & GetCharAttribs()
Definition: editobj2.hxx:149
void SetStyle(const OUString &rStyle)
Definition: editobj2.hxx:154
const WrongList * GetWrongList() const
Definition: editobj.cxx:167
const std::vector< XEditAttribute > & GetCharAttribs() const
Definition: editobj2.hxx:148
ContentInfo(const ContentInfo &)=delete
void SetFamily(const SfxStyleFamily &rFamily)
Definition: editobj2.hxx:155
std::vector< XEditAttribute > maCharAttribs
Definition: editobj2.hxx:127
void SetText(const OUString &rStr)
Definition: editobj.cxx:141
void SetWrongList(WrongList *p)
Definition: editobj.cxx:172
SfxStyleFamily eFamily
Definition: editobj2.hxx:128
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: editobj.cxx:146
const OUString & GetStyle() const
Definition: editobj2.hxx:151
bool isWrongListEqual(const ContentInfo &rCompare) const
Definition: editobj.cxx:178
bool ImpChangeStyleSheets(std::u16string_view rOldName, SfxStyleFamily eOldFamily, const OUString &rNewName, SfxStyleFamily eNewFamily)
Definition: editobj.cxx:706
virtual bool isWrongListEqual(const EditTextObject &rCompare) const override
Definition: editobj.cxx:770
void SetPortionInfo(std::unique_ptr< XParaPortionList > pP)
Definition: editobj2.hxx:226
virtual bool IsTopToBottom() const override
Definition: editobj.cxx:343
virtual bool RemoveCharAttribs(sal_uInt16 nWhich) override
Definition: editobj.cxx:530
std::unique_ptr< XParaPortionList > mpPortionInfo
Definition: editobj2.hxx:180
EditTextObjectImpl & operator=(const EditTextObjectImpl &)=delete
virtual OUString GetText(sal_Int32 nParagraph) const override
Definition: editobj.cxx:405
virtual void ChangeStyleSheetName(SfxStyleFamily eFamily, std::u16string_view rOldName, const OUString &rNewName) override
Definition: editobj.cxx:740
virtual ~EditTextObjectImpl() override
Definition: editobj.cxx:301
virtual void NormalizeString(svl::SharedStringPool &rPool) override
Set paragraph strings to the shared string pool.
Definition: editobj.cxx:316
MapUnit GetMetric() const
Definition: editobj2.hxx:259
virtual const SvxFieldItem * GetField() const override
Definition: editobj.cxx:447
virtual bool GetVertical() const override
Definition: editobj.cxx:358
virtual TextRotation GetRotation() const override
Definition: editobj.cxx:372
virtual std::vector< svl::SharedString > GetSharedStrings() const override
Definition: editobj.cxx:325
std::vector< std::unique_ptr< ContentInfo > > ContentInfosType
Definition: editobj2.hxx:175
SvtScriptType meScriptType
Definition: editobj2.hxx:183
virtual void GetStyleSheet(sal_Int32 nPara, OUString &rName, SfxStyleFamily &eFamily) const override
Definition: editobj.cxx:686
virtual const SfxItemPool * GetPool() const override
Definition: editobj2.hxx:224
virtual bool IsEffectivelyVertical() const override
Definition: editobj.cxx:337
EditTextObjectImpl(SfxItemPool *pPool, MapUnit eDefaultMetric, bool bVertical, TextRotation eRotation, SvtScriptType eScriptType)
Definition: editobj.cxx:275
virtual const SvxFieldData * GetFieldData(sal_Int32 nPara, size_t nPos, sal_Int32 nType) const override
Definition: editobj.cxx:466
virtual bool operator==(const EditTextObject &rCompare) const override
Definition: editobj.cxx:746
ContentInfosType maContents
Definition: editobj2.hxx:178
TextRotation meRotation
Definition: editobj2.hxx:184
virtual sal_Int32 GetParagraphCount() const override
Definition: editobj.cxx:394
virtual void ClearPortionInfo() override
Definition: editobj.cxx:413
ContentInfo * CreateAndInsertContent()
Definition: editobj.cxx:388
virtual std::unique_ptr< EditTextObject > Clone() const override
Definition: editobj.cxx:214
bool HasMetric() const
Definition: editobj2.hxx:258
virtual bool HasField(sal_Int32 nType=css::text::textfield::Type::UNSPECIFIED) const override
Definition: editobj.cxx:499
SfxItemPool * GetPool()
Definition: editobj2.hxx:223
virtual void SetVertical(bool bVert) override
Definition: editobj.cxx:349
OutlinerMode meUserType
Definition: editobj2.hxx:182
rtl::Reference< SfxItemPool > mpPool
Definition: editobj2.hxx:179
virtual void GetAllSections(std::vector< editeng::Section > &rAttrs) const override
Get all text sections in this content.
Definition: editobj.cxx:583
void DestroyAttrib(const XEditAttribute &rAttr)
Definition: editobj.cxx:382
virtual bool ChangeStyleSheets(std::u16string_view rOldName, SfxStyleFamily eOldFamily, const OUString &rNewName, SfxStyleFamily eNewFamily) override
Definition: editobj.cxx:729
virtual void SetStyleSheet(sal_Int32 nPara, const OUString &rName, const SfxStyleFamily &eFamily) override
Definition: editobj.cxx:696
virtual const SfxItemSet & GetParaAttribs(sal_Int32 nPara) const override
Definition: editobj.cxx:524
virtual void SetUserType(OutlinerMode n) override
Definition: editobj.cxx:311
const ContentInfosType & GetContents() const
Definition: editobj2.hxx:222
virtual SvtScriptType GetScriptType() const override
Definition: editobj2.hxx:213
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override
Definition: editobj.cxx:224
XEditAttribute CreateAttrib(const SfxPoolItem &rItem, sal_Int32 nStart, sal_Int32 nEnd)
Definition: editobj.cxx:377
virtual bool IsFieldObject() const override
Definition: editobj.cxx:442
bool Equals(const EditTextObjectImpl &rCompare, bool bComparePool) const
Definition: editobj.cxx:751
virtual void SetRotation(TextRotation nRotation) override
Definition: editobj.cxx:363
virtual void GetCharAttribs(sal_Int32 nPara, std::vector< EECharAttrib > &rLst) const override
Definition: editobj.cxx:428
virtual bool HasOnlineSpellErrors() const override
Definition: editobj.cxx:418
virtual OutlinerMode GetUserType() const override
Definition: editobj2.hxx:200
ContentInfosType & GetContents()
Definition: editobj2.hxx:221
XParaPortionList * GetPortionInfo() const
Definition: editobj2.hxx:225
virtual editeng::FieldUpdater GetFieldUpdater() override
Definition: editobj2.hxx:256
sal_uInt16 Which() const
This item stores a field (SvxFieldData).
Definition: flditem.hxx:70
Keeps track of misspelled ranges in paragraph.
Definition: edtspell.hxx:55
const SfxPoolItem * pItem
Definition: editobj2.hxx:50
const SfxPoolItem * GetItem() const
Definition: editobj2.hxx:57
sal_Int32 nStart
Definition: editobj2.hxx:51
XEditAttribute(const SfxPoolItem &rAttr, sal_Int32 nStart, sal_Int32 nEnd)
Definition: editobj.cxx:55
sal_Int32 GetStart() const
Definition: editobj2.hxx:62
sal_Int32 GetEnd() const
Definition: editobj2.hxx:63
sal_Int32 & GetEnd()
Definition: editobj2.hxx:60
sal_Int32 GetLen() const
Definition: editobj2.hxx:65
bool IsFeature() const
Definition: editobj.cxx:62
void SetItem(const SfxPoolItem &rNew)
Definition: editobj.cxx:68
sal_Int32 & GetStart()
Definition: editobj2.hxx:59
sal_Int32 nEnd
Definition: editobj2.hxx:52
bool operator==(const XEditAttribute &rCompare) const
Definition: editobj2.hxx:73
double mfSpacingScaleY
Definition: editobj2.hxx:100
VclPtr< OutputDevice > pRefDevPtr
Definition: editobj2.hxx:96
double getSpacingScaleY() const
Definition: editobj2.hxx:116
double getFontScaleY() const
Definition: editobj2.hxx:114
double mfSpacingScaleX
Definition: editobj2.hxx:99
sal_uInt32 GetPaperWidth() const
Definition: editobj2.hxx:110
double mfFontScaleY
Definition: editobj2.hxx:98
double mfFontScaleX
Definition: editobj2.hxx:97
bool RefDevIsVirtual() const
Definition: editobj2.hxx:111
ListType maList
Definition: editobj2.hxx:94
void push_back(XParaPortion *p)
Definition: editobj.cxx:85
XParaPortionList(OutputDevice *pRefDev, sal_uInt32 nPW, double fFontScaleX, double fFontScaleY, double fSpacingScaleX, double fSpacingScaleY)
Definition: editobj.cxx:73
OutputDevice * GetRefDevPtr() const
Definition: editobj2.hxx:109
const MapMode & GetRefMapMode() const
Definition: editobj2.hxx:112
const XParaPortion & operator[](size_t i) const
Definition: editobj.cxx:90
sal_uInt32 nPaperWidth
Definition: editobj2.hxx:101
double getSpacingScaleX() const
Definition: editobj2.hxx:115
double getFontScaleX() const
Definition: editobj2.hxx:113
std::vector< std::unique_ptr< XParaPortion > > ListType
Definition: editobj2.hxx:93
Wrapper for EditTextObject to handle updating of fields without exposing the internals of EditTextObj...
EditTextObjectImpl & toImpl(EditTextObject &rObj)
Definition: editobj2.hxx:273
TextRotation
Definition: editobj.hxx:55
struct _xmlTextWriter * xmlTextWriterPtr
SvtScriptType
MapUnit
long Long
OutlinerMode
Definition: outliner.hxx:563
EditLineList aLines
Definition: editobj2.hxx:87
TextPortionList aTextPortions
Definition: editobj2.hxx:88
tools::Long nHeight
Definition: editobj2.hxx:84
sal_uInt16 nFirstLineOffset
Definition: editobj2.hxx:85
SfxStyleFamily