22#include <rtl/ustring.hxx>
24#include <vcl/font.hxx>
27#include <com/sun/star/i18n/ScriptType.hpp>
28#include <com/sun/star/i18n/XBreakIterator.hpp>
60 const uno::Reference< i18n::XBreakIterator >& _xBreakIter );
71 const OUString& _rText,
72 const uno::Reference< i18n::XBreakIterator >& _xBreakIter );
84 mrOutDevice( _rOutDevice ),
85 maLatinFont( _rOutDevice.
GetFont() ),
86 maAsianFont( _rOutDevice.
GetFont() ),
87 maCmplxFont( _rOutDevice.
GetFont() ),
88 maDefltFont( _rOutDevice.
GetFont() )
114 "SvtScriptedTextHelper_Impl::CalculateWidth - invalid std::vectors" );
118 sal_Int32 nPosVecSize =
maPosVec.size();
119 sal_Int32 nPosVecIndex = 1;
122 sal_Int32 nScriptVecIndex = 0;
124 sal_Int32 nCurrWidth;
126 while( nPosVecIndex < nPosVecSize )
128 nNextPos =
maPosVec[ nPosVecIndex++ ];
155 DBG_ASSERT( _xBreakIter.is(),
"SvtScriptedTextHelper_Impl::CalculateBreaks - no break iterator" );
157 sal_Int32 nLen =
maText.getLength();
160 if( _xBreakIter.is() )
162 sal_Int32 nThisPos = 0;
163 sal_Int32 nNextPos = 0;
164 sal_Int16 nPortScript;
167 nPortScript = _xBreakIter->getScriptType(
maText, nThisPos );
168 nNextPos = _xBreakIter->endOfScript(
maText, nThisPos, nPortScript );
170 switch( nPortScript )
172 case i18n::ScriptType::LATIN:
173 case i18n::ScriptType::ASIAN:
174 case i18n::ScriptType::COMPLEX:
185 sal_Int32 nCharIx = 0;
186 sal_Int32 nNextCharIx = 0;
190 nScript = i18n::ScriptType::LATIN;
191 while( (nScript != i18n::ScriptType::WEAK) && (nCharIx == nNextCharIx) )
194 if( nCharIx == nNextCharIx )
197 if( nNextCharIx == nCharIx )
202 nCharIx = nNextCharIx;
204 while( nCharIx < nNextPos && nCharIx != -1 );
211 while( (0 <= nThisPos) && (nThisPos < nLen) );
251 Point aCurrPos( _rPos );
254 sal_Int32 nPosVecSize =
maPosVec.size();
255 sal_Int32 nPosVecIndex = 1;
258 sal_Int32 nVecIndex = 0;
260 while( nPosVecIndex < nPosVecSize )
262 nNextPos =
maPosVec[ nPosVecIndex++ ];
294 mpImpl->SetFonts( _pLatinFont, _pAsianFont, _pCmplxFont );
299 mpImpl->SetFonts(
nullptr,
nullptr,
nullptr );
304 mpImpl->SetText( _rText, _xBreakIter );
309 return mpImpl->GetTextSize();
314 mpImpl->DrawText( _rPos );
void SetFont(const vcl::Font &rNewFont)
tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::text::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
void SetTextColor(const Color &rColor)
sal_Int32 HasGlyphs(const vcl::Font &rFont, std::u16string_view rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1) const
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
tools::Long GetTextHeight() const
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, std::vector< tools::Rectangle > *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
const Color & GetFillColor() const
tools::Long AdjustX(tools::Long nHorzMove)
constexpr tools::Long Height() const
void setWidth(tools::Long nWidth)
tools::Long AdjustWidth(tools::Long n)
void setHeight(tools::Long nHeight)
vcl::Font maLatinFont
The output device for drawing the text.
void CalculateBreaks(const uno::Reference< i18n::XBreakIterator > &_xBreakIter)
Fills maPosVec with positions of all changes of script type and maScriptVec with the script type of e...
vcl::Font maAsianFont
The font for latin text portions.
Size maTextSize
The output width of each text portion.
std::vector< sal_Int16 > maScriptVec
The start position of each text portion.
vcl::Font maCmplxFont
The font for asian text portions.
std::vector< sal_Int32 > maWidthVec
The script type of each text portion.
const Size & GetTextSize() const
Returns a size struct containing the width and height of the text in the current output device.
OUString maText
The default font of the output device.
OutputDevice & mrOutDevice
SvtScriptedTextHelper_Impl(OutputDevice &_rOutDevice)
This constructor sets an output device and fonts for all script types.
void SetText(const OUString &_rText, const uno::Reference< i18n::XBreakIterator > &_xBreakIter)
Sets a new text and calculates all script breaks and the text width.
const vcl::Font & GetFont(sal_uInt16 _nScript) const
The size the text will take in the current output device.
std::vector< sal_Int32 > maPosVec
The text.
void DrawText(const Point &_rPos)
Draws the text in the current output device.
void SetOutDevFont(sal_uInt16 _nScript)
Sets a font on the output device depending on the script type.
void CalculateSizes()
Fills maPosVec with positions of all changes of script type.
vcl::Font maDefltFont
The font for complex text portions.
void SetFonts(vcl::Font const *_pLatinFont, vcl::Font const *_pAsianFont, vcl::Font const *_pCmplxFont)
Sets new fonts and recalculates the text width.
This class provides drawing text with different script types on any output devices.
void SetDefaultFont()
Sets the default font of the current output device to all script types.
const Size & GetTextSize() const
Returns a size struct containing the width and height of the text in the current output device.
void SetText(const OUString &_rText, const css::uno::Reference< css::i18n::XBreakIterator > &_xBreakIter)
Sets a new text and calculates all script breaks and the text width.
void DrawText(const Point &_rPos)
Draws the text in the current output device.
std::unique_ptr< SvtScriptedTextHelper_Impl > mpImpl
~SvtScriptedTextHelper()
Destructor.
SvtScriptedTextHelper(OutputDevice &_rOutDevice)
Constructor sets an output device and no fonts.
void SetFonts(vcl::Font const *_pLatinFont, vcl::Font const *_pAsianFont, vcl::Font const *_pCmplxFont)
Sets new fonts and recalculates the text width.
const Color & GetColor() const
constexpr ::Color COL_WHITE(0xFF, 0xFF, 0xFF)
constexpr ::Color COL_AUTO(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
#define DBG_ASSERT(sCon, aError)
vcl::Font GetFont(vcl::Font const &rFont, DrawModeFlags nDrawMode, StyleSettings const &rStyleSettings)