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 INCLUDED_SW_SOURCE_CORE_TEXT_INFTXT_HXX
20 : #define INCLUDED_SW_SOURCE_CORE_TEXT_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 "swrect.hxx"
28 : #include "txtfly.hxx"
29 : #include "swfont.hxx"
30 : #include "porlay.hxx"
31 : #include "txtfrm.hxx"
32 : #include "ndtxt.hxx"
33 : #include <editeng/paravertalignitem.hxx>
34 :
35 : namespace vcl { class Font; }
36 : class OutputDevice;
37 : class SvxBrushItem;
38 : class SvxLineSpacingItem;
39 : class SvxTabStop;
40 : class SvxTabStopItem;
41 : class SwAttrSet;
42 : class SwFldPortion;
43 : class SwFlyPortion;
44 : class SwFmtDrop;
45 : class SwLineLayout;
46 : class SwLinePortion;
47 : class SwParaPortion;
48 : class SwTabPortion;
49 : class SwTxtFrm;
50 : class SwTxtSizeInfo;
51 : class SwViewOption;
52 : class SwViewShell;
53 : class SwAttrIter;
54 : struct SwMultiCreator;
55 : class SwMultiPortion;
56 : class SwWrongList;
57 :
58 : /* Minimum percentage for kerning */
59 : #define MINKERNPERCENT 5
60 : #define ARROW_WIDTH 200
61 : #define DIR_LEFT2RIGHT 0
62 : #define DIR_BOTTOM2TOP 1
63 : #define DIR_RIGHT2LEFT 2
64 : #define DIR_TOP2BOTTOM 3
65 :
66 : #ifdef DBG_UTIL
67 : #define OPTDBG( rInf ) (rInf).IsOptDbg()
68 : #else
69 : #define OPTDBG( rInf ) false
70 : #endif
71 :
72 : // Respects the attribute LineSpace when calculating the Height/Ascent
73 : class SwLineInfo
74 : {
75 : friend class SwTxtIter;
76 :
77 : SvxTabStopItem* pRuler;
78 : const SvxLineSpacingItem *pSpace;
79 : sal_uInt16 nVertAlign;
80 : sal_uInt16 nDefTabStop;
81 : bool bListTabStopIncluded;
82 : long nListTabStopPosition;
83 :
84 : void CtorInitLineInfo( const SwAttrSet& rAttrSet,
85 : const SwTxtNode& rTxtNode );
86 :
87 : SwLineInfo();
88 : ~SwLineInfo();
89 : public:
90 : // #i24363# tab stops relative to indent - returns the tab stop following nSearchPos or NULL
91 : const SvxTabStop *GetTabStop( const SwTwips nSearchPos,
92 : const SwTwips nRight ) const;
93 180333 : inline const SvxLineSpacingItem *GetLineSpacing() const { return pSpace; }
94 25638 : inline sal_uInt16 GetDefTabStop() const { return nDefTabStop; }
95 10290 : inline void SetDefTabStop( sal_uInt16 nNew ) const
96 10290 : { ( (SwLineInfo*)this )->nDefTabStop = nNew; }
97 :
98 : // vertical alignment
99 100160 : inline sal_uInt16 GetVertAlign() const { return nVertAlign; }
100 42942 : inline bool HasSpecialAlign( bool bVert ) const
101 : { return bVert ?
102 0 : ( SvxParaVertAlignItem::BASELINE != nVertAlign ) :
103 85644 : ( SvxParaVertAlignItem::BASELINE != nVertAlign &&
104 128586 : SvxParaVertAlignItem::AUTOMATIC != nVertAlign ); }
105 :
106 : sal_uInt16 NumberOfTabStops() const;
107 :
108 7844 : inline bool IsListTabStopIncluded() const
109 : {
110 7844 : return bListTabStopIncluded;
111 : }
112 7112 : inline long GetListTabStopPosition() const
113 : {
114 7112 : return nListTabStopPosition;
115 : }
116 :
117 : friend SvStream & WriteSwLineInfo( SvStream &rOS, const SwLineInfo &rInf );
118 : };
119 :
120 : class SwTxtInfo
121 : {
122 : // Implementation in txthyph.cxx
123 : friend void SetParaPortion( SwTxtInfo *pInf, SwParaPortion *pRoot );
124 : SwParaPortion *m_pPara;
125 : sal_Int32 m_nTxtStart; // TxtOfst for Follows
126 :
127 : protected:
128 317938 : SwTxtInfo()
129 : : m_pPara(0)
130 317938 : , m_nTxtStart(0)
131 317938 : {}
132 :
133 : public:
134 : void CtorInitTxtInfo( SwTxtFrm *pFrm );
135 : SwTxtInfo( const SwTxtInfo &rInf );
136 244 : SwTxtInfo( SwTxtFrm *pFrm ) { CtorInitTxtInfo( pFrm ); }
137 2517367 : SwParaPortion *GetParaPortion() { return m_pPara; }
138 1373489 : const SwParaPortion *GetParaPortion() const { return m_pPara; }
139 1303521 : sal_Int32 GetTxtStart() const { return m_nTxtStart; }
140 :
141 : friend SvStream & WriteSwTxtInfo( SvStream &rOS, const SwTxtInfo &rInf );
142 : };
143 :
144 542666 : class SwTxtSizeInfo : public SwTxtInfo
145 : {
146 : private:
147 : typedef ::std::map< sal_uIntPtr, sal_uInt16 > SwTxtPortionMap;
148 :
149 : protected:
150 : // during formatting, a small database is built, mapping portion pointers
151 : // to their maximum size (used for kana compression)
152 : SwTxtPortionMap m_aMaxWidth;
153 : // for each line, an array of compression values is calculated
154 : // this array is passed over to the info structure
155 : std::deque<sal_uInt16>* m_pKanaComp;
156 :
157 : SwViewShell *m_pVsh;
158 :
159 : // m_pOut is the output device, m_pRef is the device used for formatting
160 : OutputDevice* m_pOut;
161 : OutputDevice* m_pRef;
162 :
163 : SwFont *m_pFnt;
164 : SwUnderlineFont *m_pUnderFnt; // Font for underlining
165 : SwTxtFrm *m_pFrm;
166 : const SwViewOption *m_pOpt;
167 : const OUString *m_pTxt;
168 : sal_Int32 m_nIdx, m_nLen;
169 : sal_uInt16 m_nKanaIdx;
170 : bool m_bOnWin : 1;
171 : bool m_bNotEOL : 1;
172 : bool m_bURLNotify : 1;
173 : bool m_bStopUnderflow : 1; // Underflow was stopped e.g. by a FlyPortion
174 : bool m_bFtnInside : 1; // the current line contains a footnote
175 : bool m_bOtherThanFtnInside : 1; // the current line contains another portion than a footnote portion.
176 : // needed for checking keep together of footnote portion with previous portion
177 : bool m_bMulti : 1; // inside a multiportion
178 : bool m_bFirstMulti : 1; // this flag is used for two purposes:
179 : // - the multiportion is the first lineportion
180 : // - indicates, if we are currently in second
181 : // line of multi portion
182 : bool m_bRuby : 1; // during the formatting of a phonetic line
183 : bool m_bHanging : 1; // formatting of hanging punctuation allowed
184 : bool m_bScriptSpace : 1; // space between different scripts (Asian/Latin)
185 : bool m_bForbiddenChars : 1; // Forbidden start/endline characters
186 : bool m_bSnapToGrid : 1; // paragraph snaps to grid
187 : sal_uInt8 m_nDirection : 2; // writing direction: 0/90/180/270 degree
188 :
189 : protected:
190 : void CtorInitTxtSizeInfo( SwTxtFrm *pFrm, SwFont *pFnt = 0,
191 : const sal_Int32 nIdx = 0,
192 : const sal_Int32 nLen = COMPLETE_STRING );
193 119602 : SwTxtSizeInfo()
194 : : m_pKanaComp(0)
195 : , m_pVsh(0)
196 : , m_pOut(0)
197 : , m_pRef(0)
198 : , m_pFnt(0)
199 : , m_pUnderFnt(0)
200 : , m_pFrm(0)
201 : , m_pOpt(0)
202 : , m_pTxt(0)
203 : , m_nIdx(0)
204 : , m_nLen(0)
205 : , m_nKanaIdx(0)
206 : , m_bOnWin (false)
207 : , m_bNotEOL (false)
208 : , m_bURLNotify(false)
209 : , m_bStopUnderflow(false)
210 : , m_bFtnInside(false)
211 : , m_bOtherThanFtnInside(false)
212 : , m_bMulti(false)
213 : , m_bFirstMulti(false)
214 : , m_bRuby(false)
215 : , m_bHanging(false)
216 : , m_bScriptSpace(false)
217 : , m_bForbiddenChars(false)
218 : , m_bSnapToGrid(false)
219 119602 : , m_nDirection(0)
220 119602 : {}
221 : public:
222 : SwTxtSizeInfo( const SwTxtSizeInfo &rInf );
223 : SwTxtSizeInfo( const SwTxtSizeInfo &rInf, const OUString* pTxt,
224 : const sal_Int32 nIdx = 0,
225 : const sal_Int32 nLen = COMPLETE_STRING );
226 :
227 198336 : SwTxtSizeInfo( SwTxtFrm *pTxtFrm, SwFont *pTxtFnt = 0,
228 : const sal_Int32 nIndex = 0,
229 : const sal_Int32 nLength = COMPLETE_STRING )
230 198336 : : m_bOnWin(false)
231 : {
232 198336 : CtorInitTxtSizeInfo( pTxtFrm, pTxtFnt, nIndex, nLength );
233 198336 : }
234 :
235 : // GetMultiAttr returns the text attribute of the multiportion,
236 : // if rPos is inside any multi-line part.
237 : // rPos will set to the end of the multi-line part.
238 : SwMultiCreator* GetMultiCreator( sal_Int32 &rPos, SwMultiPortion* pM ) const;
239 :
240 776374 : inline bool OnWin() const { return m_bOnWin; }
241 292118 : inline void SetOnWin( const bool bNew ) { m_bOnWin = bNew; }
242 236874 : inline bool NotEOL() const { return m_bNotEOL; }
243 28524 : inline void SetNotEOL( const bool bNew ) { m_bNotEOL = bNew; }
244 224728 : inline bool URLNotify() const { return m_bURLNotify; }
245 : inline void SetURLNotify( const bool bNew ) { m_bURLNotify = bNew; }
246 224788 : inline bool StopUnderflow() const { return m_bStopUnderflow; }
247 350177 : inline void SetStopUnderflow( const bool bNew ) { m_bStopUnderflow = bNew; }
248 361490 : inline bool IsFtnInside() const { return m_bFtnInside; }
249 137076 : inline void SetFtnInside( const bool bNew ) { m_bFtnInside = bNew; }
250 431651 : inline bool IsOtherThanFtnInside() const { return m_bOtherThanFtnInside; }
251 343721 : inline void SetOtherThanFtnInside( const bool bNew ) { m_bOtherThanFtnInside = bNew; }
252 441457 : inline bool IsMulti() const { return m_bMulti; }
253 4855 : inline void SetMulti( const bool bNew ) { m_bMulti = bNew; }
254 230782 : inline bool IsFirstMulti() const { return m_bFirstMulti; }
255 1576 : inline void SetFirstMulti( const bool bNew ) { m_bFirstMulti = bNew; }
256 432447 : inline bool IsRuby() const { return m_bRuby; }
257 996 : inline void SetRuby( const bool bNew ) { m_bRuby = bNew; }
258 278755 : inline bool IsHanging() const { return m_bHanging; }
259 97770 : inline void SetHanging( const bool bNew ) { m_bHanging = bNew; }
260 580368 : inline bool HasScriptSpace() const { return m_bScriptSpace; }
261 97770 : inline void SetScriptSpace( const bool bNew ) { m_bScriptSpace = bNew; }
262 278755 : inline bool HasForbiddenChars() const { return m_bForbiddenChars; }
263 97770 : inline void SetForbiddenChars( const bool bN ) { m_bForbiddenChars = bN; }
264 513016 : inline bool SnapToGrid() const { return m_bSnapToGrid; }
265 319014 : inline void SetSnapToGrid( const bool bN ) { m_bSnapToGrid = bN; }
266 1246581 : inline sal_uInt8 GetDirection() const { return m_nDirection; }
267 760 : inline void SetDirection( const sal_uInt8 nNew ) { m_nDirection = nNew; }
268 579180 : inline bool IsRotated() const { return ( 1 & m_nDirection ); }
269 :
270 441698 : inline SwViewShell *GetVsh() { return m_pVsh; }
271 602525 : inline const SwViewShell *GetVsh() const { return m_pVsh; }
272 :
273 1058107 : inline OutputDevice *GetOut() { return m_pOut; }
274 841452 : inline const OutputDevice *GetOut() const { return m_pOut; }
275 284526 : inline void SetOut( OutputDevice* pNewOut ) { m_pOut = pNewOut; }
276 :
277 367102 : inline OutputDevice *GetRefDev() { return m_pRef; }
278 : inline const OutputDevice *GetRefDev() const { return m_pRef; }
279 :
280 2601617 : inline SwFont *GetFont() { return m_pFnt; }
281 1114583 : inline const SwFont *GetFont() const { return m_pFnt; }
282 497218 : inline void SetFont( SwFont *pNew ) { m_pFnt = pNew; }
283 : void SelectFont();
284 103794 : inline void SetUnderFnt( SwUnderlineFont* pNew ) { m_pUnderFnt = pNew; }
285 389920 : inline SwUnderlineFont* GetUnderFnt() const { return m_pUnderFnt; }
286 :
287 906077 : inline const SwViewOption &GetOpt() const { return *m_pOpt; }
288 3888555 : inline const OUString &GetTxt() const { return *m_pTxt; }
289 6465518 : inline sal_Unicode GetChar( const sal_Int32 nPos ) const
290 6465518 : { if (m_pTxt && nPos < m_pTxt->getLength()) return (*m_pTxt)[ nPos ]; return 0; }
291 :
292 : sal_uInt16 GetTxtHeight() const;
293 :
294 : SwPosSize GetTxtSize( OutputDevice* pOut, const SwScriptInfo* pSI,
295 : const OUString& rTxt, const sal_Int32 nIdx,
296 : const sal_Int32 nLen, const sal_uInt16 nComp ) const;
297 : SwPosSize GetTxtSize() const;
298 : void GetTxtSize( const SwScriptInfo* pSI, const sal_Int32 nIdx,
299 : const sal_Int32 nLen, const sal_uInt16 nComp,
300 : sal_uInt16& nMinSize, sal_uInt16& nMaxSizeDiff ) const;
301 : inline SwPosSize GetTxtSize( const SwScriptInfo* pSI, const sal_Int32 nIdx,
302 : const sal_Int32 nLen, const sal_uInt16 nComp ) const;
303 : inline SwPosSize GetTxtSize( const OUString &rTxt ) const;
304 :
305 : sal_Int32 GetTxtBreak( const long nLineWidth,
306 : const sal_Int32 nMaxLen,
307 : const sal_uInt16 nComp ) const;
308 : sal_Int32 GetTxtBreak( const long nLineWidth,
309 : const sal_Int32 nMaxLen,
310 : const sal_uInt16 nComp,
311 : sal_Int32& rExtraCharPos ) const;
312 :
313 : sal_uInt16 GetAscent() const;
314 :
315 6936927 : inline sal_Int32 GetIdx() const { return m_nIdx; }
316 1068777 : inline void SetIdx( const sal_Int32 nNew ) { m_nIdx = nNew; }
317 1434965 : inline sal_Int32 GetLen() const { return m_nLen; }
318 1223418 : inline void SetLen( const sal_Int32 nNew ) { m_nLen = nNew; }
319 55416 : inline void SetTxt( const OUString &rNew ){ m_pTxt = &rNew; }
320 :
321 : friend SvStream & WriteSwTxtSizeInfo( SvStream &rOS, const SwTxtSizeInfo &rInf );
322 :
323 : // No Bullets for the symbol font!
324 0 : inline bool IsNoSymbol() const
325 0 : { return RTL_TEXTENCODING_SYMBOL != m_pFnt->GetCharSet( m_pFnt->GetActual() ); }
326 :
327 : void NoteAnimation() const;
328 :
329 : // Home is where Your heart is...
330 1879038 : inline SwTxtFrm *GetTxtFrm() { return m_pFrm; }
331 1187015 : inline const SwTxtFrm *GetTxtFrm() const { return m_pFrm; }
332 :
333 11760 : inline bool HasHint( sal_Int32 nPos ) const
334 11760 : { return _HasHint( m_pFrm->GetTxtNode(), nPos ); }
335 : static bool _HasHint( const SwTxtNode* pTxtNode, sal_Int32 nPos );
336 :
337 : // If Kana Compression is enabled, a minimum and maximum portion width
338 : // is calculated. We format lines with minimal size and share remaining
339 : // space among compressed kanas.
340 : // During formatting, the maximum values of compressable portions are
341 : // stored in m_aMaxWidth and discarded after a line has been formatted.
342 0 : inline void SetMaxWidthDiff( const void *nKey, sal_uInt16 nVal )
343 : {
344 0 : m_aMaxWidth.insert( ::std::make_pair( reinterpret_cast<sal_uIntPtr>(nKey), nVal ) );
345 0 : };
346 0 : inline sal_uInt16 GetMaxWidthDiff( const void *nKey )
347 : {
348 0 : SwTxtPortionMap::iterator it = m_aMaxWidth.find( reinterpret_cast<sal_uIntPtr>(nKey) );
349 :
350 0 : if( it != m_aMaxWidth.end() )
351 0 : return it->second;
352 : else
353 0 : return 0;
354 : };
355 26 : inline void ResetMaxWidthDiff()
356 : {
357 26 : m_aMaxWidth.clear();
358 26 : };
359 136772 : inline bool CompressLine()
360 : {
361 136772 : return !m_aMaxWidth.empty();
362 : };
363 :
364 : // Feature: Kana Compression
365 :
366 224728 : inline sal_uInt16 GetKanaIdx() const { return m_nKanaIdx; }
367 144884 : inline void ResetKanaIdx(){ m_nKanaIdx = 0; }
368 3907 : inline void SetKanaIdx( sal_uInt16 nNew ) { m_nKanaIdx = nNew; }
369 53803 : inline void IncKanaIdx() { ++m_nKanaIdx; }
370 148791 : inline void SetKanaComp( std::deque<sal_uInt16> *pNew ){ m_pKanaComp = pNew; }
371 224728 : inline std::deque<sal_uInt16>* GetpKanaComp() const { return m_pKanaComp; }
372 43833 : inline sal_uInt16 GetKanaComp() const
373 0 : { return ( m_pKanaComp && m_nKanaIdx < m_pKanaComp->size() )
374 43833 : ? (*m_pKanaComp)[m_nKanaIdx] : 0; }
375 :
376 : #ifdef DBG_UTIL
377 : bool IsOptDbg() const;
378 : #endif
379 : };
380 :
381 225279 : class SwTxtPaintInfo : public SwTxtSizeInfo
382 : {
383 : const SwWrongList *pWrongList;
384 : const SwWrongList *pGrammarCheckList;
385 : const SwWrongList *pSmartTags;
386 : std::vector<long>* pSpaceAdd;
387 : const SvxBrushItem *pBrushItem; // For the background
388 : SwRect aItemRect; // Also for the background
389 : SwTxtFly aTxtFly; // Calculate the FlyFrm
390 : Point aPos; // Paint position
391 : SwRect aPaintRect; // Original paint rect (from Layout paint)
392 :
393 : sal_uInt16 nSpaceIdx;
394 : void _DrawText( const OUString &rText, const SwLinePortion &rPor,
395 : const sal_Int32 nIdx, const sal_Int32 nLen,
396 : const bool bKern, const bool bWrong = false,
397 : const bool bSmartTag = false,
398 : const bool bGrammarCheck = false );
399 :
400 : SwTxtPaintInfo &operator=(const SwTxtPaintInfo&);
401 : void _NotifyURL( const SwLinePortion &rPor ) const;
402 :
403 : protected:
404 97770 : SwTxtPaintInfo()
405 : : pWrongList(0)
406 : , pGrammarCheckList(0)
407 : , pSmartTags(0)
408 : , pSpaceAdd(0)
409 : #ifdef DBG_UTIL
410 : , pBrushItem((SvxBrushItem*)-1)
411 : #else
412 : , pBrushItem(0)
413 : #endif
414 97770 : , nSpaceIdx(0)
415 97770 : {}
416 :
417 : public:
418 : SwTxtPaintInfo( const SwTxtPaintInfo &rInf );
419 : SwTxtPaintInfo( const SwTxtPaintInfo &rInf, const OUString* pTxt );
420 :
421 : void CtorInitTxtPaintInfo( SwTxtFrm *pFrame, const SwRect &rPaint );
422 :
423 : void SetBack( const SvxBrushItem *pItem,
424 : const SwRect &rRect ) { pBrushItem = pItem; aItemRect = rRect;}
425 105677 : const SvxBrushItem *GetBrushItem() const { return pBrushItem; }
426 0 : const SwRect &GetBrushRect() const { return aItemRect; }
427 :
428 21832 : inline SwTxtPaintInfo( SwTxtFrm *pFrame, const SwRect &rPaint )
429 21832 : { CtorInitTxtPaintInfo( pFrame, rPaint ); }
430 :
431 1910371 : inline SwTwips X() const { return aPos.X(); }
432 691823 : inline void X( const long nNew ) { aPos.X() = nNew; }
433 339453 : inline SwTwips Y() const { return aPos.Y(); }
434 347496 : inline void Y( const SwTwips nNew ) { aPos.Y() = nNew; }
435 :
436 669343 : inline SwTxtFly& GetTxtFly() { return aTxtFly; }
437 197636 : inline const SwTxtFly& GetTxtFly() const { return aTxtFly; }
438 : inline void DrawText( const OUString &rText, const SwLinePortion &rPor,
439 : const sal_Int32 nIdx = 0,
440 : const sal_Int32 nLen = COMPLETE_STRING,
441 : const bool bKern = false) const;
442 : inline void DrawText( const SwLinePortion &rPor, const sal_Int32 nLen,
443 : const bool bKern = false ) const;
444 : inline void DrawMarkedText( const SwLinePortion &rPor, const sal_Int32 nLen,
445 : const bool bKern,
446 : const bool bWrong,
447 : const bool bSmartTags,
448 : const bool bGrammarCheck ) const;
449 :
450 : void DrawRect( const SwRect &rRect, bool bNoGraphic = false,
451 : bool bRetouche = true ) const;
452 :
453 : void DrawTab( const SwLinePortion &rPor ) const;
454 : void DrawLineBreak( const SwLinePortion &rPor ) const;
455 : void DrawRedArrow( const SwLinePortion &rPor ) const;
456 : void DrawPostIts( const SwLinePortion &rPor, bool bScript ) const;
457 : void DrawBackground( const SwLinePortion &rPor ) const;
458 : void DrawViewOpt( const SwLinePortion &rPor, const sal_uInt16 nWhich ) const;
459 : void DrawBackBrush( const SwLinePortion &rPor ) const;
460 :
461 : /**
462 : * Draw character border around a line portion.
463 : *
464 : * @param[in] rPor line portion around which border have to be drawn.
465 : **/
466 : void DrawBorder( const SwLinePortion &rPor ) const;
467 :
468 : void DrawCheckBox(const SwFieldFormCheckboxPortion &rPor, bool bChecked) const;
469 :
470 0 : inline void NotifyURL( const SwLinePortion &rPor ) const
471 0 : { if( URLNotify() ) _NotifyURL( rPor ); }
472 :
473 : /**
474 : * Calculate the rectangular area where the portion takes place.
475 : * @param[in] rPor portion for which the method specify the painting area
476 : * @param[out] pRect whole area of the portion
477 : * @param[out] pIntersect part of the portion area clipped by OutputDevice's clip region
478 : * @param[in] bInsideBox area of portion's content, padding and border, but shadow
479 : * is excluded (e.g. for background)
480 : **/
481 : void CalcRect( const SwLinePortion& rPor, SwRect* pRect,
482 : SwRect* pIntersect = 0, const bool bInsideBox = false ) const;
483 :
484 : inline SwTwips GetPaintOfst() const;
485 : inline void SetPaintOfst( const SwTwips nNew );
486 343248 : inline const Point &GetPos() const { return aPos; }
487 144932 : inline void SetPos( const Point &rNew ) { aPos = rNew; }
488 :
489 193581 : inline const SwRect &GetPaintRect() const { return aPaintRect; }
490 : inline void SetPaintRect( const SwRect &rNew ) { aPaintRect = rNew; }
491 :
492 : friend SvStream & WriteSwTxtPaintInfo( SvStream &rOS, const SwTxtPaintInfo &rInf );
493 :
494 : // STUFF FOR JUSTIFIED ALIGNMENT
495 :
496 106057 : inline sal_uInt16 GetSpaceIdx() const { return nSpaceIdx; }
497 145242 : inline void ResetSpaceIdx(){nSpaceIdx = 0; }
498 716 : inline void SetSpaceIdx( sal_uInt16 nNew ) { nSpaceIdx = nNew; }
499 53803 : inline void IncSpaceIdx() { ++nSpaceIdx; }
500 0 : inline void RemoveFirstSpaceAdd() { pSpaceAdd->erase( pSpaceAdd->begin() ); }
501 540287 : inline long GetSpaceAdd() const
502 15278 : { return ( pSpaceAdd && nSpaceIdx < pSpaceAdd->size() )
503 555565 : ? (*pSpaceAdd)[nSpaceIdx] : 0; }
504 :
505 145958 : inline void SetpSpaceAdd( std::vector<long>* pNew ){ pSpaceAdd = pNew; }
506 106057 : inline std::vector<long>* GetpSpaceAdd() const { return pSpaceAdd; }
507 :
508 19954 : inline void SetWrongList( const SwWrongList *pNew ){ pWrongList = pNew; }
509 146614 : inline const SwWrongList* GetpWrongList() const { return pWrongList; }
510 :
511 19954 : inline void SetGrammarCheckList( const SwWrongList *pNew ){ pGrammarCheckList = pNew; }
512 152346 : inline const SwWrongList* GetGrammarCheckList() const { return pGrammarCheckList; }
513 :
514 19954 : inline void SetSmartTags( const SwWrongList *pNew ){ pSmartTags = pNew; }
515 152346 : inline const SwWrongList* GetSmartTags() const { return pSmartTags; }
516 : };
517 :
518 105428 : class SwTxtFormatInfo : public SwTxtPaintInfo
519 : {
520 : // temporary arguments for hyphenation
521 : com::sun::star::beans::PropertyValues aHyphVals;
522 :
523 : SwLineLayout *pRoot; // The Root of the current line (pCurr)
524 : SwLinePortion *pLast; // The last Portion
525 : SwFlyPortion *pFly; // The following FlyPortion
526 : SwFldPortion *pLastFld; // Wrapped Field
527 : SwLinePortion *pUnderflow; // Underflow: Last Portion
528 : SwLinePortion *pRest; // The Rest is the start of the next Line
529 :
530 : SwTabPortion *pLastTab; // The _last_ TabPortion
531 :
532 : sal_Int32 nSoftHyphPos; // SoftHyphPos forr Hyphenation
533 : sal_Int32 nLineStart; // Current line start in rTxt
534 : sal_Int32 nUnderScorePos; // enlarge repaint if underscore has been found
535 : // #i34348# Changed type from sal_uInt16 to SwTwips
536 : SwTwips nLeft; // Left margin
537 : SwTwips nRight; // Right margin
538 : SwTwips nFirst; // EZE
539 : sal_uInt16 nRealWidth; // "real" line width
540 : sal_uInt16 nWidth; // "virtual" line width
541 : sal_uInt16 nLineHeight; // Final height after CalcLine
542 : sal_uInt16 nLineNetHeight; // line height without spacing
543 : sal_uInt16 nForcedLeftMargin; // Shift of left margin due to frame
544 :
545 : sal_Int16 nMinLeading; // minimum number of chars before hyphenation point
546 : sal_Int16 nMinTrailing; // minimum number of chars after hyphenation point
547 : sal_Int16 nMinWordLength; // minimum length of word to be hyphenated
548 :
549 : bool bFull : 1; // Line is full
550 : bool bFtnDone : 1; // Ftn already formatted
551 : bool bErgoDone : 1; // ErgoDone already formatted
552 : bool bNumDone : 1; // bNumDone already formatted
553 : bool bArrowDone : 1; // Arrow to the left for scrolling paragraphs
554 : bool bStop : 1; // Cancel immediately, discarding the line
555 : bool bNewLine : 1; // Format another line
556 : bool bShift : 1; // Position change: Repaint until further notice
557 : bool bUnderflow : 1; // Context: Underflow() ?
558 : bool bInterHyph : 1; // Interactive hyphenation?
559 : bool bAutoHyph : 1; // Automatic hyphenation?
560 : bool bDropInit : 1; // Set DropWidth
561 : bool bQuick : 1; // FormatQuick()
562 : bool bNoEndHyph : 1; // Switch off hyphenation at the line end (due to MaxHyphens)
563 : bool bNoMidHyph : 1; // Switch off hyphenation before flys (due to MaxHyphens)
564 : bool bIgnoreFly : 1; // FitToContent ignores flys
565 : bool bFakeLineStart : 1; // String has been replaced by field portion
566 : // info structure only pretends that we are at
567 : // the beginning of a line
568 : bool bTabOverflow : 1; // Tabs are expanding after the end margin
569 : bool bTestFormat : 1; // Test formatting from WouldFit, no notification etc.
570 :
571 : sal_Unicode cTabDecimal; // the current decimal delimiter
572 : sal_Unicode cHookChar; // For tabs in fields etc.
573 : sal_uInt8 nMaxHyph; // Max. line count of followup hyphenations
574 :
575 : // Hyphenating ...
576 : bool InitHyph( const bool bAuto = false );
577 : bool _CheckFtnPortion( SwLineLayout* pCurr );
578 :
579 : public:
580 : void CtorInitTxtFormatInfo( SwTxtFrm *pFrm, const bool bInterHyph = false,
581 : const bool bQuick = false, const bool bTst = false );
582 97770 : inline SwTxtFormatInfo(SwTxtFrm *pFrame, const bool bInterHyphL = false,
583 : const bool bQuickL = false, const bool bTst = false)
584 97770 : { CtorInitTxtFormatInfo( pFrame, bInterHyphL, bQuickL, bTst ); }
585 :
586 : // For the formatting inside a double line in a line (multi-line portion)
587 : // we need a modified text-format-info:
588 : SwTxtFormatInfo( const SwTxtFormatInfo& rInf, SwLineLayout& rLay,
589 : SwTwips nActWidth );
590 :
591 615233 : inline sal_uInt16 Width() const { return nWidth; }
592 146306 : inline void Width( const sal_uInt16 nNew ) { nWidth = nNew; }
593 : void Init();
594 :
595 : // Returns the first changed position of the paragraph
596 : inline sal_Int32 GetReformatStart() const;
597 :
598 : // Margins
599 684 : inline SwTwips Left() const { return nLeft; }
600 143092 : inline void Left( const SwTwips nNew ) { nLeft = nNew; }
601 143092 : inline SwTwips Right() const { return nRight; }
602 143092 : inline void Right( const SwTwips nNew ) { nRight = nNew; }
603 684 : inline SwTwips First() const { return nFirst; }
604 143092 : inline void First( const SwTwips nNew ) { nFirst = nNew; }
605 385549 : inline sal_uInt16 RealWidth() const { return nRealWidth; }
606 143752 : inline void RealWidth( const sal_uInt16 nNew ) { nRealWidth = nNew; }
607 684 : inline sal_uInt16 ForcedLeftMargin() const { return nForcedLeftMargin; }
608 143254 : inline void ForcedLeftMargin( const sal_uInt16 nN ) { nForcedLeftMargin = nN; }
609 :
610 180563 : inline sal_uInt8 &MaxHyph() { return nMaxHyph; }
611 : inline const sal_uInt8 &MaxHyph() const { return nMaxHyph; }
612 :
613 35708 : inline SwLineLayout *GetRoot() { return pRoot; }
614 60 : inline const SwLineLayout *GetRoot() const { return pRoot; }
615 :
616 143092 : inline void SetRoot( SwLineLayout *pNew ) { pRoot = pNew; }
617 2108374 : inline SwLinePortion *GetLast() { return pLast; }
618 566739 : inline void SetLast( SwLinePortion *pNewLast ) { pLast = pNewLast; }
619 496412 : inline bool IsFull() const { return bFull; }
620 293299 : inline void SetFull( const bool bNew ) { bFull = bNew; }
621 0 : inline bool IsHyphForbud() const
622 0 : { return pFly ? bNoMidHyph : bNoEndHyph; }
623 : inline void SetHyphForbud( const bool bNew )
624 : { if ( pFly ) bNoMidHyph = bNew; else bNoEndHyph = bNew; }
625 286346 : inline void ChkNoHyph( const sal_uInt8 bEnd, const sal_uInt8 bMid )
626 286346 : { bNoEndHyph = (nMaxHyph && bEnd >= nMaxHyph);
627 286346 : bNoMidHyph = (nMaxHyph && bMid >= nMaxHyph); }
628 89391 : inline bool IsIgnoreFly() const { return bIgnoreFly; }
629 5380 : inline void SetIgnoreFly( const bool bNew ) { bIgnoreFly = bNew; }
630 3010 : inline bool IsFakeLineStart() const { return bFakeLineStart; }
631 31866 : inline void SetFakeLineStart( const bool bNew ) { bFakeLineStart = bNew; }
632 1280798 : inline bool IsStop() const { return bStop; }
633 500 : inline void SetStop( const bool bNew ) { bStop = bNew; }
634 1621171 : inline SwLinePortion *GetRest() { return pRest; }
635 17528 : inline void SetRest( SwLinePortion *pNewRest ) { pRest = pNewRest; }
636 468854 : inline bool IsNewLine() const { return bNewLine; }
637 682 : inline void SetNewLine( const bool bNew ) { bNewLine = bNew; }
638 55766 : inline bool IsShift() const { return bShift; }
639 99679 : inline void SetShift( const bool bNew ) { bShift = bNew; }
640 0 : inline bool IsInterHyph() const { return bInterHyph; }
641 : inline bool IsAutoHyph() const { return bAutoHyph; }
642 191985 : inline bool IsUnderflow() const { return bUnderflow; }
643 148717 : inline void ClrUnderflow() { bUnderflow = false; }
644 136798 : inline bool IsDropInit() const { return bDropInit; }
645 24 : inline void SetDropInit( const bool bNew ) { bDropInit = bNew; }
646 115756 : inline bool IsQuick() const { return bQuick; }
647 270643 : inline bool IsTest() const { return bTestFormat; }
648 :
649 883663 : inline sal_Int32 GetLineStart() const { return nLineStart; }
650 255506 : inline void SetLineStart( const sal_Int32 nNew ) { nLineStart = nNew; }
651 :
652 : // these are used during fly calculation
653 216947 : inline sal_uInt16 GetLineHeight() const { return nLineHeight; }
654 136798 : inline void SetLineHeight( const sal_uInt16 nNew ) { nLineHeight = nNew; }
655 20 : inline sal_uInt16 GetLineNetHeight() const { return nLineNetHeight; }
656 136798 : inline void SetLineNetHeight( const sal_uInt16 nNew ) { nLineNetHeight = nNew; }
657 :
658 : inline const SwLinePortion *GetUnderflow() const { return pUnderflow; }
659 350457 : inline SwLinePortion *GetUnderflow() { return pUnderflow; }
660 508 : inline void SetUnderflow( SwLinePortion *pNew )
661 508 : { pUnderflow = pNew; bUnderflow = true; }
662 472 : inline sal_Int32 GetSoftHyphPos() const { return nSoftHyphPos; }
663 328 : inline void SetSoftHyphPos( const sal_Int32 nNew ) { nSoftHyphPos = nNew; }
664 :
665 : inline void SetParaFtn();
666 :
667 : // FlyFrms
668 934525 : inline SwFlyPortion *GetFly() { return pFly; }
669 290658 : inline void SetFly( SwFlyPortion *pNew ) { pFly = pNew; }
670 :
671 : inline const SwAttrSet& GetCharAttr() const;
672 :
673 : // Tabs
674 536008 : inline SwTabPortion *GetLastTab() { return pLastTab; }
675 10212 : inline void SetLastTab( SwTabPortion *pNew ) { pLastTab = pNew; }
676 5158 : inline sal_Unicode GetTabDecimal() const { return cTabDecimal; }
677 48 : inline void SetTabDecimal( const sal_Unicode cNew ) { cTabDecimal = cNew;}
678 :
679 : // Last*
680 : inline SwFldPortion *GetLastFld() { return pLastFld; }
681 : inline void SetLastFld( SwFldPortion *pNew ) { pLastFld = pNew; }
682 :
683 17544 : inline void ClearHookChar() { cHookChar = 0; }
684 36 : inline void SetHookChar( const sal_Unicode cNew ) { cHookChar = cNew; }
685 297891 : inline sal_Unicode GetHookChar() const { return cHookChar; }
686 :
687 : // Done-Flags
688 93184 : inline bool IsFtnDone() const { return bFtnDone; }
689 84392 : inline void SetFtnDone( const bool bNew ) { bFtnDone = bNew; }
690 468939 : inline bool IsErgoDone() const { return bErgoDone; }
691 225637 : inline void SetErgoDone( const bool bNew ) { bErgoDone = bNew; }
692 255264 : inline bool IsNumDone() const { return bNumDone; }
693 245458 : inline void SetNumDone( const bool bNew ) { bNumDone = bNew; }
694 376179 : inline bool IsArrowDone() const { return bArrowDone; }
695 201058 : inline void SetArrowDone( const bool bNew ) { bArrowDone = bNew; }
696 :
697 : // For SwTxtPortion::Hyphenate
698 : inline bool IsSoftHyph( const sal_Int32 nPos ) const;
699 : bool ChgHyph( const bool bNew );
700 :
701 : // Should the hyphenate helper be discarded?
702 : bool IsHyphenate() const;
703 158817 : inline sal_Int32 GetUnderScorePos() const { return nUnderScorePos; }
704 254 : inline void SetUnderScorePos( sal_Int32 nNew ) { nUnderScorePos = nNew; }
705 :
706 : // Calls HyphenateWord() of Hyphenator
707 : ::com::sun::star::uno::Reference<
708 : ::com::sun::star::linguistic2::XHyphenatedWord >
709 : HyphWord( const OUString &rTxt, const sal_Int32 nMinTrail );
710 : const com::sun::star::beans::PropertyValues &
711 : GetHyphValues() const;
712 :
713 136762 : bool CheckFtnPortion( SwLineLayout* pCurr )
714 136762 : { return IsFtnInside() && _CheckFtnPortion( pCurr ); }
715 :
716 : // Dropcaps called by SwTxtFormatter::CTOR
717 : const SwFmtDrop *GetDropFmt() const;
718 :
719 : // Sets the last SwKernPortion as pLast, if it is followed by empty portions
720 : bool LastKernPortion();
721 :
722 : // Looks for tabs, TabDec, TXTATR and BRK from nIdx until nEnd.
723 : // Return: Position; sets cHookChar if necessary
724 : sal_Int32 ScanPortionEnd( const sal_Int32 nStart, const sal_Int32 nEnd );
725 :
726 : friend SvStream & WriteSwTxtFormatInfo( SvStream &rOS, const SwTxtFormatInfo &rInf );
727 :
728 143256 : inline void SetTabOverflow( bool bOverflow ) { bTabOverflow = bOverflow; }
729 68 : inline bool IsTabOverflow() { return bTabOverflow; }
730 : };
731 :
732 : /**
733 : * For the text replacement and restoration of SwTxtSizeInfo.
734 : * The way this is done is a bit of a hack: Although rInf is const we change it
735 : * anyway.
736 : * Because rInf is restorated again in the DTOR, we can do this.
737 : * You could call it a "logical const", if you wish.
738 : */
739 : class SwTxtSlot
740 : {
741 : OUString aTxt;
742 : const OUString *pOldTxt;
743 : const SwWrongList* pOldSmartTagList;
744 : const SwWrongList* pOldGrammarCheckList;
745 : SwWrongList* pTempList;
746 : sal_Int32 nIdx;
747 : sal_Int32 nLen;
748 : bool bOn;
749 : protected:
750 : SwTxtSizeInfo *pInf;
751 : public:
752 : // The replacement string originates either from the portion via GetExpText()
753 : // or from the rCh, if it is not empty.
754 : SwTxtSlot( const SwTxtSizeInfo *pNew, const SwLinePortion *pPor, bool bTxtLen,
755 : bool bExgLists, OUString const & rCh = OUString() );
756 : ~SwTxtSlot();
757 : bool IsOn() const { return bOn; }
758 : };
759 :
760 : class SwFontSave
761 : {
762 : SwTxtSizeInfo *pInf;
763 : SwFont *pFnt;
764 : SwAttrIter *pIter;
765 : public:
766 : SwFontSave( const SwTxtSizeInfo &rInf, SwFont *pFnt,
767 : SwAttrIter* pItr = NULL );
768 : ~SwFontSave();
769 : };
770 :
771 352803 : inline sal_uInt16 SwTxtSizeInfo::GetAscent() const
772 : {
773 : SAL_WARN_IF( !GetOut(), "sw.core", "SwTxtSizeInfo::GetAscent() without m_pOut" );
774 :
775 352803 : return ((SwFont*)GetFont())->GetAscent( m_pVsh, *GetOut() );
776 : }
777 :
778 352769 : inline sal_uInt16 SwTxtSizeInfo::GetTxtHeight() const
779 : {
780 : SAL_WARN_IF( !GetOut(), "sw.core", "SwTxtSizeInfo::GetTxtHeight() without m_pOut" );
781 :
782 352769 : return ((SwFont*)GetFont())->GetHeight( m_pVsh, *GetOut() );
783 : }
784 :
785 1210 : inline SwPosSize SwTxtSizeInfo::GetTxtSize( const OUString &rTxt ) const
786 : {
787 1210 : return GetTxtSize( m_pOut, 0, rTxt, 0, rTxt.getLength(), 0 );
788 : }
789 :
790 0 : inline SwPosSize SwTxtSizeInfo::GetTxtSize( const SwScriptInfo* pSI,
791 : const sal_Int32 nNewIdx,
792 : const sal_Int32 nNewLen,
793 : const sal_uInt16 nCompress ) const
794 : {
795 0 : return GetTxtSize( m_pOut, pSI, *m_pTxt, nNewIdx, nNewLen, nCompress );
796 : }
797 :
798 421781 : inline SwTwips SwTxtPaintInfo::GetPaintOfst() const
799 : {
800 421781 : return GetParaPortion()->GetRepaint().GetOfst();
801 : }
802 :
803 529481 : inline void SwTxtPaintInfo::SetPaintOfst( const SwTwips nNew )
804 : {
805 529481 : GetParaPortion()->GetRepaint().SetOfst( nNew );
806 529481 : }
807 :
808 166 : inline void SwTxtPaintInfo::DrawText( const OUString &rText,
809 : const SwLinePortion &rPor,
810 : const sal_Int32 nStart, const sal_Int32 nLength,
811 : const bool bKern ) const
812 : {
813 166 : ((SwTxtPaintInfo*)this)->_DrawText( rText, rPor, nStart, nLength, bKern );
814 166 : }
815 :
816 35937 : inline void SwTxtPaintInfo::DrawText( const SwLinePortion &rPor,
817 : const sal_Int32 nLength, const bool bKern ) const
818 : {
819 35937 : ((SwTxtPaintInfo*)this)->_DrawText( *m_pTxt, rPor, m_nIdx, nLength, bKern );
820 35937 : }
821 :
822 7838 : inline void SwTxtPaintInfo::DrawMarkedText( const SwLinePortion &rPor,
823 : const sal_Int32 nLength,
824 : const bool bKern,
825 : const bool bWrong,
826 : const bool bSmartTags,
827 : const bool bGrammarCheck ) const
828 : {
829 7838 : ((SwTxtPaintInfo*)this)->_DrawText( *m_pTxt, rPor, m_nIdx, nLength, bKern, bWrong, bSmartTags, bGrammarCheck );
830 7838 : }
831 :
832 316010 : inline sal_Int32 SwTxtFormatInfo::GetReformatStart() const
833 : {
834 316010 : return GetParaPortion()->GetReformat().Start();
835 : }
836 :
837 8650 : inline const SwAttrSet& SwTxtFormatInfo::GetCharAttr() const
838 : {
839 8650 : return GetTxtFrm()->GetTxtNode()->GetSwAttrSet();
840 : }
841 :
842 278 : inline void SwTxtFormatInfo::SetParaFtn()
843 : {
844 278 : GetTxtFrm()->SetFtn( true );
845 278 : }
846 :
847 : inline bool SwTxtFormatInfo::IsSoftHyph( const sal_Int32 nPos ) const
848 : {
849 : return CHAR_SOFTHYPHEN == GetTxtFrm()->GetTxtNode()->GetTxt()[nPos];
850 : }
851 :
852 : #endif
853 :
854 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|