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