22#include <com/sun/star/rendering/TextDirection.hpp>
24#include <rtl/math.hxx>
38using namespace ::
cairo;
44 const rendering::FontRequest& fontRequest,
45 const uno::Sequence< beans::PropertyValue >& extraFontProperties,
46 const geometry::Matrix2D& fontMatrix )
48 return uno::Reference< rendering::XCanvasFont >(
new CanvasFont( fontRequest, extraFontProperties, fontMatrix,
mpSurfaceProvider ));
52 const rendering::FontInfo& ,
53 const uno::Sequence< beans::PropertyValue >& )
56 return uno::Sequence< rendering::FontInfo >();
63 const rendering::ViewState& rViewState,
64 const rendering::RenderState& rRenderState )
74 double nRotate, nShearX;
76 aMatrix.
decompose( aScale, aTranslate, nRotate, nShearX );
79 if( !::rtl::math::approxEqual(aScale.
getX(), aScale.
getY()) )
84 const sal_Int32 nScaledFontWidth( ::basegfx::fround(nFontWidth * aScale.
getX()) );
86 if( !nScaledFontWidth )
96 if( !::rtl::math::approxEqual(aScale.
getY(), 1.0) )
102 io_rVCLFont.
SetOrientation(
Degree10( ::basegfx::fround(-basegfx::rad2deg<10>(fmod(nRotate, 2*M_PI))) ) );
105 o_rPoint.
setX( ::basegfx::fround(aTranslate.
getX()) );
106 o_rPoint.
setY( ::basegfx::fround(aTranslate.
getY()) );
113 const rendering::XCanvas* pOwner,
114 const rendering::ViewState& viewState,
115 const rendering::RenderState& renderState )
119 const_cast<rendering::XCanvas*
>(
pOwner),
129 if( renderState.DeviceColor.getLength() > 2 )
143 class DeviceSettingsGuard
157 ~DeviceSettingsGuard()
167 const rendering::XCanvas* pOwner,
169 const rendering::ViewState& viewState,
170 const rendering::RenderState& renderState,
171 const uno::Reference< rendering::XCanvasFont >& xFont )
178 "CanvasHelper::setupTextOutput(): Font not compatible with this canvas" );
184 if( renderState.DeviceColor.getLength() > 2 )
206 const rendering::StringContext& text,
207 const uno::Reference< rendering::XCanvasFont >& xFont,
208 const rendering::ViewState& viewState,
209 const rendering::RenderState& renderState,
212#ifdef CAIRO_CANVAS_PERF_TRACE
213 struct timespec aTimer;
214 mxDevice->startPerfTrace( &aTimer );
218 "CanvasHelper::drawText(): font is NULL");
229 return uno::Reference< rendering::XCachedPrimitive >(
nullptr);
233 switch( textDirection )
235 case rendering::TextDirection::WEAK_LEFT_TO_RIGHT:
236 case rendering::TextDirection::STRONG_LEFT_TO_RIGHT:
241 case rendering::TextDirection::WEAK_RIGHT_TO_LEFT:
244 case rendering::TextDirection::STRONG_RIGHT_TO_LEFT:
257 return uno::Reference< rendering::XCachedPrimitive >(
nullptr);
261 const uno::Reference< rendering::XTextLayout >& xLayoutedText,
262 const rendering::ViewState& viewState,
263 const rendering::RenderState& renderState )
266 "CanvasHelper::drawTextLayout(): layout is NULL");
268 TextLayout* pTextLayout =
dynamic_cast< TextLayout*
>( xLayoutedText.get() );
286 return uno::Reference< rendering::XCachedPrimitive >(
nullptr);
295 "CanvasHelper::drawTextLayout(): TextLayout not compatible with this canvas" );
298 return uno::Reference< rendering::XCachedPrimitive >(
nullptr);
VclPtr< OutputDevice > mpVirtualDevice
void SetAlpha(sal_uInt8 nAlpha)
void SetFont(const vcl::Font &rNewFont)
void SetTextColor(const Color &rColor)
FontMetric GetFontMetric() const
void setX(tools::Long nX)
void setY(tools::Long nY)
reference_type * get() const
bool decompose(B2DTuple &rScale, B2DTuple &rTranslate, double &rRotate, double &rShearX) const
rtl::Reference< CanvasFont > Reference
sal_uInt32 getEmphasisMark() const
vcl::Font const & getVCLFont() const
::cairo::SurfaceSharedPtr mpSurface
SurfaceProvider * mpSurfaceProvider
Surface provider.
VclPtr< VirtualDevice > mpVirtualDevice
css::uno::Sequence< css::rendering::FontInfo > queryAvailableFonts(const css::rendering::XCanvas *pCanvas, const css::rendering::FontInfo &aFilter, const css::uno::Sequence< css::beans::PropertyValue > &aFontProperties)
css::uno::Reference< css::rendering::XCachedPrimitive > drawText(const css::rendering::XCanvas *pCanvas, const css::rendering::StringContext &text, const css::uno::Reference< css::rendering::XCanvasFont > &xFont, const css::rendering::ViewState &viewState, const css::rendering::RenderState &renderState, sal_Int8 textDirection)
css::uno::Reference< css::rendering::XCanvasFont > createFont(const css::rendering::XCanvas *pCanvas, const css::rendering::FontRequest &fontRequest, const css::uno::Sequence< css::beans::PropertyValue > &extraFontProperties, const css::geometry::Matrix2D &fontMatrix)
css::uno::Reference< css::rendering::XCachedPrimitive > drawTextLayout(const css::rendering::XCanvas *pCanvas, const css::uno::Reference< css::rendering::XTextLayout > &laidOutText, const css::rendering::ViewState &viewState, const css::rendering::RenderState &renderState)
tools::Long GetFontHeight() const
void SetOrientation(Degree10 nLineOrientation)
void SetAverageFontWidth(tools::Long nWidth)
void SetFillColor(const Color &)
void SetColor(const Color &)
void SetFontHeight(tools::Long nHeight)
void SetEmphasisMark(FontEmphasisMark)
tools::Long GetAverageFontWidth() const
constexpr ::Color COL_WHITE(0xFF, 0xFF, 0xFF)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
#define ENSURE_ARG_OR_THROW(c, m)
static void setupOutDevState(OutputDevice &rOutDev, const rendering::XCanvas *pOwner, const rendering::ViewState &viewState, const rendering::RenderState &renderState)
static bool setupFontTransform(::OutputDevice const &rOutDev, ::Point &o_rPoint, vcl::Font &io_rVCLFont, const rendering::ViewState &rViewState, const rendering::RenderState &rRenderState)
static bool setupTextOutput(OutputDevice &rOutDev, const rendering::XCanvas *pOwner, ::Point &o_rOutPos, const rendering::ViewState &viewState, const rendering::RenderState &renderState, const uno::Reference< rendering::XCanvasFont > &xFont)