Line data Source code
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 _EDITOBJ2_HXX
21 : #define _EDITOBJ2_HXX
22 :
23 : #include <editeng/editobj.hxx>
24 : #include <editdoc.hxx>
25 :
26 : #include <unotools/fontcvt.hxx>
27 :
28 : #include <boost/ptr_container/ptr_vector.hpp>
29 :
30 : class XEditAttribute
31 : {
32 : private:
33 : const SfxPoolItem* pItem;
34 : sal_uInt16 nStart;
35 : sal_uInt16 nEnd;
36 :
37 : XEditAttribute();
38 : XEditAttribute( const XEditAttribute& rCopyFrom );
39 :
40 : public:
41 : XEditAttribute( const SfxPoolItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
42 : ~XEditAttribute();
43 :
44 193216 : const SfxPoolItem* GetItem() const { return pItem; }
45 :
46 0 : sal_uInt16& GetStart() { return nStart; }
47 30845 : sal_uInt16& GetEnd() { return nEnd; }
48 :
49 84956 : sal_uInt16 GetStart() const { return nStart; }
50 132754 : sal_uInt16 GetEnd() const { return nEnd; }
51 :
52 33101 : sal_uInt16 GetLen() const { return nEnd-nStart; }
53 :
54 : bool IsFeature() const;
55 : void SetItem(const SfxPoolItem& rNew);
56 :
57 : inline bool operator==( const XEditAttribute& rCompare ) const;
58 :
59 0 : bool operator!= (const XEditAttribute& r) const
60 : {
61 0 : return !operator==(r);
62 : }
63 : };
64 :
65 0 : inline bool XEditAttribute::operator==( const XEditAttribute& rCompare ) const
66 : {
67 : return (nStart == rCompare.nStart) &&
68 : (nEnd == rCompare.nEnd) &&
69 : ( (pItem == rCompare.pItem) ||
70 0 : ( pItem->Which() != rCompare.pItem->Which()) ||
71 0 : (*pItem == *rCompare.pItem));
72 : }
73 :
74 0 : struct XParaPortion
75 : {
76 : long nHeight;
77 : sal_uInt16 nFirstLineOffset;
78 :
79 : EditLineList aLines;
80 : TextPortionList aTextPortions;
81 : };
82 :
83 0 : class XParaPortionList
84 : {
85 : typedef boost::ptr_vector<XParaPortion> ListType;
86 : ListType maList;
87 :
88 : sal_uIntPtr nRefDevPtr;
89 : OutDevType eRefDevType;
90 : MapMode aRefMapMode;
91 : sal_uInt16 nStretchX;
92 : sal_uInt16 nStretchY;
93 : sal_uLong nPaperWidth;
94 :
95 : public:
96 : XParaPortionList(OutputDevice* pRefDev, sal_uLong nPW, sal_uInt16 _nStretchX, sal_uInt16 _nStretchY);
97 :
98 : void push_back(XParaPortion* p);
99 : const XParaPortion& operator[](size_t i) const;
100 :
101 0 : sal_uIntPtr GetRefDevPtr() const { return nRefDevPtr; }
102 0 : sal_uLong GetPaperWidth() const { return nPaperWidth; }
103 0 : OutDevType GetRefDevType() const { return eRefDevType; }
104 0 : const MapMode& GetRefMapMode() const { return aRefMapMode; }
105 0 : sal_uInt16 GetStretchX() const { return nStretchX; }
106 0 : sal_uInt16 GetStretchY() const { return nStretchY; }
107 :
108 : };
109 :
110 : class ContentInfo
111 : {
112 : friend class BinTextObject;
113 : public:
114 : typedef boost::ptr_vector<XEditAttribute> XEditAttributesType;
115 :
116 : private:
117 : String aText;
118 : String aStyle;
119 :
120 : XEditAttributesType aAttribs;
121 : SfxStyleFamily eFamily;
122 : SfxItemSet aParaAttribs;
123 : WrongList* pWrongs;
124 :
125 : ContentInfo( SfxItemPool& rPool );
126 : ContentInfo( const ContentInfo& rCopyFrom, SfxItemPool& rPoolToUse );
127 :
128 : public:
129 : ~ContentInfo();
130 :
131 : const XEditAttributesType& GetAttribs() const { return aAttribs; }
132 94876 : XEditAttributesType& GetAttribs() { return aAttribs; }
133 :
134 19589 : const String& GetText() const { return aText; }
135 15508 : const String& GetStyle() const { return aStyle; }
136 15703 : const SfxItemSet& GetParaAttribs() const { return aParaAttribs; }
137 15508 : SfxStyleFamily GetFamily() const { return eFamily; }
138 :
139 44593 : String& GetText() { return aText; }
140 19092 : String& GetStyle() { return aStyle; }
141 39883 : SfxItemSet& GetParaAttribs() { return aParaAttribs; }
142 10648 : SfxStyleFamily& GetFamily() { return eFamily; }
143 :
144 35453 : WrongList* GetWrongList() const { return pWrongs; }
145 5943 : void SetWrongList( WrongList* p ) { pWrongs = p; }
146 : bool operator==( const ContentInfo& rCompare ) const;
147 : bool operator!=( const ContentInfo& rCompare ) const;
148 :
149 : // #i102062#
150 : bool isWrongListEqual(const ContentInfo& rCompare) const;
151 : };
152 :
153 : class BinTextObject : public EditTextObject, public SfxItemPoolUser
154 : {
155 : using EditTextObject::operator==;
156 : using EditTextObject::isWrongListEqual;
157 :
158 : public:
159 : typedef boost::ptr_vector<ContentInfo> ContentInfosType;
160 :
161 : private:
162 : ContentInfosType aContents;
163 : SfxItemPool* pPool;
164 : XParaPortionList* pPortionInfo;
165 :
166 : sal_uInt32 nObjSettings;
167 : sal_uInt16 nMetric;
168 : sal_uInt16 nVersion;
169 : sal_uInt16 nUserType;
170 : sal_uInt16 nScriptType;
171 :
172 : bool bOwnerOfPool:1;
173 : bool bVertical:1;
174 : bool bStoreUnicodeStrings:1;
175 :
176 : protected:
177 : virtual void StoreData( SvStream& rOStream ) const;
178 : virtual void CreateData( SvStream& rIStream );
179 : sal_Bool ImpChangeStyleSheets( const String& rOldName, SfxStyleFamily eOldFamily,
180 : const String& rNewName, SfxStyleFamily eNewFamily );
181 :
182 : public:
183 : BinTextObject( SfxItemPool* pPool );
184 : BinTextObject( const BinTextObject& );
185 : virtual ~BinTextObject();
186 :
187 : virtual EditTextObject* Clone() const;
188 :
189 : sal_uInt16 GetUserType() const;
190 : void SetUserType( sal_uInt16 n );
191 :
192 : sal_uLong GetObjectSettings() const;
193 : void SetObjectSettings( sal_uLong n );
194 :
195 : bool IsVertical() const;
196 : void SetVertical( bool b );
197 :
198 : sal_uInt16 GetScriptType() const;
199 : void SetScriptType( sal_uInt16 nType );
200 :
201 : sal_uInt16 GetVersion() const; // As long as the outliner does not store any record length
202 :
203 : ContentInfo* CreateAndInsertContent();
204 : XEditAttribute* CreateAttrib( const SfxPoolItem& rItem, sal_uInt16 nStart, sal_uInt16 nEnd );
205 : void DestroyAttrib( XEditAttribute* pAttr );
206 :
207 : ContentInfosType& GetContents();
208 : const ContentInfosType& GetContents() const;
209 6224 : SfxItemPool* GetPool() const { return pPool; }
210 13359 : XParaPortionList* GetPortionInfo() const { return pPortionInfo; }
211 0 : void SetPortionInfo( XParaPortionList* pP )
212 0 : { pPortionInfo = pP; }
213 :
214 : virtual size_t GetParagraphCount() const;
215 : virtual String GetText(size_t nParagraph) const;
216 : virtual void Insert(const EditTextObject& rObj, size_t nPara);
217 : virtual EditTextObject* CreateTextObject(size_t nPara, size_t nParas = 1) const;
218 : virtual void RemoveParagraph(size_t nPara);
219 :
220 : virtual sal_Bool HasPortionInfo() const;
221 : virtual void ClearPortionInfo();
222 :
223 : virtual sal_Bool HasOnlineSpellErrors() const;
224 :
225 : virtual sal_Bool HasCharAttribs( sal_uInt16 nWhich = 0 ) const;
226 : virtual void GetCharAttribs( sal_uInt16 nPara, std::vector<EECharAttrib>& rLst ) const;
227 :
228 : virtual sal_Bool RemoveCharAttribs( sal_uInt16 nWhich = 0 );
229 : virtual sal_Bool RemoveParaAttribs( sal_uInt16 nWhich = 0 );
230 :
231 : virtual void MergeParaAttribs( const SfxItemSet& rAttribs, sal_uInt16 nStart, sal_uInt16 nEnd );
232 :
233 : virtual sal_Bool IsFieldObject() const;
234 : virtual const SvxFieldItem* GetField() const;
235 : virtual sal_Bool HasField( TypeId Type = NULL ) const;
236 :
237 : virtual SfxItemSet GetParaAttribs(size_t nPara) const;
238 : virtual void SetParaAttribs(size_t nPara, const SfxItemSet& rAttribs);
239 :
240 : virtual sal_Bool HasStyleSheet( const XubString& rName, SfxStyleFamily eFamily ) const;
241 : virtual void GetStyleSheet(size_t nPara, String& rName, SfxStyleFamily& eFamily) const;
242 : virtual void SetStyleSheet(size_t nPara, const String& rName, const SfxStyleFamily& eFamily);
243 : virtual sal_Bool ChangeStyleSheets( const XubString& rOldName, SfxStyleFamily eOldFamily,
244 : const String& rNewName, SfxStyleFamily eNewFamily );
245 : virtual void ChangeStyleSheetName( SfxStyleFamily eFamily, const XubString& rOldName, const XubString& rNewName );
246 :
247 : virtual editeng::FieldUpdater GetFieldUpdater();
248 :
249 : void CreateData300( SvStream& rIStream );
250 :
251 13359 : sal_Bool HasMetric() const { return nMetric != 0xFFFF; }
252 13359 : sal_uInt16 GetMetric() const { return nMetric; }
253 11195 : void SetMetric( sal_uInt16 n ) { nMetric = n; }
254 :
255 11195 : bool IsOwnerOfPool() const { return bOwnerOfPool; }
256 0 : void StoreUnicodeStrings( sal_Bool b ) { bStoreUnicodeStrings = b; }
257 :
258 : bool operator==( const BinTextObject& rCompare ) const;
259 :
260 : // #i102062#
261 : bool isWrongListEqual(const BinTextObject& rCompare) const;
262 :
263 : // from SfxItemPoolUser
264 : virtual void ObjectInDestruction(const SfxItemPool& rSfxItemPool);
265 : };
266 :
267 : #endif // _EDITOBJ2_HXX
268 :
269 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|