24#include <textlayout.hxx>
26#include <osl/diagnose.h>
30#if OSL_DEBUG_LEVEL > 1
31#include <rtl/strbuf.hxx>
50 sal_Int32 _nLength, std::vector< tools::Rectangle >* _pVector, OUString* _pDisplayText )
56 sal_Int32 _nStartIndex, sal_Int32 _nLength )
const
79 virtual void DrawText(
const Point& _rStartPoint,
const OUString& _rText, sal_Int32 _nStartIndex, sal_Int32 _nLength, std::vector< tools::Rectangle >* _pVector, OUString* _pDisplayText )
override;
80 virtual void GetCaretPositions(
const OUString& _rText, sal_Int32* _pCaretXArray, sal_Int32 _nStartIndex, sal_Int32 _nLength )
const override;
81 virtual sal_Int32
GetTextBreak(
const OUString& _rText,
tools::Long _nMaxTextWidth, sal_Int32 _nStartIndex, sal_Int32 _nLength)
const override;
101 :m_rTargetDevice( _rTargetDevice )
102 ,m_rReferenceDevice( _rReferenceDevice )
103 ,m_bRTLEnabled( _rControl.IsRTLEnabled() )
110 OSL_ENSURE( aTargetMapMode.
GetOrigin() ==
Point(),
"ReferenceDeviceTextLayout::ReferenceDeviceTextLayout: uhm, the code below won't work here ..." );
121 OSL_ENSURE( aTargetMapMode.
GetMapUnit() == MapUnit::MapPixel,
122 "ReferenceDeviceTextLayout::ReferenceDeviceTextLayout: this class is not expected to work with such target devices!" );
126 OSL_ENSURE( aTargetMapMode.
GetMapUnit() != MapUnit::MapPixel,
127 "ReferenceDeviceTextLayout::ReferenceDeviceTextLayout: a reference device which has map mode PIXEL?!" );
132 Font aDrawFont( aUnzoomedPointFont );
134 _rTargetDevice.
SetFont( aDrawFont );
138 Font aRefFont( aUnzoomedPointFont );
152 bool lcl_normalizeLength( std::u16string_view _rText,
const sal_Int32 _nStartIndex, sal_Int32& _io_nLength )
154 sal_Int32 nTextLength = _rText.size();
155 if ( _nStartIndex > nTextLength )
157 if ( _nStartIndex + _io_nLength > nTextLength )
158 _io_nLength = nTextLength - _nStartIndex;
165 if ( !lcl_normalizeLength( _rText, _nStartIndex, _nLength ) )
170#if OSL_DEBUG_LEVEL > 1
173 OStringBuffer aTrace;
174 aTrace.append(
"ReferenceDeviceTextLayout::GetTextArray( " );
176 aTrace.append(
" ): " );
177 aTrace.append( nTextWidth );
178 aTrace.append(
" = ( " );
179 for ( sal_Int32
i=0;
i<_nLength; )
181 aTrace.append( _pDXAry->at(
i) );
182 if ( ++
i < _nLength )
183 aTrace.append(
", " );
185 aTrace.append(
")" );
186 SAL_INFO(
"vcl", aTrace.makeStringAndClear() );
194 return GetTextArray( _rText,
nullptr, _nStartIndex, _nLength );
197 void ReferenceDeviceTextLayout::DrawText(
const Point& _rStartPoint,
const OUString& _rText, sal_Int32 _nStartIndex, sal_Int32 _nLength, std::vector< tools::Rectangle >* _pVector, OUString* _pDisplayText )
199 if ( !lcl_normalizeLength( _rText, _nStartIndex, _nLength ) )
202 if ( _pVector && _pDisplayText )
204 std::vector< tools::Rectangle > aGlyphBounds;
206 _pVector->insert( _pVector->end(), aGlyphBounds.begin(), aGlyphBounds.end() );
207 *_pDisplayText += _rText.subView( _nStartIndex, _nLength );
219 sal_Int32 _nStartIndex, sal_Int32 _nLength )
const
221 if ( !lcl_normalizeLength( _rText, _nStartIndex, _nLength ) )
230 if ( !lcl_normalizeLength( _rText, _nStartIndex, _nLength ) )
242 std::vector< tools::Rectangle >* _pVector, OUString* _pDisplayText,
const Size* i_pDeviceSize )
244 if ( _rText.isEmpty() )
287 for (
auto& rCharRect : *_pVector )
298 if ( _rText.isEmpty() )
317 *o_pDeviceSize = aTextRect.
GetSize();
337 std::vector< tools::Rectangle >* _pVector, OUString* _pDisplayText,
const Size* i_pDeviceSize )
339 return m_pImpl->DrawText( _rRect, _rText, _nStyle, _pVector, _pDisplayText, i_pDeviceSize );
344 return m_pImpl->GetTextRect( _rRect, _rText, _nStyle, o_pDeviceSize );
vcl::Font GetUnzoomedControlPointFont() const
void SetScaleY(const Fraction &rScaleY)
MapUnit GetMapUnit() const
void SetMapUnit(MapUnit eUnit)
const Point & GetOrigin() const
void SetScaleX(const Fraction &rScaleX)
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
bool GetGlyphBoundRects(const Point &rOrigin, const OUString &rStr, int nIndex, int nLen, std::vector< tools::Rectangle > &rVector) const
sal_Int32 GetTextBreak(const OUString &rStr, tools::Long nTextWidth, sal_Int32 nIndex, sal_Int32 nLen=-1, tools::Long nCharExtra=0, vcl::text::TextLayoutCache const *=nullptr, const SalLayoutGlyphs *pGlyphs=nullptr) const
void DrawTextArray(const Point &rStartPt, const OUString &rStr, KernArraySpan aKernArray, o3tl::span< const sal_Bool > pKashidaAry, sal_Int32 nIndex, sal_Int32 nLen, SalLayoutFlags flags=SalLayoutFlags::NONE, const SalLayoutGlyphs *pLayoutCache=nullptr)
void SetFont(const vcl::Font &rNewFont)
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
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
Width of the text.
tools::Long GetTextArray(const OUString &rStr, KernArray *pDXAry, sal_Int32 nIndex=0, sal_Int32 nLen=-1, bool bCaret=false, vcl::text::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
tools::Rectangle GetTextRect(const tools::Rectangle &rRect, const OUString &rStr, DrawTextFlags nStyle=DrawTextFlags::WordBreak, TextRectInfo *pInfo=nullptr, const vcl::ITextLayout *_pTextLayout=nullptr) const
const MapMode & GetMapMode() const
void GetCaretPositions(const OUString &, sal_Int32 *pCaretXArray, sal_Int32 nIndex, sal_Int32 nLen, const SalLayoutGlyphs *pGlyphs=nullptr) const
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
tools::Long GetTextHeight() const
Height where any character of the current font fits; in logic coordinates.
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)
void SetLayoutMode(vcl::text::ComplexTextLayoutFlags nTextLayoutMode)
constexpr tools::Long Height() const
constexpr tools::Long Width() const
::std::unique_ptr< ReferenceDeviceTextLayout > m_pImpl
tools::Rectangle DrawText(const tools::Rectangle &_rRect, const OUString &_rText, DrawTextFlags _nStyle, std::vector< tools::Rectangle > *_pVector, OUString *_pDisplayText, const Size *i_pDeviceSize)
tools::Rectangle GetTextRect(const tools::Rectangle &_rRect, const OUString &_rText, DrawTextFlags _nStyle, Size *o_pDeviceSize)
ControlTextRenderer(const Control &_rControl, OutputDevice &_rTargetDevice, OutputDevice &_rReferenceDevice)
virtual void DrawText(const Point &_rStartPoint, const OUString &_rText, sal_Int32 _nStartIndex, sal_Int32 _nLength, std::vector< tools::Rectangle > *_pVector, OUString *_pDisplayText) override
virtual ~DefaultTextLayout()
virtual bool DecomposeTextRectAction() const override
virtual tools::Long GetTextWidth(const OUString &_rText, sal_Int32 _nStartIndex, sal_Int32 _nLength) const override
virtual sal_Int32 GetTextBreak(const OUString &_rText, tools::Long _nMaxTextWidth, sal_Int32 _nStartIndex, sal_Int32 _nLength) const override
virtual void GetCaretPositions(const OUString &_rText, sal_Int32 *_pCaretXArray, sal_Int32 _nStartIndex, sal_Int32 _nLength) const override
OutputDevice & m_rTargetDevice
void SetFontSize(const Size &)
const Size & GetFontSize() const
OutputDevice & m_rReferenceDevice
tools::Rectangle m_aCompleteTextRect
tools::Long GetTextArray(const OUString &_rText, KernArray *_pDXAry, sal_Int32 _nStartIndex, sal_Int32 _nLength) const
virtual void DrawText(const Point &_rStartPoint, const OUString &_rText, sal_Int32 _nStartIndex, sal_Int32 _nLength, std::vector< tools::Rectangle > *_pVector, OUString *_pDisplayText) override
tools::Rectangle GetTextRect(const tools::Rectangle &_rRect, const OUString &_rText, DrawTextFlags _nStyle, Size *o_pDeviceSize)
virtual void GetCaretPositions(const OUString &_rText, sal_Int32 *_pCaretXArray, sal_Int32 _nStartIndex, sal_Int32 _nLength) const override
virtual bool DecomposeTextRectAction() const override
virtual sal_Int32 GetTextBreak(const OUString &_rText, tools::Long _nMaxTextWidth, sal_Int32 _nStartIndex, sal_Int32 _nLength) const override
ReferenceDeviceTextLayout(const Control &_rControl, OutputDevice &_rTargetDevice, OutputDevice &_rReferenceDevice)
virtual ~ReferenceDeviceTextLayout()
OutputDevice & m_rTargetDevice
virtual tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex, sal_Int32 nLen) const override
const Fraction & GetZoom() const
#define SAL_WARN_IF(condition, area, stream)
#define SAL_INFO(area, stream)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)