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_EDITDOC_HXX
21 : #define INCLUDED_EDITENG_SOURCE_EDITENG_EDITDOC_HXX
22 :
23 : #include <com/sun/star/i18n/XExtendedInputSequenceChecker.hpp>
24 :
25 : #include "editattr.hxx"
26 : #include "edtspell.hxx"
27 : #include <editeng/svxfont.hxx>
28 : #include <svl/itemset.hxx>
29 : #include <svl/style.hxx>
30 : #include <svl/itempool.hxx>
31 : #include <svl/languageoptions.hxx>
32 : #include <tools/lineend.hxx>
33 :
34 : #include <vector>
35 : #include <deque>
36 :
37 : #include <boost/ptr_container/ptr_vector.hpp>
38 : #include <boost/noncopyable.hpp>
39 : #include <boost/scoped_ptr.hpp>
40 :
41 : class ImpEditEngine;
42 : class SvxTabStop;
43 :
44 :
45 : #define CHARPOSGROW 16
46 : #define DEFTAB 720
47 :
48 : void CreateFont( SvxFont& rFont, const SfxItemSet& rSet, bool bSearchInParent = true, SvtScriptType nScriptType = SvtScriptType::NONE );
49 : sal_uInt16 GetScriptItemId( sal_uInt16 nItemId, SvtScriptType nScriptType );
50 : bool IsScriptItemValid( sal_uInt16 nItemId, short nScriptType );
51 :
52 : EditCharAttrib* MakeCharAttrib( SfxItemPool& rPool, const SfxPoolItem& rAttr, sal_Int32 nS, sal_Int32 nE );
53 :
54 : class ContentNode;
55 : class EditDoc;
56 :
57 : struct EPaM
58 : {
59 : sal_Int32 nPara;
60 : sal_Int32 nIndex;
61 :
62 252 : EPaM() : nPara(0), nIndex(0) {}
63 30212 : EPaM( sal_Int32 nP, sal_Int32 nI ) : nPara(nP), nIndex(nI) {}
64 29960 : EPaM( const EPaM& r) : nPara(r.nPara), nIndex(r.nIndex) {}
65 252 : EPaM& operator = ( const EPaM& r ) { nPara = r.nPara; nIndex = r.nIndex; return *this; }
66 : inline bool operator == ( const EPaM& r ) const;
67 : inline bool operator < ( const EPaM& r ) const;
68 : };
69 :
70 84 : inline bool EPaM::operator < ( const EPaM& r ) const
71 : {
72 84 : return ( nPara < r.nPara ) || ( ( nPara == r.nPara ) && nIndex < r.nIndex );
73 : }
74 :
75 84 : inline bool EPaM::operator == ( const EPaM& r ) const
76 : {
77 84 : return ( nPara == r.nPara ) && ( nIndex == r.nIndex );
78 : }
79 :
80 : struct ScriptTypePosInfo
81 : {
82 : short nScriptType;
83 : sal_Int32 nStartPos;
84 : sal_Int32 nEndPos;
85 :
86 263467 : ScriptTypePosInfo( short _Type, sal_Int32 _Start, sal_Int32 _End )
87 : : nScriptType(_Type)
88 : , nStartPos(_Start)
89 263467 : , nEndPos(_End)
90 : {
91 263467 : }
92 : };
93 :
94 : typedef std::deque< ScriptTypePosInfo > ScriptTypePosInfos;
95 :
96 : struct WritingDirectionInfo
97 : {
98 : sal_uInt8 nType;
99 : sal_Int32 nStartPos;
100 : sal_Int32 nEndPos;
101 :
102 258757 : WritingDirectionInfo( sal_uInt8 _Type, sal_Int32 _Start, sal_Int32 _End )
103 : : nType(_Type)
104 : , nStartPos(_Start)
105 258757 : , nEndPos(_End)
106 : {
107 258757 : }
108 : };
109 :
110 :
111 : typedef std::deque< WritingDirectionInfo > WritingDirectionInfos;
112 :
113 6299 : class ContentAttribsInfo
114 : {
115 : private:
116 : typedef boost::ptr_vector<EditCharAttrib> CharAttribsType;
117 :
118 : SfxItemSet aPrevParaAttribs;
119 : CharAttribsType aPrevCharAttribs;
120 :
121 : public:
122 : ContentAttribsInfo( const SfxItemSet& rParaAttribs );
123 :
124 0 : const SfxItemSet& GetPrevParaAttribs() const { return aPrevParaAttribs; }
125 0 : const CharAttribsType& GetPrevCharAttribs() const { return aPrevCharAttribs; }
126 :
127 : void RemoveAllCharAttribsFromPool(SfxItemPool& rPool) const;
128 : void AppendCharAttrib(EditCharAttrib* pNew);
129 : };
130 :
131 :
132 : // class SvxColorList
133 :
134 : typedef std::vector<Color> SvxColorList;
135 :
136 :
137 : // class ItemList
138 :
139 :
140 0 : class ItemList
141 : {
142 : private:
143 : typedef std::vector<const SfxPoolItem*> DummyItemList;
144 : DummyItemList aItemPool;
145 : sal_Int32 CurrentItem;
146 :
147 : public:
148 : ItemList();
149 : const SfxPoolItem* First();
150 : const SfxPoolItem* Next();
151 0 : sal_Int32 Count() { return aItemPool.size(); };
152 : void Insert( const SfxPoolItem* pItem );
153 0 : void Clear() { aItemPool.clear(); };
154 : };
155 :
156 :
157 : // class ContentAttribs
158 :
159 : class ContentAttribs
160 : {
161 : private:
162 : SfxStyleSheet* pStyle;
163 : SfxItemSet aAttribSet;
164 :
165 : public:
166 : ContentAttribs( SfxItemPool& rItemPool );
167 : ContentAttribs( const ContentAttribs& );
168 : ~ContentAttribs(); // only for larger Tabs
169 :
170 : SvxTabStop FindTabStop( sal_Int32 nCurPos, sal_uInt16 nDefTab );
171 2914541 : SfxItemSet& GetItems() { return aAttribSet; }
172 886400 : const SfxItemSet& GetItems() const { return aAttribSet; }
173 0 : const SfxStyleSheet* GetStyleSheet() const { return pStyle; }
174 1498998 : SfxStyleSheet* GetStyleSheet() { return pStyle; }
175 : void SetStyleSheet( SfxStyleSheet* pS );
176 :
177 : const SfxPoolItem& GetItem( sal_uInt16 nWhich ) const;
178 : bool HasItem( sal_uInt16 nWhich ) const;
179 : };
180 :
181 :
182 : // class CharAttribList
183 :
184 : class CharAttribList
185 : {
186 : public:
187 : typedef boost::ptr_vector<EditCharAttrib> AttribsType;
188 :
189 : private:
190 : AttribsType aAttribs;
191 : SvxFont aDefFont; // faster than ever from the pool!
192 : bool bHasEmptyAttribs;
193 :
194 : CharAttribList( const CharAttribList& ) {;}
195 :
196 : public:
197 : CharAttribList();
198 : ~CharAttribList();
199 :
200 : void DeleteEmptyAttribs( SfxItemPool& rItemPool );
201 : void RemoveItemsFromPool( SfxItemPool* pItemPool );
202 :
203 : const EditCharAttrib* FindAttrib( sal_uInt16 nWhich, sal_Int32 nPos ) const;
204 : EditCharAttrib* FindAttrib( sal_uInt16 nWhich, sal_Int32 nPos );
205 : const EditCharAttrib* FindNextAttrib( sal_uInt16 nWhich, sal_Int32 nFromPos ) const;
206 : const EditCharAttrib* FindEmptyAttrib( sal_uInt16 nWhich, sal_Int32 nPos ) const;
207 : EditCharAttrib* FindEmptyAttrib( sal_uInt16 nWhich, sal_Int32 nPos );
208 : const EditCharAttrib* FindFeature( sal_Int32 nPos ) const;
209 :
210 :
211 : void ResortAttribs();
212 : void OptimizeRanges( SfxItemPool& rItemPool );
213 :
214 : sal_Int32 Count() const;
215 :
216 : void InsertAttrib( EditCharAttrib* pAttrib );
217 :
218 2411609 : SvxFont& GetDefFont() { return aDefFont; }
219 :
220 13441 : bool HasEmptyAttribs() const { return bHasEmptyAttribs; }
221 : void SetHasEmptyAttribs(bool b);
222 : bool HasBoundingAttrib( sal_Int32 nBound ) const;
223 : bool HasAttrib( sal_Int32 nStartPos, sal_Int32 nEndPos ) const;
224 :
225 1948142 : AttribsType& GetAttribs() { return aAttribs;}
226 202795 : const AttribsType& GetAttribs() const { return aAttribs;}
227 :
228 : void Remove(const EditCharAttrib* p);
229 : void Remove(sal_Int32 nPos);
230 : void Release(const EditCharAttrib* p);
231 :
232 : #if OSL_DEBUG_LEVEL > 0
233 : static void DbgCheckAttribs(CharAttribList const& rAttribs);
234 : #endif
235 : };
236 :
237 :
238 : // class ContentNode
239 :
240 : class ContentNode : boost::noncopyable
241 : {
242 : private:
243 : OUString maString;
244 : ContentAttribs aContentAttribs;
245 : CharAttribList aCharAttribList;
246 : boost::scoped_ptr<WrongList> mpWrongList;
247 :
248 : void UnExpandPosition( sal_Int32 &rStartPos, bool bBiasStart );
249 :
250 : public:
251 : ContentNode( SfxItemPool& rItemPool );
252 : ContentNode( const OUString& rStr, const ContentAttribs& rContentAttribs );
253 : ~ContentNode();
254 :
255 7560235 : ContentAttribs& GetContentAttribs() { return aContentAttribs; }
256 2968744 : const ContentAttribs& GetContentAttribs() const { return aContentAttribs; }
257 5215477 : CharAttribList& GetCharAttribs() { return aCharAttribList; }
258 1161696 : const CharAttribList& GetCharAttribs() const { return aCharAttribList; }
259 :
260 : void ExpandAttribs( sal_Int32 nIndex, sal_Int32 nNewChars, SfxItemPool& rItemPool );
261 : void CollapsAttribs( sal_Int32 nIndex, sal_Int32 nDelChars, SfxItemPool& rItemPool );
262 : void AppendAttribs( ContentNode* pNextNode );
263 : void CopyAndCutAttribs( ContentNode* pPrevNode, SfxItemPool& rPool, bool bKeepEndingAttribs );
264 :
265 : void SetStyleSheet( SfxStyleSheet* pS, bool bRecalcFont = true );
266 : void SetStyleSheet( SfxStyleSheet* pS, const SvxFont& rFontFromStyle );
267 845781 : SfxStyleSheet* GetStyleSheet() { return aContentAttribs.GetStyleSheet(); }
268 : const SfxStyleSheet* GetStyleSheet() const { return aContentAttribs.GetStyleSheet(); }
269 :
270 : void CreateDefFont();
271 :
272 : void EnsureWrongList();
273 : WrongList* GetWrongList();
274 : const WrongList* GetWrongList() const;
275 : void SetWrongList( WrongList* p );
276 :
277 : void CreateWrongList();
278 : void DestroyWrongList();
279 :
280 : bool IsFeature( sal_Int32 nPos ) const;
281 :
282 : sal_Int32 Len() const;
283 659261 : const OUString& GetString() const { return maString;}
284 :
285 : /// return length including expanded fields
286 : sal_uLong GetExpandedLen() const;
287 : /// return content including expanded fields
288 : OUString GetExpandedText(sal_Int32 nStartPos = 0, sal_Int32 nEndPos = -1, bool bResolveFields = true) const;
289 : /// re-write offsets in the expanded text to string offsets
290 : void UnExpandPositions( sal_Int32 &rStartPos, sal_Int32 &rEndPos );
291 :
292 : void SetChar(sal_Int32 nPos, sal_Unicode c);
293 : void Insert(const OUString& rStr, sal_Int32 nPos);
294 : void Append(const OUString& rStr);
295 : void Erase(sal_Int32 nPos);
296 : void Erase(sal_Int32 nPos, sal_Int32 nCount);
297 : OUString Copy(sal_Int32 nPos) const;
298 : OUString Copy(sal_Int32 nPos, sal_Int32 nCount) const;
299 : sal_Unicode GetChar(sal_Int32 nPos) const;
300 : };
301 :
302 :
303 : // class EditPaM
304 :
305 : class EditPaM
306 : {
307 : private:
308 : ContentNode* pNode;
309 : sal_Int32 nIndex;
310 :
311 : public:
312 : EditPaM();
313 : EditPaM(const EditPaM& r);
314 : EditPaM(ContentNode* p, sal_Int32 n);
315 :
316 2812247 : const ContentNode* GetNode() const { return pNode;}
317 4223810 : ContentNode* GetNode() { return pNode;}
318 : void SetNode(ContentNode* p);
319 :
320 4399392 : sal_Int32 GetIndex() const { return nIndex; }
321 439688 : void SetIndex( sal_Int32 n ) { nIndex = n; }
322 :
323 : bool DbgIsBuggy( EditDoc& rDoc );
324 :
325 : EditPaM& operator = ( const EditPaM& rPaM );
326 : friend bool operator == ( const EditPaM& r1, const EditPaM& r2 );
327 : friend bool operator != ( const EditPaM& r1, const EditPaM& r2 );
328 : bool operator !() const { return !pNode && !nIndex; }
329 : };
330 :
331 : enum class PortionKind
332 : {
333 : TEXT = 0,
334 : TAB = 1,
335 : LINEBREAK = 2,
336 : FIELD = 3,
337 : HYPHENATOR = 4
338 : };
339 :
340 : #define DELMODE_SIMPLE 0
341 : #define DELMODE_RESTOFWORD 1
342 : #define DELMODE_RESTOFCONTENT 2
343 :
344 : #define CHAR_NORMAL 0x00
345 : #define CHAR_KANA 0x01
346 : #define CHAR_PUNCTUATIONLEFT 0x02
347 : #define CHAR_PUNCTUATIONRIGHT 0x04
348 :
349 :
350 : // struct ExtraPortionInfos
351 :
352 : struct ExtraPortionInfo
353 : {
354 : long nOrgWidth;
355 : long nWidthFullCompression;
356 :
357 : long nPortionOffsetX;
358 :
359 : sal_uInt16 nMaxCompression100thPercent;
360 :
361 : sal_uInt8 nAsianCompressionTypes;
362 : bool bFirstCharIsRightPunktuation;
363 : bool bCompressed;
364 :
365 : long* pOrgDXArray;
366 : ::std::vector< sal_Int32 > lineBreaksList;
367 :
368 :
369 : ExtraPortionInfo();
370 : ~ExtraPortionInfo();
371 :
372 : void SaveOrgDXArray( const long* pDXArray, sal_Int32 nLen );
373 : };
374 :
375 :
376 :
377 : // class TextPortion
378 :
379 : class TextPortion
380 : {
381 : private:
382 : ExtraPortionInfo* pExtraInfos;
383 : sal_Int32 nLen;
384 : Size aOutSz;
385 : PortionKind nKind;
386 : sal_uInt8 nRightToLeft;
387 : sal_Unicode nExtraValue;
388 :
389 :
390 : TextPortion()
391 : : pExtraInfos( NULL )
392 : , nLen( 0 )
393 : , aOutSz()
394 : , nKind( PortionKind::TEXT )
395 : , nRightToLeft( sal_False )
396 : , nExtraValue( 0 )
397 : {
398 : }
399 :
400 : public:
401 474742 : TextPortion( sal_Int32 nL )
402 : : pExtraInfos( NULL )
403 : , nLen( nL )
404 : , aOutSz( -1, -1 )
405 : , nKind( PortionKind::TEXT )
406 : , nRightToLeft( sal_False )
407 474742 : , nExtraValue( 0 )
408 : {
409 474742 : }
410 :
411 0 : TextPortion( const TextPortion& r )
412 : : pExtraInfos( NULL )
413 : , nLen( r.nLen )
414 : , aOutSz( r.aOutSz )
415 : , nKind( r.nKind )
416 : , nRightToLeft( r.nRightToLeft )
417 0 : , nExtraValue( r.nExtraValue )
418 : {
419 0 : }
420 :
421 :
422 2700290 : sal_Int32 GetLen() const { return nLen; }
423 80222 : void SetLen( sal_Int32 nL ) { nLen = nL; }
424 :
425 1408889 : Size& GetSize() { return aOutSz; }
426 136112 : const Size& GetSize() const { return aOutSz; }
427 :
428 571954 : PortionKind& GetKind() { return nKind; }
429 499872 : PortionKind GetKind() const { return nKind; }
430 :
431 224035 : void SetRightToLeft( sal_uInt8 b ) { nRightToLeft = b; }
432 52702 : sal_uInt8 GetRightToLeft() const { return nRightToLeft; }
433 31512 : bool IsRightToLeft() const { return (nRightToLeft&1); }
434 :
435 0 : sal_Unicode GetExtraValue() const { return nExtraValue; }
436 12 : void SetExtraValue( sal_Unicode n ) { nExtraValue = n; }
437 :
438 0 : bool HasValidSize() const { return aOutSz.Width() != (-1); }
439 :
440 84757 : ExtraPortionInfo* GetExtraInfos() const { return pExtraInfos; }
441 0 : void SetExtraInfos( ExtraPortionInfo* p ) { delete pExtraInfos; pExtraInfos = p; }
442 : };
443 :
444 :
445 : // class TextPortionList
446 :
447 : class TextPortionList
448 : {
449 : typedef boost::ptr_vector<TextPortion> PortionsType;
450 : PortionsType maPortions;
451 :
452 : public:
453 : TextPortionList();
454 : ~TextPortionList();
455 :
456 : void Reset();
457 : sal_Int32 FindPortion(
458 : sal_Int32 nCharPos, sal_Int32& rPortionStart, bool bPreferStartingPortion = false) const;
459 : sal_Int32 GetStartPos(sal_Int32 nPortion);
460 : void DeleteFromPortion(sal_Int32 nDelFrom);
461 : sal_Int32 Count() const;
462 : const TextPortion* operator[](sal_Int32 nPos) const;
463 : TextPortion* operator[](sal_Int32 nPos);
464 :
465 : void Append(TextPortion* p);
466 : void Insert(sal_Int32 nPos, TextPortion* p);
467 : void Remove(sal_Int32 nPos);
468 : sal_Int32 GetPos(const TextPortion* p) const;
469 : };
470 :
471 : class ParaPortion;
472 :
473 :
474 : // class EditLine
475 :
476 : class EditLine
477 : {
478 : public:
479 : typedef std::vector<long> CharPosArrayType;
480 :
481 : private:
482 : CharPosArrayType aPositions;
483 : long nTxtWidth;
484 : sal_uInt16 nStartPosX;
485 : sal_Int32 nStart; // could be replaced by nStartPortion
486 : sal_Int32 nEnd; // could be replaced by nEndPortion
487 : sal_Int32 nStartPortion;
488 : sal_Int32 nEndPortion;
489 : sal_uInt16 nHeight; // Total height of the line
490 : sal_uInt16 nTxtHeight; // Pure Text height
491 : sal_uInt16 nCrsrHeight; // For contour flow high lines => cursor is large.
492 : sal_uInt16 nMaxAscent;
493 : bool bHangingPunctuation:1;
494 : bool bInvalid:1; // for skillful formatting
495 :
496 : public:
497 : EditLine();
498 : EditLine( const EditLine& );
499 : ~EditLine();
500 :
501 8 : bool IsIn( sal_Int32 nIndex ) const
502 8 : { return ( (nIndex >= nStart ) && ( nIndex < nEnd ) ); }
503 :
504 394 : bool IsIn( sal_Int32 nIndex, bool bInclEnd ) const
505 394 : { return ( ( nIndex >= nStart ) && ( bInclEnd ? ( nIndex <= nEnd ) : ( nIndex < nEnd ) ) ); }
506 :
507 324075 : void SetStart( sal_Int32 n ) { nStart = n; }
508 55648 : sal_Int32 GetStart() const { return nStart; }
509 1681040 : sal_Int32& GetStart() { return nStart; }
510 :
511 548905 : void SetEnd( sal_Int32 n ) { nEnd = n; }
512 2806 : sal_Int32 GetEnd() const { return nEnd; }
513 370646 : sal_Int32& GetEnd() { return nEnd; }
514 :
515 80667 : void SetStartPortion( sal_Int32 n ) { nStartPortion = n; }
516 54239 : sal_Int32 GetStartPortion() const { return nStartPortion; }
517 569167 : sal_Int32& GetStartPortion() { return nStartPortion; }
518 :
519 305497 : void SetEndPortion( sal_Int32 n ) { nEndPortion = n; }
520 74750 : sal_Int32 GetEndPortion() const { return nEndPortion; }
521 894991 : sal_Int32& GetEndPortion() { return nEndPortion; }
522 :
523 : void SetHeight( sal_uInt16 nH, sal_uInt16 nTxtH = 0, sal_uInt16 nCrsrH = 0 );
524 1670726 : sal_uInt16 GetHeight() const { return nHeight; }
525 5500 : sal_uInt16 GetTxtHeight() const { return nTxtHeight; }
526 : sal_uInt16 GetCrsrHeight() const { return nCrsrHeight; }
527 :
528 224846 : void SetTextWidth( long n ) { nTxtWidth = n; }
529 157 : long GetTextWidth() const { return nTxtWidth; }
530 :
531 470550 : void SetMaxAscent( sal_uInt16 n ) { nMaxAscent = n; }
532 32303 : sal_uInt16 GetMaxAscent() const { return nMaxAscent; }
533 :
534 89546 : void SetHangingPunctuation( bool b ) { bHangingPunctuation = b; }
535 224710 : bool IsHangingPunctuation() const { return bHangingPunctuation; }
536 :
537 225275 : sal_Int32 GetLen() const { return nEnd - nStart; }
538 :
539 55700 : sal_uInt16 GetStartPosX() const { return nStartPosX; }
540 : void SetStartPosX( long start );
541 : Size CalcTextSize( ParaPortion& rParaPortion );
542 :
543 375861 : bool IsInvalid() const { return bInvalid; }
544 453756 : bool IsValid() const { return !bInvalid; }
545 224710 : void SetInvalid() { bInvalid = true; }
546 140739 : void SetValid() { bInvalid = false; }
547 :
548 596 : bool IsEmpty() const { return nEnd <= nStart; }
549 :
550 952037 : CharPosArrayType& GetCharPosArray() { return aPositions;}
551 47470 : const CharPosArrayType& GetCharPosArray() const { return aPositions;}
552 :
553 : EditLine* Clone() const;
554 :
555 : EditLine& operator = ( const EditLine& rLine );
556 : friend bool operator == ( const EditLine& r1, const EditLine& r2 );
557 : friend bool operator != ( const EditLine& r1, const EditLine& r2 );
558 : };
559 :
560 :
561 :
562 : // class LineList
563 :
564 : class EditLineList
565 : {
566 : typedef boost::ptr_vector<EditLine> LinesType;
567 : LinesType maLines;
568 :
569 : public:
570 : EditLineList();
571 : ~EditLineList();
572 :
573 : void Reset();
574 : void DeleteFromLine(sal_Int32 nDelFrom);
575 : sal_Int32 FindLine(sal_Int32 nChar, bool bInclEnd);
576 : sal_Int32 Count() const;
577 : const EditLine* operator[](sal_Int32 nPos) const;
578 : EditLine* operator[](sal_Int32 nPos);
579 :
580 : void Append(EditLine* p);
581 : void Insert(sal_Int32 nPos, EditLine* p);
582 : };
583 :
584 :
585 : // class ParaPortion
586 :
587 : class ParaPortion
588 : {
589 : friend class ImpEditEngine; // to adjust the height
590 : private:
591 : EditLineList aLineList;
592 : TextPortionList aTextPortionList;
593 : ContentNode* pNode;
594 : long nHeight;
595 :
596 : ScriptTypePosInfos aScriptInfos;
597 : WritingDirectionInfos aWritingDirectionInfos;
598 :
599 : sal_Int32 nInvalidPosStart;
600 : sal_Int32 nFirstLineOffset; // For Writer-LineSpacing-Interpretation
601 : sal_uInt16 nBulletX;
602 : sal_Int32 nInvalidDiff;
603 :
604 : bool bInvalid : 1;
605 : bool bSimple : 1; // only linear Tap
606 : bool bVisible : 1; // Belongs to the node!
607 : bool bForceRepaint : 1;
608 :
609 : ParaPortion( const ParaPortion& ) SAL_DELETED_FUNCTION;
610 :
611 : public:
612 : ParaPortion( ContentNode* pNode );
613 : ~ParaPortion();
614 :
615 : sal_Int32 GetLineNumber( sal_Int32 nIndex ) const;
616 :
617 5894133 : EditLineList& GetLines() { return aLineList; }
618 53896 : const EditLineList& GetLines() const { return aLineList; }
619 :
620 454276 : bool IsInvalid() const { return bInvalid; }
621 512814 : bool IsSimpleInvalid() const { return bSimple; }
622 387460 : void SetValid() { bInvalid = false; bSimple = true;}
623 :
624 800889 : bool MustRepaint() const { return bForceRepaint; }
625 325367 : void SetMustRepaint( bool bRP ) { bForceRepaint = bRP; }
626 :
627 489948 : sal_uInt16 GetBulletX() const { return nBulletX; }
628 387460 : void SetBulletX( sal_uInt16 n ) { nBulletX = n; }
629 :
630 : void MarkInvalid( sal_Int32 nStart, sal_Int32 nDiff);
631 : void MarkSelectionInvalid( sal_Int32 nStart, sal_Int32 nEnd );
632 :
633 : void SetVisible( bool bVisible );
634 1296951 : bool IsVisible() const { return bVisible; }
635 :
636 414466 : bool IsEmpty() { return GetTextPortions().Count() == 1 && GetTextPortions()[0]->GetLen() == 0; }
637 :
638 1639129 : long GetHeight() const { return ( bVisible ? nHeight : 0 ); }
639 402338 : sal_Int32 GetFirstLineOffset() const { return ( bVisible ? nFirstLineOffset : 0 ); }
640 0 : void ResetHeight() { nHeight = 0; nFirstLineOffset = 0; }
641 :
642 6298560 : ContentNode* GetNode() const { return pNode; }
643 3741265 : TextPortionList& GetTextPortions() { return aTextPortionList; }
644 204013 : const TextPortionList& GetTextPortions() const { return aTextPortionList; }
645 :
646 144052 : sal_Int32 GetInvalidPosStart() const { return nInvalidPosStart; }
647 144052 : short GetInvalidDiff() const { return nInvalidDiff; }
648 :
649 : void CorrectValuesBehindLastFormattedLine( sal_Int32 nLastFormattedLine );
650 : #if OSL_DEBUG_LEVEL > 0
651 : static bool DbgCheckTextPortions(ParaPortion const&);
652 : #endif
653 : };
654 :
655 :
656 : // class ParaPortionList
657 :
658 : class ParaPortionList
659 : {
660 : mutable sal_Int32 nLastCache;
661 : boost::ptr_vector<ParaPortion> maPortions;
662 : public:
663 : ParaPortionList();
664 : ~ParaPortionList();
665 :
666 : void Reset();
667 : long GetYOffset(const ParaPortion* pPPortion) const;
668 : sal_Int32 FindParagraph(long nYOffset) const;
669 :
670 : const ParaPortion* SafeGetObject(sal_Int32 nPos) const;
671 : ParaPortion* SafeGetObject(sal_Int32 nPos);
672 :
673 : sal_Int32 GetPos(const ParaPortion* p) const;
674 : ParaPortion* operator[](sal_Int32 nPos);
675 : const ParaPortion* operator[](sal_Int32 nPos) const;
676 :
677 : ParaPortion* Release(sal_Int32 nPos);
678 : void Remove(sal_Int32 nPos);
679 : void Insert(sal_Int32 nPos, ParaPortion* p);
680 : void Append(ParaPortion* p);
681 : sal_Int32 Count() const;
682 :
683 : #if OSL_DEBUG_LEVEL > 0
684 : // temporary:
685 : static void DbgCheck(ParaPortionList const&, EditDoc const& rDoc);
686 : #endif
687 : };
688 :
689 :
690 : // class EditSelection
691 :
692 316175 : class EditSelection
693 : {
694 : private:
695 : EditPaM aStartPaM;
696 : EditPaM aEndPaM;
697 :
698 : public:
699 : EditSelection(); // No constructor and destructor
700 : // are automatically executed correctly!
701 : EditSelection( const EditPaM& rStartAndAnd );
702 : EditSelection( const EditPaM& rStart, const EditPaM& rEnd );
703 :
704 854061 : EditPaM& Min() { return aStartPaM; }
705 1416828 : EditPaM& Max() { return aEndPaM; }
706 :
707 12254 : const EditPaM& Min() const { return aStartPaM; }
708 103509 : const EditPaM& Max() const { return aEndPaM; }
709 :
710 310072 : bool HasRange() const { return aStartPaM != aEndPaM; }
711 : bool IsInvalid() const { return !aStartPaM || !aEndPaM; }
712 : bool DbgIsBuggy( EditDoc& rDoc );
713 :
714 : void Adjust( const EditDoc& rNodes );
715 :
716 : EditSelection& operator = ( const EditPaM& r );
717 9 : bool operator == ( const EditSelection& r ) const
718 9 : { return ( aStartPaM == r.aStartPaM ) && ( aEndPaM == r.aEndPaM ); }
719 2 : bool operator != ( const EditSelection& r ) const { return !( r == *this ); }
720 : };
721 :
722 :
723 : // class DeletedNodeInfo
724 :
725 : class DeletedNodeInfo
726 : {
727 : private:
728 : ContentNode* mpInvalidNode;
729 : sal_Int32 nInvalidParagraph;
730 :
731 : public:
732 2445 : DeletedNodeInfo( ContentNode* pNode, sal_Int32 nPos )
733 : : mpInvalidNode(pNode)
734 2445 : , nInvalidParagraph(nPos)
735 : {
736 2445 : }
737 :
738 0 : ContentNode* GetNode() const { return mpInvalidNode; }
739 0 : sal_Int32 GetPosition() const { return nInvalidParagraph; }
740 : };
741 :
742 :
743 : // class EditDoc
744 :
745 : class EditDoc
746 : {
747 : private:
748 : mutable sal_Int32 nLastCache;
749 : boost::ptr_vector<ContentNode> maContents;
750 :
751 : SfxItemPool* pItemPool;
752 : Link<> aModifyHdl;
753 :
754 : SvxFont aDefFont; //faster than ever from the pool!!
755 : sal_uInt16 nDefTab;
756 : bool bIsVertical:1;
757 : bool bIsFixedCellHeight:1;
758 :
759 : bool bOwnerOfPool:1;
760 : bool bModified:1;
761 :
762 : private:
763 : void ImplDestroyContents();
764 :
765 : public:
766 : EditDoc( SfxItemPool* pItemPool );
767 : ~EditDoc();
768 :
769 : void ClearSpellErrors();
770 :
771 43 : bool IsModified() const { return bModified; }
772 : void SetModified( bool b );
773 :
774 42102 : void SetModifyHdl( const Link<>& rLink ) { aModifyHdl = rLink; }
775 : Link<> GetModifyHdl() const { return aModifyHdl; }
776 :
777 : void CreateDefFont( bool bUseStyles );
778 22160 : const SvxFont& GetDefFont() { return aDefFont; }
779 :
780 39947 : void SetDefTab( sal_uInt16 nTab ) { nDefTab = nTab ? nTab : DEFTAB; }
781 12 : sal_uInt16 GetDefTab() const { return nDefTab; }
782 :
783 4 : void SetVertical( bool bVertical ) { bIsVertical = bVertical; }
784 4799938 : bool IsVertical() const { return bIsVertical; }
785 :
786 49 : void SetFixedCellHeight( bool bUseFixedCellHeight ) { bIsFixedCellHeight = bUseFixedCellHeight; }
787 1065458 : bool IsFixedCellHeight() const { return bIsFixedCellHeight; }
788 :
789 : EditPaM Clear();
790 : EditPaM RemoveText();
791 : EditPaM RemoveChars( EditPaM aPaM, sal_Int32 nChars );
792 : EditPaM InsertText( EditPaM aPaM, const OUString& rStr );
793 : EditPaM InsertParaBreak( EditPaM aPaM, bool bKeepEndingAttribs );
794 : EditPaM InsertFeature( EditPaM aPaM, const SfxPoolItem& rItem );
795 : EditPaM ConnectParagraphs( ContentNode* pLeft, ContentNode* pRight );
796 :
797 : OUString GetText( LineEnd eEnd ) const;
798 : sal_uLong GetTextLen() const;
799 :
800 : OUString GetParaAsString( sal_Int32 nNode ) const;
801 : static OUString GetParaAsString(const ContentNode* pNode, sal_Int32 nStartPos = 0, sal_Int32 nEndPos = -1, bool bResolveFields = true);
802 :
803 : EditPaM GetStartPaM() const;
804 : EditPaM GetEndPaM() const;
805 :
806 1845743 : SfxItemPool& GetItemPool() { return *pItemPool; }
807 26701 : const SfxItemPool& GetItemPool() const { return *pItemPool; }
808 :
809 : void RemoveItemsFromPool(const ContentNode& rNode);
810 :
811 : void InsertAttrib( const SfxPoolItem& rItem, ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEnd );
812 : void InsertAttrib( ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEnd, const SfxPoolItem& rPoolItem );
813 : void InsertAttribInSelection( ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEnd, const SfxPoolItem& rPoolItem );
814 : bool RemoveAttribs( ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEnd, sal_uInt16 nWhich = 0 );
815 : bool RemoveAttribs( ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEnd, EditCharAttrib*& rpStarting, EditCharAttrib*& rpEnding, sal_uInt16 nWhich = 0 );
816 : static void FindAttribs( ContentNode* pNode, sal_Int32 nStartPos, sal_Int32 nEndPos, SfxItemSet& rCurSet );
817 :
818 : sal_Int32 GetPos(const ContentNode* pNode) const;
819 : const ContentNode* GetObject(sal_Int32 nPos) const;
820 : ContentNode* GetObject(sal_Int32 nPos);
821 : sal_Int32 Count() const;
822 : const ContentNode* operator[](sal_Int32 nPos) const;
823 : ContentNode* operator[](sal_Int32 nPos);
824 : void Insert(sal_Int32 nPos, ContentNode* p);
825 : /// deletes
826 : void Remove(sal_Int32 nPos);
827 : /// does not delete
828 : void Release(sal_Int32 nPos);
829 :
830 : static OUString GetSepStr( LineEnd eEnd );
831 : };
832 :
833 2716664 : inline EditCharAttrib* GetAttrib(CharAttribList::AttribsType& rAttribs, sal_Int32 nAttr)
834 : {
835 2716664 : return (nAttr < (sal_Int32)rAttribs.size()) ? &rAttribs[nAttr] : NULL;
836 : }
837 :
838 : void CheckOrderedList(const CharAttribList::AttribsType& rAttribs, bool bStart);
839 :
840 :
841 : // class EditEngineItemPool
842 :
843 : class EditEngineItemPool : public SfxItemPool
844 : {
845 : public:
846 : EditEngineItemPool( bool bPersistenRefCounts );
847 : protected:
848 : virtual ~EditEngineItemPool();
849 : public:
850 :
851 : virtual SvStream& Store( SvStream& rStream ) const SAL_OVERRIDE;
852 : };
853 :
854 : #endif // INCLUDED_EDITENG_SOURCE_EDITENG_EDITDOC_HXX
855 :
856 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|