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