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