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 <editeng/editobj.hxx>
28 #include <editdoc.hxx>
29 
30 #include <unotools/fontcvt.hxx>
31 
32 
33 class SfxStyleSheetPool;
34 
35 class XEditAttribute
36 {
37 	friend class ContentInfo;	// fuer DTOR
38 	friend class BinTextObject;	// fuer DTOR
39 
40 private:
41 	const SfxPoolItem*	pItem;
42 	sal_uInt16 				nStart;
43 	sal_uInt16 				nEnd;
44 
45 						XEditAttribute();
46 						XEditAttribute( const XEditAttribute& rCopyFrom );
47 
48 						~XEditAttribute();
49 
50 public:
51 						XEditAttribute( const SfxPoolItem& rAttr );
52 						XEditAttribute( const SfxPoolItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
53 
GetItem() const54 	const SfxPoolItem*	GetItem() const				{ return pItem; }
55 
GetStart()56 	sal_uInt16&				GetStart()					{ return nStart; }
GetEnd()57 	sal_uInt16&				GetEnd()					{ return nEnd; }
58 
GetStart() const59 	sal_uInt16				GetStart() const			{ return nStart; }
GetEnd() const60 	sal_uInt16				GetEnd() const				{ return nEnd; }
61 
GetLen() const62 	sal_uInt16				GetLen() const				{ return nEnd-nStart; }
63 
64 	inline sal_Bool			IsFeature();
65 
66 	inline bool			operator==( const XEditAttribute& rCompare );
67 };
68 
operator ==(const XEditAttribute & rCompare)69 inline bool XEditAttribute::operator==( const XEditAttribute& rCompare )
70 {
71 	return	(nStart == rCompare.nStart) &&
72 			(nEnd == rCompare.nEnd) &&
73 			( (pItem == rCompare.pItem) ||
74 			( pItem->Which() != rCompare.pItem->Which()) ||
75 			(*pItem == *rCompare.pItem));
76 }
77 
IsFeature()78 inline sal_Bool XEditAttribute::IsFeature()
79 {
80 	sal_uInt16 nWhich = pItem->Which();
81 	return 	( ( nWhich >= EE_FEATURE_START ) &&
82 			  ( nWhich <=  EE_FEATURE_END ) );
83 }
84 
85 typedef XEditAttribute* XEditAttributePtr;
86 SV_DECL_PTRARR( XEditAttributeListImpl, XEditAttributePtr, 0, 4 )
87 
88 class XEditAttributeList : public XEditAttributeListImpl
89 {
90 public:
91     XEditAttribute* FindAttrib( sal_uInt16 nWhich, sal_uInt16 nChar ) const;
92 };
93 
94 struct XParaPortion
95 {
96 	long				nHeight;
97 	sal_uInt16				nFirstLineOffset;
98 
99 	EditLineList		aLines;
100 	TextPortionList		aTextPortions;
101 };
102 
103 typedef XParaPortion* XParaPortionPtr;
104 SV_DECL_PTRARR( XBaseParaPortionList, XParaPortionPtr, 0, 4 )
105 
106 class XParaPortionList : public  XBaseParaPortionList
107 {
108 	sal_uIntPtr 		nRefDevPtr;
109 	OutDevType	eRefDevType;
110 	MapMode		aRefMapMode;
111 	sal_uLong		nPaperWidth;
112 
113 
114 public:
XParaPortionList(OutputDevice * pRefDev,sal_uLong nPW)115 			XParaPortionList( OutputDevice* pRefDev, sal_uLong nPW ) :
116 				aRefMapMode( pRefDev->GetMapMode() )
117 				{
118 					nRefDevPtr = (sal_uIntPtr)pRefDev; nPaperWidth = nPW;
119 					eRefDevType = pRefDev->GetOutDevType();
120 				}
121 
GetRefDevPtr() const122 	sal_uIntPtr			GetRefDevPtr() const 		{ return nRefDevPtr; }
GetPaperWidth() const123 	sal_uLong			GetPaperWidth() const 		{ return nPaperWidth; }
GetRefDevType() const124 	OutDevType		GetRefDevType() const 		{ return eRefDevType; }
GetRefMapMode() const125 	const MapMode&	GetRefMapMode() const		{ return aRefMapMode; }
126 };
127 
128 /* cl removed because not needed anymore since binfilter
129 struct LoadStoreTempInfos
130 {
131     ByteString              aOrgString_Load;
132 
133     FontToSubsFontConverter hOldSymbolConv_Store;
134     sal_Bool                    bSymbolParagraph_Store;
135 
136 
137     LoadStoreTempInfos() { bSymbolParagraph_Store = sal_False; hOldSymbolConv_Store = NULL; }
138 };
139 */
140 
141 class ContentInfo
142 {
143 	friend class BinTextObject;
144 
145 private:
146 	String				aText;
147 	String				aStyle;
148 	XEditAttributeList	aAttribs;
149 	SfxStyleFamily		eFamily;
150 	SfxItemSet			aParaAttribs;
151 	WrongList*			pWrongs;
152 
153 /* cl removed because not needed anymore since binfilter
154 	LoadStoreTempInfos* pTempLoadStoreInfos;
155 */
156 
157 						ContentInfo( SfxItemPool& rPool );
158 						ContentInfo( const ContentInfo& rCopyFrom, SfxItemPool& rPoolToUse  );
159 
160 public:
161 						~ContentInfo();
162 
GetText() const163 	const String&		GetText()			const	{ return aText; }
GetStyle() const164 	const String&		GetStyle()			const	{ return aStyle; }
GetAttribs() const165 	const XEditAttributeList& GetAttribs()	const	{ return aAttribs; }
GetParaAttribs() const166 	const SfxItemSet&	GetParaAttribs()	const	{ return aParaAttribs; }
GetFamily() const167 	SfxStyleFamily		GetFamily()			const	{ return eFamily; }
168 
GetText()169 	String&				GetText()			{ return aText; }
GetStyle()170 	String&				GetStyle()			{ return aStyle; }
GetAttribs()171 	XEditAttributeList&	GetAttribs()		{ return aAttribs; }
GetParaAttribs()172 	SfxItemSet&			GetParaAttribs()	{ return aParaAttribs; }
GetFamily()173 	SfxStyleFamily&		GetFamily()			{ return eFamily; }
174 
GetWrongList() const175 	WrongList*			GetWrongList() const			{ return pWrongs; }
SetWrongList(WrongList * p)176 	void				SetWrongList( WrongList* p )	{ pWrongs = p; }
177 	bool				operator==( const ContentInfo& rCompare ) const;
178 
179     // #i102062#
180     bool isWrongListEqual(const ContentInfo& rCompare) const;
181 };
182 
183 typedef ContentInfo* ContentInfoPtr;
184 SV_DECL_PTRARR( ContentInfoList, ContentInfoPtr, 1, 4 )
185 
186 // MT 05/00: Sollte mal direkt EditTextObjekt werden => keine virtuellen Methoden mehr.
187 
188 class BinTextObject : public EditTextObject, public SfxItemPoolUser
189 {
190 	using EditTextObject::operator==;
191 	using EditTextObject::isWrongListEqual;
192 
193 private:
194 	ContentInfoList			aContents;
195 	SfxItemPool*			pPool;
196 	sal_Bool					bOwnerOfPool;
197 	XParaPortionList*		pPortionInfo;
198 
199 	sal_uInt32				nObjSettings;
200 	sal_uInt16 					nMetric;
201 	sal_uInt16 					nVersion;
202 	sal_uInt16					nUserType;
203 	sal_uInt16					nScriptType;
204 
205 	sal_Bool					bVertical;
206 	sal_Bool					bStoreUnicodeStrings;
207 
208 protected:
209 	void					DeleteContents();
210 	virtual void			StoreData( SvStream& rOStream ) const;
211 	virtual void			CreateData( SvStream& rIStream );
212 	sal_Bool					ImpChangeStyleSheets( const String& rOldName, SfxStyleFamily eOldFamily,
213 										const String& rNewName, SfxStyleFamily eNewFamily );
214 
215 public:
216 							BinTextObject( SfxItemPool* pPool );
217 							BinTextObject( const BinTextObject& );
218 	virtual					~BinTextObject();
219 
220 	virtual EditTextObject*	Clone() const;
221 
222 	sal_uInt16					GetUserType() const;
223 	void					SetUserType( sal_uInt16 n );
224 
225 	sal_uLong					GetObjectSettings() const;
226 	void					SetObjectSettings( sal_uLong n );
227 
228 	sal_Bool					IsVertical() const;
229 	void					SetVertical( sal_Bool b );
230 
231 	sal_uInt16					GetScriptType() const;
232 	void					SetScriptType( sal_uInt16 nType );
233 
234 	sal_uInt16					GetVersion() const;	// Solange der Outliner keine Recordlaenge speichert
235 
236 	ContentInfo*			CreateAndInsertContent();
237 	XEditAttribute*			CreateAttrib( const SfxPoolItem& rItem, sal_uInt16 nStart, sal_uInt16 nEnd );
238 	void					DestroyAttrib( XEditAttribute* pAttr );
239 
GetContents()240 	ContentInfoList&		GetContents()			{ return aContents; }
GetContents() const241 	const ContentInfoList&	GetContents() const		{ return aContents; }
GetPool() const242 	SfxItemPool*			GetPool() const			{ return pPool; }
GetPortionInfo() const243 	XParaPortionList*		GetPortionInfo() const	{ return pPortionInfo; }
SetPortionInfo(XParaPortionList * pP)244 	void					SetPortionInfo( XParaPortionList* pP )
245 								{ pPortionInfo = pP; }
246 
247 	virtual sal_uInt16			GetParagraphCount() const;
248 	virtual String			GetText( sal_uInt16 nParagraph ) const;
249 	virtual void			Insert( const EditTextObject& rObj, sal_uInt16 nPara );
250 	virtual EditTextObject*	CreateTextObject( sal_uInt16 nPara, sal_uInt16 nParas = 1 ) const;
251 	virtual void			RemoveParagraph( sal_uInt16 nPara );
252 
253 	virtual sal_Bool			HasPortionInfo() const;
254 	virtual void			ClearPortionInfo();
255 
256 	virtual sal_Bool			HasOnlineSpellErrors() const;
257 
258 	virtual sal_Bool			HasCharAttribs( sal_uInt16 nWhich = 0 ) const;
259 	virtual void			GetCharAttribs( sal_uInt16 nPara, EECharAttribArray& rLst ) const;
260 
261 	virtual sal_Bool			RemoveCharAttribs( sal_uInt16 nWhich = 0 );
262 	virtual sal_Bool			RemoveParaAttribs( sal_uInt16 nWhich = 0 );
263 
264 	virtual void			MergeParaAttribs( const SfxItemSet& rAttribs, sal_uInt16 nStart, sal_uInt16 nEnd );
265 
266 	virtual sal_Bool			IsFieldObject() const;
267 	virtual const SvxFieldItem*	GetField() const;
268 	virtual sal_Bool			HasField( TypeId Type = NULL ) const;
269 
270 	SfxItemSet 				GetParaAttribs( sal_uInt16 nPara ) const;
271 	void 					SetParaAttribs( sal_uInt16 nPara, const SfxItemSet& rAttribs );
272 
273 	virtual sal_Bool			HasStyleSheet( const XubString& rName, SfxStyleFamily eFamily ) const;
274 	virtual void			GetStyleSheet( sal_uInt16 nPara, XubString& rName, SfxStyleFamily& eFamily ) const;
275 	virtual void			SetStyleSheet( sal_uInt16 nPara, const XubString& rName, const SfxStyleFamily& eFamily );
276 	virtual sal_Bool			ChangeStyleSheets( 	const XubString& rOldName, SfxStyleFamily eOldFamily,
277 												const String& rNewName, SfxStyleFamily eNewFamily );
278 	virtual void			ChangeStyleSheetName( SfxStyleFamily eFamily, const XubString& rOldName, const XubString& rNewName );
279 
280 	void					CreateData300( SvStream& rIStream );
281 
HasMetric() const282 	sal_Bool					HasMetric() const			{ return nMetric != 0xFFFF; }
GetMetric() const283 	sal_uInt16					GetMetric() const			{ return nMetric; }
SetMetric(sal_uInt16 n)284 	void					SetMetric( sal_uInt16 n )		{ nMetric = n; }
285 
IsOwnerOfPool() const286 	sal_Bool					IsOwnerOfPool() const		{ return bOwnerOfPool; }
StoreUnicodeStrings(sal_Bool b)287 	void					StoreUnicodeStrings( sal_Bool b ) { bStoreUnicodeStrings = b; }
288 
289 /* cl removed because not needed anymore since binfilter
290 	void 					PrepareStore( SfxStyleSheetPool* pStyleSheetPool );
291 	void 					FinishStore();
292 	void 					FinishLoad( SfxStyleSheetPool* pStyleSheetPool );
293 */
294 
295 	bool					operator==( const BinTextObject& rCompare ) const;
296 
297     // #i102062#
298     bool isWrongListEqual(const BinTextObject& rCompare) const;
299 
300     // from SfxItemPoolUser
301 	virtual void ObjectInDestruction(const SfxItemPool& rSfxItemPool);
302 };
303 
304 #endif	// _EDITOBJ2_HXX
305 
306