xref: /trunk/main/editeng/source/editeng/editobj2.hxx (revision fffd1d5d)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _EDITOBJ2_HXX
25 #define _EDITOBJ2_HXX
26 
27 #include <baselist.hxx>
28 #include <editeng/editobj.hxx>
29 #include <editdoc.hxx>
30 
31 #include <unotools/fontcvt.hxx>
32 
33 
34 class SfxStyleSheetPool;
35 
36 class XEditAttribute
37 {
38 	friend class ContentInfo;	// fuer DTOR
39 	friend class BinTextObject;	// fuer DTOR
40 
41 private:
42 	const SfxPoolItem*	pItem;
43 	sal_uInt16 				nStart;
44 	sal_uInt16 				nEnd;
45 
46 						XEditAttribute();
47 						XEditAttribute( const XEditAttribute& rCopyFrom );
48 
49 						~XEditAttribute();
50 
51 public:
52 						XEditAttribute( const SfxPoolItem& rAttr );
53 						XEditAttribute( const SfxPoolItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
54 
GetItem() const55 	const SfxPoolItem*	GetItem() const				{ return pItem; }
56 
GetStart()57 	sal_uInt16&				GetStart()					{ return nStart; }
GetEnd()58 	sal_uInt16&				GetEnd()					{ return nEnd; }
59 
GetStart() const60 	sal_uInt16				GetStart() const			{ return nStart; }
GetEnd() const61 	sal_uInt16				GetEnd() const				{ return nEnd; }
62 
GetLen() const63 	sal_uInt16				GetLen() const				{ return nEnd-nStart; }
64 
65 	inline sal_Bool			IsFeature();
66 
67 	inline bool			operator==( const XEditAttribute& rCompare );
68 };
69 
operator ==(const XEditAttribute & rCompare)70 inline bool XEditAttribute::operator==( const XEditAttribute& rCompare )
71 {
72 	return	(nStart == rCompare.nStart) &&
73 			(nEnd == rCompare.nEnd) &&
74 			( (pItem == rCompare.pItem) ||
75 			( pItem->Which() != rCompare.pItem->Which()) ||
76 			(*pItem == *rCompare.pItem));
77 }
78 
IsFeature()79 inline sal_Bool XEditAttribute::IsFeature()
80 {
81 	sal_uInt16 nWhich = pItem->Which();
82 	return 	( ( nWhich >= EE_FEATURE_START ) &&
83 			  ( nWhich <=  EE_FEATURE_END ) );
84 }
85 
86 typedef XEditAttribute* XEditAttributePtr;
87 SV_DECL_PTRARR( XEditAttributeListImpl, XEditAttributePtr, 0, 4 )
88 
89 class XEditAttributeList : public XEditAttributeListImpl
90 {
91 public:
92     XEditAttribute* FindAttrib( sal_uInt16 nWhich, sal_uInt16 nChar ) const;
93 };
94 
95 struct XParaPortion
96 {
97 	long				nHeight;
98 	sal_uInt16				nFirstLineOffset;
99 
100 	EditLineList		aLines;
101 	TextPortionList		aTextPortions;
102 };
103 
104 typedef XParaPortion* XParaPortionPtr;
105 SV_DECL_PTRARR( XBaseParaPortionList, XParaPortionPtr, 0, 4 )
106 
107 class XParaPortionList : public  XBaseParaPortionList
108 {
109 	sal_uIntPtr 		nRefDevPtr;
110 	OutDevType	eRefDevType;
111 	MapMode		aRefMapMode;
112 	sal_uLong		nPaperWidth;
113 
114 
115 public:
XParaPortionList(OutputDevice * pRefDev,sal_uLong nPW)116 			XParaPortionList( OutputDevice* pRefDev, sal_uLong nPW ) :
117 				aRefMapMode( pRefDev->GetMapMode() )
118 				{
119 					nRefDevPtr = (sal_uIntPtr)pRefDev; nPaperWidth = nPW;
120 					eRefDevType = pRefDev->GetOutDevType();
121 				}
122 
GetRefDevPtr() const123 	sal_uIntPtr			GetRefDevPtr() const 		{ return nRefDevPtr; }
GetPaperWidth() const124 	sal_uLong			GetPaperWidth() const 		{ return nPaperWidth; }
GetRefDevType() const125 	OutDevType		GetRefDevType() const 		{ return eRefDevType; }
GetRefMapMode() const126 	const MapMode&	GetRefMapMode() const		{ return aRefMapMode; }
127 };
128 
129 /* cl removed because not needed anymore since binfilter
130 struct LoadStoreTempInfos
131 {
132     ByteString              aOrgString_Load;
133 
134     FontToSubsFontConverter hOldSymbolConv_Store;
135     sal_Bool                    bSymbolParagraph_Store;
136 
137 
138     LoadStoreTempInfos() { bSymbolParagraph_Store = sal_False; hOldSymbolConv_Store = NULL; }
139 };
140 */
141 
142 class ContentInfo
143 {
144 	friend class BinTextObject;
145 
146 private:
147 	String				aText;
148 	String				aStyle;
149 	XEditAttributeList	aAttribs;
150 	SfxStyleFamily		eFamily;
151 	SfxItemSet			aParaAttribs;
152 	WrongList*			pWrongs;
153 
154 /* cl removed because not needed anymore since binfilter
155 	LoadStoreTempInfos* pTempLoadStoreInfos;
156 */
157 
158 						ContentInfo( SfxItemPool& rPool );
159 						ContentInfo( const ContentInfo& rCopyFrom, SfxItemPool& rPoolToUse  );
160 
161 public:
162 						~ContentInfo();
163 
GetText() const164 	const String&		GetText()			const	{ return aText; }
GetStyle() const165 	const String&		GetStyle()			const	{ return aStyle; }
GetAttribs() const166 	const XEditAttributeList& GetAttribs()	const	{ return aAttribs; }
GetParaAttribs() const167 	const SfxItemSet&	GetParaAttribs()	const	{ return aParaAttribs; }
GetFamily() const168 	SfxStyleFamily		GetFamily()			const	{ return eFamily; }
169 
GetText()170 	String&				GetText()			{ return aText; }
GetStyle()171 	String&				GetStyle()			{ return aStyle; }
GetAttribs()172 	XEditAttributeList&	GetAttribs()		{ return aAttribs; }
GetParaAttribs()173 	SfxItemSet&			GetParaAttribs()	{ return aParaAttribs; }
GetFamily()174 	SfxStyleFamily&		GetFamily()			{ return eFamily; }
175 
GetWrongList() const176 	WrongList*			GetWrongList() const			{ return pWrongs; }
SetWrongList(WrongList * p)177 	void				SetWrongList( WrongList* p )	{ pWrongs = p; }
178 	bool				operator==( const ContentInfo& rCompare ) const;
179 
180     // #i102062#
181     bool isWrongListEqual(const ContentInfo& rCompare) const;
182 };
183 
184 typedef ContentInfo* ContentInfoPtr;
185 
186 typedef BaseList<ContentInfo> ContentInfoList;
187 
188 // MT 05/00: Sollte mal direkt EditTextObjekt werden => keine virtuellen Methoden mehr.
189 
190 class BinTextObject : public EditTextObject, public SfxItemPoolUser
191 {
192 	using EditTextObject::operator==;
193 	using EditTextObject::isWrongListEqual;
194 
195 private:
196 	ContentInfoList			aContents;
197 	SfxItemPool*			pPool;
198 	sal_Bool					bOwnerOfPool;
199 	XParaPortionList*		pPortionInfo;
200 
201 	sal_uInt32				nObjSettings;
202 	sal_uInt16 					nMetric;
203 	sal_uInt16 					nVersion;
204 	sal_uInt16					nUserType;
205 	sal_uInt16					nScriptType;
206 
207 	sal_Bool					bVertical;
208 	sal_Bool					bStoreUnicodeStrings;
209 
210 protected:
211 	void					DeleteContents();
212 	virtual void			StoreData( SvStream& rOStream ) const;
213 	virtual void			CreateData( SvStream& rIStream );
214 	sal_Bool					ImpChangeStyleSheets( const String& rOldName, SfxStyleFamily eOldFamily,
215 										const String& rNewName, SfxStyleFamily eNewFamily );
216 
217 public:
218 							BinTextObject( SfxItemPool* pPool );
219 							BinTextObject( const BinTextObject& );
220 	virtual					~BinTextObject();
221 
222 	virtual EditTextObject*	Clone() const;
223 
224 	sal_uInt16					GetUserType() const;
225 	void					SetUserType( sal_uInt16 n );
226 
227 	sal_uLong					GetObjectSettings() const;
228 	void					SetObjectSettings( sal_uLong n );
229 
230 	sal_Bool					IsVertical() const;
231 	void					SetVertical( sal_Bool b );
232 
233 	sal_uInt16					GetScriptType() const;
234 	void					SetScriptType( sal_uInt16 nType );
235 
236 	sal_uInt16					GetVersion() const;	// Solange der Outliner keine Recordlaenge speichert
237 
238 	ContentInfo*			CreateAndInsertContent();
239 	XEditAttribute*			CreateAttrib( const SfxPoolItem& rItem, sal_uInt16 nStart, sal_uInt16 nEnd );
240 	void					DestroyAttrib( XEditAttribute* pAttr );
241 
GetContents()242 	ContentInfoList&		GetContents()			{ return aContents; }
GetContents() const243 	const ContentInfoList&	GetContents() const		{ return aContents; }
GetPool() const244 	SfxItemPool*			GetPool() const			{ return pPool; }
GetPortionInfo() const245 	XParaPortionList*		GetPortionInfo() const	{ return pPortionInfo; }
SetPortionInfo(XParaPortionList * pP)246 	void					SetPortionInfo( XParaPortionList* pP )
247 								{ pPortionInfo = pP; }
248 
249 	virtual sal_uInt32			GetParagraphCount() const;
250 	virtual String			GetText( sal_uInt32 nParagraph ) const;
251 	virtual void			Insert( const EditTextObject& rObj, sal_uInt32 nPara );
252 	virtual EditTextObject*	CreateTextObject( sal_uInt32 nPara, sal_uInt32 nParas = 1 ) const;
253 	virtual void			RemoveParagraph( sal_uInt32 nPara );
254 
255 	virtual sal_Bool			HasPortionInfo() const;
256 	virtual void			ClearPortionInfo();
257 
258 	virtual sal_Bool			HasOnlineSpellErrors() const;
259 
260 	virtual sal_Bool			HasCharAttribs( sal_uInt16 nWhich = 0 ) const;
261 	virtual void			GetCharAttribs( sal_uInt32 nPara, EECharAttribArray& rLst ) const;
262 
263 	virtual sal_Bool			RemoveCharAttribs( sal_uInt16 nWhich = 0 );
264 	virtual sal_Bool			RemoveParaAttribs( sal_uInt16 nWhich = 0 );
265 
266 	virtual void			MergeParaAttribs( const SfxItemSet& rAttribs, sal_uInt16 nStart, sal_uInt16 nEnd );
267 
268 	virtual sal_Bool			IsFieldObject() const;
269 	virtual const SvxFieldItem*	GetField() const;
270 	virtual sal_Bool			HasField( TypeId Type = NULL ) const;
271 
272 	SfxItemSet 				GetParaAttribs( sal_uInt32 nPara ) const;
273 	void 					SetParaAttribs( sal_uInt32 nPara, const SfxItemSet& rAttribs );
274 
275 	virtual sal_Bool			HasStyleSheet( const XubString& rName, SfxStyleFamily eFamily ) const;
276 	virtual void			GetStyleSheet( sal_uInt32 nPara, XubString& rName, SfxStyleFamily& eFamily ) const;
277 	virtual void			SetStyleSheet( sal_uInt32 nPara, const XubString& rName, const SfxStyleFamily& eFamily );
278 	virtual sal_Bool			ChangeStyleSheets( 	const XubString& rOldName, SfxStyleFamily eOldFamily,
279 												const String& rNewName, SfxStyleFamily eNewFamily );
280 	virtual void			ChangeStyleSheetName( SfxStyleFamily eFamily, const XubString& rOldName, const XubString& rNewName );
281 
282 	void					CreateData300( SvStream& rIStream );
283 
HasMetric() const284 	sal_Bool					HasMetric() const			{ return nMetric != 0xFFFF; }
GetMetric() const285 	sal_uInt16					GetMetric() const			{ return nMetric; }
SetMetric(sal_uInt16 n)286 	void					SetMetric( sal_uInt16 n )		{ nMetric = n; }
287 
IsOwnerOfPool() const288 	sal_Bool					IsOwnerOfPool() const		{ return bOwnerOfPool; }
StoreUnicodeStrings(sal_Bool b)289 	void					StoreUnicodeStrings( sal_Bool b ) { bStoreUnicodeStrings = b; }
290 
291 /* cl removed because not needed anymore since binfilter
292 	void 					PrepareStore( SfxStyleSheetPool* pStyleSheetPool );
293 	void 					FinishStore();
294 	void 					FinishLoad( SfxStyleSheetPool* pStyleSheetPool );
295 */
296 
297 	bool					operator==( const BinTextObject& rCompare ) const;
298 
299     // #i102062#
300     bool isWrongListEqual(const BinTextObject& rCompare) const;
301 
302     // from SfxItemPoolUser
303 	virtual void ObjectInDestruction(const SfxItemPool& rSfxItemPool);
304 };
305 
306 #endif	// _EDITOBJ2_HXX
307 
308