update dev300-m58
[ooovba.git] / canvas / source / cairo / cairo_textlayout.cxx
blob003ba683b35e24ada0e88696500c9ccfcbc8ea9b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cairo_textlayout.cxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_canvas.hxx"
34 #include <math.h>
36 #include <canvas/debug.hxx>
37 #include <canvas/verbosetrace.hxx>
38 #include <tools/diagnose_ex.h>
40 #include <vcl/metric.hxx>
41 #include <vcl/virdev.hxx>
43 #ifdef WNT
44 #include <tools/prewin.h>
45 #include <windows.h>
46 #include <tools/postwin.h>
47 #endif
48 #include <vcl/sysdata.hxx>
50 #include <basegfx/matrix/b2dhommatrix.hxx>
51 #include <basegfx/numeric/ftools.hxx>
53 #include <boost/scoped_array.hpp>
55 #include "cairo_textlayout.hxx"
56 #include "cairo_spritecanvas.hxx"
58 #ifdef CAIRO_HAS_QUARTZ_SURFACE
59 # include "cairo_quartz_cairo.hxx"
60 #elif defined CAIRO_HAS_WIN32_SURFACE
61 # include "cairo_win32_cairo.hxx"
62 # include <cairo-win32.h>
63 #elif defined CAIRO_HAS_XLIB_SURFACE
64 # include "cairo_xlib_cairo.hxx"
65 # include <cairo-ft.h>
66 #else
67 # error Native API needed.
68 #endif
70 using namespace ::cairo;
71 using namespace ::com::sun::star;
73 namespace cairocanvas
75 namespace
77 void setupLayoutMode( OutputDevice& rOutDev,
78 sal_Int8 nTextDirection )
80 // TODO(P3): avoid if already correctly set
81 ULONG nLayoutMode;
82 switch( nTextDirection )
84 default:
85 nLayoutMode = 0;
86 break;
87 case rendering::TextDirection::WEAK_LEFT_TO_RIGHT:
88 nLayoutMode = TEXT_LAYOUT_BIDI_LTR;
89 break;
90 case rendering::TextDirection::STRONG_LEFT_TO_RIGHT:
91 nLayoutMode = TEXT_LAYOUT_BIDI_LTR | TEXT_LAYOUT_BIDI_STRONG;
92 break;
93 case rendering::TextDirection::WEAK_RIGHT_TO_LEFT:
94 nLayoutMode = TEXT_LAYOUT_BIDI_RTL;
95 break;
96 case rendering::TextDirection::STRONG_RIGHT_TO_LEFT:
97 nLayoutMode = TEXT_LAYOUT_BIDI_RTL | TEXT_LAYOUT_BIDI_STRONG;
98 break;
101 // set calculated layout mode. Origin is always the left edge,
102 // as required at the API spec
103 rOutDev.SetLayoutMode( nLayoutMode | TEXT_LAYOUT_TEXTORIGIN_LEFT );
107 TextLayout::TextLayout( const rendering::StringContext& aText,
108 sal_Int8 nDirection,
109 sal_Int64 /*nRandomSeed*/,
110 const CanvasFont::Reference& rFont,
111 const SurfaceProviderRef& rRefDevice ) :
112 TextLayout_Base( m_aMutex ),
113 maText( aText ),
114 maLogicalAdvancements(),
115 mpFont( rFont ),
116 mpRefDevice( rRefDevice ),
117 mnTextDirection( nDirection )
121 TextLayout::~TextLayout()
125 void SAL_CALL TextLayout::disposing()
127 ::osl::MutexGuard aGuard( m_aMutex );
129 mpFont.reset();
130 mpRefDevice.clear();
133 // XTextLayout
134 uno::Sequence< uno::Reference< rendering::XPolyPolygon2D > > SAL_CALL TextLayout::queryTextShapes( ) throw (uno::RuntimeException)
136 ::osl::MutexGuard aGuard( m_aMutex );
138 // TODO
139 return uno::Sequence< uno::Reference< rendering::XPolyPolygon2D > >();
142 uno::Sequence< geometry::RealRectangle2D > SAL_CALL TextLayout::queryInkMeasures( ) throw (uno::RuntimeException)
144 ::osl::MutexGuard aGuard( m_aMutex );
146 // TODO
147 return uno::Sequence< geometry::RealRectangle2D >();
150 uno::Sequence< geometry::RealRectangle2D > SAL_CALL TextLayout::queryMeasures( ) throw (uno::RuntimeException)
152 ::osl::MutexGuard aGuard( m_aMutex );
154 // TODO
155 return uno::Sequence< geometry::RealRectangle2D >();
158 uno::Sequence< double > SAL_CALL TextLayout::queryLogicalAdvancements( ) throw (uno::RuntimeException)
160 ::osl::MutexGuard aGuard( m_aMutex );
162 return maLogicalAdvancements;
165 void SAL_CALL TextLayout::applyLogicalAdvancements( const uno::Sequence< double >& aAdvancements ) throw (lang::IllegalArgumentException, uno::RuntimeException)
167 ::osl::MutexGuard aGuard( m_aMutex );
169 if( aAdvancements.getLength() != maText.Length )
171 OSL_TRACE( "TextLayout::applyLogicalAdvancements(): mismatching number of advancements" );
172 throw lang::IllegalArgumentException();
175 maLogicalAdvancements = aAdvancements;
178 geometry::RealRectangle2D SAL_CALL TextLayout::queryTextBounds( ) throw (uno::RuntimeException)
180 ::osl::MutexGuard aGuard( m_aMutex );
182 OutputDevice* pOutDev = mpRefDevice->getOutputDevice();
183 if( !pOutDev )
184 return geometry::RealRectangle2D();
186 VirtualDevice aVDev( *pOutDev );
187 aVDev.SetFont( mpFont->getVCLFont() );
189 // need metrics for Y offset, the XCanvas always renders
190 // relative to baseline
191 const ::FontMetric& aMetric( aVDev.GetFontMetric() );
193 setupLayoutMode( aVDev, mnTextDirection );
195 const sal_Int32 nAboveBaseline( -aMetric.GetIntLeading() - aMetric.GetAscent() );
196 const sal_Int32 nBelowBaseline( aMetric.GetDescent() );
198 if( maLogicalAdvancements.getLength() )
200 return geometry::RealRectangle2D( 0, nAboveBaseline,
201 maLogicalAdvancements[ maLogicalAdvancements.getLength()-1 ],
202 nBelowBaseline );
204 else
206 return geometry::RealRectangle2D( 0, nAboveBaseline,
207 aVDev.GetTextWidth(
208 maText.Text,
209 ::canvas::tools::numeric_cast<USHORT>(maText.StartPosition),
210 ::canvas::tools::numeric_cast<USHORT>(maText.Length) ),
211 nBelowBaseline );
215 double SAL_CALL TextLayout::justify( double /*nSize*/ ) throw (lang::IllegalArgumentException, uno::RuntimeException)
217 ::osl::MutexGuard aGuard( m_aMutex );
219 // TODO
220 return 0.0;
223 double SAL_CALL TextLayout::combinedJustify( const uno::Sequence< uno::Reference< rendering::XTextLayout > >& /*aNextLayouts*/,
224 double /*nSize*/ ) throw (lang::IllegalArgumentException, uno::RuntimeException)
226 ::osl::MutexGuard aGuard( m_aMutex );
228 // TODO
229 return 0.0;
232 rendering::TextHit SAL_CALL TextLayout::getTextHit( const geometry::RealPoint2D& /*aHitPoint*/ ) throw (uno::RuntimeException)
234 ::osl::MutexGuard aGuard( m_aMutex );
236 // TODO
237 return rendering::TextHit();
240 rendering::Caret SAL_CALL TextLayout::getCaret( sal_Int32 /*nInsertionIndex*/,
241 sal_Bool /*bExcludeLigatures*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
243 ::osl::MutexGuard aGuard( m_aMutex );
245 // TODO
246 return rendering::Caret();
249 sal_Int32 SAL_CALL TextLayout::getNextInsertionIndex( sal_Int32 /*nStartIndex*/,
250 sal_Int32 /*nCaretAdvancement*/,
251 sal_Bool /*bExcludeLigatures*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
253 ::osl::MutexGuard aGuard( m_aMutex );
255 // TODO
256 return 0;
259 uno::Reference< rendering::XPolyPolygon2D > SAL_CALL TextLayout::queryVisualHighlighting( sal_Int32 /*nStartIndex*/,
260 sal_Int32 /*nEndIndex*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
262 ::osl::MutexGuard aGuard( m_aMutex );
264 // TODO
265 return uno::Reference< rendering::XPolyPolygon2D >();
268 uno::Reference< rendering::XPolyPolygon2D > SAL_CALL TextLayout::queryLogicalHighlighting( sal_Int32 /*nStartIndex*/,
269 sal_Int32 /*nEndIndex*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
271 ::osl::MutexGuard aGuard( m_aMutex );
273 // TODO
274 return uno::Reference< rendering::XPolyPolygon2D >();
277 double SAL_CALL TextLayout::getBaselineOffset( ) throw (uno::RuntimeException)
279 ::osl::MutexGuard aGuard( m_aMutex );
281 // TODO
282 return 0.0;
285 sal_Int8 SAL_CALL TextLayout::getMainTextDirection( ) throw (uno::RuntimeException)
287 ::osl::MutexGuard aGuard( m_aMutex );
289 return mnTextDirection;
292 uno::Reference< rendering::XCanvasFont > SAL_CALL TextLayout::getFont( ) throw (uno::RuntimeException)
294 ::osl::MutexGuard aGuard( m_aMutex );
296 return mpFont.getRef();
299 rendering::StringContext SAL_CALL TextLayout::getText( ) throw (uno::RuntimeException)
301 ::osl::MutexGuard aGuard( m_aMutex );
303 return maText;
306 void TextLayout::useFont( Cairo* pCairo )
308 rendering::FontRequest aFontRequest = mpFont->getFontRequest();
309 rendering::FontInfo aFontInfo = aFontRequest.FontDescription;
311 cairo_select_font_face( pCairo, ::rtl::OUStringToOString( aFontInfo.FamilyName, RTL_TEXTENCODING_UTF8 ), CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL );
312 cairo_set_font_size( pCairo, aFontRequest.CellSize );
315 /** TextLayout:draw
317 * This function uses the "toy" api of the cairo library
320 bool TextLayout::draw( Cairo* pCairo )
322 ::osl::MutexGuard aGuard( m_aMutex );
324 ::rtl::OUString aSubText = maText.Text.copy( maText.StartPosition, maText.Length );
325 ::rtl::OString aUTF8String = ::rtl::OUStringToOString( aSubText, RTL_TEXTENCODING_UTF8 );
327 cairo_save( pCairo );
328 /* move to 0, 0 as cairo_show_text advances current point and current point is not restored by cairo_restore.
329 before we were depending on unmodified current point which I believed was preserved by save/restore */
330 cairo_move_to( pCairo, 0, 0 );
331 useFont( pCairo );
332 cairo_show_text( pCairo, aUTF8String );
333 cairo_restore( pCairo );
335 return true;
340 * TextLayout::isCairoRenderable
342 * Features currenly not supported by Cairo (VCL rendering is used as fallback):
343 * - vertical glyphs
345 * @return true, if text/font can be rendered with cairo
347 bool TextLayout::isCairoRenderable(SystemFontData aSysFontData) const
349 #if defined UNX && !defined QUARTZ
350 // is font usable?
351 if (!aSysFontData.nFontId) return false;
352 #endif
354 // vertical glyph rendering is not supported in cairo for now
355 if (aSysFontData.bVerticalCharacterType) {
356 OSL_TRACE(":cairocanvas::TextLayout::isCairoRenderable(): ***************** VERTICAL CHARACTER STYLE!!! ****************");
357 return false;
360 return true;
365 * TextLayout::draw
367 * Cairo-based text rendering. Draw text directly on the cairo surface with cairo fonts.
368 * Avoid using VCL VirtualDevices for that, bypassing VCL DrawText functions, when possible
370 * Note: some text effects are not rendered due to lacking generic canvas or cairo canvas
371 * implementation. See issues 92657, 92658, 92659, 92660, 97529
373 * @return true, if successful
375 bool TextLayout::draw( SurfaceSharedPtr& pSurface,
376 OutputDevice& rOutDev,
377 const Point& rOutpos,
378 const rendering::ViewState& viewState,
379 const rendering::RenderState& renderState ) const
381 ::osl::MutexGuard aGuard( m_aMutex );
382 SystemTextLayoutData aSysLayoutData;
383 #if (defined CAIRO_HAS_WIN32_SURFACE) && (OSL_DEBUG_LEVEL > 1)
384 LOGFONTW logfont;
385 #endif
386 setupLayoutMode( rOutDev, mnTextDirection );
388 // TODO(P2): cache that
389 ::boost::scoped_array< sal_Int32 > aOffsets(new sal_Int32[maLogicalAdvancements.getLength()]);
391 if( maLogicalAdvancements.getLength() )
393 setupTextOffsets( aOffsets.get(), maLogicalAdvancements, viewState, renderState );
395 // TODO(F3): ensure correct length and termination for DX
396 // array (last entry _must_ contain the overall width)
399 aSysLayoutData = rOutDev.GetSysTextLayoutData(rOutpos, maText.Text,
400 ::canvas::tools::numeric_cast<USHORT>(maText.StartPosition),
401 ::canvas::tools::numeric_cast<USHORT>(maText.Length),
402 maLogicalAdvancements.getLength() ? aOffsets.get() : NULL);
404 // The ::GetSysTextLayoutData(), i.e. layouting of text to glyphs can change the font being used.
405 // The fallback checks need to be done after final font is known.
406 if (!isCairoRenderable(aSysLayoutData.aSysFontData)) // VCL FALLBACKS
408 OSL_TRACE(":cairocanvas::TextLayout::draw(S,O,p,v,r): VCL FALLBACK %s%s%s%s - %s",
409 maLogicalAdvancements.getLength() ? "ADV " : "",
410 aSysLayoutData.aSysFontData.bAntialias ? "AA " : "",
411 aSysLayoutData.aSysFontData.bFakeBold ? "FB " : "",
412 aSysLayoutData.aSysFontData.bFakeItalic ? "FI " : "",
413 ::rtl::OUStringToOString( maText.Text.copy( maText.StartPosition, maText.Length ),
414 RTL_TEXTENCODING_UTF8 ).getStr());
416 if (maLogicalAdvancements.getLength()) // VCL FALLBACK - with glyph advances
418 rOutDev.DrawTextArray( rOutpos, maText.Text, aOffsets.get(),
419 ::canvas::tools::numeric_cast<USHORT>(maText.StartPosition),
420 ::canvas::tools::numeric_cast<USHORT>(maText.Length) );
421 return true;
423 else // VCL FALLBACK - without advances
425 rOutDev.DrawText( rOutpos, maText.Text,
426 ::canvas::tools::numeric_cast<USHORT>(maText.StartPosition),
427 ::canvas::tools::numeric_cast<USHORT>(maText.Length) );
428 return true;
432 if (aSysLayoutData.rGlyphData.empty()) return false; //??? false?
435 * Setup platform independent glyph vector into cairo-based glyphs vector.
438 // setup glyphs
439 std::vector<cairo_glyph_t> cairo_glyphs;
440 cairo_glyphs.reserve( 256 );
442 for( int nStart = 0; nStart < (int) aSysLayoutData.rGlyphData.size(); nStart++ )
444 cairo_glyph_t aGlyph;
445 SystemGlyphData systemGlyph = aSysLayoutData.rGlyphData.at(nStart);
446 aGlyph.index = systemGlyph.index;
447 #ifdef CAIRO_HAS_WIN32_SURFACE
448 // Cairo requires standard glyph indexes (ETO_GLYPH_INDEX), while vcl/win/* uses ucs4 chars.
449 // Convert to standard indexes
450 aGlyph.index = cairo::ucs4toindex((unsigned int) aGlyph.index, aSysLayoutData.aSysFontData.hFont);
451 #endif
452 aGlyph.x = systemGlyph.x;
453 aGlyph.y = systemGlyph.y;
454 cairo_glyphs.push_back(aGlyph);
457 if (cairo_glyphs.empty()) return true; //true or false??
460 * Setup font
461 **/
462 cairo_font_face_t* font_face = NULL;
464 #ifdef CAIRO_HAS_QUARTZ_SURFACE
465 // TODO: use cairo_quartz_font_face_create_for_cgfont(cgFont)
466 // when CGFont (Mac OS X 10.5 API) is provided by the AQUA VCL backend.
467 font_face = cairo_quartz_font_face_create_for_atsu_font_id((ATSUFontID) aSysLayoutData.aSysFontData.aATSUFontID);
469 #elif defined CAIRO_HAS_WIN32_SURFACE
470 #if (OSL_DEBUG_LEVEL > 1)
471 GetObjectW( aSysLayoutData.aSysFontData.hFont, sizeof(logfont), &logfont );
472 #endif
473 // Note: cairo library uses logfont fallbacks when lfEscapement, lfOrientation and lfWidth are not zero.
474 // VCL always has non-zero value for lfWidth
475 font_face = cairo_win32_font_face_create_for_hfont(aSysLayoutData.aSysFontData.hFont);
477 #elif defined CAIRO_HAS_XLIB_SURFACE
478 font_face = cairo_ft_font_face_create_for_ft_face((FT_Face)aSysLayoutData.aSysFontData.nFontId,
479 aSysLayoutData.aSysFontData.nFontFlags);
480 #else
481 # error Native API needed.
482 #endif
484 CairoSharedPtr pSCairo = pSurface->getCairo();
486 cairo_set_font_face( pSCairo.get(), font_face);
488 // create default font options. cairo_get_font_options() does not retrieve the surface defaults,
489 // only what has been set before with cairo_set_font_options()
490 cairo_font_options_t* options = cairo_font_options_create();
491 if (aSysLayoutData.aSysFontData.bAntialias) {
492 // CAIRO_ANTIALIAS_GRAY provides more similar result to VCL Canvas,
493 // so we're not using CAIRO_ANTIALIAS_SUBPIXEL
494 cairo_font_options_set_antialias(options, CAIRO_ANTIALIAS_GRAY);
496 cairo_set_font_options( pSCairo.get(), options);
498 // Font color
499 Color mTextColor = rOutDev.GetTextColor();
500 cairo_set_source_rgb(pSCairo.get(),
501 mTextColor.GetRed()/255.0,
502 mTextColor.GetGreen()/255.0,
503 mTextColor.GetBlue()/255.0);
505 // Font rotation and scaling
506 cairo_matrix_t m;
507 Font aFont = rOutDev.GetFont();
508 FontMetric aMetric( rOutDev.GetFontMetric(aFont) );
509 long nWidth = 0;
511 // width calculation is deep magic and platform/font dependant.
512 // width == 0 means no scaling, and usually width == height means the same.
513 // Other values mean horizontal scaling (narrow or stretching)
514 // see issue #101566
516 //proper scale calculation across platforms
517 if (aFont.GetWidth() == 0) {
518 nWidth = aFont.GetHeight();
519 } else {
520 // any scaling needs to be relative to the platform-dependent definition
521 // of width of the font
522 nWidth = aFont.GetHeight() * aFont.GetWidth() / aMetric.GetWidth();
525 cairo_matrix_init_identity(&m);
527 if (aSysLayoutData.orientation) cairo_matrix_rotate(&m, (3600 - aSysLayoutData.orientation) * M_PI / 1800.0);
529 cairo_matrix_scale(&m, nWidth, aFont.GetHeight());
531 //faux italics
532 if (aSysLayoutData.aSysFontData.bFakeItalic) m.xy = -m.xx * 0x6000L / 0x10000L;
534 cairo_set_font_matrix(pSCairo.get(), &m);
536 OSL_TRACE("\r\n:cairocanvas::TextLayout::draw(S,O,p,v,r): Size:(%d,%d), W:%d->%d, Pos (%d,%d), G(%d,%d,%d) %s%s%s%s || Name:%s - %s",
537 aFont.GetWidth(),
538 aFont.GetHeight(),
539 aMetric.GetWidth(),
540 nWidth,
541 (int) rOutpos.X(),
542 (int) rOutpos.Y(),
543 cairo_glyphs[0].index, cairo_glyphs[1].index, cairo_glyphs[2].index,
544 maLogicalAdvancements.getLength() ? "ADV " : "",
545 aSysLayoutData.aSysFontData.bAntialias ? "AA " : "",
546 aSysLayoutData.aSysFontData.bFakeBold ? "FB " : "",
547 aSysLayoutData.aSysFontData.bFakeItalic ? "FI " : "",
548 #if (defined CAIRO_HAS_WIN32_SURFACE) && (OSL_DEBUG_LEVEL > 1)
549 ::rtl::OUStringToOString( reinterpret_cast<const sal_Unicode*> (logfont.lfFaceName), RTL_TEXTENCODING_UTF8 ).getStr(),
550 #else
551 ::rtl::OUStringToOString( aFont.GetName(), RTL_TEXTENCODING_UTF8 ).getStr(),
552 #endif
553 ::rtl::OUStringToOString( maText.Text.copy( maText.StartPosition, maText.Length ),
554 RTL_TEXTENCODING_UTF8 ).getStr()
557 cairo_show_glyphs(pSCairo.get(), &cairo_glyphs[0], cairo_glyphs.size());
559 //faux bold
560 if (aSysLayoutData.aSysFontData.bFakeBold) {
561 double bold_dx = 0.5 * sqrt( 0.7 * aFont.GetHeight() );
562 int total_steps = 2 * ((int) (bold_dx + 0.5));
564 // loop to draw the text for every half pixel of displacement
565 for (int nSteps = 0; nSteps < total_steps; nSteps++) {
566 for(int nGlyphIdx = 0; nGlyphIdx < (int) cairo_glyphs.size(); nGlyphIdx++) {
567 cairo_glyphs[nGlyphIdx].x += bold_dx * nSteps / total_steps;
569 cairo_show_glyphs(pSCairo.get(), &cairo_glyphs[0], cairo_glyphs.size());
571 OSL_TRACE(":cairocanvas::TextLayout::draw(S,O,p,v,r): FAKEBOLD - dx:%d", (int) bold_dx);
574 cairo_restore( pSCairo.get() );
575 cairo_font_face_destroy(font_face);
576 return true;
580 namespace
582 class OffsetTransformer
584 public:
585 OffsetTransformer( const ::basegfx::B2DHomMatrix& rMat ) :
586 maMatrix( rMat )
590 sal_Int32 operator()( const double& rOffset )
592 // This is an optimization of the normal rMat*[x,0]
593 // transformation of the advancement vector (in x
594 // direction), followed by a length calculation of the
595 // resulting vector: advancement' =
596 // ||rMat*[x,0]||. Since advancements are vectors, we
597 // can ignore translational components, thus if [x,0],
598 // it follows that rMat*[x,0]=[x',0] holds. Thus, we
599 // just have to calc the transformation of the x
600 // component.
602 // TODO(F2): Handle non-horizontal advancements!
603 return ::basegfx::fround( hypot(maMatrix.get(0,0)*rOffset,
604 maMatrix.get(1,0)*rOffset) );
607 private:
608 ::basegfx::B2DHomMatrix maMatrix;
612 void TextLayout::setupTextOffsets( sal_Int32* outputOffsets,
613 const uno::Sequence< double >& inputOffsets,
614 const rendering::ViewState& viewState,
615 const rendering::RenderState& renderState ) const
617 ENSURE_OR_THROW( outputOffsets!=NULL,
618 "TextLayout::setupTextOffsets offsets NULL" );
620 ::basegfx::B2DHomMatrix aMatrix;
622 ::canvas::tools::mergeViewAndRenderTransform(aMatrix,
623 viewState,
624 renderState);
626 // fill integer offsets
627 ::std::transform( const_cast< uno::Sequence< double >& >(inputOffsets).getConstArray(),
628 const_cast< uno::Sequence< double >& >(inputOffsets).getConstArray()+inputOffsets.getLength(),
629 outputOffsets,
630 OffsetTransformer( aMatrix ) );
633 #define SERVICE_NAME "com.sun.star.rendering.TextLayout"
634 #define IMPLEMENTATION_NAME "CairoCanvas::TextLayout"
636 ::rtl::OUString SAL_CALL TextLayout::getImplementationName() throw( uno::RuntimeException )
638 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATION_NAME ) );
641 sal_Bool SAL_CALL TextLayout::supportsService( const ::rtl::OUString& ServiceName ) throw( uno::RuntimeException )
643 return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME ) );
646 uno::Sequence< ::rtl::OUString > SAL_CALL TextLayout::getSupportedServiceNames() throw( uno::RuntimeException )
648 uno::Sequence< ::rtl::OUString > aRet(1);
649 aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
651 return aRet;