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 25670 : inline const SvxLineSpacingItem *GetLineSpacing() const { return pSpace; }
99 755 : inline KSHORT GetDefTabStop() const { return nDefTabStop; }
100 312 : inline void SetDefTabStop( KSHORT nNew ) const
101 312 : { ( (SwLineInfo*)this )->nDefTabStop = nNew; }
102 :
103 : // vertical alignment
104 26164 : inline sal_uInt16 GetVertAlign() const { return nVertAlign; }
105 12723 : inline bool HasSpecialAlign( sal_Bool bVert ) const
106 : { return bVert ?
107 0 : ( SvxParaVertAlignItem::BASELINE != nVertAlign ) :
108 25446 : ( SvxParaVertAlignItem::BASELINE != nVertAlign &&
109 38169 : SvxParaVertAlignItem::AUTOMATIC != nVertAlign ); }
110 :
111 : sal_uInt16 NumberOfTabStops() const;
112 :
113 117 : inline bool IsListTabStopIncluded() const
114 : {
115 117 : return bListTabStopIncluded;
116 : }
117 74 : inline long GetListTabStopPosition() const
118 : {
119 74 : 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 48474 : inline SwTxtInfo() : pPara(0) {}
138 : public:
139 : void CtorInitTxtInfo( SwTxtFrm *pFrm );
140 : SwTxtInfo( const SwTxtInfo &rInf );
141 99 : inline SwTxtInfo( SwTxtFrm *pFrm ) { CtorInitTxtInfo( pFrm ); }
142 343495 : inline SwParaPortion *GetParaPortion() { return pPara; }
143 190209 : inline const SwParaPortion *GetParaPortion() const { return pPara; }
144 193180 : 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 87437 : 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 m_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>* m_pKanaComp;
164 :
165 : ViewShell *m_pVsh;
166 :
167 : // m_pOut is the output device, m_pRef is the device used for formatting
168 : OutputDevice* m_pOut;
169 : OutputDevice* m_pRef;
170 :
171 : SwFont *m_pFnt;
172 : SwUnderlineFont *m_pUnderFnt; // Font for underlining
173 : SwTxtFrm *m_pFrm;
174 : const SwViewOption *m_pOpt;
175 : const OUString *m_pTxt;
176 : sal_Int32 m_nIdx, m_nLen;
177 : sal_uInt16 m_nKanaIdx;
178 : bool m_bOnWin : 1;
179 : bool m_bNotEOL : 1;
180 : bool m_bURLNotify : 1;
181 : bool m_bStopUnderFlow : 1; // Underflow was stopped e.g. by a FlyPortion
182 : bool m_bFtnInside : 1; // the current line contains a footnote
183 : bool m_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 m_bMulti : 1; // inside a multiportion
186 : bool m_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 m_bRuby : 1; // during the formatting of a phonetic line
191 : bool m_bHanging : 1; // formatting of hanging punctuation allowed
192 : bool m_bScriptSpace : 1; // space between different scripts (Asian/Latin)
193 : bool m_bForbiddenChars : 1; // Forbidden start/endline characters
194 : bool m_bSnapToGrid : 1; // paragraph snaps to grid
195 : sal_uInt8 m_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 14294 : SwTxtSizeInfo() : m_pKanaComp(0), m_pVsh(0), m_pOut(0), m_pRef(0), m_pFnt(0), m_pUnderFnt(0), m_pFrm(0), m_pOpt(0), m_pTxt(0) {}
202 : public:
203 : SwTxtSizeInfo( const SwTxtSizeInfo &rInf );
204 : SwTxtSizeInfo( const SwTxtSizeInfo &rInf, const OUString* pTxt,
205 : const sal_Int32 nIdx = 0,
206 : const xub_StrLen nLen = STRING_LEN );
207 :
208 34180 : inline SwTxtSizeInfo( SwTxtFrm *pTxtFrm, SwFont *pTxtFnt = 0,
209 : const sal_Int32 nIndex = 0,
210 : const xub_StrLen nLength = STRING_LEN )
211 34180 : { 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 174969 : inline bool OnWin() const { return m_bOnWin; }
219 51162 : inline void SetOnWin( const bool bNew ) { m_bOnWin = bNew; }
220 39235 : inline bool NotEOL() const { return m_bNotEOL; }
221 1166 : inline void SetNotEOL( const bool bNew ) { m_bNotEOL = bNew; }
222 38963 : inline bool URLNotify() const { return m_bURLNotify; }
223 : inline void SetURLNotify( const bool bNew ) { m_bURLNotify = bNew; }
224 38963 : inline bool StopUnderFlow() const { return m_bStopUnderFlow; }
225 50360 : inline void SetStopUnderFlow( const bool bNew ) { m_bStopUnderFlow = bNew; }
226 62954 : inline bool IsFtnInside() const { return m_bFtnInside; }
227 24068 : inline void SetFtnInside( const bool bNew ) { m_bFtnInside = bNew; }
228 64768 : inline bool IsOtherThanFtnInside() const { return m_bOtherThanFtnInside; }
229 49796 : inline void SetOtherThanFtnInside( const bool bNew ) { m_bOtherThanFtnInside = bNew; }
230 77377 : inline bool IsMulti() const { return m_bMulti; }
231 2329 : inline void SetMulti( const bool bNew ) { m_bMulti = bNew; }
232 42046 : inline bool IsFirstMulti() const { return m_bFirstMulti; }
233 686 : inline void SetFirstMulti( const bool bNew ) { m_bFirstMulti = bNew; }
234 65115 : inline bool IsRuby() const { return m_bRuby; }
235 447 : inline void SetRuby( const bool bNew ) { m_bRuby = bNew; }
236 56220 : inline bool IsHanging() const { return m_bHanging; }
237 7758 : inline void SetHanging( const bool bNew ) { m_bHanging = bNew; }
238 72685 : inline bool HasScriptSpace() const { return m_bScriptSpace; }
239 7758 : inline void SetScriptSpace( const bool bNew ) { m_bScriptSpace = bNew; }
240 56220 : inline bool HasForbiddenChars() const { return m_bForbiddenChars; }
241 7758 : inline void SetForbiddenChars( const bool bN ) { m_bForbiddenChars = bN; }
242 94333 : inline bool SnapToGrid() const { return m_bSnapToGrid; }
243 48961 : inline void SetSnapToGrid( const bool bN ) { m_bSnapToGrid = bN; }
244 155111 : inline sal_uInt8 GetDirection() const { return m_nDirection; }
245 366 : inline void SetDirection( const sal_uInt8 nNew ) { m_nDirection = nNew; }
246 64274 : inline sal_Bool IsRotated() const { return 0 != ( 1 & m_nDirection ); }
247 :
248 80979 : inline ViewShell *GetVsh() { return m_pVsh; }
249 67728 : inline const ViewShell *GetVsh() const { return m_pVsh; }
250 :
251 176836 : inline OutputDevice *GetOut() { return m_pOut; }
252 103682 : inline const OutputDevice *GetOut() const { return m_pOut; }
253 48172 : inline void SetOut( OutputDevice* pNewOut ) { m_pOut = pNewOut; }
254 :
255 63067 : inline OutputDevice *GetRefDev() { return m_pRef; }
256 : inline const OutputDevice *GetRefDev() const { return m_pRef; }
257 :
258 151946 : inline SwFont *GetFont() { return m_pFnt; }
259 103661 : inline const SwFont *GetFont() const { return m_pFnt; }
260 65162 : inline void SetFont( SwFont *pNew ) { m_pFnt = pNew; }
261 : void SelectFont();
262 30362 : inline void SetUnderFnt( SwUnderlineFont* pNew ) { m_pUnderFnt = pNew; }
263 86847 : inline SwUnderlineFont* GetUnderFnt() const { return m_pUnderFnt; }
264 :
265 143883 : inline const SwViewOption &GetOpt() const { return *m_pOpt; }
266 566638 : inline const OUString &GetTxt() const { return *m_pTxt; }
267 1598054 : inline sal_Unicode GetChar( const sal_Int32 nPos ) const
268 1598054 : { if (m_pTxt && !m_pTxt->isEmpty()) return (*m_pTxt)[ nPos ]; return 0; }
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 1176288 : inline sal_Int32 GetIdx() const { return m_nIdx; }
300 157290 : inline void SetIdx( const sal_Int32 nNew ) { m_nIdx = nNew; }
301 251805 : inline sal_Int32 GetLen() const { return m_nLen; }
302 199432 : inline void SetLen( const sal_Int32 nNew ) { m_nLen = nNew; }
303 4194 : inline void SetTxt( const OUString &rNew ){ m_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 != m_pFnt->GetCharSet( m_pFnt->GetActual() ); }
310 :
311 : void NoteAnimation() const;
312 :
313 : // Home is where Your heart is...
314 282606 : inline SwTxtFrm *GetTxtFrm() { return m_pFrm; }
315 122406 : inline const SwTxtFrm *GetTxtFrm() const { return m_pFrm; }
316 :
317 1437 : inline sal_Bool HasHint( xub_StrLen nPos ) const
318 1437 : { return _HasHint( m_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 m_aMaxWidth and discarded after a line has been formatted.
326 0 : inline void SetMaxWidthDiff( sal_uLong nKey, sal_uInt16 nVal )
327 : {
328 0 : m_aMaxWidth.insert( ::std::make_pair( nKey, nVal ) );
329 0 : };
330 0 : inline sal_uInt16 GetMaxWidthDiff( sal_uLong nKey )
331 : {
332 0 : SwTxtPortionMap::iterator it = m_aMaxWidth.find( nKey );
333 :
334 0 : if( it != m_aMaxWidth.end() )
335 0 : return it->second;
336 : else
337 0 : return 0;
338 : };
339 0 : inline void ResetMaxWidthDiff()
340 : {
341 0 : m_aMaxWidth.clear();
342 0 : };
343 23991 : inline sal_Bool CompressLine()
344 : {
345 23991 : return (sal_Bool)!m_aMaxWidth.empty();
346 : };
347 :
348 : //
349 : // Feature: Kana Compression
350 : //
351 38963 : inline MSHORT GetKanaIdx() const { return m_nKanaIdx; }
352 20273 : inline void ResetKanaIdx(){ m_nKanaIdx = 0; }
353 1513 : inline void SetKanaIdx( MSHORT nNew ) { m_nKanaIdx = nNew; }
354 650 : inline void IncKanaIdx() { ++m_nKanaIdx; }
355 21786 : inline void SetKanaComp( std::deque<sal_uInt16> *pNew ){ m_pKanaComp = pNew; }
356 38963 : inline std::deque<sal_uInt16>* GetpKanaComp() const { return m_pKanaComp; }
357 11174 : inline sal_uInt16 GetKanaComp() const
358 0 : { return ( m_pKanaComp && m_nKanaIdx < m_pKanaComp->size() )
359 11174 : ? (*m_pKanaComp)[m_nKanaIdx] : 0; }
360 :
361 : #ifdef DBG_UTIL
362 : sal_Bool IsOptDbg() const;
363 : #endif
364 : };
365 :
366 : /*************************************************************************
367 : * class SwTxtPaintInfo
368 : *************************************************************************/
369 :
370 24425 : 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() { m_pFrm = 0; pWrongList = 0; pGrammarCheckList = 0; pSmartTags = 0; pSpaceAdd = 0;
396 : pBrushItem = ((SvxBrushItem*)-1);}
397 : #else
398 7758 : SwTxtPaintInfo() { m_pFrm = 0; pWrongList = 0; pGrammarCheckList = 0; pSmartTags = 0; pSpaceAdd = 0;
399 7758 : pBrushItem = 0;}
400 : #endif
401 : public:
402 : SwTxtPaintInfo( const SwTxtPaintInfo &rInf );
403 : SwTxtPaintInfo( const SwTxtPaintInfo &rInf, const OUString* pTxt );
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 10131 : const SvxBrushItem *GetBrushItem() const { return pBrushItem; }
410 0 : const SwRect &GetBrushRect() const { return aItemRect; }
411 :
412 6536 : inline SwTxtPaintInfo( SwTxtFrm *pFrame, const SwRect &rPaint )
413 6536 : { CtorInitTxtPaintInfo( pFrame, rPaint ); }
414 :
415 236831 : inline SwTwips X() const { return aPos.X(); }
416 85428 : inline void X( const long nNew ) { aPos.X() = nNew; }
417 49837 : inline SwTwips Y() const { return aPos.Y(); }
418 62448 : inline void Y( const SwTwips nNew ) { aPos.Y() = nNew; }
419 :
420 104936 : inline SwTxtFly *GetTxtFly() { return &aTxtFly; }
421 17787 : 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 11201 : inline void DrawBackBrush( const SwLinePortion &rPor ) const
443 11201 : { /* 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 86288 : inline const Point &GetPos() const { return aPos; }
455 20291 : inline void SetPos( const Point &rNew ) { aPos = rNew; }
456 :
457 32519 : 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 10314 : inline MSHORT GetSpaceIdx() const { return nSpaceIdx; }
466 20456 : inline void ResetSpaceIdx(){nSpaceIdx = 0; }
467 354 : inline void SetSpaceIdx( MSHORT nNew ) { nSpaceIdx = nNew; }
468 650 : inline void IncSpaceIdx() { ++nSpaceIdx; }
469 0 : inline void RemoveFirstSpaceAdd() { pSpaceAdd->erase( pSpaceAdd->begin() ); }
470 68910 : inline long GetSpaceAdd() const
471 191 : { return ( pSpaceAdd && nSpaceIdx < pSpaceAdd->size() )
472 69101 : ? (*pSpaceAdd)[nSpaceIdx] : 0; }
473 :
474 20810 : inline void SetpSpaceAdd( std::vector<long>* pNew ){ pSpaceAdd = pNew; }
475 10314 : inline std::vector<long>* GetpSpaceAdd() const { return pSpaceAdd; }
476 :
477 :
478 6485 : inline void SetWrongList( const SwWrongList *pNew ){ pWrongList = pNew; }
479 20442 : inline const SwWrongList* GetpWrongList() const { return pWrongList; }
480 :
481 6485 : inline void SetGrammarCheckList( const SwWrongList *pNew ){ pGrammarCheckList = pNew; }
482 22186 : inline const SwWrongList* GetGrammarCheckList() const { return pGrammarCheckList; }
483 :
484 : // SMARTTAGS
485 6485 : inline void SetSmartTags( const SwWrongList *pNew ){ pSmartTags = pNew; }
486 22186 : inline const SwWrongList* GetSmartTags() const { return pSmartTags; }
487 : };
488 :
489 : /*************************************************************************
490 : * class SwTxtFormatInfo
491 : *************************************************************************/
492 :
493 11407 : 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 7758 : inline SwTxtFormatInfo(SwTxtFrm *pFrame,const sal_Bool bInterHyphL=sal_False,
561 : const sal_Bool bQuickL = sal_False, const sal_Bool bTst = sal_False )
562 7758 : { 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 91856 : inline KSHORT Width() const { return nWidth; }
570 25037 : 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 102 : inline SwTwips Left() const { return nLeft; }
578 24348 : inline void Left( const SwTwips nNew ) { nLeft = nNew; }
579 24348 : inline SwTwips Right() const { return nRight; }
580 24348 : inline void Right( const SwTwips nNew ) { nRight = nNew; }
581 102 : inline SwTwips First() const { return nFirst; }
582 24348 : inline void First( const SwTwips nNew ) { nFirst = nNew; }
583 : inline SwTwips CurrLeft() const { return (nLineStart ? nLeft : nFirst); }
584 52056 : inline KSHORT RealWidth() const { return nRealWidth; }
585 24627 : inline void RealWidth( const KSHORT nNew ) { nRealWidth = nNew; }
586 102 : inline KSHORT ForcedLeftMargin() const { return nForcedLeftMargin; }
587 24555 : inline void ForcedLeftMargin( const KSHORT nN ) { nForcedLeftMargin = nN; }
588 :
589 15196 : inline sal_uInt8 &MaxHyph() { return nMaxHyph; }
590 : inline const sal_uInt8 &MaxHyph() const { return nMaxHyph; }
591 :
592 1872 : inline SwLineLayout *GetRoot() { return pRoot; }
593 0 : inline const SwLineLayout *GetRoot() const { return pRoot; }
594 :
595 24348 : inline void SetRoot( SwLineLayout *pNew ) { pRoot = pNew; }
596 306954 : inline SwLinePortion *GetLast() { return pLast; }
597 76791 : inline void SetLast( SwLinePortion *pNewLast ) { pLast = pNewLast; }
598 73697 : inline sal_Bool IsFull() const { return bFull; }
599 32574 : 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 48903 : inline void ChkNoHyph( const sal_uInt8 bEnd, const sal_uInt8 bMid )
605 48903 : { bNoEndHyph = (nMaxHyph && bEnd >= nMaxHyph);
606 48903 : bNoMidHyph = (nMaxHyph && bMid >= nMaxHyph); }
607 1971 : inline sal_Bool IsIgnoreFly() const { return bIgnoreFly; }
608 77 : inline void SetIgnoreFly( const sal_Bool bNew ) { bIgnoreFly = bNew; }
609 1151 : inline sal_Bool IsFakeLineStart() const { return bFakeLineStart; }
610 1461 : inline void SetFakeLineStart( const sal_Bool bNew ) { bFakeLineStart = bNew; }
611 176176 : inline sal_Bool IsStop() const { return bStop; }
612 199 : inline void SetStop( const sal_Bool bNew ) { bStop = bNew; }
613 231561 : inline SwLinePortion *GetRest() { return pRest; }
614 859 : inline void SetRest( SwLinePortion *pNewRest ) { pRest = pNewRest; }
615 89892 : inline sal_Bool IsNewLine() const { return bNewLine; }
616 57 : inline void SetNewLine( const sal_Bool bNew ) { bNewLine = bNew; }
617 17475 : inline sal_Bool IsShift() const { return bShift; }
618 7402 : 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 24174 : inline sal_Bool IsUnderFlow() const { return bUnderFlow; }
622 7917 : inline void ClrUnderFlow() { bUnderFlow = sal_False; }
623 23991 : inline sal_Bool IsDropInit() const { return bDropInit; }
624 0 : inline void SetDropInit( const sal_Bool bNew ) { bDropInit = bNew; }
625 9766 : inline sal_Bool IsQuick() const { return bQuick; }
626 23009 : inline sal_Bool IsTest() const { return bTestFormat; }
627 :
628 149338 : inline xub_StrLen GetLineStart() const { return nLineStart; }
629 32857 : inline void SetLineStart( const xub_StrLen nNew ) { nLineStart = nNew; }
630 :
631 : // these are used during fly calculation
632 25788 : inline KSHORT GetLineHeight() const { return nLineHeight; }
633 23991 : inline void SetLineHeight( const KSHORT nNew ) { nLineHeight = nNew; }
634 0 : inline KSHORT GetLineNettoHeight() const { return nLineNettoHeight; }
635 23991 : inline void SetLineNettoHeight( const KSHORT nNew ) { nLineNettoHeight = nNew; }
636 :
637 : inline const SwLinePortion *GetUnderFlow() const { return pUnderFlow; }
638 50361 : inline SwLinePortion *GetUnderFlow() { return pUnderFlow; }
639 2 : inline void SetUnderFlow( SwLinePortion *pNew )
640 2 : { pUnderFlow = pNew; bUnderFlow = sal_True; }
641 2 : inline xub_StrLen GetSoftHyphPos() const { return nSoftHyphPos; }
642 3 : inline void SetSoftHyphPos( const xub_StrLen nNew ) { nSoftHyphPos = nNew; }
643 :
644 : inline void SetParaFtn();
645 :
646 : // FlyFrms
647 148918 : inline SwFlyPortion *GetFly() { return pFly; }
648 49872 : inline void SetFly( SwFlyPortion *pNew ) { pFly = pNew; }
649 :
650 : inline const SwAttrSet& GetCharAttr() const;
651 :
652 : // Tabs
653 70991 : inline SwTabPortion *GetLastTab() { return pLastTab; }
654 38 : inline void SetLastTab( SwTabPortion *pNew ) { pLastTab = pNew; }
655 14 : 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 227 : inline void ClearHookChar() { cHookChar = 0; }
663 0 : inline void SetHookChar( const sal_Unicode cNew ) { cHookChar = cNew; }
664 32234 : inline sal_Unicode GetHookChar() const { return cHookChar; }
665 :
666 : // Done-Flags
667 6629 : inline sal_Bool IsFtnDone() const { return bFtnDone; }
668 6367 : inline void SetFtnDone( const sal_Bool bNew ) { bFtnDone = bNew; }
669 73747 : inline sal_Bool IsErgoDone() const { return bErgoDone; }
670 31704 : inline void SetErgoDone( const sal_Bool bNew ) { bErgoDone = bNew; }
671 31170 : inline sal_Bool IsNumDone() const { return bNumDone; }
672 30713 : inline void SetNumDone( const sal_Bool bNew ) { bNumDone = bNew; }
673 67325 : inline sal_Bool IsArrowDone() const { return bArrowDone; }
674 30481 : 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 24443 : inline xub_StrLen GetUnderScorePos() const { return nUnderScorePos; }
689 1 : 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 23991 : sal_Bool CheckFtnPortion( SwLineLayout* pCurr )
699 23991 : { 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 24555 : 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 : OUString aTxt;
731 : const OUString *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 49462 : inline KSHORT SwTxtSizeInfo::GetAscent() const
783 : {
784 : OSL_ENSURE( GetOut(), "SwTxtSizeInfo::GetAscent() without m_pOut" );
785 49462 : return ((SwFont*)GetFont())->GetAscent( m_pVsh, *GetOut() );
786 : }
787 :
788 49443 : inline KSHORT SwTxtSizeInfo::GetTxtHeight() const
789 : {
790 : OSL_ENSURE( GetOut(), "SwTxtSizeInfo::GetTxtHeight() without m_pOut" );
791 49443 : return ((SwFont*)GetFont())->GetHeight( m_pVsh, *GetOut() );
792 : }
793 :
794 442 : inline SwPosSize SwTxtSizeInfo::GetTxtSize( const XubString &rTxt ) const
795 : {
796 442 : return GetTxtSize( m_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( m_pOut, pSI, *m_pTxt, nNewIdx, nNewLen, nCompress );
805 : }
806 :
807 : /*************************************************************************
808 : * Inline implementations of SwTxtPaintInfo
809 : *************************************************************************/
810 :
811 53178 : inline SwTwips SwTxtPaintInfo::GetPaintOfst() const
812 : {
813 53178 : return GetParaPortion()->GetRepaint()->GetOfst();
814 : }
815 :
816 76887 : inline void SwTxtPaintInfo::SetPaintOfst( const SwTwips nNew )
817 : {
818 76887 : GetParaPortion()->GetRepaint()->SetOfst( nNew );
819 76887 : }
820 :
821 :
822 14 : 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 14 : ((SwTxtPaintInfo*)this)->_DrawText( rText, rPor, nStart, nLength, bKern );
828 14 : }
829 :
830 5174 : inline void SwTxtPaintInfo::DrawText( const SwLinePortion &rPor,
831 : const xub_StrLen nLength, const sal_Bool bKern ) const
832 : {
833 5174 : ((SwTxtPaintInfo*)this)->_DrawText( *m_pTxt, rPor, m_nIdx, nLength, bKern );
834 5174 : }
835 :
836 6009 : 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 6009 : ((SwTxtPaintInfo*)this)->_DrawText( *m_pTxt, rPor, m_nIdx, nLength, bKern, bWrong, bSmartTags, bGrammarCheck );
844 6009 : }
845 :
846 : /*************************************************************************
847 : * Inline implementations of SwTxtFormatInfo
848 : *************************************************************************/
849 :
850 52484 : inline xub_StrLen SwTxtFormatInfo::GetReformatStart() const
851 : {
852 52484 : return GetParaPortion()->GetReformat()->Start();
853 : }
854 :
855 230 : inline const SwAttrSet& SwTxtFormatInfo::GetCharAttr() const
856 : {
857 230 : return GetTxtFrm()->GetTxtNode()->GetSwAttrSet();
858 : }
859 :
860 77 : inline void SwTxtFormatInfo::SetParaFtn()
861 : {
862 77 : GetTxtFrm()->SetFtn( sal_True );
863 77 : }
864 :
865 : inline sal_Bool SwTxtFormatInfo::IsSoftHyph( const xub_StrLen nPos ) const
866 : {
867 : return CHAR_SOFTHYPHEN == GetTxtFrm()->GetTxtNode()->GetTxt()[nPos];
868 : }
869 :
870 :
871 :
872 : #endif
873 :
874 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|