xref: /aoo42x/main/sw/source/core/text/inftxt.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _INFTXT_HXX
28 #define _INFTXT_HXX
29 #include <com/sun/star/linguistic2/XHyphenatedWord.hpp>
30 #include <com/sun/star/beans/PropertyValues.hpp>
31 
32 #ifndef _TABLE_HXX //autogen
33 #include <tools/table.hxx>
34 #endif
35 
36 #include "swtypes.hxx"
37 #include "txttypes.hxx"
38 #include "swrect.hxx"
39 #include "txtfly.hxx"
40 #include "swfont.hxx"
41 #include "porlay.hxx"
42 #include "txtfrm.hxx"
43 #include "ndtxt.hxx"
44 #include "txttypes.hxx"
45 #include <editeng/paravertalignitem.hxx>
46 
47 class Font;
48 class OutputDevice;
49 class SvxBrushItem;
50 class SvxLineSpacingItem;
51 class SvxTabStop;
52 class SvxTabStopItem;
53 class SwAttrSet;
54 class SwFldPortion;
55 class SwFlyPortion;
56 class SwFmtDrop;
57 class SwLineLayout;
58 class SwLinePortion;
59 class SwParaPortion;
60 class SwTabPortion;
61 class SwTxtFrm;
62 class SwTxtSizeInfo;
63 class SwViewOption;
64 class ViewShell;
65 class SwTxtFtn;
66 class SwAttrIter;
67 struct SwMultiCreator;
68 class SwMultiPortion;
69 class SwWrongList;
70 
71 /* Minimum: Prozentwert fuers kernen */
72 #define MINKERNPERCENT 5
73 #define ARROW_WIDTH	200
74 #define DIR_LEFT2RIGHT 0
75 #define DIR_BOTTOM2TOP 1
76 #define DIR_RIGHT2LEFT 2
77 #define DIR_TOP2BOTTOM 3
78 
79 #ifdef DBG_UTIL
80 #define OPTCALM( rInf )  (rInf).IsOptCalm()
81 #define OPTLOW( rInf )	 (rInf).IsOptLow()
82 #define OPTDBG( rInf )	 (rInf).IsOptDbg()
83 #else
84 #define OPTCALM( rInf )  sal_True
85 #define OPTLOW( rInf )	 sal_False
86 #define OPTDBG( rInf )	 sal_False
87 #endif
88 
89 /*************************************************************************
90  *						class SwLineInfo
91  *************************************************************************/
92 
93 // Beruecksichtigt das Attribut LineSpace bei der Hoehen/Ascentberechnung.
94 
95 class SwLineInfo
96 {
97 	friend class SwTxtIter;
98 
99     SvxTabStopItem* pRuler;
100 	const SvxLineSpacingItem *pSpace;
101     sal_uInt16 nVertAlign;
102     KSHORT nDefTabStop;
103     // --> OD 2008-02-04 #newlistlevelattrs#
104     bool bListTabStopIncluded;
105     long nListTabStopPosition;
106     // <--
107 
108     // --> OD 2008-01-17 #newlistlevelattrs#
109     void CtorInitLineInfo( const SwAttrSet& rAttrSet,
110                            const SwTxtNode& rTxtNode );
111     // <--
112 
113     // --> OD 2008-01-17 #newlistlevelattrs#
114     SwLineInfo();
115     ~SwLineInfo();
116 public:
117 //        const SvxTabStop *GetTabStop( const SwTwips nLinePos,
118 //                                        const SwTwips nLeft,
119     // #i24363# tab stops relative to indent - returns the tab stop following nSearchPos or NULL
120     const SvxTabStop *GetTabStop( const SwTwips nSearchPos,
121 								 const SwTwips nRight ) const;
122 	inline const SvxLineSpacingItem *GetLineSpacing() const { return pSpace; }
123 	inline KSHORT GetDefTabStop() const { return nDefTabStop; }
124 	inline void SetDefTabStop( KSHORT nNew ) const
125 		{ ( (SwLineInfo*)this )->nDefTabStop = nNew; }
126 
127     // vertical alignment
128     inline sal_uInt16 GetVertAlign() const { return nVertAlign; }
129     inline sal_Bool HasSpecialAlign( sal_Bool bVert ) const
130         { return bVert ?
131                  ( SvxParaVertAlignItem::BASELINE  != nVertAlign ) :
132                  ( SvxParaVertAlignItem::BASELINE  != nVertAlign &&
133                    SvxParaVertAlignItem::AUTOMATIC != nVertAlign ); }
134 
135     sal_uInt16 NumberOfTabStops() const;
136 
137     // --> OD 2008-02-04 #newlistlevelattrs#
138     inline bool IsListTabStopIncluded() const
139     {
140         return bListTabStopIncluded;
141     }
142     inline long GetListTabStopPosition() const
143     {
144         return nListTabStopPosition;
145     }
146     // <--
147 
148 
149 //  friend ostream &operator<<( ostream &rOS, const SwLineInfo &rInf );
150 	friend SvStream &operator<<( SvStream &rOS, const SwLineInfo &rInf );
151 };
152 
153 /*************************************************************************
154  *						class SwTxtInfo
155  *************************************************************************/
156 
157 class SwTxtInfo
158 {
159 	// Implementation in txthyph.cxx
160 	friend void SetParaPortion( SwTxtInfo *pInf, SwParaPortion *pRoot );
161 	SwParaPortion *pPara;
162 	xub_StrLen nTxtStart;				  // TxtOfst bei Follows
163 
164 protected:
165 	inline SwTxtInfo() { }
166 public:
167 	void CtorInitTxtInfo( SwTxtFrm *pFrm );
168 	SwTxtInfo( const SwTxtInfo &rInf );
169 	inline SwTxtInfo( SwTxtFrm *pFrm ) { CtorInitTxtInfo( pFrm ); }
170 	inline SwParaPortion *GetParaPortion() { return pPara; }
171 	inline const SwParaPortion *GetParaPortion() const { return pPara; }
172 	inline xub_StrLen GetTxtStart() const { return nTxtStart; }
173 
174 	friend SvStream &operator<<( SvStream &rOS, const SwTxtInfo &rInf );
175 };
176 
177 /*************************************************************************
178  *						class SwTxtSizeInfo
179  *************************************************************************/
180 
181 DECLARE_TABLE( SwTxtPortionTable, sal_IntPtr )
182 
183 class SwTxtSizeInfo : public SwTxtInfo
184 {
185 protected:
186     // during formatting, a small database is built, mapping portion pointers
187     // to their maximum size (used for kana compression)
188     SwTxtPortionTable aMaxWidth;
189     // for each line, an array of compression values is calculated
190     // this array is passed over to the info structure
191     SvUShorts* pKanaComp;
192 
193 	ViewShell	 *pVsh;
194 
195     // pOut is the output device, pRef is the device used for formatting
196     OutputDevice* pOut;
197     OutputDevice* pRef;
198 
199 	SwFont *pFnt;
200     SwUnderlineFont *pUnderFnt; // Font for underlining
201 	SwTxtFrm *pFrm;
202 	const SwViewOption *pOpt;
203 	const XubString *pTxt;
204 	xub_StrLen nIdx, nLen;
205     sal_uInt16 nKanaIdx;
206     sal_Bool bOnWin     : 1;
207 	sal_Bool bNotEOL	: 1;
208 	sal_Bool bURLNotify : 1;
209 	sal_Bool bStopUnderFlow : 1;// Underflow gestoppt z.B. von einer FlyPortion
210     sal_Bool bFtnInside : 1;    // the current line contains a footnote
211     sal_Bool bOtherThanFtnInside : 1; // the current line contains another portion than a footnote portion.
212                                       // needed for checking keep together of footnote portion with previous portion
213 	sal_Bool bMulti : 1;		// inside a multiportion
214     sal_Bool bFirstMulti : 1;   // this flag is used for two purposes:
215                                 // - the multiportion is the first lineportion
216                                 // - indicates, if we are currently in second
217                                 //   line of multi portion
218 	sal_Bool bRuby : 1;			// during the formatting of a phonetic line
219 	sal_Bool bHanging : 1;		// formatting of hanging punctuation allowed
220 	sal_Bool bScriptSpace : 1;	// space between different scripts (Asian/Latin)
221 	sal_Bool bForbiddenChars : 1; // Forbidden start/endline characters
222     sal_Bool bSnapToGrid : 1;   // paragraph snaps to grid
223     sal_uInt8 nDirection : 2;       // writing direction: 0/90/180/270 degree
224 
225 protected:
226 	void CtorInitTxtSizeInfo( SwTxtFrm *pFrm, SwFont *pFnt = 0,
227 				   const xub_StrLen nIdx = 0,
228 				   const xub_StrLen nLen = STRING_LEN );
229 	SwTxtSizeInfo() {}
230 public:
231 	SwTxtSizeInfo( const SwTxtSizeInfo &rInf );
232 	SwTxtSizeInfo( const SwTxtSizeInfo &rInf, const XubString &rTxt,
233 				   const xub_StrLen nIdx = 0,
234 				   const xub_StrLen nLen = STRING_LEN );
235 
236     inline SwTxtSizeInfo( SwTxtFrm *pTxtFrm, SwFont *pTxtFnt = 0,
237                    const xub_StrLen nIndex = 0,
238                    const xub_StrLen nLength = STRING_LEN )
239            { CtorInitTxtSizeInfo( pTxtFrm, pTxtFnt, nIndex, nLength ); }
240 
241 	// GetMultiAttr returns the text attribute of the multiportion,
242 	// if rPos is inside any multi-line part.
243 	// rPos will set to the end of the multi-line part.
244     SwMultiCreator* GetMultiCreator( xub_StrLen &rPos, SwMultiPortion* pM ) const;
245 
246 	inline sal_Bool OnWin() const { return bOnWin; }
247 	inline void SetOnWin( const sal_Bool bNew ) { bOnWin = bNew; }
248 	inline sal_Bool NotEOL() const { return bNotEOL; }
249 	inline void SetNotEOL( const sal_Bool bNew ) { bNotEOL = bNew; }
250 	inline sal_Bool URLNotify() const { return bURLNotify; }
251 	inline void SetURLNotify( const sal_Bool bNew ) { bURLNotify = bNew; }
252 	inline sal_Bool StopUnderFlow() const { return bStopUnderFlow; }
253 	inline void SetStopUnderFlow( const sal_Bool bNew ) { bStopUnderFlow = bNew; }
254 	inline sal_Bool IsFtnInside() const { return bFtnInside; }
255 	inline void SetFtnInside( const sal_Bool bNew ) { bFtnInside = bNew; }
256     inline sal_Bool IsOtherThanFtnInside() const { return bOtherThanFtnInside; }
257     inline void SetOtherThanFtnInside( const sal_Bool bNew ) { bOtherThanFtnInside = bNew; }
258 	inline sal_Bool IsMulti() const { return bMulti; }
259 	inline void SetMulti( const sal_Bool bNew ) { bMulti = bNew; }
260 	inline sal_Bool IsFirstMulti() const { return bFirstMulti; }
261 	inline void SetFirstMulti( const sal_Bool bNew ) { bFirstMulti = bNew; }
262 	inline sal_Bool IsRuby() const { return bRuby; }
263 	inline void SetRuby( const sal_Bool bNew ) { bRuby = bNew; }
264 	inline sal_Bool IsHanging() const { return bHanging; }
265 	inline void SetHanging( const sal_Bool bNew ) { bHanging = bNew; }
266 	inline sal_Bool HasScriptSpace() const { return bScriptSpace; }
267 	inline void SetScriptSpace( const sal_Bool bNew ) { bScriptSpace = bNew; }
268 	inline sal_Bool HasForbiddenChars() const { return bForbiddenChars; }
269 	inline void SetForbiddenChars( const sal_Bool bN ) { bForbiddenChars = bN; }
270     inline sal_Bool SnapToGrid() const { return bSnapToGrid; }
271     inline void SetSnapToGrid( const sal_Bool bN ) { bSnapToGrid = bN; }
272     inline sal_uInt8 GetDirection() const { return nDirection; }
273 	inline void SetDirection( const sal_uInt8 nNew ) { nDirection = nNew; }
274 	inline sal_Bool IsRotated() const { return 0 != ( 1 & nDirection ); }
275 
276 	inline ViewShell *GetVsh() { return pVsh; }
277 	inline const ViewShell *GetVsh() const { return pVsh; }
278 
279     inline OutputDevice *GetOut() { return pOut; }
280 	inline const OutputDevice *GetOut() const { return pOut; }
281     inline void SetOut( OutputDevice* pNewOut ) { pOut = pNewOut; }
282 
283     inline OutputDevice *GetRefDev() { return pRef; }
284     inline const OutputDevice *GetRefDev() const { return pRef; }
285 
286     inline SwFont *GetFont() { return pFnt; }
287 	inline const SwFont *GetFont() const { return pFnt; }
288 	inline void SetFont( SwFont *pNew ) { pFnt = pNew; }
289 	void SelectFont();
290     inline void SetUnderFnt( SwUnderlineFont* pNew ) { pUnderFnt = pNew; }
291     inline SwUnderlineFont* GetUnderFnt() const { return pUnderFnt; }
292 
293 	inline const  SwViewOption &GetOpt() const { return *pOpt; }
294 	inline const XubString &GetTxt() const { return *pTxt; }
295 	inline xub_Unicode GetChar( const xub_StrLen nPos ) const
296 		{ return pTxt->GetChar( nPos ); }
297 
298 	inline KSHORT	   GetTxtHeight() const;
299 
300     //
301     // GetTxtSize
302     //
303     SwPosSize GetTxtSize( OutputDevice* pOut, const SwScriptInfo* pSI,
304                           const XubString& rTxt, const xub_StrLen nIdx,
305                           const xub_StrLen nLen, const sal_uInt16 nComp ) const;
306     SwPosSize GetTxtSize() const;
307     void GetTxtSize( const SwScriptInfo* pSI, const xub_StrLen nIdx,
308                       const xub_StrLen nLen, const sal_uInt16 nComp,
309                       sal_uInt16& nMinSize, sal_uInt16& nMaxSizeDiff ) const;
310     inline SwPosSize GetTxtSize( const SwScriptInfo* pSI, const xub_StrLen nIdx,
311                                  const xub_StrLen nLen, const sal_uInt16 nComp ) const;
312     inline SwPosSize GetTxtSize( const XubString &rTxt ) const;
313 
314     //
315     // GetTxtBreak
316     //
317     xub_StrLen GetTxtBreak( const long nLineWidth,
318                                            const xub_StrLen nMaxLen,
319                                            const sal_uInt16 nComp ) const;
320     xub_StrLen GetTxtBreak( const long nLineWidth,
321                                            const xub_StrLen nMaxLen,
322                                            const sal_uInt16 nComp,
323                                            xub_StrLen& rExtraCharPos ) const;
324 
325     inline KSHORT GetAscent() const;
326 
327 	inline xub_StrLen GetIdx() const { return nIdx; }
328 	inline void SetIdx( const xub_StrLen nNew ) { nIdx = nNew; }
329 	inline xub_StrLen GetLen() const { return nLen; }
330 	inline void SetLen( const xub_StrLen nNew ) { nLen = nNew; }
331 	inline void SetTxt( const XubString &rNew ){ pTxt = &rNew; }
332 
333 	friend SvStream &operator<<( SvStream &rOS, const SwTxtSizeInfo &rInf );
334 
335 // 7780: Keine Bullets beim Symbol-Zeichensatz!
336 	inline sal_Bool IsNoSymbol() const
337 	{ return RTL_TEXTENCODING_SYMBOL != pFnt->GetCharSet( pFnt->GetActual() ); }
338 
339     void NoteAnimation() const;
340 
341     // Home is where Your heart is...
342 	inline SwTxtFrm *GetTxtFrm() { return pFrm; }
343 	inline const SwTxtFrm *GetTxtFrm() const { return pFrm; }
344 
345 	inline sal_Bool HasHint( xub_StrLen nPos ) const
346 		{ return _HasHint( pFrm->GetTxtNode(), nPos ); }
347 	static sal_Bool _HasHint( const SwTxtNode* pTxtNode, xub_StrLen nPos );
348 
349     // If Kana Compression is enabled, a minimum and maximum portion width
350     // is calculated. We format lines with minimal size and share remaining
351     // space among compressed kanas.
352     // During formatting, the maximum values of compressable portions are
353     // stored in aMaxWidth and discarded after a line has been formatted.
354     inline void SetMaxWidthDiff( sal_uLong nKey, sal_uInt16 nVal )
355     {
356         aMaxWidth.Insert( nKey, nVal );
357     };
358     inline sal_uInt16 GetMaxWidthDiff( sal_uLong nKey )
359     {
360         return (sal_uInt16)aMaxWidth.Get( nKey );
361     };
362     inline void ResetMaxWidthDiff()
363     {
364         aMaxWidth.Clear();
365     };
366     inline sal_Bool CompressLine()
367     {
368         return (sal_Bool)aMaxWidth.Count();
369     };
370 
371     //
372     // Feature: Kana Compression
373     //
374     inline MSHORT GetKanaIdx() const { return nKanaIdx; }
375     inline void ResetKanaIdx(){ nKanaIdx = 0; }
376     inline void SetKanaIdx( MSHORT nNew ) { nKanaIdx = nNew; }
377     inline void IncKanaIdx() { ++nKanaIdx; }
378     inline void SetKanaComp( SvUShorts *pNew ){ pKanaComp = pNew; }
379     inline SvUShorts* GetpKanaComp() const { return pKanaComp; }
380     inline sal_uInt16 GetKanaComp() const
381         { return ( pKanaComp && nKanaIdx < pKanaComp->Count() )
382                    ? (*pKanaComp)[nKanaIdx] : 0; }
383 
384 #ifdef DBG_UTIL
385 	sal_Bool IsOptCalm() const;
386 	sal_Bool IsOptLow() const;
387 	sal_Bool IsOptDbg() const;
388 	sal_Bool IsOptTest1() const;
389 	sal_Bool IsOptTest2() const;
390 	sal_Bool IsOptTest3() const;
391 	sal_Bool IsOptTest4() const;
392 	sal_Bool IsOptTest5() const;
393 	sal_Bool IsOptTest6() const;
394 	sal_Bool IsOptTest7() const;
395 	sal_Bool IsOptTest8() const;
396 #endif
397 };
398 
399 /*************************************************************************
400  *						class SwTxtPaintInfo
401  *************************************************************************/
402 
403 class SwTxtPaintInfo : public SwTxtSizeInfo
404 {
405     const SwWrongList *pWrongList;
406     const SwWrongList *pGrammarCheckList;
407     const SwWrongList *pSmartTags;    // SMARTTAGS
408     std::vector<long>* pSpaceAdd;
409 	const SvxBrushItem *pBrushItem; // Fuer den Hintergrund
410 	SwRect      aItemRect;			// ebenfalls fuer den Hintergrund
411 	SwTxtFly	aTxtFly;	// FlyFrm-Berechnung
412 	Point		aPos;		// Ausgabeposition
413 	SwRect		aPaintRect;	// Original Ausgaberechteck (aus Layout-Paint)
414 
415 	MSHORT nSpaceIdx;
416 	void _DrawText( const XubString &rText, const SwLinePortion &rPor,
417 				   const xub_StrLen nIdx, const xub_StrLen nLen,
418                    const sal_Bool bKern, const sal_Bool bWrong = sal_False,
419                    const sal_Bool bSmartTag = sal_False,
420                    const sal_Bool bGrammarCheck = sal_False );  // SMARTTAGS
421 
422 	SwTxtPaintInfo &operator=(const SwTxtPaintInfo&);
423 	void _NotifyURL( const SwLinePortion &rPor ) const;
424 	void _DrawBackBrush( const SwLinePortion &rPor ) const;
425 
426 protected:
427 #ifndef DBG_UTIL
428     SwTxtPaintInfo() { pFrm = 0; pWrongList = 0; pGrammarCheckList = 0; pWrongList = 0; pSmartTags = 0; pSpaceAdd = 0; pBrushItem = 0;}
429 #else
430     SwTxtPaintInfo() { pFrm = 0; pWrongList = 0; pGrammarCheckList = 0; pSmartTags = 0; pSpaceAdd = 0;
431                        pBrushItem = ((SvxBrushItem*)-1);}
432 #endif
433 public:
434 	SwTxtPaintInfo( const SwTxtPaintInfo &rInf );
435 	SwTxtPaintInfo( const SwTxtPaintInfo &rInf, const XubString &rTxt );
436 
437 	void CtorInitTxtPaintInfo( SwTxtFrm *pFrame, const SwRect &rPaint );
438 
439 	void SetBack( const SvxBrushItem *pItem,
440 				  const SwRect &rRect ) { pBrushItem = pItem; aItemRect = rRect;}
441 	const SvxBrushItem *GetBrushItem() const { return pBrushItem; }
442 	const SwRect       &GetBrushRect() const { return aItemRect;  }
443 
444 	inline SwTxtPaintInfo( SwTxtFrm *pFrame, const SwRect &rPaint )
445 		   { CtorInitTxtPaintInfo( pFrame, rPaint ); }
446 
447 	inline SwTwips X() const { return aPos.X(); }
448 	inline void X( const long nNew ) { aPos.X() = nNew; }
449 	inline SwTwips Y() const { return aPos.Y(); }
450 	inline void Y( const SwTwips nNew ) { aPos.Y() = nNew; }
451 
452 	inline SwTxtFly *GetTxtFly() { return &aTxtFly; }
453 	inline const SwTxtFly *GetTxtFly() const { return &aTxtFly; }
454 	inline void DrawText( const XubString &rText, const SwLinePortion &rPor,
455 						  const xub_StrLen nIdx = 0,
456 						  const xub_StrLen nLen = STRING_LEN,
457 						  const sal_Bool bKern = sal_False) const;
458 	inline void DrawText( const SwLinePortion &rPor, const xub_StrLen nLen,
459 						  const sal_Bool bKern = sal_False ) const;
460     inline void DrawMarkedText( const SwLinePortion &rPor, const xub_StrLen nLen,
461                                 const sal_Bool bKern,
462                                 const sal_Bool bWrong,
463                                 const sal_Bool bSmartTags,
464                                 const sal_Bool bGrammarCheck ) const;
465 
466     void DrawRect( const SwRect &rRect, sal_Bool bNoGraphic = sal_False,
467 				   sal_Bool bRetouche = sal_True ) const;
468 	void DrawTab( const SwLinePortion &rPor ) const;
469 	void DrawLineBreak( const SwLinePortion &rPor ) const;
470     void DrawRedArrow( const SwLinePortion &rPor ) const;
471     void DrawPostIts( const SwLinePortion &rPor, sal_Bool bScript ) const;
472 	void DrawBackground( const SwLinePortion &rPor ) const;
473 	void DrawViewOpt( const SwLinePortion &rPor, const MSHORT nWhich ) const;
474 	inline void DrawBackBrush( const SwLinePortion &rPor ) const
475 	{ /* if( pFnt->GetBackColor() ) */ _DrawBackBrush( rPor ); }
476 
477     void DrawCheckBox( const SwFieldFormPortion &rPor, bool checked) const;
478 
479 	inline void NotifyURL( const SwLinePortion &rPor ) const
480 		{ if( URLNotify() ) _NotifyURL( rPor ); }
481 
482     void CalcRect( const SwLinePortion& rPor, SwRect* pRect, SwRect* pIntersect = 0 ) const;
483 
484 	inline SwTwips GetPaintOfst() const;
485 	inline void SetPaintOfst( const SwTwips nNew );
486 	inline const Point &GetPos() const { return aPos; }
487 	inline void SetPos( const Point &rNew ) { aPos = rNew; }
488 
489 	inline const SwRect &GetPaintRect() const { return aPaintRect; }
490 	inline void SetPaintRect( const SwRect &rNew ) { aPaintRect = rNew; }
491 
492 	friend SvStream &operator<<( SvStream &rOS, const SwTxtPaintInfo &rInf );
493 
494     //
495     // STUFF FOR JUSTIFIED ALIGNMENT
496     //
497     inline MSHORT GetSpaceIdx() const { return nSpaceIdx; }
498 	inline void ResetSpaceIdx(){nSpaceIdx = 0; }
499 	inline void SetSpaceIdx( MSHORT nNew ) { nSpaceIdx = nNew; }
500 	inline void IncSpaceIdx() { ++nSpaceIdx; }
501     inline void RemoveFirstSpaceAdd() { pSpaceAdd->erase( pSpaceAdd->begin() ); }
502     inline long GetSpaceAdd() const
503         { return ( pSpaceAdd && nSpaceIdx < pSpaceAdd->size() )
504 				   ? (*pSpaceAdd)[nSpaceIdx] : 0; }
505 
506     inline void SetpSpaceAdd( std::vector<long>* pNew ){ pSpaceAdd = pNew; }
507     inline std::vector<long>* GetpSpaceAdd() const { return pSpaceAdd; }
508 
509 
510     inline void SetWrongList( const SwWrongList *pNew ){ pWrongList = pNew; }
511     inline const SwWrongList* GetpWrongList() const { return pWrongList; }
512 
513     inline void SetGrammarCheckList( const SwWrongList *pNew ){ pGrammarCheckList = pNew; }
514     inline const SwWrongList* GetGrammarCheckList() const { return pGrammarCheckList; }
515 
516     // SMARTTAGS
517     inline void SetSmartTags( const SwWrongList *pNew ){ pSmartTags = pNew; }
518     inline const SwWrongList* GetSmartTags() const { return pSmartTags; }
519 };
520 
521 /*************************************************************************
522  *						class SwTxtFormatInfo
523  *************************************************************************/
524 
525 class SwTxtFormatInfo : public SwTxtPaintInfo
526 {
527 	// temporary arguments for hyphenation
528 	com::sun::star::beans::PropertyValues	aHyphVals;
529 
530 	SwLineLayout	*pRoot; 	  // die Root der aktuellen Zeile (pCurr)
531 	SwLinePortion	*pLast; 	  // die letzte Portion
532 	SwFlyPortion	*pFly;		  // die nachfolgende FlyPortion
533 	SwFldPortion	*pLastFld;	  // umgebrochenes Feld
534 	SwLinePortion	*pUnderFlow;  // Unterlaufsituation: letzte Portion
535 	SwLinePortion	*pRest; 	  // Rest ist der Beginn der naechsten Zeile
536 
537 	SwTabPortion	*pLastTab;	   // die _letzte_ TabPortion
538 
539 	xub_StrLen nSoftHyphPos;    // SoftHyphPos fuer Hyphenate
540 	xub_StrLen nHyphStart;	    // TxtPos, an der die interakt.Tr.z.Z. steht
541 	xub_StrLen nHyphWrdStart;   // gefundene Wort-Position
542 	xub_StrLen nHyphWrdLen;     // gefundene Wort-Laenge
543 	xub_StrLen nLineStart;		// aktueller Zeilenbeginn im rTxt
544     xub_StrLen nUnderScorePos;  // enlarge repaint if underscore has been found
545     // --> FME 2004-11-25 #i34348# Changed type from sal_uInt16 to SwTwips
546     SwTwips nLeft;          // linker Rand
547     SwTwips nRight;           // rechter Rand
548     SwTwips nFirst;           // EZE
549     // <--
550     KSHORT nRealWidth;      // "echte" Zeilenbreite
551 	KSHORT nWidth;			// "virtuelle" Zeilenbreite
552 	KSHORT nLineHeight; 	// endgueltige Hoehe nach CalcLine
553     KSHORT nLineNettoHeight;   // line height without spacing
554 	KSHORT nForcedLeftMargin;	// Verschiebung des linken Rands wg. Rahmen
555 
556 	sal_Int16  nMinLeading;		// minimum number of chars before hyphenation point
557 	sal_Int16  nMinTrailing;	// minimum number of chars after hyphenation point
558 	sal_Int16  nMinWordLength;	// minimum length of word to be hyphenated
559 
560 	sal_Bool bFull	 : 1;	   // Zeile ist voll
561 	sal_Bool bFtnDone  : 1;	   // Ftn bereits formatiert
562 	sal_Bool bErgoDone : 1;	   // ErgoDone bereits formatiert
563 	sal_Bool bNumDone  : 1;	   // bNumDone bereits formatiert
564     sal_Bool bArrowDone : 1;    // Pfeil nach links bei gescrollten Absaetzen
565 	sal_Bool bStop	 : 1;	   // Sofort abbrechen, Zeile verwerfen.
566 	sal_Bool bNewLine  : 1;	   // Noch eine weitere Zeile formatieren.
567 	sal_Bool bShift	 : 1;	   // Positionsaend.: Repaint bis auf Weiteres
568 	sal_Bool bUnderFlow : 1;	   // Kontext: UnderFlow() ?
569 	sal_Bool bInterHyph: 1;	   // interaktive Trennung ?
570 	sal_Bool bAutoHyph : 1;	   // automatische Trennung ?
571 	sal_Bool bDropInit : 1;	   // DropWidth einstellen.
572 	sal_Bool bQuick	 : 1;	   // FormatQuick()
573 	sal_Bool bNoEndHyph	 : 1;  // Trennung am Zeilenende abgeschaltet wg. MaxHyphens
574 	sal_Bool bNoMidHyph	 : 1;  // Trennung vor Flies abgeschaltet wg. MaxHyphens
575 	sal_Bool bIgnoreFly: 1;	   // FitToContent ignoriert Flies
576     sal_Bool bFakeLineStart: 1; // String has been replaced by field portion
577                                 // info structure only pretends that we are at
578                                 // the beginning of a line
579 
580 	xub_Unicode   cTabDecimal;	// das _aktuelle_ Dezimalzeichen
581 	xub_Unicode   cHookChar;	// fuer Tabs in Feldern etc.
582 	sal_uInt8   nMaxHyph;		// max. Zeilenanz. aufeinanderfolg. Trenn.
583 	sal_Bool   bTestFormat;		// Testformatierung aus WouldFit, keine Benachrichtigungen etc.
584 
585 	// Hyphenating ...
586 	sal_Bool InitHyph( const sal_Bool bAuto = sal_False );
587 	sal_Bool _CheckFtnPortion( SwLineLayout* pCurr );
588 
589 public:
590 	void CtorInitTxtFormatInfo( SwTxtFrm *pFrm, const sal_Bool bInterHyph = sal_False,
591 		const sal_Bool bQuick = sal_False, const sal_Bool bTst = sal_False );
592     inline SwTxtFormatInfo(SwTxtFrm *pFrame,const sal_Bool bInterHyphL=sal_False,
593             const sal_Bool bQuickL = sal_False, const sal_Bool bTst = sal_False )
594            { CtorInitTxtFormatInfo( pFrame, bInterHyphL, bQuickL, bTst ); }
595 
596 	// For the formatting inside a double line in a line (multi-line portion)
597 	// we need a modified text-format-info:
598 	SwTxtFormatInfo( const SwTxtFormatInfo& rInf, SwLineLayout& rLay,
599 		SwTwips nActWidth );
600 
601 	inline KSHORT Width() const { return nWidth; }
602 	inline void Width( const KSHORT nNew ) { nWidth = nNew; }
603 		   void Init();
604 
605 	// liefert die erste veraenderte Position im Absatz zurueck
606 	inline xub_StrLen GetReformatStart() const;
607 
608 	// Raender
609     inline SwTwips Left() const { return nLeft; }
610     inline void Left( const SwTwips nNew ) { nLeft = nNew; }
611     inline SwTwips Right() const { return nRight; }
612     inline void Right( const SwTwips nNew ) { nRight = nNew; }
613     inline SwTwips First() const { return nFirst; }
614     inline void First( const SwTwips nNew ) { nFirst = nNew; }
615     inline SwTwips CurrLeft() const { return (nLineStart ? nLeft : nFirst); }
616 	inline KSHORT RealWidth() const { return nRealWidth; }
617 	inline void RealWidth( const KSHORT nNew ) { nRealWidth = nNew; }
618 	inline KSHORT ForcedLeftMargin() const { return nForcedLeftMargin; }
619 	inline void ForcedLeftMargin( const KSHORT nN ) { nForcedLeftMargin = nN; }
620 
621 	inline sal_uInt8 &MaxHyph() { return nMaxHyph; }
622 	inline const sal_uInt8 &MaxHyph() const { return nMaxHyph; }
623 
624 	inline SwLineLayout *GetRoot() { return pRoot; }
625 	inline const SwLineLayout *GetRoot() const { return pRoot; }
626 
627 	inline void SetRoot( SwLineLayout *pNew ) { pRoot = pNew; }
628 	inline SwLinePortion *GetLast() { return pLast; }
629 	inline void SetLast( SwLinePortion *pNewLast ) { pLast = pNewLast; }
630 	inline sal_Bool IsFull() const { return bFull; }
631 	inline void SetFull( const sal_Bool bNew ) { bFull = bNew; }
632 	inline sal_Bool IsHyphForbud() const
633 		{ return pFly ? bNoMidHyph : bNoEndHyph; }
634 	inline void SetHyphForbud( const sal_Bool bNew )
635 		{ if ( pFly ) bNoMidHyph = bNew; else bNoEndHyph = bNew; }
636 	inline void ChkNoHyph( const sal_uInt8 bEnd, const sal_uInt8 bMid )
637 		{ bNoEndHyph = (nMaxHyph && bEnd >= nMaxHyph);
638 		  bNoMidHyph = (nMaxHyph && bMid >= nMaxHyph); }
639 	inline sal_Bool IsIgnoreFly() const { return bIgnoreFly; }
640 	inline void SetIgnoreFly( const sal_Bool bNew ) { bIgnoreFly = bNew; }
641     inline sal_Bool IsFakeLineStart() const { return bFakeLineStart; }
642     inline void SetFakeLineStart( const sal_Bool bNew ) { bFakeLineStart = bNew; }
643 	inline sal_Bool IsStop() const { return bStop; }
644 	inline void SetStop( const sal_Bool bNew ) { bStop = bNew; }
645 	inline SwLinePortion *GetRest() { return pRest; }
646 	inline void SetRest( SwLinePortion *pNewRest ) { pRest = pNewRest; }
647 	inline sal_Bool IsNewLine() const { return bNewLine; }
648 	inline void SetNewLine( const sal_Bool bNew ) { bNewLine = bNew; }
649 	inline sal_Bool IsShift() const { return bShift; }
650 	inline void SetShift( const sal_Bool bNew ) { bShift = bNew; }
651 	inline sal_Bool IsInterHyph() const { return bInterHyph; }
652 	inline sal_Bool IsAutoHyph() const { return bAutoHyph; }
653 	inline sal_Bool IsUnderFlow() const { return bUnderFlow; }
654 	inline void ClrUnderFlow() { bUnderFlow = sal_False; }
655 	inline sal_Bool IsDropInit() const { return bDropInit; }
656 	inline void SetDropInit( const sal_Bool bNew ) { bDropInit = bNew; }
657 	inline sal_Bool IsQuick() const { return bQuick; }
658 	inline sal_Bool IsTest() const { return bTestFormat; }
659 
660 	inline xub_StrLen GetLineStart() const { return nLineStart; }
661 	inline void SetLineStart( const xub_StrLen nNew ) { nLineStart = nNew; }
662 
663     // these are used during fly calculation
664     inline KSHORT GetLineHeight() const { return nLineHeight; }
665 	inline void SetLineHeight( const KSHORT nNew ) { nLineHeight = nNew; }
666     inline KSHORT GetLineNettoHeight() const { return nLineNettoHeight; }
667     inline void SetLineNettoHeight( const KSHORT nNew ) { nLineNettoHeight = nNew; }
668 
669 	inline const SwLinePortion *GetUnderFlow() const { return pUnderFlow; }
670 	inline SwLinePortion *GetUnderFlow() { return pUnderFlow; }
671 	inline void SetUnderFlow( SwLinePortion *pNew )
672 		   { pUnderFlow = pNew; bUnderFlow = sal_True; }
673 	inline xub_StrLen GetSoftHyphPos() const { return nSoftHyphPos; }
674 	inline void SetSoftHyphPos( const xub_StrLen nNew ) { nSoftHyphPos = nNew; }
675 
676 	inline void SetParaFtn();
677 
678 	// FlyFrms
679 	inline SwFlyPortion *GetFly() { return pFly; }
680 	inline void SetFly( SwFlyPortion *pNew ) { pFly = pNew; }
681 
682 	inline const SwAttrSet& GetCharAttr() const;
683 
684 	// Tabs
685 	inline SwTabPortion *GetLastTab() { return pLastTab; }
686 	inline void SetLastTab( SwTabPortion *pNew ) { pLastTab = pNew; }
687 	inline xub_Unicode GetTabDecimal() const { return cTabDecimal; }
688 	inline void SetTabDecimal( const xub_Unicode cNew ) { cTabDecimal = cNew;}
689 
690 	// Last*
691 	inline SwFldPortion *GetLastFld() { return pLastFld; }
692 	inline void SetLastFld( SwFldPortion *pNew ) { pLastFld = pNew; }
693 
694 	inline void ClearHookChar() { cHookChar = 0; }
695 	inline void SetHookChar( const xub_Unicode cNew ) { cHookChar = cNew; }
696 	inline xub_Unicode GetHookChar() const { return cHookChar; }
697 
698 	// Done-Flags
699 	inline sal_Bool IsFtnDone() const { return bFtnDone; }
700 	inline void SetFtnDone( const sal_Bool bNew ) { bFtnDone = bNew; }
701 	inline sal_Bool IsErgoDone() const { return bErgoDone; }
702 	inline void SetErgoDone( const sal_Bool bNew ) { bErgoDone = bNew; }
703 	inline sal_Bool IsNumDone() const { return bNumDone; }
704 	inline void SetNumDone( const sal_Bool bNew ) { bNumDone = bNew; }
705 	inline sal_Bool IsArrowDone() const { return bArrowDone; }
706 	inline void SetArrowDone( const sal_Bool bNew ) { bArrowDone = bNew; }
707 
708 	// Fuer SwTxtPortion::Hyphenate
709 	inline sal_Bool IsSoftHyph( const xub_StrLen nPos ) const;
710 	sal_Bool ChgHyph( const sal_Bool bNew );
711 
712 	// Soll die Trennhilfe angeschmissen werden?
713 	sal_Bool IsHyphenate() const;
714 	inline void SetHyphStart( const xub_StrLen nNew ) { nHyphStart = nNew; }
715 	inline xub_StrLen GetHyphStart() const { return nHyphStart; }
716 	inline void SetHyphWrdStart( const xub_StrLen nNew ) { nHyphWrdStart = nNew; }
717 	inline xub_StrLen GetHyphWrdStart() const { return nHyphWrdStart; }
718 	inline void SetHyphWrdLen( const xub_StrLen nNew ) { nHyphWrdLen = nNew; }
719 	inline xub_StrLen GetHyphWrdLen() const { return nHyphWrdLen; }
720     inline xub_StrLen GetUnderScorePos() const { return nUnderScorePos; }
721     inline void SetUnderScorePos( xub_StrLen nNew ) { nUnderScorePos = nNew; }
722 
723 	// ruft HyphenateWord() des Hyphenators
724 	::com::sun::star::uno::Reference<
725 		::com::sun::star::linguistic2::XHyphenatedWord >
726 				HyphWord( const String &rTxt, const sal_uInt16 nMinTrail );
727 	const com::sun::star::beans::PropertyValues	&
728 				GetHyphValues() const;
729 
730 	sal_Bool CheckFtnPortion( SwLineLayout* pCurr )
731 		{ return IsFtnInside() && _CheckFtnPortion( pCurr ); }
732 
733 	// Dropcaps vom SwTxtFormatter::CTOR gerufen.
734 	const SwFmtDrop *GetDropFmt() const;
735 
736 	// setzt die FormatInfo wieder in den Anfangszustand
737 	void Reset( const SwTxtFrm *pFrame); // , const sal_Bool bAll );
738 
739 	// Sets the last SwKernPortion as pLast, if it is followed by empty portions
740 	sal_Bool LastKernPortion();
741 
742     // Sucht ab nIdx bis nEnd nach Tabs, TabDec, TXTATR und BRK.
743 	// Return: gefundene Position, setzt ggf. cHookChar
744     xub_StrLen ScanPortionEnd( const xub_StrLen nStart, const xub_StrLen nEnd );
745 
746 //	friend ostream &operator<<( ostream &rOS, const SwTxtFormatInfo &rInf );
747 	friend SvStream &operator<<( SvStream &rOS, const SwTxtFormatInfo &rInf );
748 };
749 
750 /*************************************************************************
751  *						class SwTxtSlot
752  *************************************************************************/
753 
754 // Fuer die Textersetzung und Restaurierung der SwTxtSizeInfo.
755 // Die Art und Weise ist etwas kriminell, rInf ist const und wird
756 // trotzdem veraendert. Da rInf im DTOR wieder restauriert wird,
757 // ist dies zulaessig, es handelt sich um ein "logisches const".
758 
759 class SwTxtSlot
760 {
761     XubString aTxt;
762     const XubString *pOldTxt;
763     const SwWrongList* pOldSmartTagList;
764     const SwWrongList* pOldGrammarCheckList;
765     SwWrongList* pTempList;
766     xub_StrLen nIdx;
767 	xub_StrLen nLen;
768 	sal_Bool bOn;
769 protected:
770 	SwTxtSizeInfo *pInf;
771 public:
772     // Der Ersetzungstring kommt wahlweise aus der Portion via GetExpText()
773     // oder aus dem char Pointer pCh, wenn dieser ungleich NULL ist.
774     SwTxtSlot( const SwTxtSizeInfo *pNew, const SwLinePortion *pPor, bool bTxtLen,
775                bool bExgLists, const sal_Char *pCh = NULL );
776     ~SwTxtSlot();
777 	inline sal_Bool IsOn() const { return bOn; }
778 };
779 
780 /*************************************************************************
781  *						class SwFontSave
782  *************************************************************************/
783 
784 class SwFontSave
785 {
786 	SwTxtSizeInfo *pInf;
787 	SwFont		  *pFnt;
788 	SwAttrIter	  *pIter;
789 public:
790 	SwFontSave( const SwTxtSizeInfo &rInf, SwFont *pFnt,
791 				SwAttrIter* pItr = NULL );
792    ~SwFontSave();
793 };
794 
795 /*************************************************************************
796  *						class SwDefFontSave
797  *************************************************************************/
798 
799 class SwDefFontSave
800 {
801 	SwTxtSizeInfo *pInf;
802 	SwFont		  *pFnt;
803 	SwFont		  *pNewFnt;
804 	sal_Bool		   bAlter;
805 public:
806 	SwDefFontSave( const SwTxtSizeInfo &rInf );
807    ~SwDefFontSave();
808 };
809 
810 /*************************************************************************
811  *                       Inline-Implementierungen SwTxtSizeInfo
812  *************************************************************************/
813 
814 inline KSHORT SwTxtSizeInfo::GetAscent() const
815 {
816     ASSERT( GetOut(), "SwTxtSizeInfo::GetAscent() without pOut" )
817     return ((SwFont*)GetFont())->GetAscent( pVsh, *GetOut() );
818 }
819 
820 inline KSHORT SwTxtSizeInfo::GetTxtHeight() const
821 {
822     ASSERT( GetOut(), "SwTxtSizeInfo::GetTxtHeight() without pOut" )
823     return ((SwFont*)GetFont())->GetHeight( pVsh, *GetOut() );
824 }
825 
826 inline SwPosSize SwTxtSizeInfo::GetTxtSize( const XubString &rTxt ) const
827 {
828     return GetTxtSize( pOut, 0, rTxt, 0, rTxt.Len(), 0 );
829 }
830 
831 inline SwPosSize SwTxtSizeInfo::GetTxtSize( const SwScriptInfo* pSI,
832                                             const xub_StrLen nNewIdx,
833                                             const xub_StrLen nNewLen,
834                                             const sal_uInt16 nCompress ) const
835 {
836     return GetTxtSize( pOut, pSI, *pTxt, nNewIdx, nNewLen, nCompress );
837 }
838 
839 /*************************************************************************
840  *                       Inline-Implementierungen SwTxtPaintInfo
841  *************************************************************************/
842 
843 inline SwTwips SwTxtPaintInfo::GetPaintOfst() const
844 {
845 	return GetParaPortion()->GetRepaint()->GetOfst();
846 }
847 
848 inline void SwTxtPaintInfo::SetPaintOfst( const SwTwips nNew )
849 {
850 	GetParaPortion()->GetRepaint()->SetOfst( nNew );
851 }
852 
853 
854 inline void SwTxtPaintInfo::DrawText( const XubString &rText,
855 							const SwLinePortion &rPor,
856                             const xub_StrLen nStart, const xub_StrLen nLength,
857 							const sal_Bool bKern ) const
858 {
859     ((SwTxtPaintInfo*)this)->_DrawText( rText, rPor, nStart, nLength, bKern );
860 }
861 
862 inline void SwTxtPaintInfo::DrawText( const SwLinePortion &rPor,
863         const xub_StrLen nLength, const sal_Bool bKern ) const
864 {
865     ((SwTxtPaintInfo*)this)->_DrawText( *pTxt, rPor, nIdx, nLength, bKern );
866 }
867 
868 inline void SwTxtPaintInfo::DrawMarkedText( const SwLinePortion &rPor,
869                                             const xub_StrLen nLength,
870                                             const sal_Bool bKern,
871                                             const sal_Bool bWrong,
872                                             const sal_Bool bSmartTags,
873                                             const sal_Bool bGrammarCheck ) const
874 {
875     ((SwTxtPaintInfo*)this)->_DrawText( *pTxt, rPor, nIdx, nLength, bKern, bWrong, bSmartTags, bGrammarCheck );
876 }
877 
878 /*************************************************************************
879  *                       Inline-Implementierungen SwTxtFormatInfo
880  *************************************************************************/
881 
882 inline xub_StrLen SwTxtFormatInfo::GetReformatStart() const
883 {
884 	return GetParaPortion()->GetReformat()->Start();
885 }
886 
887 inline const SwAttrSet& SwTxtFormatInfo::GetCharAttr() const
888 {
889 	return GetTxtFrm()->GetTxtNode()->GetSwAttrSet();
890 }
891 
892 inline void SwTxtFormatInfo::SetParaFtn()
893 {
894 	GetTxtFrm()->SetFtn( sal_True );
895 }
896 
897 inline sal_Bool SwTxtFormatInfo::IsSoftHyph( const xub_StrLen nPos ) const
898 {
899 	return CHAR_SOFTHYPHEN == GetTxtFrm()->GetTxtNode()->GetTxt().GetChar(nPos);
900 }
901 
902 
903 
904 #endif
905 
906