1*25b11142SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*25b11142SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*25b11142SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*25b11142SAndrew Rist * distributed with this work for additional information 6*25b11142SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*25b11142SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*25b11142SAndrew Rist * "License"); you may not use this file except in compliance 9*25b11142SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*25b11142SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*25b11142SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*25b11142SAndrew Rist * software distributed under the License is distributed on an 15*25b11142SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*25b11142SAndrew Rist * KIND, either express or implied. See the License for the 17*25b11142SAndrew Rist * specific language governing permissions and limitations 18*25b11142SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*25b11142SAndrew Rist *************************************************************/ 21*25b11142SAndrew Rist 22*25b11142SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_cppcanvas.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <impltext.hxx> 28cdf0e10cSrcweir #include <canvas/canvastools.hxx> 29cdf0e10cSrcweir 30cdf0e10cSrcweir #ifndef _COM_SUN_STAR_RENDERING_TEXTDIRECTION_HPP__ 31cdf0e10cSrcweir #include <com/sun/star/rendering/TextDirection.hpp> 32cdf0e10cSrcweir #endif 33cdf0e10cSrcweir #ifndef _COM_SUN_STAR_RENDERING_XCANVAS_HPP__ 34cdf0e10cSrcweir #include <com/sun/star/rendering/XCanvas.hpp> 35cdf0e10cSrcweir #endif 36cdf0e10cSrcweir #ifndef _COM_SUN_STAR_RENDERING_STRINGCONTEXT_HPP__ 37cdf0e10cSrcweir #include <com/sun/star/rendering/StringContext.hpp> 38cdf0e10cSrcweir #endif 39cdf0e10cSrcweir #include <rtl/ustring.hxx> 40cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx> 41cdf0e10cSrcweir 42cdf0e10cSrcweir 43cdf0e10cSrcweir using namespace ::com::sun::star; 44cdf0e10cSrcweir 45cdf0e10cSrcweir namespace cppcanvas 46cdf0e10cSrcweir { 47cdf0e10cSrcweir namespace internal 48cdf0e10cSrcweir { 49cdf0e10cSrcweir 50cdf0e10cSrcweir ImplText::ImplText( const CanvasSharedPtr& rParentCanvas, 51cdf0e10cSrcweir const ::rtl::OUString& rText ) : 52cdf0e10cSrcweir CanvasGraphicHelper( rParentCanvas ), 53cdf0e10cSrcweir mpFont(), 54cdf0e10cSrcweir maText(rText) 55cdf0e10cSrcweir { 56cdf0e10cSrcweir } 57cdf0e10cSrcweir 58cdf0e10cSrcweir ImplText::~ImplText() 59cdf0e10cSrcweir { 60cdf0e10cSrcweir } 61cdf0e10cSrcweir 62cdf0e10cSrcweir bool ImplText::draw() const 63cdf0e10cSrcweir { 64cdf0e10cSrcweir CanvasSharedPtr pCanvas( getCanvas() ); 65cdf0e10cSrcweir 66cdf0e10cSrcweir OSL_ENSURE( pCanvas.get() != NULL && 67cdf0e10cSrcweir pCanvas->getUNOCanvas().is(), 68cdf0e10cSrcweir "ImplBitmap::draw: invalid canvas" ); 69cdf0e10cSrcweir 70cdf0e10cSrcweir rendering::StringContext aText; 71cdf0e10cSrcweir aText.Text = maText; 72cdf0e10cSrcweir aText.StartPosition = 0; 73cdf0e10cSrcweir aText.Length = maText.getLength(); 74cdf0e10cSrcweir 75cdf0e10cSrcweir // TODO(P1): implement caching 76cdf0e10cSrcweir // TODO(F2): where to get current BiDi status? 77cdf0e10cSrcweir sal_Int8 nBidiOption = rendering::TextDirection::WEAK_LEFT_TO_RIGHT; 78cdf0e10cSrcweir pCanvas->getUNOCanvas()->drawText( aText, 79cdf0e10cSrcweir mpFont->getUNOFont(), 80cdf0e10cSrcweir pCanvas->getViewState(), 81cdf0e10cSrcweir getRenderState(), 82cdf0e10cSrcweir nBidiOption ); 83cdf0e10cSrcweir 84cdf0e10cSrcweir return true; 85cdf0e10cSrcweir } 86cdf0e10cSrcweir 87cdf0e10cSrcweir void ImplText::setFont( const FontSharedPtr& rFont ) 88cdf0e10cSrcweir { 89cdf0e10cSrcweir mpFont = rFont; 90cdf0e10cSrcweir } 91cdf0e10cSrcweir 92cdf0e10cSrcweir FontSharedPtr ImplText::getFont() 93cdf0e10cSrcweir { 94cdf0e10cSrcweir return mpFont; 95cdf0e10cSrcweir } 96cdf0e10cSrcweir } 97cdf0e10cSrcweir } 98