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