1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_canvas.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <math.h> 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #include <canvas/debug.hxx> 34*cdf0e10cSrcweir #include <canvas/verbosetrace.hxx> 35*cdf0e10cSrcweir #include <tools/diagnose_ex.h> 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir #include <vcl/metric.hxx> 38*cdf0e10cSrcweir #include <vcl/virdev.hxx> 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir #ifdef WNT 41*cdf0e10cSrcweir #include <tools/prewin.h> 42*cdf0e10cSrcweir #include <windows.h> 43*cdf0e10cSrcweir #include <tools/postwin.h> 44*cdf0e10cSrcweir #ifdef max 45*cdf0e10cSrcweir #undef max 46*cdf0e10cSrcweir #endif 47*cdf0e10cSrcweir #ifdef min 48*cdf0e10cSrcweir #undef min 49*cdf0e10cSrcweir #endif 50*cdf0e10cSrcweir #endif 51*cdf0e10cSrcweir #include <vcl/sysdata.hxx> 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx> 54*cdf0e10cSrcweir #include <basegfx/numeric/ftools.hxx> 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir #include <boost/scoped_array.hpp> 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir #include "cairo_textlayout.hxx" 59*cdf0e10cSrcweir #include "cairo_spritecanvas.hxx" 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir #ifdef CAIRO_HAS_QUARTZ_SURFACE 62*cdf0e10cSrcweir # include "cairo_quartz_cairo.hxx" 63*cdf0e10cSrcweir #elif defined CAIRO_HAS_WIN32_SURFACE 64*cdf0e10cSrcweir # include "cairo_win32_cairo.hxx" 65*cdf0e10cSrcweir # include <cairo-win32.h> 66*cdf0e10cSrcweir #elif defined CAIRO_HAS_XLIB_SURFACE 67*cdf0e10cSrcweir # include "cairo_xlib_cairo.hxx" 68*cdf0e10cSrcweir # include <cairo-ft.h> 69*cdf0e10cSrcweir #else 70*cdf0e10cSrcweir # error Native API needed. 71*cdf0e10cSrcweir #endif 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir using namespace ::cairo; 74*cdf0e10cSrcweir using namespace ::com::sun::star; 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir namespace cairocanvas 77*cdf0e10cSrcweir { 78*cdf0e10cSrcweir namespace 79*cdf0e10cSrcweir { 80*cdf0e10cSrcweir void setupLayoutMode( OutputDevice& rOutDev, 81*cdf0e10cSrcweir sal_Int8 nTextDirection ) 82*cdf0e10cSrcweir { 83*cdf0e10cSrcweir // TODO(P3): avoid if already correctly set 84*cdf0e10cSrcweir sal_uLong nLayoutMode; 85*cdf0e10cSrcweir switch( nTextDirection ) 86*cdf0e10cSrcweir { 87*cdf0e10cSrcweir default: 88*cdf0e10cSrcweir nLayoutMode = 0; 89*cdf0e10cSrcweir break; 90*cdf0e10cSrcweir case rendering::TextDirection::WEAK_LEFT_TO_RIGHT: 91*cdf0e10cSrcweir nLayoutMode = TEXT_LAYOUT_BIDI_LTR; 92*cdf0e10cSrcweir break; 93*cdf0e10cSrcweir case rendering::TextDirection::STRONG_LEFT_TO_RIGHT: 94*cdf0e10cSrcweir nLayoutMode = TEXT_LAYOUT_BIDI_LTR | TEXT_LAYOUT_BIDI_STRONG; 95*cdf0e10cSrcweir break; 96*cdf0e10cSrcweir case rendering::TextDirection::WEAK_RIGHT_TO_LEFT: 97*cdf0e10cSrcweir nLayoutMode = TEXT_LAYOUT_BIDI_RTL; 98*cdf0e10cSrcweir break; 99*cdf0e10cSrcweir case rendering::TextDirection::STRONG_RIGHT_TO_LEFT: 100*cdf0e10cSrcweir nLayoutMode = TEXT_LAYOUT_BIDI_RTL | TEXT_LAYOUT_BIDI_STRONG; 101*cdf0e10cSrcweir break; 102*cdf0e10cSrcweir } 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir // set calculated layout mode. Origin is always the left edge, 105*cdf0e10cSrcweir // as required at the API spec 106*cdf0e10cSrcweir rOutDev.SetLayoutMode( nLayoutMode | TEXT_LAYOUT_TEXTORIGIN_LEFT ); 107*cdf0e10cSrcweir } 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir bool compareFallbacks(const SystemGlyphData&rA, const SystemGlyphData &rB) 110*cdf0e10cSrcweir { 111*cdf0e10cSrcweir return rA.fallbacklevel < rB.fallbacklevel; 112*cdf0e10cSrcweir } 113*cdf0e10cSrcweir } 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir TextLayout::TextLayout( const rendering::StringContext& aText, 116*cdf0e10cSrcweir sal_Int8 nDirection, 117*cdf0e10cSrcweir sal_Int64 /*nRandomSeed*/, 118*cdf0e10cSrcweir const CanvasFont::Reference& rFont, 119*cdf0e10cSrcweir const SurfaceProviderRef& rRefDevice ) : 120*cdf0e10cSrcweir TextLayout_Base( m_aMutex ), 121*cdf0e10cSrcweir maText( aText ), 122*cdf0e10cSrcweir maLogicalAdvancements(), 123*cdf0e10cSrcweir mpFont( rFont ), 124*cdf0e10cSrcweir mpRefDevice( rRefDevice ), 125*cdf0e10cSrcweir mnTextDirection( nDirection ) 126*cdf0e10cSrcweir { 127*cdf0e10cSrcweir } 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir TextLayout::~TextLayout() 130*cdf0e10cSrcweir { 131*cdf0e10cSrcweir } 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir void SAL_CALL TextLayout::disposing() 134*cdf0e10cSrcweir { 135*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir mpFont.reset(); 138*cdf0e10cSrcweir mpRefDevice.clear(); 139*cdf0e10cSrcweir } 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir // XTextLayout 142*cdf0e10cSrcweir uno::Sequence< uno::Reference< rendering::XPolyPolygon2D > > SAL_CALL TextLayout::queryTextShapes( ) throw (uno::RuntimeException) 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir // TODO 147*cdf0e10cSrcweir return uno::Sequence< uno::Reference< rendering::XPolyPolygon2D > >(); 148*cdf0e10cSrcweir } 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir uno::Sequence< geometry::RealRectangle2D > SAL_CALL TextLayout::queryInkMeasures( ) throw (uno::RuntimeException) 151*cdf0e10cSrcweir { 152*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir // TODO 155*cdf0e10cSrcweir return uno::Sequence< geometry::RealRectangle2D >(); 156*cdf0e10cSrcweir } 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir uno::Sequence< geometry::RealRectangle2D > SAL_CALL TextLayout::queryMeasures( ) throw (uno::RuntimeException) 159*cdf0e10cSrcweir { 160*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir // TODO 163*cdf0e10cSrcweir return uno::Sequence< geometry::RealRectangle2D >(); 164*cdf0e10cSrcweir } 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir uno::Sequence< double > SAL_CALL TextLayout::queryLogicalAdvancements( ) throw (uno::RuntimeException) 167*cdf0e10cSrcweir { 168*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir return maLogicalAdvancements; 171*cdf0e10cSrcweir } 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir void SAL_CALL TextLayout::applyLogicalAdvancements( const uno::Sequence< double >& aAdvancements ) throw (lang::IllegalArgumentException, uno::RuntimeException) 174*cdf0e10cSrcweir { 175*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir if( aAdvancements.getLength() != maText.Length ) 178*cdf0e10cSrcweir { 179*cdf0e10cSrcweir OSL_TRACE( "TextLayout::applyLogicalAdvancements(): mismatching number of advancements" ); 180*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 181*cdf0e10cSrcweir } 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir maLogicalAdvancements = aAdvancements; 184*cdf0e10cSrcweir } 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir geometry::RealRectangle2D SAL_CALL TextLayout::queryTextBounds( ) throw (uno::RuntimeException) 187*cdf0e10cSrcweir { 188*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir OutputDevice* pOutDev = mpRefDevice->getOutputDevice(); 191*cdf0e10cSrcweir if( !pOutDev ) 192*cdf0e10cSrcweir return geometry::RealRectangle2D(); 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir VirtualDevice aVDev( *pOutDev ); 195*cdf0e10cSrcweir aVDev.SetFont( mpFont->getVCLFont() ); 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir // need metrics for Y offset, the XCanvas always renders 198*cdf0e10cSrcweir // relative to baseline 199*cdf0e10cSrcweir const ::FontMetric& aMetric( aVDev.GetFontMetric() ); 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir setupLayoutMode( aVDev, mnTextDirection ); 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir const sal_Int32 nAboveBaseline( -aMetric.GetIntLeading() - aMetric.GetAscent() ); 204*cdf0e10cSrcweir const sal_Int32 nBelowBaseline( aMetric.GetDescent() ); 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir if( maLogicalAdvancements.getLength() ) 207*cdf0e10cSrcweir { 208*cdf0e10cSrcweir return geometry::RealRectangle2D( 0, nAboveBaseline, 209*cdf0e10cSrcweir maLogicalAdvancements[ maLogicalAdvancements.getLength()-1 ], 210*cdf0e10cSrcweir nBelowBaseline ); 211*cdf0e10cSrcweir } 212*cdf0e10cSrcweir else 213*cdf0e10cSrcweir { 214*cdf0e10cSrcweir return geometry::RealRectangle2D( 0, nAboveBaseline, 215*cdf0e10cSrcweir aVDev.GetTextWidth( 216*cdf0e10cSrcweir maText.Text, 217*cdf0e10cSrcweir ::canvas::tools::numeric_cast<sal_uInt16>(maText.StartPosition), 218*cdf0e10cSrcweir ::canvas::tools::numeric_cast<sal_uInt16>(maText.Length) ), 219*cdf0e10cSrcweir nBelowBaseline ); 220*cdf0e10cSrcweir } 221*cdf0e10cSrcweir } 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir double SAL_CALL TextLayout::justify( double /*nSize*/ ) throw (lang::IllegalArgumentException, uno::RuntimeException) 224*cdf0e10cSrcweir { 225*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir // TODO 228*cdf0e10cSrcweir return 0.0; 229*cdf0e10cSrcweir } 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir double SAL_CALL TextLayout::combinedJustify( const uno::Sequence< uno::Reference< rendering::XTextLayout > >& /*aNextLayouts*/, 232*cdf0e10cSrcweir double /*nSize*/ ) throw (lang::IllegalArgumentException, uno::RuntimeException) 233*cdf0e10cSrcweir { 234*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 235*cdf0e10cSrcweir 236*cdf0e10cSrcweir // TODO 237*cdf0e10cSrcweir return 0.0; 238*cdf0e10cSrcweir } 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir rendering::TextHit SAL_CALL TextLayout::getTextHit( const geometry::RealPoint2D& /*aHitPoint*/ ) throw (uno::RuntimeException) 241*cdf0e10cSrcweir { 242*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir // TODO 245*cdf0e10cSrcweir return rendering::TextHit(); 246*cdf0e10cSrcweir } 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir rendering::Caret SAL_CALL TextLayout::getCaret( sal_Int32 /*nInsertionIndex*/, 249*cdf0e10cSrcweir sal_Bool /*bExcludeLigatures*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 250*cdf0e10cSrcweir { 251*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 252*cdf0e10cSrcweir 253*cdf0e10cSrcweir // TODO 254*cdf0e10cSrcweir return rendering::Caret(); 255*cdf0e10cSrcweir } 256*cdf0e10cSrcweir 257*cdf0e10cSrcweir sal_Int32 SAL_CALL TextLayout::getNextInsertionIndex( sal_Int32 /*nStartIndex*/, 258*cdf0e10cSrcweir sal_Int32 /*nCaretAdvancement*/, 259*cdf0e10cSrcweir sal_Bool /*bExcludeLigatures*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 260*cdf0e10cSrcweir { 261*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 262*cdf0e10cSrcweir 263*cdf0e10cSrcweir // TODO 264*cdf0e10cSrcweir return 0; 265*cdf0e10cSrcweir } 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir uno::Reference< rendering::XPolyPolygon2D > SAL_CALL TextLayout::queryVisualHighlighting( sal_Int32 /*nStartIndex*/, 268*cdf0e10cSrcweir sal_Int32 /*nEndIndex*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 269*cdf0e10cSrcweir { 270*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir // TODO 273*cdf0e10cSrcweir return uno::Reference< rendering::XPolyPolygon2D >(); 274*cdf0e10cSrcweir } 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir uno::Reference< rendering::XPolyPolygon2D > SAL_CALL TextLayout::queryLogicalHighlighting( sal_Int32 /*nStartIndex*/, 277*cdf0e10cSrcweir sal_Int32 /*nEndIndex*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 278*cdf0e10cSrcweir { 279*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 280*cdf0e10cSrcweir 281*cdf0e10cSrcweir // TODO 282*cdf0e10cSrcweir return uno::Reference< rendering::XPolyPolygon2D >(); 283*cdf0e10cSrcweir } 284*cdf0e10cSrcweir 285*cdf0e10cSrcweir double SAL_CALL TextLayout::getBaselineOffset( ) throw (uno::RuntimeException) 286*cdf0e10cSrcweir { 287*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 288*cdf0e10cSrcweir 289*cdf0e10cSrcweir // TODO 290*cdf0e10cSrcweir return 0.0; 291*cdf0e10cSrcweir } 292*cdf0e10cSrcweir 293*cdf0e10cSrcweir sal_Int8 SAL_CALL TextLayout::getMainTextDirection( ) throw (uno::RuntimeException) 294*cdf0e10cSrcweir { 295*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 296*cdf0e10cSrcweir 297*cdf0e10cSrcweir return mnTextDirection; 298*cdf0e10cSrcweir } 299*cdf0e10cSrcweir 300*cdf0e10cSrcweir uno::Reference< rendering::XCanvasFont > SAL_CALL TextLayout::getFont( ) throw (uno::RuntimeException) 301*cdf0e10cSrcweir { 302*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 303*cdf0e10cSrcweir 304*cdf0e10cSrcweir return mpFont.getRef(); 305*cdf0e10cSrcweir } 306*cdf0e10cSrcweir 307*cdf0e10cSrcweir rendering::StringContext SAL_CALL TextLayout::getText( ) throw (uno::RuntimeException) 308*cdf0e10cSrcweir { 309*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 310*cdf0e10cSrcweir 311*cdf0e10cSrcweir return maText; 312*cdf0e10cSrcweir } 313*cdf0e10cSrcweir 314*cdf0e10cSrcweir void TextLayout::useFont( Cairo* pCairo ) 315*cdf0e10cSrcweir { 316*cdf0e10cSrcweir rendering::FontRequest aFontRequest = mpFont->getFontRequest(); 317*cdf0e10cSrcweir rendering::FontInfo aFontInfo = aFontRequest.FontDescription; 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir cairo_select_font_face( pCairo, ::rtl::OUStringToOString( aFontInfo.FamilyName, RTL_TEXTENCODING_UTF8 ), CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL ); 320*cdf0e10cSrcweir cairo_set_font_size( pCairo, aFontRequest.CellSize ); 321*cdf0e10cSrcweir } 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir /** TextLayout:draw 324*cdf0e10cSrcweir * 325*cdf0e10cSrcweir * This function uses the "toy" api of the cairo library 326*cdf0e10cSrcweir * 327*cdf0e10cSrcweir **/ 328*cdf0e10cSrcweir bool TextLayout::draw( Cairo* pCairo ) 329*cdf0e10cSrcweir { 330*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 331*cdf0e10cSrcweir 332*cdf0e10cSrcweir ::rtl::OUString aSubText = maText.Text.copy( maText.StartPosition, maText.Length ); 333*cdf0e10cSrcweir ::rtl::OString aUTF8String = ::rtl::OUStringToOString( aSubText, RTL_TEXTENCODING_UTF8 ); 334*cdf0e10cSrcweir 335*cdf0e10cSrcweir cairo_save( pCairo ); 336*cdf0e10cSrcweir /* move to 0, 0 as cairo_show_text advances current point and current point is not restored by cairo_restore. 337*cdf0e10cSrcweir before we were depending on unmodified current point which I believed was preserved by save/restore */ 338*cdf0e10cSrcweir cairo_move_to( pCairo, 0, 0 ); 339*cdf0e10cSrcweir useFont( pCairo ); 340*cdf0e10cSrcweir cairo_show_text( pCairo, aUTF8String ); 341*cdf0e10cSrcweir cairo_restore( pCairo ); 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir return true; 344*cdf0e10cSrcweir } 345*cdf0e10cSrcweir 346*cdf0e10cSrcweir 347*cdf0e10cSrcweir /** 348*cdf0e10cSrcweir * TextLayout::isCairoRenderable 349*cdf0e10cSrcweir * 350*cdf0e10cSrcweir * Features currenly not supported by Cairo (VCL rendering is used as fallback): 351*cdf0e10cSrcweir * - vertical glyphs 352*cdf0e10cSrcweir * 353*cdf0e10cSrcweir * @return true, if text/font can be rendered with cairo 354*cdf0e10cSrcweir **/ 355*cdf0e10cSrcweir bool TextLayout::isCairoRenderable(SystemFontData aSysFontData) const 356*cdf0e10cSrcweir { 357*cdf0e10cSrcweir #if defined UNX && !defined QUARTZ 358*cdf0e10cSrcweir // is font usable? 359*cdf0e10cSrcweir if (!aSysFontData.nFontId) return false; 360*cdf0e10cSrcweir #endif 361*cdf0e10cSrcweir 362*cdf0e10cSrcweir // vertical glyph rendering is not supported in cairo for now 363*cdf0e10cSrcweir if (aSysFontData.bVerticalCharacterType) { 364*cdf0e10cSrcweir OSL_TRACE(":cairocanvas::TextLayout::isCairoRenderable(): ***************** VERTICAL CHARACTER STYLE!!! ****************"); 365*cdf0e10cSrcweir return false; 366*cdf0e10cSrcweir } 367*cdf0e10cSrcweir 368*cdf0e10cSrcweir return true; 369*cdf0e10cSrcweir } 370*cdf0e10cSrcweir 371*cdf0e10cSrcweir /** 372*cdf0e10cSrcweir * TextLayout::draw 373*cdf0e10cSrcweir * 374*cdf0e10cSrcweir * Cairo-based text rendering. Draw text directly on the cairo surface with cairo fonts. 375*cdf0e10cSrcweir * Avoid using VCL VirtualDevices for that, bypassing VCL DrawText functions, when possible 376*cdf0e10cSrcweir * 377*cdf0e10cSrcweir * Note: some text effects are not rendered due to lacking generic canvas or cairo canvas 378*cdf0e10cSrcweir * implementation. See issues 92657, 92658, 92659, 92660, 97529 379*cdf0e10cSrcweir * 380*cdf0e10cSrcweir * @return true, if successful 381*cdf0e10cSrcweir **/ 382*cdf0e10cSrcweir bool TextLayout::draw( SurfaceSharedPtr& pSurface, 383*cdf0e10cSrcweir OutputDevice& rOutDev, 384*cdf0e10cSrcweir const Point& rOutpos, 385*cdf0e10cSrcweir const rendering::ViewState& viewState, 386*cdf0e10cSrcweir const rendering::RenderState& renderState ) const 387*cdf0e10cSrcweir { 388*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 389*cdf0e10cSrcweir SystemTextLayoutData aSysLayoutData; 390*cdf0e10cSrcweir #if (defined CAIRO_HAS_WIN32_SURFACE) && (OSL_DEBUG_LEVEL > 1) 391*cdf0e10cSrcweir LOGFONTW logfont; 392*cdf0e10cSrcweir #endif 393*cdf0e10cSrcweir setupLayoutMode( rOutDev, mnTextDirection ); 394*cdf0e10cSrcweir 395*cdf0e10cSrcweir // TODO(P2): cache that 396*cdf0e10cSrcweir ::boost::scoped_array< sal_Int32 > aOffsets(new sal_Int32[maLogicalAdvancements.getLength()]); 397*cdf0e10cSrcweir 398*cdf0e10cSrcweir if( maLogicalAdvancements.getLength() ) 399*cdf0e10cSrcweir { 400*cdf0e10cSrcweir setupTextOffsets( aOffsets.get(), maLogicalAdvancements, viewState, renderState ); 401*cdf0e10cSrcweir 402*cdf0e10cSrcweir // TODO(F3): ensure correct length and termination for DX 403*cdf0e10cSrcweir // array (last entry _must_ contain the overall width) 404*cdf0e10cSrcweir } 405*cdf0e10cSrcweir 406*cdf0e10cSrcweir aSysLayoutData = rOutDev.GetSysTextLayoutData(rOutpos, maText.Text, 407*cdf0e10cSrcweir ::canvas::tools::numeric_cast<sal_uInt16>(maText.StartPosition), 408*cdf0e10cSrcweir ::canvas::tools::numeric_cast<sal_uInt16>(maText.Length), 409*cdf0e10cSrcweir maLogicalAdvancements.getLength() ? aOffsets.get() : NULL); 410*cdf0e10cSrcweir 411*cdf0e10cSrcweir // Sort them so that all glyphs on the same glyph fallback level are consecutive 412*cdf0e10cSrcweir std::sort(aSysLayoutData.rGlyphData.begin(), aSysLayoutData.rGlyphData.end(), compareFallbacks); 413*cdf0e10cSrcweir bool bCairoRenderable = true; 414*cdf0e10cSrcweir 415*cdf0e10cSrcweir //Pull all the fonts we need to render the text 416*cdf0e10cSrcweir typedef std::pair<SystemFontData,int> FontLevel; 417*cdf0e10cSrcweir typedef std::vector<FontLevel> FontLevelVector; 418*cdf0e10cSrcweir FontLevelVector aFontData; 419*cdf0e10cSrcweir SystemGlyphDataVector::const_iterator aIter=aSysLayoutData.rGlyphData.begin(); 420*cdf0e10cSrcweir const SystemGlyphDataVector::const_iterator aEnd=aSysLayoutData.rGlyphData.end(); 421*cdf0e10cSrcweir for( ; aIter != aEnd; ++aIter ) 422*cdf0e10cSrcweir { 423*cdf0e10cSrcweir if( aFontData.empty() || aIter->fallbacklevel != aFontData.back().second ) 424*cdf0e10cSrcweir { 425*cdf0e10cSrcweir aFontData.push_back(FontLevel(rOutDev.GetSysFontData(aIter->fallbacklevel), 426*cdf0e10cSrcweir aIter->fallbacklevel)); 427*cdf0e10cSrcweir if( !isCairoRenderable(aFontData.back().first) ) 428*cdf0e10cSrcweir { 429*cdf0e10cSrcweir bCairoRenderable = false; 430*cdf0e10cSrcweir OSL_TRACE(":cairocanvas::TextLayout::draw(S,O,p,v,r): VCL FALLBACK %s%s%s%s - %s", 431*cdf0e10cSrcweir maLogicalAdvancements.getLength() ? "ADV " : "", 432*cdf0e10cSrcweir aFontData.back().first.bAntialias ? "AA " : "", 433*cdf0e10cSrcweir aFontData.back().first.bFakeBold ? "FB " : "", 434*cdf0e10cSrcweir aFontData.back().first.bFakeItalic ? "FI " : "", 435*cdf0e10cSrcweir ::rtl::OUStringToOString( maText.Text.copy( maText.StartPosition, maText.Length ), 436*cdf0e10cSrcweir RTL_TEXTENCODING_UTF8 ).getStr()); 437*cdf0e10cSrcweir break; 438*cdf0e10cSrcweir } 439*cdf0e10cSrcweir } 440*cdf0e10cSrcweir } 441*cdf0e10cSrcweir 442*cdf0e10cSrcweir // The ::GetSysTextLayoutData(), i.e. layouting of text to glyphs can change the font being used. 443*cdf0e10cSrcweir // The fallback checks need to be done after final font is known. 444*cdf0e10cSrcweir if (!bCairoRenderable) // VCL FALLBACKS 445*cdf0e10cSrcweir { 446*cdf0e10cSrcweir if (maLogicalAdvancements.getLength()) // VCL FALLBACK - with glyph advances 447*cdf0e10cSrcweir { 448*cdf0e10cSrcweir rOutDev.DrawTextArray( rOutpos, maText.Text, aOffsets.get(), 449*cdf0e10cSrcweir ::canvas::tools::numeric_cast<sal_uInt16>(maText.StartPosition), 450*cdf0e10cSrcweir ::canvas::tools::numeric_cast<sal_uInt16>(maText.Length) ); 451*cdf0e10cSrcweir return true; 452*cdf0e10cSrcweir } 453*cdf0e10cSrcweir else // VCL FALLBACK - without advances 454*cdf0e10cSrcweir { 455*cdf0e10cSrcweir rOutDev.DrawText( rOutpos, maText.Text, 456*cdf0e10cSrcweir ::canvas::tools::numeric_cast<sal_uInt16>(maText.StartPosition), 457*cdf0e10cSrcweir ::canvas::tools::numeric_cast<sal_uInt16>(maText.Length) ); 458*cdf0e10cSrcweir return true; 459*cdf0e10cSrcweir } 460*cdf0e10cSrcweir } 461*cdf0e10cSrcweir 462*cdf0e10cSrcweir if (aSysLayoutData.rGlyphData.empty()) return false; //??? false? 463*cdf0e10cSrcweir 464*cdf0e10cSrcweir /** 465*cdf0e10cSrcweir * Setup platform independent glyph vector into cairo-based glyphs vector. 466*cdf0e10cSrcweir **/ 467*cdf0e10cSrcweir 468*cdf0e10cSrcweir // Loop through the fonts used and render the matching glyphs for each 469*cdf0e10cSrcweir FontLevelVector::const_iterator aFontDataIter = aFontData.begin(); 470*cdf0e10cSrcweir const FontLevelVector::const_iterator aFontDataEnd = aFontData.end(); 471*cdf0e10cSrcweir for( ; aFontDataIter != aFontDataEnd; ++aFontDataIter ) 472*cdf0e10cSrcweir { 473*cdf0e10cSrcweir const SystemFontData &rSysFontData = aFontDataIter->first; 474*cdf0e10cSrcweir 475*cdf0e10cSrcweir // setup glyphs 476*cdf0e10cSrcweir std::vector<cairo_glyph_t> cairo_glyphs; 477*cdf0e10cSrcweir cairo_glyphs.reserve( 256 ); 478*cdf0e10cSrcweir 479*cdf0e10cSrcweir SystemGlyphDataVector::const_iterator aIter=aSysLayoutData.rGlyphData.begin(); 480*cdf0e10cSrcweir const SystemGlyphDataVector::const_iterator aEnd=aSysLayoutData.rGlyphData.end(); 481*cdf0e10cSrcweir for( ; aIter != aEnd; ++aIter ) 482*cdf0e10cSrcweir { 483*cdf0e10cSrcweir SystemGlyphData systemGlyph = *aIter; 484*cdf0e10cSrcweir if( systemGlyph.fallbacklevel != aFontDataIter->second ) 485*cdf0e10cSrcweir continue; 486*cdf0e10cSrcweir 487*cdf0e10cSrcweir cairo_glyph_t aGlyph; 488*cdf0e10cSrcweir aGlyph.index = systemGlyph.index; 489*cdf0e10cSrcweir #ifdef CAIRO_HAS_WIN32_SURFACE 490*cdf0e10cSrcweir // Cairo requires standard glyph indexes (ETO_GLYPH_INDEX), while vcl/win/* uses ucs4 chars. 491*cdf0e10cSrcweir // Convert to standard indexes 492*cdf0e10cSrcweir aGlyph.index = cairo::ucs4toindex((unsigned int) aGlyph.index, rSysFontData.hFont); 493*cdf0e10cSrcweir #endif 494*cdf0e10cSrcweir aGlyph.x = systemGlyph.x; 495*cdf0e10cSrcweir aGlyph.y = systemGlyph.y; 496*cdf0e10cSrcweir cairo_glyphs.push_back(aGlyph); 497*cdf0e10cSrcweir } 498*cdf0e10cSrcweir 499*cdf0e10cSrcweir if (cairo_glyphs.empty()) 500*cdf0e10cSrcweir continue; 501*cdf0e10cSrcweir 502*cdf0e10cSrcweir /** 503*cdf0e10cSrcweir * Setup font 504*cdf0e10cSrcweir **/ 505*cdf0e10cSrcweir cairo_font_face_t* font_face = NULL; 506*cdf0e10cSrcweir 507*cdf0e10cSrcweir #ifdef CAIRO_HAS_QUARTZ_SURFACE 508*cdf0e10cSrcweir // TODO: use cairo_quartz_font_face_create_for_cgfont(cgFont) 509*cdf0e10cSrcweir // when CGFont (Mac OS X 10.5 API) is provided by the AQUA VCL backend. 510*cdf0e10cSrcweir font_face = cairo_quartz_font_face_create_for_atsu_font_id((ATSUFontID) rSysFontData.aATSUFontID); 511*cdf0e10cSrcweir 512*cdf0e10cSrcweir #elif defined CAIRO_HAS_WIN32_SURFACE 513*cdf0e10cSrcweir #if (OSL_DEBUG_LEVEL > 1) 514*cdf0e10cSrcweir GetObjectW( rSysFontData.hFont, sizeof(logfont), &logfont ); 515*cdf0e10cSrcweir #endif 516*cdf0e10cSrcweir // Note: cairo library uses logfont fallbacks when lfEscapement, lfOrientation and lfWidth are not zero. 517*cdf0e10cSrcweir // VCL always has non-zero value for lfWidth 518*cdf0e10cSrcweir font_face = cairo_win32_font_face_create_for_hfont(rSysFontData.hFont); 519*cdf0e10cSrcweir 520*cdf0e10cSrcweir #elif defined CAIRO_HAS_XLIB_SURFACE 521*cdf0e10cSrcweir font_face = cairo_ft_font_face_create_for_ft_face((FT_Face)rSysFontData.nFontId, 522*cdf0e10cSrcweir rSysFontData.nFontFlags); 523*cdf0e10cSrcweir #else 524*cdf0e10cSrcweir # error Native API needed. 525*cdf0e10cSrcweir #endif 526*cdf0e10cSrcweir 527*cdf0e10cSrcweir CairoSharedPtr pSCairo = pSurface->getCairo(); 528*cdf0e10cSrcweir 529*cdf0e10cSrcweir cairo_set_font_face( pSCairo.get(), font_face); 530*cdf0e10cSrcweir 531*cdf0e10cSrcweir // create default font options. cairo_get_font_options() does not retrieve the surface defaults, 532*cdf0e10cSrcweir // only what has been set before with cairo_set_font_options() 533*cdf0e10cSrcweir cairo_font_options_t* options = cairo_font_options_create(); 534*cdf0e10cSrcweir if (rSysFontData.bAntialias) { 535*cdf0e10cSrcweir // CAIRO_ANTIALIAS_GRAY provides more similar result to VCL Canvas, 536*cdf0e10cSrcweir // so we're not using CAIRO_ANTIALIAS_SUBPIXEL 537*cdf0e10cSrcweir cairo_font_options_set_antialias(options, CAIRO_ANTIALIAS_GRAY); 538*cdf0e10cSrcweir } 539*cdf0e10cSrcweir cairo_set_font_options( pSCairo.get(), options); 540*cdf0e10cSrcweir 541*cdf0e10cSrcweir // Font color 542*cdf0e10cSrcweir Color mTextColor = rOutDev.GetTextColor(); 543*cdf0e10cSrcweir cairo_set_source_rgb(pSCairo.get(), 544*cdf0e10cSrcweir mTextColor.GetRed()/255.0, 545*cdf0e10cSrcweir mTextColor.GetGreen()/255.0, 546*cdf0e10cSrcweir mTextColor.GetBlue()/255.0); 547*cdf0e10cSrcweir 548*cdf0e10cSrcweir // Font rotation and scaling 549*cdf0e10cSrcweir cairo_matrix_t m; 550*cdf0e10cSrcweir Font aFont = rOutDev.GetFont(); 551*cdf0e10cSrcweir FontMetric aMetric( rOutDev.GetFontMetric(aFont) ); 552*cdf0e10cSrcweir long nWidth = 0; 553*cdf0e10cSrcweir 554*cdf0e10cSrcweir // width calculation is deep magic and platform/font dependant. 555*cdf0e10cSrcweir // width == 0 means no scaling, and usually width == height means the same. 556*cdf0e10cSrcweir // Other values mean horizontal scaling (narrow or stretching) 557*cdf0e10cSrcweir // see issue #101566 558*cdf0e10cSrcweir 559*cdf0e10cSrcweir //proper scale calculation across platforms 560*cdf0e10cSrcweir if (aFont.GetWidth() == 0) { 561*cdf0e10cSrcweir nWidth = aFont.GetHeight(); 562*cdf0e10cSrcweir } else { 563*cdf0e10cSrcweir // any scaling needs to be relative to the platform-dependent definition 564*cdf0e10cSrcweir // of height of the font 565*cdf0e10cSrcweir nWidth = aFont.GetWidth() * aFont.GetHeight() / aMetric.GetHeight(); 566*cdf0e10cSrcweir } 567*cdf0e10cSrcweir 568*cdf0e10cSrcweir cairo_matrix_init_identity(&m); 569*cdf0e10cSrcweir 570*cdf0e10cSrcweir if (aSysLayoutData.orientation) cairo_matrix_rotate(&m, (3600 - aSysLayoutData.orientation) * M_PI / 1800.0); 571*cdf0e10cSrcweir 572*cdf0e10cSrcweir cairo_matrix_scale(&m, nWidth, aFont.GetHeight()); 573*cdf0e10cSrcweir 574*cdf0e10cSrcweir //faux italics 575*cdf0e10cSrcweir if (rSysFontData.bFakeItalic) m.xy = -m.xx * 0x6000L / 0x10000L; 576*cdf0e10cSrcweir 577*cdf0e10cSrcweir cairo_set_font_matrix(pSCairo.get(), &m); 578*cdf0e10cSrcweir 579*cdf0e10cSrcweir 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", 580*cdf0e10cSrcweir aFont.GetWidth(), 581*cdf0e10cSrcweir aFont.GetHeight(), 582*cdf0e10cSrcweir aMetric.GetWidth(), 583*cdf0e10cSrcweir nWidth, 584*cdf0e10cSrcweir (int) rOutpos.X(), 585*cdf0e10cSrcweir (int) rOutpos.Y(), 586*cdf0e10cSrcweir cairo_glyphs[0].index, cairo_glyphs[1].index, cairo_glyphs[2].index, 587*cdf0e10cSrcweir maLogicalAdvancements.getLength() ? "ADV " : "", 588*cdf0e10cSrcweir rSysFontData.bAntialias ? "AA " : "", 589*cdf0e10cSrcweir rSysFontData.bFakeBold ? "FB " : "", 590*cdf0e10cSrcweir rSysFontData.bFakeItalic ? "FI " : "", 591*cdf0e10cSrcweir #if (defined CAIRO_HAS_WIN32_SURFACE) && (OSL_DEBUG_LEVEL > 1) 592*cdf0e10cSrcweir ::rtl::OUStringToOString( reinterpret_cast<const sal_Unicode*> (logfont.lfFaceName), RTL_TEXTENCODING_UTF8 ).getStr(), 593*cdf0e10cSrcweir #else 594*cdf0e10cSrcweir ::rtl::OUStringToOString( aFont.GetName(), RTL_TEXTENCODING_UTF8 ).getStr(), 595*cdf0e10cSrcweir #endif 596*cdf0e10cSrcweir ::rtl::OUStringToOString( maText.Text.copy( maText.StartPosition, maText.Length ), 597*cdf0e10cSrcweir RTL_TEXTENCODING_UTF8 ).getStr() 598*cdf0e10cSrcweir ); 599*cdf0e10cSrcweir 600*cdf0e10cSrcweir cairo_show_glyphs(pSCairo.get(), &cairo_glyphs[0], cairo_glyphs.size()); 601*cdf0e10cSrcweir 602*cdf0e10cSrcweir //faux bold 603*cdf0e10cSrcweir if (rSysFontData.bFakeBold) { 604*cdf0e10cSrcweir double bold_dx = 0.5 * sqrt( 0.7 * aFont.GetHeight() ); 605*cdf0e10cSrcweir int total_steps = 2 * ((int) (bold_dx + 0.5)); 606*cdf0e10cSrcweir 607*cdf0e10cSrcweir // loop to draw the text for every half pixel of displacement 608*cdf0e10cSrcweir for (int nSteps = 0; nSteps < total_steps; nSteps++) { 609*cdf0e10cSrcweir for(int nGlyphIdx = 0; nGlyphIdx < (int) cairo_glyphs.size(); nGlyphIdx++) { 610*cdf0e10cSrcweir cairo_glyphs[nGlyphIdx].x += bold_dx * nSteps / total_steps; 611*cdf0e10cSrcweir } 612*cdf0e10cSrcweir cairo_show_glyphs(pSCairo.get(), &cairo_glyphs[0], cairo_glyphs.size()); 613*cdf0e10cSrcweir } 614*cdf0e10cSrcweir OSL_TRACE(":cairocanvas::TextLayout::draw(S,O,p,v,r): FAKEBOLD - dx:%d", (int) bold_dx); 615*cdf0e10cSrcweir } 616*cdf0e10cSrcweir 617*cdf0e10cSrcweir cairo_restore( pSCairo.get() ); 618*cdf0e10cSrcweir cairo_font_face_destroy(font_face); 619*cdf0e10cSrcweir } 620*cdf0e10cSrcweir return true; 621*cdf0e10cSrcweir } 622*cdf0e10cSrcweir 623*cdf0e10cSrcweir 624*cdf0e10cSrcweir namespace 625*cdf0e10cSrcweir { 626*cdf0e10cSrcweir class OffsetTransformer 627*cdf0e10cSrcweir { 628*cdf0e10cSrcweir public: 629*cdf0e10cSrcweir OffsetTransformer( const ::basegfx::B2DHomMatrix& rMat ) : 630*cdf0e10cSrcweir maMatrix( rMat ) 631*cdf0e10cSrcweir { 632*cdf0e10cSrcweir } 633*cdf0e10cSrcweir 634*cdf0e10cSrcweir sal_Int32 operator()( const double& rOffset ) 635*cdf0e10cSrcweir { 636*cdf0e10cSrcweir // This is an optimization of the normal rMat*[x,0] 637*cdf0e10cSrcweir // transformation of the advancement vector (in x 638*cdf0e10cSrcweir // direction), followed by a length calculation of the 639*cdf0e10cSrcweir // resulting vector: advancement' = 640*cdf0e10cSrcweir // ||rMat*[x,0]||. Since advancements are vectors, we 641*cdf0e10cSrcweir // can ignore translational components, thus if [x,0], 642*cdf0e10cSrcweir // it follows that rMat*[x,0]=[x',0] holds. Thus, we 643*cdf0e10cSrcweir // just have to calc the transformation of the x 644*cdf0e10cSrcweir // component. 645*cdf0e10cSrcweir 646*cdf0e10cSrcweir // TODO(F2): Handle non-horizontal advancements! 647*cdf0e10cSrcweir return ::basegfx::fround( hypot(maMatrix.get(0,0)*rOffset, 648*cdf0e10cSrcweir maMatrix.get(1,0)*rOffset) ); 649*cdf0e10cSrcweir } 650*cdf0e10cSrcweir 651*cdf0e10cSrcweir private: 652*cdf0e10cSrcweir ::basegfx::B2DHomMatrix maMatrix; 653*cdf0e10cSrcweir }; 654*cdf0e10cSrcweir } 655*cdf0e10cSrcweir 656*cdf0e10cSrcweir void TextLayout::setupTextOffsets( sal_Int32* outputOffsets, 657*cdf0e10cSrcweir const uno::Sequence< double >& inputOffsets, 658*cdf0e10cSrcweir const rendering::ViewState& viewState, 659*cdf0e10cSrcweir const rendering::RenderState& renderState ) const 660*cdf0e10cSrcweir { 661*cdf0e10cSrcweir ENSURE_OR_THROW( outputOffsets!=NULL, 662*cdf0e10cSrcweir "TextLayout::setupTextOffsets offsets NULL" ); 663*cdf0e10cSrcweir 664*cdf0e10cSrcweir ::basegfx::B2DHomMatrix aMatrix; 665*cdf0e10cSrcweir 666*cdf0e10cSrcweir ::canvas::tools::mergeViewAndRenderTransform(aMatrix, 667*cdf0e10cSrcweir viewState, 668*cdf0e10cSrcweir renderState); 669*cdf0e10cSrcweir 670*cdf0e10cSrcweir // fill integer offsets 671*cdf0e10cSrcweir ::std::transform( const_cast< uno::Sequence< double >& >(inputOffsets).getConstArray(), 672*cdf0e10cSrcweir const_cast< uno::Sequence< double >& >(inputOffsets).getConstArray()+inputOffsets.getLength(), 673*cdf0e10cSrcweir outputOffsets, 674*cdf0e10cSrcweir OffsetTransformer( aMatrix ) ); 675*cdf0e10cSrcweir } 676*cdf0e10cSrcweir 677*cdf0e10cSrcweir #define SERVICE_NAME "com.sun.star.rendering.TextLayout" 678*cdf0e10cSrcweir #define IMPLEMENTATION_NAME "CairoCanvas::TextLayout" 679*cdf0e10cSrcweir 680*cdf0e10cSrcweir ::rtl::OUString SAL_CALL TextLayout::getImplementationName() throw( uno::RuntimeException ) 681*cdf0e10cSrcweir { 682*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATION_NAME ) ); 683*cdf0e10cSrcweir } 684*cdf0e10cSrcweir 685*cdf0e10cSrcweir sal_Bool SAL_CALL TextLayout::supportsService( const ::rtl::OUString& ServiceName ) throw( uno::RuntimeException ) 686*cdf0e10cSrcweir { 687*cdf0e10cSrcweir return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME ) ); 688*cdf0e10cSrcweir } 689*cdf0e10cSrcweir 690*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > SAL_CALL TextLayout::getSupportedServiceNames() throw( uno::RuntimeException ) 691*cdf0e10cSrcweir { 692*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > aRet(1); 693*cdf0e10cSrcweir aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) ); 694*cdf0e10cSrcweir 695*cdf0e10cSrcweir return aRet; 696*cdf0e10cSrcweir } 697*cdf0e10cSrcweir } 698