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 _EDITDOC_HXX
25 #define _EDITDOC_HXX
26
27 #ifndef _COM_SUN_STAR_I18N_XEXTENDEDINPUTSEQUENCECHECKER_HDL_
28 #include <com/sun/star/i18n/XExtendedInputSequenceChecker.hpp>
29 #endif
30
31 #include <editattr.hxx>
32 #include <edtspell.hxx>
33 #include <editeng/svxfont.hxx>
34 #include <svl/itemset.hxx>
35 #include <svl/style.hxx>
36 #include <svl/itempool.hxx>
37 #include <tools/table.hxx>
38
39 #include <deque>
40
41 class ImpEditEngine;
42 class SvxTabStop;
43 class SvtCTLOptions;
44
45 DBG_NAMEEX( EE_TextPortion )
46
47 #define CHARPOSGROW 16
48 #define DEFTAB 720
49
50 void CreateFont( SvxFont& rFont, const SfxItemSet& rSet, bool bSearchInParent = true, short nScriptType = 0 );
51 sal_uInt16 GetScriptItemId( sal_uInt16 nItemId, short nScriptType );
52 sal_Bool IsScriptItemValid( sal_uInt16 nItemId, short nScriptType );
53
54 EditCharAttrib* MakeCharAttrib( SfxItemPool& rPool, const SfxPoolItem& rAttr, sal_uInt16 nS, sal_uInt16 nE );
55
56 class ContentNode;
57 class EditDoc;
58
59 struct EPaM
60 {
61 sal_uInt16 nPara;
62 sal_uInt16 nIndex;
63
EPaMEPaM64 EPaM() { nPara = 0; nIndex = 0; }
EPaMEPaM65 EPaM( sal_uInt16 nP, sal_uInt16 nI ) { nPara = nP; nIndex = nI; }
EPaMEPaM66 EPaM( const EPaM& r) { nPara = r.nPara; nIndex = r.nIndex; }
operator =EPaM67 EPaM& operator = ( const EPaM& r ) { nPara = r.nPara; nIndex = r.nIndex; return *this; }
68 inline sal_Bool operator == ( const EPaM& r ) const;
69 inline sal_Bool operator < ( const EPaM& r ) const;
70 };
71
operator <(const EPaM & r) const72 inline sal_Bool EPaM::operator < ( const EPaM& r ) const
73 {
74 return ( ( nPara < r.nPara ) ||
75 ( ( nPara == r.nPara ) && nIndex < r.nIndex ) ) ? sal_True : sal_False;
76 }
77
operator ==(const EPaM & r) const78 inline sal_Bool EPaM::operator == ( const EPaM& r ) const
79 {
80 return ( ( nPara == r.nPara ) && ( nIndex == r.nIndex ) ) ? sal_True : sal_False;
81 }
82
83 struct ScriptTypePosInfo
84 {
85 short nScriptType;
86 sal_uInt16 nStartPos;
87 sal_uInt16 nEndPos;
88
ScriptTypePosInfoScriptTypePosInfo89 ScriptTypePosInfo( short _Type, sal_uInt16 _Start, sal_uInt16 _End )
90 {
91 nScriptType = _Type;
92 nStartPos = _Start;
93 nEndPos = _End;
94 }
95 };
96
97 typedef std::deque< ScriptTypePosInfo > ScriptTypePosInfos;
98
99 struct WritingDirectionInfo
100 {
101 sal_uInt8 nType;
102 sal_uInt16 nStartPos;
103 sal_uInt16 nEndPos;
104
WritingDirectionInfoWritingDirectionInfo105 WritingDirectionInfo( sal_uInt8 _Type, sal_uInt16 _Start, sal_uInt16 _End )
106 {
107 nType = _Type;
108 nStartPos = _Start;
109 nEndPos = _End;
110 }
111 };
112
113
114 typedef std::deque< WritingDirectionInfo > WritingDirectionInfos;
115
116 typedef EditCharAttrib* EditCharAttribPtr;
117 SV_DECL_PTRARR( CharAttribArray, EditCharAttribPtr, 0, 4 )
118
119 class ContentAttribsInfo
120 {
121 private:
122 SfxItemSet aPrevParaAttribs;
123 CharAttribArray aPrevCharAttribs;
124
125 public:
126 ContentAttribsInfo( const SfxItemSet& rParaAttribs );
127
GetPrevParaAttribs() const128 const SfxItemSet& GetPrevParaAttribs() const { return aPrevParaAttribs; }
GetPrevCharAttribs() const129 const CharAttribArray& GetPrevCharAttribs() const { return aPrevCharAttribs; }
130
GetPrevCharAttribs()131 CharAttribArray& GetPrevCharAttribs() { return aPrevCharAttribs; }
132 };
133
134 typedef ContentAttribsInfo* ContentAttribsInfoPtr;
135 SV_DECL_PTRARR( ContentInfoArray, ContentAttribsInfoPtr, 1, 1 )
136
137 // ----------------------------------------------------------------------
138 // class SvxFontTable
139 // ----------------------------------------------------------------------
140 DECLARE_TABLE( DummyFontTable, SvxFontItem* )
141 class SvxFontTable : public DummyFontTable
142 {
143 public:
144 SvxFontTable();
145 ~SvxFontTable();
146
147 sal_uLong GetId( const SvxFontItem& rFont );
148 };
149
150 // ----------------------------------------------------------------------
151 // class SvxColorList
152 // ----------------------------------------------------------------------
153 typedef ContentNode* ContentNodePtr;
154 DECLARE_LIST( DummyColorList, SvxColorItem* )
155 class SvxColorList : public DummyColorList
156 {
157 public:
158 SvxColorList();
159 ~SvxColorList();
160
161 sal_uLong GetId( const SvxColorItem& rColor );
162 };
163
164 // ----------------------------------------------------------------------
165 // class ItemList
166 // ----------------------------------------------------------------------
167 typedef const SfxPoolItem* ConstPoolItemPtr;
168 DECLARE_LIST( DummyItemList, ConstPoolItemPtr )
169 class ItemList : public DummyItemList
170 {
171 public:
172 const SfxPoolItem* FindAttrib( sal_uInt16 nWhich );
173 };
174
175 // -------------------------------------------------------------------------
176 // class ContentAttribs
177 // -------------------------------------------------------------------------
178 class ContentAttribs
179 {
180 private:
181 SfxStyleSheet* pStyle;
182 SfxItemSet aAttribSet;
183
184 public:
185 ContentAttribs( SfxItemPool& rItemPool );
186 ContentAttribs( const ContentAttribs& );
187 ~ContentAttribs(); // erst bei umfangreicheren Tabs
188
189 SvxTabStop FindTabStop( long nCurPos, sal_uInt16 nDefTab );
GetItems()190 SfxItemSet& GetItems() { return aAttribSet; }
GetStyleSheet() const191 SfxStyleSheet* GetStyleSheet() const { return pStyle; }
192 void SetStyleSheet( SfxStyleSheet* pS );
193
194 const SfxPoolItem& GetItem( sal_uInt16 nWhich );
195 sal_Bool HasItem( sal_uInt16 nWhich );
196 };
197
198 // -------------------------------------------------------------------------
199 // class CharAttribList
200 // -------------------------------------------------------------------------
201 class CharAttribList
202 {
203 private:
204 CharAttribArray aAttribs;
205 SvxFont aDefFont; // schneller, als jedesmal vom Pool!
206 sal_Bool bHasEmptyAttribs;
207
CharAttribList(const CharAttribList &)208 CharAttribList( const CharAttribList& ) {;}
209
210 public:
211 CharAttribList();
212 ~CharAttribList();
213
214 void DeleteEmptyAttribs( SfxItemPool& rItemPool );
215 void RemoveItemsFromPool( SfxItemPool* pItemPool );
216
217 EditCharAttrib* FindAttrib( sal_uInt16 nWhich, sal_uInt16 nPos );
218 EditCharAttrib* FindNextAttrib( sal_uInt16 nWhich, sal_uInt16 nFromPos ) const;
219 EditCharAttrib* FindEmptyAttrib( sal_uInt16 nWhich, sal_uInt16 nPos );
220 EditCharAttrib* FindFeature( sal_uInt16 nPos ) const;
221
222
223 void ResortAttribs();
224 void OptimizeRanges( SfxItemPool& rItemPool );
225
Count()226 sal_uInt16 Count() { return aAttribs.Count(); }
Clear()227 void Clear() { aAttribs.Remove( 0, aAttribs.Count()); }
228 void InsertAttrib( EditCharAttrib* pAttrib );
229
GetDefFont()230 SvxFont& GetDefFont() { return aDefFont; }
231
HasEmptyAttribs() const232 sal_Bool HasEmptyAttribs() const { return bHasEmptyAttribs; }
HasEmptyAttribs()233 sal_Bool& HasEmptyAttribs() { return bHasEmptyAttribs; }
234 sal_Bool HasBoundingAttrib( sal_uInt16 nBound );
235 sal_Bool HasAttrib( sal_uInt16 nWhich ) const;
236 sal_Bool HasAttrib( sal_uInt16 nStartPos, sal_uInt16 nEndPos ) const;
237
GetAttribs()238 CharAttribArray& GetAttribs() { return aAttribs; }
GetAttribs() const239 const CharAttribArray& GetAttribs() const { return aAttribs; }
240
241 // Debug:
242 sal_Bool DbgCheckAttribs();
243 };
244
245 // -------------------------------------------------------------------------
246 // class ContentNode
247 // -------------------------------------------------------------------------
248 class ContentNode : public XubString
249 {
250 private:
251 ContentAttribs aContentAttribs;
252 CharAttribList aCharAttribList;
253 WrongList* pWrongList;
254
255 public:
256 ContentNode( SfxItemPool& rItemPool );
257 ContentNode( const XubString& rStr, const ContentAttribs& rContentAttribs );
258 ~ContentNode();
259
GetContentAttribs()260 ContentAttribs& GetContentAttribs() { return aContentAttribs; }
GetCharAttribs()261 CharAttribList& GetCharAttribs() { return aCharAttribList; }
262
263 void ExpandAttribs( sal_uInt16 nIndex, sal_uInt16 nNewChars, SfxItemPool& rItemPool );
264 void CollapsAttribs( sal_uInt16 nIndex, sal_uInt16 nDelChars, SfxItemPool& rItemPool );
265 void AppendAttribs( ContentNode* pNextNode );
266 void CopyAndCutAttribs( ContentNode* pPrevNode, SfxItemPool& rPool, sal_Bool bKeepEndingAttribs );
267
268 void SetStyleSheet( SfxStyleSheet* pS, sal_Bool bRecalcFont = sal_True );
269 void SetStyleSheet( SfxStyleSheet* pS, const SvxFont& rFontFromStyle );
GetStyleSheet()270 SfxStyleSheet* GetStyleSheet() { return aContentAttribs.GetStyleSheet(); }
271
272 void CreateDefFont();
273
GetWrongList()274 WrongList* GetWrongList() { return pWrongList; }
275 void SetWrongList( WrongList* p );
276
277 void CreateWrongList();
278 void DestroyWrongList();
279
IsFeature(sal_uInt16 nPos) const280 sal_Bool IsFeature( sal_uInt16 nPos ) const { return ( GetChar( nPos ) == CH_FEATURE ); }
281 };
282
283 typedef ContentNode* ContentNodePtr;
284 SV_DECL_PTRARR( DummyContentList, ContentNodePtr, 0, 4 )
285
286 class ContentList : public DummyContentList
287 {
288 sal_uInt16 nLastCache;
289 public:
ContentList()290 ContentList() : DummyContentList( 0, 4 ), nLastCache(0) {}
291 sal_uInt16 GetPos( const ContentNodePtr &rPtr ) const;
292 };
293
294 // -------------------------------------------------------------------------
295 // class EditPaM
296 // -------------------------------------------------------------------------
297 class EditPaM
298 {
299 private:
300 ContentNode* pNode;
301 sal_uInt16 nIndex;
302
303 public:
EditPaM()304 EditPaM() { pNode = NULL; nIndex = 0; }
EditPaM(ContentNode * p,sal_uInt16 n)305 EditPaM( ContentNode* p, sal_uInt16 n ) { pNode = p; nIndex = n; }
306
GetNode() const307 ContentNode* GetNode() const { return pNode; }
SetNode(ContentNode * p)308 void SetNode( ContentNode* p) { pNode = p; }
309
GetIndex() const310 sal_uInt16 GetIndex() const { return nIndex; }
GetIndex()311 sal_uInt16& GetIndex() { return nIndex; }
SetIndex(sal_uInt16 n)312 void SetIndex( sal_uInt16 n ) { nIndex = n; }
313
IsParaStart() const314 sal_Bool IsParaStart() const { return nIndex == 0; }
IsParaEnd() const315 sal_Bool IsParaEnd() const { return nIndex == pNode->Len(); }
316
317 sal_Bool DbgIsBuggy( EditDoc& rDoc );
318
319 EditPaM& operator = ( const EditPaM& rPaM );
320 friend sal_Bool operator == ( const EditPaM& r1, const EditPaM& r2 );
321 friend sal_Bool operator != ( const EditPaM& r1, const EditPaM& r2 );
322 };
323
324 #define PORTIONKIND_TEXT 0
325 #define PORTIONKIND_TAB 1
326 #define PORTIONKIND_LINEBREAK 2
327 #define PORTIONKIND_FIELD 3
328 #define PORTIONKIND_HYPHENATOR 4
329 // #define PORTIONKIND_EXTRASPACE 5
330
331 #define DELMODE_SIMPLE 0
332 #define DELMODE_RESTOFWORD 1
333 #define DELMODE_RESTOFCONTENT 2
334
335 #define CHAR_NORMAL 0x00
336 #define CHAR_KANA 0x01
337 #define CHAR_PUNCTUATIONLEFT 0x02
338 #define CHAR_PUNCTUATIONRIGHT 0x04
339
340 // -------------------------------------------------------------------------
341 // struct ExtraPortionInfos
342 // -------------------------------------------------------------------------
343 struct ExtraPortionInfo
344 {
345 long nOrgWidth;
346 long nWidthFullCompression;
347
348 long nPortionOffsetX;
349
350 sal_uInt16 nMaxCompression100thPercent;
351
352 sal_uInt8 nAsianCompressionTypes;
353 sal_Bool bFirstCharIsRightPunktuation;
354 sal_Bool bCompressed;
355
356 sal_Int32* pOrgDXArray;
357
358
359 ExtraPortionInfo();
360 ~ExtraPortionInfo();
361
362 void SaveOrgDXArray( const sal_Int32* pDXArray, sal_uInt16 nLen );
363 void DestroyOrgDXArray();
364 };
365
366
367 // -------------------------------------------------------------------------
368 // class TextPortion
369 // -------------------------------------------------------------------------
370 class TextPortion
371 {
372 private:
373 ExtraPortionInfo* pExtraInfos;
374 sal_uInt16 nLen;
375 Size aOutSz;
376 sal_uInt8 nKind;
377 sal_uInt8 nRightToLeft;
378 sal_Unicode nExtraValue;
379
380
TextPortion()381 TextPortion() { DBG_CTOR( EE_TextPortion, 0 );
382 pExtraInfos = NULL; nLen = 0; nKind = PORTIONKIND_TEXT; nExtraValue = 0; nRightToLeft = sal_False;}
383
384 public:
TextPortion(sal_uInt16 nL)385 TextPortion( sal_uInt16 nL ) : aOutSz( -1, -1 )
386 { DBG_CTOR( EE_TextPortion, 0 );
387 pExtraInfos = NULL; nLen = nL; nKind = PORTIONKIND_TEXT; nExtraValue = 0; nRightToLeft = sal_False;}
TextPortion(const TextPortion & r)388 TextPortion( const TextPortion& r ) : aOutSz( r.aOutSz )
389 { DBG_CTOR( EE_TextPortion, 0 );
390 pExtraInfos = NULL; nLen = r.nLen; nKind = r.nKind; nExtraValue = r.nExtraValue; nRightToLeft = r.nRightToLeft; }
391
~TextPortion()392 ~TextPortion() { DBG_DTOR( EE_TextPortion, 0 ); delete pExtraInfos; }
393
GetLen() const394 sal_uInt16 GetLen() const { return nLen; }
GetLen()395 sal_uInt16& GetLen() { return nLen; }
SetLen(sal_uInt16 nL)396 void SetLen( sal_uInt16 nL ) { nLen = nL; }
397
GetSize()398 Size& GetSize() { return aOutSz; }
GetSize() const399 Size GetSize() const { return aOutSz; }
400
GetKind()401 sal_uInt8& GetKind() { return nKind; }
GetKind() const402 sal_uInt8 GetKind() const { return nKind; }
403
SetRightToLeft(sal_uInt8 b)404 void SetRightToLeft( sal_uInt8 b ) { nRightToLeft = b; }
GetRightToLeft() const405 sal_uInt8 GetRightToLeft() const { return nRightToLeft; }
IsRightToLeft() const406 sal_Bool IsRightToLeft() const { return (nRightToLeft&1); }
407
GetExtraValue() const408 sal_Unicode GetExtraValue() const { return nExtraValue; }
SetExtraValue(sal_Unicode n)409 void SetExtraValue( sal_Unicode n ) { nExtraValue = n; }
410
HasValidSize() const411 sal_Bool HasValidSize() const { return aOutSz.Width() != (-1); }
412
GetExtraInfos() const413 ExtraPortionInfo* GetExtraInfos() const { return pExtraInfos; }
SetExtraInfos(ExtraPortionInfo * p)414 void SetExtraInfos( ExtraPortionInfo* p ) { delete pExtraInfos; pExtraInfos = p; }
415 };
416
417 // -------------------------------------------------------------------------
418 // class TextPortionList
419 // -------------------------------------------------------------------------
420 typedef TextPortion* TextPortionPtr;
421 SV_DECL_PTRARR( TextPortionArray, TextPortionPtr, 0, 8 )
422
423 class TextPortionList : public TextPortionArray
424 {
425 public:
426 TextPortionList();
427 ~TextPortionList();
428
429 void Reset();
430 sal_uInt16 FindPortion( sal_uInt16 nCharPos, sal_uInt16& rPortionStart, sal_Bool bPreferStartingPortion = sal_False );
431 sal_uInt16 GetStartPos( sal_uInt16 nPortion );
432 void DeleteFromPortion( sal_uInt16 nDelFrom );
433 };
434
435 class ParaPortion;
436
437 SV_DECL_VARARR( CharPosArray, sal_Int32, 0, CHARPOSGROW )
438
439 // ------------------------------------------------------------------------
440 // class EditLine
441 // -------------------------------------------------------------------------
442 class EditLine
443 {
444 private:
445 CharPosArray aPositions;
446 long nTxtWidth;
447 sal_uInt16 nStartPosX;
448 sal_uInt16 nStart; // koennte durch nStartPortion ersetzt werden
449 sal_uInt16 nEnd; // koennte durch nEndPortion ersetzt werden
450 sal_uInt16 nStartPortion;
451 sal_uInt16 nEndPortion;
452 sal_uInt16 nHeight; // Gesamthoehe der Zeile
453 sal_uInt16 nTxtHeight; // Reine Texthoehe
454 sal_uInt16 nCrsrHeight; // Bei Konturfluss hohe Zeilen => Cursor zu gro?.
455 sal_uInt16 nMaxAscent;
456 sal_Bool bHangingPunctuation;
457 sal_Bool bInvalid; // fuer geschickte Formatierung
458
459 public:
460 EditLine();
461 EditLine( const EditLine& );
462 ~EditLine();
463
IsIn(sal_uInt16 nIndex) const464 sal_Bool IsIn( sal_uInt16 nIndex ) const
465 { return ( (nIndex >= nStart ) && ( nIndex < nEnd ) ); }
466
IsIn(sal_uInt16 nIndex,sal_Bool bInclEnd) const467 sal_Bool IsIn( sal_uInt16 nIndex, sal_Bool bInclEnd ) const
468 { return ( ( nIndex >= nStart ) && ( bInclEnd ? ( nIndex <= nEnd ) : ( nIndex < nEnd ) ) ); }
469
SetStart(sal_uInt16 n)470 void SetStart( sal_uInt16 n ) { nStart = n; }
GetStart() const471 sal_uInt16 GetStart() const { return nStart; }
GetStart()472 sal_uInt16& GetStart() { return nStart; }
473
SetEnd(sal_uInt16 n)474 void SetEnd( sal_uInt16 n ) { nEnd = n; }
GetEnd() const475 sal_uInt16 GetEnd() const { return nEnd; }
GetEnd()476 sal_uInt16& GetEnd() { return nEnd; }
477
SetStartPortion(sal_uInt16 n)478 void SetStartPortion( sal_uInt16 n ) { nStartPortion = n; }
GetStartPortion() const479 sal_uInt16 GetStartPortion() const { return nStartPortion; }
GetStartPortion()480 sal_uInt16& GetStartPortion() { return nStartPortion; }
481
SetEndPortion(sal_uInt16 n)482 void SetEndPortion( sal_uInt16 n ) { nEndPortion = n; }
GetEndPortion() const483 sal_uInt16 GetEndPortion() const { return nEndPortion; }
GetEndPortion()484 sal_uInt16& GetEndPortion() { return nEndPortion; }
485
SetHeight(sal_uInt16 nH,sal_uInt16 nTxtH=0,sal_uInt16 nCrsrH=0)486 void SetHeight( sal_uInt16 nH, sal_uInt16 nTxtH = 0, sal_uInt16 nCrsrH = 0 )
487 { nHeight = nH;
488 nTxtHeight = ( nTxtH ? nTxtH : nH );
489 nCrsrHeight = ( nCrsrH ? nCrsrH : nTxtHeight );
490 }
GetHeight() const491 sal_uInt16 GetHeight() const { return nHeight; }
GetTxtHeight() const492 sal_uInt16 GetTxtHeight() const { return nTxtHeight; }
GetCrsrHeight() const493 sal_uInt16 GetCrsrHeight() const { return nCrsrHeight; }
494
SetTextWidth(long n)495 void SetTextWidth( long n ) { nTxtWidth = n; }
GetTextWidth() const496 long GetTextWidth() const { return nTxtWidth; }
497
SetMaxAscent(sal_uInt16 n)498 void SetMaxAscent( sal_uInt16 n ) { nMaxAscent = n; }
GetMaxAscent() const499 sal_uInt16 GetMaxAscent() const { return nMaxAscent; }
500
SetHangingPunctuation(sal_Bool b)501 void SetHangingPunctuation( sal_Bool b ) { bHangingPunctuation = b; }
IsHangingPunctuation() const502 sal_Bool IsHangingPunctuation() const { return bHangingPunctuation; }
503
GetLen() const504 sal_uInt16 GetLen() const { return nEnd - nStart; }
505
GetStartPosX() const506 sal_uInt16 GetStartPosX() const { return nStartPosX; }
SetStartPosX(sal_uInt16 start)507 void SetStartPosX( sal_uInt16 start ) { nStartPosX = start; }
508
509 Size CalcTextSize( ParaPortion& rParaPortion );
510
IsInvalid() const511 sal_Bool IsInvalid() const { return bInvalid; }
IsValid() const512 sal_Bool IsValid() const { return !bInvalid; }
SetInvalid()513 void SetInvalid() { bInvalid = sal_True; }
SetValid()514 void SetValid() { bInvalid = sal_False; }
515
IsEmpty() const516 sal_Bool IsEmpty() const { return (nEnd > nStart) ? sal_False : sal_True; }
517
GetCharPosArray()518 CharPosArray& GetCharPosArray() { return aPositions; }
519
520 EditLine* Clone() const;
521
522 EditLine& operator = ( const EditLine& rLine );
523 friend sal_Bool operator == ( const EditLine& r1, const EditLine& r2 );
524 friend sal_Bool operator != ( const EditLine& r1, const EditLine& r2 );
525 };
526
527
528 // -------------------------------------------------------------------------
529 // class LineList
530 // -------------------------------------------------------------------------
531 typedef EditLine* EditLinePtr;
532 SV_DECL_PTRARR( LineArray, EditLinePtr, 0, 4 )
533
534 class EditLineList : public LineArray
535 {
536 public:
537 EditLineList();
538 ~EditLineList();
539
540 void Reset();
541 void DeleteFromLine( sal_uInt16 nDelFrom );
542 sal_uInt16 FindLine( sal_uInt16 nChar, sal_Bool bInclEnd );
543 };
544
545 // -------------------------------------------------------------------------
546 // class ParaPortion
547 // -------------------------------------------------------------------------
548 class ParaPortion
549 {
550 friend class ImpEditEngine; // zum Einstellen der Hoehe
551 private:
552 EditLineList aLineList;
553 TextPortionList aTextPortionList;
554 ContentNode* pNode;
555 long nHeight;
556
557 ScriptTypePosInfos aScriptInfos;
558 WritingDirectionInfos aWritingDirectionInfos;
559
560 sal_uInt16 nInvalidPosStart;
561 sal_uInt16 nFirstLineOffset; // Fuer Writer-LineSpacing-Interpretation
562 sal_uInt16 nBulletX;
563 short nInvalidDiff;
564
565 sal_Bool bInvalid : 1;
566 sal_Bool bSimple : 1; // nur lineares Tippen
567 sal_Bool bVisible : 1; // MT 05/00: Gehoert an den Node!!!
568 sal_Bool bForceRepaint : 1;
569
570 ParaPortion( const ParaPortion& );
571
572 public:
573 ParaPortion( ContentNode* pNode );
574 ~ParaPortion();
575
576 sal_uInt16 GetLineNumber( sal_uInt16 nIndex );
577
GetLines()578 EditLineList& GetLines() { return aLineList; }
579
IsInvalid() const580 sal_Bool IsInvalid() const { return bInvalid; }
IsSimpleInvalid() const581 sal_Bool IsSimpleInvalid() const { return bSimple; }
SetValid()582 void SetValid() { bInvalid = sal_False; bSimple = sal_True;}
583
MustRepaint() const584 sal_Bool MustRepaint() const { return bForceRepaint; }
SetMustRepaint(sal_Bool bRP)585 void SetMustRepaint( sal_Bool bRP ) { bForceRepaint = bRP; }
586
GetBulletX() const587 sal_uInt16 GetBulletX() const { return nBulletX; }
SetBulletX(sal_uInt16 n)588 void SetBulletX( sal_uInt16 n ) { nBulletX = n; }
589
590 void MarkInvalid( sal_uInt16 nStart, short nDiff);
591 void MarkSelectionInvalid( sal_uInt16 nStart, sal_uInt16 nEnd );
592
593 void SetVisible( sal_Bool bVisible );
IsVisible()594 sal_Bool IsVisible() { return bVisible; }
595
GetHeight() const596 long GetHeight() const { return ( bVisible ? nHeight : 0 ); }
GetFirstLineOffset() const597 sal_uInt16 GetFirstLineOffset() const { return ( bVisible ? nFirstLineOffset : 0 ); }
ResetHeight()598 void ResetHeight() { nHeight = 0; nFirstLineOffset = 0; }
599
GetNode() const600 ContentNode* GetNode() const { return pNode; }
GetTextPortions()601 TextPortionList& GetTextPortions() { return aTextPortionList; }
602
GetInvalidPosStart() const603 sal_uInt16 GetInvalidPosStart() const { return nInvalidPosStart; }
GetInvalidDiff() const604 short GetInvalidDiff() const { return nInvalidDiff; }
605
606 void CorrectValuesBehindLastFormattedLine( sal_uInt16 nLastFormattedLine );
607
608 sal_Bool DbgCheckTextPortions();
609 };
610
611 typedef ParaPortion* ParaPortionPtr;
612 SV_DECL_PTRARR( DummyParaPortionList, ParaPortionPtr, 0, 4 )
613
614 // -------------------------------------------------------------------------
615 // class ParaPortionList
616 // -------------------------------------------------------------------------
617 class ParaPortionList : public DummyParaPortionList
618 {
619 sal_uInt16 nLastCache;
620 public:
621 ParaPortionList();
622 ~ParaPortionList();
623
624 void Reset();
625 long GetYOffset( ParaPortion* pPPortion );
626 sal_uInt16 FindParagraph( long nYOffset );
627
SaveGetObject(sal_uInt16 nPos) const628 inline ParaPortion* SaveGetObject( sal_uInt16 nPos ) const
629 { return ( nPos < Count() ) ? GetObject( nPos ) : 0; }
630
631 sal_uInt16 GetPos( const ParaPortionPtr &rPtr ) const;
632
633 // temporaer:
634 void DbgCheck( EditDoc& rDoc );
635 };
636
637 // -------------------------------------------------------------------------
638 // class EditSelection
639 // -------------------------------------------------------------------------
640 class EditSelection
641 {
642 private:
643 EditPaM aStartPaM;
644 EditPaM aEndPaM;
645
646 public:
647 EditSelection(); // kein CCTOR und DTOR, geht autom. richtig!
648 EditSelection( const EditPaM& rStartAndAnd );
649 EditSelection( const EditPaM& rStart, const EditPaM& rEnd );
650
Min()651 EditPaM& Min() { return aStartPaM; }
Max()652 EditPaM& Max() { return aEndPaM; }
653
Min() const654 const EditPaM& Min() const { return aStartPaM; }
Max() const655 const EditPaM& Max() const { return aEndPaM; }
656
HasRange() const657 sal_Bool HasRange() const { return aStartPaM != aEndPaM; }
658 sal_Bool IsInvalid() const;
659 sal_Bool DbgIsBuggy( EditDoc& rDoc );
660
661 sal_Bool Adjust( const ContentList& rNodes );
662
663 EditSelection& operator = ( const EditPaM& r );
operator ==(const EditSelection & r) const664 sal_Bool operator == ( const EditSelection& r ) const
665 { return ( ( aStartPaM == r.aStartPaM ) && ( aEndPaM == r.aEndPaM ) )
666 ? sal_True : sal_False; }
operator !=(const EditSelection & r) const667 sal_Bool operator != ( const EditSelection& r ) const { return !( r == *this ); }
668 };
669
670 // -------------------------------------------------------------------------
671 // class DeletedNodeInfo
672 // -------------------------------------------------------------------------
673 class DeletedNodeInfo
674 {
675 private:
676 sal_uIntPtr nInvalidAdressPtr;
677 sal_uInt16 nInvalidParagraph;
678
679 public:
DeletedNodeInfo(sal_uIntPtr nInvAdr,sal_uInt16 nPos)680 DeletedNodeInfo( sal_uIntPtr nInvAdr, sal_uInt16 nPos )
681 { nInvalidAdressPtr = nInvAdr;
682 nInvalidParagraph = nPos; }
683
GetInvalidAdress()684 sal_uIntPtr GetInvalidAdress() { return nInvalidAdressPtr; }
GetPosition()685 sal_uInt16 GetPosition() { return nInvalidParagraph; }
686 };
687
688 typedef DeletedNodeInfo* DeletedNodeInfoPtr;
689 SV_DECL_PTRARR( DeletedNodesList, DeletedNodeInfoPtr, 0, 4 )
690
691 // -------------------------------------------------------------------------
692 // class EditDoc
693 // -------------------------------------------------------------------------
694 class EditDoc : public ContentList
695 {
696 private:
697 SfxItemPool* pItemPool;
698 Link aModifyHdl;
699
700 SvxFont aDefFont; //schneller, als jedesmal vom Pool!
701 sal_uInt16 nDefTab;
702 sal_Bool bIsVertical;
703 sal_Bool bIsFixedCellHeight;
704
705 sal_Bool bOwnerOfPool;
706 sal_Bool bModified;
707
708 protected:
709 void ImplDestroyContents();
710
711 public:
712 EditDoc( SfxItemPool* pItemPool );
713 ~EditDoc();
714
IsModified() const715 sal_Bool IsModified() const { return bModified; }
716 void SetModified( sal_Bool b );
717
SetModifyHdl(const Link & rLink)718 void SetModifyHdl( const Link& rLink ) { aModifyHdl = rLink; }
GetModifyHdl() const719 Link GetModifyHdl() const { return aModifyHdl; }
720
721 void CreateDefFont( sal_Bool bUseStyles );
GetDefFont()722 const SvxFont& GetDefFont() { return aDefFont; }
723
SetDefTab(sal_uInt16 nTab)724 void SetDefTab( sal_uInt16 nTab ) { nDefTab = nTab ? nTab : DEFTAB; }
GetDefTab() const725 sal_uInt16 GetDefTab() const { return nDefTab; }
726
SetVertical(sal_Bool bVertical)727 void SetVertical( sal_Bool bVertical ) { bIsVertical = bVertical; }
IsVertical() const728 sal_Bool IsVertical() const { return bIsVertical; }
729
SetFixedCellHeight(sal_Bool bUseFixedCellHeight)730 void SetFixedCellHeight( sal_Bool bUseFixedCellHeight ) { bIsFixedCellHeight = bUseFixedCellHeight; }
IsFixedCellHeight() const731 sal_Bool IsFixedCellHeight() const { return bIsFixedCellHeight; }
732
733 EditPaM Clear();
734 EditPaM RemoveText();
735 EditPaM RemoveChars( EditPaM aPaM, sal_uInt16 nChars );
736 void InsertText( const EditPaM& rPaM, xub_Unicode c );
737 EditPaM InsertText( EditPaM aPaM, const XubString& rStr );
738 EditPaM InsertParaBreak( EditPaM aPaM, sal_Bool bKeepEndingAttribs );
739 EditPaM InsertFeature( EditPaM aPaM, const SfxPoolItem& rItem );
740 EditPaM ConnectParagraphs( ContentNode* pLeft, ContentNode* pRight );
741
742 String GetText( LineEnd eEnd ) const;
743 sal_uLong GetTextLen() const;
744
745 XubString GetParaAsString( sal_uInt16 nNode ) const;
746 XubString GetParaAsString( ContentNode* pNode, sal_uInt16 nStartPos = 0, sal_uInt16 nEndPos = 0xFFFF, sal_Bool bResolveFields = sal_True ) const;
747
748 inline EditPaM GetStartPaM() const;
749 inline EditPaM GetEndPaM() const;
750
GetItemPool()751 SfxItemPool& GetItemPool() { return *pItemPool; }
GetItemPool() const752 const SfxItemPool& GetItemPool() const { return *pItemPool; }
753
754 void RemoveItemsFromPool( ContentNode* pNode );
755
756 void InsertAttrib( const SfxPoolItem& rItem, ContentNode* pNode, sal_uInt16 nStart, sal_uInt16 nEnd );
757 void InsertAttrib( ContentNode* pNode, sal_uInt16 nStart, sal_uInt16 nEnd, const SfxPoolItem& rPoolItem );
758 void InsertAttribInSelection( ContentNode* pNode, sal_uInt16 nStart, sal_uInt16 nEnd, const SfxPoolItem& rPoolItem );
759 sal_Bool RemoveAttribs( ContentNode* pNode, sal_uInt16 nStart, sal_uInt16 nEnd, sal_uInt16 nWhich = 0 );
760 sal_Bool RemoveAttribs( ContentNode* pNode, sal_uInt16 nStart, sal_uInt16 nEnd, EditCharAttrib*& rpStarting, EditCharAttrib*& rpEnding, sal_uInt16 nWhich = 0 );
761 void FindAttribs( ContentNode* pNode, sal_uInt16 nStartPos, sal_uInt16 nEndPos, SfxItemSet& rCurSet );
762
GetPos(ContentNode * pNode) const763 sal_uInt16 GetPos( ContentNode* pNode ) const { return ContentList::GetPos(pNode); }
SaveGetObject(sal_uInt16 nPos) const764 ContentNode* SaveGetObject( sal_uInt16 nPos ) const { return ( nPos < Count() ) ? GetObject( nPos ) : 0; }
765
766 static XubString GetSepStr( LineEnd eEnd );
767 };
768
GetStartPaM() const769 inline EditPaM EditDoc::GetStartPaM() const
770 {
771 return EditPaM( GetObject( 0 ), 0 );
772 }
773
GetEndPaM() const774 inline EditPaM EditDoc::GetEndPaM() const
775 {
776 ContentNode* pLastNode = GetObject( Count()-1 );
777 return EditPaM( pLastNode, pLastNode->Len() );
778 }
779
GetAttrib(const CharAttribArray & rAttribs,sal_uInt16 nAttr)780 inline EditCharAttrib* GetAttrib( const CharAttribArray& rAttribs, sal_uInt16 nAttr )
781 {
782 return ( nAttr < rAttribs.Count() ) ? rAttribs[nAttr] : 0;
783 }
784
785 sal_Bool CheckOrderedList( CharAttribArray& rAttribs, sal_Bool bStart );
786
787 // -------------------------------------------------------------------------
788 // class EditEngineItemPool
789 // -------------------------------------------------------------------------
790 class EditEngineItemPool : public SfxItemPool
791 {
792 public:
793 EditEngineItemPool( sal_Bool bPersistenRefCounts );
794 protected:
795 virtual ~EditEngineItemPool();
796 public:
797
798 virtual SvStream& Store( SvStream& rStream ) const;
799 };
800
801 #endif // _EDITDOC_HXX
802