31 #include <com/sun/star/i18n/ScriptType.hpp>
32 #include <com/sun/star/i18n/WordType.hpp>
33 #include <com/sun/star/i18n/XBreakIterator.hpp>
49 sal_uInt16 nWidth, sal_uInt16 nHeight )
56 aRect.Pos().AdjustX(rInf.
X() );
57 aRect.Pos().setY( rInf.
Y() );
84 nLen( rInf.
GetLen() ), nX( rInf.
X() ), nY( rInf.
Y() )
88 SwDropSave::~SwDropSave()
105 const sal_uInt16 nDrpHeight,
106 const sal_uInt16 nDrpDescent,
107 const sal_uInt16 nDist )
108 : m_nLines( nLineCnt ),
109 m_nDropHeight(nDrpHeight),
110 m_nDropDescent(nDrpDescent),
126 sal_Int32 nEnd =
GetText().getLength();
127 if( nWishLen && nWishLen < nEnd )
138 switch ( nTextScript )
140 case i18n::ScriptType::ASIAN :
143 case i18n::ScriptType::COMPLEX :
155 nEnd = aBound.endPos;
159 for( ; i < nEnd; ++i )
174 if (nWishLen && nWishLen < nEnd)
185 switch ( nTextScript )
187 case i18n::ScriptType::ASIAN :
190 case i18n::ScriptType::COMPLEX :
200 WordType::DICTIONARY_WORD, true );
206 for ( ; i < nEnd; ++i)
216 assert(pos.first->GetTextAttrForCharAt(pos.second) !=
nullptr);
251 if (!pLastFrame->IsFollow() &&
252 pLastFrame->GetTextNodeForFirstText() ==
this)
255 if( !pLastFrame->HasPara() )
256 pLastFrame->GetFormatted();
258 if ( !pLastFrame->IsEmpty() )
261 OSL_ENSURE( pPara,
"GetDropSize could not find the ParaPortion, I'll guess the drop cap size" );
272 rFontHeight = pFont->GetSize(pFont->GetActual()).
Height();
285 if (rFontHeight==0 && rDropHeight==0 && rDropDescent==0)
287 const sal_uInt16 nLines = rDrop.
GetLines();
291 rDropHeight = nLines * rFontHeight;
292 rDropDescent = rFontHeight / 5;
306 const sal_uInt16 nOldWidth =
Width();
307 const sal_uInt16 nOldAscent =
GetAscent();
312 SwDropSave aSave( rInf );
355 const sal_uInt16 nOldHeight =
Height();
356 const sal_uInt16 nOldWidth =
Width();
357 const sal_uInt16 nOldAscent =
GetAscent();
404 std::unique_ptr<SwFont> pTmpFont;
430 rInf.
SetLen( nOldInfLen );
443 while ( pCurrPart && nIdx + pCurrPart->
GetLen() < rInf.
GetLen() )
445 nMyX = nMyX + pCurrPart->
GetWidth();
446 nIdx = nIdx + pCurrPart->
GetLen();
465 aPosSize.Width( aPosSize.Width() + nMyX );
486 sal_uInt16 nDropHght = 0;
489 sal_uInt16 nDropLns = 0;
504 for( ; nDropLns < nLines; nDropLns++ )
511 nDropHght = nDropHght + nHeight;
522 nDropHght = nDropHght - nHeight;
523 nDropHght = nDropHght + nAscent;
535 OSL_ENSURE(
false,
"SwTextFormatter::_CalcDropHeight: left Toulouse" );
547 OSL_ENSURE( nLines,
"GuessDropHeight: Give me more Lines!" );
591 pDropPor->
SetLen( nPorLen );
604 OSL_ENSURE( ! rInf.
GetIdx(),
"Drop Portion not at 0 position!" );
609 while ( nNextChg < nPorLen )
629 if( nNextChg > nNextAttr )
630 nNextChg = nNextAttr;
631 if ( nNextChg > nPorLen )
634 std::unique_ptr<SwDropPortionPart> pPart(
636 auto pPartTemp = pPart.get();
639 pDropPor->
SetPart( std::move(pPart) );
641 pCurrPart->
SetFollow( std::move(pPart) );
643 pCurrPart = pPartTemp;
653 OSL_ENSURE( pDrop,
"DrapCop-Portion not available." );
675 nX = nX + pPor->
Width();
680 aLineOrigin.AdjustX(nX );
681 SwTwips nTmpAscent, nTmpHeight;
683 aLineOrigin.AdjustY(nTmpAscent );
695 #define DROP_CACHE_SIZE 10
717 const void* nFntCacheId =
nullptr;
718 sal_uInt16 nTmpIdx = 0;
720 OSL_ENSURE( pDrop->
GetPart(),
"DropPortion without part during font calculation");
725 OUString
aStr(rInf.
GetText().copy(sal_Int32(nIdx), sal_Int32(pCurrPart->GetLen())));
732 SwFont& rFnt = pCurrPart->GetFont();
761 const SwFont& rFnt = pCurrPart->GetFont();
763 if ( nCurrHeight > nMaxFontHeight )
764 nMaxFontHeight = nCurrHeight;
766 pCurrPart = pCurrPart->GetFollow();
769 nFactor = ( 1000 * nWishedHeight ) / nMaxFontHeight;
778 m_aFactor[ nTmpIdx ] = o3tl::narrowing<sal_uInt16>(nFactor);
786 #if OSL_DEBUG_LEVEL > 1
790 bool bWinUsed =
false;
792 MapMode aOldMap( MapUnit::MapTwip );
804 bool bFirstGlyphRect =
true;
810 SwFont& rFnt = pCurrPart->GetFont();
820 Size aNewSize( 0, ( nFactor * nCurrHeight ) / 1000 );
828 sal_Int32(nIdx), sal_Int32(pCurrPart->GetLen()))
831 if ( ! bHaveGlyphRect )
847 sal_Int32(nIdx), sal_Int32(pCurrPart->GetLen()))
888 if ( bFirstGlyphRect )
891 bFirstGlyphRect =
false;
894 aCommonRect.
Union( aRect );
896 nIdx = nIdx + pCurrPart->GetLen();
897 pCurrPart = pCurrPart->GetFollow();
906 nDescent = aCommonRect.
Left();
907 nAscent = aCommonRect.
Right();
910 nDescent = -nDescent;
914 nDescent = aCommonRect.
Bottom();
915 nAscent = aCommonRect.
Top();
923 if ( nHght > nWishedHeight )
928 m_aFactor[ nTmpIdx ] = o3tl::narrowing<sal_uInt16>(nFactor);
932 nFactor = ( nFactor * nWishedHeight ) / nHght;
933 bGrow = ( nFactor > nMin ) && ( nFactor < nMax );
934 #if OSL_DEBUG_LEVEL > 1
964 nDescent = -nDescent;
969 SwFont& rFnt = pCurrPart->GetFont();
977 pCurrPart = pCurrPart->GetFollow();
979 pDrop->
SetY( static_cast<short>(nDescent) );
985 m_nFix = o3tl::narrowing<sal_uInt16>(rInf.
X());
1000 SwDropSave aSave( rInf );
1023 pCurrPart->
SetWidth( o3tl::narrowing<sal_uInt16>(nTmpWidth) );
1027 rInf.
X( rInf.
X() + nTmpWidth );
1032 Width( o3tl::narrowing<sal_uInt16>(rInf.
X() - nOldX) );
1069 const sal_uInt16 nRest = o3tl::narrowing<sal_uInt16>(rInf.
Width() - rInf.
X());
1070 if( ( nWant > nRest ) ||
void SetLeftBorderDist(const sal_uInt16 nLeftDist)
virtual void Height(const SwTwips nNew, const bool bText=true) override
SwScriptInfo * m_pScriptInfo
std::deque< sal_uInt16 > * GetpKanaComp() const
const sal_Unicode CH_BREAK
Represents the visualization of a paragraph.
const SwFormatDrop * m_pDropFormat
bool IsRegisterOn() const
virtual TextFrameIndex GetModelPositionForViewPoint(sal_uInt16 nOfst) const override
the parameter is actually SwTwips apparently?
const std::optional< editeng::SvxBorderLine > & GetBottomBorder() const
~SwDropPortionPart()
SwDropPortionPart DTor.
const SwFormatDrop & GetDrop(bool=true) const
bool IsPagePreview() const
sal_uInt16 GetDropDescent() const
TextFrameIndex NextScriptChg(TextFrameIndex nPos) const
const OUString & GetText() const
void SetWidth(sal_uInt16 nNew)
TextFrameIndex GetStart() const
void SetPos(const Point &rNew)
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...
sal_uInt8 GetPropr() const
constexpr::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
const SwRect & getFramePrintArea() const
constexpr TypedWhichId< SvxFontHeightItem > RES_CHRATR_FONTSIZE(8)
static void DeleteDropCapCache()
const SvxLanguageItem & GetLanguage(bool=true) const
The purpose of this class is to be the universal interface between formatting/text output and the pos...
tools::Long GetLen(const Point &rPnt)
const SvxFont & GetActualFont() const
sal_uInt16 GetDropHeight() const
const SvxLanguageItem & GetCJKLanguage(bool=true) const
sal_uInt16 GetTextHeight() const
void SetLen(TextFrameIndex const nLen)
const MapMode & GetMapMode() const
TextFrameIndex GetNextAttr() const
virtual tools::Long CalcSpacing(tools::Long nSpaceAdd, const SwTextSizeInfo &rInf) const override
bool HasBorder() const
Check whether font has any border on any side.
SwDropPortionPart * GetPart() const
const SwLineLayout * Next()
tools::Long GetSpaceAdd() const
void Pos(const Point &rNew)
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...
void SetKanaComp(std::deque< sal_uInt16 > *pNew)
void SetJoinBorderWithPrev(const bool bJoinPrev)
Of course Writer needs its own rectangles.
const OUString & GetText() const
Returns the text portion we want to edit (for inline see underneath)
Collection of SwLineLayout instances, represents the paragraph text in Writer layout.
Degree10 GetOrientation(const bool bVertLayout=false, const bool bVertFormatLRBT=false) const
void SetBottomBorderDist(const sal_uInt16 nBottomDist)
virtual void Paint(const SwTextPaintInfo &rInf) const override
sal_uInt16 GetRealScriptOfText(const OUString &rText, sal_Int32 nPos) const
bool Seek(TextFrameIndex nPos)
Enables the attributes used at char pos nPos in the logical font.
static OutputDevice * GetDefaultDevice()
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...
#define CH_TXTATR_BREAKWORD
SwRect GetFrame(const SwRect &rPortion) const
Text portion for the Format -> Paragraph -> Drop Caps functionality.
const SwRect & getFrameArea() const
const vcl::Font & GetFont() const
sal_uInt16 GetAscent(SwViewShell const *pSh, const OutputDevice &rOut)
void PaintText(const SwTextPaintInfo &rInf) const
Manipulate the width, otherwise the chars are being stretched.
SwRect & Intersection(const SwRect &rRect)
void SetDropDescent(const sal_uInt16 nNew)
SwTextPaintInfo & GetInfo()
bool GetTextBoundRect(tools::Rectangle &rRect, const OUString &rStr, sal_Int32 nBase=0, sal_Int32 nIndex=0, sal_Int32 nLen=-1, sal_uLong nLayoutWidth=0, o3tl::span< const sal_Int32 > pDXArray={}, const SalLayoutGlyphs *pGlyphs=nullptr) const
void CalcRealHeight(bool bNewLine=false)
void ChgPhysFnt(SwViewShell const *pSh, OutputDevice &rOut)
virtual bool Format(SwTextFormatInfo &rInf) override
const std::optional< Color > & GetBackColor() const
sal_uInt16 GetDistance() const
SwFontScript GetActual() const
void DrawBackground(const SwLinePortion &rPor, const Color *pColor=nullptr) const
SwDropCapCache * pDropCapCache
const SwViewOption & GetOpt() const
void SetDropLines(const sal_uInt16 nNew)
SwTextNode const * GetTextNodeForParaProps() const
void SetFollow(std::unique_ptr< SwDropPortionPart > pNew)
sal_uInt16 GetDropDescent() const
void SetPart(std::unique_ptr< SwDropPortionPart > pNew)
SwTwips GetRealHeight() const
void SetRightBorderDist(const sal_uInt16 nRightDist)
sal_uInt16 m_nDropDescent
vcl::RenderContext * GetOut()
SwParaPortion * GetParaPortion()
void SetWhichPor(const PortionType nNew)
void CheckFontCacheId(SwViewShell const *pSh, SwFontScript nWhich)
void SetUnderflow(SwLinePortion *pNew)
void SetVertical(Degree10 nDir, const bool bVertLayout=false, const bool bVertLayoutLRBT=false)
SwLinePortion * GetFirstPortion() const
sal_uInt16 GetTopBorderSpace() const
void SetJoinBorderWithNext(const bool bJoinNext)
const SvxLanguageItem & GetCTLLanguage(bool=true) const
bool FormatText(SwTextFormatInfo &rInf)
TextFrameIndex GetIdx() const
sal_uInt16 m_aFactor[DROP_CACHE_SIZE]
bool IsDropPortion() const
static bool IsFieldShadings()
TextFrameIndex GetLen() const
SwTextFrame * GetTextFrame()
std::pair< SwTextNode *, sal_Int32 > MapViewToModel(TextFrameIndex nIndex) const
map position in potentially merged text frame to SwPosition
const OUString & GetText() const
std::unique_ptr< SwDropPortionPart > m_pPart
sal_uInt16 GetWidth() const
css::uno::Reference< css::i18n::XBreakIterator > const & GetBreakIter() const
Base class for anything that can be part of a line in the Writer layout.
const css::lang::Locale & GetLocale(const LanguageType aLang)
TextFrameIndex GetDropLen(TextFrameIndex nWishLen) const
nWishLen = 0 indicates that we want a whole word
void CalcAscentAndHeight(SwTwips &rAscent, SwTwips &rHeight) const
LanguageType GetLanguage() const
sal_Int32 GetDropLen(sal_Int32 nWishLen) const
nWishLen = 0 indicates that we want a whole word
virtual bool Format(SwTextFormatInfo &rInf) override
void PaintDrop(const SwTextPaintInfo &rInf) const
sal_uInt32 GetHeight() const
void CalcFontSize(SwDropPortion *pDrop, SwTextFormatInfo &rInf)
void ChgClip(const SwRect &rRect, const SwTextFrame *pFrame=nullptr, bool bEnlargeRect=false, sal_Int32 nEnlargeTop=0, sal_Int32 nEnlargeBottom=0)
void SetLen(const TextFrameIndex nNew)
TextFrameIndex GetLen() const
bool GetDropSize(int &rFontHeight, int &rDropHeight, int &rDropDescent) const
Passes back info needed on the dropcap dimensions.
void CalcDropHeight(const sal_uInt16 nLines)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
virtual SwPosSize GetTextSize(const SwTextSizeInfo &rInfo) const override
void SetSize(const Size &rSize, const SwFontScript nWhich)
vcl::Window * GetWin() const
bool GetJoinBorderWithNext() const
void SetFont(const vcl::Font &rNewFont)
std::unique_ptr< SwFont > m_pFnt
void SetDropHeight(const sal_uInt16 nNew)
friend class SwDropCapCache
::OutputDevice const * GetOutDev() const
IDocumentSettingAccess const & getIDocumentSettingAccess() const
virtual void Paint(const SwTextPaintInfo &rInf) const override
std::unique_ptr< SwDropPortionPart > m_pFollow
TextFrameIndex GetLen() const
sal_uInt16 GetBottomBorderSpace() const
OUString m_aText[DROP_CACHE_SIZE]
void SetPaintDrop(const bool bNew)
double getLength(const B2DPolygon &rCandidate)
void SetpSpaceAdd(std::vector< tools::Long > *pNew)
const SwAttrSet & GetSwAttrSet() const
Does node has already its own auto-attributes? Access to SwAttrSet.
const SwDropPortion * FindDropPortion() const
sal_uInt16 m_aWishedHeight[DROP_CACHE_SIZE]
const std::optional< editeng::SvxBorderLine > & GetTopBorder() const
const SwLineLayout * GetNext() const
const SwLineLayout * GetCurr() const
SwDropPortionPart * GetFollow() const
const SwRect & GetPaintRect() const
void SetDiffFnt(const SfxItemSet *pSet, const IDocumentSettingAccess *pIDocumentSettingAccess)
short m_aDescent[DROP_CACHE_SIZE]
virtual SwPosSize GetTextSize(const SwTextSizeInfo &rInfo) const override
sal_uInt16 GetDropLines() const
virtual ~SwDropPortion() override
std::vector< tools::Long > * GetpLLSpaceAdd() const
void SetProportion(const sal_uInt8 nNewPropr)
SwLinePortion * GetNextPortion() const
void SetIdx(const TextFrameIndex nNew)
SwDropPortion(const sal_uInt16 nLineCnt, const sal_uInt16 nDropHeight, const sal_uInt16 nDropDescent, const sal_uInt16 nDistance)
SwDropPortion CTor, DTor.
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...
void SetDropInit(const bool bNew)
tools::Long GetHeight() const
const void * m_aFontCacheId[DROP_CACHE_SIZE]
void SetTopBorderDist(const sal_uInt16 nTopDist)
SwDropPortion * NewDropPortion(SwTextFormatInfo &rInf)
sal_uInt16 GetAscent() const
sal_uInt16 GetDropHeight() const
void SetAscent(const SwTwips nNewAsc)
bool GetJoinBorderWithPrev() const
void GetFontCacheId(const void *&rnFontCacheId, sal_uInt16 &rIdx, SwFontScript nWhich)