/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ #pragma once
namespace com::sun::star::linguistic2 { class XHyphenatedWord; }
class SvxBrushItem; class SvxLineSpacingItem; class SwFlyPortion; class SwFormatDrop; class SwLinePortion; class SwTabPortion; class SwViewOption; class SwViewShell; class SwAttrIter; struct SwMultiCreator; class SwMultiPortion; namespace sw { class WrongListIterator; }
class SwTextSizeInfo : public SwTextInfo
{ private: typedef std::map<SwLinePortion const*, SwTwips> SwTextPortionMap;
protected: // during formatting, a small database is built, mapping portion pointers // to their maximum size (used for kana compression)
SwTextPortionMap m_aMaxWidth; // for each line, an array of compression values is calculated // this array is passed over to the info structure
std::deque<sal_uInt16>* m_pKanaComp;
SwViewShell *m_pVsh;
// m_pOut is the output device, m_pRef is the device used for formatting
VclPtr<OutputDevice> m_pOut;
VclPtr<OutputDevice> m_pRef;
// performance hack - this is only used by SwTextFormatInfo but // because it's not even possible to dynamic_cast these things // currently it has to be stored here
std::shared_ptr<const vcl::text::TextLayoutCache> m_pCachedVclData;
SwFont *m_pFnt;
SwUnderlineFont *m_pUnderFnt; // Font for underlining
SwTextFrame *m_pFrame; const SwViewOption *m_pOpt; const OUString *m_pText;
TextFrameIndex m_nIdx;
TextFrameIndex m_nLen;
TextFrameIndex m_nMeasureLen;
std::optional<SwLinePortionLayoutContext> m_nLayoutContext;
sal_uInt16 m_nKanaIdx; bool m_bOnWin : 1; bool m_bNotEOL : 1; bool m_bURLNotify : 1; bool m_bStopUnderflow : 1; // Underflow was stopped e.g. by a FlyPortion bool m_bFootnoteInside : 1; // the current line contains a footnote bool m_bOtherThanFootnoteInside : 1; // the current line contains another portion than a footnote portion. // needed for checking keep together of footnote portion with previous portion bool m_bMulti : 1; // inside a multiportion bool m_bFirstMulti : 1; // this flag is used for two purposes: // - the multiportion is the first lineportion // - indicates, if we are currently in second // line of multi portion bool m_bRuby : 1; // during the formatting of a phonetic line bool m_bHanging : 1; // formatting of hanging punctuation allowed bool m_bScriptSpace : 1; // space between different scripts (Asian/Latin) bool m_bForbiddenChars : 1; // Forbidden start/endline characters bool m_bSnapToGrid : 1; // paragraph snaps to grid
sal_uInt8 m_nDirection : 2; // writing direction: 0/90/180/270 degree
SwTwips m_nExtraSpace; // extra space before shrinking = nSpacesInLine * (nSpaceWidth/0.8 - nSpaceWidth)
SwTwips m_nBreakWidth; // break width to calculate space width at justification
// GetMultiAttr returns the text attribute of the multiportion, // if rPos is inside any multi-line part. // rPos will set to the end of the multi-line part.
std::optional<SwMultiCreator> GetMultiCreator(TextFrameIndex &rPos, SwMultiPortion const* pM) const;
// No Bullets for the symbol font! bool IsNoSymbol() const
{ return RTL_TEXTENCODING_SYMBOL != m_pFnt->GetCharSet( m_pFnt->GetActual() ); }
void NoteAnimation() const;
// Home is where Your heart is...
SwTextFrame *GetTextFrame() { return m_pFrame; } const SwTextFrame *GetTextFrame() const { return m_pFrame; }
bool HasHint(TextFrameIndex nPos) const;
// extra space before shrinking = nSpacesInLine * (nSpaceWidth/0.8 - nSpaceWidth) void SetExtraSpace(SwTwips nVal) { m_nExtraSpace = nVal; }
SwTwips GetExtraSpace() const { return m_nExtraSpace; } // set break width to calculate space width later void SetBreakWidth(SwTwips nVal) { m_nBreakWidth = nVal; }
SwTwips GetBreakWidth() const { return m_nBreakWidth; }
// If Kana Compression is enabled, a minimum and maximum portion width // is calculated. We format lines with minimal size and share remaining // space among compressed kanas. // During formatting, the maximum values of compressible portions are // stored in m_aMaxWidth and discarded after a line has been formatted. void SetMaxWidthDiff(const SwLinePortion* nKey, SwTwips nVal)
{
m_aMaxWidth.insert( std::make_pair( nKey, nVal ) );
};
SwTwips GetMaxWidthDiff(const SwLinePortion* nKey)
{
SwTextPortionMap::iterator it = m_aMaxWidth.find( nKey );
class SwTextPaintInfo : public SwTextSizeInfo
{
sw::WrongListIterator *m_pWrongList;
sw::WrongListIterator *m_pGrammarCheckList;
sw::WrongListIterator *m_pSmartTags;
std::vector<tools::Long>* m_pSpaceAdd; const SvxBrushItem *m_pBrushItem; // For the background
SwTextFly m_aTextFly; // Calculate the FlyFrame
Point m_aPos; // Paint position
SwRect m_aPaintRect; // Original paint rect (from Layout paint)
/** * Draw character border around a line portion. * * @param[in] rPor line portion around which border have to be drawn.
**/ void DrawBorder( const SwLinePortion &rPor ) const;
void NotifyURL(const SwLinePortion& rPor) const
{ if (URLNotify())
NotifyURL_(rPor);
}
/** * Calculate the rectangular area where the portion takes place. * @param[in] rPor portion for which the method specify the painting area * @param[out] pRect whole area of the portion * @param[out] pIntersect part of the portion area clipped by OutputDevice's clip region * @param[in] bInsideBox area of portion's content, padding and border, but shadow * is excluded (e.g. for background)
**/ void CalcRect( const SwLinePortion& rPor, SwRect* pRect,
SwRect* pIntersect = nullptr, constbool bInsideBox = false ) const;
class SwTextFormatInfo : public SwTextPaintInfo
{ // temporary arguments for hyphenation
css::beans::PropertyValues m_aHyphVals;
SwLineLayout *m_pRoot; // The Root of the current line (pCurr)
SwLinePortion *m_pLast; // The last Portion
SwFlyPortion *m_pFly; // The following FlyPortion
SwLinePortion *m_pUnderflow; // Underflow: Last Portion
SwLinePortion *m_pRest; // The Rest is the start of the next Line
SwTabPortion *m_pLastTab; // The _last_ TabPortion
TextFrameIndex m_nSoftHyphPos; ///< SoftHyphPos for Hyphenation
TextFrameIndex m_nLineStart; ///< Current line start in rText
TextFrameIndex m_nLastBookmarkPos; ///< need to check for bookmarks at every portion // #i34348# Changed type from sal_uInt16 to SwTwips
SwTwips m_nLeft; // Left margin
SwTwips m_nRight; // Right margin
SwTwips m_nFirst; // EZE /// First or left margin, depending on context.
SwTwips m_nLeftMargin = 0;
SwTwips m_nRealWidth; // "real" line width
SwTwips m_nWidth; // "virtual" line width
SwTwips m_nLineHeight; // Final height after CalcLine
SwTwips m_nLineNetHeight; // line height without spacing
SwTwips m_nForcedLeftMargin; // Shift of left margin due to frame
SwTwips m_nExtraAscent = 0; // Enlarge clipping area for glyphs above the line height
SwTwips m_nExtraDescent = 0; // Enlarge clipping area for glyphs below the line height
bool m_bFull : 1; // Line is full bool m_bFootnoteDone : 1; // Footnote already formatted bool m_bErgoDone : 1; // ErgoDone already formatted bool m_bNumDone : 1; // bNumDone already formatted bool m_bArrowDone : 1; // Arrow to the left for scrolling paragraphs bool m_bStop : 1; // Cancel immediately, discarding the line bool m_bNewLine : 1; // Format another line bool m_bShift : 1; // Position change: Repaint until further notice bool m_bUnderflow : 1; // Context: Underflow() ? bool m_bInterHyph : 1; // Interactive hyphenation? bool m_bAutoHyph : 1; // Automatic hyphenation? bool m_bDropInit : 1; // Set DropWidth bool m_bQuick : 1; // FormatQuick() bool m_bNoEndHyph : 1; // Switch off hyphenation at the line end (due to MaxHyphens) bool m_bNoMidHyph : 1; // Switch off hyphenation before flys (due to MaxHyphens) bool m_bIgnoreFly : 1; // FitToContent ignores flys bool m_bFakeLineStart : 1; // String has been replaced by field portion // info structure only pretends that we are at // the beginning of a line bool m_bTabOverflow : 1; // Tabs are expanding after the end margin bool m_bTestFormat : 1; // Test formatting from WouldFit, no notification etc.
sal_Unicode m_cTabDecimal; // the current decimal delimiter
sal_Unicode m_cHookChar; // For tabs in fields etc.
sal_uInt8 m_nMaxHyph; // Max. line count of followup hyphenations
// Used to stop justification after center/right/decimal tab stops - see tdf#tdf#106234 enumclass TabSeen
{
None,
Left,
Center,
Right,
Decimal,
} m_eLastTabsSeen = TabSeen::None;
// For the formatting inside a double line in a line (multi-line portion) // we need a modified text-format-info:
SwTextFormatInfo( const SwTextFormatInfo& rInf, SwLineLayout& rLay,
SwTwips nActWidth );
// Dropcaps called by SwTextFormatter::CTOR const SwFormatDrop *GetDropFormat() const;
// Sets the last SwKernPortion as pLast, if it is followed by empty portions bool LastKernPortion();
// Looks for tabs, TabDec, TXTATR and BRK from nIdx until nEnd. // Return: Position; sets cHookChar if necessary
TextFrameIndex ScanPortionEnd(TextFrameIndex nStart, TextFrameIndex nEnd);
// get line space count between line start and break position // by stripping also terminating spaces
sal_Int32 GetLineSpaceCount(TextFrameIndex nBreakPos);
};
/** * For the text replacement and restoration of SwTextSizeInfo. * The way this is done is a bit of a hack: Although rInf is const we change it * anyway. * Because rInf is restored again in the DTOR, we can do this. * You could call it a "logical const", if you wish.
*/ class SwTextSlot final
{
OUString aText;
std::shared_ptr<const vcl::text::TextLayoutCache> m_pOldCachedVclData; const OUString *pOldText;
sw::WrongListIterator * m_pOldSmartTagList;
sw::WrongListIterator * m_pOldGrammarCheckList;
std::unique_ptr<SwWrongList> m_pTempList;
std::unique_ptr<sw::WrongListIterator> m_pTempIter;
TextFrameIndex nIdx;
TextFrameIndex nLen;
TextFrameIndex nMeasureLen; bool bOn;
SwTextSizeInfo *pInf;
public: // The replacement string originates either from the portion via GetExpText() // or from the rCh, if it is not empty.
SwTextSlot( const SwTextSizeInfo *pNew, const SwLinePortion *pPor, bool bTextLen, bool bExgLists, OUString const & rCh = OUString() );
~SwTextSlot();
};
inlineconst SwAttrSet& SwTextFormatInfo::GetCharAttr() const
{ // sw_redlinehide: this is used for numbering/footnote number portions, so: return GetTextFrame()->GetTextNodeForParaProps()->GetSwAttrSet();
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.39Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.