25#include <com/sun/star/rendering/TextDirection.hpp>
38using namespace ::
cairo;
50 switch( nTextDirection )
52 case rendering::TextDirection::WEAK_LEFT_TO_RIGHT:
54 case rendering::TextDirection::STRONG_LEFT_TO_RIGHT:
57 case rendering::TextDirection::WEAK_RIGHT_TO_LEFT:
60 case rendering::TextDirection::STRONG_RIGHT_TO_LEFT:
80 mpRefDevice(
std::move( rRefDevice )),
81 mnTextDirection( nDirection )
85 TextLayout::~TextLayout()
89 void TextLayout::disposing(std::unique_lock<std::mutex>& )
96 uno::Sequence< uno::Reference< rendering::XPolyPolygon2D > > SAL_CALL TextLayout::queryTextShapes( )
99 return uno::Sequence< uno::Reference< rendering::XPolyPolygon2D > >();
102 uno::Sequence< geometry::RealRectangle2D > SAL_CALL TextLayout::queryInkMeasures( )
105 return uno::Sequence< geometry::RealRectangle2D >();
108 uno::Sequence< geometry::RealRectangle2D > SAL_CALL TextLayout::queryMeasures( )
111 return uno::Sequence< geometry::RealRectangle2D >();
114 uno::Sequence< double > SAL_CALL TextLayout::queryLogicalAdvancements( )
116 std::unique_lock aGuard(
m_aMutex );
118 return maLogicalAdvancements;
121 void SAL_CALL TextLayout::applyLogicalAdvancements(
const uno::Sequence< double >& aAdvancements )
123 std::unique_lock aGuard( m_aMutex );
125 if( aAdvancements.getLength() !=
maText.Length )
127 SAL_WARN(
"canvas.cairo",
"TextLayout::applyLogicalAdvancements(): mismatching number of advancements" );
128 throw lang::IllegalArgumentException(
"mismatching number of advancements", getXWeak(), 1);
131 maLogicalAdvancements = aAdvancements;
134 uno::Sequence< sal_Bool > SAL_CALL TextLayout::queryKashidaPositions( )
136 std::unique_lock aGuard(
m_aMutex );
138 return maKashidaPositions;
141 void SAL_CALL TextLayout::applyKashidaPositions(
const uno::Sequence< sal_Bool >& aPositions )
143 std::unique_lock aGuard( m_aMutex );
145 if( aPositions.hasElements() && aPositions.getLength() !=
maText.Length )
147 SAL_WARN(
"canvas.cairo",
"TextLayout::applyKashidaPositions(): mismatching number of positions" );
148 throw lang::IllegalArgumentException(
"mismatching number of positions", getXWeak(), 1);
151 maKashidaPositions = aPositions;
154 geometry::RealRectangle2D SAL_CALL TextLayout::queryTextBounds( )
156 std::unique_lock aGuard(
m_aMutex );
160 return geometry::RealRectangle2D();
163 pVDev->SetFont(
mpFont->getVCLFont() );
167 const ::FontMetric& aMetric( pVDev->GetFontMetric() );
169 setupLayoutMode( *pVDev, mnTextDirection );
171 const sal_Int32 nAboveBaseline( -aMetric.GetAscent() );
172 const sal_Int32 nBelowBaseline( aMetric.GetDescent() );
174 if( maLogicalAdvancements.hasElements() )
176 return geometry::RealRectangle2D( 0, nAboveBaseline,
177 maLogicalAdvancements[ maLogicalAdvancements.getLength()-1 ],
182 return geometry::RealRectangle2D( 0, nAboveBaseline,
185 ::canvas::tools::numeric_cast<sal_uInt16>(
maText.StartPosition),
186 ::canvas::tools::numeric_cast<sal_uInt16>(
maText.Length) ),
191 double SAL_CALL TextLayout::justify(
double )
197 double SAL_CALL TextLayout::combinedJustify(
const uno::Sequence< uno::Reference< rendering::XTextLayout > >& ,
204 rendering::TextHit SAL_CALL TextLayout::getTextHit(
const geometry::RealPoint2D& )
207 return rendering::TextHit();
210 rendering::Caret SAL_CALL TextLayout::getCaret( sal_Int32 ,
214 return rendering::Caret();
217 sal_Int32 SAL_CALL TextLayout::getNextInsertionIndex( sal_Int32 ,
225 uno::Reference< rendering::XPolyPolygon2D > SAL_CALL TextLayout::queryVisualHighlighting( sal_Int32 ,
229 return uno::Reference< rendering::XPolyPolygon2D >();
232 uno::Reference< rendering::XPolyPolygon2D > SAL_CALL TextLayout::queryLogicalHighlighting( sal_Int32 ,
236 return uno::Reference< rendering::XPolyPolygon2D >();
239 double SAL_CALL TextLayout::getBaselineOffset( )
245 sal_Int8 SAL_CALL TextLayout::getMainTextDirection( )
247 std::unique_lock aGuard(
m_aMutex );
249 return mnTextDirection;
252 uno::Reference< rendering::XCanvasFont > SAL_CALL TextLayout::getFont( )
254 std::unique_lock aGuard(
m_aMutex );
259 rendering::StringContext SAL_CALL TextLayout::getText( )
261 std::unique_lock aGuard(
m_aMutex );
276 const Point& rOutpos,
277 const rendering::ViewState& viewState,
278 const rendering::RenderState& renderState )
const
280 std::unique_lock aGuard( m_aMutex );
281 setupLayoutMode( rOutDev, mnTextDirection );
283 if (maLogicalAdvancements.hasElements())
285 KernArray aOffsets(setupTextOffsets(maLogicalAdvancements, viewState, renderState));
289 ::canvas::tools::numeric_cast<sal_uInt16>(
maText.StartPosition),
290 ::canvas::tools::numeric_cast<sal_uInt16>(
maText.Length) );
295 ::canvas::tools::numeric_cast<sal_uInt16>(
maText.StartPosition),
296 ::canvas::tools::numeric_cast<sal_uInt16>(
maText.Length) );
302 class OffsetTransformer
310 sal_Int32 operator()(
const double& rOffset )
323 return ::basegfx::fround( hypot(
maMatrix.
get(0,0)*rOffset,
333 const uno::Sequence< double >& inputOffsets,
334 const rendering::ViewState& viewState,
335 const rendering::RenderState& renderState )
const
345 OffsetTransformer aTransform(aMatrix);
346 std::for_each(inputOffsets.begin(), inputOffsets.end(),
347 [&outputOffsets, &aTransform](
double n) {outputOffsets.push_back(aTransform(n)); } );
348 return outputOffsets;
351 OUString SAL_CALL TextLayout::getImplementationName()
353 return "CairoCanvas::TextLayout";
356 sal_Bool SAL_CALL TextLayout::supportsService(
const OUString& ServiceName )
361 uno::Sequence< OUString > SAL_CALL TextLayout::getSupportedServiceNames()
363 return {
"com.sun.star.rendering.TextLayout" };
::basegfx::B2DHomMatrix maMatrix
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 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)
double get(sal_uInt16 nRow, sal_uInt16 nColumn) const
rtl::Reference< CanvasFont > Reference
TextLayout(const TextLayout &)=delete
make noncopyable
#define SAL_WARN(area, stream)
class SAL_LOPLUGIN_ANNOTATE("crosscast") SurfaceProvider typedef ::rtl::Reference< SurfaceProvider > SurfaceProviderRef
Target interface for XCachedPrimitive implementations.
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
std::optional< vcl::Font > mpFont