1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_cppcanvas.hxx" 26 27 #include <implfont.hxx> 28 #include <canvas/canvastools.hxx> 29 30 31 using namespace ::com::sun::star; 32 33 /* Definition of Font class */ 34 35 namespace cppcanvas 36 { 37 namespace internal 38 { 39 ImplFont(const uno::Reference<rendering::XCanvas> & rCanvas,const::rtl::OUString & rFontName,const double & rCellSize)40 ImplFont::ImplFont( const uno::Reference< rendering::XCanvas >& rCanvas, 41 const ::rtl::OUString& rFontName, 42 const double& rCellSize ) : 43 mxCanvas( rCanvas ), 44 mxFont( NULL ) 45 { 46 OSL_ENSURE( mxCanvas.is(), "ImplFont::ImplFont(): Invalid Canvas" ); 47 48 rendering::FontRequest aFontRequest; 49 aFontRequest.FontDescription.FamilyName = rFontName; 50 aFontRequest.CellSize = rCellSize; 51 52 geometry::Matrix2D aFontMatrix; 53 ::canvas::tools::setIdentityMatrix2D( aFontMatrix ); 54 55 mxFont = mxCanvas->createFont( aFontRequest, 56 uno::Sequence< beans::PropertyValue >(), 57 aFontMatrix ); 58 } 59 60 ~ImplFont()61 ImplFont::~ImplFont() 62 { 63 } 64 getName() const65 ::rtl::OUString ImplFont::getName() const 66 { 67 OSL_ENSURE( mxFont.is(), "ImplFont::getName(): Invalid Font" ); 68 69 return mxFont->getFontRequest().FontDescription.FamilyName; 70 } 71 getCellSize() const72 double ImplFont::getCellSize() const 73 { 74 OSL_ENSURE( mxFont.is(), "ImplFont::getCellSize(): Invalid Font" ); 75 76 return mxFont->getFontRequest().CellSize; 77 } 78 getUNOFont() const79 uno::Reference< rendering::XCanvasFont > ImplFont::getUNOFont() const 80 { 81 OSL_ENSURE( mxFont.is(), "ImplFont::getUNOFont(): Invalid Font" ); 82 83 return mxFont; 84 } 85 86 } 87 } 88