xref: /AOO41X/main/sw/source/core/inc/txtfrm.hxx (revision ff0525f24f03981d56b7579b645949f111420994)
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 #ifndef SW_TXTFRM_HXX
24 #define SW_TXTFRM_HXX
25 
26 #include <tools/mempool.hxx>
27 #include <tools/string.hxx>
28 #include "cntfrm.hxx"
29 
30 #define STRSIZE(x) (sizeof(x)-1)
31 
32 class SwCharRange;
33 class SwTxtNode;
34 class SwTxtFormatter;
35 class SwTxtFormatInfo;
36 class SwParaPortion;
37 class WidowsAndOrphans;
38 class SwBodyFrm;
39 class SwTxtFtn;
40 class SwInterHyphInfo;      // Hyphenate()
41 class SwCache;
42 class SwBorderAttrs;
43 class SwFrmFmt;
44 class OutputDevice;
45 class SwTestFormat;
46 struct SwCrsrMoveState;
47 struct SwFillData;
48 class SwPortionHandler;
49 class SwScriptInfo;
50 class SwViewOption;
51 class SwWrongList;
52 
53 #define GRID_ON         0
54 #define GRID_HEIGHT     1
55 #define RUBY_HEIGHT     2
56 #define RUBY_TOP        3
57 #define GRID_CELLS      4
58 
59 class SwTxtFrm: public SwCntntFrm
60 {
61     friend class SwTxtIter;
62     friend class SwTestFormat;
63     friend class WidowsAndOrphans;
64     friend class SwTxtFrmLocker;        // duerfen Lock()/Unlock()
65     friend sal_Bool lcl_ChangeOffset( SwTxtFrm* pFrm, sal_uInt16 nNew );
66 
67     static SwCache *pTxtCache;  //Pointer auf den Line-Cache
68     static long nMinPrtLine;    //Diese Linie darf beim Drucken nicht
69         //unterschritten werden, Hack fuer Tabellenzellen ueber mehrere Seiten
70 
71     sal_uLong  nAllLines        :24;//Anzahl der Zeilen fuer das Paint (inkl. nThisLines)
72     sal_uLong  nThisLines       :8; //Anzahl der Zeilen dieses Frames
73 
74     // The x position for flys anchored at this paragraph.
75     // These values are calculated in SwTxtFrm::CalcBaseOfstForFly()
76     SwTwips mnFlyAnchorOfst;
77     // The x position for wrap-through flys anchored at this paragraph.
78     SwTwips mnFlyAnchorOfstNoWrap;
79     SwTwips mnFtnLine;
80     // OD 2004-03-17 #i11860# - re-factoring of #i11859#
81     // member for height of last line (value needed for proportional line spacing)
82     SwTwips mnHeightOfLastLine;
83     // --> OD 2008-01-31 #newlistlevelattrs#
84     // member for the additional first line offset, which is caused by the list
85     // label alignment for list level position and space mode LABEL_ALIGNMENT.
86     // This additional first line offset is used for the text formatting.
87     // It is NOT used for the determination of printing area.
88     SwTwips mnAdditionalFirstLineOffset;
89     // <--
90 
91 
92     xub_StrLen nOfst;           //nOfst gibt den Offset im Cntnt (Anzahl Zeichen) an.
93 
94     sal_uInt16 nCacheIdx;           //Index in den Cache, USHRT_MAX wenn definitiv
95                                 //kein passendes Objekt im Cache steht.
96 
97     //Teilt den Master ab und erzeugt einen Follow oder passt die
98     //Daten im Follow an.
99            void _AdjustFollow( SwTxtFormatter &rLine, const xub_StrLen nOffset,
100                                const xub_StrLen nStrEnd, const sal_uInt8 nMode );
101     inline void AdjustFollow( SwTxtFormatter &rLine, const xub_StrLen nOffset,
102                               const xub_StrLen nStrEnd, const sal_uInt8 nMode );
103 
104     //Iteriert ueber alle Zeilen und stellt das Linespacing
105     //entsprechend dem Attribut ein.
106     void CalcLineSpace();
107 
108     void InitCtor();        // Wird in beiden Ctoren gerufen
109 
110     // Wird nur in Format gerufen:
111     void AdjustFrm( const SwTwips nChgHeight, sal_Bool bHasToFit = sal_False );
112 
113     // wertet in Format() die Preps aus.
114     sal_Bool CalcPreps();
115     void PrepWidows( const sal_uInt16 nNeed, sal_Bool bNotify = sal_True );
116     void _InvalidateRange( const SwCharRange &, const long = 0);
117     inline void InvalidateRange( const SwCharRange &, const long = 0);
118 
119     // WidowsAndOrphans, AdjustFrm, AdjustFollow
120     void FormatAdjust( SwTxtFormatter &rLine, WidowsAndOrphans &rFrmBreak,
121                        const xub_StrLen nStrLen, const sal_Bool bDummy );
122 
123     sal_Bool bLocked        : 1;        // im Format?
124     sal_Bool bFormatted     : 1;        // nach Format auf sal_True
125     sal_Bool bWidow         : 1;        // sind wir ein Widow
126     sal_Bool bJustWidow     : 1;        // haben wir soeben Widow angefordert
127     sal_Bool bEmpty         : 1;        // sind wir ein leerer Absatz
128     sal_Bool bInFtnConnect  : 1;        // Steht gerade im Connect
129     sal_Bool bFtn           : 1;        // Hat mindestens eine Fussnote
130     sal_Bool bRepaint       : 1;        // TxtFrm: Repaint steht zur Abholung bereit
131     sal_Bool bBlinkPor      : 1;        // enthaelt Blink-Portions
132     sal_Bool bFieldFollow   : 1;        // beginne mit Feldrest des Masters
133     sal_Bool bHasAnimation  : 1;        // enthaelt animierte SwGrfNumPortion
134     sal_Bool bIsSwapped     : 1;        // during text formatting we swap the
135                                         // width and height for vertical formatting
136     // OD 14.03.2003 #i11760# - flag to control, if follow is formatted in
137     // method <CalcFollow(..)>.
138     // E.g., avoid formatting of follow, if method <SwLayoutFrm::FormatWidthCols(..)>
139     // is running.
140     sal_Bool mbFollowFormatAllowed : 1;
141 
142     void ResetPreps();
143     inline void Lock() { bLocked = sal_True; }
144     inline void Unlock() { bLocked = sal_False; }
145     inline void SetFormatted( const sal_Bool bNew ) { bFormatted = bNew; }
146     inline void SetWidow( const sal_Bool bNew ) { bWidow = bNew; }
147     inline void SetJustWidow( const sal_Bool bNew ) { bJustWidow = bNew; }
148     inline void SetEmpty( const sal_Bool bNew ) { bEmpty = bNew; }
149     inline void SetFieldFollow( const sal_Bool bNew ) { bFieldFollow = bNew; }
150 
151     sal_Bool IsIdxInside( const xub_StrLen nPos, const xub_StrLen nLen ) const;
152 
153     // Wechselt den Frame oder auch nicht (vgl. FlyCnt)
154     sal_Bool _GetCrsrOfst(SwPosition *pPos, const Point &rPoint,
155                       const sal_Bool bChgFrm, SwCrsrMoveState* = 0 ) const;
156     void FillCrsrPos( SwFillData &rFill ) const;
157 
158     // formatiert genau eine Zeile ...
159     sal_Bool FormatLine( SwTxtFormatter &rLine, const sal_Bool bPrev );
160 
161     // Um Stack einzusparen aufgeteilt ...
162     // _Format ruft _Format mit Parametern
163     void _Format( SwParaPortion *pPara );
164     void _Format( SwTxtFormatter &rLine, SwTxtFormatInfo &rInf,
165                   const sal_Bool bAdjust = sal_False );
166     void FormatOnceMore( SwTxtFormatter &rLine, SwTxtFormatInfo &rInf );
167 
168     // formatiert den Follow und sorgt fuer die Entsorgung bei Orphans
169     sal_Bool CalcFollow(  const xub_StrLen nTxtOfst );
170 
171     // korrigiert die Stelle ab der formatiert werden muss.
172     xub_StrLen FindBrk(const String &rTxt, const xub_StrLen nStart,
173                                        const xub_StrLen nEnd) const;
174 
175     // inline-Weiche
176     SwTwips _GetFtnFrmHeight() const;
177 
178     // Aus CalcPreps ausgelagert.
179     sal_Bool CalcPrepFtnAdjust();
180 
181     // Fuer Ftn und WidOrp: Zwangsvalidierung
182     void ValidateFrm();
183     void ValidateBodyFrm();
184 
185     sal_Bool _GetDropRect( SwRect &rRect ) const;
186 
187     void SetPara( SwParaPortion *pNew, sal_Bool bDelete = sal_True );
188 
189     sal_Bool _IsFtnNumFrm() const;
190 
191     // 6995: Formatinformationen auffrischen
192     sal_Bool FormatQuick( bool bForceQuickFormat );
193 
194     // Opt: Leere Absaetze formatieren
195     sal_Bool FormatEmpty();
196     SwTwips EmptyHeight() const;
197     // Opt: Leere Absaetze painten
198     sal_Bool PaintEmpty( const SwRect &, sal_Bool bCheck ) const;
199 
200     void ChgThisLines();//Muss immer gerufen werden, wenn sich die Zeilenazahl
201                         //veraendert haben kann.
202 
203     // required for 'new' relative anchor position
204     void CalcBaseOfstForFly();
205 
206     /** method to determine height of last line, needed for proportional line spacing
207 
208         OD 2004-03-17 #i11860#
209         OD 2005-05-20 #i47162# - introduce new optional parameter <_bUseFont>
210         in order to force the usage of the former algorithm to determine the
211         height of the last line, which uses the font.
212 
213         @param _bUseFont
214         optional input parameter - boolean indicating, if the font has to be
215         used to determine the height of the last line. default value: false
216 
217         @author OD
218     */
219     void _CalcHeightOfLastLine( const bool _bUseFont = false );
220 
221     // ST2
222     SwWrongList* _SmartTagScan ( ::rtl::OUString aTxtToScan, SwWrongList *pSmartTagList,
223                                  xub_StrLen nBegin,xub_StrLen nEnd,
224                                  xub_StrLen nInsertPos, xub_StrLen nActPos,
225                                  xub_StrLen &nChgStart, xub_StrLen &nChgEnd,
226                                  xub_StrLen &nInvStart, xub_StrLen &nInvEnd);
227 protected:
228     virtual void Modify( const SfxPoolItem*, const SfxPoolItem* );
229 
230 public:
231 
232     //public, weil der eine oder andere die Methode rufen darf um das
233     //Prepare zu sparen - mit Vorsicht zu geniessen!
234     void Init();
235 
236     // Wird von FormatSpelling( ) gerufen
237     SwRect _AutoSpell( const SwCntntNode*, const SwViewOption&, sal_uInt16 );
238     // is called from the FormatSpelling( ) method
239     SwRect SmartTagScan( SwCntntNode* , sal_uInt16 );
240     // Wird vom CollectAutoCmplWords gerufen
241     void CollectAutoCmplWrds( SwCntntNode* , sal_uInt16 );
242 
243     //Bug 120881:Modify here for Directly Page Numbering
244     sal_Bool HasPageNumberField();
245     //Bug 120881(End)
246 
247     // Returns the screen position of rPos. The values are relative to the upper
248     // left position of the page frame.
249     // Additional information can be obtained by passing an SwCrsrMoveState object.
250     // Returns sal_False if rPos > number of character is string
251     virtual sal_Bool   GetCharRect( SwRect& rRect, const SwPosition& rPos,
252                                 SwCrsrMoveState* pCMS = 0 ) const;
253     // Eine etwas abgespeckte GetCharRect-Version fuer autopositionierte Rahmen
254     sal_Bool GetAutoPos( SwRect &, const SwPosition& ) const;
255 
256     /** determine top of line for given position in the text frame
257 
258         OD 11.11.2003 #i22341#
259         Assumption: given position exists in the text frame or in a follow of it
260         OD 2004-02-02 - adjustment
261         Top of first paragraph line is the top of the paragraph.
262         OD 2004-03-18 #i11860# - Consider upper space amount considered for
263         previous frame and the page grid.
264 
265         @author OD
266 
267         @param _onTopOfLine
268         output parameter - top of line, if the given position is found in the
269         text frame.
270 
271         @param _rPos
272         input parameter - reference to the position in the text frame
273 
274         @return boolean indicating, if the top of line for the given position
275         has been determined or not.
276     */
277     bool GetTopOfLine( SwTwips& _onTopOfLine,
278                        const SwPosition& _rPos ) const;
279 
280     virtual bool FillSelection( SwSelectionList& rList, const SwRect& rRect ) const;
281 
282 
283     //Liefert in nOffset den Offset des Characters innerhalb des
284     //gesetzten Textbuffers zurueck, welcher der durch aPoint
285     //gegebenen Position innerhalb der SSize des Layout am
286     //naechsten ist. Wenn der SPoint ausserhalb der SSize liegt,
287     //liefert die Funktion sal_False, sal_True sonst.
288     virtual sal_Bool GetCrsrOfst( SwPosition *, Point&,
289                                   SwCrsrMoveState* = 0) const;
290 
291     // GetKeyCrsrOfst sorgt dafuer, dass der Frame nicht gewechselt wird
292     // (z.B. Wechsel in den zeichengebundenen Frame).
293     inline  sal_Bool GetKeyCrsrOfst(SwPosition *pPos, const Point &rPoint ) const
294             { return _GetCrsrOfst( pPos, rPoint, sal_False ); }
295 
296     void   PaintExtraData( const SwRect & rRect ) const; //Seitennummer usw.
297     SwRect Paint();
298     virtual void Paint( SwRect const&,
299                         SwPrintData const*const pPrintData = NULL ) const;
300     virtual sal_Bool GetInfo( SfxPoolItem & ) const;
301 
302     //Layoutorientiertes Cursortravelling: Linker, rechter Rand,
303     //vorhergehende/naechste Zeile, gleiche horizontale Position.
304     virtual sal_Bool LeftMargin(SwPaM *) const;
305     virtual sal_Bool RightMargin(SwPaM *, sal_Bool bAPI = sal_False) const;
306 
307     virtual sal_Bool UnitUp(SwPaM *, const SwTwips nOffset = 0,
308                             sal_Bool bSetInReadOnly = sal_False  ) const;
309     virtual sal_Bool UnitDown(SwPaM *, const SwTwips nOffset = 0,
310                             sal_Bool bSetInReadOnly = sal_False ) const;
311     sal_Bool _UnitUp(SwPaM *, const SwTwips nOffset = 0,
312                             sal_Bool bSetInReadOnly = sal_False ) const;
313     sal_Bool _UnitDown(SwPaM *, const SwTwips nOffset = 0,
314                             sal_Bool bSetInReadOnly = sal_False ) const;
315 
316     // Prepares the cursor position for a visual cursor move (BiDi).
317     // The behaviour is different for insert and overwrite cursors
318     void PrepareVisualMove( xub_StrLen& nPos, sal_uInt8& nCrsrLevel,
319                             sal_Bool& bRight, sal_Bool bInsertCrsr );
320 
321     // Methoden zur Verwaltung von FolgeFrames
322            SwCntntFrm *SplitFrm( const xub_StrLen nTxtPos );
323            SwCntntFrm *JoinFrm();
324     inline sal_uInt16      GetOfst() const { return nOfst; }
325            void        _SetOfst( const sal_uInt16 nNewOfst );
326     inline void        SetOfst ( const sal_uInt16 nNewOfst );
327     inline void        ManipOfst ( const sal_uInt16 nNewOfst ){ nOfst = nNewOfst; }
328            SwTxtFrm   *GetFrmAtPos ( const SwPosition &rPos);
329     inline const SwTxtFrm *GetFrmAtPos ( const SwPosition &rPos) const;
330            // OD 07.10.2003 #110978# - return <reference> instead of <pointer>
331     SwTxtFrm&   GetFrmAtOfst( const xub_StrLen nOfst );
332     // Wenn es einen Follow gibt und wir selbst keinen Text enthalten:
333     inline sal_Bool IsEmptyMaster() const
334         { return GetFollow() && !GetFollow()->GetOfst(); }
335 
336     // Liefert den zu bearbeitenden Textausschnitt zurueck (inline, s.u.)
337     const String& GetTxt() const;
338     inline SwTxtNode *GetTxtNode()
339         { return (SwTxtNode*)SwCntntFrm::GetNode(); }
340     inline const SwTxtNode *GetTxtNode() const
341         { return (SwTxtNode*)SwCntntFrm::GetNode(); }
342 
343     SwTxtFrm(SwTxtNode * const, SwFrm* );
344     virtual ~SwTxtFrm();
345 
346     // SwCntntFrm: der "kurze Dienstweg" fuer die Frames.
347     // Wer den void* falsch casted ist selbst Schuld!
348     // Auf jedenfall muss der void* auf 0 geprueft werden.
349     virtual void Prepare( const PrepareHint ePrep = PREP_CLEAR,
350                           const void *pVoid = 0, sal_Bool bNotify = sal_True );
351 
352     // nMaxHeight is the required height
353     // bSplit indicates, that the paragraph has to be split
354     // bTst indicates, that we are currently doing a test formatting
355     virtual sal_Bool WouldFit( SwTwips &nMaxHeight, sal_Bool &bSplit, sal_Bool bTst );
356 
357     // Hier das WouldFit-Aequivalent fuer mal kurz probeweise
358     // umgehaengte TextFrames, auch hier liefert
359     // nMaxHeight die benoetigte Hoehe,
360     // und bSplit sagt, obj der Absatz gesplittet werden muss.
361     // Uebergeben wird der potentielle Vorgaenger fuer die Abstandsberechnung
362     sal_Bool TestFormat( const SwFrm* pPrv, SwTwips &nMaxHeight, sal_Bool &bSplit );
363 
364     // Wir formatieren eine Zeile fuer die interaktive Trennung
365     // Return: found
366     sal_Bool Hyphenate( SwInterHyphInfo &rInf );
367 
368     // Probegrow
369     inline SwTwips GrowTst( const SwTwips nGrow );
370 
371     SwParaPortion *GetPara();
372     inline const SwParaPortion *GetPara() const;
373     inline sal_Bool HasPara() const;
374     sal_Bool _HasPara() const;
375     // If there are any hanging punctuation portions in the margin
376     // the offset will be returned.
377     SwTwips HangingMargin() const;
378 
379     // RTTI
380     TYPEINFO();
381     DECL_FIXEDMEMPOOL_NEWDEL(SwTxtFrm)
382 
383     // Locking
384     inline sal_Bool IsLocked()      const { return bLocked;     }
385     inline sal_Bool IsFormatted()   const { return bFormatted;  }
386 
387     inline sal_Bool IsWidow()       const { return bWidow;      }
388     inline sal_Bool IsJustWidow()   const { return bJustWidow;  }
389     inline sal_Bool IsEmpty()       const { return bEmpty;      }
390     inline sal_Bool HasFtn()        const { return bFtn;        }
391     inline sal_Bool IsInFtnConnect()const { return bInFtnConnect;}
392     inline sal_Bool IsFieldFollow() const { return bFieldFollow;}
393 
394     inline void SetRepaint() const;
395     inline void ResetRepaint() const;
396     inline sal_Bool HasRepaint() const { return bRepaint; }
397     inline void SetBlinkPor() const;
398     inline void ResetBlinkPor() const;
399     inline sal_Bool HasBlinkPor() const { return bBlinkPor; }
400     inline void SetAnimation() const
401         { ( (SwTxtFrm*)this )->bHasAnimation = sal_True; }
402     inline sal_Bool HasAnimation() const { return bHasAnimation; }
403 
404     inline sal_Bool IsSwapped() const { return bIsSwapped; }
405 
406     // Hat der Frm eine lokale Fussnote (in diesem Frm bzw. Follow)?
407 #ifndef DBG_UTIL
408     void CalcFtnFlag();
409 #else
410     void CalcFtnFlag( xub_StrLen nStop = STRING_LEN );//Fuer den Test von SplitFrm
411 #endif
412 
413     // Hidden
414     sal_Bool IsHiddenNow() const;       // bHidden && pOut == pPrt
415     void HideHidden();              // Anhaengsel entfernen wenn Hidden
416     void HideFootnotes( xub_StrLen nStart, xub_StrLen nEnd );
417 
418     /** method to hide/show objects
419 
420         OD 2004-01-15 #110582#
421         method hides respectively shows objects, which are anchored at paragraph,
422         at/as a character of the paragraph, corresponding to the paragraph and
423         paragraph portion visibility.
424 
425         @author OD
426     */
427     void HideAndShowObjects();
428 
429     // Ftn
430     void RemoveFtn( const xub_StrLen nStart = 0,
431                     const xub_StrLen nLen = STRING_LEN );
432     inline SwTwips GetFtnFrmHeight() const;
433     SwTxtFrm *FindFtnRef( const SwTxtFtn *pFtn );
434     inline const SwTxtFrm *FindFtnRef( const SwTxtFtn *pFtn ) const
435     { return FindFtnRef( pFtn ); }
436     void ConnectFtn( SwTxtFtn *pFtn, const SwTwips nDeadLine );
437 
438     // Wenn wir eine Ftn sind, die auf ihre Referenz zu waechst...
439     // public weil von SwCntntFrm::MakeAll benoetigt.
440     SwTwips GetFtnLine( const SwTxtFtn *pFtn ) const;
441 
442     // Liefern den linken und den rechten Rand in
443     // Dokumentkoordinaten (unter Beachtung der Absatzattribute).
444     inline SwTwips GetLeftMargin() const;
445     inline SwTwips GetRightMargin() const;
446 
447     virtual void Format( const SwBorderAttrs *pAttrs = 0 );
448     virtual void  CheckDirection( sal_Bool bVert );
449 
450     // Liefert die Summe der Zeilenhoehen in pLine zurueck.
451     sal_uInt16 GetParHeight() const;
452 
453     // Liefert die Resthoehe zurueck
454     inline SwTwips GetRstHeight() const;
455 
456     inline       SwTxtFrm *GetFollow();
457     inline const SwTxtFrm *GetFollow() const;
458 
459     // Suche die Seitennummer von ErgoSum und QuoVadis
460     SwTxtFrm *FindQuoVadisFrm();
461 
462     // holt die Formatierug nach, wenn der Idle-Handler zugeschlagen hat.
463     // --> FME 2004-10-29 #i29062# GetFormatted() can trigger a full formatting
464     // of the paragraph, causing other layout frames to become invalid. This
465     // has to be avoided during painting. Therefore we need to pass the
466     // information that we are currently in the paint process.
467     SwTxtFrm* GetFormatted( bool bForceQuickFormat = false );
468     // <--
469 
470     // wird demnaechst uebertragen
471     inline void SetFtn( const sal_Bool bNew ) { bFtn = bNew; }
472 
473     // Beruecksichtigung der Follows
474     inline sal_Bool IsInside( const xub_StrLen nPos ) const;
475 
476     const SwBodyFrm   *FindBodyFrm()   const;
477 
478     // DropCaps und Selektionen
479     inline sal_Bool GetDropRect( SwRect &rRect ) const
480     { return HasPara() ? _GetDropRect( rRect ) : sal_False; }
481 
482     static SwCache *GetTxtCache() { return pTxtCache; }
483     static void     SetTxtCache( SwCache *pNew ) { pTxtCache = pNew; }
484 
485     static long GetMinPrtLine() { return nMinPrtLine; }
486     static void SetMinPrtLine( long nNew ) { nMinPrtLine = nNew; }
487 
488     inline sal_uInt16 GetCacheIdx() const { return nCacheIdx; }
489     inline void   SetCacheIdx( const sal_uInt16 nNew ) { nCacheIdx = nNew; }
490 
491     //Entfert die Line-Informationen aus dem Cache.
492     void ClearPara();
493 
494     // Bin ich ein FtnFrm, der eine Nummer am Absatzanfang hat?
495     inline sal_Bool IsFtnNumFrm() const
496     { return IsInFtn() && !GetIndPrev() && _IsFtnNumFrm(); }
497 
498     // simuliert eine Formatierung, als wenn es keinen rechten Rand und
499     // keine Flys oder andere Hindernisse gaebe und liefert die Breite.
500     SwTwips CalcFitToContent();
501 
502     /** simulate format for a list item paragraph, whose list level attributes
503         are in LABEL_ALIGNMENT mode, in order to determine additional first
504         line offset for the real text formatting due to the value of label
505         adjustment attribute of the list level.
506 
507         OD 2008-01-31 #newlistlevelattrs#
508 
509         @author OD
510     */
511     void CalcAdditionalFirstLineOffset();
512 
513     // --> OD 2008-01-31 #newlistlevelattrs#
514     inline SwTwips GetAdditionalFirstLineOffset() const
515     {
516         return mnAdditionalFirstLineOffset;
517     }
518     // <--
519 
520     // liefert den zusaetzlichen Zeilenabstand fuer den naechsten Absatz
521     // OD 07.01.2004 #i11859# - change return data type;
522     //      add default parameter <_bNoPropLineSpacing> to control, if the
523     //      value of a proportional line spacing is returned or not
524     long GetLineSpace( const bool _bNoPropLineSpacing = false ) const;
525 
526     // liefert die erste Zeilenhoehe zurueck
527     sal_uInt16 FirstLineHeight() const;
528 
529     // Haengt FlyInCntFrm um, wenn nEnd > Index >= nStart ist.
530     void MoveFlyInCnt( SwTxtFrm *pNew, sal_uInt16 nStart, sal_uInt16 nEnd );
531 
532     // Berechnet die Position von FlyInCntFrms
533     sal_uInt16 CalcFlyPos( SwFrmFmt* pSearch );
534 
535     // Ermittelt die Startposition und Schrittweite des Registers
536     sal_Bool FillRegister( SwTwips& rRegStart, sal_uInt16& rRegDiff );
537 
538 
539     sal_uInt16 GetLineCount( sal_uInt16 nPos );     //Ermittelt die Zeilenanzahl
540 
541     //Fuer die Anzeige der Zeilennummern.
542     sal_uLong GetAllLines()  const { return nAllLines; }
543     sal_uLong GetThisLines() const { return nThisLines;}
544     void RecalcAllLines();
545 
546     // Stoppt Animationen innerhalb von Numerierungen
547     void StopAnimation( OutputDevice *pOut );
548 
549     // visit all portions for Accessibility
550     void VisitPortions( SwPortionHandler& rPH ) const;
551 
552     // returns the script info stored at the paraportion
553     const SwScriptInfo* GetScriptInfo() const;
554 
555     // Swaps width and height of the text frame
556     void SwapWidthAndHeight();
557     // Calculates the coordinates of a rectangle when switching from
558     // horizontal to vertical layout.
559     void SwitchHorizontalToVertical( SwRect& rRect ) const;
560     // Calculates the coordinates of a point when switching from
561     // horizontal to vertical layout.
562     void SwitchHorizontalToVertical( Point& rPoint ) const;
563     // Calculates the a limit value when switching from
564     // horizontal to vertical layout.
565     long SwitchHorizontalToVertical( long nLimit ) const;
566     // Calculates the coordinates of a rectangle when switching from
567     // vertical to horizontal layout.
568     void SwitchVerticalToHorizontal( SwRect& rRect ) const;
569     // Calculates the coordinates of a point when switching from
570     // vertical to horizontal layout.
571     void SwitchVerticalToHorizontal( Point& rPoint ) const;
572     // Calculates the a limit value when switching from
573     // vertical to horizontal layout.
574     long SwitchVerticalToHorizontal( long nLimit ) const;
575 
576     // Calculates the coordinates of a rectangle when switching from
577     // LTR to RTL layout
578     void SwitchLTRtoRTL( SwRect& rRect ) const;
579     // Calculates the coordinates of a point when switching from
580     // LTR to RTL layout.
581     void SwitchLTRtoRTL( Point& rPoint ) const;
582     // Calculates the coordinates of a rectangle when switching from
583     // RTL to LTR layout
584     inline void SwitchRTLtoLTR( SwRect& rRect ) const { SwitchLTRtoRTL( rRect ); }
585     // Calculates the coordinates of a point when switching from
586     // RTL to LTR layout.
587     inline void SwitchRTLtoLTR( Point& rPoint ) const { SwitchLTRtoRTL( rPoint ); };
588 
589     // OD 14.03.2003 #i11760# - access to new member <mbNoFollowFormat>
590     inline bool FollowFormatAllowed() const
591     {
592         return mbFollowFormatAllowed;
593     }
594     inline void AllowFollowFormat()
595     {
596         mbFollowFormatAllowed = true;
597     }
598     inline void ForbidFollowFormat()
599     {
600         mbFollowFormatAllowed = false;
601     }
602 
603     SwTwips GetBaseOfstForFly( sal_Bool bIgnoreFlysAnchoredAtThisFrame ) const
604     {
605         return ( bIgnoreFlysAnchoredAtThisFrame ?
606                  mnFlyAnchorOfst :
607                  mnFlyAnchorOfstNoWrap );
608     }
609 
610     // OD 2004-03-17 #i11860#
611     inline SwTwips GetHeightOfLastLine() const
612     {
613         return mnHeightOfLastLine;
614     }
615 
616     static void repaintTextFrames( const SwTxtNode& rNode );
617 };
618 
619 /*************************************************************************
620  *                          class SwTxtFrmLocker
621  *************************************************************************/
622 
623 class SwTxtFrmLocker
624 {
625 private:
626     SwTxtFrm * const pFrm;
627 public:
628     inline SwTxtFrmLocker( SwTxtFrm *pTxtFrm )
629         : pFrm( pTxtFrm->IsLocked() ? 0 : pTxtFrm )
630     { if( pFrm ) pFrm->Lock(); }
631     inline ~SwTxtFrmLocker() { if( pFrm ) pFrm->Unlock(); }
632 };
633 
634 /*************************************************************************
635  *                      Inline-Implementierung
636  *************************************************************************/
637 
638 inline const SwParaPortion *SwTxtFrm::GetPara() const
639 {
640     return ((SwTxtFrm*)this)->GetPara();
641 }
642 
643 inline sal_Bool SwTxtFrm::HasPara() const
644 {
645     return nCacheIdx != USHRT_MAX ? _HasPara() : sal_False;
646 }
647 
648 // 9104: Frm().Height() - Prt().Height(), siehe widorp.cxx und 7455, 6114, 7908
649 inline SwTwips SwTxtFrm::GetRstHeight() const
650 {
651     return !GetUpper() ? 0 : ((const SwFrm*)GetUpper())->Frm().Top()
652                            + ((const SwFrm*)GetUpper())->Prt().Top()
653                            + ((const SwFrm*)GetUpper())->Prt().Height()
654                            - Frm().Top() - (Frm().Height() - Prt().Height());
655 }
656 
657 inline SwTwips SwTxtFrm::GetLeftMargin() const
658 {
659     return Frm().Left() + Prt().Left();
660 }
661 inline SwTwips SwTxtFrm::GetRightMargin() const
662 {
663     return Frm().Left() + Prt().Left() + Prt().Width();
664 }
665 inline SwTwips SwTxtFrm::GrowTst( const SwTwips nGrow )
666 {
667     return Grow( nGrow, sal_True );
668 }
669 
670 #if OSL_DEBUG_LEVEL > 1
671 // fragt auf WYSIWYG DBG ab
672 extern sal_Bool IsDbg( const SwTxtFrm *pFrm );
673 #define DBTXTFRM aDbstream << "SwTxtFrm[" << GetFrmId() << "]"
674 #endif
675 
676 inline sal_Bool SwTxtFrm::IsInside( const xub_StrLen nPos ) const
677 {
678     sal_Bool bRet = sal_True;
679     if( nPos < GetOfst() )
680         bRet = sal_False;
681     else
682     {
683         const SwTxtFrm *pFoll = GetFollow();
684         if( pFoll && nPos >= pFoll->GetOfst() )
685             bRet = sal_False;
686     }
687     return bRet;
688 }
689 
690 inline SwTwips SwTxtFrm::GetFtnFrmHeight() const
691 {
692     if(  !IsFollow() && IsInFtn() && HasPara() )
693         return _GetFtnFrmHeight();
694     else
695         return 0;
696 }
697 
698 inline const SwTxtFrm *SwTxtFrm::GetFollow() const
699 {
700     return (const SwTxtFrm*)SwCntntFrm::GetFollow();
701 }
702 inline SwTxtFrm *SwTxtFrm::GetFollow()
703 {
704     return (SwTxtFrm*)SwCntntFrm::GetFollow();
705 }
706 
707 inline const SwTxtFrm *SwTxtFrm::GetFrmAtPos( const SwPosition &rPos) const
708 {
709     return ((SwTxtFrm*)this)->GetFrmAtPos( rPos );
710 }
711 
712 inline void SwTxtFrm::AdjustFollow( SwTxtFormatter &rLine,
713     const xub_StrLen nOffset, const xub_StrLen nStrEnd, const sal_uInt8 nMode )
714 {
715     if ( HasFollow() )
716         _AdjustFollow( rLine, nOffset, nStrEnd, nMode );
717 }
718 
719 inline void SwTxtFrm::SetOfst( const xub_StrLen nNewOfst )
720 {
721     if ( nOfst != nNewOfst )
722         _SetOfst( nNewOfst );
723 }
724 
725 inline void SwTxtFrm::SetRepaint() const
726 {
727     ((SwTxtFrm*)this)->bRepaint = sal_True;
728 }
729 inline void SwTxtFrm::ResetRepaint() const
730 {
731     ((SwTxtFrm*)this)->bRepaint = sal_False;
732 }
733 
734 inline void SwTxtFrm::SetBlinkPor() const
735 {
736     ((SwTxtFrm*)this)->bBlinkPor = sal_True;
737 }
738 inline void SwTxtFrm::ResetBlinkPor() const
739 {
740     ((SwTxtFrm*)this)->bBlinkPor = sal_False;
741 }
742 
743 #ifdef LINGU_STATISTIK
744 
745 class SwLinguStatistik
746 {
747 public:
748     long nWords;    // gepruefte Worte
749     long nFlushCnt; // zaehlt die Messungen
750 
751     long nWrong;  // als falsch erkannt
752     long nAlter;  // Alternativvorschlaege
753     long nSpellTime; // Zeitmessung
754     long nSynonym; // Thesaurus
755     long nNoSynonym; // Thesaurus ratlos
756     long nMeaning; // Thesaurus-Bedeutung
757     long nNoMeaning; // Thesaurus meinungslos
758     long nTheTime; // Zeitmessung
759     long nHyphens; // Trennstellen
760     long nNoHyph; // Worte ohne Trennstellen
761     long nHyphErr; // Fehler beim Trennen
762     long nHyphTime; // Zeitmessung
763     SpellCheck *pSpell;
764     LanguageType eLang;
765 
766     void Flush();
767 
768     inline SwLinguStatistik()
769         { nWords = nWrong = nAlter = nSynonym = nNoSynonym =
770           nHyphens = nNoHyph = nHyphErr = nSpellTime = nTheTime =
771           nHyphTime = nFlushCnt = 0;
772           pSpell = NULL;
773           eLang = LANGUAGE_DONTKNOW; }
774     inline ~SwLinguStatistik(){ Flush(); }
775 };
776 
777 // globale Variable, implementiert in txtfrm.cxx
778 extern SwLinguStatistik aSwLinguStat;
779 
780 #define SW_LING(nWhich,nInc) (aSwLinguStat.nWhich) += nInc;
781 
782 #endif
783 
784 #define SWAP_IF_SWAPPED( pFrm )\
785     sal_Bool bUndoSwap = sal_False;   \
786     if ( pFrm->IsVertical() && pFrm->IsSwapped() )\
787     {                                 \
788         bUndoSwap = sal_True;         \
789         ((SwTxtFrm*)pFrm)->SwapWidthAndHeight();         \
790     }
791 
792 #define SWAP_IF_NOT_SWAPPED( pFrm )\
793     sal_Bool bUndoSwap = sal_False;     \
794     if ( pFrm->IsVertical() && ! pFrm->IsSwapped() )\
795     {                                   \
796         bUndoSwap = sal_True;           \
797         ((SwTxtFrm*)pFrm)->SwapWidthAndHeight();         \
798     }
799 
800 #define UNDO_SWAP( pFrm )\
801     if ( bUndoSwap )\
802         ((SwTxtFrm*)pFrm)->SwapWidthAndHeight();
803 
804 // Helper class which can be used instead of the macros if a function
805 // has too many returns
806 class SwFrmSwapper
807 {
808     const SwTxtFrm* pFrm;
809     sal_Bool bUndo;
810 public:
811     SwFrmSwapper( const SwTxtFrm* pFrm, sal_Bool bSwapIfNotSwapped );
812     ~SwFrmSwapper();
813 };
814 
815 class SwLayoutModeModifier
816 {
817     const OutputDevice& rOut;
818     long nOldLayoutMode;
819 public:
820     SwLayoutModeModifier( const OutputDevice& rOutp );
821     ~SwLayoutModeModifier();
822     void Modify( sal_Bool bChgToRTL );
823     void SetAuto();
824 };
825 
826 class SwDigitModeModifier
827 {
828     const OutputDevice& rOut;
829     LanguageType nOldLanguageType;
830 public:
831     SwDigitModeModifier( const OutputDevice& rOutp, LanguageType eCurLang );
832     ~SwDigitModeModifier();
833 };
834 
835 #endif
836