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 _DXCANVAS_CANVASFONT_HXX
25 #define _DXCANVAS_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/rendering/XCanvas.hpp>
34 #include <com/sun/star/rendering/XCanvasFont.hpp>
35 
36 #include <rtl/ref.hxx>
37 
38 #include <boost/shared_ptr.hpp>
39 #include <boost/utility.hpp>
40 
41 #include "dx_winstuff.hxx"
42 #include "dx_gdiplususer.hxx"
43 
44 
45 /* Definition of CanvasFont class */
46 
47 namespace dxcanvas
48 {
49     class SpriteCanvas;
50 
51 	typedef ::boost::shared_ptr< Gdiplus::Font > 		FontSharedPtr;
52     typedef ::boost::shared_ptr< Gdiplus::FontFamily > 	FontFamilySharedPtr;
53 
54     typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::rendering::XCanvasFont,
55                          					  ::com::sun::star::lang::XServiceInfo > CanvasFont_Base;
56 
57     class CanvasFont : public ::comphelper::OBaseMutex,
58                        public CanvasFont_Base,
59                        private ::boost::noncopyable
60     {
61     public:
62         typedef ::comphelper::ImplementationReference<
63             CanvasFont,
64             ::com::sun::star::rendering::XCanvasFont > ImplRef;
65 
66         CanvasFont( const ::com::sun::star::rendering::FontRequest&                                     fontRequest,
67                     const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& 	extraFontProperties,
68                     const ::com::sun::star::geometry::Matrix2D&                                         fontMatrix );
69 
70         /// Dispose all internal references
71         virtual void SAL_CALL disposing();
72 
73         // XCanvasFont
74         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);
75         virtual ::com::sun::star::rendering::FontRequest SAL_CALL getFontRequest(  ) throw (::com::sun::star::uno::RuntimeException);
76         virtual ::com::sun::star::rendering::FontMetrics SAL_CALL getFontMetrics(  ) throw (::com::sun::star::uno::RuntimeException);
77         virtual ::com::sun::star::uno::Sequence< double > SAL_CALL getAvailableSizes(  ) throw (::com::sun::star::uno::RuntimeException);
78         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getExtraFontProperties(  ) throw (::com::sun::star::uno::RuntimeException);
79 
80         // XServiceInfo
81         virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
82         virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( ::com::sun::star::uno::RuntimeException );
83         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()  throw( ::com::sun::star::uno::RuntimeException );
84 
85         double				getCellAscent() const;
86         double				getEmHeight() const;
87         FontSharedPtr 		getFont() const;
88 		const ::com::sun::star::geometry::Matrix2D& getFontMatrix() const;
89 
90     private:
91         GDIPlusUserSharedPtr						mpGdiPlusUser;
92         FontFamilySharedPtr							mpFontFamily;
93         FontSharedPtr								mpFont;
94         ::com::sun::star::rendering::FontRequest	maFontRequest;
95 		::com::sun::star::geometry::Matrix2D		maFontMatrix;
96     };
97 
98 }
99 
100 #endif /* _DXCANVAS_CANVASFONT_HXX */
101