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 .
|
|
|
|
*/
|
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
#include "Qt5Graphics.hxx"
|
2017-10-21 13:50:30 +00:00
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
#include "Qt5Bitmap.hxx"
|
|
|
|
#include "Qt5Frame.hxx"
|
|
|
|
#include "Qt5Tools.hxx"
|
2017-10-30 18:33:06 +01:00
|
|
|
|
|
|
|
#include <QtGui/QPainter>
|
|
|
|
#include <QtGui/QScreen>
|
|
|
|
#include <QtGui/QWindow>
|
|
|
|
#include <QtWidgets/QWidget>
|
|
|
|
|
2017-10-30 20:31:42 +01:00
|
|
|
static const basegfx::B2DPoint aHalfPointOfs ( 0.5, 0.5 );
|
|
|
|
|
|
|
|
static void AddPolygonToPath( QPainterPath& rPath,
|
|
|
|
const basegfx::B2DPolygon& rPolygon,
|
|
|
|
bool bClosePath, bool bPixelSnap, bool bLineDraw )
|
|
|
|
{
|
|
|
|
// short circuit if there is nothing to do
|
|
|
|
const int nPointCount = rPolygon.count();
|
|
|
|
if( nPointCount <= 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
const bool bHasCurves = rPolygon.areControlPointsUsed();
|
|
|
|
for( int nPointIdx = 0, nPrevIdx = 0;; nPrevIdx = nPointIdx++ )
|
|
|
|
{
|
|
|
|
int nClosedIdx = nPointIdx;
|
|
|
|
if( nPointIdx >= nPointCount )
|
|
|
|
{
|
|
|
|
// prepare to close last curve segment if needed
|
|
|
|
if( bClosePath && (nPointIdx == nPointCount) )
|
|
|
|
nClosedIdx = 0;
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
basegfx::B2DPoint aPoint = rPolygon.getB2DPoint( nClosedIdx );
|
|
|
|
|
|
|
|
if( bPixelSnap )
|
|
|
|
{
|
|
|
|
// snap device coordinates to full pixels
|
|
|
|
aPoint.setX( basegfx::fround( aPoint.getX() ) );
|
|
|
|
aPoint.setY( basegfx::fround( aPoint.getY() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( bLineDraw )
|
|
|
|
aPoint += aHalfPointOfs;
|
|
|
|
if( !nPointIdx )
|
|
|
|
{
|
|
|
|
// first point => just move there
|
|
|
|
rPath.moveTo( aPoint.getX(), aPoint.getY() );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool bPendingCurve = false;
|
|
|
|
if( bHasCurves )
|
|
|
|
{
|
|
|
|
bPendingCurve = rPolygon.isNextControlPointUsed( nPrevIdx );
|
|
|
|
bPendingCurve |= rPolygon.isPrevControlPointUsed( nClosedIdx );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !bPendingCurve ) // line segment
|
|
|
|
rPath.lineTo( aPoint.getX(), aPoint.getY() );
|
|
|
|
else // cubic bezier segment
|
|
|
|
{
|
|
|
|
basegfx::B2DPoint aCP1 = rPolygon.getNextControlPoint( nPrevIdx );
|
|
|
|
basegfx::B2DPoint aCP2 = rPolygon.getPrevControlPoint( nClosedIdx );
|
|
|
|
if( bLineDraw )
|
|
|
|
{
|
|
|
|
aCP1 += aHalfPointOfs;
|
|
|
|
aCP2 += aHalfPointOfs;
|
|
|
|
}
|
|
|
|
rPath.cubicTo( aCP1.getX(), aCP1.getY(),
|
|
|
|
aCP2.getX(), aCP2.getY(), aPoint.getX(), aPoint.getY() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( bClosePath )
|
|
|
|
rPath.closeSubpath();
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool AddPolyPolygonToPath( QPainterPath& rPath,
|
|
|
|
const basegfx::B2DPolyPolygon& rPolyPoly,
|
|
|
|
bool bPixelSnap, bool bLineDraw )
|
|
|
|
{
|
|
|
|
const int nPolyCount = rPolyPoly.count();
|
|
|
|
if( nPolyCount <= 0 )
|
|
|
|
return false;
|
|
|
|
for( int nPolyIdx = 0; nPolyIdx < nPolyCount; ++nPolyIdx )
|
|
|
|
{
|
|
|
|
const basegfx::B2DPolygon rPolygon = rPolyPoly.getB2DPolygon( nPolyIdx );
|
|
|
|
AddPolygonToPath( rPath, rPolygon, true, bPixelSnap, bLineDraw );
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
bool Qt5Graphics::setClipRegion( const vcl::Region& rRegion )
|
2017-10-21 13:50:30 +00:00
|
|
|
{
|
2017-10-30 18:33:06 +01:00
|
|
|
if ( rRegion.IsRectangle() )
|
2017-10-30 20:31:42 +01:00
|
|
|
{
|
2017-10-30 18:33:06 +01:00
|
|
|
m_aClipRegion = toQRect( rRegion.GetBoundRect() );
|
2017-10-30 20:31:42 +01:00
|
|
|
if ( !m_aClipPath.isEmpty() )
|
|
|
|
{
|
|
|
|
QPainterPath aPath;
|
|
|
|
m_aClipPath.swap( aPath );
|
|
|
|
}
|
|
|
|
}
|
2017-10-30 18:33:06 +01:00
|
|
|
else if( !rRegion.HasPolyPolygonOrB2DPolyPolygon() )
|
|
|
|
{
|
|
|
|
QRegion aQRegion;
|
|
|
|
RectangleVector aRectangles;
|
|
|
|
rRegion.GetRegionRectangles( aRectangles );
|
|
|
|
for ( auto & rRect : aRectangles )
|
|
|
|
aQRegion += toQRect( rRect );
|
|
|
|
m_aClipRegion = aQRegion;
|
2017-10-30 20:31:42 +01:00
|
|
|
if ( !m_aClipPath.isEmpty() )
|
|
|
|
{
|
|
|
|
QPainterPath aPath;
|
|
|
|
m_aClipPath.swap( aPath );
|
|
|
|
}
|
2017-10-30 18:33:06 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-10-30 20:31:42 +01:00
|
|
|
QPainterPath aPath;
|
|
|
|
const basegfx::B2DPolyPolygon aPolyClip( rRegion.GetAsB2DPolyPolygon() );
|
|
|
|
AddPolyPolygonToPath( aPath, aPolyClip, !getAntiAliasB2DDraw(), false );
|
|
|
|
m_aClipPath.swap( aPath );
|
|
|
|
if ( !m_aClipRegion.isEmpty() )
|
|
|
|
{
|
|
|
|
QRegion aRegion;
|
|
|
|
m_aClipRegion.swap( aRegion );
|
|
|
|
}
|
2017-10-30 18:33:06 +01:00
|
|
|
}
|
|
|
|
return true;
|
2017-10-21 13:50:30 +00:00
|
|
|
}
|
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
void Qt5Graphics::ResetClipRegion()
|
2017-10-21 13:50:30 +00:00
|
|
|
{
|
2017-10-30 18:33:06 +01:00
|
|
|
m_aClipRegion = QRegion( m_pQImage->rect() );
|
2017-10-30 20:31:42 +01:00
|
|
|
if ( !m_aClipPath.isEmpty() )
|
|
|
|
{
|
|
|
|
QPainterPath aPath;
|
|
|
|
m_aClipPath.swap( aPath );
|
|
|
|
}
|
2017-10-21 13:50:30 +00:00
|
|
|
}
|
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
void Qt5Graphics::drawPixel( long nX, long nY )
|
2017-10-21 13:50:30 +00:00
|
|
|
{
|
2017-10-30 20:19:45 +01:00
|
|
|
PREPARE_PAINTER;
|
|
|
|
aPainter.drawPoint( nX, nY );
|
2017-10-21 13:50:30 +00:00
|
|
|
}
|
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
void Qt5Graphics::drawPixel( long nX, long nY, SalColor nSalColor )
|
2017-10-21 13:50:30 +00:00
|
|
|
{
|
2017-10-30 20:19:45 +01:00
|
|
|
PREPARE_PAINTER;
|
|
|
|
aPainter.setPen( QColor( QRgb( nSalColor ) ) );
|
|
|
|
aPainter.setPen( Qt::SolidLine );
|
|
|
|
aPainter.drawPoint( nX, nY );
|
2017-10-21 13:50:30 +00:00
|
|
|
}
|
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
void Qt5Graphics::drawLine( long nX1, long nY1, long nX2, long nY2 )
|
2017-10-21 13:50:30 +00:00
|
|
|
{
|
2017-10-30 20:19:45 +01:00
|
|
|
PREPARE_PAINTER;
|
|
|
|
aPainter.drawLine( nX1, nY1, nX2, nY2 );
|
2017-10-21 13:50:30 +00:00
|
|
|
}
|
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
void Qt5Graphics::drawRect( long nX, long nY, long nWidth, long nHeight )
|
2017-10-21 13:50:30 +00:00
|
|
|
{
|
2017-10-30 20:19:45 +01:00
|
|
|
PREPARE_PAINTER;
|
|
|
|
aPainter.drawRect( nX, nY, nWidth, nHeight );
|
2017-10-21 13:50:30 +00:00
|
|
|
}
|
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
void Qt5Graphics::drawPolyLine( sal_uInt32 nPoints, const SalPoint* pPtAry )
|
2017-10-21 13:50:30 +00:00
|
|
|
{
|
2017-10-30 20:19:45 +01:00
|
|
|
PREPARE_PAINTER;
|
2017-10-30 18:33:06 +01:00
|
|
|
QPoint *pPoints = new QPoint[ nPoints ];
|
|
|
|
for ( sal_uInt32 i = 0; i < nPoints; ++i, ++pPtAry )
|
|
|
|
pPoints[ i ] = QPoint( pPtAry->mnX, pPtAry->mnY );
|
2017-10-30 20:19:45 +01:00
|
|
|
aPainter.drawPolyline( pPoints, nPoints );
|
2017-10-30 18:33:06 +01:00
|
|
|
delete [] pPoints;
|
2017-10-21 13:50:30 +00:00
|
|
|
}
|
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
void Qt5Graphics::drawPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry )
|
2017-10-21 13:50:30 +00:00
|
|
|
{
|
2017-10-30 20:19:45 +01:00
|
|
|
PREPARE_PAINTER;
|
2017-10-30 18:33:06 +01:00
|
|
|
QPoint *pPoints = new QPoint[ nPoints ];
|
|
|
|
for ( sal_uInt32 i = 0; i < nPoints; ++i, ++pPtAry )
|
|
|
|
pPoints[ i ] = QPoint( pPtAry->mnX, pPtAry->mnY );
|
2017-10-30 20:19:45 +01:00
|
|
|
aPainter.drawPolygon( pPoints, nPoints );
|
2017-10-30 18:33:06 +01:00
|
|
|
delete [] pPoints;
|
2017-10-21 13:50:30 +00:00
|
|
|
}
|
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
void Qt5Graphics::drawPolyPolygon( sal_uInt32 nPoly, const sal_uInt32* pPoints, PCONSTSALPOINT* pPtAry )
|
2017-10-21 13:50:30 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-10-30 20:31:42 +01:00
|
|
|
bool Qt5Graphics::drawPolyPolygon( const basegfx::B2DPolyPolygon& rPolyPoly,
|
|
|
|
double fTransparency )
|
2017-10-21 13:50:30 +00:00
|
|
|
{
|
2017-10-30 20:31:42 +01:00
|
|
|
// ignore invisible polygons
|
|
|
|
if (SALCOLOR_NONE == m_aFillColor && SALCOLOR_NONE == m_aLineColor )
|
|
|
|
return true;
|
|
|
|
if( (fTransparency >= 1.0) || (fTransparency < 0) )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
QPainterPath aPath;
|
|
|
|
// ignore empty polygons
|
|
|
|
if( !AddPolyPolygonToPath( aPath, rPolyPoly, !getAntiAliasB2DDraw(),
|
|
|
|
m_aLineColor != SALCOLOR_NONE ) )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
PREPARE_PAINTER;
|
|
|
|
|
|
|
|
QBrush aBrush = aPainter.brush();
|
|
|
|
aBrush.setStyle( SALCOLOR_NONE == m_aFillColor ? Qt::NoBrush : Qt::SolidPattern );
|
|
|
|
aPainter.setBrush( aBrush );
|
|
|
|
|
|
|
|
aPainter.drawPath( aPath );
|
|
|
|
|
|
|
|
return true;
|
2017-10-21 13:50:30 +00:00
|
|
|
}
|
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
bool Qt5Graphics::drawPolyLineBezier( sal_uInt32 nPoints, const SalPoint* pPtAry, const PolyFlags* pFlgAry )
|
2017-10-21 13:50:30 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
bool Qt5Graphics::drawPolygonBezier( sal_uInt32 nPoints, const SalPoint* pPtAry, const PolyFlags* pFlgAry )
|
2017-10-21 13:50:30 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
bool Qt5Graphics::drawPolyPolygonBezier( sal_uInt32 nPoly, const sal_uInt32* pPoints,
|
2017-10-21 13:50:30 +00:00
|
|
|
const SalPoint* const* pPtAry, const PolyFlags* const* pFlgAry )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-10-30 20:31:42 +01:00
|
|
|
bool Qt5Graphics::drawPolyLine( const basegfx::B2DPolygon& rPolyLine,
|
2017-10-21 13:50:30 +00:00
|
|
|
double fTransparency,
|
|
|
|
const basegfx::B2DVector& rLineWidths,
|
2017-10-30 20:31:42 +01:00
|
|
|
basegfx::B2DLineJoin eLineJoin,
|
2017-10-21 13:50:30 +00:00
|
|
|
css::drawing::LineCap eLineCap,
|
2017-10-31 01:10:36 +01:00
|
|
|
double fMiterMinimumAngle )
|
2017-10-21 13:50:30 +00:00
|
|
|
{
|
2017-10-30 20:31:42 +01:00
|
|
|
if (SALCOLOR_NONE == m_aFillColor && SALCOLOR_NONE == m_aLineColor )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if( basegfx::B2DLineJoin::NONE == eLineJoin )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// short circuit if there is nothing to do
|
|
|
|
const int nPointCount = rPolyLine.count();
|
|
|
|
if( nPointCount <= 0 )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
// setup poly-polygon path
|
|
|
|
QPainterPath aPath;
|
|
|
|
AddPolygonToPath( aPath, rPolyLine, rPolyLine.isClosed(),
|
|
|
|
!getAntiAliasB2DDraw(), true );
|
|
|
|
|
|
|
|
QPainter aPainter;
|
|
|
|
PreparePainter( aPainter, 255 * fTransparency );
|
|
|
|
|
|
|
|
// setup line attributes
|
|
|
|
QPen aPen = aPainter.pen();
|
|
|
|
aPen.setWidth( rLineWidths.getX() );
|
|
|
|
|
|
|
|
switch( eLineJoin )
|
|
|
|
{
|
|
|
|
case basegfx::B2DLineJoin::NONE: std::abort(); return false;
|
|
|
|
case basegfx::B2DLineJoin::Bevel: aPen.setJoinStyle( Qt::BevelJoin ); break;
|
|
|
|
case basegfx::B2DLineJoin::Round: aPen.setJoinStyle( Qt::RoundJoin ); break;
|
|
|
|
case basegfx::B2DLineJoin::Miter:
|
|
|
|
aPen.setMiterLimit( 1.0 / sin(fMiterMinimumAngle / 2.0) );
|
|
|
|
aPen.setJoinStyle( Qt::MiterJoin );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(eLineCap)
|
|
|
|
{
|
|
|
|
default: // css::drawing::LineCap_BUTT:
|
|
|
|
aPen.setCapStyle( Qt::FlatCap ); break;
|
|
|
|
case css::drawing::LineCap_ROUND: aPen.setCapStyle( Qt::RoundCap ); break;
|
|
|
|
case css::drawing::LineCap_SQUARE: aPen.setCapStyle( Qt::SquareCap ); break;
|
|
|
|
}
|
|
|
|
|
|
|
|
aPainter.setPen( aPen );
|
|
|
|
aPainter.drawPath( aPath );
|
|
|
|
return true;
|
2017-10-21 13:50:30 +00:00
|
|
|
}
|
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
bool Qt5Graphics::drawGradient( const tools::PolyPolygon&, const Gradient& )
|
2017-10-21 13:50:30 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
void Qt5Graphics::copyArea( long nDestX, long nDestY, long nSrcX, long nSrcY, long nSrcWidth,
|
2017-10-21 13:50:30 +00:00
|
|
|
long nSrcHeight, bool bWindowInvalidate )
|
|
|
|
{
|
2017-10-30 18:33:06 +01:00
|
|
|
if ( nDestX == nSrcX && nDestY == nSrcY )
|
|
|
|
return;
|
|
|
|
|
|
|
|
SalTwoRect aTR( nSrcX, nSrcY, nSrcWidth, nSrcHeight,
|
|
|
|
nDestX, nDestY, nSrcWidth, nSrcHeight );
|
|
|
|
copyBits( aTR, this );
|
2017-10-21 13:50:30 +00:00
|
|
|
}
|
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
void Qt5Graphics::copyBits( const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics )
|
2017-10-21 13:50:30 +00:00
|
|
|
{
|
2017-10-30 18:33:06 +01:00
|
|
|
if( rPosAry.mnSrcWidth <= 0 || rPosAry.mnSrcHeight <= 0
|
|
|
|
|| rPosAry.mnDestWidth <= 0 || rPosAry.mnDestHeight <= 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
assert( rPosAry.mnSrcWidth == rPosAry.mnDestWidth );
|
|
|
|
assert( rPosAry.mnSrcHeight == rPosAry.mnDestHeight );
|
|
|
|
|
2017-10-30 20:19:45 +01:00
|
|
|
QImage aImage, *pImage = &aImage;
|
2017-10-30 18:33:06 +01:00
|
|
|
if ( !pSrcGraphics || this == pSrcGraphics )
|
|
|
|
{
|
|
|
|
if ( rPosAry.mnDestX == rPosAry.mnSrcX
|
|
|
|
&& rPosAry.mnDestY == rPosAry.mnSrcY )
|
|
|
|
return;
|
|
|
|
aImage = pImage->copy( rPosAry.mnSrcX, rPosAry.mnSrcY,
|
|
|
|
rPosAry.mnSrcWidth, rPosAry.mnSrcHeight );
|
|
|
|
}
|
|
|
|
else
|
2017-10-30 18:45:46 +01:00
|
|
|
pImage = static_cast< Qt5Graphics* >( pSrcGraphics )->m_pQImage;
|
2017-10-30 18:33:06 +01:00
|
|
|
|
2017-10-30 20:19:45 +01:00
|
|
|
PREPARE_PAINTER;
|
|
|
|
|
|
|
|
aPainter.drawImage( QPoint( rPosAry.mnDestX, rPosAry.mnDestY ),
|
2017-10-30 18:33:06 +01:00
|
|
|
*pImage, QRect( rPosAry.mnSrcX, rPosAry.mnSrcY,
|
|
|
|
rPosAry.mnSrcWidth, rPosAry.mnSrcHeight) );
|
2017-10-21 13:50:30 +00:00
|
|
|
}
|
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
void Qt5Graphics::drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap )
|
2017-10-21 13:50:30 +00:00
|
|
|
{
|
2017-10-30 18:33:06 +01:00
|
|
|
if( rPosAry.mnSrcWidth <= 0 || rPosAry.mnSrcHeight <= 0
|
|
|
|
|| rPosAry.mnDestWidth <= 0 || rPosAry.mnDestHeight <= 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
assert( rPosAry.mnSrcWidth == rPosAry.mnDestWidth );
|
|
|
|
assert( rPosAry.mnSrcHeight == rPosAry.mnDestHeight );
|
|
|
|
|
2017-10-30 20:19:45 +01:00
|
|
|
PREPARE_PAINTER;
|
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
const QImage *pImage = static_cast< const Qt5Bitmap* >( &rSalBitmap )->GetQImage();
|
2017-10-24 19:49:45 +02:00
|
|
|
assert( pImage );
|
2017-10-30 18:33:06 +01:00
|
|
|
|
2017-10-30 20:19:45 +01:00
|
|
|
aPainter.drawImage( QPoint( rPosAry.mnDestX, rPosAry.mnDestY ),
|
2017-10-30 18:33:06 +01:00
|
|
|
*pImage, QRect( rPosAry.mnSrcX, rPosAry.mnSrcY,
|
|
|
|
rPosAry.mnSrcWidth, rPosAry.mnSrcHeight) );
|
|
|
|
|
|
|
|
// Workaround to get updates
|
|
|
|
if ( m_pFrame )
|
|
|
|
m_pFrame->GetQWidget()->update();
|
2017-10-21 13:50:30 +00:00
|
|
|
}
|
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
void Qt5Graphics::drawBitmap( const SalTwoRect& rPosAry,
|
2017-10-21 13:50:30 +00:00
|
|
|
const SalBitmap& rSalBitmap,
|
|
|
|
const SalBitmap& rTransparentBitmap )
|
|
|
|
{
|
2017-10-24 19:49:45 +02:00
|
|
|
if( rPosAry.mnSrcWidth <= 0 || rPosAry.mnSrcHeight <= 0
|
|
|
|
|| rPosAry.mnDestWidth <= 0 || rPosAry.mnDestHeight <= 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
assert( rPosAry.mnSrcWidth == rPosAry.mnDestWidth );
|
|
|
|
assert( rPosAry.mnSrcHeight == rPosAry.mnDestHeight );
|
2017-10-21 13:50:30 +00:00
|
|
|
}
|
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
void Qt5Graphics::drawMask( const SalTwoRect& rPosAry,
|
2017-10-24 19:49:45 +02:00
|
|
|
const SalBitmap& rSalBitmap,
|
|
|
|
SalColor nMaskColor )
|
2017-10-21 13:50:30 +00:00
|
|
|
{
|
2017-10-24 19:49:45 +02:00
|
|
|
if( rPosAry.mnSrcWidth <= 0 || rPosAry.mnSrcHeight <= 0
|
|
|
|
|| rPosAry.mnDestWidth <= 0 || rPosAry.mnDestHeight <= 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
assert( rPosAry.mnSrcWidth == rPosAry.mnDestWidth );
|
|
|
|
assert( rPosAry.mnSrcHeight == rPosAry.mnDestHeight );
|
2017-10-21 13:50:30 +00:00
|
|
|
}
|
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
SalBitmap* Qt5Graphics::getBitmap( long nX, long nY, long nWidth, long nHeight )
|
2017-10-21 13:50:30 +00:00
|
|
|
{
|
2017-10-30 18:45:46 +01:00
|
|
|
return new Qt5Bitmap( m_pQImage->copy( nX, nY, nWidth, nHeight ) );
|
2017-10-21 13:50:30 +00:00
|
|
|
}
|
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
SalColor Qt5Graphics::getPixel( long nX, long nY )
|
2017-10-21 13:50:30 +00:00
|
|
|
{
|
2017-10-30 18:33:06 +01:00
|
|
|
return m_pQImage->pixel( nX, nY );
|
2017-10-21 13:50:30 +00:00
|
|
|
}
|
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
void Qt5Graphics::invert( long nX, long nY, long nWidth, long nHeight, SalInvert nFlags)
|
2017-10-21 13:50:30 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
void Qt5Graphics::invert( sal_uInt32 nPoints, const SalPoint* pPtAry, SalInvert nFlags )
|
2017-10-21 13:50:30 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
bool Qt5Graphics::drawEPS( long nX, long nY, long nWidth, long nHeight, void* pPtr, sal_uLong nSize )
|
2017-10-21 13:50:30 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
bool Qt5Graphics::blendBitmap( const SalTwoRect&,
|
2017-10-21 13:50:30 +00:00
|
|
|
const SalBitmap& rBitmap )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
bool Qt5Graphics::blendAlphaBitmap( const SalTwoRect&,
|
2017-10-21 13:50:30 +00:00
|
|
|
const SalBitmap& rSrcBitmap,
|
|
|
|
const SalBitmap& rMaskBitmap,
|
|
|
|
const SalBitmap& rAlphaBitmap )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
bool Qt5Graphics::drawAlphaBitmap( const SalTwoRect&,
|
2017-10-21 13:50:30 +00:00
|
|
|
const SalBitmap& rSourceBitmap,
|
|
|
|
const SalBitmap& rAlphaBitmap )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
bool Qt5Graphics::drawTransformedBitmap(
|
2017-10-21 13:50:30 +00:00
|
|
|
const basegfx::B2DPoint& rNull,
|
|
|
|
const basegfx::B2DPoint& rX,
|
|
|
|
const basegfx::B2DPoint& rY,
|
|
|
|
const SalBitmap& rSourceBitmap,
|
|
|
|
const SalBitmap* pAlphaBitmap)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
bool Qt5Graphics::drawAlphaRect( long nX, long nY, long nWidth,
|
2017-10-21 13:50:30 +00:00
|
|
|
long nHeight, sal_uInt8 nTransparency )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
void Qt5Graphics::GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY )
|
2017-10-21 13:50:30 +00:00
|
|
|
{
|
2017-10-30 18:33:06 +01:00
|
|
|
char* pForceDpi;
|
|
|
|
if ((pForceDpi = getenv("SAL_FORCEDPI")))
|
|
|
|
{
|
|
|
|
OString sForceDPI(pForceDpi);
|
|
|
|
rDPIX = rDPIY = sForceDPI.toInt32();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !m_pFrame || !m_pFrame->GetQWidget()->window()->windowHandle() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
QScreen *pScreen = m_pFrame->GetQWidget()->window()->windowHandle()->screen();
|
|
|
|
rDPIX = pScreen->physicalDotsPerInchX();
|
|
|
|
rDPIY = pScreen->physicalDotsPerInchY();
|
2017-10-21 13:50:30 +00:00
|
|
|
}
|
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
sal_uInt16 Qt5Graphics::GetBitCount() const
|
2017-10-21 13:50:30 +00:00
|
|
|
{
|
2017-10-30 18:33:06 +01:00
|
|
|
return getFormatBits( m_pQImage->format() );
|
2017-10-21 13:50:30 +00:00
|
|
|
}
|
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
long Qt5Graphics::GetGraphicsWidth() const
|
2017-10-21 13:50:30 +00:00
|
|
|
{
|
2017-10-30 18:33:06 +01:00
|
|
|
return m_pQImage->width();
|
2017-10-21 13:50:30 +00:00
|
|
|
}
|
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
void Qt5Graphics::SetLineColor()
|
2017-10-21 13:50:30 +00:00
|
|
|
{
|
2017-10-30 20:19:45 +01:00
|
|
|
m_aLineColor = SALCOLOR_NONE;
|
2017-10-21 13:50:30 +00:00
|
|
|
}
|
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
void Qt5Graphics::SetLineColor( SalColor nSalColor )
|
2017-10-21 13:50:30 +00:00
|
|
|
{
|
2017-10-30 20:19:45 +01:00
|
|
|
m_aLineColor = nSalColor;
|
2017-10-21 13:50:30 +00:00
|
|
|
}
|
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
void Qt5Graphics::SetFillColor()
|
2017-10-21 13:50:30 +00:00
|
|
|
{
|
2017-10-30 20:19:45 +01:00
|
|
|
m_aFillColor = SALCOLOR_NONE;
|
2017-10-21 13:50:30 +00:00
|
|
|
}
|
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
void Qt5Graphics::SetFillColor( SalColor nSalColor )
|
2017-10-21 13:50:30 +00:00
|
|
|
{
|
2017-10-30 20:19:45 +01:00
|
|
|
m_aFillColor = nSalColor;
|
2017-10-21 13:50:30 +00:00
|
|
|
}
|
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
void Qt5Graphics::SetXORMode( bool bSet )
|
2017-10-21 13:50:30 +00:00
|
|
|
{
|
2017-10-30 20:19:45 +01:00
|
|
|
if ( bSet )
|
|
|
|
m_eCompositionMode = QPainter::CompositionMode_Xor;
|
|
|
|
else
|
|
|
|
m_eCompositionMode = QPainter::CompositionMode_SourceOver;
|
2017-10-21 13:50:30 +00:00
|
|
|
}
|
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
void Qt5Graphics::SetROPLineColor( SalROPColor nROPColor )
|
2017-10-21 13:50:30 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-10-30 18:45:46 +01:00
|
|
|
void Qt5Graphics::SetROPFillColor( SalROPColor nROPColor )
|
2017-10-21 13:50:30 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|