Update ooo320-m1
[ooovba.git] / svx / source / editeng / editdoc.hxx
blob90efe213b6d428c48739899b2653bcef939bf088
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: editdoc.hxx,v $
10 * $Revision: 1.29 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _EDITDOC_HXX
32 #define _EDITDOC_HXX
34 #ifndef _COM_SUN_STAR_I18N_XEXTENDEDINPUTSEQUENCECHECKER_HDL_
35 #include <com/sun/star/i18n/XExtendedInputSequenceChecker.hpp>
36 #endif
38 #include <editattr.hxx>
39 #include <edtspell.hxx>
40 #include <svx/svxfont.hxx>
41 #include <svtools/itemset.hxx>
42 #include <svtools/style.hxx>
43 #include <svtools/itempool.hxx>
44 #include <tools/table.hxx>
46 class ImpEditEngine;
47 class SvxTabStop;
48 class SvtCTLOptions;
50 DBG_NAMEEX( EE_TextPortion )
52 #define CHARPOSGROW 16
53 #define DEFTAB 720
55 void CreateFont( SvxFont& rFont, const SfxItemSet& rSet, bool bSearchInParent = true, short nScriptType = 0 );
56 USHORT GetScriptItemId( USHORT nItemId, short nScriptType );
57 BOOL IsScriptItemValid( USHORT nItemId, short nScriptType );
59 EditCharAttrib* MakeCharAttrib( SfxItemPool& rPool, const SfxPoolItem& rAttr, USHORT nS, USHORT nE );
61 class ContentNode;
62 class EditDoc;
64 struct EPaM
66 USHORT nPara;
67 USHORT nIndex;
69 EPaM() { nPara = 0; nIndex = 0; }
70 EPaM( USHORT nP, USHORT nI ) { nPara = nP; nIndex = nI; }
71 EPaM( const EPaM& r) { nPara = r.nPara; nIndex = r.nIndex; }
72 EPaM& operator = ( const EPaM& r ) { nPara = r.nPara; nIndex = r.nIndex; return *this; }
73 inline BOOL operator == ( const EPaM& r ) const;
74 inline BOOL operator < ( const EPaM& r ) const;
77 inline BOOL EPaM::operator < ( const EPaM& r ) const
79 return ( ( nPara < r.nPara ) ||
80 ( ( nPara == r.nPara ) && nIndex < r.nIndex ) ) ? TRUE : FALSE;
83 inline BOOL EPaM::operator == ( const EPaM& r ) const
85 return ( ( nPara == r.nPara ) && ( nIndex == r.nIndex ) ) ? TRUE : FALSE;
88 struct ScriptTypePosInfo
90 short nScriptType;
91 USHORT nStartPos;
92 USHORT nEndPos;
94 ScriptTypePosInfo( short _Type, USHORT _Start, USHORT _End )
96 nScriptType = _Type;
97 nStartPos = _Start;
98 nEndPos = _End;
102 SV_DECL_VARARR( ScriptTypePosInfos, ScriptTypePosInfo, 0, 4 )
104 struct WritingDirectionInfo
106 BYTE nType;
107 USHORT nStartPos;
108 USHORT nEndPos;
110 WritingDirectionInfo( BYTE _Type, USHORT _Start, USHORT _End )
112 nType = _Type;
113 nStartPos = _Start;
114 nEndPos = _End;
118 SV_DECL_VARARR( WritingDirectionInfos, WritingDirectionInfo, 0, 4 )
120 typedef EditCharAttrib* EditCharAttribPtr;
121 SV_DECL_PTRARR( CharAttribArray, EditCharAttribPtr, 0, 4 )
123 class ContentAttribsInfo
125 private:
126 SfxItemSet aPrevParaAttribs;
127 CharAttribArray aPrevCharAttribs;
129 public:
130 ContentAttribsInfo( const SfxItemSet& rParaAttribs );
132 const SfxItemSet& GetPrevParaAttribs() const { return aPrevParaAttribs; }
133 const CharAttribArray& GetPrevCharAttribs() const { return aPrevCharAttribs; }
135 CharAttribArray& GetPrevCharAttribs() { return aPrevCharAttribs; }
138 typedef ContentAttribsInfo* ContentAttribsInfoPtr;
139 SV_DECL_PTRARR( ContentInfoArray, ContentAttribsInfoPtr, 1, 1 )
141 // ----------------------------------------------------------------------
142 // class SvxFontTable
143 // ----------------------------------------------------------------------
144 DECLARE_TABLE( DummyFontTable, SvxFontItem* )
145 class SvxFontTable : public DummyFontTable
147 public:
148 SvxFontTable();
149 ~SvxFontTable();
151 ULONG GetId( const SvxFontItem& rFont );
154 // ----------------------------------------------------------------------
155 // class SvxColorList
156 // ----------------------------------------------------------------------
157 typedef ContentNode* ContentNodePtr;
158 DECLARE_LIST( DummyColorList, SvxColorItem* )
159 class SvxColorList : public DummyColorList
161 public:
162 SvxColorList();
163 ~SvxColorList();
165 ULONG GetId( const SvxColorItem& rColor );
168 // ----------------------------------------------------------------------
169 // class ItemList
170 // ----------------------------------------------------------------------
171 typedef const SfxPoolItem* ConstPoolItemPtr;
172 DECLARE_LIST( DummyItemList, ConstPoolItemPtr )
173 class ItemList : public DummyItemList
175 public:
176 const SfxPoolItem* FindAttrib( USHORT nWhich );
179 // -------------------------------------------------------------------------
180 // class ContentAttribs
181 // -------------------------------------------------------------------------
182 class ContentAttribs
184 private:
185 SfxStyleSheet* pStyle;
186 SfxItemSet aAttribSet;
188 public:
189 ContentAttribs( SfxItemPool& rItemPool );
190 ContentAttribs( const ContentAttribs& );
191 ~ContentAttribs(); // erst bei umfangreicheren Tabs
193 SvxTabStop FindTabStop( long nCurPos, USHORT nDefTab );
194 SfxItemSet& GetItems() { return aAttribSet; }
195 SfxStyleSheet* GetStyleSheet() const { return pStyle; }
196 void SetStyleSheet( SfxStyleSheet* pS );
198 const SfxPoolItem& GetItem( USHORT nWhich );
199 BOOL HasItem( USHORT nWhich );
202 // -------------------------------------------------------------------------
203 // class CharAttribList
204 // -------------------------------------------------------------------------
205 class CharAttribList
207 private:
208 CharAttribArray aAttribs;
209 SvxFont aDefFont; // schneller, als jedesmal vom Pool!
210 BOOL bHasEmptyAttribs;
212 CharAttribList( const CharAttribList& ) {;}
214 public:
215 CharAttribList();
216 ~CharAttribList();
218 void DeleteEmptyAttribs( SfxItemPool& rItemPool );
219 void RemoveItemsFromPool( SfxItemPool* pItemPool );
221 EditCharAttrib* FindAttrib( USHORT nWhich, USHORT nPos );
222 EditCharAttrib* FindNextAttrib( USHORT nWhich, USHORT nFromPos ) const;
223 EditCharAttrib* FindEmptyAttrib( USHORT nWhich, USHORT nPos );
224 EditCharAttrib* FindFeature( USHORT nPos ) const;
227 void ResortAttribs();
228 void OptimizeRanges( SfxItemPool& rItemPool );
230 USHORT Count() { return aAttribs.Count(); }
231 void Clear() { aAttribs.Remove( 0, aAttribs.Count()); }
232 void InsertAttrib( EditCharAttrib* pAttrib );
234 SvxFont& GetDefFont() { return aDefFont; }
236 BOOL HasEmptyAttribs() const { return bHasEmptyAttribs; }
237 BOOL& HasEmptyAttribs() { return bHasEmptyAttribs; }
238 BOOL HasBoundingAttrib( USHORT nBound );
239 BOOL HasAttrib( USHORT nWhich ) const;
240 BOOL HasAttrib( USHORT nStartPos, USHORT nEndPos ) const;
242 CharAttribArray& GetAttribs() { return aAttribs; }
243 const CharAttribArray& GetAttribs() const { return aAttribs; }
245 // Debug:
246 BOOL DbgCheckAttribs();
249 // -------------------------------------------------------------------------
250 // class ContentNode
251 // -------------------------------------------------------------------------
252 class ContentNode : public XubString
254 private:
255 ContentAttribs aContentAttribs;
256 CharAttribList aCharAttribList;
257 WrongList* pWrongList;
259 public:
260 ContentNode( SfxItemPool& rItemPool );
261 ContentNode( const XubString& rStr, const ContentAttribs& rContentAttribs );
262 ~ContentNode();
264 ContentAttribs& GetContentAttribs() { return aContentAttribs; }
265 CharAttribList& GetCharAttribs() { return aCharAttribList; }
267 void ExpandAttribs( USHORT nIndex, USHORT nNewChars, SfxItemPool& rItemPool );
268 void CollapsAttribs( USHORT nIndex, USHORT nDelChars, SfxItemPool& rItemPool );
269 void AppendAttribs( ContentNode* pNextNode );
270 void CopyAndCutAttribs( ContentNode* pPrevNode, SfxItemPool& rPool, BOOL bKeepEndingAttribs );
272 void SetStyleSheet( SfxStyleSheet* pS, BOOL bRecalcFont = TRUE );
273 void SetStyleSheet( SfxStyleSheet* pS, const SvxFont& rFontFromStyle );
274 SfxStyleSheet* GetStyleSheet() { return aContentAttribs.GetStyleSheet(); }
276 void CreateDefFont();
278 WrongList* GetWrongList() { return pWrongList; }
279 void SetWrongList( WrongList* p );
281 void CreateWrongList();
282 void DestroyWrongList();
284 BOOL IsFeature( USHORT nPos ) const { return ( GetChar( nPos ) == CH_FEATURE ); }
287 typedef ContentNode* ContentNodePtr;
288 SV_DECL_PTRARR( DummyContentList, ContentNodePtr, 0, 4 )
290 class ContentList : public DummyContentList
292 USHORT nLastCache;
293 public:
294 ContentList() : DummyContentList( 0, 4 ), nLastCache(0) {}
295 USHORT GetPos( const ContentNodePtr &rPtr ) const;
298 // -------------------------------------------------------------------------
299 // class EditPaM
300 // -------------------------------------------------------------------------
301 class EditPaM
303 private:
304 ContentNode* pNode;
305 USHORT nIndex;
307 public:
308 EditPaM() { pNode = NULL; nIndex = 0; }
309 EditPaM( ContentNode* p, USHORT n ) { pNode = p; nIndex = n; }
311 ContentNode* GetNode() const { return pNode; }
312 void SetNode( ContentNode* p) { pNode = p; }
314 USHORT GetIndex() const { return nIndex; }
315 USHORT& GetIndex() { return nIndex; }
316 void SetIndex( USHORT n ) { nIndex = n; }
318 BOOL IsParaStart() const { return nIndex == 0; }
319 BOOL IsParaEnd() const { return nIndex == pNode->Len(); }
321 BOOL DbgIsBuggy( EditDoc& rDoc );
323 EditPaM& operator = ( const EditPaM& rPaM );
324 friend BOOL operator == ( const EditPaM& r1, const EditPaM& r2 );
325 friend BOOL operator != ( const EditPaM& r1, const EditPaM& r2 );
328 #define PORTIONKIND_TEXT 0
329 #define PORTIONKIND_TAB 1
330 #define PORTIONKIND_LINEBREAK 2
331 #define PORTIONKIND_FIELD 3
332 #define PORTIONKIND_HYPHENATOR 4
333 // #define PORTIONKIND_EXTRASPACE 5
335 #define DELMODE_SIMPLE 0
336 #define DELMODE_RESTOFWORD 1
337 #define DELMODE_RESTOFCONTENT 2
339 #define CHAR_NORMAL 0x00
340 #define CHAR_KANA 0x01
341 #define CHAR_PUNCTUATIONLEFT 0x02
342 #define CHAR_PUNCTUATIONRIGHT 0x04
344 // -------------------------------------------------------------------------
345 // struct ExtraPortionInfos
346 // -------------------------------------------------------------------------
347 struct ExtraPortionInfo
349 long nOrgWidth;
350 long nWidthFullCompression;
352 long nPortionOffsetX;
354 USHORT nMaxCompression100thPercent;
356 BYTE nAsianCompressionTypes;
357 BOOL bFirstCharIsRightPunktuation;
358 BOOL bCompressed;
360 sal_Int32* pOrgDXArray;
363 ExtraPortionInfo();
364 ~ExtraPortionInfo();
366 void SaveOrgDXArray( const sal_Int32* pDXArray, USHORT nLen );
367 void DestroyOrgDXArray();
371 // -------------------------------------------------------------------------
372 // class TextPortion
373 // -------------------------------------------------------------------------
374 class TextPortion
376 private:
377 ExtraPortionInfo* pExtraInfos;
378 USHORT nLen;
379 Size aOutSz;
380 BYTE nKind;
381 BYTE nRightToLeft;
382 sal_Unicode nExtraValue;
385 TextPortion() { DBG_CTOR( EE_TextPortion, 0 );
386 pExtraInfos = NULL; nLen = 0; nKind = PORTIONKIND_TEXT; nExtraValue = 0; nRightToLeft = FALSE;}
388 public:
389 TextPortion( USHORT nL ) : aOutSz( -1, -1 )
390 { DBG_CTOR( EE_TextPortion, 0 );
391 pExtraInfos = NULL; nLen = nL; nKind = PORTIONKIND_TEXT; nExtraValue = 0; nRightToLeft = FALSE;}
392 TextPortion( const TextPortion& r ) : aOutSz( r.aOutSz )
393 { DBG_CTOR( EE_TextPortion, 0 );
394 pExtraInfos = NULL; nLen = r.nLen; nKind = r.nKind; nExtraValue = r.nExtraValue; nRightToLeft = r.nRightToLeft; }
396 ~TextPortion() { DBG_DTOR( EE_TextPortion, 0 ); delete pExtraInfos; }
398 USHORT GetLen() const { return nLen; }
399 USHORT& GetLen() { return nLen; }
400 void SetLen( USHORT nL ) { nLen = nL; }
402 Size& GetSize() { return aOutSz; }
403 Size GetSize() const { return aOutSz; }
405 BYTE& GetKind() { return nKind; }
406 BYTE GetKind() const { return nKind; }
408 void SetRightToLeft( BYTE b ) { nRightToLeft = b; }
409 BYTE GetRightToLeft() const { return nRightToLeft; }
410 BOOL IsRightToLeft() const { return (nRightToLeft&1); }
412 sal_Unicode GetExtraValue() const { return nExtraValue; }
413 void SetExtraValue( sal_Unicode n ) { nExtraValue = n; }
415 BOOL HasValidSize() const { return aOutSz.Width() != (-1); }
417 ExtraPortionInfo* GetExtraInfos() const { return pExtraInfos; }
418 void SetExtraInfos( ExtraPortionInfo* p ) { delete pExtraInfos; pExtraInfos = p; }
421 // -------------------------------------------------------------------------
422 // class TextPortionList
423 // -------------------------------------------------------------------------
424 typedef TextPortion* TextPortionPtr;
425 SV_DECL_PTRARR( TextPortionArray, TextPortionPtr, 0, 8 )
427 class TextPortionList : public TextPortionArray
429 public:
430 TextPortionList();
431 ~TextPortionList();
433 void Reset();
434 USHORT FindPortion( USHORT nCharPos, USHORT& rPortionStart, BOOL bPreferStartingPortion = FALSE );
435 USHORT GetStartPos( USHORT nPortion );
436 void DeleteFromPortion( USHORT nDelFrom );
439 class ParaPortion;
441 SV_DECL_VARARR( CharPosArray, sal_Int32, 0, CHARPOSGROW )
443 // ------------------------------------------------------------------------
444 // class EditLine
445 // -------------------------------------------------------------------------
446 class EditLine
448 private:
449 CharPosArray aPositions;
450 long nTxtWidth;
451 USHORT nStartPosX;
452 USHORT nStart; // koennte durch nStartPortion ersetzt werden
453 USHORT nEnd; // koennte durch nEndPortion ersetzt werden
454 USHORT nStartPortion;
455 USHORT nEndPortion;
456 USHORT nHeight; // Gesamthoehe der Zeile
457 USHORT nTxtHeight; // Reine Texthoehe
458 USHORT nCrsrHeight; // Bei Konturfluss hohe Zeilen => Cursor zu groá.
459 USHORT nMaxAscent;
460 BOOL bHangingPunctuation;
461 BOOL bInvalid; // fuer geschickte Formatierung
463 public:
464 EditLine();
465 EditLine( const EditLine& );
466 ~EditLine();
468 BOOL IsIn( USHORT nIndex ) const
469 { return ( (nIndex >= nStart ) && ( nIndex < nEnd ) ); }
471 BOOL IsIn( USHORT nIndex, BOOL bInclEnd ) const
472 { return ( ( nIndex >= nStart ) && ( bInclEnd ? ( nIndex <= nEnd ) : ( nIndex < nEnd ) ) ); }
474 void SetStart( USHORT n ) { nStart = n; }
475 USHORT GetStart() const { return nStart; }
476 USHORT& GetStart() { return nStart; }
478 void SetEnd( USHORT n ) { nEnd = n; }
479 USHORT GetEnd() const { return nEnd; }
480 USHORT& GetEnd() { return nEnd; }
482 void SetStartPortion( USHORT n ) { nStartPortion = n; }
483 USHORT GetStartPortion() const { return nStartPortion; }
484 USHORT& GetStartPortion() { return nStartPortion; }
486 void SetEndPortion( USHORT n ) { nEndPortion = n; }
487 USHORT GetEndPortion() const { return nEndPortion; }
488 USHORT& GetEndPortion() { return nEndPortion; }
490 void SetHeight( USHORT nH, USHORT nTxtH = 0, USHORT nCrsrH = 0 )
491 { nHeight = nH;
492 nTxtHeight = ( nTxtH ? nTxtH : nH );
493 nCrsrHeight = ( nCrsrH ? nCrsrH : nTxtHeight );
495 USHORT GetHeight() const { return nHeight; }
496 USHORT GetTxtHeight() const { return nTxtHeight; }
497 USHORT GetCrsrHeight() const { return nCrsrHeight; }
499 void SetTextWidth( long n ) { nTxtWidth = n; }
500 long GetTextWidth() const { return nTxtWidth; }
502 void SetMaxAscent( USHORT n ) { nMaxAscent = n; }
503 USHORT GetMaxAscent() const { return nMaxAscent; }
505 void SetHangingPunctuation( BOOL b ) { bHangingPunctuation = b; }
506 BOOL IsHangingPunctuation() const { return bHangingPunctuation; }
508 USHORT GetLen() const { return nEnd - nStart; }
510 USHORT GetStartPosX() const { return nStartPosX; }
511 void SetStartPosX( USHORT start ) { nStartPosX = start; }
513 Size CalcTextSize( ParaPortion& rParaPortion );
515 BOOL IsInvalid() const { return bInvalid; }
516 BOOL IsValid() const { return !bInvalid; }
517 void SetInvalid() { bInvalid = TRUE; }
518 void SetValid() { bInvalid = FALSE; }
520 BOOL IsEmpty() const { return (nEnd > nStart) ? FALSE : TRUE; }
522 CharPosArray& GetCharPosArray() { return aPositions; }
524 EditLine* Clone() const;
526 EditLine& operator = ( const EditLine& rLine );
527 friend BOOL operator == ( const EditLine& r1, const EditLine& r2 );
528 friend BOOL operator != ( const EditLine& r1, const EditLine& r2 );
532 // -------------------------------------------------------------------------
533 // class LineList
534 // -------------------------------------------------------------------------
535 typedef EditLine* EditLinePtr;
536 SV_DECL_PTRARR( LineArray, EditLinePtr, 0, 4 )
538 class EditLineList : public LineArray
540 public:
541 EditLineList();
542 ~EditLineList();
544 void Reset();
545 void DeleteFromLine( USHORT nDelFrom );
546 USHORT FindLine( USHORT nChar, BOOL bInclEnd );
549 // -------------------------------------------------------------------------
550 // class ParaPortion
551 // -------------------------------------------------------------------------
552 class ParaPortion
554 friend class ImpEditEngine; // zum Einstellen der Hoehe
555 private:
556 EditLineList aLineList;
557 TextPortionList aTextPortionList;
558 ContentNode* pNode;
559 long nHeight;
561 ScriptTypePosInfos aScriptInfos;
562 WritingDirectionInfos aWritingDirectionInfos;
564 USHORT nInvalidPosStart;
565 USHORT nFirstLineOffset; // Fuer Writer-LineSpacing-Interpretation
566 USHORT nBulletX;
567 short nInvalidDiff;
569 BOOL bInvalid : 1;
570 BOOL bSimple : 1; // nur lineares Tippen
571 BOOL bVisible : 1; // MT 05/00: Gehoert an den Node!!!
572 BOOL bForceRepaint : 1;
574 ParaPortion( const ParaPortion& );
576 public:
577 ParaPortion( ContentNode* pNode );
578 ~ParaPortion();
580 USHORT GetLineNumber( USHORT nIndex );
582 EditLineList& GetLines() { return aLineList; }
584 BOOL IsInvalid() const { return bInvalid; }
585 BOOL IsSimpleInvalid() const { return bSimple; }
586 void SetValid() { bInvalid = FALSE; bSimple = TRUE;}
588 BOOL MustRepaint() const { return bForceRepaint; }
589 void SetMustRepaint( BOOL bRP ) { bForceRepaint = bRP; }
591 USHORT GetBulletX() const { return nBulletX; }
592 void SetBulletX( USHORT n ) { nBulletX = n; }
594 void MarkInvalid( USHORT nStart, short nDiff);
595 void MarkSelectionInvalid( USHORT nStart, USHORT nEnd );
597 void SetVisible( BOOL bVisible );
598 BOOL IsVisible() { return bVisible; }
600 long GetHeight() const { return ( bVisible ? nHeight : 0 ); }
601 USHORT GetFirstLineOffset() const { return ( bVisible ? nFirstLineOffset : 0 ); }
602 void ResetHeight() { nHeight = 0; nFirstLineOffset = 0; }
604 ContentNode* GetNode() const { return pNode; }
605 TextPortionList& GetTextPortions() { return aTextPortionList; }
607 USHORT GetInvalidPosStart() const { return nInvalidPosStart; }
608 short GetInvalidDiff() const { return nInvalidDiff; }
610 void CorrectValuesBehindLastFormattedLine( USHORT nLastFormattedLine );
612 BOOL DbgCheckTextPortions();
615 typedef ParaPortion* ParaPortionPtr;
616 SV_DECL_PTRARR( DummyParaPortionList, ParaPortionPtr, 0, 4 )
618 // -------------------------------------------------------------------------
619 // class ParaPortionList
620 // -------------------------------------------------------------------------
621 class ParaPortionList : public DummyParaPortionList
623 USHORT nLastCache;
624 public:
625 ParaPortionList();
626 ~ParaPortionList();
628 void Reset();
629 long GetYOffset( ParaPortion* pPPortion );
630 USHORT FindParagraph( long nYOffset );
632 inline ParaPortion* SaveGetObject( USHORT nPos ) const
633 { return ( nPos < Count() ) ? GetObject( nPos ) : 0; }
635 USHORT GetPos( const ParaPortionPtr &rPtr ) const;
637 // temporaer:
638 void DbgCheck( EditDoc& rDoc );
641 // -------------------------------------------------------------------------
642 // class EditSelection
643 // -------------------------------------------------------------------------
644 class EditSelection
646 private:
647 EditPaM aStartPaM;
648 EditPaM aEndPaM;
650 public:
651 EditSelection(); // kein CCTOR und DTOR, geht autom. richtig!
652 EditSelection( const EditPaM& rStartAndAnd );
653 EditSelection( const EditPaM& rStart, const EditPaM& rEnd );
655 EditPaM& Min() { return aStartPaM; }
656 EditPaM& Max() { return aEndPaM; }
658 const EditPaM& Min() const { return aStartPaM; }
659 const EditPaM& Max() const { return aEndPaM; }
661 BOOL HasRange() const { return aStartPaM != aEndPaM; }
662 BOOL IsInvalid() const;
663 BOOL DbgIsBuggy( EditDoc& rDoc );
665 BOOL Adjust( const ContentList& rNodes );
667 EditSelection& operator = ( const EditPaM& r );
668 BOOL operator == ( const EditSelection& r ) const
669 { return ( ( aStartPaM == r.aStartPaM ) && ( aEndPaM == r.aEndPaM ) )
670 ? TRUE : FALSE; }
671 BOOL operator != ( const EditSelection& r ) const { return !( r == *this ); }
674 // -------------------------------------------------------------------------
675 // class DeletedNodeInfo
676 // -------------------------------------------------------------------------
677 class DeletedNodeInfo
679 private:
680 ULONG nInvalidAdressPtr;
681 USHORT nInvalidParagraph;
683 public:
684 DeletedNodeInfo( ULONG nInvAdr, USHORT nPos )
685 { nInvalidAdressPtr = nInvAdr;
686 nInvalidParagraph = nPos; }
688 ULONG GetInvalidAdress() { return nInvalidAdressPtr; }
689 USHORT GetPosition() { return nInvalidParagraph; }
692 typedef DeletedNodeInfo* DeletedNodeInfoPtr;
693 SV_DECL_PTRARR( DeletedNodesList, DeletedNodeInfoPtr, 0, 4 )
695 // -------------------------------------------------------------------------
696 // class EditDoc
697 // -------------------------------------------------------------------------
698 class EditDoc : public ContentList
700 private:
701 SfxItemPool* pItemPool;
702 Link aModifyHdl;
704 SvxFont aDefFont; //schneller, als jedesmal vom Pool!
705 USHORT nDefTab;
706 BOOL bIsVertical;
707 BOOL bIsFixedCellHeight;
709 BOOL bOwnerOfPool;
710 BOOL bModified;
712 protected:
713 void ImplDestroyContents();
715 public:
716 EditDoc( SfxItemPool* pItemPool );
717 ~EditDoc();
719 BOOL IsModified() const { return bModified; }
720 void SetModified( BOOL b );
722 void SetModifyHdl( const Link& rLink ) { aModifyHdl = rLink; }
723 Link GetModifyHdl() const { return aModifyHdl; }
725 void CreateDefFont( BOOL bUseStyles );
726 const SvxFont& GetDefFont() { return aDefFont; }
728 void SetDefTab( USHORT nTab ) { nDefTab = nTab ? nTab : DEFTAB; }
729 USHORT GetDefTab() const { return nDefTab; }
731 void SetVertical( BOOL bVertical ) { bIsVertical = bVertical; }
732 BOOL IsVertical() const { return bIsVertical; }
734 void SetFixedCellHeight( BOOL bUseFixedCellHeight ) { bIsFixedCellHeight = bUseFixedCellHeight; }
735 BOOL IsFixedCellHeight() const { return bIsFixedCellHeight; }
737 EditPaM Clear();
738 EditPaM RemoveText();
739 EditPaM RemoveChars( EditPaM aPaM, USHORT nChars );
740 void InsertText( const EditPaM& rPaM, xub_Unicode c );
741 EditPaM InsertText( EditPaM aPaM, const XubString& rStr );
742 EditPaM InsertParaBreak( EditPaM aPaM, BOOL bKeepEndingAttribs );
743 EditPaM InsertFeature( EditPaM aPaM, const SfxPoolItem& rItem );
744 EditPaM ConnectParagraphs( ContentNode* pLeft, ContentNode* pRight );
746 String GetText( LineEnd eEnd ) const;
747 ULONG GetTextLen() const;
749 XubString GetParaAsString( USHORT nNode ) const;
750 XubString GetParaAsString( ContentNode* pNode, USHORT nStartPos = 0, USHORT nEndPos = 0xFFFF, BOOL bResolveFields = TRUE ) const;
752 inline EditPaM GetStartPaM() const;
753 inline EditPaM GetEndPaM() const;
755 SfxItemPool& GetItemPool() { return *pItemPool; }
756 const SfxItemPool& GetItemPool() const { return *pItemPool; }
758 void RemoveItemsFromPool( ContentNode* pNode );
760 void InsertAttrib( const SfxPoolItem& rItem, ContentNode* pNode, USHORT nStart, USHORT nEnd );
761 void InsertAttrib( ContentNode* pNode, USHORT nStart, USHORT nEnd, const SfxPoolItem& rPoolItem );
762 void InsertAttribInSelection( ContentNode* pNode, USHORT nStart, USHORT nEnd, const SfxPoolItem& rPoolItem );
763 BOOL RemoveAttribs( ContentNode* pNode, USHORT nStart, USHORT nEnd, USHORT nWhich = 0 );
764 BOOL RemoveAttribs( ContentNode* pNode, USHORT nStart, USHORT nEnd, EditCharAttrib*& rpStarting, EditCharAttrib*& rpEnding, USHORT nWhich = 0 );
765 void FindAttribs( ContentNode* pNode, USHORT nStartPos, USHORT nEndPos, SfxItemSet& rCurSet );
767 USHORT GetPos( ContentNode* pNode ) const { return ContentList::GetPos(pNode); }
768 ContentNode* SaveGetObject( USHORT nPos ) const { return ( nPos < Count() ) ? GetObject( nPos ) : 0; }
770 static XubString GetSepStr( LineEnd eEnd );
773 inline EditPaM EditDoc::GetStartPaM() const
775 return EditPaM( GetObject( 0 ), 0 );
778 inline EditPaM EditDoc::GetEndPaM() const
780 ContentNode* pLastNode = GetObject( Count()-1 );
781 return EditPaM( pLastNode, pLastNode->Len() );
784 inline EditCharAttrib* GetAttrib( const CharAttribArray& rAttribs, USHORT nAttr )
786 return ( nAttr < rAttribs.Count() ) ? rAttribs[nAttr] : 0;
789 BOOL CheckOrderedList( CharAttribArray& rAttribs, BOOL bStart );
791 // -------------------------------------------------------------------------
792 // class EditEngineItemPool
793 // -------------------------------------------------------------------------
794 class EditEngineItemPool : public SfxItemPool
796 public:
797 EditEngineItemPool( BOOL bPersistenRefCounts );
798 protected:
799 virtual ~EditEngineItemPool();
800 public:
802 virtual SvStream& Store( SvStream& rStream ) const;
805 #endif // _EDITDOC_HXX