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
10*25b11142SAndrew Rist  *
11*25b11142SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*25b11142SAndrew Rist  *
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.
19*25b11142SAndrew Rist  *
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 <implfont.hxx>
28cdf0e10cSrcweir #include <canvas/canvastools.hxx>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir 
31cdf0e10cSrcweir using namespace ::com::sun::star;
32cdf0e10cSrcweir 
33cdf0e10cSrcweir /* Definition of Font class */
34cdf0e10cSrcweir 
35cdf0e10cSrcweir namespace cppcanvas
36cdf0e10cSrcweir {
37cdf0e10cSrcweir     namespace internal
38cdf0e10cSrcweir     {
39cdf0e10cSrcweir 
ImplFont(const uno::Reference<rendering::XCanvas> & rCanvas,const::rtl::OUString & rFontName,const double & rCellSize)40cdf0e10cSrcweir         ImplFont::ImplFont( const uno::Reference< rendering::XCanvas >& rCanvas,
41cdf0e10cSrcweir                             const ::rtl::OUString& rFontName,
42cdf0e10cSrcweir                             const double& rCellSize ) :
43cdf0e10cSrcweir             mxCanvas( rCanvas ),
44cdf0e10cSrcweir             mxFont( NULL )
45cdf0e10cSrcweir         {
46cdf0e10cSrcweir             OSL_ENSURE( mxCanvas.is(), "ImplFont::ImplFont(): Invalid Canvas" );
47cdf0e10cSrcweir 
48cdf0e10cSrcweir             rendering::FontRequest aFontRequest;
49cdf0e10cSrcweir             aFontRequest.FontDescription.FamilyName = rFontName;
50cdf0e10cSrcweir             aFontRequest.CellSize = rCellSize;
51cdf0e10cSrcweir 
52cdf0e10cSrcweir             geometry::Matrix2D aFontMatrix;
53cdf0e10cSrcweir             ::canvas::tools::setIdentityMatrix2D( aFontMatrix );
54cdf0e10cSrcweir 
55cdf0e10cSrcweir             mxFont = mxCanvas->createFont( aFontRequest,
56cdf0e10cSrcweir                                            uno::Sequence< beans::PropertyValue >(),
57cdf0e10cSrcweir                                            aFontMatrix );
58cdf0e10cSrcweir         }
59cdf0e10cSrcweir 
60cdf0e10cSrcweir 
~ImplFont()61cdf0e10cSrcweir         ImplFont::~ImplFont()
62cdf0e10cSrcweir         {
63cdf0e10cSrcweir         }
64cdf0e10cSrcweir 
getName() const65cdf0e10cSrcweir         ::rtl::OUString ImplFont::getName() const
66cdf0e10cSrcweir         {
67cdf0e10cSrcweir             OSL_ENSURE( mxFont.is(), "ImplFont::getName(): Invalid Font" );
68cdf0e10cSrcweir 
69cdf0e10cSrcweir             return mxFont->getFontRequest().FontDescription.FamilyName;
70cdf0e10cSrcweir         }
71cdf0e10cSrcweir 
getCellSize() const72cdf0e10cSrcweir         double ImplFont::getCellSize() const
73cdf0e10cSrcweir         {
74cdf0e10cSrcweir             OSL_ENSURE( mxFont.is(), "ImplFont::getCellSize(): Invalid Font" );
75cdf0e10cSrcweir 
76cdf0e10cSrcweir             return mxFont->getFontRequest().CellSize;
77cdf0e10cSrcweir         }
78cdf0e10cSrcweir 
getUNOFont() const79cdf0e10cSrcweir         uno::Reference< rendering::XCanvasFont > ImplFont::getUNOFont() const
80cdf0e10cSrcweir         {
81cdf0e10cSrcweir             OSL_ENSURE( mxFont.is(), "ImplFont::getUNOFont(): Invalid Font" );
82cdf0e10cSrcweir 
83cdf0e10cSrcweir             return mxFont;
84cdf0e10cSrcweir         }
85cdf0e10cSrcweir 
86cdf0e10cSrcweir     }
87cdf0e10cSrcweir }
88