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,
bool bCaret )
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 tools::Long GetTextArray(
const OUString& _rText,
KernArray* _pDXAry, sal_Int32 _nStartIndex, sal_Int32 _nLength,
bool bCaret =
false )
const override;
81 virtual sal_Int32
GetTextBreak(
const OUString& _rText,
tools::Long _nMaxTextWidth, sal_Int32 _nStartIndex, sal_Int32 _nLength)
const override;
100 :m_rTargetDevice( _rTargetDevice )
101 ,m_rReferenceDevice( _rReferenceDevice )
102 ,m_bRTLEnabled( _rControl.IsRTLEnabled() )
109 OSL_ENSURE( aTargetMapMode.
GetOrigin() ==
Point(),
"ReferenceDeviceTextLayout::ReferenceDeviceTextLayout: uhm, the code below won't work here ..." );
120 OSL_ENSURE( aTargetMapMode.
GetMapUnit() == MapUnit::MapPixel,
121 "ReferenceDeviceTextLayout::ReferenceDeviceTextLayout: this class is not expected to work with such target devices!" );
125 OSL_ENSURE( aTargetMapMode.
GetMapUnit() != MapUnit::MapPixel,
126 "ReferenceDeviceTextLayout::ReferenceDeviceTextLayout: a reference device which has map mode PIXEL?!" );
131 Font aDrawFont( aUnzoomedPointFont );
133 _rTargetDevice.
SetFont( aDrawFont );
137 Font aRefFont( aUnzoomedPointFont );
151 bool lcl_normalizeLength( std::u16string_view _rText,
const sal_Int32 _nStartIndex, sal_Int32& _io_nLength )
153 sal_Int32 nTextLength = _rText.size();
154 if ( _nStartIndex > nTextLength )
156 if ( _nStartIndex + _io_nLength > nTextLength )
157 _io_nLength = nTextLength - _nStartIndex;
164 if ( !lcl_normalizeLength( _rText, _nStartIndex, _nLength ) )
169#if OSL_DEBUG_LEVEL > 1
172 OStringBuffer aTrace;
173 aTrace.append(
"ReferenceDeviceTextLayout::GetTextArray( " );
175 aTrace.append(
" ): " );
176 aTrace.append( nTextWidth );
177 aTrace.append(
" = ( " );
178 for ( sal_Int32
i=0;
i<_nLength; )
180 aTrace.append( _pDXAry->at(
i) );
181 if ( ++
i < _nLength )
182 aTrace.append(
", " );
184 aTrace.append(
")" );
185 SAL_INFO(
"vcl", aTrace.makeStringAndClear() );
193 return GetTextArray( _rText,
nullptr, _nStartIndex, _nLength );
198 if ( !lcl_normalizeLength( _rText, _nStartIndex, _nLength ) )
201 if ( _pVector && _pDisplayText )
203 std::vector< tools::Rectangle > aGlyphBounds;
205 _pVector->insert( _pVector->end(), aGlyphBounds.begin(), aGlyphBounds.end() );
206 *_pDisplayText += _rText.subView( _nStartIndex, _nLength );
219 if ( !lcl_normalizeLength( _rText, _nStartIndex, _nLength ) )
231 std::vector< tools::Rectangle >* _pVector, OUString* _pDisplayText,
const Size* i_pDeviceSize )
233 if ( _rText.isEmpty() )
276 for (
auto& rCharRect : *_pVector )
287 if ( _rText.isEmpty() )
306 *o_pDeviceSize = aTextRect.
GetSize();
326 std::vector< tools::Rectangle >* _pVector, OUString* _pDisplayText,
const Size* i_pDeviceSize )
328 return m_pImpl->DrawText( _rRect, _rText, _nStyle, _pVector, _pDisplayText, i_pDeviceSize );
333 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 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 tools::Long GetTextArray(const OUString &_rText, KernArray *_pDXArray, sal_Int32 _nStartIndex, sal_Int32 _nLength, bool bCaret=false) const override
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
OutputDevice & m_rTargetDevice
void SetFontSize(const Size &)
const Size & GetFontSize() const
OutputDevice & m_rReferenceDevice
tools::Rectangle m_aCompleteTextRect
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 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 tools::Long GetTextArray(const OUString &_rText, KernArray *_pDXAry, sal_Int32 _nStartIndex, sal_Int32 _nLength, bool bCaret=false) const override
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)