xref: /aoo41x/main/sw/source/core/inc/txtfrm.hxx (revision 1d2dbeb0)
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     // Returns the screen position of rPos. The values are relative to the upper
244     // left position of the page frame.
245     // Additional information can be obtained by passing an SwCrsrMoveState object.
246     // Returns sal_False if rPos > number of character is string
247     virtual sal_Bool   GetCharRect( SwRect& rRect, const SwPosition& rPos,
248                                 SwCrsrMoveState* pCMS = 0 ) const;
249 	// Eine etwas abgespeckte GetCharRect-Version fuer autopositionierte Rahmen
250 	sal_Bool GetAutoPos( SwRect &, const SwPosition& ) const;
251 
252     /** determine top of line for given position in the text frame
253 
254         OD 11.11.2003 #i22341#
255         Assumption: given position exists in the text frame or in a follow of it
256         OD 2004-02-02 - adjustment
257         Top of first paragraph line is the top of the paragraph.
258         OD 2004-03-18 #i11860# - Consider upper space amount considered for
259         previous frame and the page grid.
260 
261         @author OD
262 
263         @param _onTopOfLine
264         output parameter - top of line, if the given position is found in the
265         text frame.
266 
267         @param _rPos
268         input parameter - reference to the position in the text frame
269 
270         @return boolean indicating, if the top of line for the given position
271         has been determined or not.
272     */
273     bool GetTopOfLine( SwTwips& _onTopOfLine,
274                        const SwPosition& _rPos ) const;
275 
276 	virtual bool FillSelection( SwSelectionList& rList, const SwRect& rRect ) const;
277 
278 
279 	//Liefert in nOffset den Offset des Characters innerhalb des
280 	//gesetzten Textbuffers zurueck, welcher der durch aPoint
281 	//gegebenen Position innerhalb der SSize des Layout am
282 	//naechsten ist. Wenn der SPoint ausserhalb der SSize liegt,
283 	//liefert die Funktion sal_False, sal_True sonst.
284 	virtual sal_Bool GetCrsrOfst( SwPosition *, Point&,
285                                   SwCrsrMoveState* = 0) const;
286 
287 	// GetKeyCrsrOfst sorgt dafuer, dass der Frame nicht gewechselt wird
288 	// (z.B. Wechsel in den zeichengebundenen Frame).
289 	inline	sal_Bool GetKeyCrsrOfst(SwPosition *pPos, const Point &rPoint ) const
290 			{ return _GetCrsrOfst( pPos, rPoint, sal_False ); }
291 
292 	void   PaintExtraData( const SwRect & rRect ) const; //Seitennummer usw.
293 	SwRect Paint();
294     virtual void Paint( SwRect const&,
295                         SwPrintData const*const pPrintData = NULL ) const;
296 	virtual sal_Bool GetInfo( SfxPoolItem & ) const;
297 
298 	//Layoutorientiertes Cursortravelling: Linker, rechter Rand,
299 	//vorhergehende/naechste Zeile, gleiche horizontale Position.
300 	virtual sal_Bool LeftMargin(SwPaM *) const;
301 	virtual sal_Bool RightMargin(SwPaM *, sal_Bool bAPI = sal_False) const;
302 
303 	virtual sal_Bool UnitUp(SwPaM *, const SwTwips nOffset = 0,
304 							sal_Bool bSetInReadOnly = sal_False  ) const;
305 	virtual sal_Bool UnitDown(SwPaM *, const SwTwips nOffset = 0,
306 							sal_Bool bSetInReadOnly = sal_False ) const;
307 	sal_Bool _UnitUp(SwPaM *, const SwTwips nOffset = 0,
308 							sal_Bool bSetInReadOnly = sal_False ) const;
309 	sal_Bool _UnitDown(SwPaM *, const SwTwips nOffset = 0,
310 							sal_Bool bSetInReadOnly = sal_False ) const;
311 
312     // Prepares the cursor position for a visual cursor move (BiDi).
313     // The behaviour is different for insert and overwrite cursors
314     void PrepareVisualMove( xub_StrLen& nPos, sal_uInt8& nCrsrLevel,
315                             sal_Bool& bRight, sal_Bool bInsertCrsr );
316 
317 	// Methoden zur Verwaltung von FolgeFrames
318 		   SwCntntFrm *SplitFrm( const xub_StrLen nTxtPos );
319 		   SwCntntFrm *JoinFrm();
320 	inline sal_uInt16	   GetOfst() const { return nOfst; }
321 		   void		   _SetOfst( const sal_uInt16 nNewOfst );
322 	inline void 	   SetOfst ( const sal_uInt16 nNewOfst );
323 	inline void 	   ManipOfst ( const sal_uInt16 nNewOfst ){ nOfst = nNewOfst; }
324 		   SwTxtFrm   *GetFrmAtPos ( const SwPosition &rPos);
325 	inline const SwTxtFrm *GetFrmAtPos ( const SwPosition &rPos) const;
326            // OD 07.10.2003 #110978# - return <reference> instead of <pointer>
327     SwTxtFrm&   GetFrmAtOfst( const xub_StrLen nOfst );
328 	// Wenn es einen Follow gibt und wir selbst keinen Text enthalten:
329 	inline sal_Bool IsEmptyMaster() const
330 		{ return GetFollow() && !GetFollow()->GetOfst(); }
331 
332 	// Liefert den zu bearbeitenden Textausschnitt zurueck (inline, s.u.)
333 	const String& GetTxt() const;
334 	inline SwTxtNode *GetTxtNode()
335 		{ return (SwTxtNode*)SwCntntFrm::GetNode(); }
336 	inline const SwTxtNode *GetTxtNode() const
337 		{ return (SwTxtNode*)SwCntntFrm::GetNode(); }
338 
339 	SwTxtFrm(SwTxtNode * const, SwFrm* );
340     virtual ~SwTxtFrm();
341 
342 	// SwCntntFrm: der "kurze Dienstweg" fuer die Frames.
343 	// Wer den void* falsch casted ist selbst Schuld!
344 	// Auf jedenfall muss der void* auf 0 geprueft werden.
345 	virtual void Prepare( const PrepareHint ePrep = PREP_CLEAR,
346 						  const void *pVoid = 0, sal_Bool bNotify = sal_True );
347 
348     // nMaxHeight is the required height
349     // bSplit indicates, that the paragraph has to be split
350     // bTst indicates, that we are currently doing a test formatting
351     virtual sal_Bool WouldFit( SwTwips &nMaxHeight, sal_Bool &bSplit, sal_Bool bTst );
352 
353 	// Hier das WouldFit-Aequivalent fuer mal kurz probeweise
354 	// umgehaengte TextFrames, auch hier liefert
355 	// nMaxHeight die benoetigte Hoehe,
356 	// und bSplit sagt, obj der Absatz gesplittet werden muss.
357 	// Uebergeben wird der potentielle Vorgaenger fuer die Abstandsberechnung
358 	sal_Bool TestFormat( const SwFrm* pPrv, SwTwips &nMaxHeight, sal_Bool &bSplit );
359 
360 	// Wir formatieren eine Zeile fuer die interaktive Trennung
361 	// Return: found
362 	sal_Bool Hyphenate( SwInterHyphInfo &rInf );
363 
364 	// Probegrow
365 	inline SwTwips GrowTst( const SwTwips nGrow );
366 
367 	SwParaPortion *GetPara();
368 	inline const SwParaPortion *GetPara() const;
369 	inline sal_Bool HasPara() const;
370 	sal_Bool _HasPara() const;
371 	// If there are any hanging punctuation portions in the margin
372 	// the offset will be returned.
373 	SwTwips HangingMargin() const;
374 
375 	// RTTI
376 	TYPEINFO();
377 	DECL_FIXEDMEMPOOL_NEWDEL(SwTxtFrm)
378 
379 	// Locking
380 	inline sal_Bool IsLocked() 		const { return bLocked;		}
381 	inline sal_Bool IsFormatted() 	const { return bFormatted;	}
382 
383 	inline sal_Bool IsWidow() 		const { return bWidow;		}
384 	inline sal_Bool IsJustWidow()	const { return bJustWidow;	}
385 	inline sal_Bool IsEmpty() 		const { return bEmpty;		}
386 	inline sal_Bool HasFtn() 		const { return bFtn; 		}
387 	inline sal_Bool IsInFtnConnect()const { return bInFtnConnect;}
388 	inline sal_Bool IsFieldFollow() const { return bFieldFollow;}
389 
390 	inline void SetRepaint() const;
391 	inline void ResetRepaint() const;
392 	inline sal_Bool HasRepaint() const { return bRepaint; }
393 	inline void SetBlinkPor() const;
394 	inline void ResetBlinkPor() const;
395 	inline sal_Bool HasBlinkPor() const { return bBlinkPor; }
396 	inline void SetAnimation() const
397 		{ ( (SwTxtFrm*)this )->bHasAnimation = sal_True; }
398 	inline sal_Bool HasAnimation() const { return bHasAnimation; }
399 
400     inline sal_Bool IsSwapped() const { return bIsSwapped; }
401 
402 	// Hat der Frm eine lokale Fussnote (in diesem Frm bzw. Follow)?
403 #ifndef DBG_UTIL
404 	void CalcFtnFlag();
405 #else
406 	void CalcFtnFlag( xub_StrLen nStop = STRING_LEN );//Fuer den Test von SplitFrm
407 #endif
408 
409 	// Hidden
410 	sal_Bool IsHiddenNow() const;		// bHidden && pOut == pPrt
411 	void HideHidden();				// Anhaengsel entfernen wenn Hidden
412     void HideFootnotes( xub_StrLen nStart, xub_StrLen nEnd );
413 
414     /** method to hide/show objects
415 
416         OD 2004-01-15 #110582#
417         method hides respectively shows objects, which are anchored at paragraph,
418         at/as a character of the paragraph, corresponding to the paragraph and
419         paragraph portion visibility.
420 
421         @author OD
422     */
423     void HideAndShowObjects();
424 
425 	// Ftn
426 	void RemoveFtn( const xub_StrLen nStart = 0,
427 					const xub_StrLen nLen = STRING_LEN );
428 	inline SwTwips GetFtnFrmHeight() const;
429 	SwTxtFrm *FindFtnRef( const SwTxtFtn *pFtn );
430 	inline const SwTxtFrm *FindFtnRef( const SwTxtFtn *pFtn ) const
431 	{ return FindFtnRef( pFtn ); }
432 	void ConnectFtn( SwTxtFtn *pFtn, const SwTwips nDeadLine );
433 
434 	// Wenn wir eine Ftn sind, die auf ihre Referenz zu waechst...
435 	// public weil von SwCntntFrm::MakeAll benoetigt.
436     SwTwips GetFtnLine( const SwTxtFtn *pFtn ) const;
437 
438 	// Liefern den linken und den rechten Rand in
439 	// Dokumentkoordinaten (unter Beachtung der Absatzattribute).
440 	inline SwTwips GetLeftMargin() const;
441 	inline SwTwips GetRightMargin() const;
442 
443 	virtual void Format( const SwBorderAttrs *pAttrs = 0 );
444     virtual void  CheckDirection( sal_Bool bVert );
445 
446 	// Liefert die Summe der Zeilenhoehen in pLine zurueck.
447 	sal_uInt16 GetParHeight() const;
448 
449 	// Liefert die Resthoehe zurueck
450 	inline SwTwips GetRstHeight() const;
451 
452 	inline 		 SwTxtFrm *GetFollow();
453 	inline const SwTxtFrm *GetFollow() const;
454 
455     // Suche die Seitennummer von ErgoSum und QuoVadis
456 	SwTxtFrm *FindQuoVadisFrm();
457 
458 	// holt die Formatierug nach, wenn der Idle-Handler zugeschlagen hat.
459     // --> FME 2004-10-29 #i29062# GetFormatted() can trigger a full formatting
460     // of the paragraph, causing other layout frames to become invalid. This
461     // has to be avoided during painting. Therefore we need to pass the
462     // information that we are currently in the paint process.
463     SwTxtFrm* GetFormatted( bool bForceQuickFormat = false );
464     // <--
465 
466 	// wird demnaechst uebertragen
467 	inline void SetFtn( const sal_Bool bNew ) { bFtn = bNew; }
468 
469 	// Beruecksichtigung der Follows
470 	inline sal_Bool IsInside( const xub_StrLen nPos ) const;
471 
472 	const SwBodyFrm   *FindBodyFrm()   const;
473 
474 	// DropCaps und Selektionen
475 	inline sal_Bool GetDropRect( SwRect &rRect ) const
476 	{ return HasPara() ? _GetDropRect( rRect ) : sal_False; }
477 
478 	static SwCache *GetTxtCache() { return pTxtCache; }
479 	static void		SetTxtCache( SwCache *pNew ) { pTxtCache = pNew; }
480 
481 	static long GetMinPrtLine() { return nMinPrtLine; }
482 	static void	SetMinPrtLine( long nNew ) { nMinPrtLine = nNew; }
483 
484 	inline sal_uInt16 GetCacheIdx() const { return nCacheIdx; }
485 	inline void	  SetCacheIdx( const sal_uInt16 nNew ) { nCacheIdx = nNew; }
486 
487 	//Entfert die Line-Informationen aus dem Cache.
488 	void ClearPara();
489 
490 	// Bin ich ein FtnFrm, der eine Nummer am Absatzanfang hat?
491 	inline sal_Bool IsFtnNumFrm() const
492 	{ return IsInFtn() && !GetIndPrev() && _IsFtnNumFrm(); }
493 
494 	// simuliert eine Formatierung, als wenn es keinen rechten Rand und
495 	// keine Flys oder andere Hindernisse gaebe und liefert die Breite.
496     SwTwips CalcFitToContent();
497 
498     /** simulate format for a list item paragraph, whose list level attributes
499         are in LABEL_ALIGNMENT mode, in order to determine additional first
500         line offset for the real text formatting due to the value of label
501         adjustment attribute of the list level.
502 
503         OD 2008-01-31 #newlistlevelattrs#
504 
505         @author OD
506     */
507     void CalcAdditionalFirstLineOffset();
508 
509     // --> OD 2008-01-31 #newlistlevelattrs#
510     inline SwTwips GetAdditionalFirstLineOffset() const
511     {
512         return mnAdditionalFirstLineOffset;
513     }
514     // <--
515 
516 	// liefert den zusaetzlichen Zeilenabstand fuer den naechsten Absatz
517     // OD 07.01.2004 #i11859# - change return data type;
518     //      add default parameter <_bNoPropLineSpacing> to control, if the
519     //      value of a proportional line spacing is returned or not
520     long GetLineSpace( const bool _bNoPropLineSpacing = false ) const;
521 
522     // liefert die erste Zeilenhoehe zurueck
523 	sal_uInt16 FirstLineHeight() const;
524 
525 	// Haengt FlyInCntFrm um, wenn nEnd > Index >= nStart ist.
526 	void MoveFlyInCnt( SwTxtFrm *pNew, sal_uInt16 nStart, sal_uInt16 nEnd );
527 
528 	// Berechnet die Position von FlyInCntFrms
529 	sal_uInt16 CalcFlyPos( SwFrmFmt* pSearch );
530 
531 	// Ermittelt die Startposition und Schrittweite des Registers
532 	sal_Bool FillRegister( SwTwips& rRegStart, sal_uInt16& rRegDiff );
533 
534 
535 	sal_uInt16 GetLineCount( sal_uInt16 nPos );		//Ermittelt die Zeilenanzahl
536 
537 	//Fuer die Anzeige der Zeilennummern.
538 	sal_uLong GetAllLines()  const { return nAllLines; }
539 	sal_uLong GetThisLines() const { return nThisLines;}
540 	void RecalcAllLines();
541 
542 	// Stoppt Animationen innerhalb von Numerierungen
543 	void StopAnimation( OutputDevice *pOut );
544 
545     // visit all portions for Accessibility
546     void VisitPortions( SwPortionHandler& rPH ) const;
547 
548     // returns the script info stored at the paraportion
549     const SwScriptInfo* GetScriptInfo() const;
550 
551     // Swaps width and height of the text frame
552     void SwapWidthAndHeight();
553     // Calculates the coordinates of a rectangle when switching from
554     // horizontal to vertical layout.
555     void SwitchHorizontalToVertical( SwRect& rRect ) const;
556     // Calculates the coordinates of a point when switching from
557     // horizontal to vertical layout.
558     void SwitchHorizontalToVertical( Point& rPoint ) const;
559     // Calculates the a limit value when switching from
560     // horizontal to vertical layout.
561     long SwitchHorizontalToVertical( long nLimit ) const;
562     // Calculates the coordinates of a rectangle when switching from
563     // vertical to horizontal layout.
564     void SwitchVerticalToHorizontal( SwRect& rRect ) const;
565     // Calculates the coordinates of a point when switching from
566     // vertical to horizontal layout.
567     void SwitchVerticalToHorizontal( Point& rPoint ) const;
568     // Calculates the a limit value when switching from
569     // vertical to horizontal layout.
570     long SwitchVerticalToHorizontal( long nLimit ) const;
571 
572     // Calculates the coordinates of a rectangle when switching from
573     // LTR to RTL layout
574     void SwitchLTRtoRTL( SwRect& rRect ) const;
575     // Calculates the coordinates of a point when switching from
576     // LTR to RTL layout.
577     void SwitchLTRtoRTL( Point& rPoint ) const;
578     // Calculates the coordinates of a rectangle when switching from
579     // RTL to LTR layout
580     inline void SwitchRTLtoLTR( SwRect& rRect ) const { SwitchLTRtoRTL( rRect ); }
581     // Calculates the coordinates of a point when switching from
582     // RTL to LTR layout.
583     inline void SwitchRTLtoLTR( Point& rPoint ) const { SwitchLTRtoRTL( rPoint ); };
584 
585     // OD 14.03.2003 #i11760# - access to new member <mbNoFollowFormat>
586     inline bool FollowFormatAllowed() const
587     {
588         return mbFollowFormatAllowed;
589     }
590     inline void AllowFollowFormat()
591     {
592         mbFollowFormatAllowed = true;
593     }
594     inline void ForbidFollowFormat()
595     {
596         mbFollowFormatAllowed = false;
597     }
598 
599     SwTwips GetBaseOfstForFly( sal_Bool bIgnoreFlysAnchoredAtThisFrame ) const
600     {
601         return ( bIgnoreFlysAnchoredAtThisFrame ?
602                  mnFlyAnchorOfst :
603                  mnFlyAnchorOfstNoWrap );
604     }
605 
606     // OD 2004-03-17 #i11860#
607     inline SwTwips GetHeightOfLastLine() const
608     {
609         return mnHeightOfLastLine;
610     }
611 
612     static void repaintTextFrames( const SwTxtNode& rNode );
613 };
614 
615 /*************************************************************************
616  *							class SwTxtFrmLocker
617  *************************************************************************/
618 
619 class SwTxtFrmLocker
620 {
621 private:
622 	SwTxtFrm * const pFrm;
623 public:
624 	inline SwTxtFrmLocker( SwTxtFrm *pTxtFrm )
625 		: pFrm( pTxtFrm->IsLocked() ? 0 : pTxtFrm )
626 	{ if( pFrm ) pFrm->Lock(); }
627 	inline ~SwTxtFrmLocker() { if( pFrm ) pFrm->Unlock(); }
628 };
629 
630 /*************************************************************************
631  *						Inline-Implementierung
632  *************************************************************************/
633 
634 inline const SwParaPortion *SwTxtFrm::GetPara() const
635 {
636 	return ((SwTxtFrm*)this)->GetPara();
637 }
638 
639 inline sal_Bool SwTxtFrm::HasPara() const
640 {
641 	return nCacheIdx != USHRT_MAX ? _HasPara() : sal_False;
642 }
643 
644 // 9104: Frm().Height() - Prt().Height(), siehe widorp.cxx und 7455, 6114, 7908
645 inline SwTwips SwTxtFrm::GetRstHeight() const
646 {
647 	return !GetUpper() ? 0 : ((const SwFrm*)GetUpper())->Frm().Top()
648 						   + ((const SwFrm*)GetUpper())->Prt().Top()
649 						   + ((const SwFrm*)GetUpper())->Prt().Height()
650 						   - Frm().Top() - (Frm().Height() - Prt().Height());
651 }
652 
653 inline SwTwips SwTxtFrm::GetLeftMargin() const
654 {
655 	return Frm().Left() + Prt().Left();
656 }
657 inline SwTwips SwTxtFrm::GetRightMargin() const
658 {
659 	return Frm().Left() + Prt().Left() + Prt().Width();
660 }
661 inline SwTwips SwTxtFrm::GrowTst( const SwTwips nGrow )
662 {
663     return Grow( nGrow, sal_True );
664 }
665 
666 #if OSL_DEBUG_LEVEL > 1
667 // fragt auf WYSIWYG DBG ab
668 extern sal_Bool IsDbg( const SwTxtFrm *pFrm );
669 #define DBTXTFRM aDbstream << "SwTxtFrm[" << GetFrmId() << "]"
670 #endif
671 
672 inline sal_Bool SwTxtFrm::IsInside( const xub_StrLen nPos ) const
673 {
674 	sal_Bool bRet = sal_True;
675 	if( nPos < GetOfst() )
676 		bRet = sal_False;
677 	else
678 	{
679 		const SwTxtFrm *pFoll = GetFollow();
680 		if( pFoll && nPos >= pFoll->GetOfst() )
681 			bRet = sal_False;
682 	}
683 	return bRet;
684 }
685 
686 inline SwTwips SwTxtFrm::GetFtnFrmHeight() const
687 {
688 	if(  !IsFollow() && IsInFtn() && HasPara() )
689 		return _GetFtnFrmHeight();
690 	else
691 		return 0;
692 }
693 
694 inline const SwTxtFrm *SwTxtFrm::GetFollow() const
695 {
696 	return (const SwTxtFrm*)SwCntntFrm::GetFollow();
697 }
698 inline SwTxtFrm *SwTxtFrm::GetFollow()
699 {
700 	return (SwTxtFrm*)SwCntntFrm::GetFollow();
701 }
702 
703 inline const SwTxtFrm *SwTxtFrm::GetFrmAtPos( const SwPosition &rPos) const
704 {
705 	return ((SwTxtFrm*)this)->GetFrmAtPos( rPos );
706 }
707 
708 inline void SwTxtFrm::AdjustFollow( SwTxtFormatter &rLine,
709 	const xub_StrLen nOffset, const xub_StrLen nStrEnd, const sal_uInt8 nMode )
710 {
711 	if ( HasFollow() )
712 		_AdjustFollow( rLine, nOffset, nStrEnd, nMode );
713 }
714 
715 inline void SwTxtFrm::SetOfst( const xub_StrLen nNewOfst )
716 {
717 	if ( nOfst != nNewOfst )
718 		_SetOfst( nNewOfst );
719 }
720 
721 inline void SwTxtFrm::SetRepaint() const
722 {
723 	((SwTxtFrm*)this)->bRepaint = sal_True;
724 }
725 inline void SwTxtFrm::ResetRepaint() const
726 {
727 	((SwTxtFrm*)this)->bRepaint = sal_False;
728 }
729 
730 inline void SwTxtFrm::SetBlinkPor() const
731 {
732 	((SwTxtFrm*)this)->bBlinkPor = sal_True;
733 }
734 inline void SwTxtFrm::ResetBlinkPor() const
735 {
736 	((SwTxtFrm*)this)->bBlinkPor = sal_False;
737 }
738 
739 #ifdef LINGU_STATISTIK
740 
741 class SwLinguStatistik
742 {
743 public:
744 	long nWords;	// gepruefte Worte
745 	long nFlushCnt;	// zaehlt die Messungen
746 
747 	long nWrong;  // als falsch erkannt
748 	long nAlter;  // Alternativvorschlaege
749 	long nSpellTime; // Zeitmessung
750 	long nSynonym; // Thesaurus
751 	long nNoSynonym; // Thesaurus ratlos
752 	long nMeaning; // Thesaurus-Bedeutung
753 	long nNoMeaning; // Thesaurus meinungslos
754 	long nTheTime; // Zeitmessung
755 	long nHyphens; // Trennstellen
756 	long nNoHyph; // Worte ohne Trennstellen
757 	long nHyphErr; // Fehler beim Trennen
758 	long nHyphTime; // Zeitmessung
759 	SpellCheck *pSpell;
760 	LanguageType eLang;
761 
762 	void Flush();
763 
764 	inline SwLinguStatistik()
765 		{ nWords = nWrong = nAlter = nSynonym = nNoSynonym =
766 		  nHyphens = nNoHyph = nHyphErr = nSpellTime = nTheTime =
767 		  nHyphTime = nFlushCnt = 0;
768 		  pSpell = NULL;
769 		  eLang = LANGUAGE_DONTKNOW; }
770 	inline ~SwLinguStatistik(){ Flush(); }
771 };
772 
773 // globale Variable, implementiert in txtfrm.cxx
774 extern SwLinguStatistik aSwLinguStat;
775 
776 #define SW_LING(nWhich,nInc) (aSwLinguStat.nWhich) += nInc;
777 
778 #endif
779 
780 #define SWAP_IF_SWAPPED( pFrm )\
781     sal_Bool bUndoSwap = sal_False;   \
782     if ( pFrm->IsVertical() && pFrm->IsSwapped() )\
783     {                                 \
784         bUndoSwap = sal_True;         \
785         ((SwTxtFrm*)pFrm)->SwapWidthAndHeight();         \
786     }
787 
788 #define SWAP_IF_NOT_SWAPPED( pFrm )\
789     sal_Bool bUndoSwap = sal_False;     \
790     if ( pFrm->IsVertical() && ! pFrm->IsSwapped() )\
791     {                                   \
792         bUndoSwap = sal_True;           \
793         ((SwTxtFrm*)pFrm)->SwapWidthAndHeight();         \
794     }
795 
796 #define UNDO_SWAP( pFrm )\
797     if ( bUndoSwap )\
798         ((SwTxtFrm*)pFrm)->SwapWidthAndHeight();
799 
800 // Helper class which can be used instead of the macros if a function
801 // has too many returns
802 class SwFrmSwapper
803 {
804     const SwTxtFrm* pFrm;
805     sal_Bool bUndo;
806 public:
807     SwFrmSwapper( const SwTxtFrm* pFrm, sal_Bool bSwapIfNotSwapped );
808     ~SwFrmSwapper();
809 };
810 
811 class SwLayoutModeModifier
812 {
813     const OutputDevice& rOut;
814     long nOldLayoutMode;
815 public:
816     SwLayoutModeModifier( const OutputDevice& rOutp );
817     ~SwLayoutModeModifier();
818     void Modify( sal_Bool bChgToRTL );
819     void SetAuto();
820 };
821 
822 class SwDigitModeModifier
823 {
824     const OutputDevice& rOut;
825     LanguageType nOldLanguageType;
826 public:
827     SwDigitModeModifier( const OutputDevice& rOutp, LanguageType eCurLang );
828     ~SwDigitModeModifier();
829 };
830 
831 #endif
832