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 );
FindFtnRef(const SwTxtFtn * pFtn) const435 inline const SwTxtFrm *FindFtnRef( const SwTxtFtn *pFtn ) const
436 { return FindFtnRef( pFtn ); }
437 void ConnectFtn( SwTxtFtn *pFtn, const SwTwips nDeadLine );
438
439 // Wenn wir eine Ftn sind, die auf ihre Referenz zu waechst...
440 // public weil von SwCntntFrm::MakeAll benoetigt.
441 SwTwips GetFtnLine( const SwTxtFtn *pFtn ) const;
442
443 // Liefern den linken und den rechten Rand in
444 // Dokumentkoordinaten (unter Beachtung der Absatzattribute).
445 inline SwTwips GetLeftMargin() const;
446 inline SwTwips GetRightMargin() const;
447
448 virtual void Format( const SwBorderAttrs *pAttrs = 0 );
449 virtual void CheckDirection( sal_Bool bVert );
450
451 // Liefert die Summe der Zeilenhoehen in pLine zurueck.
452 sal_uInt16 GetParHeight() const;
453
454 // Liefert die Resthoehe zurueck
455 inline SwTwips GetRstHeight() const;
456
457 inline SwTxtFrm *GetFollow();
458 inline const SwTxtFrm *GetFollow() const;
459
460 // Suche die Seitennummer von ErgoSum und QuoVadis
461 SwTxtFrm *FindQuoVadisFrm();
462
463 // holt die Formatierug nach, wenn der Idle-Handler zugeschlagen hat.
464 // --> FME 2004-10-29 #i29062# GetFormatted() can trigger a full formatting
465 // of the paragraph, causing other layout frames to become invalid. This
466 // has to be avoided during painting. Therefore we need to pass the
467 // information that we are currently in the paint process.
468 SwTxtFrm* GetFormatted( bool bForceQuickFormat = false );
469 // <--
470
471 // wird demnaechst uebertragen
SetFtn(const sal_Bool bNew)472 inline void SetFtn( const sal_Bool bNew ) { bFtn = bNew; }
473
474 // Beruecksichtigung der Follows
475 inline sal_Bool IsInside( const xub_StrLen nPos ) const;
476
477 const SwBodyFrm *FindBodyFrm() const;
478
479 // DropCaps und Selektionen
GetDropRect(SwRect & rRect) const480 inline sal_Bool GetDropRect( SwRect &rRect ) const
481 { return HasPara() ? _GetDropRect( rRect ) : sal_False; }
482
GetTxtCache()483 static SwCache *GetTxtCache() { return pTxtCache; }
SetTxtCache(SwCache * pNew)484 static void SetTxtCache( SwCache *pNew ) { pTxtCache = pNew; }
485
GetMinPrtLine()486 static long GetMinPrtLine() { return nMinPrtLine; }
SetMinPrtLine(long nNew)487 static void SetMinPrtLine( long nNew ) { nMinPrtLine = nNew; }
488
GetCacheIdx() const489 inline sal_uInt16 GetCacheIdx() const { return nCacheIdx; }
SetCacheIdx(const sal_uInt16 nNew)490 inline void SetCacheIdx( const sal_uInt16 nNew ) { nCacheIdx = nNew; }
491
492 //Entfert die Line-Informationen aus dem Cache.
493 void ClearPara();
494
495 // Bin ich ein FtnFrm, der eine Nummer am Absatzanfang hat?
IsFtnNumFrm() const496 inline sal_Bool IsFtnNumFrm() const
497 { return IsInFtn() && !GetIndPrev() && _IsFtnNumFrm(); }
498
499 // simuliert eine Formatierung, als wenn es keinen rechten Rand und
500 // keine Flys oder andere Hindernisse gaebe und liefert die Breite.
501 SwTwips CalcFitToContent();
502
503 /** simulate format for a list item paragraph, whose list level attributes
504 are in LABEL_ALIGNMENT mode, in order to determine additional first
505 line offset for the real text formatting due to the value of label
506 adjustment attribute of the list level.
507
508 OD 2008-01-31 #newlistlevelattrs#
509
510 @author OD
511 */
512 void CalcAdditionalFirstLineOffset();
513
514 // --> OD 2008-01-31 #newlistlevelattrs#
GetAdditionalFirstLineOffset() const515 inline SwTwips GetAdditionalFirstLineOffset() const
516 {
517 return mnAdditionalFirstLineOffset;
518 }
519 // <--
520
521 // liefert den zusaetzlichen Zeilenabstand fuer den naechsten Absatz
522 // OD 07.01.2004 #i11859# - change return data type;
523 // add default parameter <_bNoPropLineSpacing> to control, if the
524 // value of a proportional line spacing is returned or not
525 long GetLineSpace( const bool _bNoPropLineSpacing = false ) const;
526
527 // liefert die erste Zeilenhoehe zurueck
528 sal_uInt16 FirstLineHeight() const;
529
530 // Haengt FlyInCntFrm um, wenn nEnd > Index >= nStart ist.
531 void MoveFlyInCnt( SwTxtFrm *pNew, sal_uInt16 nStart, sal_uInt16 nEnd );
532
533 // Berechnet die Position von FlyInCntFrms
534 sal_uInt16 CalcFlyPos( SwFrmFmt* pSearch );
535
536 // Ermittelt die Startposition und Schrittweite des Registers
537 sal_Bool FillRegister( SwTwips& rRegStart, sal_uInt16& rRegDiff );
538
539
540 sal_uInt16 GetLineCount( sal_uInt16 nPos ); //Ermittelt die Zeilenanzahl
541
542 //Fuer die Anzeige der Zeilennummern.
GetAllLines() const543 sal_uLong GetAllLines() const { return nAllLines; }
GetThisLines() const544 sal_uLong GetThisLines() const { return nThisLines;}
545 void RecalcAllLines();
546
547 // Stoppt Animationen innerhalb von Numerierungen
548 void StopAnimation( OutputDevice *pOut );
549
550 // visit all portions for Accessibility
551 void VisitPortions( SwPortionHandler& rPH ) const;
552
553 // returns the script info stored at the paraportion
554 const SwScriptInfo* GetScriptInfo() const;
555
556 // Swaps width and height of the text frame
557 void SwapWidthAndHeight();
558 // Calculates the coordinates of a rectangle when switching from
559 // horizontal to vertical layout.
560 void SwitchHorizontalToVertical( SwRect& rRect ) const;
561 // Calculates the coordinates of a point when switching from
562 // horizontal to vertical layout.
563 void SwitchHorizontalToVertical( Point& rPoint ) const;
564 // Calculates the a limit value when switching from
565 // horizontal to vertical layout.
566 long SwitchHorizontalToVertical( long nLimit ) const;
567 // Calculates the coordinates of a rectangle when switching from
568 // vertical to horizontal layout.
569 void SwitchVerticalToHorizontal( SwRect& rRect ) const;
570 // Calculates the coordinates of a point when switching from
571 // vertical to horizontal layout.
572 void SwitchVerticalToHorizontal( Point& rPoint ) const;
573 // Calculates the a limit value when switching from
574 // vertical to horizontal layout.
575 long SwitchVerticalToHorizontal( long nLimit ) const;
576
577 // Calculates the coordinates of a rectangle when switching from
578 // LTR to RTL layout
579 void SwitchLTRtoRTL( SwRect& rRect ) const;
580 // Calculates the coordinates of a point when switching from
581 // LTR to RTL layout.
582 void SwitchLTRtoRTL( Point& rPoint ) const;
583 // Calculates the coordinates of a rectangle when switching from
584 // RTL to LTR layout
SwitchRTLtoLTR(SwRect & rRect) const585 inline void SwitchRTLtoLTR( SwRect& rRect ) const { SwitchLTRtoRTL( rRect ); }
586 // Calculates the coordinates of a point when switching from
587 // RTL to LTR layout.
SwitchRTLtoLTR(Point & rPoint) const588 inline void SwitchRTLtoLTR( Point& rPoint ) const { SwitchLTRtoRTL( rPoint ); };
589
590 // OD 14.03.2003 #i11760# - access to new member <mbNoFollowFormat>
FollowFormatAllowed() const591 inline bool FollowFormatAllowed() const
592 {
593 return mbFollowFormatAllowed;
594 }
AllowFollowFormat()595 inline void AllowFollowFormat()
596 {
597 mbFollowFormatAllowed = true;
598 }
ForbidFollowFormat()599 inline void ForbidFollowFormat()
600 {
601 mbFollowFormatAllowed = false;
602 }
603
GetBaseOfstForFly(sal_Bool bIgnoreFlysAnchoredAtThisFrame) const604 SwTwips GetBaseOfstForFly( sal_Bool bIgnoreFlysAnchoredAtThisFrame ) const
605 {
606 return ( bIgnoreFlysAnchoredAtThisFrame ?
607 mnFlyAnchorOfst :
608 mnFlyAnchorOfstNoWrap );
609 }
610
611 // OD 2004-03-17 #i11860#
GetHeightOfLastLine() const612 inline SwTwips GetHeightOfLastLine() const
613 {
614 return mnHeightOfLastLine;
615 }
616
617 static void repaintTextFrames( const SwTxtNode& rNode );
618 };
619
620 /*************************************************************************
621 * class SwTxtFrmLocker
622 *************************************************************************/
623
624 class SwTxtFrmLocker
625 {
626 private:
627 SwTxtFrm * const pFrm;
628 public:
SwTxtFrmLocker(SwTxtFrm * pTxtFrm)629 inline SwTxtFrmLocker( SwTxtFrm *pTxtFrm )
630 : pFrm( pTxtFrm->IsLocked() ? 0 : pTxtFrm )
631 { if( pFrm ) pFrm->Lock(); }
~SwTxtFrmLocker()632 inline ~SwTxtFrmLocker() { if( pFrm ) pFrm->Unlock(); }
633 };
634
635 /*************************************************************************
636 * Inline-Implementierung
637 *************************************************************************/
638
GetPara() const639 inline const SwParaPortion *SwTxtFrm::GetPara() const
640 {
641 return ((SwTxtFrm*)this)->GetPara();
642 }
643
HasPara() const644 inline sal_Bool SwTxtFrm::HasPara() const
645 {
646 return nCacheIdx != USHRT_MAX ? _HasPara() : sal_False;
647 }
648
649 // 9104: Frm().Height() - Prt().Height(), siehe widorp.cxx und 7455, 6114, 7908
GetRstHeight() const650 inline SwTwips SwTxtFrm::GetRstHeight() const
651 {
652 return !GetUpper() ? 0 : ((const SwFrm*)GetUpper())->Frm().Top()
653 + ((const SwFrm*)GetUpper())->Prt().Top()
654 + ((const SwFrm*)GetUpper())->Prt().Height()
655 - Frm().Top() - (Frm().Height() - Prt().Height());
656 }
657
GetLeftMargin() const658 inline SwTwips SwTxtFrm::GetLeftMargin() const
659 {
660 return Frm().Left() + Prt().Left();
661 }
GetRightMargin() const662 inline SwTwips SwTxtFrm::GetRightMargin() const
663 {
664 return Frm().Left() + Prt().Left() + Prt().Width();
665 }
GrowTst(const SwTwips nGrow)666 inline SwTwips SwTxtFrm::GrowTst( const SwTwips nGrow )
667 {
668 return Grow( nGrow, sal_True );
669 }
670
671 #if OSL_DEBUG_LEVEL > 1
672 // fragt auf WYSIWYG DBG ab
673 extern sal_Bool IsDbg( const SwTxtFrm *pFrm );
674 #define DBTXTFRM aDbstream << "SwTxtFrm[" << GetFrmId() << "]"
675 #endif
676
IsInside(const xub_StrLen nPos) const677 inline sal_Bool SwTxtFrm::IsInside( const xub_StrLen nPos ) const
678 {
679 sal_Bool bRet = sal_True;
680 if( nPos < GetOfst() )
681 bRet = sal_False;
682 else
683 {
684 const SwTxtFrm *pFoll = GetFollow();
685 if( pFoll && nPos >= pFoll->GetOfst() )
686 bRet = sal_False;
687 }
688 return bRet;
689 }
690
GetFtnFrmHeight() const691 inline SwTwips SwTxtFrm::GetFtnFrmHeight() const
692 {
693 if( !IsFollow() && IsInFtn() && HasPara() )
694 return _GetFtnFrmHeight();
695 else
696 return 0;
697 }
698
GetFollow() const699 inline const SwTxtFrm *SwTxtFrm::GetFollow() const
700 {
701 return (const SwTxtFrm*)SwCntntFrm::GetFollow();
702 }
GetFollow()703 inline SwTxtFrm *SwTxtFrm::GetFollow()
704 {
705 return (SwTxtFrm*)SwCntntFrm::GetFollow();
706 }
707
GetFrmAtPos(const SwPosition & rPos) const708 inline const SwTxtFrm *SwTxtFrm::GetFrmAtPos( const SwPosition &rPos) const
709 {
710 return ((SwTxtFrm*)this)->GetFrmAtPos( rPos );
711 }
712
AdjustFollow(SwTxtFormatter & rLine,const xub_StrLen nOffset,const xub_StrLen nStrEnd,const sal_uInt8 nMode)713 inline void SwTxtFrm::AdjustFollow( SwTxtFormatter &rLine,
714 const xub_StrLen nOffset, const xub_StrLen nStrEnd, const sal_uInt8 nMode )
715 {
716 if ( HasFollow() )
717 _AdjustFollow( rLine, nOffset, nStrEnd, nMode );
718 }
719
SetOfst(const xub_StrLen nNewOfst)720 inline void SwTxtFrm::SetOfst( const xub_StrLen nNewOfst )
721 {
722 if ( nOfst != nNewOfst )
723 _SetOfst( nNewOfst );
724 }
725
SetRepaint() const726 inline void SwTxtFrm::SetRepaint() const
727 {
728 ((SwTxtFrm*)this)->bRepaint = sal_True;
729 }
ResetRepaint() const730 inline void SwTxtFrm::ResetRepaint() const
731 {
732 ((SwTxtFrm*)this)->bRepaint = sal_False;
733 }
734
SetBlinkPor() const735 inline void SwTxtFrm::SetBlinkPor() const
736 {
737 ((SwTxtFrm*)this)->bBlinkPor = sal_True;
738 }
ResetBlinkPor() const739 inline void SwTxtFrm::ResetBlinkPor() const
740 {
741 ((SwTxtFrm*)this)->bBlinkPor = sal_False;
742 }
743
744 #ifdef LINGU_STATISTIK
745
746 class SwLinguStatistik
747 {
748 public:
749 long nWords; // gepruefte Worte
750 long nFlushCnt; // zaehlt die Messungen
751
752 long nWrong; // als falsch erkannt
753 long nAlter; // Alternativvorschlaege
754 long nSpellTime; // Zeitmessung
755 long nSynonym; // Thesaurus
756 long nNoSynonym; // Thesaurus ratlos
757 long nMeaning; // Thesaurus-Bedeutung
758 long nNoMeaning; // Thesaurus meinungslos
759 long nTheTime; // Zeitmessung
760 long nHyphens; // Trennstellen
761 long nNoHyph; // Worte ohne Trennstellen
762 long nHyphErr; // Fehler beim Trennen
763 long nHyphTime; // Zeitmessung
764 SpellCheck *pSpell;
765 LanguageType eLang;
766
767 void Flush();
768
SwLinguStatistik()769 inline SwLinguStatistik()
770 { nWords = nWrong = nAlter = nSynonym = nNoSynonym =
771 nHyphens = nNoHyph = nHyphErr = nSpellTime = nTheTime =
772 nHyphTime = nFlushCnt = 0;
773 pSpell = NULL;
774 eLang = LANGUAGE_DONTKNOW; }
~SwLinguStatistik()775 inline ~SwLinguStatistik(){ Flush(); }
776 };
777
778 // globale Variable, implementiert in txtfrm.cxx
779 extern SwLinguStatistik aSwLinguStat;
780
781 #define SW_LING(nWhich,nInc) (aSwLinguStat.nWhich) += nInc;
782
783 #endif
784
785 #define SWAP_IF_SWAPPED( pFrm )\
786 sal_Bool bUndoSwap = sal_False; \
787 if ( pFrm->IsVertical() && pFrm->IsSwapped() )\
788 { \
789 bUndoSwap = sal_True; \
790 ((SwTxtFrm*)pFrm)->SwapWidthAndHeight(); \
791 }
792
793 #define SWAP_IF_NOT_SWAPPED( pFrm )\
794 sal_Bool bUndoSwap = sal_False; \
795 if ( pFrm->IsVertical() && ! pFrm->IsSwapped() )\
796 { \
797 bUndoSwap = sal_True; \
798 ((SwTxtFrm*)pFrm)->SwapWidthAndHeight(); \
799 }
800
801 #define UNDO_SWAP( pFrm )\
802 if ( bUndoSwap )\
803 ((SwTxtFrm*)pFrm)->SwapWidthAndHeight();
804
805 // Helper class which can be used instead of the macros if a function
806 // has too many returns
807 class SwFrmSwapper
808 {
809 const SwTxtFrm* pFrm;
810 sal_Bool bUndo;
811 public:
812 SwFrmSwapper( const SwTxtFrm* pFrm, sal_Bool bSwapIfNotSwapped );
813 ~SwFrmSwapper();
814 };
815
816 class SwLayoutModeModifier
817 {
818 const OutputDevice& rOut;
819 long nOldLayoutMode;
820 public:
821 SwLayoutModeModifier( const OutputDevice& rOutp );
822 ~SwLayoutModeModifier();
823 void Modify( sal_Bool bChgToRTL );
824 void SetAuto();
825 };
826
827 class SwDigitModeModifier
828 {
829 const OutputDevice& rOut;
830 LanguageType nOldLanguageType;
831 public:
832 SwDigitModeModifier( const OutputDevice& rOutp, LanguageType eCurLang );
833 ~SwDigitModeModifier();
834 };
835
836 #endif
837