1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
20 #include <sal/config.h>
21 #include <sal/log.hxx>
25 #include <sal/types.h>
32 #include <i18nlangtag/mslangid.hxx>
33 #include <jobdata.hxx>
34 #include <vcl/settings.hxx>
35 #include <vcl/svapp.hxx>
36 #include <vcl/sysdata.hxx>
37 #include <vcl/fontcharmap.hxx>
38 #include <config_cairo_canvas.h>
40 #include <fontsubset.hxx>
41 #include <unx/freetype_glyphcache.hxx>
42 #include <unx/geninst.h>
43 #include <unx/genpspgraphics.h>
44 #include <langboost.hxx>
45 #include <font/LogicalFontInstance.hxx>
46 #include <fontattributes.hxx>
47 #include <font/FontMetricData.hxx>
48 #include <font/FontSelectPattern.hxx>
49 #include <font/PhysicalFontCollection.hxx>
50 #include <font/PhysicalFontFace.hxx>
51 #include <o3tl/string_view.hxx>
52 #include <sallayout.hxx>
56 /*******************************************************
58 *******************************************************/
60 GenPspGraphics::GenPspGraphics()
61 : m_pJobData( nullptr )
62 , m_aTextRenderImpl(m_aCairoCommon
)
63 , m_pBackend(new SvpGraphicsBackend(m_aCairoCommon
))
67 void GenPspGraphics::Init(psp::JobData
* pJob
)
70 SetLayout( SalLayoutFlags::NONE
);
73 GenPspGraphics::~GenPspGraphics()
78 void GenPspGraphics::GetResolution( sal_Int32
&rDPIX
, sal_Int32
&rDPIY
)
80 if (m_pJobData
!= nullptr)
82 int x
= m_pJobData
->m_aContext
.getRenderResolution();
89 void GenPspGraphics::DrawTextLayout(const GenericSalLayout
& rLayout
)
91 m_aTextRenderImpl
.DrawTextLayout(rLayout
, *this);
94 FontCharMapRef
GenPspGraphics::GetFontCharMap() const
96 return m_aTextRenderImpl
.GetFontCharMap();
99 bool GenPspGraphics::GetFontCapabilities(vcl::FontCapabilities
&rFontCapabilities
) const
101 return m_aTextRenderImpl
.GetFontCapabilities(rFontCapabilities
);
104 void GenPspGraphics::SetFont(LogicalFontInstance
*pFontInstance
, int nFallbackLevel
)
106 m_aTextRenderImpl
.SetFont(pFontInstance
, nFallbackLevel
);
109 void GenPspGraphics::SetTextColor( Color nColor
)
111 m_aTextRenderImpl
.SetTextColor(nColor
);
114 bool GenPspGraphics::AddTempDevFont( vcl::font::PhysicalFontCollection
* pFontCollection
,
115 const OUString
& rFileURL
,
116 const OUString
& rFontName
)
118 return m_aTextRenderImpl
.AddTempDevFont(pFontCollection
, rFileURL
, rFontName
);
121 void GenPspGraphics::GetDevFontList( vcl::font::PhysicalFontCollection
*pFontCollection
)
123 m_aTextRenderImpl
.GetDevFontList(pFontCollection
);
126 void GenPspGraphics::ClearDevFontCache()
128 m_aTextRenderImpl
.ClearDevFontCache();
131 void GenPspGraphics::GetFontMetric(FontMetricDataRef
& rxFontMetric
, int nFallbackLevel
)
133 m_aTextRenderImpl
.GetFontMetric(rxFontMetric
, nFallbackLevel
);
136 std::unique_ptr
<GenericSalLayout
> GenPspGraphics::GetTextLayout(int nFallbackLevel
)
138 return m_aTextRenderImpl
.GetTextLayout(nFallbackLevel
);
143 const char* getLangBoost()
145 const char* pLangBoost
;
146 const LanguageType eLang
= Application::GetSettings().GetUILanguageTag().getLanguageType();
147 if (eLang
== LANGUAGE_JAPANESE
)
149 else if (MsLangId::isKorean(eLang
))
151 else if (MsLangId::isSimplifiedChinese(eLang
))
153 else if (MsLangId::isTraditionalChinese(eLang
))
156 pLangBoost
= nullptr;
161 SystemGraphicsData
GenPspGraphics::GetGraphicsData() const
163 return SystemGraphicsData();
166 #if ENABLE_CAIRO_CANVAS
168 bool GenPspGraphics::SupportsCairo() const
173 cairo::SurfaceSharedPtr
GenPspGraphics::CreateSurface(const cairo::CairoSurfaceSharedPtr
& /*rSurface*/) const
175 return cairo::SurfaceSharedPtr();
178 cairo::SurfaceSharedPtr
GenPspGraphics::CreateSurface(const OutputDevice
& /*rRefDevice*/, int /*x*/, int /*y*/, int /*width*/, int /*height*/) const
180 return cairo::SurfaceSharedPtr();
183 cairo::SurfaceSharedPtr
GenPspGraphics::CreateBitmapSurface(const OutputDevice
& /*rRefDevice*/, const BitmapSystemData
& /*rData*/, const Size
& /*rSize*/) const
185 return cairo::SurfaceSharedPtr();
188 css::uno::Any
GenPspGraphics::GetNativeSurfaceHandle(cairo::SurfaceSharedPtr
& /*rSurface*/, const basegfx::B2ISize
& /*rSize*/) const
190 return css::uno::Any();
193 #endif // ENABLE_CAIRO_CANVAS
195 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */