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 : #include <boost/noncopyable.hpp>
30 :
31 : class XEditAttribute
32 : {
33 : private:
34 : const SfxPoolItem* pItem;
35 : sal_uInt16 nStart;
36 : sal_uInt16 nEnd;
37 :
38 : XEditAttribute();
39 : XEditAttribute( const XEditAttribute& rCopyFrom );
40 :
41 : public:
42 : XEditAttribute( const SfxPoolItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
43 : ~XEditAttribute();
44 :
45 1441846 : const SfxPoolItem* GetItem() const { return pItem; }
46 :
47 0 : sal_uInt16& GetStart() { return nStart; }
48 49494 : sal_uInt16& GetEnd() { return nEnd; }
49 :
50 1139114 : sal_uInt16 GetStart() const { return nStart; }
51 2200189 : sal_uInt16 GetEnd() const { return nEnd; }
52 :
53 65096 : sal_uInt16 GetLen() const { return nEnd-nStart; }
54 :
55 : bool IsFeature() const;
56 : void SetItem(const SfxPoolItem& rNew);
57 :
58 : inline bool operator==( const XEditAttribute& rCompare ) const;
59 :
60 13255 : bool operator!= (const XEditAttribute& r) const
61 : {
62 13255 : return !operator==(r);
63 : }
64 : };
65 :
66 13255 : inline bool XEditAttribute::operator==( const XEditAttribute& rCompare ) const
67 : {
68 26510 : return (nStart == rCompare.nStart) &&
69 39709 : (nEnd == rCompare.nEnd) &&
70 24407 : ( (pItem == rCompare.pItem) ||
71 11208 : ( pItem->Which() != rCompare.pItem->Which()) ||
72 13311 : (*pItem == *rCompare.pItem));
73 : }
74 :
75 0 : struct XParaPortion
76 : {
77 : long nHeight;
78 : sal_uInt16 nFirstLineOffset;
79 :
80 : EditLineList aLines;
81 : TextPortionList aTextPortions;
82 : };
83 :
84 0 : class XParaPortionList
85 : {
86 : typedef boost::ptr_vector<XParaPortion> ListType;
87 : ListType maList;
88 :
89 : sal_uIntPtr nRefDevPtr;
90 : OutDevType eRefDevType;
91 : MapMode aRefMapMode;
92 : sal_uInt16 nStretchX;
93 : sal_uInt16 nStretchY;
94 : sal_uLong nPaperWidth;
95 :
96 : public:
97 : XParaPortionList(OutputDevice* pRefDev, sal_uLong nPW, sal_uInt16 _nStretchX, sal_uInt16 _nStretchY);
98 :
99 : void push_back(XParaPortion* p);
100 : const XParaPortion& operator[](size_t i) const;
101 :
102 0 : sal_uIntPtr GetRefDevPtr() const { return nRefDevPtr; }
103 0 : sal_uLong GetPaperWidth() const { return nPaperWidth; }
104 0 : OutDevType GetRefDevType() const { return eRefDevType; }
105 0 : const MapMode& GetRefMapMode() const { return aRefMapMode; }
106 0 : sal_uInt16 GetStretchX() const { return nStretchX; }
107 0 : sal_uInt16 GetStretchY() const { return nStretchY; }
108 :
109 : };
110 :
111 : class ContentInfo
112 : {
113 : friend class EditTextObjectImpl;
114 : public:
115 : typedef boost::ptr_vector<XEditAttribute> XEditAttributesType;
116 :
117 : private:
118 : String aText;
119 : String aStyle;
120 :
121 : XEditAttributesType aAttribs;
122 : SfxStyleFamily eFamily;
123 : SfxItemSet aParaAttribs;
124 : WrongList* pWrongs;
125 :
126 : ContentInfo( SfxItemPool& rPool );
127 : ContentInfo( const ContentInfo& rCopyFrom, SfxItemPool& rPoolToUse );
128 :
129 : public:
130 : ~ContentInfo();
131 :
132 1277202 : const XEditAttributesType& GetAttribs() const { return aAttribs; }
133 65096 : XEditAttributesType& GetAttribs() { return aAttribs; }
134 :
135 595271 : const String& GetText() const { return aText; }
136 307431 : const String& GetStyle() const { return aStyle; }
137 491783 : const SfxItemSet& GetParaAttribs() const { return aParaAttribs; }
138 158667 : SfxStyleFamily GetFamily() const { return eFamily; }
139 :
140 46248 : String& GetText() { return aText; }
141 8345 : String& GetStyle() { return aStyle; }
142 46248 : SfxItemSet& GetParaAttribs() { return aParaAttribs; }
143 8793 : SfxStyleFamily& GetFamily() { return eFamily; }
144 :
145 315262 : WrongList* GetWrongList() const { return pWrongs; }
146 8072 : void SetWrongList( WrongList* p ) { pWrongs = p; }
147 : bool operator==( const ContentInfo& rCompare ) const;
148 : bool operator!=( const ContentInfo& rCompare ) const;
149 :
150 : // #i102062#
151 : bool isWrongListEqual(const ContentInfo& rCompare) const;
152 :
153 : #if DEBUG_EDIT_ENGINE
154 : void Dump() const;
155 : #endif
156 : };
157 :
158 : class EditTextObjectImpl : boost::noncopyable
159 : {
160 : public:
161 : typedef boost::ptr_vector<ContentInfo> ContentInfosType;
162 :
163 : private:
164 : EditTextObject* mpFront;
165 :
166 : ContentInfosType aContents;
167 : SfxItemPool* pPool;
168 : XParaPortionList* pPortionInfo;
169 :
170 : sal_uInt32 nObjSettings;
171 : sal_uInt16 nMetric;
172 : sal_uInt16 nVersion;
173 : sal_uInt16 nUserType;
174 : sal_uInt16 nScriptType;
175 :
176 : bool bOwnerOfPool:1;
177 : bool bVertical:1;
178 : bool bStoreUnicodeStrings:1;
179 :
180 : bool ImpChangeStyleSheets( const String& rOldName, SfxStyleFamily eOldFamily,
181 : const String& rNewName, SfxStyleFamily eNewFamily );
182 :
183 : public:
184 : void StoreData( SvStream& rOStream ) const;
185 : void CreateData( SvStream& rIStream );
186 :
187 : EditTextObjectImpl( EditTextObject* pFront, SfxItemPool* pPool );
188 : EditTextObjectImpl( EditTextObject* pFront, const EditTextObjectImpl& r );
189 : ~EditTextObjectImpl();
190 :
191 : sal_uInt16 GetUserType() const;
192 : void SetUserType( sal_uInt16 n );
193 :
194 : bool IsVertical() const;
195 : void SetVertical( bool b );
196 :
197 : sal_uInt16 GetScriptType() const;
198 : void SetScriptType( sal_uInt16 nType );
199 :
200 : ContentInfo* CreateAndInsertContent();
201 : XEditAttribute* CreateAttrib( const SfxPoolItem& rItem, sal_uInt16 nStart, sal_uInt16 nEnd );
202 : void DestroyAttrib( XEditAttribute* pAttr );
203 :
204 : ContentInfosType& GetContents();
205 : const ContentInfosType& GetContents() const;
206 14595 : SfxItemPool* GetPool() const { return pPool; }
207 211356 : XParaPortionList* GetPortionInfo() const { return pPortionInfo; }
208 0 : void SetPortionInfo( XParaPortionList* pP )
209 0 : { pPortionInfo = pP; }
210 :
211 : sal_Int32 GetParagraphCount() const;
212 : String GetText(sal_Int32 nParagraph) const;
213 :
214 : void ClearPortionInfo();
215 :
216 : bool HasOnlineSpellErrors() const;
217 :
218 : void GetCharAttribs( sal_Int32 nPara, std::vector<EECharAttrib>& rLst ) const;
219 :
220 : bool RemoveCharAttribs( sal_uInt16 nWhich = 0 );
221 :
222 : bool IsFieldObject() const;
223 : const SvxFieldItem* GetField() const;
224 : const SvxFieldData* GetFieldData(sal_Int32 nPara, size_t nPos, sal_Int32 nType) const;
225 :
226 : bool HasField( sal_Int32 nType = com::sun::star::text::textfield::Type::UNSPECIFIED ) const;
227 :
228 : const SfxItemSet& GetParaAttribs(sal_Int32 nPara) const;
229 : void SetParaAttribs(sal_Int32 nPara, const SfxItemSet& rAttribs);
230 :
231 : void GetStyleSheet(sal_Int32 nPara, String& rName, SfxStyleFamily& eFamily) const;
232 : void SetStyleSheet(sal_Int32 nPara, const String& rName, const SfxStyleFamily& eFamily);
233 : bool ChangeStyleSheets(
234 : const XubString& rOldName, SfxStyleFamily eOldFamily, const String& rNewName, SfxStyleFamily eNewFamily );
235 : void ChangeStyleSheetName( SfxStyleFamily eFamily, const XubString& rOldName, const XubString& rNewName );
236 :
237 : editeng::FieldUpdater GetFieldUpdater();
238 :
239 211356 : bool HasMetric() const { return nMetric != 0xFFFF; }
240 211356 : sal_uInt16 GetMetric() const { return nMetric; }
241 42369 : void SetMetric( sal_uInt16 n ) { nMetric = n; }
242 :
243 42369 : bool IsOwnerOfPool() const { return bOwnerOfPool; }
244 0 : void StoreUnicodeStrings( bool b ) { bStoreUnicodeStrings = b; }
245 :
246 : bool operator==( const EditTextObjectImpl& rCompare ) const;
247 :
248 : // #i102062#
249 : bool isWrongListEqual(const EditTextObjectImpl& rCompare) const;
250 :
251 : // from SfxItemPoolUser
252 : void ObjectInDestruction(const SfxItemPool& rSfxItemPool);
253 :
254 : #if DEBUG_EDIT_ENGINE
255 : void Dump() const;
256 : #endif
257 : };
258 :
259 : #endif // _EDITOBJ2_HXX
260 :
261 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|