31#include <com/sun/star/i18n/ScriptType.hpp>
32#include <com/sun/star/i18n/WordType.hpp>
33#include <com/sun/star/i18n/XBreakIterator.hpp>
50 sal_uInt16 nWidth, sal_uInt16 nHeight )
57 aRect.
Pos().AdjustX(rInf.
X() );
58 aRect.
Pos().setY( rInf.
Y() );
85 nLen( rInf.
GetLen() ), nX( rInf.
X() ), nY( rInf.
Y() )
89SwDropSave::~SwDropSave()
106 const sal_uInt16 nDrpHeight,
107 const sal_uInt16 nDrpDescent,
108 const sal_uInt16 nDist )
109 : m_nLines( nLineCnt ),
110 m_nDropHeight(nDrpHeight),
111 m_nDropDescent(nDrpDescent),
127 sal_Int32 nEnd =
GetText().getLength();
128 if( nWishLen && nWishLen < nEnd )
139 switch ( nTextScript )
141 case i18n::ScriptType::ASIAN :
144 case i18n::ScriptType::COMPLEX :
156 nEnd = aBound.endPos;
160 for( ;
i < nEnd; ++
i )
175 if (nWishLen && nWishLen < nEnd)
186 switch ( nTextScript )
188 case i18n::ScriptType::ASIAN :
191 case i18n::ScriptType::COMPLEX :
201 WordType::DICTIONARY_WORD,
true );
207 for ( ;
i < nEnd; ++
i)
217 assert(
pos.first->GetTextAttrForCharAt(
pos.second) !=
nullptr);
252 if (!pLastFrame->IsFollow() &&
253 pLastFrame->GetTextNodeForFirstText() ==
this)
256 if( !pLastFrame->HasPara() )
257 pLastFrame->GetFormatted();
259 if ( !pLastFrame->IsEmpty() )
262 OSL_ENSURE( pPara,
"GetDropSize could not find the ParaPortion, I'll guess the drop cap size" );
273 rFontHeight = pFont->GetSize(pFont->GetActual()).
Height();
286 if (rFontHeight==0 && rDropHeight==0 && rDropDescent==0)
288 const sal_uInt16 nLines = rDrop.
GetLines();
292 rDropHeight = nLines * rFontHeight;
293 rDropDescent = rFontHeight / 5;
307 const sal_uInt16 nOldWidth =
Width();
308 const sal_uInt16 nOldAscent =
GetAscent();
313 SwDropSave aSave( rInf );
356 const sal_uInt16 nOldHeight =
Height();
357 const sal_uInt16 nOldWidth =
Width();
358 const sal_uInt16 nOldAscent =
GetAscent();
405 std::unique_ptr<SwFont> pTmpFont;
431 rInf.
SetLen( nOldInfLen );
444 while ( pCurrPart && nIdx + pCurrPart->
GetLen() < rInf.
GetLen() )
446 nMyX = nMyX + pCurrPart->
GetWidth();
447 nIdx = nIdx + pCurrPart->
GetLen();
487 sal_uInt16 nDropHght = 0;
490 sal_uInt16 nDropLns = 0;
505 for( ; nDropLns < nLines; nDropLns++ )
512 nDropHght = nDropHght + nHeight;
523 nDropHght = nDropHght - nHeight;
524 nDropHght = nDropHght + nAscent;
536 OSL_ENSURE(
false,
"SwTextFormatter::_CalcDropHeight: left Toulouse" );
548 OSL_ENSURE( nLines,
"GuessDropHeight: Give me more Lines!" );
592 pDropPor->
SetLen( nPorLen );
605 OSL_ENSURE( ! rInf.
GetIdx(),
"Drop Portion not at 0 position!" );
610 while ( nNextChg < nPorLen )
630 if( nNextChg > nNextAttr )
631 nNextChg = nNextAttr;
632 if ( nNextChg > nPorLen )
635 std::unique_ptr<SwDropPortionPart> pPart(
637 auto pPartTemp = pPart.get();
640 pDropPor->
SetPart( std::move(pPart) );
642 pCurrPart->
SetFollow( std::move(pPart) );
644 pCurrPart = pPartTemp;
654 OSL_ENSURE( pDrop,
"DrapCop-Portion not available." );
676 nX = nX + pPor->
Width();
682 SwTwips nTmpAscent, nTmpHeight;
684 aLineOrigin.
AdjustY(nTmpAscent );
696#define DROP_CACHE_SIZE 10
718 const void* nFntCacheId =
nullptr;
719 sal_uInt16 nTmpIdx = 0;
721 OSL_ENSURE( pDrop->
GetPart(),
"DropPortion without part during font calculation");
726 OUString
aStr(rInf.
GetText().copy(sal_Int32(nIdx), sal_Int32(pCurrPart->
GetLen())));
764 if ( nCurrHeight > nMaxFontHeight )
765 nMaxFontHeight = nCurrHeight;
770 nFactor = ( 1000 * nWishedHeight ) / nMaxFontHeight;
779 m_aFactor[ nTmpIdx ] = o3tl::narrowing<sal_uInt16>(nFactor);
787#if OSL_DEBUG_LEVEL > 1
791 bool bWinUsed =
false;
793 MapMode aOldMap( MapUnit::MapTwip );
810 bool bFirstGlyphRect =
true;
826 Size aNewSize( 0, ( nFactor * nCurrHeight ) / 1000 );
833 bool bHaveGlyphRect =
pOut->GetTextBoundRect( aRect, rInf.
GetText(), 0,
834 sal_Int32(nIdx), sal_Int32(pCurrPart->
GetLen()))
837 if ( ! bHaveGlyphRect )
853 sal_Int32(nIdx), sal_Int32(pCurrPart->
GetLen()))
866 if ( bKeepBaseline && aRect.
Top() < 0 )
902 if ( bFirstGlyphRect )
905 bFirstGlyphRect =
false;
908 aCommonRect.
Union( aRect );
910 nIdx = nIdx + pCurrPart->
GetLen();
920 nDescent = aCommonRect.
Left();
921 nAscent = aCommonRect.
Right();
924 nDescent = -nDescent;
928 nDescent = aCommonRect.
Bottom();
929 nAscent = aCommonRect.
Top();
937 if ( nHght > nWishedHeight )
942 m_aFactor[ nTmpIdx ] = o3tl::narrowing<sal_uInt16>(nFactor);
946 nFactor = ( nFactor * nWishedHeight ) / nHght;
947 bGrow = ( nFactor > nMin ) && ( nFactor < nMax );
948#if OSL_DEBUG_LEVEL > 1
978 nDescent = -nDescent;
993 pDrop->
SetY(
static_cast<short>(nDescent) );
999 m_nFix = o3tl::narrowing<sal_uInt16>(rInf.
X());
1002 aLayoutModeModifier.
SetAuto();
1014 SwDropSave aSave( rInf );
1037 pCurrPart->
SetWidth( o3tl::narrowing<sal_uInt16>(nTmpWidth) );
1041 rInf.
X( rInf.
X() + nTmpWidth );
1046 Width( o3tl::narrowing<sal_uInt16>(rInf.
X() - nOldX) );
1083 const sal_uInt16 nRest = o3tl::narrowing<sal_uInt16>(rInf.
Width() - rInf.
X());
1084 if( ( nWant > nRest ) ||
o3tl::strong_int< sal_Int32, struct Tag_TextFrameIndex > TextFrameIndex
Denotes a character index in a text frame at a layout level, after extent mapping from a text node at...
static OutputDevice * GetDefaultDevice()
virtual bool get(DocumentSettingId id) const =0
Return the specified document setting.
const vcl::Font & GetFont() const
void SetFont(const vcl::Font &rNewFont)
bool GetTextBoundRect(tools::Rectangle &rRect, const OUString &rStr, sal_Int32 nBase=0, sal_Int32 nIndex=0, sal_Int32 nLen=-1, sal_uLong nLayoutWidth=0, KernArraySpan aDXArray=KernArraySpan(), o3tl::span< const sal_Bool > pKashidaArray={}, const SalLayoutGlyphs *pGlyphs=nullptr) const
const MapMode & GetMapMode() const
constexpr tools::Long Y() const
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
sal_uInt32 GetHeight() const
LanguageType GetLanguage() const
SwScriptInfo * m_pScriptInfo
TextFrameIndex GetNextAttr() const
bool Seek(TextFrameIndex nPos)
Enables the attributes used at char pos nPos in the logical font.
const SvxLanguageItem & GetCJKLanguage(bool=true) const
const SvxLanguageItem & GetLanguage(bool=true) const
const SvxLanguageItem & GetCTLLanguage(bool=true) const
css::uno::Reference< css::i18n::XBreakIterator > const & GetBreakIter() const
const css::lang::Locale & GetLocale(const LanguageType aLang)
sal_uInt16 GetRealScriptOfText(const OUString &rText, sal_Int32 nPos) const
const SwAttrSet & GetSwAttrSet() const
Does node has already its own auto-attributes? Access to SwAttrSet.
IDocumentSettingAccess const & getIDocumentSettingAccess() const
void CalcFontSize(SwDropPortion *pDrop, SwTextFormatInfo &rInf)
OUString m_aText[DROP_CACHE_SIZE]
sal_uInt16 m_aWishedHeight[DROP_CACHE_SIZE]
sal_uInt16 m_aFactor[DROP_CACHE_SIZE]
const void * m_aFontCacheId[DROP_CACHE_SIZE]
short m_aDescent[DROP_CACHE_SIZE]
bool GetJoinBorderWithPrev() const
std::unique_ptr< SwDropPortionPart > m_pFollow
~SwDropPortionPart()
SwDropPortionPart DTor.
void SetFollow(std::unique_ptr< SwDropPortionPart > pNew)
bool GetJoinBorderWithNext() const
TextFrameIndex GetLen() const
void SetWidth(sal_uInt16 nNew)
std::unique_ptr< SwFont > m_pFnt
SwDropPortionPart * GetFollow() const
sal_uInt16 GetWidth() const
Text portion for the Format -> Paragraph -> Drop Caps functionality.
sal_uInt16 GetDropHeight() const
virtual SwPosSize GetTextSize(const SwTextSizeInfo &rInfo) const override
sal_uInt16 m_nDropDescent
sal_uInt16 GetDropDescent() const
void SetPart(std::unique_ptr< SwDropPortionPart > pNew)
static void DeleteDropCapCache()
virtual bool Format(SwTextFormatInfo &rInf) override
virtual TextFrameIndex GetModelPositionForViewPoint(sal_uInt16 nOfst) const override
the parameter is actually SwTwips apparently?
friend class SwDropCapCache
bool FormatText(SwTextFormatInfo &rInf)
virtual ~SwDropPortion() override
void PaintDrop(const SwTextPaintInfo &rInf) const
void PaintText(const SwTextPaintInfo &rInf) const
Manipulate the width, otherwise the chars are being stretched.
std::unique_ptr< SwDropPortionPart > m_pPart
SwDropPortion(const sal_uInt16 nLineCnt, const sal_uInt16 nDropHeight, const sal_uInt16 nDropDescent, const sal_uInt16 nDistance)
SwDropPortion CTor, DTor.
sal_uInt16 GetDistance() const
virtual void Paint(const SwTextPaintInfo &rInf) const override
SwDropPortionPart * GetPart() const
To take Asian or other languages into consideration, an SwFont object consists of 3 SwSubFonts (Latin...
const std::optional< Color > & GetBackColor() const
sal_uInt16 GetBottomBorderSpace() const
sal_uInt16 GetTopBorderSpace() const
const std::optional< editeng::SvxBorderLine > & GetTopBorder() const
void SetDiffFnt(const SfxItemSet *pSet, const IDocumentSettingAccess *pIDocumentSettingAccess)
void SetVertical(Degree10 nDir, const bool bVertLayout=false, const bool bVertLayoutLRBT=false)
Degree10 GetOrientation(const bool bVertLayout=false, const bool bVertFormatLRBT=false) const
void SetProportion(const sal_uInt8 nNewPropr)
const std::optional< editeng::SvxBorderLine > & GetBottomBorder() const
void SetTopBorderDist(const sal_uInt16 nTopDist)
void GetFontCacheId(const void *&rnFontCacheId, sal_uInt16 &rIdx, SwFontScript nWhich)
void SetSize(const Size &rSize, const SwFontScript nWhich)
const SvxFont & GetActualFont() const
void SetLeftBorderDist(const sal_uInt16 nLeftDist)
SwFontScript GetActual() const
void SetRightBorderDist(const sal_uInt16 nRightDist)
sal_uInt8 GetPropr() const
void CheckFontCacheId(SwViewShell const *pSh, SwFontScript nWhich)
sal_uInt16 GetAscent(SwViewShell const *pSh, const OutputDevice &rOut)
bool HasBorder() const
Check whether font has any border on any side.
void ChgPhysFnt(SwViewShell const *pSh, OutputDevice &rOut)
tools::Long GetHeight() const
void SetBottomBorderDist(const sal_uInt16 nBottomDist)
const SwRect & getFrameArea() const
const SwRect & getFramePrintArea() const
SwLinePortion * GetFirstPortion() const
virtual void Height(const SwTwips nNew, const bool bText=true) override
SwTwips GetRealHeight() const
std::vector< tools::Long > * GetpLLSpaceAdd() const
std::deque< sal_uInt16 > * GetpKanaComp() const
Base class for anything that can be part of a line in the Writer layout.
void SetJoinBorderWithNext(const bool bJoinNext)
SwLinePortion * GetNextPortion() const
void SetAscent(const SwTwips nNewAsc)
TextFrameIndex GetLen() const
bool IsDropPortion() const
void SetLen(TextFrameIndex const nLen)
void SetJoinBorderWithPrev(const bool bJoinPrev)
void SetWhichPor(const PortionType nNew)
Collection of SwLineLayout instances, represents the paragraph text in Writer layout.
const SwDropPortion * FindDropPortion() const
Of course Writer needs its own rectangles.
SwRect & Intersection(const SwRect &rRect)
void Pos(const Point &rNew)
void ChgClip(const SwRect &rRect, const SwTextFrame *pFrame=nullptr, bool bEnlargeRect=false, sal_Int32 nEnlargeTop=0, sal_Int32 nEnlargeBottom=0)
TextFrameIndex NextScriptChg(TextFrameIndex nPos) const
The purpose of this class is to be the universal interface between formatting/text output and the pos...
SwRect GetFrame(const SwRect &rPortion) const
const SwFormatDrop * GetDropFormat() const
void SetDropInit(const bool bNew)
void SetUnderflow(SwLinePortion *pNew)
void GuessDropHeight(const sal_uInt16 nLines)
We assume that the font height doesn't change and that at first there are at least as many lines,...
void CalcDropHeight(const sal_uInt16 nLines)
SwDropPortion * NewDropPortion(SwTextFormatInfo &rInf)
void CalcRealHeight(bool bNewLine=false)
const SwFormatDrop * m_pDropFormat
Represents the visualization of a paragraph.
TextFrameIndex GetDropLen(TextFrameIndex nWishLen) const
nWishLen = 0 indicates that we want a whole word
std::pair< SwTextNode *, sal_Int32 > MapViewToModel(TextFrameIndex nIndex) const
map position in potentially merged text frame to SwPosition
const OUString & GetText() const
Returns the text portion we want to edit (for inline see underneath)
SwTextNode const * GetTextNodeForParaProps() const
SwParaPortion * GetParaPortion()
const SwLineLayout * GetNext() const
TextFrameIndex GetStart() const
const SwLineLayout * Next()
const SwLineLayout * GetCurr() const
void CalcAscentAndHeight(SwTwips &rAscent, SwTwips &rHeight) const
bool IsRegisterOn() const
sal_uInt16 GetDropLines() const
sal_uInt16 GetDropDescent() const
void SetDropLines(const sal_uInt16 nNew)
void SetDropHeight(const sal_uInt16 nNew)
sal_uInt16 GetDropHeight() const
void SetDropDescent(const sal_uInt16 nNew)
bool GetDropSize(int &rFontHeight, int &rDropHeight, int &rDropDescent) const
Passes back info needed on the dropcap dimensions.
const OUString & GetText() const
sal_Int32 GetDropLen(sal_Int32 nWishLen) const
nWishLen = 0 indicates that we want a whole word
SwTextAttr * GetTextAttrForCharAt(const sal_Int32 nIndex, const sal_uInt16 nWhich=RES_TXTATR_END) const
get the text attribute at position nIndex which owns the dummy character CH_TXTATR_* at that position...
void SetpSpaceAdd(std::vector< tools::Long > *pNew)
const SwRect & GetPaintRect() const
void DrawBackground(const SwLinePortion &rPor, const Color *pColor=nullptr) const
void SetPos(const Point &rNew)
tools::Long GetSpaceAdd() const
SwTextPaintInfo & GetInfo()
void SetPaintDrop(const bool bNew)
virtual SwPosSize GetTextSize(const SwTextSizeInfo &rInfo) const override
virtual void Paint(const SwTextPaintInfo &rInf) const override
virtual bool Format(SwTextFormatInfo &rInf) override
virtual tools::Long CalcSpacing(tools::Long nSpaceAdd, const SwTextSizeInfo &rInf) const override
SwTextFrame * GetTextFrame()
vcl::RenderContext * GetOut()
const SwViewOption & GetOpt() const
void SetLen(const TextFrameIndex nNew)
sal_uInt16 GetTextHeight() const
void SetIdx(const TextFrameIndex nNew)
sal_uInt16 GetAscent() const
void SetKanaComp(std::deque< sal_uInt16 > *pNew)
TextFrameIndex GetLen() const
const OUString & GetText() const
TextFrameIndex GetIdx() const
bool IsPagePreview() const
bool IsFieldShadings() const
vcl::Window * GetWin() const
::OutputDevice const * GetOutDev() const
constexpr ::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
constexpr TypedWhichId< SvxFontHeightItem > RES_CHRATR_FONTSIZE(8)
#define CH_TXTATR_BREAKWORD
double getLength(const B2DPolygon &rCandidate)
SwDropCapCache * pDropCapCache
tools::Long GetLen(const Point &rPnt)
const sal_Unicode CH_BREAK
static bool lcl_IsDropFlyInter(const SwTextFormatInfo &rInf, sal_uInt16 nWidth, sal_uInt16 nHeight)
Calculates if a drop caps portion intersects with a fly The width and height of the drop caps portion...