LibreOffice Module vcl (master)  1
genpspgraphics.h
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 <sal/config.h>
23 
24 #include <vcl/vclenum.hxx>
25 #include <config_cairo_canvas.h>
26 
27 #include <unx/fontmanager.hxx>
28 #include <salgdi.hxx>
29 #include <sallayout.hxx>
30 
31 #include <unx/GenPspGfxBackend.hxx>
32 
33 namespace vcl::font
34 {
35 class PhysicalFontFace;
36 class PhysicalFontCollection;
37 }
38 
39 namespace psp { struct JobData; class PrinterGfx; }
40 
42 class FontAttributes;
43 class SalInfoPrinter;
44 class ImplFontMetricData;
45 
47 {
48  std::unique_ptr<GenPspGfxBackend> m_pBackend;
49 
52 
54  m_pFreetypeFont[ MAX_FALLBACK ];
55 public:
57  virtual ~GenPspGraphics() override;
58 
59  void Init( psp::JobData* pJob, psp::PrinterGfx* pGfx );
60 
61  // helper methods
62  static const void * DoGetEmbedFontData(psp::fontID aFont, tools::Long* pDataLen);
63  static void DoFreeEmbedFontData( const void* pData, tools::Long nLen );
64 
65  // helper methods for sharing with X11SalGraphics
66  static void DoGetGlyphWidths( psp::fontID aFont,
67  bool bVertical,
68  std::vector< sal_Int32 >& rWidths,
69  Ucs2UIntMap& rUnicodeEnc );
70 
71  static FontAttributes Info2FontAttributes( const psp::FastPrintFontInfo& );
72  static void AnnounceFonts( vcl::font::PhysicalFontCollection*,
73  const psp::FastPrintFontInfo& );
74 
75  // override all pure virtual methods
76  virtual SalGraphicsImpl* GetImpl() const override
77  {
78  return m_pBackend.get();
79  }
80 
81  virtual void GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY ) override;
82 
83  virtual void SetTextColor( Color nColor ) override;
84  virtual void SetFont(LogicalFontInstance*, int nFallbackLevel) override;
85  virtual void GetFontMetric( ImplFontMetricDataRef&, int nFallbackLevel ) override;
86  virtual FontCharMapRef GetFontCharMap() const override;
87  virtual bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const override;
88  virtual void GetDevFontList( vcl::font::PhysicalFontCollection* ) override;
89  // graphics must drop any cached font info
90  virtual void ClearDevFontCache() override;
92  const OUString& rFileURL,
93  const OUString& rFontName ) override;
94  static bool AddTempDevFontHelper( vcl::font::PhysicalFontCollection* pFontCollection,
95  const OUString& rFileURL,
96  const OUString& rFontName);
97 
98  virtual bool CreateFontSubset( const OUString& rToFile,
100  const sal_GlyphId* pGlyphIDs,
101  const sal_uInt8* pEncoding,
102  sal_Int32* pWidths,
103  int nGlyphs,
104  FontSubsetInfo& rInfo ) override;
105  virtual const void* GetEmbedFontData(const vcl::font::PhysicalFontFace*, tools::Long* pDataLen) override;
106  virtual void FreeEmbedFontData( const void* pData, tools::Long nDataLen ) override;
107  virtual void GetGlyphWidths( const vcl::font::PhysicalFontFace*,
108  bool bVertical,
109  std::vector< sal_Int32 >& rWidths,
110  Ucs2UIntMap& rUnicodeEnc ) override;
111  virtual std::unique_ptr<GenericSalLayout>
112  GetTextLayout(int nFallbackLevel) override;
113  virtual void DrawTextLayout( const GenericSalLayout& ) override;
114 
115  virtual SystemGraphicsData GetGraphicsData() const override;
116 
117 #if ENABLE_CAIRO_CANVAS
118  virtual bool SupportsCairo() const override;
119  virtual cairo::SurfaceSharedPtr CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const override;
120  virtual cairo::SurfaceSharedPtr CreateSurface(const OutputDevice& rRefDevice, int x, int y, int width, int height) const override;
121  virtual cairo::SurfaceSharedPtr CreateBitmapSurface(const OutputDevice& rRefDevice, const BitmapSystemData& rData, const Size& rSize) const override;
122  virtual css::uno::Any GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface, const basegfx::B2ISize& rSize) const override;
123 #endif // ENABLE_CAIRO_CANVAS
124 };
125 
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void ClearDevFontCache()=0
psp::PrinterGfx * m_pPrinterGfx
void Init()
virtual void DrawTextLayout(const GenericSalLayout &)=0
psp::JobData * m_pJobData
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
#define MAX_FALLBACK
Definition: sallayout.hxx:46
long Long
virtual bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const =0
virtual bool AddTempDevFont(vcl::font::PhysicalFontCollection *, const OUString &rFileURL, const OUString &rFontName)=0
virtual std::unique_ptr< GenericSalLayout > GetTextLayout(int nFallbackLevel)=0
sal_uInt16 sal_GlyphId
Definition: glyphitem.hxx:29
virtual FontCharMapRef GetFontCharMap() const =0
virtual void GetGlyphWidths(const vcl::font::PhysicalFontFace *pFont, bool bVertical, std::vector< sal_Int32 > &rWidths, Ucs2UIntMap &rUnicodeEnc)=0
virtual SalGraphicsImpl * GetImpl() const override
virtual void FreeEmbedFontData(const void *pData, tools::Long nDataLen)=0
std::shared_ptr< Surface > SurfaceSharedPtr
Definition: cairo.hxx:36
virtual void GetResolution(sal_Int32 &rDPIX, sal_Int32 &rDPIY)=0
A PhysicalFontFaceCollection is created by a PhysicalFontCollection and becomes invalid when original...
virtual bool CreateFontSubset(const OUString &rToFile, const vcl::font::PhysicalFontFace *pFont, const sal_GlyphId *pGlyphIDs, const sal_uInt8 *pEncoding, sal_Int32 *pWidths, int nGlyphs, FontSubsetInfo &rInfo)=0
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:175
std::shared_ptr< cairo_surface_t > CairoSurfaceSharedPtr
Definition: cairo.hxx:34
virtual SystemGraphicsData GetGraphicsData() const =0
abstract base class for physical font faces
std::unique_ptr< GenPspGfxBackend > m_pBackend
unsigned char sal_uInt8
int fontID
Definition: fontmanager.hxx:54
virtual void GetFontMetric(ImplFontMetricDataRef &, int nFallbackLevel)=0
virtual void GetDevFontList(vcl::font::PhysicalFontCollection *)=0
virtual void SetFont(LogicalFontInstance *, int nFallbackLevel)=0
std::map< sal_Ucs, sal_uInt32 > Ucs2UIntMap
Definition: salgdi.hxx:66
virtual const void * GetEmbedFontData(const vcl::font::PhysicalFontFace *pFont, tools::Long *pDataLen)=0
virtual void SetTextColor(Color nColor)=0
Implementation class for SalGraphics.
Definition: salgdiimpl.hxx:50