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 <canvas/debug.hxx> 32*cdf0e10cSrcweir #include <tools/diagnose_ex.h> 33*cdf0e10cSrcweir #include <canvas/verbosetrace.hxx> 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx> 36*cdf0e10cSrcweir #include <basegfx/numeric/ftools.hxx> 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir #include "null_textlayout.hxx" 39*cdf0e10cSrcweir #include "null_spritecanvas.hxx" 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir using namespace ::com::sun::star; 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir namespace nullcanvas 45*cdf0e10cSrcweir { 46*cdf0e10cSrcweir TextLayout::TextLayout( const rendering::StringContext& aText, 47*cdf0e10cSrcweir sal_Int8 nDirection, 48*cdf0e10cSrcweir sal_Int64 /*nRandomSeed*/, 49*cdf0e10cSrcweir const CanvasFont::ImplRef& rFont ) : 50*cdf0e10cSrcweir TextLayout_Base( m_aMutex ), 51*cdf0e10cSrcweir maText( aText ), 52*cdf0e10cSrcweir maLogicalAdvancements(), 53*cdf0e10cSrcweir mpFont( rFont ), 54*cdf0e10cSrcweir mnTextDirection( nDirection ) 55*cdf0e10cSrcweir { 56*cdf0e10cSrcweir } 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir TextLayout::~TextLayout() 59*cdf0e10cSrcweir { 60*cdf0e10cSrcweir } 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir void SAL_CALL TextLayout::disposing() 63*cdf0e10cSrcweir { 64*cdf0e10cSrcweir mpFont.reset(); 65*cdf0e10cSrcweir } 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir // XTextLayout 68*cdf0e10cSrcweir uno::Sequence< uno::Reference< rendering::XPolyPolygon2D > > SAL_CALL TextLayout::queryTextShapes( ) throw (uno::RuntimeException) 69*cdf0e10cSrcweir { 70*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir // TODO 73*cdf0e10cSrcweir return uno::Sequence< uno::Reference< rendering::XPolyPolygon2D > >(); 74*cdf0e10cSrcweir } 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir uno::Sequence< geometry::RealRectangle2D > SAL_CALL TextLayout::queryInkMeasures( ) throw (uno::RuntimeException) 77*cdf0e10cSrcweir { 78*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir // TODO 81*cdf0e10cSrcweir return uno::Sequence< geometry::RealRectangle2D >(); 82*cdf0e10cSrcweir } 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir uno::Sequence< geometry::RealRectangle2D > SAL_CALL TextLayout::queryMeasures( ) throw (uno::RuntimeException) 85*cdf0e10cSrcweir { 86*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir // TODO 89*cdf0e10cSrcweir return uno::Sequence< geometry::RealRectangle2D >(); 90*cdf0e10cSrcweir } 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir uno::Sequence< double > SAL_CALL TextLayout::queryLogicalAdvancements( ) throw (uno::RuntimeException) 93*cdf0e10cSrcweir { 94*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir return maLogicalAdvancements; 97*cdf0e10cSrcweir } 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir void SAL_CALL TextLayout::applyLogicalAdvancements( const uno::Sequence< double >& aAdvancements ) throw (lang::IllegalArgumentException, uno::RuntimeException) 100*cdf0e10cSrcweir { 101*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir if( aAdvancements.getLength() != maText.Length ) 104*cdf0e10cSrcweir { 105*cdf0e10cSrcweir OSL_TRACE( "TextLayout::applyLogicalAdvancements(): mismatching number of advancements" ); 106*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 107*cdf0e10cSrcweir } 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir maLogicalAdvancements = aAdvancements; 110*cdf0e10cSrcweir } 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir geometry::RealRectangle2D SAL_CALL TextLayout::queryTextBounds( ) throw (uno::RuntimeException) 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir ENSURE_OR_THROW( mpFont.get(), 117*cdf0e10cSrcweir "TextLayout::queryTextBounds(): invalid font" ); 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir // fake text bounds by either taking the advancement values, 120*cdf0e10cSrcweir // or assuming square glyph boxes (width similar to height) 121*cdf0e10cSrcweir const rendering::FontRequest& rFontRequest( mpFont->getFontRequest() ); 122*cdf0e10cSrcweir const double nFontSize( ::std::max( rFontRequest.CellSize, 123*cdf0e10cSrcweir rFontRequest.ReferenceAdvancement ) ); 124*cdf0e10cSrcweir if( maLogicalAdvancements.getLength() ) 125*cdf0e10cSrcweir { 126*cdf0e10cSrcweir return geometry::RealRectangle2D( 0, -nFontSize/2, 127*cdf0e10cSrcweir maLogicalAdvancements[ maLogicalAdvancements.getLength()-1 ], 128*cdf0e10cSrcweir nFontSize/2 ); 129*cdf0e10cSrcweir } 130*cdf0e10cSrcweir else 131*cdf0e10cSrcweir { 132*cdf0e10cSrcweir return geometry::RealRectangle2D( 0, -nFontSize/2, 133*cdf0e10cSrcweir nFontSize * maText.Length, 134*cdf0e10cSrcweir nFontSize/2 ); 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir } 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir double SAL_CALL TextLayout::justify( double /*nSize*/ ) throw (lang::IllegalArgumentException, uno::RuntimeException) 139*cdf0e10cSrcweir { 140*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir // TODO 143*cdf0e10cSrcweir return 0.0; 144*cdf0e10cSrcweir } 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir double SAL_CALL TextLayout::combinedJustify( const uno::Sequence< uno::Reference< rendering::XTextLayout > >& /*aNextLayouts*/, 147*cdf0e10cSrcweir double /*nSize*/ ) throw (lang::IllegalArgumentException, uno::RuntimeException) 148*cdf0e10cSrcweir { 149*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir // TODO 152*cdf0e10cSrcweir return 0.0; 153*cdf0e10cSrcweir } 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir rendering::TextHit SAL_CALL TextLayout::getTextHit( const geometry::RealPoint2D& /*aHitPoint*/ ) throw (uno::RuntimeException) 156*cdf0e10cSrcweir { 157*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir // TODO 160*cdf0e10cSrcweir return rendering::TextHit(); 161*cdf0e10cSrcweir } 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir rendering::Caret SAL_CALL TextLayout::getCaret( sal_Int32 /*nInsertionIndex*/, 164*cdf0e10cSrcweir sal_Bool /*bExcludeLigatures*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 165*cdf0e10cSrcweir { 166*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir // TODO 169*cdf0e10cSrcweir return rendering::Caret(); 170*cdf0e10cSrcweir } 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir sal_Int32 SAL_CALL TextLayout::getNextInsertionIndex( sal_Int32 /*nStartIndex*/, 173*cdf0e10cSrcweir sal_Int32 /*nCaretAdvancement*/, 174*cdf0e10cSrcweir sal_Bool /*bExcludeLigatures*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 175*cdf0e10cSrcweir { 176*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir // TODO 179*cdf0e10cSrcweir return 0; 180*cdf0e10cSrcweir } 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir uno::Reference< rendering::XPolyPolygon2D > SAL_CALL TextLayout::queryVisualHighlighting( sal_Int32 /*nStartIndex*/, 183*cdf0e10cSrcweir sal_Int32 /*nEndIndex*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 184*cdf0e10cSrcweir { 185*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir // TODO 188*cdf0e10cSrcweir return uno::Reference< rendering::XPolyPolygon2D >(); 189*cdf0e10cSrcweir } 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir uno::Reference< rendering::XPolyPolygon2D > SAL_CALL TextLayout::queryLogicalHighlighting( sal_Int32 /*nStartIndex*/, 192*cdf0e10cSrcweir sal_Int32 /*nEndIndex*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 193*cdf0e10cSrcweir { 194*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir // TODO 197*cdf0e10cSrcweir return uno::Reference< rendering::XPolyPolygon2D >(); 198*cdf0e10cSrcweir } 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir double SAL_CALL TextLayout::getBaselineOffset( ) throw (uno::RuntimeException) 201*cdf0e10cSrcweir { 202*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir // TODO 205*cdf0e10cSrcweir return 0.0; 206*cdf0e10cSrcweir } 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir sal_Int8 SAL_CALL TextLayout::getMainTextDirection( ) throw (uno::RuntimeException) 209*cdf0e10cSrcweir { 210*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir return mnTextDirection; 213*cdf0e10cSrcweir } 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir uno::Reference< rendering::XCanvasFont > SAL_CALL TextLayout::getFont( ) throw (uno::RuntimeException) 216*cdf0e10cSrcweir { 217*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir return mpFont.getRef(); 220*cdf0e10cSrcweir } 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir rendering::StringContext SAL_CALL TextLayout::getText( ) throw (uno::RuntimeException) 223*cdf0e10cSrcweir { 224*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir return maText; 227*cdf0e10cSrcweir } 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir bool TextLayout::draw( const rendering::ViewState& /*rViewState*/, 230*cdf0e10cSrcweir const rendering::RenderState& /*rRenderState*/, 231*cdf0e10cSrcweir const uno::Reference< rendering::XGraphicDevice >& /*xGraphicDevice*/ ) const 232*cdf0e10cSrcweir { 233*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir // TODO 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir return true; 238*cdf0e10cSrcweir } 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir #define SERVICE_NAME "com.sun.star.rendering.TextLayout" 242*cdf0e10cSrcweir #define IMPLEMENTATION_NAME "NullCanvas::TextLayout" 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir ::rtl::OUString SAL_CALL TextLayout::getImplementationName() throw( uno::RuntimeException ) 245*cdf0e10cSrcweir { 246*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATION_NAME ) ); 247*cdf0e10cSrcweir } 248*cdf0e10cSrcweir 249*cdf0e10cSrcweir sal_Bool SAL_CALL TextLayout::supportsService( const ::rtl::OUString& ServiceName ) throw( uno::RuntimeException ) 250*cdf0e10cSrcweir { 251*cdf0e10cSrcweir return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME ) ); 252*cdf0e10cSrcweir } 253*cdf0e10cSrcweir 254*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > SAL_CALL TextLayout::getSupportedServiceNames() throw( uno::RuntimeException ) 255*cdf0e10cSrcweir { 256*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > aRet(1); 257*cdf0e10cSrcweir aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) ); 258*cdf0e10cSrcweir 259*cdf0e10cSrcweir return aRet; 260*cdf0e10cSrcweir } 261*cdf0e10cSrcweir } 262