Avoid potential negative array index access to cached text.
[LibreOffice.git] / vcl / headless / svpgdi.cxx
blobc9edd7e9a19c5f20e7f7d01f63c827a801bf66de
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 .
20 #include <config_features.h>
22 #include <memory>
23 #include <numeric>
25 #include <headless/svpgdi.hxx>
26 #include <comphelper/lok.hxx>
28 SvpSalGraphics::SvpSalGraphics()
29 : m_aTextRenderImpl(m_aCairoCommon)
30 , m_pBackend(new SvpGraphicsBackend(m_aCairoCommon))
32 bool bLOKActive = comphelper::LibreOfficeKit::isActive();
33 initWidgetDrawBackends(bLOKActive);
36 SvpSalGraphics::~SvpSalGraphics()
38 ReleaseFonts();
41 void SvpSalGraphics::setSurface(cairo_surface_t* pSurface, const basegfx::B2IVector& rSize)
43 m_aCairoCommon.m_pSurface = pSurface;
44 m_aCairoCommon.m_aFrameSize = rSize;
45 dl_cairo_surface_get_device_scale(pSurface, &m_aCairoCommon.m_fScale, nullptr);
46 GetImpl()->ResetClipRegion();
49 void SvpSalGraphics::GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY )
51 rDPIX = rDPIY = 96;
54 bool SvpSalGraphics::ShouldDownscaleIconsAtSurface(double* pScaleOut) const
56 if (comphelper::LibreOfficeKit::isActive())
57 return SalGraphics::ShouldDownscaleIconsAtSurface(pScaleOut);
58 if (pScaleOut)
59 *pScaleOut = m_aCairoCommon.m_fScale;
60 return true;
63 #if ENABLE_CAIRO_CANVAS
64 bool SvpSalGraphics::SupportsCairo() const
66 return false;
69 cairo::SurfaceSharedPtr SvpSalGraphics::CreateSurface(const cairo::CairoSurfaceSharedPtr& /*rSurface*/) const
71 return cairo::SurfaceSharedPtr();
74 cairo::SurfaceSharedPtr SvpSalGraphics::CreateSurface(const OutputDevice& /*rRefDevice*/, int /*x*/, int /*y*/, int /*width*/, int /*height*/) const
76 return cairo::SurfaceSharedPtr();
79 cairo::SurfaceSharedPtr SvpSalGraphics::CreateBitmapSurface(const OutputDevice& /*rRefDevice*/, const BitmapSystemData& /*rData*/, const Size& /*rSize*/) const
81 return cairo::SurfaceSharedPtr();
84 css::uno::Any SvpSalGraphics::GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& /*rSurface*/, const basegfx::B2ISize& /*rSize*/) const
86 return css::uno::Any();
89 #endif // ENABLE_CAIRO_CANVAS
91 SystemGraphicsData SvpSalGraphics::GetGraphicsData() const
93 SystemGraphicsData aGraphicsData;
94 aGraphicsData.pSurface = m_aCairoCommon.m_pSurface;
95 return aGraphicsData;
98 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */