summaryrefslogtreecommitdiff
path: root/vcl/qt5
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2017-10-30 18:45:46 +0100
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2017-11-06 12:05:32 +0100
commit2ffb83daa4358aaad0cba7ddb67847282ac6fcce (patch)
tree2bf819492eb68134e8678e8138c983c57845e7e8 /vcl/qt5
parentbc00fcc0a05ce2fa9f0e01a291a6917c3630cfab (diff)
QT5 rename from KF5
Move out of unx, as this will eventually compile on other OS platforms. At least currently it doesn't contain platform dependant code. Change-Id: Iea0bebf574201881ea158381fe7ba8af2a9a6488
Diffstat (limited to 'vcl/qt5')
-rw-r--r--vcl/qt5/Qt5Bitmap.cxx265
-rw-r--r--vcl/qt5/Qt5Bitmap.hxx69
-rw-r--r--vcl/qt5/Qt5Data.cxx49
-rw-r--r--vcl/qt5/Qt5Data.hxx34
-rw-r--r--vcl/qt5/Qt5FontFace.cxx126
-rw-r--r--vcl/qt5/Qt5FontFace.hxx62
-rw-r--r--vcl/qt5/Qt5Frame.cxx396
-rw-r--r--vcl/qt5/Qt5Frame.hxx116
-rw-r--r--vcl/qt5/Qt5Graphics.cxx117
-rw-r--r--vcl/qt5/Qt5Graphics.hxx200
-rw-r--r--vcl/qt5/Qt5Graphics_Controls.cxx51
-rw-r--r--vcl/qt5/Qt5Graphics_GDI.cxx335
-rw-r--r--vcl/qt5/Qt5Graphics_Text.cxx118
-rw-r--r--vcl/qt5/Qt5Instance.cxx278
-rw-r--r--vcl/qt5/Qt5Instance.hxx105
-rw-r--r--vcl/qt5/Qt5Instance_Print.cxx265
-rw-r--r--vcl/qt5/Qt5Object.cxx85
-rw-r--r--vcl/qt5/Qt5Object.hxx56
-rw-r--r--vcl/qt5/Qt5Printer.cxx32
-rw-r--r--vcl/qt5/Qt5Printer.hxx39
-rw-r--r--vcl/qt5/Qt5Timer.cxx65
-rw-r--r--vcl/qt5/Qt5Timer.hxx46
-rw-r--r--vcl/qt5/Qt5Tools.hxx89
-rw-r--r--vcl/qt5/Qt5VirtualDevice.cxx103
-rw-r--r--vcl/qt5/Qt5VirtualDevice.hxx58
-rw-r--r--vcl/qt5/Qt5Widget.cxx55
-rw-r--r--vcl/qt5/Qt5Widget.hxx46
-rw-r--r--vcl/qt5/tst_exclude_posted_events.hxx67
-rw-r--r--vcl/qt5/tst_exclude_socket_notifiers.hxx80
29 files changed, 3407 insertions, 0 deletions
diff --git a/vcl/qt5/Qt5Bitmap.cxx b/vcl/qt5/Qt5Bitmap.cxx
new file mode 100644
index 000000000000..524eaf6048c2
--- /dev/null
+++ b/vcl/qt5/Qt5Bitmap.cxx
@@ -0,0 +1,265 @@
+/* -*- 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 .
+ */
+
+#include "Qt5Bitmap.hxx"
+#include "Qt5Tools.hxx"
+#include "Qt5Graphics.hxx"
+
+#include <QtGui/QImage>
+#include <QtCore/QVector>
+#include <QtGui/QColor>
+
+Qt5Bitmap::Qt5Bitmap()
+{
+}
+
+Qt5Bitmap::Qt5Bitmap( const QImage &rImage )
+{
+ m_pImage.reset( new QImage( rImage ) );
+}
+
+Qt5Bitmap::~Qt5Bitmap()
+{
+}
+
+bool Qt5Bitmap::Create( const Size& rSize, sal_uInt16 nBitCount,
+ const BitmapPalette& rPal )
+{
+ assert(
+ (nBitCount == 1
+ || nBitCount == 4
+ || nBitCount == 8
+ || nBitCount == 16
+ || nBitCount == 24
+ || nBitCount == 32)
+ && "Unsupported BitCount!");
+
+ if ( nBitCount == 1 )
+ assert( 2 == rPal.GetEntryCount() );
+ if ( nBitCount == 4 )
+ assert( 16 == rPal.GetEntryCount() );
+ if ( nBitCount == 8 )
+ assert( 256 == rPal.GetEntryCount() );
+
+ if ( nBitCount == 4 )
+ {
+ m_pImage.reset();
+ m_aSize = rSize;
+ m_nScanline = rSize.Width() / 2 + (rSize.Width() % 2) ? 0 : 1;
+ m_pBuffer.reset( new sal_uInt8[ m_nScanline * rSize.Height() ] );
+ }
+ else
+ {
+ m_pImage.reset( new QImage( toQSize( rSize ), getBitFormat( nBitCount ) ) );
+ m_pBuffer.reset();
+ }
+ m_aPalette = rPal;
+
+ auto count = rPal.GetEntryCount();
+ if( nBitCount != 4 && count )
+ {
+ QVector<QRgb> aColorTable( count );
+ for ( unsigned i = 0; i < count; ++i )
+ aColorTable[ i ] = qRgb( rPal[ i ].GetRed(),
+ rPal[ i ].GetGreen(), rPal[ i ].GetBlue() );
+ m_pImage->setColorTable( aColorTable );
+ }
+ return true;
+}
+
+bool Qt5Bitmap::Create( const SalBitmap& rSalBmp )
+{
+ const Qt5Bitmap *pBitmap = static_cast< const Qt5Bitmap*>( &rSalBmp );
+ if ( pBitmap->m_pImage.get() )
+ {
+ m_pImage.reset( new QImage( *pBitmap->m_pImage.get() ) );
+ m_pBuffer.reset();
+ }
+ else
+ {
+ m_aSize = pBitmap->m_aSize;
+ m_nScanline = pBitmap->m_nScanline;
+ m_pBuffer.reset( new sal_uInt8[ m_nScanline * m_aSize.Height() ] );
+ memcpy( m_pBuffer.get(), pBitmap->m_pBuffer.get(), m_nScanline );
+ m_pImage.reset();
+ }
+ m_aPalette = pBitmap->m_aPalette;
+ return true;
+}
+
+bool Qt5Bitmap::Create( const SalBitmap& rSalBmp,
+ SalGraphics* pSalGraphics )
+{
+ const Qt5Bitmap *pBitmap = static_cast< const Qt5Bitmap *>( &rSalBmp );
+ Qt5Graphics *pGraphics = static_cast< Qt5Graphics* >( pSalGraphics );
+ QImage *pImage = pGraphics->m_pQImage;
+ m_pImage.reset( new QImage( pBitmap->m_pImage->convertToFormat( pImage->format() ) ) );
+ m_pBuffer.reset();
+ return true;
+}
+
+bool Qt5Bitmap::Create( const SalBitmap& rSalBmp,
+ sal_uInt16 nNewBitCount )
+{
+ assert(
+ (nNewBitCount == 1
+ || nNewBitCount == 4
+ || nNewBitCount == 8
+ || nNewBitCount == 16
+ || nNewBitCount == 24
+ || nNewBitCount == 32)
+ && "Unsupported BitCount!");
+
+ const Qt5Bitmap *pBitmap = static_cast< const Qt5Bitmap *>( &rSalBmp );
+ if ( pBitmap->m_pBuffer.get() )
+ return false;
+
+ m_pImage.reset( new QImage( pBitmap->m_pImage->convertToFormat( getBitFormat( nNewBitCount ) ) ) );
+ return true;
+}
+
+bool Qt5Bitmap::Create( const css::uno::Reference< css::rendering::XBitmapCanvas >& rBitmapCanvas,
+ Size& rSize, bool bMask )
+{
+ return false;
+}
+
+void Qt5Bitmap::Destroy()
+{
+ m_pImage.reset();
+ m_pBuffer.reset();
+}
+
+Size Qt5Bitmap::GetSize() const
+{
+ if ( m_pBuffer.get() )
+ return m_aSize;
+ else if ( m_pImage.get() )
+ return toSize( m_pImage->size() );
+ return Size();
+}
+
+sal_uInt16 Qt5Bitmap::GetBitCount() const
+{
+ if ( m_pBuffer.get() )
+ return 4;
+ else if ( m_pImage.get() )
+ return getFormatBits( m_pImage->format() );
+ return 0;
+}
+
+BitmapBuffer* Qt5Bitmap::AcquireBuffer( BitmapAccessMode nMode )
+{
+ static const BitmapPalette aEmptyPalette;
+
+ if ( !(m_pImage.get() || m_pBuffer.get()) )
+ return nullptr;
+
+ BitmapBuffer* pBuffer = new BitmapBuffer;
+
+ if ( m_pBuffer.get() )
+ {
+ pBuffer->mnWidth = m_aSize.Width();
+ pBuffer->mnHeight = m_aSize.Height();
+ pBuffer->mnBitCount = 4;
+ pBuffer->mpBits = m_pBuffer.get();
+ pBuffer->mnScanlineSize = m_nScanline;
+ }
+ else
+ {
+ pBuffer->mnWidth = m_pImage->width();
+ pBuffer->mnHeight = m_pImage->height();
+ pBuffer->mnBitCount = getFormatBits( m_pImage->format() );
+ pBuffer->mpBits = m_pImage->bits();
+ pBuffer->mnScanlineSize = m_pImage->bytesPerLine();
+ }
+
+ switch( pBuffer->mnBitCount )
+ {
+ case 1:
+ pBuffer->mnFormat = ScanlineFormat::N1BitLsbPal;
+ pBuffer->maPalette = m_aPalette;
+ break;
+ case 4:
+ pBuffer->mnFormat = ScanlineFormat::N4BitMsnPal;
+ pBuffer->maPalette = m_aPalette;
+ break;
+ case 8:
+ pBuffer->mnFormat = ScanlineFormat::N8BitPal;
+ pBuffer->maPalette = m_aPalette;
+ break;
+ case 16:
+ {
+#ifdef OSL_BIGENDIAN
+ pBuffer->mnFormat= ScanlineFormat::N16BitTcMsbMask;
+#else
+ pBuffer->mnFormat= ScanlineFormat::N16BitTcLsbMask;
+#endif
+ ColorMaskElement aRedMask(0xf800); // 5
+ aRedMask.CalcMaskShift();
+ ColorMaskElement aGreenMask(0x07e0); // 6
+ aGreenMask.CalcMaskShift();
+ ColorMaskElement aBlueMask(0x001f); // 5
+ aBlueMask.CalcMaskShift();
+ pBuffer->maColorMask = ColorMask(aRedMask, aGreenMask, aBlueMask);
+ pBuffer->maPalette = aEmptyPalette;
+ break;
+ }
+ case 24:
+ pBuffer->mnFormat = ScanlineFormat::N24BitTcRgb;
+ pBuffer->maPalette = aEmptyPalette;
+ break;
+ case 32:
+ {
+ pBuffer->mnFormat = ScanlineFormat::N32BitTcArgb;
+ pBuffer->maPalette = aEmptyPalette;
+ break;
+ }
+ }
+
+ return pBuffer;
+}
+
+void Qt5Bitmap::ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode )
+{
+ m_aPalette = pBuffer->maPalette;
+ delete pBuffer;
+}
+
+bool Qt5Bitmap::GetSystemData( BitmapSystemData& rData )
+{
+ return false;
+}
+
+bool Qt5Bitmap::ScalingSupported() const
+{
+ return false;
+}
+
+bool Qt5Bitmap::Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag )
+{
+ return false;
+}
+
+bool Qt5Bitmap::Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol )
+{
+ return false;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5Bitmap.hxx b/vcl/qt5/Qt5Bitmap.hxx
new file mode 100644
index 000000000000..99c9641db789
--- /dev/null
+++ b/vcl/qt5/Qt5Bitmap.hxx
@@ -0,0 +1,69 @@
+/* -*- 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 .
+ */
+
+#pragma once
+
+#include <salbmp.hxx>
+
+#include <memory>
+
+class QImage;
+
+class VCL_DLLPUBLIC Qt5Bitmap : public SalBitmap
+{
+ std::unique_ptr< QImage > m_pImage;
+ BitmapPalette m_aPalette;
+
+ // for 4bit support
+ std::unique_ptr< sal_uInt8 > m_pBuffer;
+ Size m_aSize;
+ sal_uInt32 m_nScanline;
+
+public:
+ Qt5Bitmap();
+ Qt5Bitmap( const QImage& rQImage );
+ virtual ~Qt5Bitmap() override;
+
+ const QImage* GetQImage() const { return m_pImage.get(); }
+
+ virtual bool Create( const Size& rSize,
+ sal_uInt16 nBitCount,
+ const BitmapPalette& rPal ) override;
+ virtual bool Create( const SalBitmap& rSalBmp ) override;
+ virtual bool Create( const SalBitmap& rSalBmp,
+ SalGraphics* pGraphics ) override;
+ virtual bool Create( const SalBitmap& rSalBmp,
+ sal_uInt16 nNewBitCount ) override;
+ virtual bool Create( const css::uno::Reference< css::rendering::XBitmapCanvas >& rBitmapCanvas,
+ Size& rSize,
+ bool bMask = false ) override;
+ virtual void Destroy() final override;
+ virtual Size GetSize() const override;
+ virtual sal_uInt16 GetBitCount() const override;
+
+ virtual BitmapBuffer* AcquireBuffer( BitmapAccessMode nMode ) override;
+ virtual void ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode ) override;
+ virtual bool GetSystemData( BitmapSystemData& rData ) override;
+
+ virtual bool ScalingSupported() const override;
+ virtual bool Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag ) override;
+ virtual bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol ) override;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5Data.cxx b/vcl/qt5/Qt5Data.cxx
new file mode 100644
index 000000000000..f8d4483bf761
--- /dev/null
+++ b/vcl/qt5/Qt5Data.cxx
@@ -0,0 +1,49 @@
+/* -*- 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 .
+ */
+
+#include <QtWidgets/QStyle>
+#include <QtWidgets/QApplication>
+
+#include "Qt5Data.hxx"
+
+Qt5Data::Qt5Data( SalInstance *pInstance )
+ : GenericUnixSalData( SAL_DATA_QT5, pInstance )
+{
+ ImplSVData *pSVData = ImplGetSVData();
+
+ // draw toolbars on separate lines
+ pSVData->maNWFData.mbDockingAreaSeparateTB = true;
+ // no borders for menu, theming does that
+ pSVData->maNWFData.mbFlatMenu = true;
+}
+
+Qt5Data::~Qt5Data()
+{
+}
+
+void Qt5Data::ErrorTrapPush()
+{
+}
+
+bool Qt5Data::ErrorTrapPop( bool bIgnoreError )
+{
+ return false;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5Data.hxx b/vcl/qt5/Qt5Data.hxx
new file mode 100644
index 000000000000..31859ce9637c
--- /dev/null
+++ b/vcl/qt5/Qt5Data.hxx
@@ -0,0 +1,34 @@
+/* -*- 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 .
+ */
+
+#pragma once
+
+#include <unx/gendata.hxx>
+
+class Qt5Data : public GenericUnixSalData
+{
+public:
+ explicit Qt5Data( SalInstance *pInstance );
+ virtual ~Qt5Data() override;
+
+ virtual void ErrorTrapPush() override;
+ virtual bool ErrorTrapPop( bool bIgnoreError = true ) override;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5FontFace.cxx b/vcl/qt5/Qt5FontFace.cxx
new file mode 100644
index 000000000000..701509b06108
--- /dev/null
+++ b/vcl/qt5/Qt5FontFace.cxx
@@ -0,0 +1,126 @@
+/* -*- 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 .
+ */
+
+#include "Qt5FontFace.hxx"
+#include "Qt5Tools.hxx"
+
+#include <sft.hxx>
+#include <impfontcharmap.hxx>
+#include <fontinstance.hxx>
+#include <fontselect.hxx>
+#include <PhysicalFontCollection.hxx>
+
+#include <QtGui/QFont>
+#include <QtGui/QRawFont>
+
+using namespace vcl;
+
+Qt5FontFace::Qt5FontFace( const Qt5FontFace& rSrc )
+ : PhysicalFontFace( rSrc )
+ , m_aFontId( rSrc.m_aFontId )
+{
+ if( rSrc.m_xCharMap.is() )
+ m_xCharMap = rSrc.m_xCharMap;
+}
+
+Qt5FontFace* Qt5FontFace::fromQFont( const QFont &rFont )
+{
+ FontAttributes aFA;
+ aFA.SetFamilyName( toOUString( rFont.family() ) );
+ aFA.SetStyleName( toOUString( rFont.styleName() ) );
+ aFA.SetItalic( rFont.italic() ? ITALIC_NORMAL : ITALIC_NONE );
+
+ return new Qt5FontFace( aFA, rFont.toString() ) ;
+}
+
+Qt5FontFace::Qt5FontFace( const FontAttributes& rFA, const QString &rFontID )
+ : PhysicalFontFace( rFA )
+ , m_aFontId( rFontID )
+ , m_bFontCapabilitiesRead( false )
+{
+}
+
+Qt5FontFace::~Qt5FontFace()
+{
+}
+
+sal_IntPtr Qt5FontFace::GetFontId() const
+{
+ return reinterpret_cast<sal_IntPtr>( &m_aFontId );
+}
+
+const FontCharMapRef Qt5FontFace::GetFontCharMap()
+{
+ if( m_xCharMap.is() )
+ return m_xCharMap;
+
+ QFont aFont;
+ aFont.fromString( m_aFontId );
+ QRawFont aRawFont( QRawFont::fromFont( aFont ) );
+ QByteArray aCMapTable = aRawFont.fontTable( "cmap" );
+ if ( aCMapTable.isEmpty() )
+ {
+ m_xCharMap = new FontCharMap();
+ return m_xCharMap;
+ }
+
+ CmapResult aCmapResult;
+ if( ParseCMAP( reinterpret_cast<const unsigned char*>( aCMapTable.data() ),
+ aCMapTable.size(), aCmapResult ) )
+ m_xCharMap = new FontCharMap( aCmapResult );
+
+ return m_xCharMap;
+}
+
+bool Qt5FontFace::GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities)
+{
+ // read this only once per font
+ if( m_bFontCapabilitiesRead )
+ {
+ rFontCapabilities = m_aFontCapabilities;
+ return rFontCapabilities.oUnicodeRange || rFontCapabilities.oCodePageRange;
+ }
+ m_bFontCapabilitiesRead = true;
+
+ QFont aFont;
+ aFont.fromString( m_aFontId );
+ QRawFont aRawFont( QRawFont::fromFont( aFont ) );
+ QByteArray aOS2Table = aRawFont.fontTable( "OS/2" );
+ if ( !aOS2Table.isEmpty() )
+ {
+ vcl::getTTCoverage( m_aFontCapabilities.oUnicodeRange,
+ m_aFontCapabilities.oCodePageRange,
+ reinterpret_cast<const unsigned char*>( aOS2Table.data() ),
+ aOS2Table.size() );
+ }
+
+ rFontCapabilities = m_aFontCapabilities;
+ return rFontCapabilities.oUnicodeRange || rFontCapabilities.oCodePageRange;
+}
+
+PhysicalFontFace* Qt5FontFace::Clone() const
+{
+ return new Qt5FontFace( *this );
+}
+
+LogicalFontInstance* Qt5FontFace::CreateFontInstance( const FontSelectPattern& rFSD ) const
+{
+ return new LogicalFontInstance( rFSD );
+}
+
diff --git a/vcl/qt5/Qt5FontFace.hxx b/vcl/qt5/Qt5FontFace.hxx
new file mode 100644
index 000000000000..76b8fdee99f1
--- /dev/null
+++ b/vcl/qt5/Qt5FontFace.hxx
@@ -0,0 +1,62 @@
+/* -*- 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 .
+ */
+
+#pragma once
+
+#include <PhysicalFontFace.hxx>
+
+#include <tools/ref.hxx>
+#include <vcl/fontcapabilities.hxx>
+#include <vcl/fontcharmap.hxx>
+
+#include <QtCore/QString>
+
+class FontAttributes;
+class FontSelectPattern;
+class QFont;
+
+class Qt5FontFace : public PhysicalFontFace
+{
+public:
+ virtual ~Qt5FontFace() override;
+
+ static Qt5FontFace* fromQFont( const QFont &rFont );
+
+ PhysicalFontFace* Clone() const override;
+ LogicalFontInstance* CreateFontInstance( const FontSelectPattern& ) const override;
+ sal_IntPtr GetFontId() const override;
+
+ int GetFontTable( const char pTagName[5], unsigned char* ) const;
+
+ const FontCharMapRef GetFontCharMap();
+ bool GetFontCapabilities( vcl::FontCapabilities &rFontCapabilities );
+ bool HasChar( sal_uInt32 cChar ) const;
+
+protected:
+ Qt5FontFace( const Qt5FontFace& );
+ Qt5FontFace( const FontAttributes& rFA, const QString &rFontID );
+
+private:
+ const QString m_aFontId;
+ FontCharMapRef m_xCharMap;
+ vcl::FontCapabilities m_aFontCapabilities;
+ bool m_bFontCapabilitiesRead;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
new file mode 100644
index 000000000000..ff9dc769f00b
--- /dev/null
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -0,0 +1,396 @@
+/* -*- 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 .
+ */
+
+#include "Qt5Frame.hxx"
+
+#include "Qt5Tools.hxx"
+#include "Qt5Instance.hxx"
+#include "Qt5Graphics.hxx"
+#include "Qt5Widget.hxx"
+
+#include <QtCore/QPoint>
+#include <QtCore/QSize>
+#include <QtGui/QIcon>
+#include <QtGui/QWindow>
+
+#include <saldatabasic.hxx>
+#include <vcl/syswin.hxx>
+
+Qt5Frame::Qt5Frame( Qt5Frame* pParent, SalFrameStyleFlags nStyle )
+ : m_bGraphicsInUse( false )
+{
+ Qt5Instance *pInst = static_cast<Qt5Instance*>( GetSalData()->m_pInstance );
+ pInst->insertFrame( this );
+
+ if( nStyle & SalFrameStyleFlags::DEFAULT ) // ensure default style
+ {
+ nStyle |= SalFrameStyleFlags::MOVEABLE | SalFrameStyleFlags::SIZEABLE | SalFrameStyleFlags::CLOSEABLE;
+ nStyle &= ~SalFrameStyleFlags::FLOAT;
+ }
+
+ m_nStyle = nStyle;
+ m_pParent = pParent;
+
+ Qt::WindowFlags aWinFlags;
+ if ( !(nStyle & SalFrameStyleFlags::SYSTEMCHILD) )
+ {
+ if( nStyle & SalFrameStyleFlags::INTRO )
+ aWinFlags |= Qt::SplashScreen;
+ else if( nStyle & (SalFrameStyleFlags::FLOAT |
+ SalFrameStyleFlags::TOOLTIP) )
+ aWinFlags |= Qt::ToolTip;
+ else if( (nStyle & SalFrameStyleFlags::FLOAT) &&
+ ! (nStyle & SalFrameStyleFlags::OWNERDRAWDECORATION) )
+ aWinFlags |= Qt::Popup;
+ else if( nStyle & SalFrameStyleFlags::DIALOG && pParent )
+ aWinFlags |= Qt::Dialog;
+ else if( nStyle & SalFrameStyleFlags::TOOLWINDOW )
+ aWinFlags |= Qt::Tool;
+ else if( (nStyle & SalFrameStyleFlags::OWNERDRAWDECORATION) )
+ aWinFlags |= Qt::Window | Qt::FramelessWindowHint | Qt::WindowDoesNotAcceptFocus;
+ else
+ aWinFlags |= Qt::Window;
+ }
+
+ m_pQWidget.reset( new Qt5Widget( *this, pParent ? pParent->GetQWidget() : nullptr, aWinFlags ) );
+
+ if (pParent && !(pParent->m_nStyle & SalFrameStyleFlags::PLUG))
+ {
+ QWindow *pParentWindow = pParent->GetQWidget()->window()->windowHandle();
+ QWindow *pChildWindow = m_pQWidget->window()->windowHandle();
+ if ( pParentWindow != pChildWindow )
+ pChildWindow->setTransientParent( pParentWindow );
+ }
+}
+
+Qt5Frame::~Qt5Frame()
+{
+ Qt5Instance *pInst = static_cast<Qt5Instance*>( GetSalData()->m_pInstance );
+ pInst->eraseFrame( this );
+}
+
+void Qt5Frame::TriggerPaintEvent()
+{
+ QSize aSize( m_pQWidget->size() );
+ SalPaintEvent aPaintEvt(0, 0, aSize.width(), aSize.height(), true);
+ CallCallback(SalEvent::Paint, &aPaintEvt);
+}
+
+SalGraphics* Qt5Frame::AcquireGraphics()
+{
+ if( m_bGraphicsInUse )
+ return nullptr;
+
+ if( !m_pGraphics.get() )
+ {
+ m_pGraphics.reset( new Qt5Graphics( this ) );
+ m_pQImage.reset( new QImage( m_pQWidget->size(), QImage::Format_ARGB32 ) );
+ m_pGraphics->ChangeQImage( m_pQImage.get() );
+ TriggerPaintEvent();
+ }
+ m_bGraphicsInUse = true;
+
+ return m_pGraphics.get();
+}
+
+void Qt5Frame::ReleaseGraphics( SalGraphics* pSalGraph )
+{
+ (void) pSalGraph;
+ assert( pSalGraph == m_pGraphics.get() );
+ m_bGraphicsInUse = false;
+}
+
+bool Qt5Frame::PostEvent( ImplSVEvent* pData )
+{
+ Qt5Instance *pInst = static_cast<Qt5Instance*>( GetSalData()->m_pInstance );
+ pInst->PostEvent( this, pData, SalEvent::UserEvent );
+ return true;
+}
+
+void Qt5Frame::SetTitle( const OUString& rTitle )
+{
+ m_pQWidget->window()->setWindowTitle( toQString( rTitle ) );
+}
+
+void Qt5Frame::SetIcon( sal_uInt16 nIcon )
+{
+ if( m_nStyle & (SalFrameStyleFlags::PLUG |
+ SalFrameStyleFlags::SYSTEMCHILD |
+ SalFrameStyleFlags::FLOAT |
+ SalFrameStyleFlags::INTRO |
+ SalFrameStyleFlags::OWNERDRAWDECORATION)
+ || !m_pQWidget->isWindow() )
+ return;
+
+ const char * appicon;
+
+ if (nIcon == SV_ICON_ID_TEXT)
+ appicon = "libreoffice-writer";
+ else if (nIcon == SV_ICON_ID_SPREADSHEET)
+ appicon = "libreoffice-calc";
+ else if (nIcon == SV_ICON_ID_DRAWING)
+ appicon = "libreoffice-draw";
+ else if (nIcon == SV_ICON_ID_PRESENTATION)
+ appicon = "libreoffice-impress";
+ else if (nIcon == SV_ICON_ID_DATABASE)
+ appicon = "libreoffice-base";
+ else if (nIcon == SV_ICON_ID_FORMULA)
+ appicon = "libreoffice-math";
+ else
+ appicon = "libreoffice-startcenter";
+
+ QIcon aIcon = QIcon::fromTheme( appicon );
+ m_pQWidget->window()->setWindowIcon( aIcon );
+}
+
+void Qt5Frame::SetMenu( SalMenu* pMenu )
+{
+}
+
+void Qt5Frame::DrawMenuBar()
+{
+}
+
+void Qt5Frame::SetExtendedFrameStyle( SalExtStyle nExtStyle )
+{
+}
+
+void Qt5Frame::Show( bool bVisible, bool bNoActivate )
+{
+ assert( m_pQWidget.get() );
+ m_pQWidget->setVisible( bVisible );
+}
+
+void Qt5Frame::SetMinClientSize( long nWidth, long nHeight )
+{
+ if( ! isChild() )
+ m_pQWidget->setMinimumSize( nWidth, nHeight );
+}
+
+void Qt5Frame::SetMaxClientSize( long nWidth, long nHeight )
+{
+ if( ! isChild() )
+ m_pQWidget->setMaximumSize( nWidth, nHeight );
+}
+
+void Qt5Frame::SetPosSize( long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags )
+{
+}
+
+void Qt5Frame::GetClientSize( long& rWidth, long& rHeight )
+{
+ rWidth = m_pQWidget->width();
+ rHeight = m_pQWidget->height();
+}
+
+void Qt5Frame::GetWorkArea( tools::Rectangle& rRect )
+{
+}
+
+SalFrame* Qt5Frame::GetParent() const
+{
+ return m_pParent;
+}
+
+void Qt5Frame::SetWindowState( const SalFrameState* pState )
+{
+ if( !m_pQWidget->isWindow() || !pState || isChild( true, false ) )
+ return;
+
+ const WindowStateMask nMaxGeometryMask =
+ WindowStateMask::X | WindowStateMask::Y |
+ WindowStateMask::Width | WindowStateMask::Height |
+ WindowStateMask::MaximizedX | WindowStateMask::MaximizedY |
+ WindowStateMask::MaximizedWidth | WindowStateMask::MaximizedHeight;
+
+ if( (pState->mnMask & WindowStateMask::State) &&
+ (pState->mnState & WindowStateState::Maximized) &&
+ (pState->mnMask & nMaxGeometryMask) == nMaxGeometryMask )
+ m_pQWidget->showMaximized();
+ else if( pState->mnMask & (WindowStateMask::X | WindowStateMask::Y |
+ WindowStateMask::Width | WindowStateMask::Height ) )
+ {
+ QRect rect = m_pQWidget->geometry();
+ if ( pState->mnMask & WindowStateMask::X )
+ rect.setX( pState->mnX );
+ if ( pState->mnMask & WindowStateMask::Y )
+ rect.setY( pState->mnY );
+ if ( pState->mnMask & WindowStateMask::Width )
+ rect.setWidth( pState->mnWidth );
+ if ( pState->mnMask & WindowStateMask::Height )
+ rect.setHeight( pState->mnHeight );
+ m_pQWidget->setGeometry( rect );
+ }
+ else if( pState->mnMask & WindowStateMask::State && ! isChild() )
+ {
+ if( (pState->mnState & WindowStateState::Minimized) && m_pQWidget->isWindow() )
+ m_pQWidget->showMinimized();
+ else
+ m_pQWidget->showNormal();
+ }
+}
+
+bool Qt5Frame::GetWindowState( SalFrameState* pState )
+{
+ pState->mnState = WindowStateState::Normal;
+ pState->mnMask = WindowStateMask::State;
+ if( m_pQWidget->isMinimized() || !m_pQWidget->windowHandle() )
+ pState->mnState |= WindowStateState::Minimized;
+ else if( m_pQWidget->isMaximized() )
+ {
+ pState->mnState |= WindowStateState::Maximized;
+ }
+ else
+ {
+ QRect rect = m_pQWidget->geometry();
+ pState->mnX = rect.x();
+ pState->mnY = rect.y();
+ pState->mnWidth = rect.width();
+ pState->mnHeight = rect.height();
+ pState->mnMask |= WindowStateMask::X |
+ WindowStateMask::Y |
+ WindowStateMask::Width |
+ WindowStateMask::Height;
+ }
+
+ TriggerPaintEvent();
+ return true;
+}
+
+void Qt5Frame::ShowFullScreen( bool bFullScreen, sal_Int32 nDisplay )
+{
+}
+
+void Qt5Frame::StartPresentation( bool bStart )
+{
+}
+
+void Qt5Frame::SetAlwaysOnTop( bool bOnTop )
+{
+}
+
+void Qt5Frame::ToTop( SalFrameToTop nFlags )
+{
+}
+
+void Qt5Frame::SetPointer( PointerStyle ePointerStyle )
+{
+}
+
+void Qt5Frame::CaptureMouse( bool bMouse )
+{
+}
+
+void Qt5Frame::SetPointerPos( long nX, long nY )
+{
+}
+
+void Qt5Frame::Flush()
+{
+}
+
+void Qt5Frame::Flush( const tools::Rectangle& rRect )
+{
+}
+
+void Qt5Frame::SetInputContext( SalInputContext* pContext )
+{
+}
+
+void Qt5Frame::EndExtTextInput( EndExtTextInputFlags nFlags )
+{
+}
+
+OUString Qt5Frame::GetKeyName( sal_uInt16 nKeyCode )
+{
+ return OUString();
+}
+
+bool Qt5Frame::MapUnicodeToKeyCode( sal_Unicode aUnicode, LanguageType aLangType, vcl::KeyCode& rKeyCode )
+{
+ return false;
+}
+
+LanguageType Qt5Frame::GetInputLanguage()
+{
+ return LANGUAGE_DONTKNOW;
+}
+
+void Qt5Frame::UpdateSettings( AllSettings& rSettings )
+{
+}
+
+void Qt5Frame::Beep()
+{
+}
+
+const SystemEnvData* Qt5Frame::GetSystemData() const
+{
+ return nullptr;
+}
+
+SalFrame::SalPointerState Qt5Frame::GetPointerState()
+{
+ return SalPointerState();
+}
+
+KeyIndicatorState Qt5Frame::GetIndicatorState()
+{
+ return KeyIndicatorState();
+}
+
+void Qt5Frame::SimulateKeyPress( sal_uInt16 nKeyCode )
+{
+}
+
+void Qt5Frame::SetParent( SalFrame* pNewParent )
+{
+ m_pParent = static_cast< Qt5Frame* >( pNewParent );
+}
+
+bool Qt5Frame::SetPluginParent( SystemParentData* pNewParent )
+{
+ return false;
+}
+
+void Qt5Frame::ResetClipRegion()
+{
+}
+
+void Qt5Frame::BeginSetClipRegion( sal_uLong nRects )
+{
+}
+
+void Qt5Frame::UnionClipRegion( long nX, long nY, long nWidth, long nHeight )
+{
+}
+
+void Qt5Frame::EndSetClipRegion()
+{
+}
+
+void Qt5Frame::SetScreenNumber( unsigned int )
+{
+}
+
+void Qt5Frame::SetApplicationID(const OUString &)
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5Frame.hxx b/vcl/qt5/Qt5Frame.hxx
new file mode 100644
index 000000000000..209561780414
--- /dev/null
+++ b/vcl/qt5/Qt5Frame.hxx
@@ -0,0 +1,116 @@
+/* -*- 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 .
+ */
+
+#pragma once
+
+#include <salframe.hxx>
+
+#include <memory>
+
+class Qt5Graphics;
+class Qt5Instance;
+class Qt5Widget;
+class QWidget;
+class QPaintDevice;
+class QImage;
+
+class Qt5Frame
+ : public SalFrame
+{
+ friend class Qt5Widget;
+
+ std::unique_ptr< QWidget > m_pQWidget;
+ std::unique_ptr< QImage > m_pQImage;
+ std::unique_ptr< Qt5Graphics > m_pGraphics;
+ bool m_bGraphicsInUse;
+ SalFrameStyleFlags m_nStyle;
+ Qt5Frame *m_pParent;
+
+ bool isChild( bool bPlug = true, bool bSysChild = true )
+ {
+ SalFrameStyleFlags nMask = SalFrameStyleFlags::NONE;
+ if( bPlug )
+ nMask |= SalFrameStyleFlags::PLUG;
+ if( bSysChild )
+ nMask |= SalFrameStyleFlags::SYSTEMCHILD;
+ return bool(m_nStyle & nMask);
+ }
+
+ void TriggerPaintEvent();
+
+public:
+ Qt5Frame( Qt5Frame* pParent,
+ SalFrameStyleFlags nSalFrameStyle );
+ virtual ~Qt5Frame() override;
+
+ QWidget* GetQWidget() const { return m_pQWidget.get(); }
+
+ virtual SalGraphics* AcquireGraphics() override;
+ virtual void ReleaseGraphics( SalGraphics* pGraphics ) override;
+
+ virtual bool PostEvent(ImplSVEvent* pData) override;
+
+ virtual void SetTitle( const OUString& rTitle ) override;
+ virtual void SetIcon( sal_uInt16 nIcon ) override;
+ virtual void SetMenu( SalMenu* pMenu ) override;
+ virtual void DrawMenuBar() override;
+
+ virtual void SetExtendedFrameStyle( SalExtStyle nExtStyle ) override;
+ virtual void Show( bool bVisible, bool bNoActivate = false ) override;
+ virtual void SetMinClientSize( long nWidth, long nHeight ) override;
+ virtual void SetMaxClientSize( long nWidth, long nHeight ) override;
+ virtual void SetPosSize( long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags ) override;
+ virtual void GetClientSize( long& rWidth, long& rHeight ) override;
+ virtual void GetWorkArea( tools::Rectangle& rRect ) override;
+ virtual SalFrame* GetParent() const override;
+ virtual void SetWindowState( const SalFrameState* pState ) override;
+ virtual bool GetWindowState( SalFrameState* pState ) override;
+ virtual void ShowFullScreen( bool bFullScreen, sal_Int32 nDisplay ) override;
+ virtual void StartPresentation( bool bStart ) override;
+ virtual void SetAlwaysOnTop( bool bOnTop ) override;
+ virtual void ToTop( SalFrameToTop nFlags ) override;
+ virtual void SetPointer( PointerStyle ePointerStyle ) override;
+ virtual void CaptureMouse( bool bMouse ) override;
+ virtual void SetPointerPos( long nX, long nY ) override;
+ virtual void Flush() override;
+ virtual void Flush( const tools::Rectangle& rRect ) override;
+ virtual void SetInputContext( SalInputContext* pContext ) override;
+ virtual void EndExtTextInput( EndExtTextInputFlags nFlags ) override;
+ virtual OUString GetKeyName( sal_uInt16 nKeyCode ) override;
+ virtual bool MapUnicodeToKeyCode( sal_Unicode aUnicode, LanguageType aLangType, vcl::KeyCode& rKeyCode ) override;
+ virtual LanguageType GetInputLanguage() override;
+ virtual void UpdateSettings( AllSettings& rSettings ) override;
+ virtual void Beep() override;
+ virtual const SystemEnvData* GetSystemData() const override;
+ virtual SalPointerState GetPointerState() override;
+ virtual KeyIndicatorState GetIndicatorState() override;
+ virtual void SimulateKeyPress( sal_uInt16 nKeyCode ) override;
+ virtual void SetParent( SalFrame* pNewParent ) override;
+ virtual bool SetPluginParent( SystemParentData* pNewParent ) override;
+ virtual void ResetClipRegion() override;
+ virtual void BeginSetClipRegion( sal_uLong nRects ) override;
+ virtual void UnionClipRegion( long nX, long nY, long nWidth, long nHeight ) override;
+ virtual void EndSetClipRegion() override;
+
+ virtual void SetScreenNumber( unsigned int ) override;
+ virtual void SetApplicationID(const OUString &) override;
+
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5Graphics.cxx b/vcl/qt5/Qt5Graphics.cxx
new file mode 100644
index 000000000000..1d0d15677eb4
--- /dev/null
+++ b/vcl/qt5/Qt5Graphics.cxx
@@ -0,0 +1,117 @@
+/* -*- 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 .
+ */
+
+#include "Qt5Graphics.hxx"
+#include "Qt5Frame.hxx"
+
+#include <QtWidgets/QWidget>
+
+#include <QtGui/QPainter>
+
+#include <QtGui/QImage>
+
+Qt5Graphics::Qt5Graphics( Qt5Frame *pFrame )
+ : m_pFrame( pFrame )
+ , m_pQImage( nullptr )
+ , m_pFontCollection( nullptr )
+{
+}
+
+Qt5Graphics::Qt5Graphics( QImage *pQImage )
+ : m_pFrame( nullptr )
+ , m_pQImage( pQImage )
+ , m_pFontCollection( nullptr )
+{
+}
+
+Qt5Graphics::~Qt5Graphics()
+{
+}
+
+void Qt5Graphics::PreparePainter()
+{
+ if ( m_pPainter.get() )
+ return;
+ if ( m_pQImage )
+ m_pPainter.reset( new QPainter( m_pQImage ) );
+ else
+ {
+ assert( dynamic_cast< QPaintDevice* >( m_pFrame->GetQWidget() ) );
+ m_pPainter.reset( new QPainter( m_pFrame->GetQWidget() ) );
+ }
+ if (!m_aClipRegion.isEmpty())
+ m_pPainter->setClipRegion( m_aClipRegion );
+}
+
+void Qt5Graphics::ChangeQImage( QImage *pQImage )
+{
+ m_pPainter.reset();
+ m_pQImage = pQImage;
+}
+
+SalGraphicsImpl* Qt5Graphics::GetImpl() const
+{
+ return nullptr;
+}
+
+SystemGraphicsData Qt5Graphics::GetGraphicsData() const
+{
+ return SystemGraphicsData();
+}
+
+bool Qt5Graphics::supportsOperation( OutDevSupportType ) const
+{
+ return false;
+}
+
+#if ENABLE_CAIRO_CANVAS
+
+bool Qt5Graphics::SupportsCairo() const
+{
+ return false;
+}
+
+cairo::SurfaceSharedPtr Qt5Graphics::CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const
+{
+ return nullptr;
+}
+
+cairo::SurfaceSharedPtr Qt5Graphics::CreateSurface(const OutputDevice& rRefDevice, int x, int y, int width, int height) const
+{
+ return nullptr;
+}
+
+cairo::SurfaceSharedPtr Qt5Graphics::CreateBitmapSurface(const OutputDevice& rRefDevice, const BitmapSystemData& rData, const Size& rSize) const
+{
+ return nullptr;
+}
+
+css::uno::Any Qt5Graphics::GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface, const basegfx::B2ISize& rSize) const
+{
+ return css::uno::Any();
+}
+
+SystemFontData Qt5Graphics::GetSysFontData( int nFallbacklevel ) const
+{
+ return SystemFontData();
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5Graphics.hxx b/vcl/qt5/Qt5Graphics.hxx
new file mode 100644
index 000000000000..b021134e54b7
--- /dev/null
+++ b/vcl/qt5/Qt5Graphics.hxx
@@ -0,0 +1,200 @@
+/* -*- 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 .
+ */
+
+#pragma once
+
+#include <salgdi.hxx>
+
+#include <memory>
+
+#include <QtGui/QRegion>
+
+class Qt5Frame;
+class PhysicalFontCollection;
+class PhysicalFontFace;
+class QImage;
+class QPainter;
+
+class Qt5Graphics : public SalGraphics
+{
+ friend class Qt5Bitmap;
+
+ Qt5Frame *m_pFrame;
+ QImage *m_pQImage;
+ QRegion m_aClipRegion;
+ std::unique_ptr< QPainter > m_pPainter;
+ PhysicalFontCollection *m_pFontCollection;
+ PhysicalFontFace *m_pFont;
+
+ void PreparePainter();
+
+public:
+ Qt5Graphics( Qt5Frame *pFrame );
+ Qt5Graphics( QImage *pImage );
+ virtual ~Qt5Graphics() override;
+
+ void ChangeQImage( QImage *pImage );
+
+ virtual SalGraphicsImpl* GetImpl() const override;
+ virtual SystemGraphicsData GetGraphicsData() const override;
+ virtual bool supportsOperation( OutDevSupportType ) const override;
+
+#if ENABLE_CAIRO_CANVAS
+ virtual bool SupportsCairo() const override;
+ virtual cairo::SurfaceSharedPtr CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const override;
+ virtual cairo::SurfaceSharedPtr CreateSurface(const OutputDevice& rRefDevice,
+ int x, int y, int width, int height) const override;
+ virtual cairo::SurfaceSharedPtr CreateBitmapSurface(const OutputDevice& rRefDevice,
+ const BitmapSystemData& rData, const Size& rSize) const override;
+ virtual css::uno::Any GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface,
+ const basegfx::B2ISize& rSize) const override;
+ virtual SystemFontData GetSysFontData( int nFallbacklevel ) const override;
+#endif // ENABLE_CAIRO_CANVAS
+
+ // GDI
+
+ virtual bool setClipRegion( const vcl::Region& ) override;
+ virtual void ResetClipRegion() override;
+
+ virtual void drawPixel( long nX, long nY ) override;
+ virtual void drawPixel( long nX, long nY, SalColor nSalColor ) override;
+ virtual void drawLine( long nX1, long nY1, long nX2, long nY2 ) override;
+ virtual void drawRect( long nX, long nY, long nWidth, long nHeight ) override;
+ virtual void drawPolyLine( sal_uInt32 nPoints, const SalPoint* pPtAry ) override;
+ virtual void drawPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry ) override;
+ virtual void drawPolyPolygon( sal_uInt32 nPoly, const sal_uInt32* pPoints, PCONSTSALPOINT* pPtAry ) override;
+ virtual bool drawPolyPolygon( const basegfx::B2DPolyPolygon&, double fTransparency ) override;
+ virtual bool drawPolyLineBezier( sal_uInt32 nPoints, const SalPoint* pPtAry, const PolyFlags* pFlgAry ) override;
+ virtual bool drawPolygonBezier( sal_uInt32 nPoints, const SalPoint* pPtAry, const PolyFlags* pFlgAry ) override;
+ virtual bool drawPolyPolygonBezier( sal_uInt32 nPoly, const sal_uInt32* pPoints, const SalPoint* const* pPtAry, const PolyFlags* const* pFlgAry ) override;
+ virtual bool drawPolyLine(
+ const basegfx::B2DPolygon&,
+ double fTransparency,
+ const basegfx::B2DVector& rLineWidths,
+ basegfx::B2DLineJoin,
+ css::drawing::LineCap eLineCap,
+ double fMiterMinimumAngle) override;
+ virtual bool drawGradient( const tools::PolyPolygon&, const Gradient& ) override;
+
+ virtual void copyArea( long nDestX, long nDestY, long nSrcX, long nSrcY, long nSrcWidth,
+ long nSrcHeight, bool bWindowInvalidate ) override;
+
+ virtual void copyBits( const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics ) override;
+ virtual void drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap ) override;
+ virtual void drawBitmap( const SalTwoRect& rPosAry,
+ const SalBitmap& rSalBitmap,
+ const SalBitmap& rTransparentBitmap ) override;
+ virtual void drawMask( const SalTwoRect& rPosAry,
+ const SalBitmap& rSalBitmap,
+ SalColor nMaskColor ) override;
+
+ virtual SalBitmap* getBitmap( long nX, long nY, long nWidth, long nHeight ) override;
+ virtual SalColor getPixel( long nX, long nY ) override;
+
+ virtual void invert( long nX, long nY, long nWidth, long nHeight, SalInvert nFlags) override;
+ virtual void invert( sal_uInt32 nPoints, const SalPoint* pPtAry, SalInvert nFlags ) override;
+
+ virtual bool drawEPS( long nX, long nY, long nWidth, long nHeight, void* pPtr, sal_uLong nSize ) override;
+
+ virtual bool blendBitmap( const SalTwoRect&,
+ const SalBitmap& rBitmap ) override;
+
+ virtual bool blendAlphaBitmap( const SalTwoRect&,
+ const SalBitmap& rSrcBitmap,
+ const SalBitmap& rMaskBitmap,
+ const SalBitmap& rAlphaBitmap ) override;
+
+ virtual bool drawAlphaBitmap( const SalTwoRect&,
+ const SalBitmap& rSourceBitmap,
+ const SalBitmap& rAlphaBitmap ) override;
+
+ bool drawTransformedBitmap(
+ const basegfx::B2DPoint& rNull,
+ const basegfx::B2DPoint& rX,
+ const basegfx::B2DPoint& rY,
+ const SalBitmap& rSourceBitmap,
+ const SalBitmap* pAlphaBitmap) override;
+
+ virtual bool drawAlphaRect( long nX, long nY, long nWidth,
+ long nHeight, sal_uInt8 nTransparency ) override;
+
+ virtual void GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY ) override;
+ virtual sal_uInt16 GetBitCount() const override;
+ virtual long GetGraphicsWidth() const override;
+
+ virtual void SetLineColor() override;
+ virtual void SetLineColor( SalColor nSalColor ) override;
+ virtual void SetFillColor() override;
+ virtual void SetFillColor( SalColor nSalColor ) override;
+ virtual void SetXORMode( bool bSet ) override;
+ virtual void SetROPLineColor( SalROPColor nROPColor ) override;
+ virtual void SetROPFillColor( SalROPColor nROPColor ) override;
+
+ // Text rendering + font support
+
+ virtual void SetTextColor( SalColor nSalColor ) override;
+ virtual void SetFont( const FontSelectPattern*, int nFallbackLevel ) override;
+ virtual void GetFontMetric( ImplFontMetricDataRef&, int nFallbackLevel ) override;
+ virtual const FontCharMapRef GetFontCharMap() const override;
+ virtual bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const override;
+ virtual void GetDevFontList( PhysicalFontCollection* ) override;
+ virtual void ClearDevFontCache() override;
+ virtual bool AddTempDevFont( PhysicalFontCollection*, const OUString& rFileURL, const OUString& rFontName ) override;
+ virtual bool CreateFontSubset( const OUString& rToFile,
+ const PhysicalFontFace* pFont,
+ const sal_GlyphId* pGlyphIds,
+ const sal_uInt8* pEncoding,
+ sal_Int32* pWidths,
+ int nGlyphs,
+ FontSubsetInfo& rInfo // out parameter
+ ) override;
+
+ virtual const void* GetEmbedFontData(const PhysicalFontFace*, long* pDataLen) override;
+ virtual void FreeEmbedFontData( const void* pData, long nDataLen ) override;
+
+ virtual void GetGlyphWidths( const PhysicalFontFace*,
+ bool bVertical,
+ std::vector< sal_Int32 >& rWidths,
+ Ucs2UIntMap& rUnicodeEnc ) override;
+
+ virtual bool GetGlyphBoundRect(const GlyphItem&, tools::Rectangle&) override;
+ virtual bool GetGlyphOutline(const GlyphItem&, basegfx::B2DPolyPolygon&) override;
+
+ virtual SalLayout* GetTextLayout( ImplLayoutArgs&, int nFallbackLevel ) override;
+ virtual void DrawTextLayout( const CommonSalLayout& ) override;
+
+ // Native control support
+
+ virtual bool IsNativeControlSupported( ControlType nType, ControlPart nPart ) override;
+ virtual bool hitTestNativeControl( ControlType nType, ControlPart nPart,
+ const tools::Rectangle& rControlRegion,
+ const Point& aPos, bool& rIsInside ) override;
+ virtual bool drawNativeControl( ControlType nType, ControlPart nPart,
+ const tools::Rectangle& rControlRegion,
+ ControlState nState, const ImplControlValue& aValue,
+ const OUString& aCaption ) override;
+ virtual bool getNativeControlRegion( ControlType nType, ControlPart nPart,
+ const tools::Rectangle& rControlRegion, ControlState nState,
+ const ImplControlValue& aValue, const OUString& aCaption,
+ tools::Rectangle &rNativeBoundingRegion,
+ tools::Rectangle &rNativeContentRegion ) override;
+
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5Graphics_Controls.cxx b/vcl/qt5/Qt5Graphics_Controls.cxx
new file mode 100644
index 000000000000..42b6b3caf729
--- /dev/null
+++ b/vcl/qt5/Qt5Graphics_Controls.cxx
@@ -0,0 +1,51 @@
+/* -*- 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 .
+ */
+
+#include "Qt5Graphics.hxx"
+
+bool Qt5Graphics::IsNativeControlSupported( ControlType nType, ControlPart nPart )
+{
+ return false;
+}
+
+bool Qt5Graphics::hitTestNativeControl( ControlType nType, ControlPart nPart,
+ const tools::Rectangle& rControlRegion,
+ const Point& aPos, bool& rIsInside )
+{
+ return false;
+}
+
+bool Qt5Graphics::drawNativeControl( ControlType nType, ControlPart nPart,
+ const tools::Rectangle& rControlRegion,
+ ControlState nState, const ImplControlValue& aValue,
+ const OUString& aCaption )
+{
+ return false;
+}
+
+bool Qt5Graphics::getNativeControlRegion( ControlType nType, ControlPart nPart,
+ const tools::Rectangle& rControlRegion, ControlState nState,
+ const ImplControlValue& aValue, const OUString& aCaption,
+ tools::Rectangle &rNativeBoundingRegion,
+ tools::Rectangle &rNativeContentRegion )
+{
+ return false;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5Graphics_GDI.cxx b/vcl/qt5/Qt5Graphics_GDI.cxx
new file mode 100644
index 000000000000..b790278cdce0
--- /dev/null
+++ b/vcl/qt5/Qt5Graphics_GDI.cxx
@@ -0,0 +1,335 @@
+/* -*- 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 .
+ */
+
+#include "Qt5Graphics.hxx"
+
+#include "Qt5Bitmap.hxx"
+#include "Qt5Frame.hxx"
+#include "Qt5Tools.hxx"
+
+#include <QtGui/QPainter>
+#include <QtGui/QScreen>
+#include <QtGui/QWindow>
+#include <QtWidgets/QWidget>
+
+bool Qt5Graphics::setClipRegion( const vcl::Region& rRegion )
+{
+ PreparePainter();
+ if ( rRegion.IsRectangle() )
+ m_aClipRegion = toQRect( rRegion.GetBoundRect() );
+ else if( !rRegion.HasPolyPolygonOrB2DPolyPolygon() )
+ {
+ QRegion aQRegion;
+ RectangleVector aRectangles;
+ rRegion.GetRegionRectangles( aRectangles );
+ for ( auto & rRect : aRectangles )
+ aQRegion += toQRect( rRect );
+ m_aClipRegion = aQRegion;
+ }
+ else
+ {
+ QPolygon aPolygon;
+ }
+ m_pPainter->setClipRegion( m_aClipRegion );
+ return true;
+}
+
+void Qt5Graphics::ResetClipRegion()
+{
+ m_aClipRegion = QRegion( m_pQImage->rect() );
+ PreparePainter();
+}
+
+void Qt5Graphics::drawPixel( long nX, long nY )
+{
+ PreparePainter();
+ m_pPainter->drawPoint( nX, nY );
+}
+
+void Qt5Graphics::drawPixel( long nX, long nY, SalColor nSalColor )
+{
+ PreparePainter();
+ m_pPainter->setPen( QColor( QRgb( nSalColor ) ) );
+ m_pPainter->drawPoint( nX, nY );
+}
+
+void Qt5Graphics::drawLine( long nX1, long nY1, long nX2, long nY2 )
+{
+ PreparePainter();
+ m_pPainter->drawLine( nX1, nY1, nX2, nY2 );
+}
+
+void Qt5Graphics::drawRect( long nX, long nY, long nWidth, long nHeight )
+{
+ PreparePainter();
+ m_pPainter->drawRect( nX, nY, nWidth, nHeight );
+}
+
+void Qt5Graphics::drawPolyLine( sal_uInt32 nPoints, const SalPoint* pPtAry )
+{
+ PreparePainter();
+ QPoint *pPoints = new QPoint[ nPoints ];
+ for ( sal_uInt32 i = 0; i < nPoints; ++i, ++pPtAry )
+ pPoints[ i ] = QPoint( pPtAry->mnX, pPtAry->mnY );
+ m_pPainter->drawPolyline( pPoints, nPoints );
+ delete [] pPoints;
+}
+
+void Qt5Graphics::drawPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry )
+{
+ PreparePainter();
+ QPoint *pPoints = new QPoint[ nPoints ];
+ for ( sal_uInt32 i = 0; i < nPoints; ++i, ++pPtAry )
+ pPoints[ i ] = QPoint( pPtAry->mnX, pPtAry->mnY );
+ m_pPainter->drawPolygon( pPoints, nPoints );
+ delete [] pPoints;
+}
+
+void Qt5Graphics::drawPolyPolygon( sal_uInt32 nPoly, const sal_uInt32* pPoints, PCONSTSALPOINT* pPtAry )
+{
+ if( 0 == nPoly )
+ return;
+}
+
+bool Qt5Graphics::drawPolyPolygon( const basegfx::B2DPolyPolygon&, double fTransparency )
+{
+ return false;
+}
+
+bool Qt5Graphics::drawPolyLineBezier( sal_uInt32 nPoints, const SalPoint* pPtAry, const PolyFlags* pFlgAry )
+{
+ return false;
+}
+
+bool Qt5Graphics::drawPolygonBezier( sal_uInt32 nPoints, const SalPoint* pPtAry, const PolyFlags* pFlgAry )
+{
+ return false;
+}
+
+bool Qt5Graphics::drawPolyPolygonBezier( sal_uInt32 nPoly, const sal_uInt32* pPoints,
+ const SalPoint* const* pPtAry, const PolyFlags* const* pFlgAry )
+{
+ return false;
+}
+
+bool Qt5Graphics::drawPolyLine( const basegfx::B2DPolygon&,
+ double fTransparency,
+ const basegfx::B2DVector& rLineWidths,
+ basegfx::B2DLineJoin,
+ css::drawing::LineCap eLineCap,
+ double fMiterMinimumAngle )
+{
+ return false;
+}
+
+bool Qt5Graphics::drawGradient( const tools::PolyPolygon&, const Gradient& )
+{
+ return false;
+}
+
+void Qt5Graphics::copyArea( long nDestX, long nDestY, long nSrcX, long nSrcY, long nSrcWidth,
+ long nSrcHeight, bool bWindowInvalidate )
+{
+ if ( nDestX == nSrcX && nDestY == nSrcY )
+ return;
+
+ SalTwoRect aTR( nSrcX, nSrcY, nSrcWidth, nSrcHeight,
+ nDestX, nDestY, nSrcWidth, nSrcHeight );
+ copyBits( aTR, this );
+}
+
+void Qt5Graphics::copyBits( const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics )
+{
+ if( rPosAry.mnSrcWidth <= 0 || rPosAry.mnSrcHeight <= 0
+ || rPosAry.mnDestWidth <= 0 || rPosAry.mnDestHeight <= 0 )
+ return;
+
+ assert( rPosAry.mnSrcWidth == rPosAry.mnDestWidth );
+ assert( rPosAry.mnSrcHeight == rPosAry.mnDestHeight );
+
+ QImage *pImage;
+ QImage aImage;
+ 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 );
+ pImage = &aImage;
+ }
+ else
+ pImage = static_cast< Qt5Graphics* >( pSrcGraphics )->m_pQImage;
+
+ PreparePainter();
+ m_pPainter->drawImage( QPoint( rPosAry.mnDestX, rPosAry.mnDestY ),
+ *pImage, QRect( rPosAry.mnSrcX, rPosAry.mnSrcY,
+ rPosAry.mnSrcWidth, rPosAry.mnSrcHeight) );
+}
+
+void Qt5Graphics::drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap )
+{
+ if( rPosAry.mnSrcWidth <= 0 || rPosAry.mnSrcHeight <= 0
+ || rPosAry.mnDestWidth <= 0 || rPosAry.mnDestHeight <= 0 )
+ return;
+
+ assert( rPosAry.mnSrcWidth == rPosAry.mnDestWidth );
+ assert( rPosAry.mnSrcHeight == rPosAry.mnDestHeight );
+
+ PreparePainter();
+ const QImage *pImage = static_cast< const Qt5Bitmap* >( &rSalBitmap )->GetQImage();
+
+ m_pPainter->drawImage( QPoint( rPosAry.mnDestX, rPosAry.mnDestY ),
+ *pImage, QRect( rPosAry.mnSrcX, rPosAry.mnSrcY,
+ rPosAry.mnSrcWidth, rPosAry.mnSrcHeight) );
+
+ // Workaround to get updates
+ if ( m_pFrame )
+ m_pFrame->GetQWidget()->update();
+}
+
+void Qt5Graphics::drawBitmap( const SalTwoRect& rPosAry,
+ const SalBitmap& rSalBitmap,
+ const SalBitmap& rTransparentBitmap )
+{
+}
+
+void Qt5Graphics::drawMask( const SalTwoRect& rPosAry,
+ const SalBitmap& rSalBitmap,
+ SalColor nMaskColor )
+{
+}
+
+SalBitmap* Qt5Graphics::getBitmap( long nX, long nY, long nWidth, long nHeight )
+{
+ return new Qt5Bitmap( m_pQImage->copy( nX, nY, nWidth, nHeight ) );
+}
+
+SalColor Qt5Graphics::getPixel( long nX, long nY )
+{
+ return m_pQImage->pixel( nX, nY );
+}
+
+void Qt5Graphics::invert( long nX, long nY, long nWidth, long nHeight, SalInvert nFlags)
+{
+}
+
+void Qt5Graphics::invert( sal_uInt32 nPoints, const SalPoint* pPtAry, SalInvert nFlags )
+{
+}
+
+bool Qt5Graphics::drawEPS( long nX, long nY, long nWidth, long nHeight, void* pPtr, sal_uLong nSize )
+{
+ return false;
+}
+
+bool Qt5Graphics::blendBitmap( const SalTwoRect&,
+ const SalBitmap& rBitmap )
+{
+ return false;
+}
+
+bool Qt5Graphics::blendAlphaBitmap( const SalTwoRect&,
+ const SalBitmap& rSrcBitmap,
+ const SalBitmap& rMaskBitmap,
+ const SalBitmap& rAlphaBitmap )
+{
+ return false;
+}
+
+bool Qt5Graphics::drawAlphaBitmap( const SalTwoRect&,
+ const SalBitmap& rSourceBitmap,
+ const SalBitmap& rAlphaBitmap )
+{
+ return false;
+}
+
+bool Qt5Graphics::drawTransformedBitmap(
+ const basegfx::B2DPoint& rNull,
+ const basegfx::B2DPoint& rX,
+ const basegfx::B2DPoint& rY,
+ const SalBitmap& rSourceBitmap,
+ const SalBitmap* pAlphaBitmap)
+{
+ return false;
+}
+
+bool Qt5Graphics::drawAlphaRect( long nX, long nY, long nWidth,
+ long nHeight, sal_uInt8 nTransparency )
+{
+ return false;
+}
+
+void Qt5Graphics::GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY )
+{
+ 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();
+}
+
+sal_uInt16 Qt5Graphics::GetBitCount() const
+{
+ return getFormatBits( m_pQImage->format() );
+}
+
+long Qt5Graphics::GetGraphicsWidth() const
+{
+ return m_pQImage->width();
+}
+
+void Qt5Graphics::SetLineColor()
+{
+}
+
+void Qt5Graphics::SetLineColor( SalColor nSalColor )
+{
+}
+
+void Qt5Graphics::SetFillColor()
+{
+}
+
+void Qt5Graphics::SetFillColor( SalColor nSalColor )
+{
+}
+
+void Qt5Graphics::SetXORMode( bool bSet )
+{
+}
+
+void Qt5Graphics::SetROPLineColor( SalROPColor nROPColor )
+{
+}
+
+void Qt5Graphics::SetROPFillColor( SalROPColor nROPColor )
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5Graphics_Text.cxx b/vcl/qt5/Qt5Graphics_Text.cxx
new file mode 100644
index 000000000000..fe6931c84458
--- /dev/null
+++ b/vcl/qt5/Qt5Graphics_Text.cxx
@@ -0,0 +1,118 @@
+/* -*- 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 .
+ */
+
+#include "Qt5Graphics.hxx"
+#include "Qt5FontFace.hxx"
+
+#include <vcl/fontcharmap.hxx>
+
+#include <PhysicalFontCollection.hxx>
+
+#include <QtGui/QFontDatabase>
+#include <QtCore/QStringList>
+
+void Qt5Graphics::SetTextColor( SalColor nSalColor )
+{
+}
+
+void Qt5Graphics::SetFont( const FontSelectPattern*, int nFallbackLevel )
+{
+}
+
+void Qt5Graphics::GetFontMetric( ImplFontMetricDataRef &rFMD, int nFallbackLevel )
+{
+}
+
+const FontCharMapRef Qt5Graphics::GetFontCharMap() const
+{
+ return nullptr;
+}
+
+bool Qt5Graphics::GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const
+{
+ return false;
+}
+
+void Qt5Graphics::GetDevFontList( PhysicalFontCollection* pPFC )
+{
+ m_pFontCollection = pPFC;
+ if ( pPFC->Count() )
+ return;
+
+ QFontDatabase aFDB;
+ for ( auto& family : aFDB.families() )
+ for ( auto& style : aFDB.styles( family ) )
+ {
+ // Just get any size - we don't care
+ QList<int> sizes = aFDB.smoothSizes(family, style);
+ pPFC->Add( Qt5FontFace::fromQFont( aFDB.font( family, style, *sizes.begin() ) ) );
+ }
+}
+
+void Qt5Graphics::ClearDevFontCache()
+{
+}
+
+bool Qt5Graphics::AddTempDevFont( PhysicalFontCollection*, const OUString& rFileURL, const OUString& rFontName )
+{
+ return false;
+}
+
+bool Qt5Graphics::CreateFontSubset( const OUString& rToFile, const PhysicalFontFace* pFont,
+ const sal_GlyphId* pGlyphIds, const sal_uInt8* pEncoding,
+ sal_Int32* pWidths, int nGlyphs, FontSubsetInfo& rInfo )
+{
+ return false;
+}
+
+const void* Qt5Graphics::GetEmbedFontData( const PhysicalFontFace*, long* pDataLen )
+{
+ return nullptr;
+}
+
+void Qt5Graphics::FreeEmbedFontData( const void* pData, long nDataLen )
+{
+}
+
+void Qt5Graphics::GetGlyphWidths( const PhysicalFontFace*, bool bVertical,
+ std::vector< sal_Int32 >& rWidths,
+ Ucs2UIntMap& rUnicodeEnc )
+{
+}
+
+bool Qt5Graphics::GetGlyphBoundRect( const GlyphItem&, tools::Rectangle& )
+{
+ return false;
+}
+
+bool Qt5Graphics::GetGlyphOutline( const GlyphItem&, basegfx::B2DPolyPolygon& )
+{
+ return false;
+}
+
+SalLayout* Qt5Graphics::GetTextLayout( ImplLayoutArgs&, int nFallbackLevel )
+{
+ return nullptr;
+}
+
+void Qt5Graphics::DrawTextLayout( const CommonSalLayout& )
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5Instance.cxx b/vcl/qt5/Qt5Instance.cxx
new file mode 100644
index 000000000000..dd2daf7e8b8b
--- /dev/null
+++ b/vcl/qt5/Qt5Instance.cxx
@@ -0,0 +1,278 @@
+/* -*- 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 .
+ */
+
+#include "Qt5Instance.hxx"
+#include <Qt5Instance.moc>
+
+#include "Qt5Frame.hxx"
+#include "Qt5Data.hxx"
+#include "Qt5Timer.hxx"
+#include "Qt5VirtualDevice.hxx"
+#include "Qt5Object.hxx"
+#include "Qt5Bitmap.hxx"
+
+#include <QtCore/QThread>
+#include <QtWidgets/QApplication>
+#include <QtCore/QAbstractEventDispatcher>
+
+#include <vclpluginapi.h>
+#include <sal/log.hxx>
+#include <osl/process.h>
+
+#include <headless/svpdummies.hxx>
+#include <headless/svpbmp.hxx>
+
+Qt5Instance::Qt5Instance( SalYieldMutex* pMutex )
+ : SalGenericInstance( pMutex )
+ , m_postUserEventId( -1 )
+{
+ m_postUserEventId = QEvent::registerEventType();
+
+ // this one needs to be blocking, so that the handling in main thread
+ // is processed before the thread emitting the signal continues
+ connect( this, SIGNAL( ImplYieldSignal( bool, bool )),
+ this, SLOT( ImplYield( bool, bool )), Qt::BlockingQueuedConnection );
+}
+
+Qt5Instance::~Qt5Instance()
+{
+ // force freeing the QApplication before freeing the arguments,
+ // as it uses references to the provided arguments!
+ m_pQApplication.reset();
+ for( int i = 0; i < *m_pFakeArgc; i++ )
+ free( m_pFakeArgvFreeable[i] );
+}
+
+SalFrame* Qt5Instance::CreateChildFrame( SystemParentData* /*pParent*/, SalFrameStyleFlags nStyle )
+{
+ return new Qt5Frame( nullptr, nStyle );
+}
+
+SalFrame* Qt5Instance::CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle )
+{
+ assert( !pParent || dynamic_cast<Qt5Frame*>( pParent ) );
+ return new Qt5Frame( static_cast<Qt5Frame*>( pParent ), nStyle );
+}
+
+void Qt5Instance::DestroyFrame( SalFrame* pFrame )
+{
+ delete pFrame;
+}
+
+SalObject* Qt5Instance::CreateObject( SalFrame* pParent, SystemWindowData*, bool bShow )
+{
+ assert( !pParent || dynamic_cast<Qt5Frame*>( pParent ) );
+ return new Qt5Object( static_cast<Qt5Frame*>( pParent ), bShow );
+}
+
+void Qt5Instance::DestroyObject( SalObject* pObject )
+{
+ delete pObject;
+}
+
+SalVirtualDevice* Qt5Instance::CreateVirtualDevice( SalGraphics* /* pGraphics */,
+ long &nDX, long &nDY,
+ DeviceFormat eFormat,
+ const SystemGraphicsData* /* pData */ )
+{
+ Qt5VirtualDevice* pVD = new Qt5VirtualDevice( eFormat, 1 );
+ pVD->SetSize( nDX, nDY );
+ return pVD;
+}
+
+SalTimer* Qt5Instance::CreateSalTimer()
+{
+ return new Qt5Timer();
+}
+
+SalSystem* Qt5Instance::CreateSalSystem()
+{
+ return new SvpSalSystem();
+}
+
+SalBitmap* Qt5Instance::CreateSalBitmap()
+{
+ return new Qt5Bitmap();
+}
+
+bool Qt5Instance::ImplYield( bool bWait, bool bHandleAllCurrentEvents )
+{
+ bool wasEvent = DispatchUserEvents( bHandleAllCurrentEvents );
+ if ( !bHandleAllCurrentEvents && wasEvent )
+ return true;
+
+ /**
+ * Quoting the Qt docs: [QAbstractEventDispatcher::processEvents] processes
+ * pending events that match flags until there are no more events to process.
+ */
+ QAbstractEventDispatcher* dispatcher = QAbstractEventDispatcher::instance( qApp->thread());
+ if ( bWait && !wasEvent )
+ wasEvent = dispatcher->processEvents( QEventLoop::WaitForMoreEvents );
+ else
+ wasEvent = dispatcher->processEvents( QEventLoop::AllEvents ) || wasEvent;
+ return wasEvent;
+}
+
+bool Qt5Instance::DoYield(bool bWait, bool bHandleAllCurrentEvents)
+{
+ bool bWasEvent = false;
+ if( qApp->thread() == QThread::currentThread() )
+ {
+ bWasEvent = ImplYield( bWait, bHandleAllCurrentEvents );
+ if ( bWasEvent )
+ m_aWaitingYieldCond.set();
+ }
+ else
+ {
+ {
+ SolarMutexReleaser aReleaser;
+ bWasEvent = Q_EMIT ImplYieldSignal( false, bHandleAllCurrentEvents );
+ }
+ if ( !bWasEvent && bWait )
+ {
+ m_aWaitingYieldCond.reset();
+ SolarMutexReleaser aReleaser;
+ m_aWaitingYieldCond.wait();
+ bWasEvent = true;
+ }
+ }
+ return bWasEvent;
+}
+
+bool Qt5Instance::AnyInput( VclInputFlags nType )
+{
+ return false;
+}
+
+SalSession* Qt5Instance::CreateSalSession()
+{
+ return nullptr;
+}
+
+OUString Qt5Instance::GetConnectionIdentifier()
+{
+ return OUString();
+}
+
+void Qt5Instance::AddToRecentDocumentList(const OUString&, const OUString&, const OUString&)
+{
+}
+
+OpenGLContext* Qt5Instance::CreateOpenGLContext()
+{
+ return nullptr;
+}
+
+bool Qt5Instance::IsMainThread() const
+{
+ return qApp->thread() != QThread::currentThread();
+}
+
+void Qt5Instance::TriggerUserEventProcessing()
+{
+ QApplication::postEvent(this, new QEvent(QEvent::Type( m_postUserEventId )));
+}
+
+void Qt5Instance::ProcessEvent( SalUserEvent aEvent )
+{
+ aEvent.m_pFrame->CallCallback( aEvent.m_nEvent, aEvent.m_pData );
+}
+
+extern "C" {
+ VCLPLUG_QT5_PUBLIC SalInstance* create_SalInstance()
+ {
+ OString aVersion( qVersion() );
+ SAL_INFO( "vcl.kf5", "qt version string is " << aVersion );
+
+ QApplication *pQApplication;
+ char **pFakeArgvFreeable = nullptr;
+
+ int nFakeArgc = 2;
+ const sal_uInt32 nParams = osl_getCommandArgCount();
+ OString aDisplay;
+ OUString aParam, aBin;
+
+ for ( sal_uInt32 nIdx = 0; nIdx < nParams; ++nIdx )
+ {
+ osl_getCommandArg( nIdx, &aParam.pData );
+ if ( aParam != "-display" )
+ continue;
+ if ( !pFakeArgvFreeable )
+ {
+ pFakeArgvFreeable = new char*[ nFakeArgc + 2 ];
+ pFakeArgvFreeable[ nFakeArgc++ ] = strdup( "-display" );
+ }
+ else
+ free( pFakeArgvFreeable[ nFakeArgc ] );
+
+ ++nIdx;
+ osl_getCommandArg( nIdx, &aParam.pData );
+ aDisplay = OUStringToOString( aParam, osl_getThreadTextEncoding() );
+ pFakeArgvFreeable[ nFakeArgc ] = strdup( aDisplay.getStr() );
+ }
+ if ( !pFakeArgvFreeable )
+ pFakeArgvFreeable = new char*[ nFakeArgc ];
+ else
+ nFakeArgc++;
+
+ osl_getExecutableFile( &aParam.pData );
+ osl_getSystemPathFromFileURL( aParam.pData, &aBin.pData );
+ OString aExec = OUStringToOString( aBin, osl_getThreadTextEncoding() );
+ pFakeArgvFreeable[ 0 ] = strdup( aExec.getStr() );
+ pFakeArgvFreeable[ 1 ] = strdup( "--nocrashhandler" );
+
+ char **pFakeArgv = new char*[ nFakeArgc ];
+ for( int i = 0; i < nFakeArgc; i++ )
+ pFakeArgv[ i ] = pFakeArgvFreeable[ i ];
+
+ char* session_manager = nullptr;
+ if( getenv( "SESSION_MANAGER" ) != nullptr )
+ {
+ session_manager = strdup( getenv( "SESSION_MANAGER" ));
+ unsetenv( "SESSION_MANAGER" );
+ }
+
+ int * pFakeArgc = new int;
+ *pFakeArgc = nFakeArgc;
+ pQApplication = new QApplication( *pFakeArgc, pFakeArgv );
+
+ if( session_manager != nullptr )
+ {
+ // coverity[tainted_string] - trusted source for setenv
+ setenv( "SESSION_MANAGER", session_manager, 1 );
+ free( session_manager );
+ }
+
+ QApplication::setQuitOnLastWindowClosed(false);
+
+ Qt5Instance* pInstance = new Qt5Instance( new SalYieldMutex() );
+
+ // initialize SalData
+ new Qt5Data( pInstance );
+
+ pInstance->m_pQApplication.reset( pQApplication );
+ pInstance->m_pFakeArgvFreeable.reset( pFakeArgvFreeable );
+ pInstance->m_pFakeArgv.reset( pFakeArgv );
+ pInstance->m_pFakeArgc.reset( pFakeArgc );
+
+ return pInstance;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5Instance.hxx b/vcl/qt5/Qt5Instance.hxx
new file mode 100644
index 000000000000..ff0cacc7be97
--- /dev/null
+++ b/vcl/qt5/Qt5Instance.hxx
@@ -0,0 +1,105 @@
+/* -*- 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 .
+ */
+
+#pragma once
+
+#include <unx/geninst.h>
+#include <salusereventlist.hxx>
+
+#include <osl/conditn.hxx>
+
+#include <QtCore/QObject>
+
+class QApplication;
+class SalYieldMutex;
+class SalFrame;
+
+class Qt5Instance
+ : public QObject
+ , public SalGenericInstance
+ , public SalUserEventList
+{
+ Q_OBJECT
+
+ osl::Condition m_aWaitingYieldCond;
+ int m_postUserEventId;
+
+public:
+ std::unique_ptr< QApplication > m_pQApplication;
+ std::unique_ptr< char*[] > m_pFakeArgvFreeable;
+ std::unique_ptr< char*[] > m_pFakeArgv;
+ std::unique_ptr< int > m_pFakeArgc;
+
+private Q_SLOTS:
+ bool ImplYield( bool bWait, bool bHandleAllCurrentEvents );
+
+Q_SIGNALS:
+ bool ImplYieldSignal( bool bWait, bool bHandleAllCurrentEvents );
+
+public:
+ explicit Qt5Instance( SalYieldMutex* pMutex );
+ virtual ~Qt5Instance() override;
+
+ virtual SalFrame* CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle ) override;
+ virtual SalFrame* CreateChildFrame( SystemParentData* pParent, SalFrameStyleFlags nStyle ) override;
+ virtual void DestroyFrame( SalFrame* pFrame ) override;
+
+ virtual SalObject* CreateObject( SalFrame* pParent, SystemWindowData* pWindowData, bool bShow ) override;
+ virtual void DestroyObject( SalObject* pObject ) override;
+
+ virtual SalVirtualDevice* CreateVirtualDevice( SalGraphics* pGraphics, long &nDX, long &nDY,
+ DeviceFormat eFormat, const SystemGraphicsData *pData = nullptr ) override;
+
+ virtual SalInfoPrinter* CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo,
+ ImplJobSetup* pSetupData ) override;
+ virtual void DestroyInfoPrinter( SalInfoPrinter* pPrinter ) override;
+ virtual SalPrinter* CreatePrinter( SalInfoPrinter* pInfoPrinter ) override;
+ virtual void DestroyPrinter( SalPrinter* pPrinter ) override;
+ virtual void GetPrinterQueueInfo( ImplPrnQueueList* pList ) override;
+ virtual void GetPrinterQueueState( SalPrinterQueueInfo* pInfo ) override;
+ virtual void DeletePrinterQueueInfo( SalPrinterQueueInfo* pInfo ) override;
+ virtual OUString GetDefaultPrinter() override;
+ virtual void PostPrintersChanged() override;
+
+ virtual SalTimer* CreateSalTimer() override;
+ virtual SalSystem* CreateSalSystem() override;
+ virtual SalBitmap* CreateSalBitmap() override;
+
+ virtual bool DoYield(bool bWait, bool bHandleAllCurrentEvents) override;
+ virtual bool AnyInput( VclInputFlags nType ) override;
+
+ virtual SalSession* CreateSalSession() override;
+
+ virtual OpenGLContext* CreateOpenGLContext() override;
+
+ virtual OUString GetConnectionIdentifier() override;
+
+ virtual void AddToRecentDocumentList( const OUString& rFileUrl, const OUString& rMimeType,
+ const OUString& rDocumentService ) override;
+
+ virtual GenPspGraphics *CreatePrintGraphics() override;
+
+ virtual bool IsMainThread() const override;
+
+ virtual void TriggerUserEventProcessing() override;
+ virtual void ProcessEvent( SalUserEvent aEvent ) override;
+
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5Instance_Print.cxx b/vcl/qt5/Qt5Instance_Print.cxx
new file mode 100644
index 000000000000..4c1afd4f482f
--- /dev/null
+++ b/vcl/qt5/Qt5Instance_Print.cxx
@@ -0,0 +1,265 @@
+/* -*- 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 .
+ */
+
+#include "Qt5Instance.hxx"
+#include "Qt5Printer.hxx"
+
+#include <vcl/svapp.hxx>
+#include <vcl/timer.hxx>
+#include <printerinfomanager.hxx>
+
+#include <jobset.h>
+#include <print.h>
+#include <salptype.hxx>
+#include <saldatabasic.hxx>
+
+#include <unx/genpspgraphics.h>
+
+using namespace psp;
+
+/*
+ * static helpers
+ */
+
+static OUString getPdfDir( const PrinterInfo& rInfo )
+{
+ OUString aDir;
+ sal_Int32 nIndex = 0;
+ while( nIndex != -1 )
+ {
+ OUString aToken( rInfo.m_aFeatures.getToken( 0, ',', nIndex ) );
+ if( aToken.startsWith( "pdf=" ) )
+ {
+ sal_Int32 nPos = 0;
+ aDir = aToken.getToken( 1, '=', nPos );
+ if( aDir.isEmpty() )
+ aDir = OStringToOUString( OString( getenv( "HOME" ) ), osl_getThreadTextEncoding() );
+ break;
+ }
+ }
+ return aDir;
+}
+
+inline int PtTo10Mu( int nPoints ) { return (int)((((double)nPoints)*35.27777778)+0.5); }
+
+static void copyJobDataToJobSetup( ImplJobSetup* pJobSetup, JobData& rData )
+{
+ pJobSetup->SetOrientation( rData.m_eOrientation == orientation::Landscape ? Orientation::Landscape : Orientation::Portrait );
+
+ // copy page size
+ OUString aPaper;
+ int width, height;
+
+ rData.m_aContext.getPageSize( aPaper, width, height );
+ pJobSetup->SetPaperFormat( PaperInfo::fromPSName(OUStringToOString( aPaper, RTL_TEXTENCODING_ISO_8859_1 )) );
+ pJobSetup->SetPaperWidth( 0 );
+ pJobSetup->SetPaperHeight( 0 );
+ if( pJobSetup->GetPaperFormat() == PAPER_USER )
+ {
+ // transform to 100dth mm
+ width = PtTo10Mu( width );
+ height = PtTo10Mu( height );
+
+ if( rData.m_eOrientation == psp::orientation::Portrait )
+ {
+ pJobSetup->SetPaperWidth( width );
+ pJobSetup->SetPaperHeight( height );
+ }
+ else
+ {
+ pJobSetup->SetPaperWidth( height );
+ pJobSetup->SetPaperHeight( width );
+ }
+ }
+
+ // copy input slot
+ const PPDKey* pKey = nullptr;
+ const PPDValue* pValue = nullptr;
+
+ pJobSetup->SetPaperBin( 0xffff );
+ if( rData.m_pParser )
+ pKey = rData.m_pParser->getKey( OUString( "InputSlot" ) );
+ if( pKey )
+ pValue = rData.m_aContext.getValue( pKey );
+ if( pKey && pValue )
+ {
+ int nPaperBin;
+ for( nPaperBin = 0;
+ pValue != pKey->getValue( nPaperBin ) &&
+ nPaperBin < pKey->countValues();
+ nPaperBin++ );
+ pJobSetup->SetPaperBin(
+ (nPaperBin == pKey->countValues()
+ || pValue == pKey->getDefaultValue())
+ ? 0xffff : nPaperBin);
+ }
+
+ // copy duplex
+ pKey = nullptr;
+ pValue = nullptr;
+
+ pJobSetup->SetDuplexMode( DuplexMode::Unknown );
+ if( rData.m_pParser )
+ pKey = rData.m_pParser->getKey( OUString( "Duplex" ) );
+ if( pKey )
+ pValue = rData.m_aContext.getValue( pKey );
+ if( pKey && pValue )
+ {
+ if( pValue->m_aOption.equalsIgnoreAsciiCase( "None" ) ||
+ pValue->m_aOption.startsWithIgnoreAsciiCase( "Simplex" )
+ )
+ {
+ pJobSetup->SetDuplexMode( DuplexMode::Off );
+ }
+ else if( pValue->m_aOption.equalsIgnoreAsciiCase( "DuplexNoTumble" ) )
+ {
+ pJobSetup->SetDuplexMode( DuplexMode::LongEdge );
+ }
+ else if( pValue->m_aOption.equalsIgnoreAsciiCase( "DuplexTumble" ) )
+ {
+ pJobSetup->SetDuplexMode( DuplexMode::ShortEdge );
+ }
+ }
+
+ // copy the whole context
+ if( pJobSetup->GetDriverData() )
+ rtl_freeMemory( const_cast<sal_uInt8*>(pJobSetup->GetDriverData()) );
+
+ sal_uInt32 nBytes;
+ void* pBuffer = nullptr;
+ if( rData.getStreamBuffer( pBuffer, nBytes ) )
+ {
+ pJobSetup->SetDriverDataLen( nBytes );
+ pJobSetup->SetDriverData( static_cast<sal_uInt8*>(pBuffer) );
+ }
+ else
+ {
+ pJobSetup->SetDriverDataLen( 0 );
+ pJobSetup->SetDriverData( nullptr );
+ }
+}
+
+SalInfoPrinter* Qt5Instance::CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo,
+ ImplJobSetup* pJobSetup )
+{
+ // create and initialize SalInfoPrinter
+ Qt5InfoPrinter* pPrinter = new Qt5InfoPrinter;
+
+ if( pJobSetup )
+ {
+ PrinterInfoManager& rManager( PrinterInfoManager::get() );
+ PrinterInfo aInfo( rManager.getPrinterInfo( pQueueInfo->maPrinterName ) );
+ pPrinter->m_aJobData = aInfo;
+ pPrinter->m_aPrinterGfx.Init( pPrinter->m_aJobData );
+
+ if( pJobSetup->GetDriverData() )
+ JobData::constructFromStreamBuffer( pJobSetup->GetDriverData(),
+ pJobSetup->GetDriverDataLen(), aInfo );
+
+ pJobSetup->SetSystem( JOBSETUP_SYSTEM_UNIX );
+ pJobSetup->SetPrinterName( pQueueInfo->maPrinterName );
+ pJobSetup->SetDriver( aInfo.m_aDriverName );
+ copyJobDataToJobSetup( pJobSetup, aInfo );
+ }
+
+ return pPrinter;
+}
+
+void Qt5Instance::DestroyInfoPrinter( SalInfoPrinter* pPrinter )
+{
+ delete pPrinter;
+}
+
+SalPrinter* Qt5Instance::CreatePrinter( SalInfoPrinter* pInfoPrinter )
+{
+ // create and initialize SalPrinter
+ Qt5Printer* pPrinter = new Qt5Printer( pInfoPrinter );
+ pPrinter->m_aJobData = static_cast<Qt5InfoPrinter*>(pInfoPrinter)->m_aJobData;
+
+ return pPrinter;
+}
+
+void Qt5Instance::DestroyPrinter( SalPrinter* pPrinter )
+{
+ delete pPrinter;
+}
+
+void Qt5Instance::GetPrinterQueueInfo( ImplPrnQueueList* pList )
+{
+ PrinterInfoManager& rManager( PrinterInfoManager::get() );
+ static const char* pNoSyncDetection = getenv( "SAL_DISABLE_SYNCHRONOUS_PRINTER_DETECTION" );
+ if( ! pNoSyncDetection || ! *pNoSyncDetection )
+ {
+ // #i62663# synchronize possible asynchronouse printer detection now
+ rManager.checkPrintersChanged( true );
+ }
+ ::std::vector< OUString > aPrinters;
+ rManager.listPrinters( aPrinters );
+
+ for( ::std::vector< OUString >::iterator it = aPrinters.begin(); it != aPrinters.end(); ++it )
+ {
+ const PrinterInfo& rInfo( rManager.getPrinterInfo( *it ) );
+ // create new entry
+ SalPrinterQueueInfo* pInfo = new SalPrinterQueueInfo;
+ pInfo->maPrinterName = *it;
+ pInfo->maDriver = rInfo.m_aDriverName;
+ pInfo->maLocation = rInfo.m_aLocation;
+ pInfo->maComment = rInfo.m_aComment;
+ pInfo->mpSysData = nullptr;
+
+ sal_Int32 nIndex = 0;
+ while( nIndex != -1 )
+ {
+ OUString aToken( rInfo.m_aFeatures.getToken( 0, ',', nIndex ) );
+ if( aToken.startsWith( "pdf=" ) )
+ {
+ pInfo->maLocation = getPdfDir( rInfo );
+ break;
+ }
+ }
+
+ pList->Add( pInfo );
+ }
+}
+
+void Qt5Instance::DeletePrinterQueueInfo( SalPrinterQueueInfo* pInfo )
+{
+ delete pInfo;
+}
+
+void Qt5Instance::GetPrinterQueueState( SalPrinterQueueInfo* )
+{
+}
+
+OUString Qt5Instance::GetDefaultPrinter()
+{
+ PrinterInfoManager& rManager( PrinterInfoManager::get() );
+ return rManager.getDefaultPrinter();
+}
+
+void Qt5Instance::PostPrintersChanged()
+{
+}
+
+GenPspGraphics *Qt5Instance::CreatePrintGraphics()
+{
+ return new GenPspGraphics();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5Object.cxx b/vcl/qt5/Qt5Object.cxx
new file mode 100644
index 000000000000..ad7dfea8817e
--- /dev/null
+++ b/vcl/qt5/Qt5Object.cxx
@@ -0,0 +1,85 @@
+/* -*- 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 .
+ */
+
+#include "Qt5Object.hxx"
+
+#include "Qt5Frame.hxx"
+
+#include <QtWidgets/QWidget>
+
+Qt5Object::Qt5Object( Qt5Frame* pParent, bool bShow )
+ : m_pParent( pParent )
+{
+ if ( !m_pParent || !pParent->GetQWidget() )
+ return;
+ m_pQWidget.reset( new QWidget( pParent->GetQWidget() ) );
+ if ( bShow )
+ m_pQWidget->show();
+}
+
+Qt5Object::~Qt5Object()
+{
+}
+
+void Qt5Object::ResetClipRegion()
+{
+ if ( m_pQWidget.get() )
+ m_pRegion = QRegion( m_pQWidget->geometry() );
+ else
+ m_pRegion = QRegion();
+}
+
+void Qt5Object::BeginSetClipRegion( sal_uLong )
+{
+ m_pRegion = QRegion();
+}
+
+void Qt5Object::UnionClipRegion( long nX, long nY, long nWidth, long nHeight )
+{
+ m_pRegion += QRect( nX, nY, nWidth, nHeight );
+}
+
+void Qt5Object::EndSetClipRegion()
+{
+ if ( m_pQWidget.get() )
+ m_pRegion = m_pRegion.intersected( m_pQWidget->geometry() );
+}
+
+void Qt5Object::SetPosSize( long nX, long nY, long nWidth, long nHeight )
+{
+
+}
+
+void Qt5Object::Show( bool bVisible )
+{
+ if( m_pQWidget )
+ m_pQWidget->setVisible( bVisible );
+}
+
+void Qt5Object::SetForwardKey( bool bEnable )
+{
+}
+
+const SystemEnvData* Qt5Object::GetSystemData() const
+{
+ return nullptr;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5Object.hxx b/vcl/qt5/Qt5Object.hxx
new file mode 100644
index 000000000000..b66f55063d2c
--- /dev/null
+++ b/vcl/qt5/Qt5Object.hxx
@@ -0,0 +1,56 @@
+/* -*- 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 .
+ */
+
+#pragma once
+
+#include <salobj.hxx>
+#include <vcl/sysdata.hxx>
+
+#include <memory>
+
+#include <QtGui/QRegion>
+
+class QWidget;
+class Qt5Frame;
+
+class Qt5Object : public SalObject
+{
+ SystemEnvData m_aSystemData;
+ std::unique_ptr< QWidget > m_pQWidget;
+ Qt5Frame* m_pParent;
+ QRegion m_pRegion;
+
+public:
+ Qt5Object( Qt5Frame* pParent, bool bShow );
+ virtual ~Qt5Object() override;
+
+ virtual void ResetClipRegion() override;
+ virtual void BeginSetClipRegion( sal_uLong nRects ) override;
+ virtual void UnionClipRegion( long nX, long nY, long nWidth, long nHeight ) override;
+ virtual void EndSetClipRegion() override;
+
+ virtual void SetPosSize( long nX, long nY, long nWidth, long nHeight ) override;
+ virtual void Show( bool bVisible ) override;
+
+ virtual void SetForwardKey( bool bEnable ) override;
+
+ virtual const SystemEnvData* GetSystemData() const override;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5Printer.cxx b/vcl/qt5/Qt5Printer.cxx
new file mode 100644
index 000000000000..ad457a0904ba
--- /dev/null
+++ b/vcl/qt5/Qt5Printer.cxx
@@ -0,0 +1,32 @@
+/* -*- 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 .
+ */
+
+#include "Qt5Printer.hxx"
+
+bool Qt5InfoPrinter::Setup( SalFrame*, ImplJobSetup* )
+{
+ return false;
+}
+
+Qt5Printer::Qt5Printer( SalInfoPrinter* pInfoPrinter )
+ : PspSalPrinter( pInfoPrinter )
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5Printer.hxx b/vcl/qt5/Qt5Printer.hxx
new file mode 100644
index 000000000000..635f880561b5
--- /dev/null
+++ b/vcl/qt5/Qt5Printer.hxx
@@ -0,0 +1,39 @@
+/* -*- 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 .
+ */
+
+#pragma once
+
+#include <unx/genprn.h>
+
+class SalFrame;
+class ImplJobSetup;
+
+class Qt5InfoPrinter : public PspSalInfoPrinter
+{
+public:
+ virtual bool Setup( SalFrame* pFrame, ImplJobSetup* pSetupData ) override;
+};
+
+class Qt5Printer : public PspSalPrinter
+{
+public:
+ Qt5Printer( SalInfoPrinter* pInfoPrinter );
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5Timer.cxx b/vcl/qt5/Qt5Timer.cxx
new file mode 100644
index 000000000000..3e0b11bc983e
--- /dev/null
+++ b/vcl/qt5/Qt5Timer.cxx
@@ -0,0 +1,65 @@
+/* -*- 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 .
+ */
+
+#include "Qt5Timer.hxx"
+#include <Qt5Timer.moc>
+
+#include <QtWidgets/QApplication>
+#include <QtCore/QThread>
+
+Qt5Timer::Qt5Timer()
+{
+ m_aTimer.setSingleShot( true );
+ // run the timer itself in the main / creator thread
+ connect( &m_aTimer, SIGNAL( timeout() ),
+ this, SLOT( timeoutActivated() ), Qt::QueuedConnection );
+ // QTimer::start() can be called only in its creator thread
+ connect( this, SIGNAL( startTimerSignal() ),
+ this, SLOT( startTimer() ), Qt::QueuedConnection );
+}
+
+Qt5Timer::~Qt5Timer()
+{
+}
+
+void Qt5Timer::timeoutActivated()
+{
+ CallCallback();
+}
+
+void Qt5Timer::startTimer()
+{
+ m_aTimer.start();
+}
+
+void Qt5Timer::Start( sal_uIntPtr nMS )
+{
+ m_aTimer.setInterval( nMS );
+ if( qApp->thread() == QThread::currentThread() )
+ startTimer();
+ else
+ Q_EMIT startTimerSignal();
+}
+
+void Qt5Timer::Stop()
+{
+ m_aTimer.stop();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5Timer.hxx b/vcl/qt5/Qt5Timer.hxx
new file mode 100644
index 000000000000..cdf890dd86ed
--- /dev/null
+++ b/vcl/qt5/Qt5Timer.hxx
@@ -0,0 +1,46 @@
+/* -*- 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 .
+ */
+
+#pragma once
+
+#include <saltimer.hxx>
+#include <QtCore/QTimer>
+
+class Qt5Timer final : public QObject, public SalTimer
+{
+ Q_OBJECT
+
+ QTimer m_aTimer;
+
+private Q_SLOTS:
+ void timeoutActivated();
+ void startTimer();
+
+Q_SIGNALS:
+ void startTimerSignal();
+
+public:
+ Qt5Timer();
+ virtual ~Qt5Timer() override;
+
+ virtual void Start( sal_uIntPtr nMS ) override;
+ virtual void Stop() override;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5Tools.hxx b/vcl/qt5/Qt5Tools.hxx
new file mode 100644
index 000000000000..40c34d9d4303
--- /dev/null
+++ b/vcl/qt5/Qt5Tools.hxx
@@ -0,0 +1,89 @@
+/* -*- 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 .
+ */
+
+#pragma once
+
+#include <QtCore/QString>
+#include <QtCore/QRect>
+#include <QtCore/QSize>
+#include <QtGui/QImage>
+
+#include <rtl/string.hxx>
+#include <tools/gen.hxx>
+
+inline OUString toOUString(const QString& s)
+{
+ // QString stores UTF16, just like OUString
+ return OUString(reinterpret_cast<const sal_Unicode*>(s.data()), s.length());
+}
+
+inline QString toQString(const OUString& s)
+{
+ return QString::fromUtf16(
+ reinterpret_cast<ushort const *>(s.getStr()), s.getLength());
+}
+
+inline QRect toQRect( const tools::Rectangle& rRect )
+{
+ return QRect( rRect.Left(), rRect.Top(),
+ rRect.GetWidth(), rRect.GetHeight() );
+}
+
+inline QSize toQSize( const Size& rSize )
+{
+ return QSize( rSize.Width(), rSize.Height() );
+}
+
+inline Size toSize( const QSize& rSize )
+{
+ return Size( rSize.width(), rSize.height() );
+}
+
+inline QImage::Format getBitFormat( sal_uInt16 nBitCount )
+{
+ switch ( nBitCount )
+ {
+ case 1 : return QImage::Format_Mono;
+ case 8 : return QImage::Format_Indexed8;
+ case 16 : return QImage::Format_RGB16;
+ case 24 : return QImage::Format_RGB888;
+ case 32 : return QImage::Format_ARGB32;
+ default :
+ std::abort();
+ break;
+ }
+ return QImage::Format_Invalid;
+}
+
+inline sal_uInt16 getFormatBits( QImage::Format eFormat )
+{
+ switch ( eFormat )
+ {
+ case QImage::Format_Mono : return 1;
+ case QImage::Format_Indexed8 : return 8;
+ case QImage::Format_RGB16 : return 16;
+ case QImage::Format_RGB888 : return 24;
+ case QImage::Format_ARGB32 : return 32;
+ default :
+ std::abort();
+ return 0;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5VirtualDevice.cxx b/vcl/qt5/Qt5VirtualDevice.cxx
new file mode 100644
index 000000000000..10f286049456
--- /dev/null
+++ b/vcl/qt5/Qt5VirtualDevice.cxx
@@ -0,0 +1,103 @@
+/* -*- 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 .
+ */
+
+#include "Qt5VirtualDevice.hxx"
+
+#include "Qt5Graphics.hxx"
+
+#include <QtGui/QImage>
+
+Qt5VirtualDevice::Qt5VirtualDevice( DeviceFormat eFormat, double fScale )
+ : m_eFormat( eFormat )
+ , m_fScale( fScale )
+{
+}
+
+Qt5VirtualDevice::~Qt5VirtualDevice()
+{
+}
+
+SalGraphics* Qt5VirtualDevice::AcquireGraphics()
+{
+ assert( m_pImage );
+ Qt5Graphics* pGraphics = new Qt5Graphics( m_pImage.get() );
+ m_aGraphics.push_back( pGraphics );
+ return pGraphics;
+}
+
+void Qt5VirtualDevice::ReleaseGraphics( SalGraphics* pGraphics )
+{
+ m_aGraphics.remove( dynamic_cast<Qt5Graphics*>( pGraphics ) );
+ delete pGraphics;
+}
+
+bool Qt5VirtualDevice::SetSize( long nNewDX, long nNewDY )
+{
+ return SetSizeUsingBuffer( nNewDX, nNewDY, nullptr );
+}
+
+bool Qt5VirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY,
+ sal_uInt8 * pBuffer )
+{
+ if( nNewDX == 0 )
+ nNewDX = 1;
+ if( nNewDY == 0 )
+ nNewDY = 1;
+
+ if( m_pImage && m_aFrameSize.getX() != nNewDX
+ && m_aFrameSize.getY() != nNewDY )
+ return true;
+
+ m_aFrameSize = basegfx::B2IVector( nNewDX, nNewDY );
+
+ nNewDX *= m_fScale;
+ nNewDY *= m_fScale;
+
+ if (m_eFormat == DeviceFormat::BITMASK)
+ {
+ m_pImage.reset( new QImage( nNewDX, nNewDY, QImage::Format_Mono ) );
+ }
+ else
+ {
+ if ( pBuffer )
+ m_pImage.reset( new QImage( pBuffer, nNewDX, nNewDY, QImage::Format_ARGB32 ) );
+ else
+ m_pImage.reset( new QImage( nNewDX, nNewDY, QImage::Format_ARGB32 ) );
+ }
+
+ m_pImage->setDevicePixelRatio( m_fScale );
+
+ // update device in existing graphics
+ for( auto pQt5Graph : m_aGraphics )
+ pQt5Graph->ChangeQImage( m_pImage.get() );
+
+ return true;
+}
+
+long Qt5VirtualDevice::GetWidth() const
+{
+ return m_pImage ? m_aFrameSize.getX() : 0;
+}
+
+long Qt5VirtualDevice::GetHeight() const
+{
+ return m_pImage ? m_aFrameSize.getY() : 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5VirtualDevice.hxx b/vcl/qt5/Qt5VirtualDevice.hxx
new file mode 100644
index 000000000000..23d464d43751
--- /dev/null
+++ b/vcl/qt5/Qt5VirtualDevice.hxx
@@ -0,0 +1,58 @@
+/* -*- 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 .
+ */
+
+#pragma once
+
+#include <salvd.hxx>
+#include <basegfx/vector/b2ivector.hxx>
+
+#include <memory>
+#include <list>
+
+class Qt5Graphics;
+class QImage;
+enum class DeviceFormat;
+
+class Qt5VirtualDevice : public SalVirtualDevice
+{
+ std::list< Qt5Graphics* > m_aGraphics;
+ std::unique_ptr< QImage > m_pImage;
+ DeviceFormat m_eFormat;
+ basegfx::B2IVector m_aFrameSize;
+ double m_fScale;
+
+public:
+ Qt5VirtualDevice( DeviceFormat eFormat, double fScale );
+ virtual ~Qt5VirtualDevice() override;
+
+ // SalVirtualDevice
+ virtual SalGraphics* AcquireGraphics() override;
+ virtual void ReleaseGraphics( SalGraphics* pGraphics ) override;
+
+ virtual bool SetSize( long nNewDX, long nNewDY ) override;
+ virtual bool SetSizeUsingBuffer( long nNewDX, long nNewDY,
+ sal_uInt8 * pBuffer
+ ) override;
+
+ // SalGeometryProvider
+ virtual long GetWidth() const override;
+ virtual long GetHeight() const override;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx
new file mode 100644
index 000000000000..739708148876
--- /dev/null
+++ b/vcl/qt5/Qt5Widget.cxx
@@ -0,0 +1,55 @@
+/* -*- 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 .
+ */
+
+#include "Qt5Widget.hxx"
+#include <Qt5Widget.moc>
+
+#include "Qt5Frame.hxx"
+#include "Qt5Graphics.hxx"
+
+#include <QtGui/QImage>
+#include <QtGui/QPainter>
+#include <QtGui/QPaintEvent>
+
+Qt5Widget::Qt5Widget( Qt5Frame &rFrame, QWidget *parent, Qt::WindowFlags f )
+ : QWidget( parent, f )
+ , m_pFrame( &rFrame )
+{
+ create();
+}
+
+Qt5Widget::~Qt5Widget()
+{
+}
+
+void Qt5Widget::paintEvent( QPaintEvent *pEvent )
+{
+ QPainter p( this );
+ p.drawImage( pEvent->rect().topLeft(), *m_pFrame->m_pQImage, pEvent->rect() );
+}
+
+void Qt5Widget::resizeEvent( QResizeEvent* )
+{
+ QImage *pImage = new QImage( m_pFrame->m_pQWidget->size(), QImage::Format_ARGB32 );
+ m_pFrame->m_pGraphics->ChangeQImage( pImage );
+ m_pFrame->m_pQImage.reset( pImage );
+ m_pFrame->CallCallback( SalEvent::Resize, nullptr );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5Widget.hxx b/vcl/qt5/Qt5Widget.hxx
new file mode 100644
index 000000000000..3f6b32dfd613
--- /dev/null
+++ b/vcl/qt5/Qt5Widget.hxx
@@ -0,0 +1,46 @@
+/* -*- 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 .
+ */
+
+#pragma once
+
+#include <QtWidgets/QWidget>
+
+class Qt5Frame;
+class Qt5Object;
+class QPaintEvent;
+class QResizeEvent;
+
+class Qt5Widget
+ : public QWidget
+{
+ Q_OBJECT
+
+ Qt5Frame *m_pFrame;
+
+ void paintEvent( QPaintEvent* ) override;
+ void resizeEvent( QResizeEvent* ) override;
+
+public:
+ Qt5Widget( Qt5Frame &rFrame,
+ QWidget *parent = Q_NULLPTR,
+ Qt::WindowFlags f = Qt::WindowFlags() );
+ virtual ~Qt5Widget() override;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/tst_exclude_posted_events.hxx b/vcl/qt5/tst_exclude_posted_events.hxx
new file mode 100644
index 000000000000..c07ca895a9dc
--- /dev/null
+++ b/vcl/qt5/tst_exclude_posted_events.hxx
@@ -0,0 +1,67 @@
+/* -*- 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 .
+ *
+ * This code is based on the SocketEventsTester from the Qt4 test suite.
+ */
+
+#pragma once
+
+#include <QtCore/QCoreApplication>
+#include <QtCore/QEventLoop>
+
+const QEvent::Type eventType = QEvent::User;
+
+class TestExcludePostedEvents
+ : public QObject
+{
+ Q_OBJECT
+ public:
+ TestExcludePostedEvents();
+ virtual bool event( QEvent* e ) override;
+ bool processed;
+};
+
+TestExcludePostedEvents::TestExcludePostedEvents()
+ : processed( false )
+{
+}
+
+bool TestExcludePostedEvents::event( QEvent* e )
+{
+ if( e->type() == eventType )
+ processed = true;
+ return QObject::event( e );
+}
+
+#define QVERIFY(a) \
+ if (!a) return 1;
+
+static int tst_excludePostedEvents()
+{
+ TestExcludePostedEvents test;
+ QCoreApplication::postEvent( &test, new QEvent( eventType ));
+ QEventLoop loop;
+ loop.processEvents(QEventLoop::ExcludeUserInputEvents
+ | QEventLoop::ExcludeSocketNotifiers
+// | QEventLoop::WaitForMoreEvents
+ | QEventLoop::X11ExcludeTimers);
+ QVERIFY( !test.processed );
+ loop.processEvents();
+ QVERIFY( test.processed );
+ return 0;
+}
diff --git a/vcl/qt5/tst_exclude_socket_notifiers.hxx b/vcl/qt5/tst_exclude_socket_notifiers.hxx
new file mode 100644
index 000000000000..d0acafede239
--- /dev/null
+++ b/vcl/qt5/tst_exclude_socket_notifiers.hxx
@@ -0,0 +1,80 @@
+/* -*- 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 .
+ *
+ * This code is based on the SocketEventsTester from the Qt4 test suite.
+ */
+
+#pragma once
+
+#include <QtCore/QCoreApplication>
+#include <QtCore/QEventLoop>
+#include <QtCore/QSocketNotifier>
+#include <unistd.h>
+
+class TestExcludeSocketNotifiers
+ : public QObject
+{
+ Q_OBJECT
+ public:
+ TestExcludeSocketNotifiers( const int* pipes );
+ virtual ~TestExcludeSocketNotifiers() override;
+ bool received;
+ public slots:
+ void slotReceived();
+ private:
+ const int* pipes;
+};
+
+TestExcludeSocketNotifiers::TestExcludeSocketNotifiers( const int* thePipes )
+ : received( false )
+ , pipes( thePipes )
+{
+}
+
+TestExcludeSocketNotifiers::~TestExcludeSocketNotifiers()
+{
+ close( pipes[ 0 ] );
+ close( pipes[ 1 ] );
+}
+
+void TestExcludeSocketNotifiers::slotReceived()
+{
+ received = true;
+}
+
+#define QVERIFY(a) \
+ if (!a) return 1;
+
+static int tst_processEventsExcludeSocket()
+{
+ int pipes[ 2 ];
+ if( pipe( pipes ) < 0 )
+ return 1;
+ TestExcludeSocketNotifiers test( pipes );
+ QSocketNotifier notifier( pipes[ 0 ], QSocketNotifier::Read );
+ QObject::connect( &notifier, SIGNAL( activated( int )), &test, SLOT( slotReceived()));
+ char dummy = 'a';
+ if( 1 != write( pipes[ 1 ], &dummy, 1 ) )
+ return 1;
+ QEventLoop loop;
+ loop.processEvents( QEventLoop::ExcludeSocketNotifiers );
+ QVERIFY( !test.received );
+ loop.processEvents();
+ QVERIFY( test.received );
+ return 0;
+}