Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _EDITDOC_HXX
30 : : #define _EDITDOC_HXX
31 : :
32 : : #include <com/sun/star/i18n/XExtendedInputSequenceChecker.hpp>
33 : :
34 : : #include "editattr.hxx"
35 : : #include "edtspell.hxx"
36 : : #include <editeng/svxfont.hxx>
37 : : #include <svl/itemset.hxx>
38 : : #include <svl/style.hxx>
39 : : #include <svl/itempool.hxx>
40 : :
41 : : #include <vector>
42 : : #include <deque>
43 : :
44 : : #include <boost/ptr_container/ptr_vector.hpp>
45 : : #include <boost/noncopyable.hpp>
46 : :
47 : : class ImpEditEngine;
48 : : class SvxTabStop;
49 : :
50 : : DBG_NAMEEX( EE_TextPortion )
51 : :
52 : : #define CHARPOSGROW 16
53 : : #define DEFTAB 720
54 : :
55 : : void CreateFont( SvxFont& rFont, const SfxItemSet& rSet, bool bSearchInParent = true, short nScriptType = 0 );
56 : : sal_uInt16 GetScriptItemId( sal_uInt16 nItemId, short nScriptType );
57 : : sal_Bool IsScriptItemValid( sal_uInt16 nItemId, short nScriptType );
58 : :
59 : : EditCharAttrib* MakeCharAttrib( SfxItemPool& rPool, const SfxPoolItem& rAttr, sal_uInt16 nS, sal_uInt16 nE );
60 : :
61 : : class ContentNode;
62 : : class EditDoc;
63 : :
64 : : struct EPaM
65 : : {
66 : : sal_uInt16 nPara;
67 : : sal_uInt16 nIndex;
68 : :
69 : 54 : EPaM() { nPara = 0; nIndex = 0; }
70 : 26654 : EPaM( sal_uInt16 nP, sal_uInt16 nI ) { nPara = nP; nIndex = nI; }
71 : 26600 : EPaM( const EPaM& r) { nPara = r.nPara; nIndex = r.nIndex; }
72 : 54 : EPaM& operator = ( const EPaM& r ) { nPara = r.nPara; nIndex = r.nIndex; return *this; }
73 : : inline sal_Bool operator == ( const EPaM& r ) const;
74 : : inline sal_Bool operator < ( const EPaM& r ) const;
75 : : };
76 : :
77 : 18 : inline sal_Bool EPaM::operator < ( const EPaM& r ) const
78 : : {
79 : : return ( ( nPara < r.nPara ) ||
80 [ + - ][ + - ]: 18 : ( ( nPara == r.nPara ) && nIndex < r.nIndex ) ) ? sal_True : sal_False;
[ - + ]
81 : : }
82 : :
83 : 18 : inline sal_Bool EPaM::operator == ( const EPaM& r ) const
84 : : {
85 [ + - ][ + - ]: 18 : return ( ( nPara == r.nPara ) && ( nIndex == r.nIndex ) ) ? sal_True : sal_False;
86 : : }
87 : :
88 : : struct ScriptTypePosInfo
89 : : {
90 : : short nScriptType;
91 : : sal_uInt16 nStartPos;
92 : : sal_uInt16 nEndPos;
93 : :
94 : 176613 : ScriptTypePosInfo( short _Type, sal_uInt16 _Start, sal_uInt16 _End )
95 : : {
96 : 176613 : nScriptType = _Type;
97 : 176613 : nStartPos = _Start;
98 : 176613 : nEndPos = _End;
99 : 176613 : }
100 : : };
101 : :
102 : : typedef std::deque< ScriptTypePosInfo > ScriptTypePosInfos;
103 : :
104 : : struct WritingDirectionInfo
105 : : {
106 : : sal_uInt8 nType;
107 : : sal_uInt16 nStartPos;
108 : : sal_uInt16 nEndPos;
109 : :
110 : 174733 : WritingDirectionInfo( sal_uInt8 _Type, sal_uInt16 _Start, sal_uInt16 _End )
111 : : {
112 : 174733 : nType = _Type;
113 : 174733 : nStartPos = _Start;
114 : 174733 : nEndPos = _End;
115 : 174733 : }
116 : : };
117 : :
118 : :
119 : : typedef std::deque< WritingDirectionInfo > WritingDirectionInfos;
120 : :
121 [ + - ]: 2420 : class ContentAttribsInfo
122 : : {
123 : : private:
124 : : typedef boost::ptr_vector<EditCharAttrib> CharAttribsType;
125 : :
126 : : SfxItemSet aPrevParaAttribs;
127 : : CharAttribsType aPrevCharAttribs;
128 : :
129 : : public:
130 : : ContentAttribsInfo( const SfxItemSet& rParaAttribs );
131 : :
132 : 0 : const SfxItemSet& GetPrevParaAttribs() const { return aPrevParaAttribs; }
133 : 0 : const CharAttribsType& GetPrevCharAttribs() const { return aPrevCharAttribs; }
134 : :
135 : : void RemoveAllCharAttribsFromPool(SfxItemPool& rPool) const;
136 : : void AppendCharAttrib(EditCharAttrib* pNew);
137 : : };
138 : :
139 : : // ----------------------------------------------------------------------
140 : : // class SvxColorList
141 : : // ----------------------------------------------------------------------
142 : :
143 : : class SvxColorList
144 : : {
145 : : private:
146 : : typedef std::vector<SvxColorItem*> DummyColorList;
147 : : DummyColorList aColorList;
148 : :
149 : : public:
150 : : SvxColorList();
151 : : ~SvxColorList();
152 : :
153 : : size_t GetId( const SvxColorItem& rColor );
154 : 0 : size_t Count() { return aColorList.size(); };
155 : : void Insert( SvxColorItem* pItem, size_t nIndex );
156 : : SvxColorItem* GetObject( size_t nIndex );
157 : : };
158 : :
159 : : // ----------------------------------------------------------------------
160 : : // class ItemList
161 : : // ----------------------------------------------------------------------
162 : :
163 : 0 : class ItemList
164 : : {
165 : : private:
166 : : typedef std::vector<const SfxPoolItem*> DummyItemList;
167 : : DummyItemList aItemPool;
168 : : size_t CurrentItem;
169 : :
170 : : public:
171 : : ItemList();
172 : : const SfxPoolItem* First();
173 : : const SfxPoolItem* Next();
174 : 0 : size_t Count() { return aItemPool.size(); };
175 : : void Insert( const SfxPoolItem* pItem );
176 : 0 : void Clear() { aItemPool.clear(); };
177 : : };
178 : :
179 : : // -------------------------------------------------------------------------
180 : : // class ContentAttribs
181 : : // -------------------------------------------------------------------------
182 : : class ContentAttribs
183 : : {
184 : : private:
185 : : SfxStyleSheet* pStyle;
186 : : SfxItemSet aAttribSet;
187 : :
188 : : public:
189 : : ContentAttribs( SfxItemPool& rItemPool );
190 : : ContentAttribs( const ContentAttribs& );
191 : : ~ContentAttribs(); // only for larger Tabs
192 : :
193 : : SvxTabStop FindTabStop( long nCurPos, sal_uInt16 nDefTab );
194 : 2005076 : SfxItemSet& GetItems() { return aAttribSet; }
195 : 593842 : const SfxItemSet& GetItems() const { return aAttribSet; }
196 : 0 : const SfxStyleSheet* GetStyleSheet() const { return pStyle; }
197 : 811273 : SfxStyleSheet* GetStyleSheet() { return pStyle; }
198 : : void SetStyleSheet( SfxStyleSheet* pS );
199 : :
200 : : const SfxPoolItem& GetItem( sal_uInt16 nWhich ) const;
201 : : bool HasItem( sal_uInt16 nWhich ) const;
202 : : };
203 : :
204 : : // -------------------------------------------------------------------------
205 : : // class CharAttribList
206 : : // -------------------------------------------------------------------------
207 : : class CharAttribList
208 : : {
209 : : public:
210 : : typedef boost::ptr_vector<EditCharAttrib> AttribsType;
211 : :
212 : : private:
213 : : AttribsType aAttribs;
214 : : SvxFont aDefFont; // faster than ever from the pool!
215 : : bool bHasEmptyAttribs;
216 : :
217 : : CharAttribList( const CharAttribList& ) {;}
218 : :
219 : : public:
220 : : CharAttribList();
221 : : ~CharAttribList();
222 : :
223 : : void DeleteEmptyAttribs( SfxItemPool& rItemPool );
224 : : void RemoveItemsFromPool( SfxItemPool* pItemPool );
225 : :
226 : : const EditCharAttrib* FindAttrib( sal_uInt16 nWhich, sal_uInt16 nPos ) const;
227 : : EditCharAttrib* FindAttrib( sal_uInt16 nWhich, sal_uInt16 nPos );
228 : : const EditCharAttrib* FindNextAttrib( sal_uInt16 nWhich, sal_uInt16 nFromPos ) const;
229 : : const EditCharAttrib* FindEmptyAttrib( sal_uInt16 nWhich, sal_uInt16 nPos ) const;
230 : : EditCharAttrib* FindEmptyAttrib( sal_uInt16 nWhich, sal_uInt16 nPos );
231 : : const EditCharAttrib* FindFeature( sal_uInt16 nPos ) const;
232 : :
233 : :
234 : : void ResortAttribs();
235 : : void OptimizeRanges( SfxItemPool& rItemPool );
236 : :
237 : : size_t Count() const;
238 : :
239 : : void InsertAttrib( EditCharAttrib* pAttrib );
240 : :
241 : 1667933 : SvxFont& GetDefFont() { return aDefFont; }
242 : :
243 : 3984 : bool HasEmptyAttribs() const { return bHasEmptyAttribs; }
244 : : void SetHasEmptyAttribs(bool b);
245 : : bool HasBoundingAttrib( sal_uInt16 nBound ) const;
246 : : bool HasAttrib( sal_uInt16 nStartPos, sal_uInt16 nEndPos ) const;
247 : :
248 : : AttribsType& GetAttribs();
249 : : const AttribsType& GetAttribs() const;
250 : :
251 : : void Remove(const EditCharAttrib* p);
252 : : void Remove(size_t nPos);
253 : : void Release(const EditCharAttrib* p);
254 : :
255 : : #if OSL_DEBUG_LEVEL > 2
256 : : // Debug:
257 : : bool DbgCheckAttribs() const;
258 : : #endif
259 : : };
260 : :
261 : : // -------------------------------------------------------------------------
262 : : // class ContentNode
263 : : // -------------------------------------------------------------------------
264 : : class ContentNode : boost::noncopyable
265 : : {
266 : : private:
267 : : XubString maString;
268 : : ContentAttribs aContentAttribs;
269 : : CharAttribList aCharAttribList;
270 : : WrongList* pWrongList;
271 : :
272 : : public:
273 : : ContentNode( SfxItemPool& rItemPool );
274 : : ContentNode( const XubString& rStr, const ContentAttribs& rContentAttribs );
275 : : ~ContentNode();
276 : :
277 : 6055405 : ContentAttribs& GetContentAttribs() { return aContentAttribs; }
278 : 2294642 : const ContentAttribs& GetContentAttribs() const { return aContentAttribs; }
279 : 3566702 : CharAttribList& GetCharAttribs() { return aCharAttribList; }
280 : 756835 : const CharAttribList& GetCharAttribs() const { return aCharAttribList; }
281 : :
282 : : void ExpandAttribs( sal_uInt16 nIndex, sal_uInt16 nNewChars, SfxItemPool& rItemPool );
283 : : void CollapsAttribs( sal_uInt16 nIndex, sal_uInt16 nDelChars, SfxItemPool& rItemPool );
284 : : void AppendAttribs( ContentNode* pNextNode );
285 : : void CopyAndCutAttribs( ContentNode* pPrevNode, SfxItemPool& rPool, sal_Bool bKeepEndingAttribs );
286 : :
287 : : void SetStyleSheet( SfxStyleSheet* pS, sal_Bool bRecalcFont = sal_True );
288 : : void SetStyleSheet( SfxStyleSheet* pS, const SvxFont& rFontFromStyle );
289 : 436901 : SfxStyleSheet* GetStyleSheet() { return aContentAttribs.GetStyleSheet(); }
290 : : const SfxStyleSheet* GetStyleSheet() const { return aContentAttribs.GetStyleSheet(); }
291 : :
292 : : void CreateDefFont();
293 : :
294 : 93433 : WrongList* GetWrongList() { return pWrongList; }
295 : 0 : const WrongList* GetWrongList() const { return pWrongList; }
296 : : void SetWrongList( WrongList* p );
297 : :
298 : : void CreateWrongList();
299 : : void DestroyWrongList();
300 : :
301 : : bool IsFeature( sal_uInt16 nPos ) const;
302 : :
303 : : sal_uInt16 Len() const;
304 : : const XubString& GetString() const;
305 : :
306 : : void SetChar(sal_uInt16 nPos, sal_Unicode c);
307 : : void Insert(const XubString& rStr, sal_uInt16 nPos);
308 : : void Append(const XubString& rStr);
309 : : void Erase(sal_uInt16 nPos);
310 : : void Erase(sal_uInt16 nPos, sal_uInt16 nCount);
311 : : XubString Copy(sal_uInt16 nPos) const;
312 : : XubString Copy(sal_uInt16 nPos, sal_uInt16 nCount) const;
313 : : sal_Unicode GetChar(sal_uInt16 nPos) const;
314 : : };
315 : :
316 : : // -------------------------------------------------------------------------
317 : : // class EditPaM
318 : : // -------------------------------------------------------------------------
319 : : class EditPaM
320 : : {
321 : : private:
322 : : ContentNode* pNode;
323 : : sal_uInt16 nIndex;
324 : :
325 : : public:
326 : : EditPaM();
327 : : EditPaM(const EditPaM& r);
328 : : EditPaM(ContentNode* p, sal_uInt16 n);
329 : :
330 : : const ContentNode* GetNode() const;
331 : : ContentNode* GetNode();
332 : : void SetNode(ContentNode* p);
333 : :
334 : 1341796 : sal_uInt16 GetIndex() const { return nIndex; }
335 : 1795545 : sal_uInt16& GetIndex() { return nIndex; }
336 : 94418 : void SetIndex( sal_uInt16 n ) { nIndex = n; }
337 : :
338 : : sal_Bool DbgIsBuggy( EditDoc& rDoc );
339 : :
340 : : EditPaM& operator = ( const EditPaM& rPaM );
341 : : friend sal_Bool operator == ( const EditPaM& r1, const EditPaM& r2 );
342 : : friend sal_Bool operator != ( const EditPaM& r1, const EditPaM& r2 );
343 : : };
344 : :
345 : : #define PORTIONKIND_TEXT 0
346 : : #define PORTIONKIND_TAB 1
347 : : #define PORTIONKIND_LINEBREAK 2
348 : : #define PORTIONKIND_FIELD 3
349 : : #define PORTIONKIND_HYPHENATOR 4
350 : :
351 : : #define DELMODE_SIMPLE 0
352 : : #define DELMODE_RESTOFWORD 1
353 : : #define DELMODE_RESTOFCONTENT 2
354 : :
355 : : #define CHAR_NORMAL 0x00
356 : : #define CHAR_KANA 0x01
357 : : #define CHAR_PUNCTUATIONLEFT 0x02
358 : : #define CHAR_PUNCTUATIONRIGHT 0x04
359 : :
360 : : // -------------------------------------------------------------------------
361 : : // struct ExtraPortionInfos
362 : : // -------------------------------------------------------------------------
363 : : struct ExtraPortionInfo
364 : : {
365 : : long nOrgWidth;
366 : : long nWidthFullCompression;
367 : :
368 : : long nPortionOffsetX;
369 : :
370 : : sal_uInt16 nMaxCompression100thPercent;
371 : :
372 : : sal_uInt8 nAsianCompressionTypes;
373 : : sal_Bool bFirstCharIsRightPunktuation;
374 : : sal_Bool bCompressed;
375 : :
376 : : sal_Int32* pOrgDXArray;
377 : : ::std::vector< sal_Int32 > lineBreaksList;
378 : :
379 : :
380 : : ExtraPortionInfo();
381 : : ~ExtraPortionInfo();
382 : :
383 : : void SaveOrgDXArray( const sal_Int32* pDXArray, sal_uInt16 nLen );
384 : : };
385 : :
386 : :
387 : : // -------------------------------------------------------------------------
388 : : // class TextPortion
389 : : // -------------------------------------------------------------------------
390 : : class TextPortion
391 : : {
392 : : private:
393 : : ExtraPortionInfo* pExtraInfos;
394 : : sal_uInt16 nLen;
395 : : Size aOutSz;
396 : : sal_uInt8 nKind;
397 : : sal_uInt8 nRightToLeft;
398 : : sal_Unicode nExtraValue;
399 : :
400 : :
401 : : TextPortion() { DBG_CTOR( EE_TextPortion, 0 );
402 : : pExtraInfos = NULL; nLen = 0; nKind = PORTIONKIND_TEXT; nExtraValue = 0; nRightToLeft = sal_False;}
403 : :
404 : : public:
405 : 420715 : TextPortion( sal_uInt16 nL ) : aOutSz( -1, -1 )
406 : : { DBG_CTOR( EE_TextPortion, 0 );
407 : 420715 : pExtraInfos = NULL; nLen = nL; nKind = PORTIONKIND_TEXT; nExtraValue = 0; nRightToLeft = sal_False;}
408 : 0 : TextPortion( const TextPortion& r ) : aOutSz( r.aOutSz )
409 : : { DBG_CTOR( EE_TextPortion, 0 );
410 : 0 : pExtraInfos = NULL; nLen = r.nLen; nKind = r.nKind; nExtraValue = r.nExtraValue; nRightToLeft = r.nRightToLeft; }
411 : :
412 [ - + ]: 420500 : ~TextPortion() { DBG_DTOR( EE_TextPortion, 0 ); delete pExtraInfos; }
413 : :
414 : 370181 : sal_uInt16 GetLen() const { return nLen; }
415 : 2516346 : sal_uInt16& GetLen() { return nLen; }
416 : 0 : void SetLen( sal_uInt16 nL ) { nLen = nL; }
417 : :
418 : 1269734 : Size& GetSize() { return aOutSz; }
419 : 148027 : Size GetSize() const { return aOutSz; }
420 : :
421 : 540274 : sal_uInt8& GetKind() { return nKind; }
422 : 435252 : sal_uInt8 GetKind() const { return nKind; }
423 : :
424 : 206873 : void SetRightToLeft( sal_uInt8 b ) { nRightToLeft = b; }
425 : 40569 : sal_uInt8 GetRightToLeft() const { return nRightToLeft; }
426 : 26733 : sal_Bool IsRightToLeft() const { return (nRightToLeft&1); }
427 : :
428 : 88 : sal_Unicode GetExtraValue() const { return nExtraValue; }
429 : 0 : void SetExtraValue( sal_Unicode n ) { nExtraValue = n; }
430 : :
431 : 0 : sal_Bool HasValidSize() const { return aOutSz.Width() != (-1); }
432 : :
433 : 98188 : ExtraPortionInfo* GetExtraInfos() const { return pExtraInfos; }
434 [ # # ]: 0 : void SetExtraInfos( ExtraPortionInfo* p ) { delete pExtraInfos; pExtraInfos = p; }
435 : : };
436 : :
437 : : // -------------------------------------------------------------------------
438 : : // class TextPortionList
439 : : // -------------------------------------------------------------------------
440 : : class TextPortionList
441 : : {
442 : : typedef boost::ptr_vector<TextPortion> PortionsType;
443 : : PortionsType maPortions;
444 : :
445 : : public:
446 : : TextPortionList();
447 : : ~TextPortionList();
448 : :
449 : : void Reset();
450 : : size_t FindPortion(
451 : : sal_uInt16 nCharPos, sal_uInt16& rPortionStart, bool bPreferStartingPortion = false) const;
452 : : sal_uInt16 GetStartPos(size_t nPortion);
453 : : void DeleteFromPortion(size_t nDelFrom);
454 : : size_t Count() const;
455 : : const TextPortion* operator[](size_t nPos) const;
456 : : TextPortion* operator[](size_t nPos);
457 : :
458 : : void Append(TextPortion* p);
459 : : void Insert(size_t nPos, TextPortion* p);
460 : : void Remove(size_t nPos);
461 : : size_t GetPos(const TextPortion* p) const;
462 : : };
463 : :
464 : : class ParaPortion;
465 : :
466 : : // ------------------------------------------------------------------------
467 : : // class EditLine
468 : : // -------------------------------------------------------------------------
469 : : class EditLine
470 : : {
471 : : public:
472 : : typedef std::vector<sal_Int32> CharPosArrayType;
473 : :
474 : : private:
475 : : CharPosArrayType aPositions;
476 : : long nTxtWidth;
477 : : sal_uInt16 nStartPosX;
478 : : sal_uInt16 nStart; // could be replaced by nStartPortion
479 : : sal_uInt16 nEnd; // could be replaced by nEndPortion
480 : : sal_uInt16 nStartPortion;
481 : : sal_uInt16 nEndPortion;
482 : : sal_uInt16 nHeight; // Total height of the line
483 : : sal_uInt16 nTxtHeight; // Pure Text height
484 : : sal_uInt16 nCrsrHeight; // For contour flow high lines => cursor is large.
485 : : sal_uInt16 nMaxAscent;
486 : : bool bHangingPunctuation:1;
487 : : bool bInvalid:1; // for skillful formatting
488 : :
489 : : public:
490 : : EditLine();
491 : : EditLine( const EditLine& );
492 : : ~EditLine();
493 : :
494 : 0 : sal_Bool IsIn( sal_uInt16 nIndex ) const
495 [ # # ][ # # ]: 0 : { return ( (nIndex >= nStart ) && ( nIndex < nEnd ) ); }
496 : :
497 : 175 : sal_Bool IsIn( sal_uInt16 nIndex, sal_Bool bInclEnd ) const
498 [ + - ][ + + ]: 175 : { return ( ( nIndex >= nStart ) && ( bInclEnd ? ( nIndex <= nEnd ) : ( nIndex < nEnd ) ) ); }
[ + - ][ + + ]
499 : :
500 : 304468 : void SetStart( sal_uInt16 n ) { nStart = n; }
501 : 43346 : sal_uInt16 GetStart() const { return nStart; }
502 : 1897180 : sal_uInt16& GetStart() { return nStart; }
503 : :
504 : 513053 : void SetEnd( sal_uInt16 n ) { nEnd = n; }
505 : 1305 : sal_uInt16 GetEnd() const { return nEnd; }
506 : 323149 : sal_uInt16& GetEnd() { return nEnd; }
507 : :
508 : 94230 : void SetStartPortion( sal_uInt16 n ) { nStartPortion = n; }
509 : 44155 : sal_uInt16 GetStartPortion() const { return nStartPortion; }
510 : 511327 : sal_uInt16& GetStartPortion() { return nStartPortion; }
511 : :
512 : 302815 : void SetEndPortion( sal_uInt16 n ) { nEndPortion = n; }
513 : 61042 : sal_uInt16 GetEndPortion() const { return nEndPortion; }
514 : 815756 : sal_uInt16& GetEndPortion() { return nEndPortion; }
515 : :
516 : 426005 : void SetHeight( sal_uInt16 nH, sal_uInt16 nTxtH = 0, sal_uInt16 nCrsrH = 0 )
517 : 426005 : { nHeight = nH;
518 [ + + ]: 426005 : nTxtHeight = ( nTxtH ? nTxtH : nH );
519 [ + - ]: 426005 : nCrsrHeight = ( nCrsrH ? nCrsrH : nTxtHeight );
520 : 426005 : }
521 : 1481744 : sal_uInt16 GetHeight() const { return nHeight; }
522 : 2246 : sal_uInt16 GetTxtHeight() const { return nTxtHeight; }
523 : : sal_uInt16 GetCrsrHeight() const { return nCrsrHeight; }
524 : :
525 : 208562 : void SetTextWidth( long n ) { nTxtWidth = n; }
526 : 16 : long GetTextWidth() const { return nTxtWidth; }
527 : :
528 : 419192 : void SetMaxAscent( sal_uInt16 n ) { nMaxAscent = n; }
529 : 22617 : sal_uInt16 GetMaxAscent() const { return nMaxAscent; }
530 : :
531 : 100770 : void SetHangingPunctuation( bool b ) { bHangingPunctuation = b; }
532 : 208554 : bool IsHangingPunctuation() const { return bHangingPunctuation; }
533 : :
534 : 208760 : sal_uInt16 GetLen() const { return nEnd - nStart; }
535 : :
536 : 44368 : sal_uInt16 GetStartPosX() const { return nStartPosX; }
537 : 418811 : void SetStartPosX( sal_uInt16 start ) { nStartPosX = start; }
538 : :
539 : : Size CalcTextSize( ParaPortion& rParaPortion );
540 : :
541 : 314936 : bool IsInvalid() const { return bInvalid; }
542 : 406144 : bool IsValid() const { return !bInvalid; }
543 : 208554 : void SetInvalid() { bInvalid = true; }
544 : 111164 : void SetValid() { bInvalid = false; }
545 : :
546 : 116 : sal_Bool IsEmpty() const { return (nEnd > nStart) ? sal_False : sal_True; }
547 : :
548 : : CharPosArrayType& GetCharPosArray();
549 : : const CharPosArrayType& GetCharPosArray() const;
550 : :
551 : : EditLine* Clone() const;
552 : :
553 : : EditLine& operator = ( const EditLine& rLine );
554 : : friend sal_Bool operator == ( const EditLine& r1, const EditLine& r2 );
555 : : friend sal_Bool operator != ( const EditLine& r1, const EditLine& r2 );
556 : : };
557 : :
558 : :
559 : : // -------------------------------------------------------------------------
560 : : // class LineList
561 : : // -------------------------------------------------------------------------
562 : : class EditLineList
563 : : {
564 : : typedef boost::ptr_vector<EditLine> LinesType;
565 : : LinesType maLines;
566 : :
567 : : public:
568 : : EditLineList();
569 : : ~EditLineList();
570 : :
571 : : void Reset();
572 : : void DeleteFromLine(size_t nDelFrom);
573 : : size_t FindLine(sal_uInt16 nChar, bool bInclEnd);
574 : : size_t Count() const;
575 : : const EditLine* operator[](size_t nPos) const;
576 : : EditLine* operator[](size_t nPos);
577 : :
578 : : void Append(EditLine* p);
579 : : void Insert(size_t nPos, EditLine* p);
580 : : };
581 : :
582 : : // -------------------------------------------------------------------------
583 : : // class ParaPortion
584 : : // -------------------------------------------------------------------------
585 : : class ParaPortion
586 : : {
587 : : friend class ImpEditEngine; // to adjust the height
588 : : private:
589 : : EditLineList aLineList;
590 : : TextPortionList aTextPortionList;
591 : : ContentNode* pNode;
592 : : long nHeight;
593 : :
594 : : ScriptTypePosInfos aScriptInfos;
595 : : WritingDirectionInfos aWritingDirectionInfos;
596 : :
597 : : sal_uInt16 nInvalidPosStart;
598 : : sal_uInt16 nFirstLineOffset; // For Writer-LineSpacing-Interpretation
599 : : sal_uInt16 nBulletX;
600 : : short nInvalidDiff;
601 : :
602 : : sal_Bool bInvalid : 1;
603 : : sal_Bool bSimple : 1; // only linear Tap
604 : : sal_Bool bVisible : 1; // Belongs to the node!
605 : : sal_Bool bForceRepaint : 1;
606 : :
607 : : ParaPortion( const ParaPortion& );
608 : :
609 : : public:
610 : : ParaPortion( ContentNode* pNode );
611 : : ~ParaPortion();
612 : :
613 : : sal_uInt16 GetLineNumber( sal_uInt16 nIndex ) const;
614 : :
615 : 5101308 : EditLineList& GetLines() { return aLineList; }
616 : 42268 : const EditLineList& GetLines() const { return aLineList; }
617 : :
618 : 695880 : sal_Bool IsInvalid() const { return bInvalid; }
619 : 437184 : sal_Bool IsSimpleInvalid() const { return bSimple; }
620 : 324581 : void SetValid() { bInvalid = sal_False; bSimple = sal_True;}
621 : :
622 : 666124 : sal_Bool MustRepaint() const { return bForceRepaint; }
623 : 249795 : void SetMustRepaint( sal_Bool bRP ) { bForceRepaint = bRP; }
624 : :
625 : 415236 : sal_uInt16 GetBulletX() const { return nBulletX; }
626 : 324581 : void SetBulletX( sal_uInt16 n ) { nBulletX = n; }
627 : :
628 : : void MarkInvalid( sal_uInt16 nStart, short nDiff);
629 : : void MarkSelectionInvalid( sal_uInt16 nStart, sal_uInt16 nEnd );
630 : :
631 : : void SetVisible( sal_Bool bVisible );
632 : 1090720 : bool IsVisible() const { return bVisible; }
633 : :
634 [ + + ][ + + ]: 342380 : sal_Bool IsEmpty() { return GetTextPortions().Count() == 1 && GetTextPortions()[0]->GetLen() == 0; }
635 : :
636 [ + - ]: 1362356 : long GetHeight() const { return ( bVisible ? nHeight : 0 ); }
637 [ + - ]: 335238 : sal_uInt16 GetFirstLineOffset() const { return ( bVisible ? nFirstLineOffset : 0 ); }
638 : 0 : void ResetHeight() { nHeight = 0; nFirstLineOffset = 0; }
639 : :
640 : 5294795 : ContentNode* GetNode() const { return pNode; }
641 : 3371802 : TextPortionList& GetTextPortions() { return aTextPortionList; }
642 : 115869 : const TextPortionList& GetTextPortions() const { return aTextPortionList; }
643 : :
644 : 114343 : sal_uInt16 GetInvalidPosStart() const { return nInvalidPosStart; }
645 : 114343 : short GetInvalidDiff() const { return nInvalidDiff; }
646 : :
647 : : void CorrectValuesBehindLastFormattedLine( sal_uInt16 nLastFormattedLine );
648 : : #if OSL_DEBUG_LEVEL > 2
649 : : sal_Bool DbgCheckTextPortions();
650 : : #endif
651 : : };
652 : :
653 : : // -------------------------------------------------------------------------
654 : : // class ParaPortionList
655 : : // -------------------------------------------------------------------------
656 : : class ParaPortionList
657 : : {
658 : : mutable size_t nLastCache;
659 : : boost::ptr_vector<ParaPortion> maPortions;
660 : : public:
661 : : ParaPortionList();
662 : : ~ParaPortionList();
663 : :
664 : : void Reset();
665 : : long GetYOffset(const ParaPortion* pPPortion) const;
666 : : sal_uInt16 FindParagraph(long nYOffset) const;
667 : :
668 : : const ParaPortion* SafeGetObject(size_t nPos) const;
669 : : ParaPortion* SafeGetObject(size_t nPos);
670 : :
671 : : sal_uInt16 GetPos(const ParaPortion* p) const;
672 : : ParaPortion* operator[](size_t nPos);
673 : : const ParaPortion* operator[](size_t nPos) const;
674 : :
675 : : ParaPortion* Release(size_t nPos);
676 : : void Remove(size_t nPos);
677 : : void Insert(size_t nPos, ParaPortion* p);
678 : : void Append(ParaPortion* p);
679 : : size_t Count() const;
680 : :
681 : : #if OSL_DEBUG_LEVEL > 2
682 : : // temporary:
683 : : void DbgCheck( EditDoc& rDoc );
684 : : #endif
685 : : };
686 : :
687 : : // -------------------------------------------------------------------------
688 : : // class EditSelection
689 : : // -------------------------------------------------------------------------
690 : 222254 : class EditSelection
691 : : {
692 : : private:
693 : : EditPaM aStartPaM;
694 : : EditPaM aEndPaM;
695 : :
696 : : public:
697 : : EditSelection(); // No constructor and destructor
698 : : // are automtically excecuted correctly!
699 : : EditSelection( const EditPaM& rStartAndAnd );
700 : : EditSelection( const EditPaM& rStart, const EditPaM& rEnd );
701 : :
702 : 444921 : EditPaM& Min() { return aStartPaM; }
703 : 786935 : EditPaM& Max() { return aEndPaM; }
704 : :
705 : 3793 : const EditPaM& Min() const { return aStartPaM; }
706 : 70519 : const EditPaM& Max() const { return aEndPaM; }
707 : :
708 : 199705 : sal_Bool HasRange() const { return aStartPaM != aEndPaM; }
709 : : sal_Bool IsInvalid() const;
710 : : sal_Bool DbgIsBuggy( EditDoc& rDoc );
711 : :
712 : : sal_Bool Adjust( const EditDoc& rNodes );
713 : :
714 : : EditSelection& operator = ( const EditPaM& r );
715 : 0 : sal_Bool operator == ( const EditSelection& r ) const
716 : 0 : { return ( ( aStartPaM == r.aStartPaM ) && ( aEndPaM == r.aEndPaM ) )
717 [ # # # # ]: 0 : ? sal_True : sal_False; }
718 : 0 : sal_Bool operator != ( const EditSelection& r ) const { return !( r == *this ); }
719 : : };
720 : :
721 : : // -------------------------------------------------------------------------
722 : : // class DeletedNodeInfo
723 : : // -------------------------------------------------------------------------
724 : : class DeletedNodeInfo
725 : : {
726 : : private:
727 : : sal_uIntPtr nInvalidAdressPtr;
728 : : sal_uInt16 nInvalidParagraph;
729 : :
730 : : public:
731 : 822 : DeletedNodeInfo( sal_uIntPtr nInvAdr, sal_uInt16 nPos )
732 : 822 : { nInvalidAdressPtr = nInvAdr;
733 : 822 : nInvalidParagraph = nPos; }
734 : :
735 : 0 : sal_uIntPtr GetInvalidAdress() const { return nInvalidAdressPtr; }
736 : 0 : sal_uInt16 GetPosition() const { return nInvalidParagraph; }
737 : : };
738 : :
739 : : // -------------------------------------------------------------------------
740 : : // class EditDoc
741 : : // -------------------------------------------------------------------------
742 : : class EditDoc
743 : : {
744 : : private:
745 : : mutable size_t nLastCache;
746 : : boost::ptr_vector<ContentNode> maContents;
747 : :
748 : : SfxItemPool* pItemPool;
749 : : Link aModifyHdl;
750 : :
751 : : SvxFont aDefFont; //faster than ever from the pool!!
752 : : sal_uInt16 nDefTab;
753 : : bool bIsVertical:1;
754 : : bool bIsFixedCellHeight:1;
755 : :
756 : : bool bOwnerOfPool:1;
757 : : bool bModified:1;
758 : :
759 : : private:
760 : : void ImplDestroyContents();
761 : :
762 : : public:
763 : : EditDoc( SfxItemPool* pItemPool );
764 : : ~EditDoc();
765 : :
766 : 10 : bool IsModified() const { return bModified; }
767 : : void SetModified( bool b );
768 : :
769 : 30636 : void SetModifyHdl( const Link& rLink ) { aModifyHdl = rLink; }
770 : : Link GetModifyHdl() const { return aModifyHdl; }
771 : :
772 : : void CreateDefFont( sal_Bool bUseStyles );
773 : 14101 : const SvxFont& GetDefFont() { return aDefFont; }
774 : :
775 [ + + ]: 30356 : void SetDefTab( sal_uInt16 nTab ) { nDefTab = nTab ? nTab : DEFTAB; }
776 : 0 : sal_uInt16 GetDefTab() const { return nDefTab; }
777 : :
778 : 0 : void SetVertical( bool bVertical ) { bIsVertical = bVertical; }
779 : 3814372 : bool IsVertical() const { return bIsVertical; }
780 : :
781 : 12 : void SetFixedCellHeight( bool bUseFixedCellHeight ) { bIsFixedCellHeight = bUseFixedCellHeight; }
782 : 935194 : bool IsFixedCellHeight() const { return bIsFixedCellHeight; }
783 : :
784 : : EditPaM Clear();
785 : : EditPaM RemoveText();
786 : : EditPaM RemoveChars( EditPaM aPaM, sal_uInt16 nChars );
787 : : EditPaM InsertText( EditPaM aPaM, const XubString& rStr );
788 : : EditPaM InsertParaBreak( EditPaM aPaM, sal_Bool bKeepEndingAttribs );
789 : : EditPaM InsertFeature( EditPaM aPaM, const SfxPoolItem& rItem );
790 : : EditPaM ConnectParagraphs( ContentNode* pLeft, ContentNode* pRight );
791 : :
792 : : String GetText( LineEnd eEnd ) const;
793 : : sal_uLong GetTextLen() const;
794 : :
795 : : XubString GetParaAsString( sal_uInt16 nNode ) const;
796 : : XubString GetParaAsString(const ContentNode* pNode, sal_uInt16 nStartPos = 0, sal_uInt16 nEndPos = 0xFFFF, bool bResolveFields = true) const;
797 : :
798 : : EditPaM GetStartPaM() const;
799 : : EditPaM GetEndPaM() const;
800 : :
801 : 1230446 : SfxItemPool& GetItemPool() { return *pItemPool; }
802 : 15694 : const SfxItemPool& GetItemPool() const { return *pItemPool; }
803 : :
804 : : void RemoveItemsFromPool(const ContentNode& rNode);
805 : :
806 : : void InsertAttrib( const SfxPoolItem& rItem, ContentNode* pNode, sal_uInt16 nStart, sal_uInt16 nEnd );
807 : : void InsertAttrib( ContentNode* pNode, sal_uInt16 nStart, sal_uInt16 nEnd, const SfxPoolItem& rPoolItem );
808 : : void InsertAttribInSelection( ContentNode* pNode, sal_uInt16 nStart, sal_uInt16 nEnd, const SfxPoolItem& rPoolItem );
809 : : sal_Bool RemoveAttribs( ContentNode* pNode, sal_uInt16 nStart, sal_uInt16 nEnd, sal_uInt16 nWhich = 0 );
810 : : sal_Bool RemoveAttribs( ContentNode* pNode, sal_uInt16 nStart, sal_uInt16 nEnd, EditCharAttrib*& rpStarting, EditCharAttrib*& rpEnding, sal_uInt16 nWhich = 0 );
811 : : void FindAttribs( ContentNode* pNode, sal_uInt16 nStartPos, sal_uInt16 nEndPos, SfxItemSet& rCurSet );
812 : :
813 : : size_t GetPos(const ContentNode* pNode) const;
814 : : const ContentNode* GetObject(size_t nPos) const;
815 : : ContentNode* GetObject(size_t nPos);
816 : : size_t Count() const;
817 : : const ContentNode* operator[](size_t nPos) const;
818 : : ContentNode* operator[](size_t nPos);
819 : : void Insert(size_t nPos, ContentNode* p);
820 : : /// deletes
821 : : void Remove(size_t nPos);
822 : : /// does not delete
823 : : void Release(size_t nPos);
824 : :
825 : : static rtl::OUString GetSepStr( LineEnd eEnd );
826 : : };
827 : :
828 : 1682420 : inline EditCharAttrib* GetAttrib(CharAttribList::AttribsType& rAttribs, size_t nAttr)
829 : : {
830 [ + + ]: 1682420 : return (nAttr < rAttribs.size()) ? &rAttribs[nAttr] : NULL;
831 : : }
832 : :
833 : : bool CheckOrderedList(const CharAttribList::AttribsType& rAttribs, bool bStart);
834 : :
835 : : // -------------------------------------------------------------------------
836 : : // class EditEngineItemPool
837 : : // -------------------------------------------------------------------------
838 : : class EditEngineItemPool : public SfxItemPool
839 : : {
840 : : public:
841 : : EditEngineItemPool( sal_Bool bPersistenRefCounts );
842 : : protected:
843 : : virtual ~EditEngineItemPool();
844 : : public:
845 : :
846 : : virtual SvStream& Store( SvStream& rStream ) const;
847 : : };
848 : :
849 : : #endif // _EDITDOC_HXX
850 : :
851 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|