23#include <com/sun/star/i18n/CharType.hpp>
24#include <com/sun/star/i18n/WordType.hpp>
25#include <com/sun/star/i18n/XBreakIterator.hpp>
45 explicit SwCapitalInfo(
const OUString& rOrigText ) :
46 rString( rOrigText ), nIdx( 0 ), nLen( 0 ) {};
47 const OUString& rString;
61 const OUString& rOrigString,
68 OSL_ENSURE( sal_Int32(nEnd) <= rOrigString.getLength(),
"sw_CalcCaseMap: Wrong parameters" );
71 const bool bTitle = SvxCaseMap::Capitalize == rFnt.
GetCaseMap();
74 OUString aTmp(rOrigString.copy(sal_Int32(
i), 1));
78 rOrigString, sal_Int32(
i),
80 WordType::ANYWORD_IGNOREWHITESPACES ) )
83 j += aTmp.getLength();
102 virtual void Do() = 0;
118 virtual ~SwDoGetCapitalSize() {}
120 virtual void Do()
override;
121 const Size& GetSize()
const {
return m_aTextSize; }
129 m_aTextSize.setWidth(0);
132void SwDoGetCapitalSize::Do()
134 m_aTextSize.AdjustWidth(m_rInf.GetSize().Width());
135 if( m_rInf.GetUpper() )
136 m_aTextSize.setHeight(m_rInf.GetSize().Height());
147 SwDoGetCapitalSize aDo( rInf );
149 Size aTextSize( aDo.GetSize() );
172 , m_nTextWidth(nWidth)
175 virtual ~SwDoGetCapitalBreak() {}
177 virtual void Do()
override;
187void SwDoGetCapitalBreak::Do()
192 if (m_rInf.GetSize().Width() < m_nTextWidth)
193 m_nTextWidth -= m_rInf.GetSize().Width();
197 m_nBreak =
TextFrameIndex(GetOut().GetTextBreak(m_rInf.GetText(), m_nTextWidth,
198 sal_Int32(m_rInf.GetIdx()),
199 sal_Int32(m_rInf.GetLen()), m_rInf.GetKern()));
208 if ( GetCapInf()->nLen != m_rInf.GetLen() )
210 GetCapInf()->rString,
212 GetCapInf()->nLen, m_nBreak );
214 m_nBreak = m_nBreak + GetCapInf()->nIdx;
239 SwDoGetCapitalBreak aDo(aInfo, nTextWidth);
241 return aDo.getBreak();
255 , m_pUpperFnt(nullptr)
256 , m_pLowerFnt(nullptr)
258 virtual ~SwDoDrawCapital() {}
260 virtual void Do()
override;
261 void DrawSpace(
Point &rPos );
268 m_pUpperFnt = pUpperFont;
269 m_pLowerFnt = pLowerFont;
272void SwDoDrawCapital::Do()
275 const sal_uInt16 nOrgWidth = m_rInf.GetWidth();
276 m_rInf.SetWidth( sal_uInt16(m_rInf.GetSize().Width()) );
277 if ( m_rInf.GetUpper() )
278 m_pUpperFnt->DrawText(m_rInf);
281 bool bOldBullet = m_rInf.GetBullet();
282 m_rInf.SetBullet(
false );
283 m_pLowerFnt->DrawText(m_rInf);
284 m_rInf.SetBullet( bOldBullet );
287 OSL_ENSURE(m_pUpperFnt,
"No upper font, dying soon!");
288 m_rInf.Shift(m_pUpperFnt->GetFont().GetOrientation());
289 m_rInf.SetWidth( nOrgWidth );
292void SwDoDrawCapital::DrawSpace(
Point &rPos )
297 const bool bSwitchL2R = m_rInf.GetFrame()->IsRightToLeft() &&
298 ! m_rInf.IsIgnoreFrameRTL();
301 m_rInf.GetFrame()->SwitchLTRtoRTL( aPos );
304 const bool bBidiPor = ( bSwitchL2R !=
310 if ( m_rInf.GetFrame()->IsVertical() )
311 m_rInf.GetFrame()->SwitchHorizontalToVertical( aPos );
315 m_rInf.ApplyAutoColor();
316 GetOut().DrawStretchText( aPos, nDiff,
319 rPos.
setX( m_rInf.GetPos().X() + m_rInf.GetWidth() );
329 SwDoDrawCapital aDo( rInf );
344 SwDoCapitalCursorOfst(
SwDrawTextInfo& rInfo,
const sal_uInt16 nOfs)
346 , m_pUpperFnt(nullptr)
347 , m_pLowerFnt(nullptr)
351 virtual ~SwDoCapitalCursorOfst() {}
353 virtual void Do()
override;
360void SwDoCapitalCursorOfst::Init(
SwFntObj *pUpperFont,
SwFntObj *pLowerFont )
362 m_pUpperFnt = pUpperFont;
363 m_pLowerFnt = pLowerFont;
366void SwDoCapitalCursorOfst::Do()
371 if (
static_cast<tools::Long>(m_nOfst) > m_rInf.GetSize().Width())
373 m_nOfst -= m_rInf.GetSize().Width();
374 m_nCursor = m_nCursor + m_rInf.GetLen();
379 m_rInf.GetScriptInfo(),
382 m_rInf.GetLen(), 0,
false );
383 aDrawInf.SetOffset(m_nOfst);
384 aDrawInf.SetKern( m_rInf.GetKern() );
385 aDrawInf.SetKanaComp( m_rInf.GetKanaComp() );
386 aDrawInf.SetFrame( m_rInf.GetFrame() );
387 aDrawInf.SetFont( m_rInf.GetFont() );
389 if ( m_rInf.GetUpper() )
391 aDrawInf.SetSpace( 0 );
392 m_nCursor = m_nCursor + m_pUpperFnt->GetModelPositionForViewPoint(aDrawInf);
396 aDrawInf.SetSpace( m_rInf.GetSpace() );
397 m_nCursor = m_nCursor + m_pLowerFnt->GetModelPositionForViewPoint(aDrawInf);
407 SwDoCapitalCursorOfst aDo( rInf, rInf.
GetOffset() );
412 return aDo.GetCursor();
417class SwDoDrawStretchCapital :
public SwDoDrawCapital
420 const sal_uInt16 m_nCapWidth;
421 const sal_uInt16 m_nOrgWidth;
424 virtual void Do()
override;
426 SwDoDrawStretchCapital(
SwDrawTextInfo& rInfo,
const sal_uInt16 nCapitalWidth)
427 : SwDoDrawCapital(rInfo)
428 , m_nStrLen(rInfo.
GetLen())
429 , m_nCapWidth(nCapitalWidth)
430 , m_nOrgWidth(rInfo.GetWidth())
436void SwDoDrawStretchCapital::Do()
441 if( m_rInf.GetLen() )
447 nDiff *= sal_Int32(m_rInf.GetLen());
448 nDiff /= sal_Int32(m_nStrLen);
454 m_rInf.ApplyAutoColor();
456 Point aPos( m_rInf.GetPos() );
457 const bool bSwitchL2R = m_rInf.GetFrame()->IsRightToLeft() &&
458 ! m_rInf.IsIgnoreFrameRTL();
461 m_rInf.GetFrame()->SwitchLTRtoRTL( aPos );
463 if ( m_rInf.GetFrame()->IsVertical() )
464 m_rInf.GetFrame()->SwitchHorizontalToVertical( aPos );
468 GetOut().DrawText(aPos, m_rInf.GetText(), sal_Int32(m_rInf.GetIdx()),
469 sal_Int32(m_rInf.GetLen()));
471 GetOut().DrawStretchText(aPos, nPartWidth, m_rInf.GetText(),
472 sal_Int32(m_rInf.GetIdx()), sal_Int32(m_rInf.GetLen()));
474 const_cast<Point&
>(m_rInf.GetPos()).AdjustX(nPartWidth );
485 const sal_uInt16 nCapWidth = o3tl::narrowing<sal_uInt16>(
GetCapitalSize( rInf ).
Width() );
491 SwDoDrawStretchCapital aDo( rInf, nCapWidth );
497 OSL_ENSURE(
pLastFont,
"SwFont::DoOnCapitals: No LastFont?!" );
510 nMaxPos = nMaxPos +
nPos;
514 SwCapitalInfo aCapInf(oldText);
515 bool bCaseMapLengthDiffers(aText.getLength() != oldText.getLength());
516 if ( bCaseMapLengthDiffers )
520 std::optional<SwFntAccess> oBigFontAccess;
522 std::optional<SwFntAccess> oSpaceFontAccess;
525 const void* nFontCacheId2 =
nullptr;
526 sal_uInt16 nIndex2 = 0;
533 const bool bWordWise = bTextLines && aFont.IsWordLineMode() &&
542 oSpaceFontAccess.emplace( nFontCacheId2, nIndex2, &aFont,
544 pSpaceFont = oSpaceFontAccess->Get();
553 nFontCacheId2 =
nullptr;
555 oBigFontAccess.emplace( nFontCacheId2, nIndex2, &aFont,
557 pBigFont = oBigFontAccess->Get();
569 nFontCacheId2 =
nullptr;
571 std::optional<SwFntAccess> oSmallFontAccess( std::in_place, nFontCacheId2, nIndex2, &aFont,
573 SwFntObj *pSmallFont = oSmallFontAccess->Get();
575 rDo.
Init( pBigFont, pSmallFont );
587 oldText, sal_Int32(
nPos),
591 else if(
nPos > nMaxPos )
595 while( nOldPos < nMaxPos )
599 if( nOldPos !=
nPos )
606 if( bCaseMapLengthDiffers )
612 oldText.copy(sal_Int32(nOldPos), sal_Int32(
nPos-nOldPos)));
613 aCapInf.nIdx = nOldPos;
614 aCapInf.nLen =
nPos - nOldPos;
627 if( nTmpKern &&
nPos < nMaxPos )
634 oldText, sal_Int32(
nPos),
638 OSL_ENSURE(
nPos,
"nextCharBlock not implemented?" );
639#if OSL_DEBUG_LEVEL > 1
644 if( nOldPos !=
nPos )
657 while (nTmp <
nPos &&
CH_BLANK == oldText[sal_Int32(nTmp)])
664 static_cast<SwDoDrawCapital&
>(rDo).DrawSpace( aStartPos );
670 if( bCaseMapLengthDiffers )
676 oldText.copy(sal_Int32(nOldPos), sal_Int32(nTmp-nOldPos)));
677 aCapInf.nIdx = nOldPos;
678 aCapInf.nLen = nTmp - nOldPos;
694 aPartSize.
AdjustWidth(nSpaceAdd * sal_Int32(nTmp - nOldPos));
695 if( nTmpKern &&
nPos < nMaxPos )
703 while (nTmp <
nPos &&
CH_BLANK != oldText[sal_Int32(nTmp)])
711 if( bCaseMapLengthDiffers )
717 oldText.copy(sal_Int32(nOldPos), sal_Int32(nTmp-nOldPos)));
718 aCapInf.nIdx = nOldPos;
719 aCapInf.nLen = nTmp - nOldPos;
735 if (
CH_BLANK == oldText[sal_Int32(nI)])
739 if( nTmpKern &&
nPos < nMaxPos )
745 }
while( nOldPos !=
nPos );
748 oldText, sal_Int32(
nPos),
752 OSL_ENSURE(
nPos,
"endOfCharBlock not implemented?" );
753#if OSL_DEBUG_LEVEL > 1
760 if( pBigFont != pOldLast )
761 oBigFontAccess.reset();
769 static_cast<SwDoDrawCapital&
>( rDo ).DrawSpace( aStartPos );
772 oSpaceFontAccess.reset();
777 oSmallFontAccess.reset();
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...
tools::Long GetTextHeight() const
void setX(tools::Long nX)
constexpr tools::Long X() const
constexpr tools::Long Height() const
tools::Long AdjustWidth(tools::Long n)
void setHeight(tools::Long nHeight)
sal_uInt8 GetPropr() const
OUString CalcCaseMap(const OUString &rTxt) const
css::uno::Reference< css::i18n::XBreakIterator > const & GetBreakIter() const
const css::lang::Locale & GetLocale(const LanguageType aLang)
SwDoCapitals(SwDrawTextInfo &rInfo)
void SetCapInf(SwCapitalInfo &rNew)
virtual void Init(SwFntObj *pUpperFont, SwFntObj *pLowerFont)=0
SwCapitalInfo * m_pCapInf
SwDrawTextInfo & GetInf()
SwCapitalInfo * GetCapInf() const
void SetKern(tools::Long nNew)
void SetDrawSpace(bool bNew)
TextFrameIndex GetIdx() const
bool GetDrawSpace() const
void SetPos(const Point &rNew)
TextFrameIndex GetLen() const
void SetSize(const Size &rNew)
const OUString & GetText() const
void SetFont(SwFont *pNew)
void SetSmartTags(sw::WrongListIterator *const pNew)
SwViewShell const * GetShell() const
tools::Long GetKern() const
void SetKanaDiff(tools::Long nNew)
void SetKanaComp(short nNew)
void SetText(const OUString &rNew)
vcl::RenderContext & GetOut() const
tools::Long GetKanaDiff() const
void SetIdx(TextFrameIndex const nNew)
vcl::RenderContext * GetpOut() const
void SetTextIdxLen(const OUString &rNewStr, TextFrameIndex const nNewIdx, TextFrameIndex const nNewLen)
void SetLen(TextFrameIndex const nNew)
void SetIdxLen(TextFrameIndex const nNewIdx, TextFrameIndex const nNewLen)
void SetGrammarCheck(sw::WrongListIterator *const pNew)
const Point & GetPos() const
sal_Int32 GetOffset() const
void SetOut(OutputDevice &rNew)
void SetSpace(tools::Long nNew)
tools::Long GetSpace() const
void SetWrong(sw::WrongListIterator *const pNew)
OutputDevice * GetPrt() const
void SetDevFont(const SwViewShell *pSh, OutputDevice &rOut)
Size GetTextSize(SwDrawTextInfo &rInf)
determine the TextSize (of the printer)
To take Asian or other languages into consideration, an SwFont object consists of 3 SwSubFonts (Latin...
TextFrameIndex GetCapitalBreak(SwViewShell const *pSh, const OutputDevice *pOut, const SwScriptInfo *pScript, const OUString &rText, tools::Long nTextWidth, TextFrameIndex nIdx, TextFrameIndex nLen)
const SvxFont & GetActualFont() const
void DoOnCapitals(SwDoCapitals &rDo)
SvxCaseMap GetCaseMap() const
LanguageType GetLanguage() const
void SetProportion(const sal_uInt8 nNewPropr)
void DoOnCapitals(SwDoCapitals &rDo)
void DrawCapital(SwDrawTextInfo &rInf)
Size GetCapitalSize(SwDrawTextInfo &rInf)
bool m_bSmallCapsPercentage66
void SetOverline(const FontLineStyle eOverline)
TextFrameIndex GetCapitalCursorOfst(SwDrawTextInfo &rInf)
void SetUnderline(const FontLineStyle eUnderline)
void SetStrikeout(const FontStrikeout eStrikeout)
void DrawStretchCapital(SwDrawTextInfo &rInf)
void SetWordLineMode(const bool bWordLineMode)
TextFrameIndex sw_CalcCaseMap(const SwFont &rFnt, const OUString &rOrigString, TextFrameIndex const nOfst, TextFrameIndex const nLen, TextFrameIndex const nIdx)
#define LANGUAGE_DONTKNOW
LanguageType GetLanguage(SfxItemSet const &aSet, sal_uInt16 nLangWhichId)
SwNodeOffset min(const SwNodeOffset &a, const SwNodeOffset &b)
#define SPACING_PRECISION_FACTOR
tools::Long GetLen(const Point &rPnt)
#define SMALL_CAPS_PERCENTAGE
const sal_Unicode CH_BLANK
constexpr sal_Int32 COMPLETE_STRING