Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #ifndef _INFTXT_HXX
20 : #define _INFTXT_HXX
21 : #include <com/sun/star/linguistic2/XHyphenatedWord.hpp>
22 : #include <com/sun/star/beans/PropertyValues.hpp>
23 :
24 : #include <map>
25 :
26 : #include "swtypes.hxx"
27 : #include "txttypes.hxx"
28 : #include "swrect.hxx"
29 : #include "txtfly.hxx"
30 : #include "swfont.hxx"
31 : #include "porlay.hxx"
32 : #include "txtfrm.hxx"
33 : #include "ndtxt.hxx"
34 : #include <editeng/paravertalignitem.hxx>
35 :
36 : class Font;
37 : class OutputDevice;
38 : class SvxBrushItem;
39 : class SvxLineSpacingItem;
40 : class SvxTabStop;
41 : class SvxTabStopItem;
42 : class SwAttrSet;
43 : class SwFldPortion;
44 : class SwFlyPortion;
45 : class SwFmtDrop;
46 : class SwLineLayout;
47 : class SwLinePortion;
48 : class SwParaPortion;
49 : class SwTabPortion;
50 : class SwTxtFrm;
51 : class SwTxtSizeInfo;
52 : class SwViewOption;
53 : class ViewShell;
54 : class SwAttrIter;
55 : struct SwMultiCreator;
56 : class SwMultiPortion;
57 : class SwWrongList;
58 :
59 : /* Minimum percentage for kerning */
60 : #define MINKERNPERCENT 5
61 : #define ARROW_WIDTH 200
62 : #define DIR_LEFT2RIGHT 0
63 : #define DIR_BOTTOM2TOP 1
64 : #define DIR_RIGHT2LEFT 2
65 : #define DIR_TOP2BOTTOM 3
66 :
67 : #ifdef DBG_UTIL
68 : #define OPTDBG( rInf ) (rInf).IsOptDbg()
69 : #else
70 : #define OPTDBG( rInf ) sal_False
71 : #endif
72 :
73 : /*************************************************************************
74 : * class SwLineInfo
75 : * Respects the attribute LineSpace when calculating the Height/Ascent
76 : *************************************************************************/
77 :
78 : class SwLineInfo
79 : {
80 : friend class SwTxtIter;
81 :
82 : SvxTabStopItem* pRuler;
83 : const SvxLineSpacingItem *pSpace;
84 : sal_uInt16 nVertAlign;
85 : KSHORT nDefTabStop;
86 : bool bListTabStopIncluded;
87 : long nListTabStopPosition;
88 :
89 : void CtorInitLineInfo( const SwAttrSet& rAttrSet,
90 : const SwTxtNode& rTxtNode );
91 :
92 : SwLineInfo();
93 : ~SwLineInfo();
94 : public:
95 : // #i24363# tab stops relative to indent - returns the tab stop following nSearchPos or NULL
96 : const SvxTabStop *GetTabStop( const SwTwips nSearchPos,
97 : const SwTwips nRight ) const;
98 983 : inline const SvxLineSpacingItem *GetLineSpacing() const { return pSpace; }
99 55 : inline KSHORT GetDefTabStop() const { return nDefTabStop; }
100 51 : inline void SetDefTabStop( KSHORT nNew ) const
101 51 : { ( (SwLineInfo*)this )->nDefTabStop = nNew; }
102 :
103 : // vertical alignment
104 2063 : inline sal_uInt16 GetVertAlign() const { return nVertAlign; }
105 512 : inline bool HasSpecialAlign( sal_Bool bVert ) const
106 : { return bVert ?
107 : ( SvxParaVertAlignItem::BASELINE != nVertAlign ) :
108 : ( SvxParaVertAlignItem::BASELINE != nVertAlign &&
109 512 : SvxParaVertAlignItem::AUTOMATIC != nVertAlign ); }
110 :
111 : sal_uInt16 NumberOfTabStops() const;
112 :
113 38 : inline bool IsListTabStopIncluded() const
114 : {
115 38 : return bListTabStopIncluded;
116 : }
117 10 : inline long GetListTabStopPosition() const
118 : {
119 10 : return nListTabStopPosition;
120 : }
121 :
122 : friend SvStream &operator<<( SvStream &rOS, const SwLineInfo &rInf );
123 : };
124 :
125 : /*************************************************************************
126 : * class SwTxtInfo
127 : *************************************************************************/
128 :
129 : class SwTxtInfo
130 : {
131 : // Implementation in txthyph.cxx
132 : friend void SetParaPortion( SwTxtInfo *pInf, SwParaPortion *pRoot );
133 : SwParaPortion *pPara;
134 : xub_StrLen nTxtStart; // TxtOfst for Follows
135 :
136 : protected:
137 4152 : inline SwTxtInfo() : pPara(0) {}
138 : public:
139 : void CtorInitTxtInfo( SwTxtFrm *pFrm );
140 : SwTxtInfo( const SwTxtInfo &rInf );
141 0 : inline SwTxtInfo( SwTxtFrm *pFrm ) { CtorInitTxtInfo( pFrm ); }
142 20489 : inline SwParaPortion *GetParaPortion() { return pPara; }
143 6730 : inline const SwParaPortion *GetParaPortion() const { return pPara; }
144 13159 : inline xub_StrLen GetTxtStart() const { return nTxtStart; }
145 :
146 : friend SvStream &operator<<( SvStream &rOS, const SwTxtInfo &rInf );
147 : };
148 :
149 : /*************************************************************************
150 : * class SwTxtSizeInfo
151 : *************************************************************************/
152 :
153 : typedef ::std::map< sal_uLong, sal_IntPtr > SwTxtPortionMap;
154 :
155 7137 : class SwTxtSizeInfo : public SwTxtInfo
156 : {
157 : protected:
158 : // during formatting, a small database is built, mapping portion pointers
159 : // to their maximum size (used for kana compression)
160 : SwTxtPortionMap aMaxWidth;
161 : // for each line, an array of compression values is calculated
162 : // this array is passed over to the info structure
163 : std::deque<sal_uInt16>* pKanaComp;
164 :
165 : ViewShell *pVsh;
166 :
167 : // pOut is the output device, pRef is the device used for formatting
168 : OutputDevice* pOut;
169 : OutputDevice* pRef;
170 :
171 : SwFont *pFnt;
172 : SwUnderlineFont *pUnderFnt; // Font for underlining
173 : SwTxtFrm *pFrm;
174 : const SwViewOption *pOpt;
175 : const XubString *pTxt;
176 : xub_StrLen nIdx, nLen;
177 : sal_uInt16 nKanaIdx;
178 : bool bOnWin : 1;
179 : bool bNotEOL : 1;
180 : bool bURLNotify : 1;
181 : bool bStopUnderFlow : 1; // Underflow was stopped e.g. by a FlyPortion
182 : bool bFtnInside : 1; // the current line contains a footnote
183 : bool bOtherThanFtnInside : 1; // the current line contains another portion than a footnote portion.
184 : // needed for checking keep together of footnote portion with previous portion
185 : bool bMulti : 1; // inside a multiportion
186 : bool bFirstMulti : 1; // this flag is used for two purposes:
187 : // - the multiportion is the first lineportion
188 : // - indicates, if we are currently in second
189 : // line of multi portion
190 : bool bRuby : 1; // during the formatting of a phonetic line
191 : bool bHanging : 1; // formatting of hanging punctuation allowed
192 : bool bScriptSpace : 1; // space between different scripts (Asian/Latin)
193 : bool bForbiddenChars : 1; // Forbidden start/endline characters
194 : bool bSnapToGrid : 1; // paragraph snaps to grid
195 : sal_uInt8 nDirection : 2; // writing direction: 0/90/180/270 degree
196 :
197 : protected:
198 : void CtorInitTxtSizeInfo( SwTxtFrm *pFrm, SwFont *pFnt = 0,
199 : const xub_StrLen nIdx = 0,
200 : const xub_StrLen nLen = STRING_LEN );
201 1169 : SwTxtSizeInfo() : pKanaComp(0), pVsh(0), pOut(0), pRef(0), pFnt(0), pUnderFnt(0), pFrm(0), pOpt(0), pTxt(0) {}
202 : public:
203 : SwTxtSizeInfo( const SwTxtSizeInfo &rInf );
204 : SwTxtSizeInfo( const SwTxtSizeInfo &rInf, const XubString &rTxt,
205 : const xub_StrLen nIdx = 0,
206 : const xub_StrLen nLen = STRING_LEN );
207 :
208 2983 : inline SwTxtSizeInfo( SwTxtFrm *pTxtFrm, SwFont *pTxtFnt = 0,
209 : const xub_StrLen nIndex = 0,
210 : const xub_StrLen nLength = STRING_LEN )
211 2983 : { CtorInitTxtSizeInfo( pTxtFrm, pTxtFnt, nIndex, nLength ); }
212 :
213 : // GetMultiAttr returns the text attribute of the multiportion,
214 : // if rPos is inside any multi-line part.
215 : // rPos will set to the end of the multi-line part.
216 : SwMultiCreator* GetMultiCreator( xub_StrLen &rPos, SwMultiPortion* pM ) const;
217 :
218 8119 : inline bool OnWin() const { return bOnWin; }
219 1508 : inline void SetOnWin( const bool bNew ) { bOnWin = bNew; }
220 2986 : inline bool NotEOL() const { return bNotEOL; }
221 148 : inline void SetNotEOL( const bool bNew ) { bNotEOL = bNew; }
222 2985 : inline bool URLNotify() const { return bURLNotify; }
223 : inline void SetURLNotify( const bool bNew ) { bURLNotify = bNew; }
224 2985 : inline bool StopUnderFlow() const { return bStopUnderFlow; }
225 1759 : inline void SetStopUnderFlow( const bool bNew ) { bStopUnderFlow = bNew; }
226 3709 : inline bool IsFtnInside() const { return bFtnInside; }
227 729 : inline void SetFtnInside( const bool bNew ) { bFtnInside = bNew; }
228 3989 : inline bool IsOtherThanFtnInside() const { return bOtherThanFtnInside; }
229 1728 : inline void SetOtherThanFtnInside( const bool bNew ) { bOtherThanFtnInside = bNew; }
230 4447 : inline bool IsMulti() const { return bMulti; }
231 1 : inline void SetMulti( const bool bNew ) { bMulti = bNew; }
232 3005 : inline bool IsFirstMulti() const { return bFirstMulti; }
233 2 : inline void SetFirstMulti( const bool bNew ) { bFirstMulti = bNew; }
234 3990 : inline bool IsRuby() const { return bRuby; }
235 1 : inline void SetRuby( const bool bNew ) { bRuby = bNew; }
236 3063 : inline bool IsHanging() const { return bHanging; }
237 692 : inline void SetHanging( const bool bNew ) { bHanging = bNew; }
238 4904 : inline bool HasScriptSpace() const { return bScriptSpace; }
239 692 : inline void SetScriptSpace( const bool bNew ) { bScriptSpace = bNew; }
240 3063 : inline bool HasForbiddenChars() const { return bForbiddenChars; }
241 692 : inline void SetForbiddenChars( const bool bN ) { bForbiddenChars = bN; }
242 4221 : inline bool SnapToGrid() const { return bSnapToGrid; }
243 4153 : inline void SetSnapToGrid( const bool bN ) { bSnapToGrid = bN; }
244 8876 : inline sal_uInt8 GetDirection() const { return nDirection; }
245 4 : inline void SetDirection( const sal_uInt8 nNew ) { nDirection = nNew; }
246 3208 : inline sal_Bool IsRotated() const { return 0 != ( 1 & nDirection ); }
247 :
248 5786 : inline ViewShell *GetVsh() { return pVsh; }
249 3476 : inline const ViewShell *GetVsh() const { return pVsh; }
250 :
251 8648 : inline OutputDevice *GetOut() { return pOut; }
252 3414 : inline const OutputDevice *GetOut() const { return pOut; }
253 1658 : inline void SetOut( OutputDevice* pNewOut ) { pOut = pNewOut; }
254 :
255 3889 : inline OutputDevice *GetRefDev() { return pRef; }
256 : inline const OutputDevice *GetRefDev() const { return pRef; }
257 :
258 7366 : inline SwFont *GetFont() { return pFnt; }
259 3099 : inline const SwFont *GetFont() const { return pFnt; }
260 5531 : inline void SetFont( SwFont *pNew ) { pFnt = pNew; }
261 : void SelectFont();
262 1289 : inline void SetUnderFnt( SwUnderlineFont* pNew ) { pUnderFnt = pNew; }
263 5060 : inline SwUnderlineFont* GetUnderFnt() const { return pUnderFnt; }
264 :
265 7664 : inline const SwViewOption &GetOpt() const { return *pOpt; }
266 25533 : inline const XubString &GetTxt() const { return *pTxt; }
267 13725 : inline sal_Unicode GetChar( const xub_StrLen nPos ) const
268 13725 : { return pTxt->GetChar( nPos ); }
269 :
270 : inline KSHORT GetTxtHeight() const;
271 :
272 : //
273 : // GetTxtSize
274 : //
275 : SwPosSize GetTxtSize( OutputDevice* pOut, const SwScriptInfo* pSI,
276 : const XubString& rTxt, const xub_StrLen nIdx,
277 : const xub_StrLen nLen, const sal_uInt16 nComp ) const;
278 : SwPosSize GetTxtSize() const;
279 : void GetTxtSize( const SwScriptInfo* pSI, const xub_StrLen nIdx,
280 : const xub_StrLen nLen, const sal_uInt16 nComp,
281 : sal_uInt16& nMinSize, sal_uInt16& nMaxSizeDiff ) const;
282 : inline SwPosSize GetTxtSize( const SwScriptInfo* pSI, const xub_StrLen nIdx,
283 : const xub_StrLen nLen, const sal_uInt16 nComp ) const;
284 : inline SwPosSize GetTxtSize( const XubString &rTxt ) const;
285 :
286 : //
287 : // GetTxtBreak
288 : //
289 : xub_StrLen GetTxtBreak( const long nLineWidth,
290 : const xub_StrLen nMaxLen,
291 : const sal_uInt16 nComp ) const;
292 : xub_StrLen GetTxtBreak( const long nLineWidth,
293 : const xub_StrLen nMaxLen,
294 : const sal_uInt16 nComp,
295 : xub_StrLen& rExtraCharPos ) const;
296 :
297 : inline KSHORT GetAscent() const;
298 :
299 41700 : inline xub_StrLen GetIdx() const { return nIdx; }
300 6589 : inline void SetIdx( const xub_StrLen nNew ) { nIdx = nNew; }
301 12714 : inline xub_StrLen GetLen() const { return nLen; }
302 10841 : inline void SetLen( const xub_StrLen nNew ) { nLen = nNew; }
303 396 : inline void SetTxt( const XubString &rNew ){ pTxt = &rNew; }
304 :
305 : friend SvStream &operator<<( SvStream &rOS, const SwTxtSizeInfo &rInf );
306 :
307 : // No Bullets for the symbol font!
308 0 : inline sal_Bool IsNoSymbol() const
309 0 : { return RTL_TEXTENCODING_SYMBOL != pFnt->GetCharSet( pFnt->GetActual() ); }
310 :
311 : void NoteAnimation() const;
312 :
313 : // Home is where Your heart is...
314 9130 : inline SwTxtFrm *GetTxtFrm() { return pFrm; }
315 7896 : inline const SwTxtFrm *GetTxtFrm() const { return pFrm; }
316 :
317 183 : inline sal_Bool HasHint( xub_StrLen nPos ) const
318 183 : { return _HasHint( pFrm->GetTxtNode(), nPos ); }
319 : static sal_Bool _HasHint( const SwTxtNode* pTxtNode, xub_StrLen nPos );
320 :
321 : // If Kana Compression is enabled, a minimum and maximum portion width
322 : // is calculated. We format lines with minimal size and share remaining
323 : // space among compressed kanas.
324 : // During formatting, the maximum values of compressable portions are
325 : // stored in aMaxWidth and discarded after a line has been formatted.
326 0 : inline void SetMaxWidthDiff( sal_uLong nKey, sal_uInt16 nVal )
327 : {
328 0 : aMaxWidth.insert( ::std::make_pair( nKey, nVal ) );
329 0 : };
330 0 : inline sal_uInt16 GetMaxWidthDiff( sal_uLong nKey )
331 : {
332 0 : SwTxtPortionMap::iterator it = aMaxWidth.find( nKey );
333 :
334 0 : if( it != aMaxWidth.end() )
335 0 : return it->second;
336 : else
337 0 : return 0;
338 : };
339 0 : inline void ResetMaxWidthDiff()
340 : {
341 0 : aMaxWidth.clear();
342 0 : };
343 724 : inline sal_Bool CompressLine()
344 : {
345 724 : return (sal_Bool)!aMaxWidth.empty();
346 : };
347 :
348 : //
349 : // Feature: Kana Compression
350 : //
351 2985 : inline MSHORT GetKanaIdx() const { return nKanaIdx; }
352 1225 : inline void ResetKanaIdx(){ nKanaIdx = 0; }
353 0 : inline void SetKanaIdx( MSHORT nNew ) { nKanaIdx = nNew; }
354 177 : inline void IncKanaIdx() { ++nKanaIdx; }
355 1225 : inline void SetKanaComp( std::deque<sal_uInt16> *pNew ){ pKanaComp = pNew; }
356 2985 : inline std::deque<sal_uInt16>* GetpKanaComp() const { return pKanaComp; }
357 449 : inline sal_uInt16 GetKanaComp() const
358 0 : { return ( pKanaComp && nKanaIdx < pKanaComp->size() )
359 449 : ? (*pKanaComp)[nKanaIdx] : 0; }
360 :
361 : #ifdef DBG_UTIL
362 : sal_Bool IsOptDbg() const;
363 : #endif
364 : };
365 :
366 : /*************************************************************************
367 : * class SwTxtPaintInfo
368 : *************************************************************************/
369 :
370 1890 : class SwTxtPaintInfo : public SwTxtSizeInfo
371 : {
372 : const SwWrongList *pWrongList;
373 : const SwWrongList *pGrammarCheckList;
374 : const SwWrongList *pSmartTags; // SMARTTAGS
375 : std::vector<long>* pSpaceAdd;
376 : const SvxBrushItem *pBrushItem; // For the background
377 : SwRect aItemRect; // Also for the background
378 : SwTxtFly aTxtFly; // Calculate the FlyFrm
379 : Point aPos; // Paint position
380 : SwRect aPaintRect; // Original paint rect (from Layout paint)
381 :
382 : MSHORT nSpaceIdx;
383 : void _DrawText( const XubString &rText, const SwLinePortion &rPor,
384 : const xub_StrLen nIdx, const xub_StrLen nLen,
385 : const sal_Bool bKern, const sal_Bool bWrong = sal_False,
386 : const sal_Bool bSmartTag = sal_False,
387 : const sal_Bool bGrammarCheck = sal_False ); // SMARTTAGS
388 :
389 : SwTxtPaintInfo &operator=(const SwTxtPaintInfo&);
390 : void _NotifyURL( const SwLinePortion &rPor ) const;
391 : void _DrawBackBrush( const SwLinePortion &rPor ) const;
392 :
393 : protected:
394 : #ifdef DBG_UTIL
395 : SwTxtPaintInfo() { pFrm = 0; pWrongList = 0; pGrammarCheckList = 0; pSmartTags = 0; pSpaceAdd = 0;
396 : pBrushItem = ((SvxBrushItem*)-1);}
397 : #else
398 692 : SwTxtPaintInfo() { pFrm = 0; pWrongList = 0; pGrammarCheckList = 0; pSmartTags = 0; pSpaceAdd = 0;
399 692 : pBrushItem = 0;}
400 : #endif
401 : public:
402 : SwTxtPaintInfo( const SwTxtPaintInfo &rInf );
403 : SwTxtPaintInfo( const SwTxtPaintInfo &rInf, const XubString &rTxt );
404 :
405 : void CtorInitTxtPaintInfo( SwTxtFrm *pFrame, const SwRect &rPaint );
406 :
407 : void SetBack( const SvxBrushItem *pItem,
408 : const SwRect &rRect ) { pBrushItem = pItem; aItemRect = rRect;}
409 721 : const SvxBrushItem *GetBrushItem() const { return pBrushItem; }
410 0 : const SwRect &GetBrushRect() const { return aItemRect; }
411 :
412 477 : inline SwTxtPaintInfo( SwTxtFrm *pFrame, const SwRect &rPaint )
413 477 : { CtorInitTxtPaintInfo( pFrame, rPaint ); }
414 :
415 10091 : inline SwTwips X() const { return aPos.X(); }
416 4140 : inline void X( const long nNew ) { aPos.X() = nNew; }
417 2528 : inline SwTwips Y() const { return aPos.Y(); }
418 2761 : inline void Y( const SwTwips nNew ) { aPos.Y() = nNew; }
419 :
420 4634 : inline SwTxtFly *GetTxtFly() { return &aTxtFly; }
421 1383 : inline const SwTxtFly *GetTxtFly() const { return &aTxtFly; }
422 : inline void DrawText( const XubString &rText, const SwLinePortion &rPor,
423 : const xub_StrLen nIdx = 0,
424 : const xub_StrLen nLen = STRING_LEN,
425 : const sal_Bool bKern = sal_False) const;
426 : inline void DrawText( const SwLinePortion &rPor, const xub_StrLen nLen,
427 : const sal_Bool bKern = sal_False ) const;
428 : inline void DrawMarkedText( const SwLinePortion &rPor, const xub_StrLen nLen,
429 : const sal_Bool bKern,
430 : const sal_Bool bWrong,
431 : const sal_Bool bSmartTags,
432 : const sal_Bool bGrammarCheck ) const;
433 :
434 : void DrawRect( const SwRect &rRect, sal_Bool bNoGraphic = sal_False,
435 : sal_Bool bRetouche = sal_True ) const;
436 : void DrawTab( const SwLinePortion &rPor ) const;
437 : void DrawLineBreak( const SwLinePortion &rPor ) const;
438 : void DrawRedArrow( const SwLinePortion &rPor ) const;
439 : void DrawPostIts( const SwLinePortion &rPor, sal_Bool bScript ) const;
440 : void DrawBackground( const SwLinePortion &rPor ) const;
441 : void DrawViewOpt( const SwLinePortion &rPor, const MSHORT nWhich ) const;
442 497 : inline void DrawBackBrush( const SwLinePortion &rPor ) const
443 497 : { /* if( pFnt->GetBackColor() ) */ _DrawBackBrush( rPor ); }
444 :
445 : void DrawCheckBox( const SwFieldFormPortion &rPor, bool checked) const;
446 :
447 0 : inline void NotifyURL( const SwLinePortion &rPor ) const
448 0 : { if( URLNotify() ) _NotifyURL( rPor ); }
449 :
450 : void CalcRect( const SwLinePortion& rPor, SwRect* pRect, SwRect* pIntersect = 0 ) const;
451 :
452 : inline SwTwips GetPaintOfst() const;
453 : inline void SetPaintOfst( const SwTwips nNew );
454 4415 : inline const Point &GetPos() const { return aPos; }
455 1225 : inline void SetPos( const Point &rNew ) { aPos = rNew; }
456 :
457 1771 : inline const SwRect &GetPaintRect() const { return aPaintRect; }
458 : inline void SetPaintRect( const SwRect &rNew ) { aPaintRect = rNew; }
459 :
460 : friend SvStream &operator<<( SvStream &rOS, const SwTxtPaintInfo &rInf );
461 :
462 : //
463 : // STUFF FOR JUSTIFIED ALIGNMENT
464 : //
465 723 : inline MSHORT GetSpaceIdx() const { return nSpaceIdx; }
466 1225 : inline void ResetSpaceIdx(){nSpaceIdx = 0; }
467 2 : inline void SetSpaceIdx( MSHORT nNew ) { nSpaceIdx = nNew; }
468 177 : inline void IncSpaceIdx() { ++nSpaceIdx; }
469 0 : inline void RemoveFirstSpaceAdd() { pSpaceAdd->erase( pSpaceAdd->begin() ); }
470 2862 : inline long GetSpaceAdd() const
471 20 : { return ( pSpaceAdd && nSpaceIdx < pSpaceAdd->size() )
472 2882 : ? (*pSpaceAdd)[nSpaceIdx] : 0; }
473 :
474 1227 : inline void SetpSpaceAdd( std::vector<long>* pNew ){ pSpaceAdd = pNew; }
475 723 : inline std::vector<long>* GetpSpaceAdd() const { return pSpaceAdd; }
476 :
477 :
478 474 : inline void SetWrongList( const SwWrongList *pNew ){ pWrongList = pNew; }
479 1114 : inline const SwWrongList* GetpWrongList() const { return pWrongList; }
480 :
481 474 : inline void SetGrammarCheckList( const SwWrongList *pNew ){ pGrammarCheckList = pNew; }
482 1226 : inline const SwWrongList* GetGrammarCheckList() const { return pGrammarCheckList; }
483 :
484 : // SMARTTAGS
485 474 : inline void SetSmartTags( const SwWrongList *pNew ){ pSmartTags = pNew; }
486 1226 : inline const SwWrongList* GetSmartTags() const { return pSmartTags; }
487 : };
488 :
489 : /*************************************************************************
490 : * class SwTxtFormatInfo
491 : *************************************************************************/
492 :
493 693 : class SwTxtFormatInfo : public SwTxtPaintInfo
494 : {
495 : // temporary arguments for hyphenation
496 : com::sun::star::beans::PropertyValues aHyphVals;
497 :
498 : SwLineLayout *pRoot; // The Root of the current line (pCurr)
499 : SwLinePortion *pLast; // The last Portion
500 : SwFlyPortion *pFly; // The following FlyPortion
501 : SwFldPortion *pLastFld; // Wrapped Field
502 : SwLinePortion *pUnderFlow; // Underflow: Last Portion
503 : SwLinePortion *pRest; // The Rest is the start of the next Line
504 :
505 : SwTabPortion *pLastTab; // The _last_ TabPortion
506 :
507 : xub_StrLen nSoftHyphPos; // SoftHyphPos forr Hyphenation
508 : xub_StrLen nHyphStart; // TxtPos at which the interactive hyphen is at the moment
509 : xub_StrLen nHyphWrdStart; // Position of the found word
510 : xub_StrLen nHyphWrdLen; // Length of the found word
511 : xub_StrLen nLineStart; // Current line start in rTxt
512 : xub_StrLen nUnderScorePos; // enlarge repaint if underscore has been found
513 : // #i34348# Changed type from sal_uInt16 to SwTwips
514 : SwTwips nLeft; // Left margin
515 : SwTwips nRight; // Right margin
516 : SwTwips nFirst; // EZE
517 : KSHORT nRealWidth; // "real" line width
518 : KSHORT nWidth; // "virtual" line width
519 : KSHORT nLineHeight; // Final height after CalcLine
520 : KSHORT nLineNettoHeight; // line height without spacing
521 : KSHORT nForcedLeftMargin; // Shift of left margin due to frame
522 :
523 : sal_Int16 nMinLeading; // minimum number of chars before hyphenation point
524 : sal_Int16 nMinTrailing; // minimum number of chars after hyphenation point
525 : sal_Int16 nMinWordLength; // minimum length of word to be hyphenated
526 :
527 : sal_Bool bFull : 1; // Line is full
528 : sal_Bool bFtnDone : 1; // Ftn already formatted
529 : sal_Bool bErgoDone : 1; // ErgoDone already formatted
530 : sal_Bool bNumDone : 1; // bNumDone already formatted
531 : sal_Bool bArrowDone : 1; // Arrow to the left for scrolling paragraphs
532 : sal_Bool bStop : 1; // Cancel immediately, discarding the line
533 : sal_Bool bNewLine : 1; // Format another line
534 : sal_Bool bShift : 1; // Position change: Repaint until further notice
535 : sal_Bool bUnderFlow : 1; // Context: UnderFlow() ?
536 : sal_Bool bInterHyph: 1; // Interactive hyphenation?
537 : sal_Bool bAutoHyph : 1; // Automatic hyphenation?
538 : sal_Bool bDropInit : 1; // Set DropWidth
539 : sal_Bool bQuick : 1; // FormatQuick()
540 : sal_Bool bNoEndHyph : 1; // Switch off hyphenation at the line end (due to MaxHyphens)
541 : sal_Bool bNoMidHyph : 1; // Switch off hyphenation before flys (due to MaxHyphens)
542 : sal_Bool bIgnoreFly: 1; // FitToContent ignores flys
543 : sal_Bool bFakeLineStart: 1; // String has been replaced by field portion
544 : // info structure only pretends that we are at
545 : // the beginning of a line
546 : sal_Bool bTabOverflow; // Tabs are expanding after the end margin
547 :
548 : sal_Unicode cTabDecimal; // the current decimal delimiter
549 : sal_Unicode cHookChar; // For tabs in fields etc.
550 : sal_uInt8 nMaxHyph; // Max. line count of followup hyphenations
551 : sal_Bool bTestFormat; // Test formatting from WouldFit, no notification etc.
552 :
553 : // Hyphenating ...
554 : sal_Bool InitHyph( const sal_Bool bAuto = sal_False );
555 : sal_Bool _CheckFtnPortion( SwLineLayout* pCurr );
556 :
557 : public:
558 : void CtorInitTxtFormatInfo( SwTxtFrm *pFrm, const sal_Bool bInterHyph = sal_False,
559 : const sal_Bool bQuick = sal_False, const sal_Bool bTst = sal_False );
560 692 : inline SwTxtFormatInfo(SwTxtFrm *pFrame,const sal_Bool bInterHyphL=sal_False,
561 : const sal_Bool bQuickL = sal_False, const sal_Bool bTst = sal_False )
562 692 : { CtorInitTxtFormatInfo( pFrame, bInterHyphL, bQuickL, bTst ); }
563 :
564 : // For the formatting inside a double line in a line (multi-line portion)
565 : // we need a modified text-format-info:
566 : SwTxtFormatInfo( const SwTxtFormatInfo& rInf, SwLineLayout& rLay,
567 : SwTwips nActWidth );
568 :
569 2589 : inline KSHORT Width() const { return nWidth; }
570 807 : inline void Width( const KSHORT nNew ) { nWidth = nNew; }
571 : void Init();
572 :
573 : // Returns the first changed position of the paragraph
574 : inline xub_StrLen GetReformatStart() const;
575 :
576 : // Margins
577 5 : inline SwTwips Left() const { return nLeft; }
578 755 : inline void Left( const SwTwips nNew ) { nLeft = nNew; }
579 755 : inline SwTwips Right() const { return nRight; }
580 755 : inline void Right( const SwTwips nNew ) { nRight = nNew; }
581 5 : inline SwTwips First() const { return nFirst; }
582 755 : inline void First( const SwTwips nNew ) { nFirst = nNew; }
583 : inline SwTwips CurrLeft() const { return (nLineStart ? nLeft : nFirst); }
584 1900 : inline KSHORT RealWidth() const { return nRealWidth; }
585 756 : inline void RealWidth( const KSHORT nNew ) { nRealWidth = nNew; }
586 5 : inline KSHORT ForcedLeftMargin() const { return nForcedLeftMargin; }
587 755 : inline void ForcedLeftMargin( const KSHORT nN ) { nForcedLeftMargin = nN; }
588 :
589 1335 : inline sal_uInt8 &MaxHyph() { return nMaxHyph; }
590 : inline const sal_uInt8 &MaxHyph() const { return nMaxHyph; }
591 :
592 79 : inline SwLineLayout *GetRoot() { return pRoot; }
593 0 : inline const SwLineLayout *GetRoot() const { return pRoot; }
594 :
595 755 : inline void SetRoot( SwLineLayout *pNew ) { pRoot = pNew; }
596 9446 : inline SwLinePortion *GetLast() { return pLast; }
597 2773 : inline void SetLast( SwLinePortion *pNewLast ) { pLast = pNewLast; }
598 2370 : inline sal_Bool IsFull() const { return bFull; }
599 1678 : inline void SetFull( const sal_Bool bNew ) { bFull = bNew; }
600 0 : inline sal_Bool IsHyphForbud() const
601 0 : { return pFly ? bNoMidHyph : bNoEndHyph; }
602 : inline void SetHyphForbud( const sal_Bool bNew )
603 : { if ( pFly ) bNoMidHyph = bNew; else bNoEndHyph = bNew; }
604 1510 : inline void ChkNoHyph( const sal_uInt8 bEnd, const sal_uInt8 bMid )
605 1510 : { bNoEndHyph = (nMaxHyph && bEnd >= nMaxHyph);
606 1510 : bNoMidHyph = (nMaxHyph && bMid >= nMaxHyph); }
607 197 : inline sal_Bool IsIgnoreFly() const { return bIgnoreFly; }
608 30 : inline void SetIgnoreFly( const sal_Bool bNew ) { bIgnoreFly = bNew; }
609 7 : inline sal_Bool IsFakeLineStart() const { return bFakeLineStart; }
610 201 : inline void SetFakeLineStart( const sal_Bool bNew ) { bFakeLineStart = bNew; }
611 7354 : inline sal_Bool IsStop() const { return bStop; }
612 1 : inline void SetStop( const sal_Bool bNew ) { bStop = bNew; }
613 8119 : inline SwLinePortion *GetRest() { return pRest; }
614 116 : inline void SetRest( SwLinePortion *pNewRest ) { pRest = pNewRest; }
615 2269 : inline sal_Bool IsNewLine() const { return bNewLine; }
616 3 : inline void SetNewLine( const sal_Bool bNew ) { bNewLine = bNew; }
617 78 : inline sal_Bool IsShift() const { return bShift; }
618 712 : inline void SetShift( const sal_Bool bNew ) { bShift = bNew; }
619 0 : inline sal_Bool IsInterHyph() const { return bInterHyph; }
620 : inline sal_Bool IsAutoHyph() const { return bAutoHyph; }
621 759 : inline sal_Bool IsUnderFlow() const { return bUnderFlow; }
622 915 : inline void ClrUnderFlow() { bUnderFlow = sal_False; }
623 724 : inline sal_Bool IsDropInit() const { return bDropInit; }
624 0 : inline void SetDropInit( const sal_Bool bNew ) { bDropInit = bNew; }
625 1341 : inline sal_Bool IsQuick() const { return bQuick; }
626 2245 : inline sal_Bool IsTest() const { return bTestFormat; }
627 :
628 3056 : inline xub_StrLen GetLineStart() const { return nLineStart; }
629 1521 : inline void SetLineStart( const xub_StrLen nNew ) { nLineStart = nNew; }
630 :
631 : // these are used during fly calculation
632 915 : inline KSHORT GetLineHeight() const { return nLineHeight; }
633 724 : inline void SetLineHeight( const KSHORT nNew ) { nLineHeight = nNew; }
634 0 : inline KSHORT GetLineNettoHeight() const { return nLineNettoHeight; }
635 724 : inline void SetLineNettoHeight( const KSHORT nNew ) { nLineNettoHeight = nNew; }
636 :
637 : inline const SwLinePortion *GetUnderFlow() const { return pUnderFlow; }
638 1759 : inline SwLinePortion *GetUnderFlow() { return pUnderFlow; }
639 0 : inline void SetUnderFlow( SwLinePortion *pNew )
640 0 : { pUnderFlow = pNew; bUnderFlow = sal_True; }
641 0 : inline xub_StrLen GetSoftHyphPos() const { return nSoftHyphPos; }
642 2 : inline void SetSoftHyphPos( const xub_StrLen nNew ) { nSoftHyphPos = nNew; }
643 :
644 : inline void SetParaFtn();
645 :
646 : // FlyFrms
647 4890 : inline SwFlyPortion *GetFly() { return pFly; }
648 1625 : inline void SetFly( SwFlyPortion *pNew ) { pFly = pNew; }
649 :
650 : inline const SwAttrSet& GetCharAttr() const;
651 :
652 : // Tabs
653 2539 : inline SwTabPortion *GetLastTab() { return pLastTab; }
654 0 : inline void SetLastTab( SwTabPortion *pNew ) { pLastTab = pNew; }
655 0 : inline sal_Unicode GetTabDecimal() const { return cTabDecimal; }
656 0 : inline void SetTabDecimal( const sal_Unicode cNew ) { cTabDecimal = cNew;}
657 :
658 : // Last*
659 : inline SwFldPortion *GetLastFld() { return pLastFld; }
660 : inline void SetLastFld( SwFldPortion *pNew ) { pLastFld = pNew; }
661 :
662 67 : inline void ClearHookChar() { cHookChar = 0; }
663 0 : inline void SetHookChar( const sal_Unicode cNew ) { cHookChar = cNew; }
664 1714 : inline sal_Unicode GetHookChar() const { return cHookChar; }
665 :
666 : // Done-Flags
667 738 : inline sal_Bool IsFtnDone() const { return bFtnDone; }
668 680 : inline void SetFtnDone( const sal_Bool bNew ) { bFtnDone = bNew; }
669 2361 : inline sal_Bool IsErgoDone() const { return bErgoDone; }
670 1398 : inline void SetErgoDone( const sal_Bool bNew ) { bErgoDone = bNew; }
671 1643 : inline sal_Bool IsNumDone() const { return bNumDone; }
672 1573 : inline void SetNumDone( const sal_Bool bNew ) { bNumDone = bNew; }
673 1619 : inline sal_Bool IsArrowDone() const { return bArrowDone; }
674 1322 : inline void SetArrowDone( const sal_Bool bNew ) { bArrowDone = bNew; }
675 :
676 : // For SwTxtPortion::Hyphenate
677 : inline sal_Bool IsSoftHyph( const xub_StrLen nPos ) const;
678 : sal_Bool ChgHyph( const sal_Bool bNew );
679 :
680 : // Should the hyphenate helper be discarded?
681 : sal_Bool IsHyphenate() const;
682 : inline void SetHyphStart( const xub_StrLen nNew ) { nHyphStart = nNew; }
683 : inline xub_StrLen GetHyphStart() const { return nHyphStart; }
684 : inline void SetHyphWrdStart( const xub_StrLen nNew ) { nHyphWrdStart = nNew; }
685 : inline xub_StrLen GetHyphWrdStart() const { return nHyphWrdStart; }
686 : inline void SetHyphWrdLen( const xub_StrLen nNew ) { nHyphWrdLen = nNew; }
687 : inline xub_StrLen GetHyphWrdLen() const { return nHyphWrdLen; }
688 857 : inline xub_StrLen GetUnderScorePos() const { return nUnderScorePos; }
689 0 : inline void SetUnderScorePos( xub_StrLen nNew ) { nUnderScorePos = nNew; }
690 :
691 : // Calls HyphenateWord() of Hyphenator
692 : ::com::sun::star::uno::Reference<
693 : ::com::sun::star::linguistic2::XHyphenatedWord >
694 : HyphWord( const String &rTxt, const sal_uInt16 nMinTrail );
695 : const com::sun::star::beans::PropertyValues &
696 : GetHyphValues() const;
697 :
698 724 : sal_Bool CheckFtnPortion( SwLineLayout* pCurr )
699 724 : { return IsFtnInside() && _CheckFtnPortion( pCurr ); }
700 :
701 : // Dropcaps called by SwTxtFormatter::CTOR
702 : const SwFmtDrop *GetDropFmt() const;
703 :
704 : // Resets the FormatInfo back to its original state
705 : void Reset( const SwTxtFrm *pFrame); // , const sal_Bool bAll );
706 :
707 : // Sets the last SwKernPortion as pLast, if it is followed by empty portions
708 : sal_Bool LastKernPortion();
709 :
710 : // Looks for tabs, TabDec, TXTATR and BRK from nIdx until nEnd.
711 : // Return: Position; sets cHookChar if necessary
712 : xub_StrLen ScanPortionEnd( const xub_StrLen nStart, const xub_StrLen nEnd );
713 :
714 : friend SvStream &operator<<( SvStream &rOS, const SwTxtFormatInfo &rInf );
715 :
716 755 : inline void SetTabOverflow( sal_Bool bOverflow ) { bTabOverflow = bOverflow; }
717 0 : inline sal_Bool IsTabOverflow( ) { return bTabOverflow; }
718 : };
719 :
720 : /*************************************************************************
721 : * class SwTxtSlot
722 : * For the text replacement and restoration of SwTxtSizeInfo.
723 : * The way this is done is a bit of a hack: Although rInf is const we change it
724 : * anyway.
725 : * Because rInf is restorated again in the DTOR, we can do this.
726 : * You could call it a "logical const", if you wish.
727 : *************************************************************************/
728 : class SwTxtSlot
729 : {
730 : XubString aTxt;
731 : const XubString *pOldTxt;
732 : const SwWrongList* pOldSmartTagList;
733 : const SwWrongList* pOldGrammarCheckList;
734 : SwWrongList* pTempList;
735 : xub_StrLen nIdx;
736 : xub_StrLen nLen;
737 : sal_Bool bOn;
738 : protected:
739 : SwTxtSizeInfo *pInf;
740 : public:
741 : // The replacement string originates either from the portion via GetExpText()
742 : // or from the char * pCh, if it is not NULL
743 : SwTxtSlot( const SwTxtSizeInfo *pNew, const SwLinePortion *pPor, bool bTxtLen,
744 : bool bExgLists, const sal_Char *pCh = NULL );
745 : ~SwTxtSlot();
746 : inline sal_Bool IsOn() const { return bOn; }
747 : };
748 :
749 : /*************************************************************************
750 : * class SwFontSave
751 : *************************************************************************/
752 :
753 : class SwFontSave
754 : {
755 : SwTxtSizeInfo *pInf;
756 : SwFont *pFnt;
757 : SwAttrIter *pIter;
758 : public:
759 : SwFontSave( const SwTxtSizeInfo &rInf, SwFont *pFnt,
760 : SwAttrIter* pItr = NULL );
761 : ~SwFontSave();
762 : };
763 :
764 : /*************************************************************************
765 : * class SwDefFontSave
766 : *************************************************************************/
767 :
768 : class SwDefFontSave
769 : {
770 : SwTxtSizeInfo *pInf;
771 : SwFont *pFnt;
772 : SwFont *pNewFnt;
773 : public:
774 : SwDefFontSave( const SwTxtSizeInfo &rInf );
775 : ~SwDefFontSave();
776 : };
777 :
778 : /*************************************************************************
779 : * Inline implementations of SwTxtSizeInfo
780 : *************************************************************************/
781 :
782 1486 : inline KSHORT SwTxtSizeInfo::GetAscent() const
783 : {
784 : OSL_ENSURE( GetOut(), "SwTxtSizeInfo::GetAscent() without pOut" );
785 1486 : return ((SwFont*)GetFont())->GetAscent( pVsh, *GetOut() );
786 : }
787 :
788 1487 : inline KSHORT SwTxtSizeInfo::GetTxtHeight() const
789 : {
790 : OSL_ENSURE( GetOut(), "SwTxtSizeInfo::GetTxtHeight() without pOut" );
791 1487 : return ((SwFont*)GetFont())->GetHeight( pVsh, *GetOut() );
792 : }
793 :
794 3 : inline SwPosSize SwTxtSizeInfo::GetTxtSize( const XubString &rTxt ) const
795 : {
796 3 : return GetTxtSize( pOut, 0, rTxt, 0, rTxt.Len(), 0 );
797 : }
798 :
799 0 : inline SwPosSize SwTxtSizeInfo::GetTxtSize( const SwScriptInfo* pSI,
800 : const xub_StrLen nNewIdx,
801 : const xub_StrLen nNewLen,
802 : const sal_uInt16 nCompress ) const
803 : {
804 0 : return GetTxtSize( pOut, pSI, *pTxt, nNewIdx, nNewLen, nCompress );
805 : }
806 :
807 : /*************************************************************************
808 : * Inline implementations of SwTxtPaintInfo
809 : *************************************************************************/
810 :
811 1998 : inline SwTwips SwTxtPaintInfo::GetPaintOfst() const
812 : {
813 1998 : return GetParaPortion()->GetRepaint()->GetOfst();
814 : }
815 :
816 3402 : inline void SwTxtPaintInfo::SetPaintOfst( const SwTwips nNew )
817 : {
818 3402 : GetParaPortion()->GetRepaint()->SetOfst( nNew );
819 3402 : }
820 :
821 :
822 0 : inline void SwTxtPaintInfo::DrawText( const XubString &rText,
823 : const SwLinePortion &rPor,
824 : const xub_StrLen nStart, const xub_StrLen nLength,
825 : const sal_Bool bKern ) const
826 : {
827 0 : ((SwTxtPaintInfo*)this)->_DrawText( rText, rPor, nStart, nLength, bKern );
828 0 : }
829 :
830 449 : inline void SwTxtPaintInfo::DrawText( const SwLinePortion &rPor,
831 : const xub_StrLen nLength, const sal_Bool bKern ) const
832 : {
833 449 : ((SwTxtPaintInfo*)this)->_DrawText( *pTxt, rPor, nIdx, nLength, bKern );
834 449 : }
835 :
836 0 : inline void SwTxtPaintInfo::DrawMarkedText( const SwLinePortion &rPor,
837 : const xub_StrLen nLength,
838 : const sal_Bool bKern,
839 : const sal_Bool bWrong,
840 : const sal_Bool bSmartTags,
841 : const sal_Bool bGrammarCheck ) const
842 : {
843 0 : ((SwTxtPaintInfo*)this)->_DrawText( *pTxt, rPor, nIdx, nLength, bKern, bWrong, bSmartTags, bGrammarCheck );
844 0 : }
845 :
846 : /*************************************************************************
847 : * Inline implementations of SwTxtFormatInfo
848 : *************************************************************************/
849 :
850 1479 : inline xub_StrLen SwTxtFormatInfo::GetReformatStart() const
851 : {
852 1479 : return GetParaPortion()->GetReformat()->Start();
853 : }
854 :
855 63 : inline const SwAttrSet& SwTxtFormatInfo::GetCharAttr() const
856 : {
857 63 : return GetTxtFrm()->GetTxtNode()->GetSwAttrSet();
858 : }
859 :
860 5 : inline void SwTxtFormatInfo::SetParaFtn()
861 : {
862 5 : GetTxtFrm()->SetFtn( sal_True );
863 5 : }
864 :
865 : inline sal_Bool SwTxtFormatInfo::IsSoftHyph( const xub_StrLen nPos ) const
866 : {
867 : return CHAR_SOFTHYPHEN == GetTxtFrm()->GetTxtNode()->GetTxt().GetChar(nPos);
868 : }
869 :
870 :
871 :
872 : #endif
873 :
874 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|