fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / canvas / source / directx / dx_canvasfont.cxx
blob57690d3325e95462c9a860aa7619e181ac705296
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <ctype.h> // don't ask. msdev breaks otherwise...
22 #include "dx_winstuff.hxx"
23 #include "dx_spritecanvas.hxx"
24 #include "dx_canvasfont.hxx"
25 #include "dx_textlayout.hxx"
27 #include <com/sun/star/rendering/XSpriteCanvas.hpp>
28 #include <com/sun/star/rendering/PanoseWeight.hpp>
30 using namespace ::com::sun::star;
32 namespace dxcanvas
34 namespace
36 INT calcFontStyle( const rendering::FontRequest& rFontRequest )
38 INT nFontStyle( Gdiplus::FontStyleRegular );
40 if( rFontRequest.FontDescription.FontDescription.Weight > rendering::PanoseWeight::BOOK )
41 nFontStyle = Gdiplus::FontStyleBold;
43 return nFontStyle;
47 CanvasFont::CanvasFont( const rendering::FontRequest& rFontRequest,
48 const uno::Sequence< beans::PropertyValue >& /*extraFontProperties*/,
49 const geometry::Matrix2D& fontMatrix ) :
50 CanvasFont_Base( m_aMutex ),
51 mpGdiPlusUser( GDIPlusUser::createInstance() ),
52 // TODO(F1): extraFontProperties, fontMatrix
53 mpFontFamily(),
54 mpFont(),
55 maFontRequest( rFontRequest ),
56 maFontMatrix( fontMatrix )
58 const sal_Int32 nLen(rFontRequest.FontDescription.FamilyName.getLength());
59 const sal_Unicode* pStr(rFontRequest.FontDescription.FamilyName.getStr());
60 std::vector< sal_Unicode > pStrBuf(nLen+1,0);
61 std::copy(pStr,pStr+nLen,&pStrBuf[0]);
63 mpFontFamily.reset( new Gdiplus::FontFamily(reinterpret_cast<LPCWSTR>(&pStrBuf[0]),NULL) );
64 if( !mpFontFamily->IsAvailable() )
65 mpFontFamily.reset( new Gdiplus::FontFamily(L"Arial",NULL) );
67 mpFont.reset( new Gdiplus::Font( mpFontFamily.get(),
68 static_cast<Gdiplus::REAL>(rFontRequest.CellSize),
69 calcFontStyle( rFontRequest ),
70 Gdiplus::UnitWorld ));
73 void SAL_CALL CanvasFont::disposing()
75 ::osl::MutexGuard aGuard( m_aMutex );
77 mpFont.reset();
78 mpFontFamily.reset();
79 mpGdiPlusUser.reset();
82 uno::Reference< rendering::XTextLayout > SAL_CALL CanvasFont::createTextLayout( const rendering::StringContext& aText,
83 sal_Int8 nDirection,
84 sal_Int64 nRandomSeed ) throw (uno::RuntimeException)
86 ::osl::MutexGuard aGuard( m_aMutex );
88 return new TextLayout( aText, nDirection, nRandomSeed, ImplRef( this ) );
91 uno::Sequence< double > SAL_CALL CanvasFont::getAvailableSizes( ) throw (uno::RuntimeException)
93 ::osl::MutexGuard aGuard( m_aMutex );
95 // TODO
96 return uno::Sequence< double >();
99 uno::Sequence< beans::PropertyValue > SAL_CALL CanvasFont::getExtraFontProperties( ) throw (uno::RuntimeException)
101 ::osl::MutexGuard aGuard( m_aMutex );
103 // TODO
104 return uno::Sequence< beans::PropertyValue >();
107 rendering::FontRequest SAL_CALL CanvasFont::getFontRequest( ) throw (uno::RuntimeException)
109 ::osl::MutexGuard aGuard( m_aMutex );
111 return maFontRequest;
114 rendering::FontMetrics SAL_CALL CanvasFont::getFontMetrics( ) throw (uno::RuntimeException)
116 ::osl::MutexGuard aGuard( m_aMutex );
118 // TODO
119 return rendering::FontMetrics();
122 #define SERVICE_NAME "com.sun.star.rendering.CanvasFont"
123 #define IMPLEMENTATION_NAME "DXCanvas::CanvasFont"
125 OUString SAL_CALL CanvasFont::getImplementationName() throw( uno::RuntimeException )
127 return OUString( IMPLEMENTATION_NAME );
130 sal_Bool SAL_CALL CanvasFont::supportsService( const OUString& ServiceName ) throw( uno::RuntimeException )
132 return ServiceName == SERVICE_NAME;
135 uno::Sequence< OUString > SAL_CALL CanvasFont::getSupportedServiceNames() throw( uno::RuntimeException )
137 uno::Sequence< OUString > aRet(1);
138 aRet[0] = SERVICE_NAME;
140 return aRet;
143 double CanvasFont::getCellAscent() const
145 ::osl::MutexGuard aGuard( m_aMutex );
147 return mpFontFamily->GetCellAscent(0); // TODO(F1): rFontRequest.styleName
150 double CanvasFont::getEmHeight() const
152 ::osl::MutexGuard aGuard( m_aMutex );
154 return mpFontFamily->GetEmHeight(0); // TODO(F1): rFontRequest.styleName
157 FontSharedPtr CanvasFont::getFont() const
159 ::osl::MutexGuard aGuard( m_aMutex );
161 return mpFont;
164 const ::com::sun::star::geometry::Matrix2D& CanvasFont::getFontMatrix() const
166 ::osl::MutexGuard aGuard( m_aMutex );
168 return maFontMatrix;
172 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */