2017-10-21 13:50:30 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
|
|
|
|
2018-06-01 15:28:26 +02:00
|
|
|
#include <Qt5Graphics.hxx>
|
2017-10-30 16:11:09 +01:00
|
|
|
|
2018-07-06 13:12:05 +02:00
|
|
|
#include <Qt5Font.hxx>
|
2018-06-01 15:28:26 +02:00
|
|
|
#include <Qt5Frame.hxx>
|
|
|
|
#include <Qt5Painter.hxx>
|
2017-10-30 16:11:09 +01:00
|
|
|
|
2017-10-31 01:07:06 +01:00
|
|
|
#include <QtGui/QImage>
|
2017-12-26 15:58:21 +01:00
|
|
|
#include <QtGui/QPainter>
|
2018-08-06 17:22:29 +02:00
|
|
|
#include <QtWidgets/QPushButton>
|
2017-12-26 15:58:21 +01:00
|
|
|
#include <QtWidgets/QWidget>
|
2017-10-31 01:07:06 +01:00
|
|
|
|
2017-10-30 20:22:56 +01:00
|
|
|
Qt5Graphics::Qt5Graphics( Qt5Frame *pFrame, QImage *pQImage )
|
2017-10-31 01:07:06 +01:00
|
|
|
: m_pFrame( pFrame )
|
|
|
|
, m_pQImage( pQImage )
|
2018-03-14 11:11:02 +02:00
|
|
|
, m_aLineColor( 0x00, 0x00, 0x00 )
|
|
|
|
, m_aFillColor( 0xFF, 0xFF, 0XFF )
|
2017-10-30 20:22:56 +01:00
|
|
|
, m_eCompositionMode( QPainter::CompositionMode_SourceOver )
|
2017-10-31 01:10:36 +01:00
|
|
|
, m_pFontCollection( nullptr )
|
2017-10-30 19:05:41 +01:00
|
|
|
, m_pTextStyle{ nullptr, }
|
2018-03-14 11:11:02 +02:00
|
|
|
, m_aTextColor( 0x00, 0x00, 0x00 )
|
2017-10-21 13:50:30 +00:00
|
|
|
{
|
2017-12-09 23:12:02 +00:00
|
|
|
ResetClipRegion();
|
2017-10-21 13:50:30 +00:00
|
|
|
}
|
|
|
|
|
2017-12-26 15:58:21 +01:00
|
|
|
Qt5Graphics::~Qt5Graphics()
|
|
|
|
{
|
|
|
|
// release the text styles
|
|
|
|
for (int i = 0; i < MAX_FALLBACK; ++i)
|
|
|
|
{
|
|
|
|
if (!m_pTextStyle[i])
|
|
|
|
break;
|
2018-06-10 05:59:31 +02:00
|
|
|
m_pTextStyle[i].clear();
|
2017-12-26 15:58:21 +01:00
|
|
|
}
|
|
|
|
}
|
2017-10-21 13:50:30 +00:00
|
|
|
|
2017-11-08 11:28:04 +01:00
|
|
|
void Qt5Graphics::ChangeQImage(QImage* pQImage)
|
2017-10-31 01:07:06 +01:00
|
|
|
{
|
|
|
|
m_pQImage = pQImage;
|
2017-10-30 20:19:45 +01:00
|
|
|
ResetClipRegion();
|
2017-10-31 01:07:06 +01:00
|
|
|
}
|
|
|
|
|
2017-11-08 11:28:04 +01:00
|
|
|
SalGraphicsImpl* Qt5Graphics::GetImpl() const { return nullptr; }
|
2017-10-21 13:50:30 +00:00
|
|
|
|
2017-11-08 11:28:04 +01:00
|
|
|
SystemGraphicsData Qt5Graphics::GetGraphicsData() const { return SystemGraphicsData(); }
|
2017-10-21 13:50:30 +00:00
|
|
|
|
2017-11-08 11:28:04 +01:00
|
|
|
bool Qt5Graphics::supportsOperation(OutDevSupportType eType) const
|
2017-10-21 13:50:30 +00:00
|
|
|
{
|
2017-11-08 11:28:04 +01:00
|
|
|
switch (eType)
|
2017-10-30 20:31:42 +01:00
|
|
|
{
|
2017-11-08 11:28:04 +01:00
|
|
|
case OutDevSupportType::B2DDraw:
|
|
|
|
case OutDevSupportType::TransparentRect:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
2017-10-30 20:31:42 +01:00
|
|
|
}
|
2017-10-21 13:50:30 +00:00
|
|
|
}
|
|
|
|
|
2017-10-31 01:07:06 +01:00
|
|
|
#if ENABLE_CAIRO_CANVAS
|
|
|
|
|
2017-11-08 11:28:04 +01:00
|
|
|
bool Qt5Graphics::SupportsCairo() const { return false; }
|
2017-10-31 01:07:06 +01:00
|
|
|
|
2017-11-08 11:28:04 +01:00
|
|
|
cairo::SurfaceSharedPtr
|
2018-01-08 09:38:24 +02:00
|
|
|
Qt5Graphics::CreateSurface(const cairo::CairoSurfaceSharedPtr& /*rSurface*/) const
|
2017-10-31 01:07:06 +01:00
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2018-01-08 09:38:24 +02:00
|
|
|
cairo::SurfaceSharedPtr Qt5Graphics::CreateSurface(const OutputDevice& /*rRefDevice*/, int /*x*/,
|
|
|
|
int /*y*/, int /*width*/, int /*height*/) const
|
2017-10-31 01:07:06 +01:00
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2018-01-08 09:38:24 +02:00
|
|
|
cairo::SurfaceSharedPtr Qt5Graphics::CreateBitmapSurface(const OutputDevice& /*rRefDevice*/,
|
|
|
|
const BitmapSystemData& /*rData*/,
|
|
|
|
const Size& /*rSize*/) const
|
2017-10-31 01:07:06 +01:00
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2018-01-08 09:38:24 +02:00
|
|
|
css::uno::Any Qt5Graphics::GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& /*rSurface*/,
|
|
|
|
const basegfx::B2ISize& /*rSize*/) const
|
2017-10-31 01:07:06 +01:00
|
|
|
{
|
|
|
|
return css::uno::Any();
|
|
|
|
}
|
|
|
|
|
2018-01-08 09:38:24 +02:00
|
|
|
SystemFontData Qt5Graphics::GetSysFontData(int /*nFallbacklevel*/) const
|
|
|
|
{
|
|
|
|
return SystemFontData();
|
|
|
|
}
|
2017-10-31 01:07:06 +01:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2018-08-06 17:22:29 +02:00
|
|
|
bool Qt5Graphics::drawNativeControl(ControlType nType, ControlPart nPart,
|
|
|
|
const tools::Rectangle& rControlRegion, ControlState nState,
|
|
|
|
const ImplControlValue& aValue, const OUString& aCaption)
|
|
|
|
{
|
|
|
|
bool bHandled
|
|
|
|
= m_aControl.drawNativeControl(nType, nPart, rControlRegion, nState, aValue, aCaption);
|
|
|
|
if (bHandled)
|
|
|
|
{
|
|
|
|
Qt5Painter aPainter(*this);
|
|
|
|
aPainter.drawImage(QPoint(rControlRegion.getX(), rControlRegion.getY()),
|
|
|
|
m_aControl.getImage());
|
2018-08-09 14:53:50 +02:00
|
|
|
aPainter.update(toQRect(rControlRegion));
|
2018-08-06 17:22:29 +02:00
|
|
|
}
|
|
|
|
return bHandled;
|
|
|
|
}
|
|
|
|
|
2017-10-21 13:50:30 +00:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|