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