nss: upgrade to release 3.73
[LibreOffice.git] / vcl / qt5 / Qt5Graphics.cxx
blobc769b4e13795c55d251564d093ad31310bb19b0b
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 <Qt5Graphics.hxx>
22 #include <Qt5Data.hxx>
23 #include <Qt5Font.hxx>
24 #include <Qt5Frame.hxx>
25 #include <Qt5Graphics_Controls.hxx>
26 #include <Qt5Painter.hxx>
28 #include <QtGui/QImage>
29 #include <QtGui/QPainter>
30 #include <QtWidgets/QPushButton>
31 #include <QtWidgets/QWidget>
33 Qt5Graphics::Qt5Graphics( Qt5Frame *pFrame, QImage *pQImage )
34 : m_pFrame( pFrame )
35 , m_pQImage( pQImage )
36 , m_aLineColor( 0x00, 0x00, 0x00 )
37 , m_aFillColor( 0xFF, 0xFF, 0XFF )
38 , m_eCompositionMode( QPainter::CompositionMode_SourceOver )
39 , m_pTextStyle{ nullptr, }
40 , m_aTextColor( 0x00, 0x00, 0x00 )
42 ResetClipRegion();
44 if (!initWidgetDrawBackends(false))
46 if (!Qt5Data::noNativeControls())
47 m_pWidgetDraw.reset(new Qt5Graphics_Controls(*this));
49 if (m_pFrame)
50 setDevicePixelRatioF(m_pFrame->devicePixelRatioF());
53 Qt5Graphics::~Qt5Graphics() { ReleaseFonts(); }
55 void Qt5Graphics::ChangeQImage(QImage* pQImage)
57 m_pQImage = pQImage;
58 ResetClipRegion();
61 SalGraphicsImpl* Qt5Graphics::GetImpl() const { return nullptr; }
63 SystemGraphicsData Qt5Graphics::GetGraphicsData() const { return SystemGraphicsData(); }
65 bool Qt5Graphics::supportsOperation(OutDevSupportType eType) const
67 switch (eType)
69 case OutDevSupportType::B2DDraw:
70 case OutDevSupportType::TransparentRect:
71 return true;
72 default:
73 return false;
77 #if ENABLE_CAIRO_CANVAS
79 bool Qt5Graphics::SupportsCairo() const { return false; }
81 cairo::SurfaceSharedPtr
82 Qt5Graphics::CreateSurface(const cairo::CairoSurfaceSharedPtr& /*rSurface*/) const
84 return nullptr;
87 cairo::SurfaceSharedPtr Qt5Graphics::CreateSurface(const OutputDevice& /*rRefDevice*/, int /*x*/,
88 int /*y*/, int /*width*/, int /*height*/) const
90 return nullptr;
93 cairo::SurfaceSharedPtr Qt5Graphics::CreateBitmapSurface(const OutputDevice& /*rRefDevice*/,
94 const BitmapSystemData& /*rData*/,
95 const Size& /*rSize*/) const
97 return nullptr;
100 css::uno::Any Qt5Graphics::GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& /*rSurface*/,
101 const basegfx::B2ISize& /*rSize*/) const
103 return css::uno::Any();
106 #endif
108 void Qt5Graphics::handleDamage(const tools::Rectangle& rDamagedRegion)
110 assert(m_pWidgetDraw);
111 assert(dynamic_cast<Qt5Graphics_Controls*>(m_pWidgetDraw.get()));
112 assert(!rDamagedRegion.IsEmpty());
114 QImage* pImage = static_cast<Qt5Graphics_Controls*>(m_pWidgetDraw.get())->getImage();
115 QImage blit(*pImage);
116 blit.setDevicePixelRatio(1);
117 Qt5Painter aPainter(*this);
118 aPainter.drawImage(QPoint(rDamagedRegion.getX(), rDamagedRegion.getY()), blit);
119 aPainter.update(toQRect(rDamagedRegion));
122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */