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 <baselist.hxx>
32 #include <editattr.hxx>
33 #include <edtspell.hxx>
34 #include <editeng/svxfont.hxx>
35 #include <svl/itemset.hxx>
36 #include <svl/style.hxx>
37 #include <svl/itempool.hxx>
38 #include <tools/table.hxx>
39
40 #include <deque>
41
42 class ImpEditEngine;
43 class SvxTabStop;
44 class SvtCTLOptions;
45
46 DBG_NAMEEX( EE_TextPortion )
47
48 #define CHARPOSGROW 16
49 #define DEFTAB 720
50
51 void CreateFont( SvxFont& rFont, const SfxItemSet& rSet, bool bSearchInParent = true, short nScriptType = 0 );
52 sal_uInt16 GetScriptItemId( sal_uInt16 nItemId, short nScriptType );
53 sal_Bool IsScriptItemValid( sal_uInt16 nItemId, short nScriptType );
54
55 EditCharAttrib* MakeCharAttrib( SfxItemPool& rPool, const SfxPoolItem& rAttr, sal_uInt16 nS, sal_uInt16 nE );
56
57 class ContentNode;
58 class EditDoc;
59
60 struct EPaM
61 {
62 sal_uInt32 nPara;
63 sal_uInt16 nIndex;
64
EPaMEPaM65 EPaM() { nPara = 0; nIndex = 0; }
EPaMEPaM66 EPaM( sal_uInt32 nP, sal_uInt16 nI ) { nPara = nP; nIndex = nI; }
EPaMEPaM67 EPaM( const EPaM& r) { nPara = r.nPara; nIndex = r.nIndex; }
operator =EPaM68 EPaM& operator = ( const EPaM& r ) { nPara = r.nPara; nIndex = r.nIndex; return *this; }
69 inline sal_Bool operator == ( const EPaM& r ) const;
70 inline sal_Bool operator < ( const EPaM& r ) const;
71 };
72
operator <(const EPaM & r) const73 inline sal_Bool EPaM::operator < ( const EPaM& r ) const
74 {
75 return ( ( nPara < r.nPara ) ||
76 ( ( nPara == r.nPara ) && nIndex < r.nIndex ) ) ? sal_True : sal_False;
77 }
78
operator ==(const EPaM & r) const79 inline sal_Bool EPaM::operator == ( const EPaM& r ) const
80 {
81 return ( ( nPara == r.nPara ) && ( nIndex == r.nIndex ) ) ? sal_True : sal_False;
82 }
83
84 struct ScriptTypePosInfo
85 {
86 short nScriptType;
87 sal_uInt16 nStartPos;
88 sal_uInt16 nEndPos;
89
ScriptTypePosInfoScriptTypePosInfo90 ScriptTypePosInfo( short _Type, sal_uInt16 _Start, sal_uInt16 _End )
91 {
92 nScriptType = _Type;
93 nStartPos = _Start;
94 nEndPos = _End;
95 }
96 };
97
98 typedef std::deque< ScriptTypePosInfo > ScriptTypePosInfos;
99
100 struct WritingDirectionInfo
101 {
102 sal_uInt8 nType;
103 sal_uInt16 nStartPos;
104 sal_uInt16 nEndPos;
105
WritingDirectionInfoWritingDirectionInfo106 WritingDirectionInfo( sal_uInt8 _Type, sal_uInt16 _Start, sal_uInt16 _End )
107 {
108 nType = _Type;
109 nStartPos = _Start;
110 nEndPos = _End;
111 }
112 };
113
114
115 typedef std::deque< WritingDirectionInfo > WritingDirectionInfos;
116
117 typedef EditCharAttrib* EditCharAttribPtr;
118 SV_DECL_PTRARR( CharAttribArray, EditCharAttribPtr, 0, 4 )
119
120 class ContentAttribsInfo
121 {
122 private:
123 SfxItemSet aPrevParaAttribs;
124 CharAttribArray aPrevCharAttribs;
125
126 public:
127 ContentAttribsInfo( const SfxItemSet& rParaAttribs );
128
GetPrevParaAttribs() const129 const SfxItemSet& GetPrevParaAttribs() const { return aPrevParaAttribs; }
GetPrevCharAttribs() const130 const CharAttribArray& GetPrevCharAttribs() const { return aPrevCharAttribs; }
131
GetPrevCharAttribs()132 CharAttribArray& GetPrevCharAttribs() { return aPrevCharAttribs; }
133 };
134
135 typedef ContentAttribsInfo* ContentAttribsInfoPtr;
136 SV_DECL_PTRARR( ContentInfoArray, ContentAttribsInfoPtr, 1, 1 )
137
138 // ----------------------------------------------------------------------
139 // class SvxFontTable
140 // ----------------------------------------------------------------------
141 DECLARE_TABLE( DummyFontTable, SvxFontItem* )
142 class SvxFontTable : public DummyFontTable
143 {
144 public:
145 SvxFontTable();
146 ~SvxFontTable();
147
148 sal_uLong GetId( const SvxFontItem& rFont );
149 };
150
151 // ----------------------------------------------------------------------
152 // class SvxColorList
153 // ----------------------------------------------------------------------
154 typedef ContentNode* ContentNodePtr;
155 DECLARE_LIST( DummyColorList, SvxColorItem* )
156 class SvxColorList : public DummyColorList
157 {
158 public:
159 SvxColorList();
160 ~SvxColorList();
161
162 sal_uLong GetId( const SvxColorItem& rColor );
163 };
164
165 // ----------------------------------------------------------------------
166 // class ItemList
167 // ----------------------------------------------------------------------
168 typedef const SfxPoolItem* ConstPoolItemPtr;
169 DECLARE_LIST( DummyItemList, ConstPoolItemPtr )
170 class ItemList : public DummyItemList
171 {
172 public:
173 const SfxPoolItem* FindAttrib( sal_uInt16 nWhich );
174 };
175
176 // -------------------------------------------------------------------------
177 // class ContentAttribs
178 // -------------------------------------------------------------------------
179 class ContentAttribs
180 {
181 private:
182 SfxStyleSheet* pStyle;
183 SfxItemSet aAttribSet;
184
185 public:
186 ContentAttribs( SfxItemPool& rItemPool );
187 ContentAttribs( const ContentAttribs& );
188 ~ContentAttribs(); // erst bei umfangreicheren Tabs
189
190 SvxTabStop FindTabStop( long nCurPos, sal_uInt16 nDefTab );
GetItems()191 SfxItemSet& GetItems() { return aAttribSet; }
GetStyleSheet() const192 SfxStyleSheet* GetStyleSheet() const { return pStyle; }
193 void SetStyleSheet( SfxStyleSheet* pS );
194
195 const SfxPoolItem& GetItem( sal_uInt16 nWhich );
196 sal_Bool HasItem( sal_uInt16 nWhich );
197 };
198
199 // -------------------------------------------------------------------------
200 // class CharAttribList
201 // -------------------------------------------------------------------------
202 class CharAttribList
203 {
204 private:
205 CharAttribArray aAttribs;
206 SvxFont aDefFont; // schneller, als jedesmal vom Pool!
207 sal_Bool bHasEmptyAttribs;
208
CharAttribList(const CharAttribList &)209 CharAttribList( const CharAttribList& ) {;}
210
211 public:
212 CharAttribList();
213 ~CharAttribList();
214
215 void DeleteEmptyAttribs( SfxItemPool& rItemPool );
216 void RemoveItemsFromPool( SfxItemPool* pItemPool );
217
218 EditCharAttrib* FindAttrib( sal_uInt16 nWhich, sal_uInt16 nPos );
219 EditCharAttrib* FindNextAttrib( sal_uInt16 nWhich, sal_uInt16 nFromPos ) const;
220 EditCharAttrib* FindEmptyAttrib( sal_uInt16 nWhich, sal_uInt16 nPos );
221 EditCharAttrib* FindFeature( sal_uInt16 nPos ) const;
222
223
224 void ResortAttribs();
225 void OptimizeRanges( SfxItemPool& rItemPool );
226
Count()227 sal_uInt16 Count() { return aAttribs.Count(); }
Clear()228 void Clear() { aAttribs.Remove( 0, aAttribs.Count()); }
229 void InsertAttrib( EditCharAttrib* pAttrib );
230
GetDefFont()231 SvxFont& GetDefFont() { return aDefFont; }
232
HasEmptyAttribs() const233 sal_Bool HasEmptyAttribs() const { return bHasEmptyAttribs; }
HasEmptyAttribs()234 sal_Bool& HasEmptyAttribs() { return bHasEmptyAttribs; }
235 sal_Bool HasBoundingAttrib( sal_uInt16 nBound );
236 sal_Bool HasAttrib( sal_uInt16 nWhich ) const;
237 sal_Bool HasAttrib( sal_uInt16 nStartPos, sal_uInt16 nEndPos ) const;
238
GetAttribs()239 CharAttribArray& GetAttribs() { return aAttribs; }
GetAttribs() const240 const CharAttribArray& GetAttribs() const { return aAttribs; }
241
242 // Debug:
243 sal_Bool DbgCheckAttribs();
244 };
245
246 // -------------------------------------------------------------------------
247 // class ContentNode
248 // -------------------------------------------------------------------------
249 class ContentNode : public XubString
250 {
251 private:
252 ContentAttribs aContentAttribs;
253 CharAttribList aCharAttribList;
254 WrongList* pWrongList;
255
256 public:
257 ContentNode( SfxItemPool& rItemPool );
258 ContentNode( const XubString& rStr, const ContentAttribs& rContentAttribs );
259 ~ContentNode();
260
GetContentAttribs()261 ContentAttribs& GetContentAttribs() { return aContentAttribs; }
GetCharAttribs()262 CharAttribList& GetCharAttribs() { return aCharAttribList; }
263
264 void ExpandAttribs( sal_uInt16 nIndex, sal_uInt16 nNewChars, SfxItemPool& rItemPool );
265 void CollapsAttribs( sal_uInt16 nIndex, sal_uInt16 nDelChars, SfxItemPool& rItemPool );
266 void AppendAttribs( ContentNode* pNextNode );
267 void CopyAndCutAttribs( ContentNode* pPrevNode, SfxItemPool& rPool, sal_Bool bKeepEndingAttribs );
268
269 void SetStyleSheet( SfxStyleSheet* pS, sal_Bool bRecalcFont = sal_True );
270 void SetStyleSheet( SfxStyleSheet* pS, const SvxFont& rFontFromStyle );
GetStyleSheet()271 SfxStyleSheet* GetStyleSheet() { return aContentAttribs.GetStyleSheet(); }
272
273 void CreateDefFont();
274
GetWrongList()275 WrongList* GetWrongList() { return pWrongList; }
276 void SetWrongList( WrongList* p );
277
278 void CreateWrongList();
279 void DestroyWrongList();
280
IsFeature(sal_uInt16 nPos) const281 sal_Bool IsFeature( sal_uInt16 nPos ) const { return ( GetChar( nPos ) == CH_FEATURE ); }
282 };
283
284 typedef ContentNode* ContentNodePtr;
285
286 class ContentList : public BaseList<ContentNode>
287 {
288 sal_uInt32 nLastCache;
289 public:
ContentList()290 ContentList() : nLastCache(0) {}
291 sal_uInt32 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 EditPaM(const EditPaM&) = default;
321 friend sal_Bool operator == ( const EditPaM& r1, const EditPaM& r2 );
322 friend sal_Bool operator != ( const EditPaM& r1, const EditPaM& r2 );
323 };
324
325 #define PORTIONKIND_TEXT 0
326 #define PORTIONKIND_TAB 1
327 #define PORTIONKIND_LINEBREAK 2
328 #define PORTIONKIND_FIELD 3
329 #define PORTIONKIND_HYPHENATOR 4
330 // #define PORTIONKIND_EXTRASPACE 5
331
332 #define DELMODE_SIMPLE 0
333 #define DELMODE_RESTOFWORD 1
334 #define DELMODE_RESTOFCONTENT 2
335
336 #define CHAR_NORMAL 0x00
337 #define CHAR_KANA 0x01
338 #define CHAR_PUNCTUATIONLEFT 0x02
339 #define CHAR_PUNCTUATIONRIGHT 0x04
340
341 // -------------------------------------------------------------------------
342 // struct ExtraPortionInfos
343 // -------------------------------------------------------------------------
344 struct ExtraPortionInfo
345 {
346 long nOrgWidth;
347 long nWidthFullCompression;
348
349 long nPortionOffsetX;
350
351 sal_uInt16 nMaxCompression100thPercent;
352
353 sal_uInt8 nAsianCompressionTypes;
354 sal_Bool bFirstCharIsRightPunktuation;
355 sal_Bool bCompressed;
356
357 sal_Int32* pOrgDXArray;
358
359
360 ExtraPortionInfo();
361 ~ExtraPortionInfo();
362
363 void SaveOrgDXArray( const sal_Int32* pDXArray, sal_uInt16 nLen );
364 void DestroyOrgDXArray();
365 };
366
367
368 // -------------------------------------------------------------------------
369 // class TextPortion
370 // -------------------------------------------------------------------------
371 class TextPortion
372 {
373 private:
374 ExtraPortionInfo* pExtraInfos;
375 sal_uInt16 nLen;
376 Size aOutSz;
377 sal_uInt8 nKind;
378 sal_uInt8 nRightToLeft;
379 sal_Unicode nExtraValue;
380
381
TextPortion()382 TextPortion() { DBG_CTOR( EE_TextPortion, 0 );
383 pExtraInfos = NULL; nLen = 0; nKind = PORTIONKIND_TEXT; nExtraValue = 0; nRightToLeft = sal_False;}
384
385 public:
TextPortion(sal_uInt16 nL)386 TextPortion( sal_uInt16 nL ) : aOutSz( -1, -1 )
387 { DBG_CTOR( EE_TextPortion, 0 );
388 pExtraInfos = NULL; nLen = nL; nKind = PORTIONKIND_TEXT; nExtraValue = 0; nRightToLeft = sal_False;}
TextPortion(const TextPortion & r)389 TextPortion( const TextPortion& r ) : aOutSz( r.aOutSz )
390 { DBG_CTOR( EE_TextPortion, 0 );
391 pExtraInfos = NULL; nLen = r.nLen; nKind = r.nKind; nExtraValue = r.nExtraValue; nRightToLeft = r.nRightToLeft; }
392
~TextPortion()393 ~TextPortion() { DBG_DTOR( EE_TextPortion, 0 ); delete pExtraInfos; }
394
GetLen() const395 sal_uInt16 GetLen() const { return nLen; }
GetLen()396 sal_uInt16& GetLen() { return nLen; }
SetLen(sal_uInt16 nL)397 void SetLen( sal_uInt16 nL ) { nLen = nL; }
398
GetSize()399 Size& GetSize() { return aOutSz; }
GetSize() const400 Size GetSize() const { return aOutSz; }
401
GetKind()402 sal_uInt8& GetKind() { return nKind; }
GetKind() const403 sal_uInt8 GetKind() const { return nKind; }
404
SetRightToLeft(sal_uInt8 b)405 void SetRightToLeft( sal_uInt8 b ) { nRightToLeft = b; }
GetRightToLeft() const406 sal_uInt8 GetRightToLeft() const { return nRightToLeft; }
IsRightToLeft() const407 sal_Bool IsRightToLeft() const { return (nRightToLeft&1); }
408
GetExtraValue() const409 sal_Unicode GetExtraValue() const { return nExtraValue; }
SetExtraValue(sal_Unicode n)410 void SetExtraValue( sal_Unicode n ) { nExtraValue = n; }
411
HasValidSize() const412 sal_Bool HasValidSize() const { return aOutSz.Width() != (-1); }
413
GetExtraInfos() const414 ExtraPortionInfo* GetExtraInfos() const { return pExtraInfos; }
SetExtraInfos(ExtraPortionInfo * p)415 void SetExtraInfos( ExtraPortionInfo* p ) { delete pExtraInfos; pExtraInfos = p; }
416 };
417
418 // -------------------------------------------------------------------------
419 // class TextPortionList
420 // -------------------------------------------------------------------------
421 typedef TextPortion* TextPortionPtr;
422 SV_DECL_PTRARR( TextPortionArray, TextPortionPtr, 0, 8 )
423
424 class TextPortionList : public TextPortionArray
425 {
426 public:
427 TextPortionList();
428 ~TextPortionList();
429
430 void Reset();
431 sal_uInt16 FindPortion( sal_uInt16 nCharPos, sal_uInt16& rPortionStart, sal_Bool bPreferStartingPortion = sal_False );
432 sal_uInt16 GetStartPos( sal_uInt16 nPortion );
433 void DeleteFromPortion( sal_uInt16 nDelFrom );
434 };
435
436 class ParaPortion;
437
438 SV_DECL_VARARR( CharPosArray, sal_Int32, 0, CHARPOSGROW )
439
440 // ------------------------------------------------------------------------
441 // class EditLine
442 // -------------------------------------------------------------------------
443 class EditLine
444 {
445 private:
446 CharPosArray aPositions;
447 long nTxtWidth;
448 sal_uInt16 nStartPosX;
449 sal_uInt16 nStart; // koennte durch nStartPortion ersetzt werden
450 sal_uInt16 nEnd; // koennte durch nEndPortion ersetzt werden
451 sal_uInt16 nStartPortion; // index of TextPortion in TextPortionList
452 sal_uInt16 nEndPortion; // index of TextPortion in TextPortionList
453 sal_uInt16 nHeight; // Gesamthoehe der Zeile
454 sal_uInt16 nTxtHeight; // Reine Texthoehe
455 sal_uInt16 nCrsrHeight; // Bei Konturfluss hohe Zeilen => Cursor zu gro?.
456 sal_uInt16 nMaxAscent;
457 sal_Bool bHangingPunctuation;
458 sal_Bool bInvalid; // fuer geschickte Formatierung
459
460 public:
461 EditLine();
462 EditLine( const EditLine& );
463 ~EditLine();
464
IsIn(sal_uInt16 nIndex) const465 sal_Bool IsIn( sal_uInt16 nIndex ) const
466 { return ( (nIndex >= nStart ) && ( nIndex < nEnd ) ); }
467
IsIn(sal_uInt16 nIndex,sal_Bool bInclEnd) const468 sal_Bool IsIn( sal_uInt16 nIndex, sal_Bool bInclEnd ) const
469 { return ( ( nIndex >= nStart ) && ( bInclEnd ? ( nIndex <= nEnd ) : ( nIndex < nEnd ) ) ); }
470
SetStart(sal_uInt16 n)471 void SetStart( sal_uInt16 n ) { nStart = n; }
GetStart() const472 sal_uInt16 GetStart() const { return nStart; }
GetStart()473 sal_uInt16& GetStart() { return nStart; }
474
SetEnd(sal_uInt16 n)475 void SetEnd( sal_uInt16 n ) { nEnd = n; }
GetEnd() const476 sal_uInt16 GetEnd() const { return nEnd; }
GetEnd()477 sal_uInt16& GetEnd() { return nEnd; }
478
SetStartPortion(sal_uInt16 n)479 void SetStartPortion( sal_uInt16 n ) { nStartPortion = n; }
GetStartPortion() const480 sal_uInt16 GetStartPortion() const { return nStartPortion; }
GetStartPortion()481 sal_uInt16& GetStartPortion() { return nStartPortion; }
482
SetEndPortion(sal_uInt16 n)483 void SetEndPortion( sal_uInt16 n ) { nEndPortion = n; }
GetEndPortion() const484 sal_uInt16 GetEndPortion() const { return nEndPortion; }
GetEndPortion()485 sal_uInt16& GetEndPortion() { return nEndPortion; }
486
SetHeight(sal_uInt16 nH,sal_uInt16 nTxtH=0,sal_uInt16 nCrsrH=0)487 void SetHeight( sal_uInt16 nH, sal_uInt16 nTxtH = 0, sal_uInt16 nCrsrH = 0 )
488 { nHeight = nH;
489 nTxtHeight = ( nTxtH ? nTxtH : nH );
490 nCrsrHeight = ( nCrsrH ? nCrsrH : nTxtHeight );
491 }
GetHeight() const492 sal_uInt16 GetHeight() const { return nHeight; }
GetTxtHeight() const493 sal_uInt16 GetTxtHeight() const { return nTxtHeight; }
GetCrsrHeight() const494 sal_uInt16 GetCrsrHeight() const { return nCrsrHeight; }
495
SetTextWidth(long n)496 void SetTextWidth( long n ) { nTxtWidth = n; }
GetTextWidth() const497 long GetTextWidth() const { return nTxtWidth; }
498
SetMaxAscent(sal_uInt16 n)499 void SetMaxAscent( sal_uInt16 n ) { nMaxAscent = n; }
GetMaxAscent() const500 sal_uInt16 GetMaxAscent() const { return nMaxAscent; }
501
SetHangingPunctuation(sal_Bool b)502 void SetHangingPunctuation( sal_Bool b ) { bHangingPunctuation = b; }
IsHangingPunctuation() const503 sal_Bool IsHangingPunctuation() const { return bHangingPunctuation; }
504
GetLen() const505 sal_uInt16 GetLen() const { return nEnd - nStart; }
506
GetStartPosX() const507 sal_uInt16 GetStartPosX() const { return nStartPosX; }
SetStartPosX(sal_uInt16 start)508 void SetStartPosX( sal_uInt16 start ) { nStartPosX = start; }
509
510 Size CalcTextSize( ParaPortion& rParaPortion );
511
IsInvalid() const512 sal_Bool IsInvalid() const { return bInvalid; }
IsValid() const513 sal_Bool IsValid() const { return !bInvalid; }
SetInvalid()514 void SetInvalid() { bInvalid = sal_True; }
SetValid()515 void SetValid() { bInvalid = sal_False; }
516
IsEmpty() const517 sal_Bool IsEmpty() const { return (nEnd > nStart) ? sal_False : sal_True; }
518
GetCharPosArray()519 CharPosArray& GetCharPosArray() { return aPositions; }
520
521 EditLine* Clone() const;
522
523 EditLine& operator = ( const EditLine& rLine );
524 friend sal_Bool operator == ( const EditLine& r1, const EditLine& r2 );
525 friend sal_Bool operator != ( const EditLine& r1, const EditLine& r2 );
526 };
527
528
529 // -------------------------------------------------------------------------
530 // class LineList
531 // -------------------------------------------------------------------------
532 typedef EditLine* EditLinePtr;
533 SV_DECL_PTRARR( LineArray, EditLinePtr, 0, 4 )
534
535 class EditLineList : public LineArray
536 {
537 public:
538 EditLineList();
539 ~EditLineList();
540
541 void Reset();
542 void DeleteFromLine( sal_uInt16 nDelFrom );
543 sal_uInt16 FindLine( sal_uInt16 nChar, sal_Bool bInclEnd );
544 };
545
546 // -------------------------------------------------------------------------
547 // class ParaPortion
548 // -------------------------------------------------------------------------
549 class ParaPortion
550 {
551 friend class ImpEditEngine; // zum Einstellen der Hoehe
552 private:
553 EditLineList aLineList;
554 TextPortionList aTextPortionList;
555 ContentNode* pNode;
556 long nHeight;
557
558 ScriptTypePosInfos aScriptInfos;
559 WritingDirectionInfos aWritingDirectionInfos;
560
561 sal_uInt16 nInvalidPosStart;
562 sal_uInt16 nFirstLineOffset; // Fuer Writer-LineSpacing-Interpretation
563 sal_uInt16 nBulletX;
564 short nInvalidDiff;
565
566 sal_Bool bInvalid : 1;
567 sal_Bool bSimple : 1; // nur lineares Tippen
568 sal_Bool bVisible : 1; // MT 05/00: Gehoert an den Node!!!
569 sal_Bool bForceRepaint : 1;
570
571 ParaPortion( const ParaPortion& );
572
573 public:
574 ParaPortion( ContentNode* pNode );
575 ~ParaPortion();
576
577 sal_uInt16 GetLineNumber( sal_uInt16 nIndex );
578
GetLines()579 EditLineList& GetLines() { return aLineList; }
580
IsInvalid() const581 sal_Bool IsInvalid() const { return bInvalid; }
IsSimpleInvalid() const582 sal_Bool IsSimpleInvalid() const { return bSimple; }
SetValid()583 void SetValid() { bInvalid = sal_False; bSimple = sal_True;}
584
MustRepaint() const585 sal_Bool MustRepaint() const { return bForceRepaint; }
SetMustRepaint(sal_Bool bRP)586 void SetMustRepaint( sal_Bool bRP ) { bForceRepaint = bRP; }
587
GetBulletX() const588 sal_uInt16 GetBulletX() const { return nBulletX; }
SetBulletX(sal_uInt16 n)589 void SetBulletX( sal_uInt16 n ) { nBulletX = n; }
590
591 void MarkInvalid( sal_uInt16 nStart, short nDiff);
592 void MarkSelectionInvalid( sal_uInt16 nStart, sal_uInt16 nEnd );
593
594 void SetVisible( sal_Bool bVisible );
IsVisible()595 sal_Bool IsVisible() { return bVisible; }
596
GetHeight() const597 long GetHeight() const { return ( bVisible ? nHeight : 0 ); }
GetFirstLineOffset() const598 sal_uInt16 GetFirstLineOffset() const { return ( bVisible ? nFirstLineOffset : 0 ); }
ResetHeight()599 void ResetHeight() { nHeight = 0; nFirstLineOffset = 0; }
600
GetNode() const601 ContentNode* GetNode() const { return pNode; }
GetTextPortions()602 TextPortionList& GetTextPortions() { return aTextPortionList; }
603
GetInvalidPosStart() const604 sal_uInt16 GetInvalidPosStart() const { return nInvalidPosStart; }
GetInvalidDiff() const605 short GetInvalidDiff() const { return nInvalidDiff; }
606
607 void CorrectValuesBehindLastFormattedLine( sal_uInt16 nLastFormattedLine );
608
609 sal_Bool DbgCheckTextPortions();
610 };
611
612 typedef ParaPortion* ParaPortionPtr;
613
614 // -------------------------------------------------------------------------
615 // class ParaPortionList
616 // -------------------------------------------------------------------------
617 class ParaPortionList : public BaseList<ParaPortion>
618 {
619 sal_uInt32 nLastCache;
620 public:
621 ParaPortionList();
622 ~ParaPortionList();
623
624 void Reset();
625 long GetYOffset( ParaPortion* pPPortion );
626 sal_uInt32 FindParagraph( long nYOffset );
627
SaveGetObject(sal_uInt32 nPos) const628 inline ParaPortion* SaveGetObject( sal_uInt32 nPos ) const
629 { return ( nPos < Count() ) ? GetObject( nPos ) : 0; }
630
631 sal_uInt32 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_uInt32 nInvalidParagraph;
678
679 public:
DeletedNodeInfo(sal_uIntPtr nInvAdr,sal_uInt32 nPos)680 DeletedNodeInfo( sal_uIntPtr nInvAdr, sal_uInt32 nPos )
681 { nInvalidAdressPtr = nInvAdr;
682 nInvalidParagraph = nPos; }
683
GetInvalidAdress()684 sal_uIntPtr GetInvalidAdress() { return nInvalidAdressPtr; }
GetPosition()685 sal_uInt32 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_uInt32 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_uInt32 GetPos( ContentNode* pNode ) const { return ContentList::GetPos(pNode); }
SaveGetObject(sal_uInt32 nPos) const764 ContentNode* SaveGetObject( sal_uInt32 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