LibreOffice Module canvas (master)  1
dx_canvasfont.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #pragma once
21 
22 #include <cppuhelper/compbase.hxx>
23 #include <cppuhelper/basemutex.hxx>
24 
25 #include <com/sun/star/lang/XServiceInfo.hpp>
26 #include <com/sun/star/rendering/XCanvas.hpp>
27 #include <com/sun/star/rendering/XCanvasFont.hpp>
28 
29 #include <rtl/ref.hxx>
30 
31 #include <memory>
32 
33 #include "dx_winstuff.hxx"
34 #include "dx_gdiplususer.hxx"
35 
36 
37 /* Definition of CanvasFont class */
38 
39 namespace dxcanvas
40 {
41  typedef std::shared_ptr< Gdiplus::Font > FontSharedPtr;
42  typedef std::shared_ptr< Gdiplus::FontFamily > FontFamilySharedPtr;
43 
44  typedef ::cppu::WeakComponentImplHelper< css::rendering::XCanvasFont,
45  css::lang::XServiceInfo > CanvasFont_Base;
46 
47  class CanvasFont : public ::cppu::BaseMutex,
48  public CanvasFont_Base
49  {
50  public:
53  CanvasFont(const CanvasFont&) = delete;
54  const CanvasFont& operator=(const CanvasFont&) = delete;
55 
56  CanvasFont( const css::rendering::FontRequest& fontRequest,
57  const css::uno::Sequence< css::beans::PropertyValue >& extraFontProperties,
58  const css::geometry::Matrix2D& fontMatrix );
59 
61  virtual void SAL_CALL disposing() override;
62 
63  // XCanvasFont
64  virtual css::uno::Reference< css::rendering::XTextLayout > SAL_CALL createTextLayout( const css::rendering::StringContext& aText, sal_Int8 nDirection, sal_Int64 nRandomSeed ) override;
65  virtual css::rendering::FontRequest SAL_CALL getFontRequest( ) override;
66  virtual css::rendering::FontMetrics SAL_CALL getFontMetrics( ) override;
67  virtual css::uno::Sequence< double > SAL_CALL getAvailableSizes( ) override;
68  virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getExtraFontProperties( ) override;
69 
70  // XServiceInfo
71  virtual OUString SAL_CALL getImplementationName() override;
72  virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
73  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
74 
75  double getCellAscent() const;
76  double getEmHeight() const;
77  FontSharedPtr getFont() const;
78  const css::geometry::Matrix2D& getFontMatrix() const;
79  sal_uInt32 getEmphasisMark() const { return mnEmphasisMark; }
80 
81  private:
83  FontFamilySharedPtr mpFontFamily;
84  FontSharedPtr mpFont;
85  css::rendering::FontRequest maFontRequest;
86  sal_uInt32 mnEmphasisMark;
87  css::geometry::Matrix2D maFontMatrix;
88  };
89 
90 }
91 
92 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const CanvasFont & operator=(const CanvasFont &)=delete
const css::geometry::Matrix2D & getFontMatrix() const
signed char sal_Int8
std::shared_ptr< Gdiplus::FontFamily > FontFamilySharedPtr
FontSharedPtr mpFont
virtual css::rendering::FontMetrics SAL_CALL getFontMetrics() override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
CanvasFont(const CanvasFont &)=delete
make noncopyable
sal_uInt32 getEmphasisMark() const
virtual void SAL_CALL disposing() override
Dispose all internal references.
FontSharedPtr getFont() const
std::shared_ptr< Gdiplus::Font > FontSharedPtr
GDIPlusUserSharedPtr mpGdiPlusUser
virtual css::uno::Sequence< double > SAL_CALL getAvailableSizes() override
virtual css::rendering::FontRequest SAL_CALL getFontRequest() override
double getEmHeight() const
unsigned char sal_Bool
css::geometry::Matrix2D maFontMatrix
FontFamilySharedPtr mpFontFamily
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual OUString SAL_CALL getImplementationName() override
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getExtraFontProperties() override
GDIPlusUser::GDIPlusUserSharedPtr GDIPlusUserSharedPtr
rtl::Reference< CanvasFont > ImplRef
::cppu::WeakComponentImplHelper< css::rendering::XCanvasFont, css::lang::XServiceInfo > CanvasFont_Base
double getCellAscent() const
css::rendering::FontRequest maFontRequest
virtual css::uno::Reference< css::rendering::XTextLayout > SAL_CALL createTextLayout(const css::rendering::StringContext &aText, sal_Int8 nDirection, sal_Int64 nRandomSeed) override