android: Update app-specific/MIME type icons
[LibreOffice.git] / sw / source / core / text / inftxt.hxx
blob62cca26ac08f00f929f98e08305411340f1c7742
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #pragma once
21 #include <memory>
22 #include <optional>
23 #include <com/sun/star/beans/PropertyValues.hpp>
25 #include <map>
27 #include <swtypes.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>
36 namespace com::sun::star::linguistic2 { class XHyphenatedWord; }
38 class SvxBrushItem;
39 class SvxLineSpacingItem;
40 class SvxTabStop;
41 class SvxTabStopItem;
42 class SwFlyPortion;
43 class SwFormatDrop;
44 class SwLinePortion;
45 class SwTabPortion;
46 class SwViewOption;
47 class SwViewShell;
48 class SwAttrIter;
49 struct SwMultiCreator;
50 class SwMultiPortion;
51 namespace sw { class WrongListIterator; }
53 #define ARROW_WIDTH 200
54 #define DIR_LEFT2RIGHT 0
55 #define DIR_BOTTOM2TOP 1
56 #define DIR_RIGHT2LEFT 2
57 #define DIR_TOP2BOTTOM 3
59 // Respects the attribute LineSpace when calculating the Height/Ascent
60 class SwLineInfo
62 friend class SwTextIter;
64 std::optional<SvxTabStopItem> m_oRuler;
65 const SvxLineSpacingItem *m_pSpace;
66 SvxParaVertAlignItem::Align m_nVertAlign;
67 sal_uInt16 m_nDefTabStop;
68 bool m_bListTabStopIncluded;
69 tools::Long m_nListTabStopPosition;
71 void CtorInitLineInfo( const SwAttrSet& rAttrSet,
72 const SwTextNode& rTextNode );
74 SwLineInfo();
75 ~SwLineInfo();
76 public:
77 // #i24363# tab stops relative to indent - returns the tab stop following nSearchPos or NULL
78 const SvxTabStop* GetTabStop(const SwTwips nSearchPos, SwTwips& nRight) const;
79 const SvxLineSpacingItem *GetLineSpacing() const { return m_pSpace; }
80 sal_uInt16 GetDefTabStop() const { return m_nDefTabStop; }
81 void SetDefTabStop( sal_uInt16 nNew ) const
82 { const_cast<SwLineInfo*>(this)->m_nDefTabStop = nNew; }
84 // vertical alignment
85 SvxParaVertAlignItem::Align GetVertAlign() const { return m_nVertAlign; }
86 bool HasSpecialAlign( bool bVert ) const
87 { return bVert ?
88 ( SvxParaVertAlignItem::Align::Baseline != m_nVertAlign ) :
89 ( SvxParaVertAlignItem::Align::Baseline != m_nVertAlign &&
90 SvxParaVertAlignItem::Align::Automatic != m_nVertAlign ); }
92 sal_uInt16 NumberOfTabStops() const;
94 bool IsListTabStopIncluded() const
96 return m_bListTabStopIncluded;
98 tools::Long GetListTabStopPosition() const
100 return m_nListTabStopPosition;
104 class SwTextInfo
106 // Implementation in txthyph.cxx
107 friend void SetParaPortion( SwTextInfo *pInf, SwParaPortion *pRoot );
108 SwParaPortion *m_pPara;
109 TextFrameIndex m_nTextStart; // TextOfst for Follows
111 protected:
112 SwTextInfo()
113 : m_pPara(nullptr)
114 , m_nTextStart(0)
117 public:
118 void CtorInitTextInfo( SwTextFrame *pFrame );
119 SwTextInfo( const SwTextInfo &rInf );
120 explicit SwTextInfo( SwTextFrame *pFrame ) { CtorInitTextInfo( pFrame ); }
121 SwParaPortion *GetParaPortion() { return m_pPara; }
122 const SwParaPortion *GetParaPortion() const { return m_pPara; }
123 TextFrameIndex GetTextStart() const { return m_nTextStart; }
126 class SwTextSizeInfo : public SwTextInfo
128 private:
129 typedef std::map< SwLinePortion const *, sal_uInt16 > SwTextPortionMap;
131 protected:
132 // during formatting, a small database is built, mapping portion pointers
133 // to their maximum size (used for kana compression)
134 SwTextPortionMap m_aMaxWidth;
135 // for each line, an array of compression values is calculated
136 // this array is passed over to the info structure
137 std::deque<sal_uInt16>* m_pKanaComp;
139 SwViewShell *m_pVsh;
141 // m_pOut is the output device, m_pRef is the device used for formatting
142 VclPtr<OutputDevice> m_pOut;
143 VclPtr<OutputDevice> m_pRef;
145 // performance hack - this is only used by SwTextFormatInfo but
146 // because it's not even possible to dynamic_cast these things
147 // currently it has to be stored here
148 std::shared_ptr<const vcl::text::TextLayoutCache> m_pCachedVclData;
150 SwFont *m_pFnt;
151 SwUnderlineFont *m_pUnderFnt; // Font for underlining
152 SwTextFrame *m_pFrame;
153 const SwViewOption *m_pOpt;
154 const OUString *m_pText;
155 TextFrameIndex m_nIdx;
156 TextFrameIndex m_nLen;
157 TextFrameIndex m_nMeasureLen;
158 sal_uInt16 m_nKanaIdx;
159 bool m_bOnWin : 1;
160 bool m_bNotEOL : 1;
161 bool m_bURLNotify : 1;
162 bool m_bStopUnderflow : 1; // Underflow was stopped e.g. by a FlyPortion
163 bool m_bFootnoteInside : 1; // the current line contains a footnote
164 bool m_bOtherThanFootnoteInside : 1; // the current line contains another portion than a footnote portion.
165 // needed for checking keep together of footnote portion with previous portion
166 bool m_bMulti : 1; // inside a multiportion
167 bool m_bFirstMulti : 1; // this flag is used for two purposes:
168 // - the multiportion is the first lineportion
169 // - indicates, if we are currently in second
170 // line of multi portion
171 bool m_bRuby : 1; // during the formatting of a phonetic line
172 bool m_bHanging : 1; // formatting of hanging punctuation allowed
173 bool m_bScriptSpace : 1; // space between different scripts (Asian/Latin)
174 bool m_bForbiddenChars : 1; // Forbidden start/endline characters
175 bool m_bSnapToGrid : 1; // paragraph snaps to grid
176 sal_uInt8 m_nDirection : 2; // writing direction: 0/90/180/270 degree
178 protected:
179 void CtorInitTextSizeInfo( OutputDevice* pRenderContext, SwTextFrame *pFrame,
180 TextFrameIndex nIdx);
181 SwTextSizeInfo();
182 public:
183 SwTextSizeInfo( const SwTextSizeInfo &rInf );
184 SwTextSizeInfo( const SwTextSizeInfo &rInf, const OUString* pText,
185 TextFrameIndex nIdx = TextFrameIndex(0) );
186 SwTextSizeInfo(SwTextFrame *pTextFrame, TextFrameIndex nIndex = TextFrameIndex(0));
188 // GetMultiAttr returns the text attribute of the multiportion,
189 // if rPos is inside any multi-line part.
190 // rPos will set to the end of the multi-line part.
191 std::optional<SwMultiCreator> GetMultiCreator(TextFrameIndex &rPos, SwMultiPortion const* pM) const;
193 bool OnWin() const { return m_bOnWin; }
194 void SetOnWin( const bool bNew ) { m_bOnWin = bNew; }
195 bool NotEOL() const { return m_bNotEOL; }
196 void SetNotEOL( const bool bNew ) { m_bNotEOL = bNew; }
197 bool URLNotify() const { return m_bURLNotify; }
198 bool StopUnderflow() const { return m_bStopUnderflow; }
199 void SetStopUnderflow( const bool bNew ) { m_bStopUnderflow = bNew; }
200 bool IsFootnoteInside() const { return m_bFootnoteInside; }
201 void SetFootnoteInside( const bool bNew ) { m_bFootnoteInside = bNew; }
202 bool IsOtherThanFootnoteInside() const { return m_bOtherThanFootnoteInside; }
203 void SetOtherThanFootnoteInside( const bool bNew ) { m_bOtherThanFootnoteInside = bNew; }
204 bool IsMulti() const { return m_bMulti; }
205 void SetMulti( const bool bNew ) { m_bMulti = bNew; }
206 bool IsFirstMulti() const { return m_bFirstMulti; }
207 void SetFirstMulti( const bool bNew ) { m_bFirstMulti = bNew; }
208 bool IsRuby() const { return m_bRuby; }
209 void SetRuby( const bool bNew ) { m_bRuby = bNew; }
210 bool IsHanging() const { return m_bHanging; }
211 void SetHanging( const bool bNew ) { m_bHanging = bNew; }
212 bool HasScriptSpace() const { return m_bScriptSpace; }
213 void SetScriptSpace( const bool bNew ) { m_bScriptSpace = bNew; }
214 bool HasForbiddenChars() const { return m_bForbiddenChars; }
215 void SetForbiddenChars( const bool bN ) { m_bForbiddenChars = bN; }
216 bool SnapToGrid() const { return m_bSnapToGrid; }
217 void SetSnapToGrid( const bool bN ) { m_bSnapToGrid = bN; }
218 sal_uInt8 GetDirection() const { return m_nDirection; }
219 void SetDirection( const sal_uInt8 nNew ) { m_nDirection = nNew; }
220 bool IsRotated() const { return ( 1 & m_nDirection ); }
222 SwViewShell *GetVsh() { return m_pVsh; }
223 const SwViewShell *GetVsh() const { return m_pVsh; }
225 vcl::RenderContext *GetOut() { return m_pOut; }
226 const vcl::RenderContext *GetOut() const { return m_pOut; }
227 void SetOut( OutputDevice* pNewOut ) { m_pOut = pNewOut; }
229 vcl::RenderContext *GetRefDev() { return m_pRef; }
230 const vcl::RenderContext *GetRefDev() const { return m_pRef; }
232 SwFont *GetFont() { return m_pFnt; }
233 const SwFont *GetFont() const { return m_pFnt; }
234 void SetFont( SwFont *pNew ) { m_pFnt = pNew; }
235 void SelectFont();
236 void SetUnderFnt( SwUnderlineFont* pNew ) { m_pUnderFnt = pNew; }
237 SwUnderlineFont* GetUnderFnt() const { return m_pUnderFnt; }
239 const SwViewOption &GetOpt() const { return *m_pOpt; }
240 const OUString &GetText() const { return *m_pText; }
241 sal_Unicode GetChar(TextFrameIndex const nPos) const {
242 if (m_pText && nPos < TextFrameIndex(m_pText->getLength())) return (*m_pText)[sal_Int32(nPos)];
243 return 0;
246 sal_uInt16 GetTextHeight() const;
248 SwPosSize GetTextSize( OutputDevice* pOut, const SwScriptInfo* pSI,
249 const OUString& rText, TextFrameIndex nIdx,
250 TextFrameIndex nLen ) const;
251 SwPosSize GetTextSize() const;
252 void GetTextSize( const SwScriptInfo* pSI, TextFrameIndex nIdx,
253 TextFrameIndex nLen, const sal_uInt16 nComp,
254 sal_uInt16& nMinSize, sal_uInt16& nMaxSizeDiff,
255 vcl::text::TextLayoutCache const* = nullptr) const;
256 inline SwPosSize GetTextSize(const SwScriptInfo* pSI, TextFrameIndex nIdx,
257 TextFrameIndex nLen) const;
258 inline SwPosSize GetTextSize( const OUString &rText ) const;
260 TextFrameIndex GetTextBreak( const tools::Long nLineWidth,
261 const TextFrameIndex nMaxLen,
262 const sal_uInt16 nComp,
263 vcl::text::TextLayoutCache const*) const;
264 TextFrameIndex GetTextBreak( const tools::Long nLineWidth,
265 const TextFrameIndex nMaxLen,
266 const sal_uInt16 nComp,
267 TextFrameIndex& rExtraCharPos,
268 vcl::text::TextLayoutCache const*) const;
270 sal_uInt16 GetAscent() const;
271 sal_uInt16 GetHangingBaseline() const;
273 TextFrameIndex GetIdx() const { return m_nIdx; }
274 void SetIdx(const TextFrameIndex nNew) { m_nIdx = nNew; }
275 TextFrameIndex GetLen() const { return m_nLen; }
276 void SetLen(const TextFrameIndex nNew) { m_nLen = nNew; }
277 TextFrameIndex GetMeasureLen() const { return m_nMeasureLen; }
278 void SetMeasureLen(const TextFrameIndex nNew) { m_nMeasureLen = nNew; }
279 void SetText( const OUString &rNew ){ m_pText = &rNew; }
281 // No Bullets for the symbol font!
282 bool IsNoSymbol() const
283 { return RTL_TEXTENCODING_SYMBOL != m_pFnt->GetCharSet( m_pFnt->GetActual() ); }
285 void NoteAnimation() const;
287 // Home is where Your heart is...
288 SwTextFrame *GetTextFrame() { return m_pFrame; }
289 const SwTextFrame *GetTextFrame() const { return m_pFrame; }
291 bool HasHint(TextFrameIndex nPos) const;
293 // If Kana Compression is enabled, a minimum and maximum portion width
294 // is calculated. We format lines with minimal size and share remaining
295 // space among compressed kanas.
296 // During formatting, the maximum values of compressible portions are
297 // stored in m_aMaxWidth and discarded after a line has been formatted.
298 void SetMaxWidthDiff( const SwLinePortion *nKey, sal_uInt16 nVal )
300 m_aMaxWidth.insert( std::make_pair( nKey, nVal ) );
302 sal_uInt16 GetMaxWidthDiff( const SwLinePortion *nKey )
304 SwTextPortionMap::iterator it = m_aMaxWidth.find( nKey );
306 if( it != m_aMaxWidth.end() )
307 return it->second;
308 else
309 return 0;
311 void ResetMaxWidthDiff()
313 m_aMaxWidth.clear();
315 bool CompressLine()
317 return !m_aMaxWidth.empty();
320 // Feature: Kana Compression
322 sal_uInt16 GetKanaIdx() const { return m_nKanaIdx; }
323 void ResetKanaIdx(){ m_nKanaIdx = 0; }
324 void SetKanaIdx( sal_uInt16 nNew ) { m_nKanaIdx = nNew; }
325 void IncKanaIdx() { ++m_nKanaIdx; }
326 void SetKanaComp( std::deque<sal_uInt16> *pNew ){ m_pKanaComp = pNew; }
327 std::deque<sal_uInt16>* GetpKanaComp() const { return m_pKanaComp; }
328 sal_uInt16 GetKanaComp() const
329 { return ( m_pKanaComp && m_nKanaIdx < m_pKanaComp->size() )
330 ? (*m_pKanaComp)[m_nKanaIdx] : 0; }
332 const std::shared_ptr<const vcl::text::TextLayoutCache>& GetCachedVclData() const
334 return m_pCachedVclData;
336 void SetCachedVclData(std::shared_ptr<const vcl::text::TextLayoutCache> const& pCachedVclData)
338 m_pCachedVclData = pCachedVclData;
342 class SwTextPaintInfo : public SwTextSizeInfo
344 sw::WrongListIterator *m_pWrongList;
345 sw::WrongListIterator *m_pGrammarCheckList;
346 sw::WrongListIterator *m_pSmartTags;
347 std::vector<tools::Long>* m_pSpaceAdd;
348 const SvxBrushItem *m_pBrushItem; // For the background
349 SwTextFly m_aTextFly; // Calculate the FlyFrame
350 Point m_aPos; // Paint position
351 SwRect m_aPaintRect; // Original paint rect (from Layout paint)
353 sal_uInt16 m_nSpaceIdx;
354 void DrawText_(const OUString &rText, const SwLinePortion &rPor,
355 const TextFrameIndex nIdx, const TextFrameIndex nLen,
356 const bool bKern, const bool bWrong = false,
357 const bool bSmartTag = false,
358 const bool bGrammarCheck = false );
360 SwTextPaintInfo &operator=(const SwTextPaintInfo&) = delete;
362 protected:
363 SwTextPaintInfo()
364 : m_pWrongList(nullptr)
365 , m_pGrammarCheckList(nullptr)
366 , m_pSmartTags(nullptr)
367 , m_pSpaceAdd(nullptr)
368 , m_pBrushItem(nullptr)
369 , m_nSpaceIdx(0)
372 public:
373 SwTextPaintInfo( const SwTextPaintInfo &rInf );
374 SwTextPaintInfo( const SwTextPaintInfo &rInf, const OUString* pText );
376 void CtorInitTextPaintInfo( OutputDevice* pRenderContext, SwTextFrame *pFrame, const SwRect &rPaint );
378 const SvxBrushItem *GetBrushItem() const { return m_pBrushItem; }
380 SwTextPaintInfo( SwTextFrame *pFrame, const SwRect &rPaint );
382 SwTwips X() const { return m_aPos.X(); }
383 void X( const tools::Long nNew ) { m_aPos.setX(nNew); }
384 SwTwips Y() const { return m_aPos.Y(); }
385 void Y( const SwTwips nNew ) { m_aPos.setY(nNew); }
387 SwTextFly& GetTextFly() { return m_aTextFly; }
388 const SwTextFly& GetTextFly() const { return m_aTextFly; }
389 inline void DrawText( const OUString &rText, const SwLinePortion &rPor,
390 TextFrameIndex nIdx = TextFrameIndex(0),
391 TextFrameIndex nLen = TextFrameIndex(COMPLETE_STRING),
392 const bool bKern = false) const;
393 inline void DrawText( const SwLinePortion &rPor, TextFrameIndex nLen,
394 const bool bKern = false ) const;
395 inline void DrawMarkedText( const SwLinePortion &rPor, TextFrameIndex nLen,
396 const bool bWrong,
397 const bool bSmartTags,
398 const bool bGrammarCheck ) const;
400 void DrawRect( const SwRect &rRect, bool bRetouche ) const;
402 void DrawTab( const SwLinePortion &rPor ) const;
403 void DrawLineBreak( const SwLinePortion &rPor ) const;
404 void DrawRedArrow( const SwLinePortion &rPor ) const;
405 void DrawPostIts( bool bScript ) const;
406 void DrawBackground( const SwLinePortion &rPor, const Color *pColor=nullptr ) const;
407 void DrawViewOpt( const SwLinePortion &rPor, PortionType nWhich, const Color *pColor=nullptr ) const;
408 void DrawBackBrush( const SwLinePortion &rPor ) const;
411 * Draw character border around a line portion.
413 * @param[in] rPor line portion around which border have to be drawn.
415 void DrawBorder( const SwLinePortion &rPor ) const;
417 void DrawCheckBox(const SwFieldFormCheckboxPortion &rPor, bool bChecked) const;
419 void DrawCSDFHighlighting(const SwLinePortion &rPor) const;
422 * Calculate the rectangular area where the portion takes place.
423 * @param[in] rPor portion for which the method specify the painting area
424 * @param[out] pRect whole area of the portion
425 * @param[out] pIntersect part of the portion area clipped by OutputDevice's clip region
426 * @param[in] bInsideBox area of portion's content, padding and border, but shadow
427 * is excluded (e.g. for background)
429 void CalcRect( const SwLinePortion& rPor, SwRect* pRect,
430 SwRect* pIntersect = nullptr, const bool bInsideBox = false ) const;
432 inline SwTwips GetPaintOfst() const;
433 inline void SetPaintOfst( const SwTwips nNew );
434 const Point &GetPos() const { return m_aPos; }
435 void SetPos( const Point &rNew ) { m_aPos = rNew; }
437 const SwRect &GetPaintRect() const { return m_aPaintRect; }
439 // STUFF FOR JUSTIFIED ALIGNMENT
441 sal_uInt16 GetSpaceIdx() const { return m_nSpaceIdx; }
442 void ResetSpaceIdx(){m_nSpaceIdx = 0; }
443 void SetSpaceIdx( sal_uInt16 nNew ) { m_nSpaceIdx = nNew; }
444 void IncSpaceIdx() { ++m_nSpaceIdx; }
445 void RemoveFirstSpaceAdd() { m_pSpaceAdd->erase( m_pSpaceAdd->begin() ); }
446 tools::Long GetSpaceAdd() const
447 { return ( m_pSpaceAdd && m_nSpaceIdx < m_pSpaceAdd->size() )
448 ? (*m_pSpaceAdd)[m_nSpaceIdx] : 0; }
450 void SetpSpaceAdd( std::vector<tools::Long>* pNew ){ m_pSpaceAdd = pNew; }
451 std::vector<tools::Long>* GetpSpaceAdd() const { return m_pSpaceAdd; }
453 void SetWrongList(sw::WrongListIterator *const pNew) { m_pWrongList = pNew; }
454 sw::WrongListIterator* GetpWrongList() const { return m_pWrongList; }
456 void SetGrammarCheckList(sw::WrongListIterator *const pNew) { m_pGrammarCheckList = pNew; }
457 sw::WrongListIterator* GetGrammarCheckList() const { return m_pGrammarCheckList; }
459 void SetSmartTags(sw::WrongListIterator *const pNew) { m_pSmartTags = pNew; }
460 sw::WrongListIterator* GetSmartTags() const { return m_pSmartTags; }
463 class SwTextFormatInfo : public SwTextPaintInfo
465 // temporary arguments for hyphenation
466 css::beans::PropertyValues m_aHyphVals;
468 SwLineLayout *m_pRoot; // The Root of the current line (pCurr)
469 SwLinePortion *m_pLast; // The last Portion
470 SwFlyPortion *m_pFly; // The following FlyPortion
471 SwLinePortion *m_pUnderflow; // Underflow: Last Portion
472 SwLinePortion *m_pRest; // The Rest is the start of the next Line
474 SwTabPortion *m_pLastTab; // The _last_ TabPortion
476 TextFrameIndex m_nSoftHyphPos; ///< SoftHyphPos for Hyphenation
477 TextFrameIndex m_nLineStart; ///< Current line start in rText
478 TextFrameIndex m_nUnderScorePos; ///< enlarge repaint if underscore has been found
479 TextFrameIndex m_nLastBookmarkPos; ///< need to check for bookmarks at every portion
480 // #i34348# Changed type from sal_uInt16 to SwTwips
481 SwTwips m_nLeft; // Left margin
482 SwTwips m_nRight; // Right margin
483 SwTwips m_nFirst; // EZE
484 /// First or left margin, depending on context.
485 SwTwips m_nLeftMargin = 0;
486 sal_uInt16 m_nRealWidth; // "real" line width
487 sal_uInt16 m_nWidth; // "virtual" line width
488 sal_uInt16 m_nLineHeight; // Final height after CalcLine
489 sal_uInt16 m_nLineNetHeight; // line height without spacing
490 sal_uInt16 m_nForcedLeftMargin; // Shift of left margin due to frame
492 bool m_bFull : 1; // Line is full
493 bool m_bFootnoteDone : 1; // Footnote already formatted
494 bool m_bErgoDone : 1; // ErgoDone already formatted
495 bool m_bNumDone : 1; // bNumDone already formatted
496 bool m_bArrowDone : 1; // Arrow to the left for scrolling paragraphs
497 bool m_bStop : 1; // Cancel immediately, discarding the line
498 bool m_bNewLine : 1; // Format another line
499 bool m_bShift : 1; // Position change: Repaint until further notice
500 bool m_bUnderflow : 1; // Context: Underflow() ?
501 bool m_bInterHyph : 1; // Interactive hyphenation?
502 bool m_bAutoHyph : 1; // Automatic hyphenation?
503 bool m_bDropInit : 1; // Set DropWidth
504 bool m_bQuick : 1; // FormatQuick()
505 bool m_bNoEndHyph : 1; // Switch off hyphenation at the line end (due to MaxHyphens)
506 bool m_bNoMidHyph : 1; // Switch off hyphenation before flys (due to MaxHyphens)
507 bool m_bIgnoreFly : 1; // FitToContent ignores flys
508 bool m_bFakeLineStart : 1; // String has been replaced by field portion
509 // info structure only pretends that we are at
510 // the beginning of a line
511 bool m_bTabOverflow : 1; // Tabs are expanding after the end margin
512 bool m_bTestFormat : 1; // Test formatting from WouldFit, no notification etc.
514 sal_Unicode m_cTabDecimal; // the current decimal delimiter
515 sal_Unicode m_cHookChar; // For tabs in fields etc.
516 sal_uInt8 m_nMaxHyph; // Max. line count of followup hyphenations
518 // Hyphenating ...
519 bool InitHyph( const bool bAuto = false );
520 bool CheckFootnotePortion_( SwLineLayout const * pCurr );
522 public:
523 void CtorInitTextFormatInfo( OutputDevice* pRenderContext, SwTextFrame *pFrame, const bool bInterHyph = false,
524 const bool bQuick = false, const bool bTst = false );
525 SwTextFormatInfo(OutputDevice* pRenderContext, SwTextFrame *pFrame, const bool bInterHyphL = false,
526 const bool bQuickL = false, const bool bTst = false);
528 // For the formatting inside a double line in a line (multi-line portion)
529 // we need a modified text-format-info:
530 SwTextFormatInfo( const SwTextFormatInfo& rInf, SwLineLayout& rLay,
531 SwTwips nActWidth );
533 sal_uInt16 Width() const { return m_nWidth; }
534 void Width( const sal_uInt16 nNew ) { m_nWidth = nNew; }
535 void Init();
538 * Returns the distance between the current horizontal position and the end
539 * of the line.
541 SwTwips GetLineWidth();
543 // Returns the first changed position of the paragraph
544 inline TextFrameIndex GetReformatStart() const;
546 // Margins
547 SwTwips Left() const { return m_nLeft; }
548 void Left( const SwTwips nNew ) { m_nLeft = nNew; }
549 SwTwips Right() const { return m_nRight; }
550 void Right( const SwTwips nNew ) { m_nRight = nNew; }
551 SwTwips First() const { return m_nFirst; }
552 void First( const SwTwips nNew ) { m_nFirst = nNew; }
553 void LeftMargin( const SwTwips nNew) { m_nLeftMargin = nNew; }
554 sal_uInt16 RealWidth() const { return m_nRealWidth; }
555 void RealWidth( const sal_uInt16 nNew ) { m_nRealWidth = nNew; }
556 sal_uInt16 ForcedLeftMargin() const { return m_nForcedLeftMargin; }
557 void ForcedLeftMargin( const sal_uInt16 nN ) { m_nForcedLeftMargin = nN; }
559 sal_uInt8 &MaxHyph() { return m_nMaxHyph; }
560 const sal_uInt8 &MaxHyph() const { return m_nMaxHyph; }
562 SwLineLayout *GetRoot() { return m_pRoot; }
563 const SwLineLayout *GetRoot() const { return m_pRoot; }
565 void SetRoot( SwLineLayout *pNew ) { m_pRoot = pNew; }
566 SwLinePortion *GetLast() { return m_pLast; }
567 void SetLast( SwLinePortion *pNewLast ) { m_pLast = pNewLast; }
568 bool IsFull() const { return m_bFull; }
569 void SetFull( const bool bNew ) { m_bFull = bNew; }
570 bool IsHyphForbud() const
571 { return m_pFly ? m_bNoMidHyph : m_bNoEndHyph; }
572 void ChkNoHyph( const sal_uInt8 bEnd, const sal_uInt8 bMid )
573 { m_bNoEndHyph = (m_nMaxHyph && bEnd >= m_nMaxHyph);
574 m_bNoMidHyph = (m_nMaxHyph && bMid >= m_nMaxHyph); }
575 bool IsIgnoreFly() const { return m_bIgnoreFly; }
576 void SetIgnoreFly( const bool bNew ) { m_bIgnoreFly = bNew; }
577 bool IsFakeLineStart() const { return m_bFakeLineStart; }
578 void SetFakeLineStart( const bool bNew ) { m_bFakeLineStart = bNew; }
579 bool IsStop() const { return m_bStop; }
580 void SetStop( const bool bNew ) { m_bStop = bNew; }
581 SwLinePortion *GetRest() { return m_pRest; }
582 void SetRest( SwLinePortion *pNewRest ) { m_pRest = pNewRest; }
583 bool IsNewLine() const { return m_bNewLine; }
584 void SetNewLine( const bool bNew ) { m_bNewLine = bNew; }
585 bool IsShift() const { return m_bShift; }
586 void SetShift( const bool bNew ) { m_bShift = bNew; }
587 bool IsInterHyph() const { return m_bInterHyph; }
588 bool IsUnderflow() const { return m_bUnderflow; }
589 void ClrUnderflow() { m_bUnderflow = false; }
590 bool IsDropInit() const { return m_bDropInit; }
591 void SetDropInit( const bool bNew ) { m_bDropInit = bNew; }
592 bool IsQuick() const { return m_bQuick; }
593 bool IsTest() const { return m_bTestFormat; }
595 TextFrameIndex GetLineStart() const { return m_nLineStart; }
596 void SetLineStart(TextFrameIndex const nNew) { m_nLineStart = nNew; }
598 // these are used during fly calculation
599 sal_uInt16 GetLineHeight() const { return m_nLineHeight; }
600 void SetLineHeight( const sal_uInt16 nNew ) { m_nLineHeight = nNew; }
601 sal_uInt16 GetLineNetHeight() const { return m_nLineNetHeight; }
602 void SetLineNetHeight( const sal_uInt16 nNew ) { m_nLineNetHeight = nNew; }
604 const SwLinePortion *GetUnderflow() const { return m_pUnderflow; }
605 SwLinePortion *GetUnderflow() { return m_pUnderflow; }
606 void SetUnderflow( SwLinePortion *pNew )
607 { m_pUnderflow = pNew; m_bUnderflow = true; }
608 TextFrameIndex GetSoftHyphPos() const { return m_nSoftHyphPos; }
609 void SetSoftHyphPos(TextFrameIndex const nNew) { m_nSoftHyphPos = nNew; }
611 inline void SetParaFootnote();
613 // FlyFrames
614 SwFlyPortion *GetFly() { return m_pFly; }
615 void SetFly( SwFlyPortion *pNew ) { m_pFly = pNew; }
617 inline const SwAttrSet& GetCharAttr() const;
619 // Tabs
620 SwTabPortion *GetLastTab() { return m_pLastTab; }
621 void SetLastTab( SwTabPortion *pNew ) { m_pLastTab = pNew; }
622 sal_Unicode GetTabDecimal() const { return m_cTabDecimal; }
623 void SetTabDecimal( const sal_Unicode cNew ) { m_cTabDecimal = cNew;}
625 void ClearHookChar() { m_cHookChar = 0; }
626 void SetHookChar( const sal_Unicode cNew ) { m_cHookChar = cNew; }
627 sal_Unicode GetHookChar() const { return m_cHookChar; }
629 // Done-Flags
630 bool IsFootnoteDone() const { return m_bFootnoteDone; }
631 void SetFootnoteDone( const bool bNew ) { m_bFootnoteDone = bNew; }
632 bool IsErgoDone() const { return m_bErgoDone; }
633 void SetErgoDone( const bool bNew ) { m_bErgoDone = bNew; }
634 bool IsNumDone() const { return m_bNumDone; }
635 void SetNumDone( const bool bNew ) { m_bNumDone = bNew; }
636 bool IsArrowDone() const { return m_bArrowDone; }
637 void SetArrowDone( const bool bNew ) { m_bArrowDone = bNew; }
639 bool CheckCurrentPosBookmark();
641 // For SwTextPortion::Hyphenate
642 bool ChgHyph( const bool bNew );
644 // Should the hyphenate helper be discarded?
645 bool IsHyphenate() const;
646 TextFrameIndex GetUnderScorePos() const { return m_nUnderScorePos; }
647 void SetUnderScorePos(TextFrameIndex const nNew) { m_nUnderScorePos = nNew; }
649 // Calls HyphenateWord() of Hyphenator
650 css::uno::Reference< css::linguistic2::XHyphenatedWord >
651 HyphWord( const OUString &rText, const sal_Int32 nMinTrail );
652 const css::beans::PropertyValues & GetHyphValues() const;
654 bool CheckFootnotePortion( SwLineLayout const * pCurr )
655 { return IsFootnoteInside() && CheckFootnotePortion_( pCurr ); }
657 // Dropcaps called by SwTextFormatter::CTOR
658 const SwFormatDrop *GetDropFormat() const;
660 // Sets the last SwKernPortion as pLast, if it is followed by empty portions
661 bool LastKernPortion();
663 // Looks for tabs, TabDec, TXTATR and BRK from nIdx until nEnd.
664 // Return: Position; sets cHookChar if necessary
665 TextFrameIndex ScanPortionEnd(TextFrameIndex nStart, TextFrameIndex nEnd);
667 void SetTabOverflow( bool bOverflow ) { m_bTabOverflow = bOverflow; }
668 bool IsTabOverflow() const { return m_bTabOverflow; }
673 * For the text replacement and restoration of SwTextSizeInfo.
674 * The way this is done is a bit of a hack: Although rInf is const we change it
675 * anyway.
676 * Because rInf is restored again in the DTOR, we can do this.
677 * You could call it a "logical const", if you wish.
679 class SwTextSlot final
681 OUString aText;
682 std::shared_ptr<const vcl::text::TextLayoutCache> m_pOldCachedVclData;
683 const OUString *pOldText;
684 sw::WrongListIterator * m_pOldSmartTagList;
685 sw::WrongListIterator * m_pOldGrammarCheckList;
686 std::unique_ptr<SwWrongList> m_pTempList;
687 std::unique_ptr<sw::WrongListIterator> m_pTempIter;
688 TextFrameIndex nIdx;
689 TextFrameIndex nLen;
690 TextFrameIndex nMeasureLen;
691 bool bOn;
692 SwTextSizeInfo *pInf;
694 public:
695 // The replacement string originates either from the portion via GetExpText()
696 // or from the rCh, if it is not empty.
697 SwTextSlot( const SwTextSizeInfo *pNew, const SwLinePortion *pPor, bool bTextLen,
698 bool bExgLists, OUString const & rCh = OUString() );
699 ~SwTextSlot();
702 class SwFontSave
704 SwTextSizeInfo *pInf;
705 SwFont *pFnt;
706 SwAttrIter *pIter;
707 public:
708 SwFontSave( const SwTextSizeInfo &rInf, SwFont *pFnt,
709 SwAttrIter* pItr = nullptr );
710 ~SwFontSave();
713 inline sal_uInt16 SwTextSizeInfo::GetAscent() const
715 assert(GetOut());
716 return const_cast<SwFont*>(GetFont())->GetAscent( m_pVsh, *GetOut() );
719 inline sal_uInt16 SwTextSizeInfo::GetTextHeight() const
721 assert(GetOut());
722 return const_cast<SwFont*>(GetFont())->GetHeight( m_pVsh, *GetOut() );
725 inline sal_uInt16 SwTextSizeInfo::GetHangingBaseline() const
727 assert(GetOut());
728 return const_cast<SwFont*>(GetFont())->GetHangingBaseline( m_pVsh, *GetOut() );
731 inline SwPosSize SwTextSizeInfo::GetTextSize( const OUString &rText ) const
733 return GetTextSize(m_pOut, nullptr, rText, TextFrameIndex(0), TextFrameIndex(rText.getLength()));
736 inline SwPosSize SwTextSizeInfo::GetTextSize( const SwScriptInfo* pSI,
737 TextFrameIndex const nNewIdx,
738 TextFrameIndex const nNewLen) const
740 return GetTextSize( m_pOut, pSI, *m_pText, nNewIdx, nNewLen );
743 inline SwTwips SwTextPaintInfo::GetPaintOfst() const
745 return GetParaPortion()->GetRepaint().GetOffset();
748 inline void SwTextPaintInfo::SetPaintOfst( const SwTwips nNew )
750 GetParaPortion()->GetRepaint().SetOffset( nNew );
753 inline void SwTextPaintInfo::DrawText( const OUString &rText,
754 const SwLinePortion &rPor,
755 const TextFrameIndex nStart, const TextFrameIndex nLength,
756 const bool bKern ) const
758 const_cast<SwTextPaintInfo*>(this)->DrawText_( rText, rPor, nStart, nLength, bKern );
761 inline void SwTextPaintInfo::DrawText( const SwLinePortion &rPor,
762 const TextFrameIndex nLength, const bool bKern ) const
764 const_cast<SwTextPaintInfo*>(this)->DrawText_( *m_pText, rPor, m_nIdx, nLength, bKern );
767 inline void SwTextPaintInfo::DrawMarkedText( const SwLinePortion &rPor,
768 const TextFrameIndex nLength,
769 const bool bWrong,
770 const bool bSmartTags,
771 const bool bGrammarCheck ) const
773 const_cast<SwTextPaintInfo*>(this)->DrawText_( *m_pText, rPor, m_nIdx, nLength, false/*bKern*/, bWrong, bSmartTags, bGrammarCheck );
776 inline TextFrameIndex SwTextFormatInfo::GetReformatStart() const
778 return GetParaPortion()->GetReformat().Start();
781 inline const SwAttrSet& SwTextFormatInfo::GetCharAttr() const
783 // sw_redlinehide: this is used for numbering/footnote number portions, so:
784 return GetTextFrame()->GetTextNodeForParaProps()->GetSwAttrSet();
787 inline void SwTextFormatInfo::SetParaFootnote()
789 GetTextFrame()->SetFootnote( true );
792 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */