30#include <com/sun/star/i18n/KCharacterType.hpp>
36 sal_Int32 nIndex, sal_Int32 nLen )
40 return pOut->GetTextArray( rStr, pDXAry,
nIndex, nLen,
true,
nullptr, layoutGlyphs);
74 double fAutoAscent = .8;
75 double fAutoDescent = .2;
82 fAutoAscent = rFontMetric.
GetAscent() / fFontHeight;
83 fAutoDescent = rFontMetric.
GetDescent() / fFontHeight;
100 const Size& rSize,
const Color& rCol,
bool bLeftOrTop,
bool bVertical )
112 if (nTop < rRect.
Top())
141 if (nLeft < rRect.
Left())
143 nLeft = rRect.
Left();
144 nRight = rRect.
Right();
146 aTmp.
setX(bLeftOrTop ? nLeft : nRight);
148 aNxt.
setX(bLeftOrTop ? nRight : nLeft);
198 for (sal_Int32
i = 0;
i < aTxt.getLength(); ++
i)
200 if( aTxt[
i] ==
' ' || aTxt[
i] ==
'\t')
206 OUString sTitle(aCharClass.
uppercase(OUString(aTxt[
i])));
207 aTxt = aTxt.replaceAt(
i, 1, sTitle);
216 SAL_WARN(
"editeng",
"SvxFont::CaseMapTxt: unknown casemap");
240 const sal_Int32 _nIdx,
const sal_Int32 _nLen )
246 virtual void DoSpace(
const bool bDraw );
249 const sal_Int32
nIdx,
const sal_Int32
nLen,
250 const bool bUpper ) = 0;
269 const OUString &rTxt = rDo.
GetTxt();
270 const sal_Int32 nIdx = rDo.
GetIdx();
271 const sal_Int32 nLen = rDo.
GetLen();
274 const sal_Int32 nTxtLen = std::min( rTxt.getLength(), nLen );
276 sal_Int32 nOldPos =
nPos;
279 bool bCaseMapLengthDiffers(aTxt.getLength() != rTxt.getLength());
285 OUString aCharString;
287 while(
nPos < nTxtLen )
295 while(
nPos < nTxtLen )
297 aCharString = rTxt.copy(
nPos + nIdx, 1 );
299 if ( nCharacterType & css::i18n::KCharacterType::LOWER )
301 if ( ! ( nCharacterType & css::i18n::KCharacterType::UPPER ) )
305 if( nOldPos !=
nPos )
307 if(bCaseMapLengthDiffers)
311 const OUString aSnippet = rTxt.copy(nIdx + nOldPos,
nPos-nOldPos);
314 rDo.
Do( aNewText, 0, aNewText.getLength(),
true );
318 rDo.
Do( aTxt, nIdx + nOldPos,
nPos-nOldPos,
true );
324 while(
nPos < nTxtLen )
327 if ( nCharacterType & css::i18n::KCharacterType::UPPER )
329 if ( aCharString ==
" " )
331 if( ++
nPos < nTxtLen )
332 aCharString = rTxt.copy(
nPos + nIdx, 1 );
334 if( nOldPos !=
nPos )
336 if(bCaseMapLengthDiffers)
340 const OUString aSnippet = rTxt.copy(nIdx + nOldPos,
nPos - nOldPos);
343 rDo.
Do( aNewText, 0, aNewText.getLength(),
false );
347 rDo.
Do( aTxt, nIdx + nOldPos,
nPos-nOldPos,
false );
353 while(
nPos < nTxtLen && aCharString ==
" " && ++
nPos < nTxtLen )
354 aCharString = rTxt.copy(
nPos + nIdx, 1 );
356 if( nOldPos !=
nPos )
360 if(bCaseMapLengthDiffers)
364 const OUString aSnippet = rTxt.copy(nIdx + nOldPos,
nPos - nOldPos);
367 rDo.
Do( aNewText, 0, aNewText.getLength(),
false );
371 rDo.
Do( aTxt, nIdx + nOldPos,
nPos - nOldPos,
false );
392 Font aNewFont( *
this );
393 Size aSize( aNewFont.GetFontSize() );
409 const sal_Int32 nIdx,
const sal_Int32 nLen )
const
412 return Size(
pOut->GetTextWidth( rTxt, nIdx, nLen ),
413 pOut->GetTextHeight() );
418 aTxtSize.
setWidth(
pOut->GetTextWidth( rTxt, nIdx, nLen ) );
422 bool bCaseMapLengthDiffers(aNewText.getLength() != rTxt.getLength());
425 if(bCaseMapLengthDiffers)
429 const OUString aSnippet = rTxt.copy(nIdx, nLen);
431 nWidth =
pOut->GetTextWidth( _aNewText, 0, _aNewText.getLength() );
435 nWidth =
pOut->GetTextWidth( aNewText, nIdx, nLen );
447 sal_Int32 nSpaceCount = 0;
448 for(sal_Int32
i = 1;
i < nLen; ++
i)
450 if (aDXArray[
i] != nOldValue)
452 nOldValue = aDXArray[
i];
465 return Size(
pOut->GetTextWidth(
"" ),
pOut->GetTextHeight() );
478 const sal_Int32 nIdx,
const sal_Int32 nLen,
KernArray* pDXArray )
const
482 pOut->GetTextHeight() );
489 pDXArray = &aDXArray;
499 pDXArray, nIdx, nLen ) );
506 pDXArray->
adjust(0, nSpaceSum);
508 for ( sal_Int32
i = 1;
i < nLen;
i++ )
510 if ( (*pDXArray)[
i] != nOldValue )
512 nOldValue = (*pDXArray)[
i];
515 pDXArray->
adjust(
i, nSpaceSum);
519 nOldValue = (*pDXArray)[nLen - 1];
521 for ( sal_Int32
i = nLen - 1;
i >= 0 && (*pDXArray)[
i] == nOldValue; --
i)
522 pDXArray->
set(
i, nNewValue);
531 const sal_Int32 nIdx,
const sal_Int32 nLen)
const
533 sal_Int32 nTmp = nLen;
535 nTmp = rTxt.getLength();
550 sal_Int32 nIndex, sal_Int32 nLen )
553 pOut->DrawTextArray(rStartPt, rStr, pDXAry, pKashidaAry,
nIndex, nLen, SalLayoutFlags::NONE, layoutGlyphs);
557 const Point &rPos,
const OUString &rTxt,
558 const sal_Int32 nIdx,
const sal_Int32 nLen,
596 pOut->DrawStretchText( aPos, aSize.
Width(), rTxt, nIdx, nLen );
612 const Point &rPos,
const OUString &rTxt,
613 const sal_Int32 nIdx,
const sal_Int32 nLen )
const
615 if ( !nLen || rTxt.isEmpty() )
617 sal_Int32 nTmp = nLen;
620 nTmp = rTxt.getLength();
628 nTmpEsc = .8 * (100 -
nPropr);
629 assert (nTmpEsc ==
DFLT_ESC_SUPER &&
"I'm sure this formula needs to be changed, but how to confirm that???");
634 nTmpEsc = .2 * -(100 -
nPropr);
635 assert (nTmpEsc == -20 &&
"I'm sure this formula needs to be changed, but how to confirm that???");
653 pOut->DrawStretchText( aPos, aSize.
Width(), rTxt, nIdx, nTmp );
657 bool bCaseMapLengthDiffers(aNewText.getLength() != rTxt.getLength());
659 if(bCaseMapLengthDiffers)
663 const OUString aSnippet(rTxt.copy( nIdx, nTmp));
666 pOut->DrawStretchText( aPos, aSize.
Width(), _aNewText, 0, _aNewText.getLength() );
674 pOut->SetFont(aOldFont);
675 pPrinter->
SetFont( aOldPrnFont );
681 Font::operator=( rFont );
687 Font::operator=( rFont );
704 const OUString &_rTxt,
const sal_Int32 _nIdx,
705 const sal_Int32 _nLen,
const short _nKrn )
711 virtual void Do(
const OUString &rTxt,
const sal_Int32 nIdx,
712 const sal_Int32 nLen,
const bool bUpper )
override;
714 const Size &GetSize()
const {
return aTxtSize; };
719void SvxDoGetCapitalSize::Do(
const OUString &_rTxt,
const sal_Int32 _nIdx,
720 const sal_Int32 _nLen,
const bool bUpper )
727 pFont->SetPhysFont( *pOut );
728 aPartSize.
setWidth(
pOut->GetTextWidth( _rTxt, _nIdx, _nLen ) );
730 aTxtSize.setHeight( aPartSize.
Height() );
731 pFont->SetPropr( nProp );
732 pFont->SetPhysFont( *pOut );
736 aPartSize.
setWidth(
pOut->GetTextWidth( _rTxt, _nIdx, _nLen ) );
739 aTxtSize.AdjustWidth(aPartSize.
Width() );
740 aTxtSize.AdjustWidth( _nLen *
tools::Long( nKern ) );
744 const sal_Int32 nIdx,
const sal_Int32 nLen)
const
749 Size aTxtSize( aDo.GetSize() );
771 const sal_Int32 _nIdx,
const sal_Int32 _nLen,
772 const Point &rPos,
const short nKrn )
779 virtual void DoSpace(
const bool bDraw )
override;
781 virtual void Do(
const OUString &rTxt,
const sal_Int32 nIdx,
782 const sal_Int32 nLen,
const bool bUpper )
override;
787void SvxDoDrawCapital::DoSpace(
const bool bDraw )
789 if ( !(bDraw || pFont->IsWordLineMode()) )
792 sal_Int32 nDiff =
static_cast<sal_Int32
>(aPos.X() - aSpacePos.X());
795 bool bWordWise = pFont->IsWordLineMode();
796 bool bTrans = pFont->IsTransparent();
797 pFont->SetWordLineMode(
false );
798 pFont->SetTransparent(
true );
799 pFont->SetPhysFont(*pOut);
800 pOut->DrawStretchText( aSpacePos, nDiff,
" ", 0, 2 );
801 pFont->SetWordLineMode( bWordWise );
802 pFont->SetTransparent( bTrans );
803 pFont->SetPhysFont(*pOut);
807void SvxDoDrawCapital::SetSpace()
809 if ( pFont->IsWordLineMode() )
810 aSpacePos.setX( aPos.X() );
813void SvxDoDrawCapital::Do(
const OUString &_rTxt,
const sal_Int32 _nIdx,
814 const sal_Int32 _nLen,
const bool bUpper)
822 pFont->SetUnderline( LINESTYLE_NONE );
823 pFont->SetStrikeout( STRIKEOUT_NONE );
826 nProp = pFont->GetPropr();
829 pFont->SetPhysFont(*pOut);
831 aPartSize.
setWidth(
pOut->GetTextWidth( _rTxt, _nIdx, _nLen ) );
836 aPos.AdjustX(nKern/2);
839 pOut->DrawStretchText(aPos,nWidth-nKern,_rTxt,_nIdx,_nLen);
842 pFont->SetUnderline( eUnder );
843 pFont->SetStrikeout( eStrike );
845 pFont->SetPropr( nProp );
846 pFont->SetPhysFont(*pOut);
848 aPos.AdjustX(nWidth-(nKern/2) );
856 const Point &rPos,
const OUString &rTxt,
857 const sal_Int32 nIdx,
const sal_Int32 nLen )
const
OUString uppercase(const OUString &rStr, sal_Int32 nPos, sal_Int32 nCount) const
sal_Int32 getCharacterType(const OUString &rStr, sal_Int32 nPos) const
OUString lowercase(const OUString &rStr, sal_Int32 nPos, sal_Int32 nCount) const
tools::Long GetDescent() const
tools::Long GetAscent() const
void reserve(size_t nCapacity)
void set(size_t nIndex, sal_Int32 nValue)
void adjust(size_t nIndex, sal_Int32 nDiff)
const vcl::Font & GetFont() const
void SetFont(const vcl::Font &rNewFont)
void DrawLine(const Point &rStartPt, const Point &rEndPt)
void DrawPolygon(const tools::Polygon &rPoly)
FontMetric GetFontMetric() const
const Color & GetLineColor() const
const Color & GetFillColor() const
void setX(tools::Long nX)
void setY(tools::Long nY)
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
static SalLayoutGlyphsCache * self()
const SalLayoutGlyphs * GetLayoutGlyphs(VclPtr< const OutputDevice > outputDevice, const OUString &text, const vcl::text::TextLayoutCache *layoutCache=nullptr)
constexpr tools::Long Height() const
void setWidth(tools::Long nWidth)
tools::Long AdjustWidth(tools::Long n)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
SvxDoCapitals(OutputDevice *_pOut, const OUString &_rTxt, const sal_Int32 _nIdx, const sal_Int32 _nLen)
VclPtr< OutputDevice > pOut
virtual void DoSpace(const bool bDraw)
const OUString & GetTxt() const
virtual void Do(const OUString &rTxt, const sal_Int32 nIdx, const sal_Int32 nLen, const bool bUpper)=0
void DrawCapital(OutputDevice *pOut, const Point &rPos, const OUString &rTxt, const sal_Int32 nIdx, const sal_Int32 nLen) const
Size GetTextSize(const OutputDevice &rOut, const OUString &rTxt, const sal_Int32 nIdx=0, const sal_Int32 nLen=SAL_MAX_INT32) const
void QuickDrawText(OutputDevice *pOut, const Point &rPos, const OUString &rTxt, const sal_Int32 nIdx=0, const sal_Int32 nLen=SAL_MAX_INT32, o3tl::span< const sal_Int32 > pDXArray={}, o3tl::span< const sal_Bool > pKashidaArray={}) const
void SetPhysFont(OutputDevice &rOut) const
SvxFont & operator=(const SvxFont &rFont)
sal_uInt8 GetPropr() const
SvxCaseMap GetCaseMap() const
Size GetPhysTxtSize(const OutputDevice *pOut, const OUString &rTxt, const sal_Int32 nIdx, const sal_Int32 nLen) const
static tools::Polygon DrawArrow(OutputDevice &rOut, const tools::Rectangle &rRect, const Size &rSize, const Color &rCol, bool bLeftOrTop, bool bVertical)
Size QuickGetTextSize(const OutputDevice *pOut, const OUString &rTxt, const sal_Int32 nIdx, const sal_Int32 nLen, KernArray *pDXArray=nullptr) const
void DrawPrev(OutputDevice *pOut, Printer *pPrinter, const Point &rPos, const OUString &rTxt, const sal_Int32 nIdx=0, const sal_Int32 nLen=SAL_MAX_INT32) const
void DoOnCapitals(SvxDoCapitals &rDo) const
short GetEscapement() const
vcl::Font ChgPhysFont(OutputDevice &rOut) const
void SetNonAutoEscapement(short nNewEsc, const OutputDevice *pOutDev=nullptr)
Size GetCapitalSize(const OutputDevice *pOut, const OUString &rTxt, const sal_Int32 nIdx, const sal_Int32 nLen) const
OUString CalcCaseMap(const OUString &rTxt) const
constexpr bool empty() const noexcept
bool IsSameInstance(const Font &) const
const Size & GetFontSize() const
LanguageType GetLanguage() const
void SetLanguage(LanguageType)
bool IsFixKerning() const
short GetFixKerning() const
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
#define DBG_ASSERT(sCon, aError)
#define DFLT_ESC_AUTO_SUB
#define DFLT_ESC_AUTO_SUPER
#define LANGUAGE_DONTKNOW
#define SAL_WARN(area, stream)
SwNodeOffset abs(const SwNodeOffset &a)
static tools::Long GetTextArray(const OutputDevice *pOut, const OUString &rStr, KernArray *pDXAry, sal_Int32 nIndex, sal_Int32 nLen)
static void DrawTextArray(OutputDevice *pOut, const Point &rStartPt, const OUString &rStr, o3tl::span< const sal_Int32 > pDXAry, o3tl::span< const sal_Bool > pKashidaAry, sal_Int32 nIndex, sal_Int32 nLen)
#define SMALL_CAPS_PERCENTAGE