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 #ifndef _CAIROCANVAS_CANVASFONT_HXX
25 #define _CAIROCANVAS_CANVASFONT_HXX
26 
27 #include <comphelper/implementationreference.hxx>
28 
29 #include <cppuhelper/compbase2.hxx>
30 #include <comphelper/broadcasthelper.hxx>
31 
32 #include <com/sun/star/lang/XServiceInfo.hpp>
33 #include <com/sun/star/geometry/Matrix2D.hpp>
34 #include <com/sun/star/rendering/FontRequest.hpp>
35 #include <com/sun/star/rendering/XCanvasFont.hpp>
36 
37 #include <vcl/font.hxx>
38 
39 #include <canvas/vclwrapper.hxx>
40 
41 #include "cairo_spritecanvas.hxx"
42 
43 #include <boost/utility.hpp>
44 
45 
46 /* Definition of CanvasFont class */
47 
48 namespace cairocanvas
49 {
50     typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::rendering::XCanvasFont,
51                          					  ::com::sun::star::lang::XServiceInfo > CanvasFont_Base;
52 
53     class CanvasFont : public ::comphelper::OBaseMutex,
54                        public CanvasFont_Base,
55         			   private ::boost::noncopyable
56     {
57     public:
58         typedef ::comphelper::ImplementationReference<
59             CanvasFont,
60             ::com::sun::star::rendering::XCanvasFont > Reference;
61 
62         CanvasFont( const ::com::sun::star::rendering::FontRequest& 								 fontRequest,
63                     const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& extraFontProperties,
64                     const ::com::sun::star::geometry::Matrix2D&										 rFontMatrix,
65                     const SurfaceProviderRef&														 rDevice );
66 
67         /// Dispose all internal references
68         virtual void SAL_CALL disposing();
69 
70         // XCanvasFont
71         virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XTextLayout > SAL_CALL createTextLayout( const ::com::sun::star::rendering::StringContext& aText, sal_Int8 nDirection, sal_Int64 nRandomSeed ) throw (::com::sun::star::uno::RuntimeException);
72         virtual ::com::sun::star::rendering::FontRequest SAL_CALL getFontRequest(  ) throw (::com::sun::star::uno::RuntimeException);
73         virtual ::com::sun::star::rendering::FontMetrics SAL_CALL getFontMetrics(  ) throw (::com::sun::star::uno::RuntimeException);
74         virtual ::com::sun::star::uno::Sequence< double > SAL_CALL getAvailableSizes(  ) throw (::com::sun::star::uno::RuntimeException);
75         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getExtraFontProperties(  ) throw (::com::sun::star::uno::RuntimeException);
76 
77         // XServiceInfo
78         virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
79         virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( ::com::sun::star::uno::RuntimeException );
80         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()  throw( ::com::sun::star::uno::RuntimeException );
81 
82         ::Font getVCLFont() const;
83 
84     private:
85         ::canvas::vcltools::VCLObject<Font>		 maFont;
86         ::com::sun::star::rendering::FontRequest maFontRequest;
87         SurfaceProviderRef						 mpRefDevice;
88     };
89 
90 }
91 
92 #endif /* _CAIROCANVAS_CANVASFONT_HXX */
93