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