include/vcl/outdev.hxx | 8 ++++++ include/vcl/print.hxx | 2 + include/vcl/window.hxx | 2 + toolkit/source/awt/vclxdevice.cxx | 45 +------------------------------------- vcl/source/gdi/print.cxx | 15 ++++++++++++ vcl/source/outdev/outdev.cxx | 32 +++++++++++++++++++++++++++ vcl/source/window/window.cxx | 7 +++++ 7 files changed, 68 insertions(+), 43 deletions(-)
New commits: commit 2dac72b24085ac938784a68e01fbd27773084cc3 Author: Chris Sherlock <chris.sherloc...@gmail.com> AuthorDate: Tue Dec 22 10:54:27 2020 +1100 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Sat Jun 19 23:32:52 2021 +0200 tdf#74702 - vcl: introduce OutputDevice::GetDeviceInfo() Change-Id: I02c9cc83fea330ed0ba1539b2682f75d33ba80fd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108132 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117502 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Andras Timar <andras.ti...@collabora.com> diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx index 1b29dddf532b..ec40d6f46294 100644 --- a/include/vcl/outdev.hxx +++ b/include/vcl/outdev.hxx @@ -48,6 +48,7 @@ #include <com/sun/star/drawing/LineCap.hpp> #include <com/sun/star/uno/Reference.h> +#include <com/sun/star/awt/DeviceInfo.hpp> #include <memory> #include <vector> @@ -2013,6 +2014,13 @@ public: const Point& rPt, const Size& rSz, const GfxLink& rGfxLink, GDIMetaFile* pSubst = nullptr ); ///@} + +public: + virtual css::awt::DeviceInfo GetDeviceInfo() const; + +protected: + css::awt::DeviceInfo GetCommonDeviceInfo(Size const& aDevSize) const; + }; #endif // INCLUDED_VCL_OUTDEV_HXX diff --git a/include/vcl/print.hxx b/include/vcl/print.hxx index 631b2f5b83fe..ed339266256a 100644 --- a/include/vcl/print.hxx +++ b/include/vcl/print.hxx @@ -221,6 +221,8 @@ public: DrawRect(aBorderRect); } + css::awt::DeviceInfo GetDeviceInfo() const override; + protected: virtual void DrawDeviceMask( const Bitmap& rMask, const Color& rMaskColor, const Point& rDestPt, const Size& rDestSize, diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx index ae5886b9b07d..41b35a24063d 100644 --- a/include/vcl/window.hxx +++ b/include/vcl/window.hxx @@ -1545,6 +1545,8 @@ public: void SetMnemonicActivateHdl(const Link<vcl::Window&, bool>& rLink); void SetModalHierarchyHdl(const Link<bool, void>& rLink); void SetDumpAsPropertyTreeHdl(const Link<tools::JsonWriter&, void>& rLink); + + css::awt::DeviceInfo GetDeviceInfo() const override; }; } diff --git a/toolkit/source/awt/vclxdevice.cxx b/toolkit/source/awt/vclxdevice.cxx index 84e54e630453..ba382248c0fd 100644 --- a/toolkit/source/awt/vclxdevice.cxx +++ b/toolkit/source/awt/vclxdevice.cxx @@ -17,8 +17,6 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <com/sun/star/awt/DeviceCapability.hpp> - #include <com/sun/star/util/MeasureUnit.hpp> #include <com/sun/star/lang/IllegalArgumentException.hpp> @@ -87,47 +85,8 @@ css::awt::DeviceInfo VCLXDevice::getInfo() css::awt::DeviceInfo aInfo; - if( mpOutputDevice ) - { - Size aDevSz; - OutDevType eDevType = mpOutputDevice->GetOutDevType(); - if ( eDevType == OUTDEV_WINDOW ) - { - aDevSz = static_cast<vcl::Window*>(mpOutputDevice.get())->GetSizePixel(); - static_cast<vcl::Window*>(mpOutputDevice.get())->GetBorder( aInfo.LeftInset, aInfo.TopInset, aInfo.RightInset, aInfo.BottomInset ); - } - else if ( eDevType == OUTDEV_PRINTER ) - { - aDevSz = static_cast<Printer*>(mpOutputDevice.get())->GetPaperSizePixel(); - Size aOutSz = mpOutputDevice->GetOutputSizePixel(); - Point aOffset = static_cast<Printer*>(mpOutputDevice.get())->GetPageOffset(); - aInfo.LeftInset = aOffset.X(); - aInfo.TopInset = aOffset.Y(); - aInfo.RightInset = aDevSz.Width() - aOutSz.Width() - aOffset.X(); - aInfo.BottomInset = aDevSz.Height() - aOutSz.Height() - aOffset.Y(); - } - else // VirtualDevice - { - aDevSz = mpOutputDevice->GetOutputSizePixel(); - aInfo.LeftInset = 0; - aInfo.TopInset = 0; - aInfo.RightInset = 0; - aInfo.BottomInset = 0; - } - - aInfo.Width = aDevSz.Width(); - aInfo.Height = aDevSz.Height(); - - Size aTmpSz = mpOutputDevice->LogicToPixel( Size( 1000, 1000 ), MapMode( MapUnit::MapCM ) ); - aInfo.PixelPerMeterX = aTmpSz.Width()/10; - aInfo.PixelPerMeterY = aTmpSz.Height()/10; - - aInfo.BitsPerPixel = mpOutputDevice->GetBitCount(); - - aInfo.Capabilities = 0; - if ( mpOutputDevice->GetOutDevType() != OUTDEV_PRINTER ) - aInfo.Capabilities = css::awt::DeviceCapability::RASTEROPERATIONS|css::awt::DeviceCapability::GETBITS; - } + if (mpOutputDevice) + aInfo = mpOutputDevice->GetDeviceInfo(); return aInfo; } diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx index 48338a879ea5..e2dba7e1ff53 100644 --- a/vcl/source/gdi/print.cxx +++ b/vcl/source/gdi/print.cxx @@ -1643,4 +1643,19 @@ Bitmap Printer::GetBitmap( const Point& rSrcPt, const Size& rSize ) const return OutputDevice::GetBitmap( rSrcPt, rSize ); } +css::awt::DeviceInfo Printer::GetDeviceInfo() const +{ + Size aDevSz = GetPaperSizePixel(); + css::awt::DeviceInfo aInfo = GetCommonDeviceInfo(aDevSz); + Size aOutSz = GetOutputSizePixel(); + Point aOffset = GetPageOffset(); + aInfo.LeftInset = aOffset.X(); + aInfo.TopInset = aOffset.Y(); + aInfo.RightInset = aDevSz.Width() - aOutSz.Width() - aOffset.X(); + aInfo.BottomInset = aDevSz.Height() - aOutSz.Height() - aOffset.Y(); + aInfo.Capabilities = 0; + + return aInfo; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/outdev/outdev.cxx b/vcl/source/outdev/outdev.cxx index e5bf4c4d21c6..bf7e4bdb21a9 100644 --- a/vcl/source/outdev/outdev.cxx +++ b/vcl/source/outdev/outdev.cxx @@ -34,6 +34,8 @@ #include <window.h> #include <outdev.h> +#include <com/sun/star/awt/DeviceCapability.hpp> + #ifdef DISABLE_DYNLOADING // Linking all needed LO code into one .so/executable, these already // exist in the tools library, so put them in the anonymous namespace @@ -699,4 +701,34 @@ bool OutputDevice::DrawEPS( const Point& rPoint, const Size& rSize, return bDrawn; } +css::awt::DeviceInfo OutputDevice::GetCommonDeviceInfo(Size const& rDevSz) const +{ + css::awt::DeviceInfo aInfo; + + aInfo.Width = rDevSz.Width(); + aInfo.Height = rDevSz.Height(); + + Size aTmpSz = LogicToPixel(Size(1000, 1000), MapMode(MapUnit::MapCM)); + aInfo.PixelPerMeterX = aTmpSz.Width() / 10; + aInfo.PixelPerMeterY = aTmpSz.Height() / 10; + aInfo.BitsPerPixel = GetBitCount(); + + aInfo.Capabilities = css::awt::DeviceCapability::RASTEROPERATIONS | + css::awt::DeviceCapability::GETBITS; + + return aInfo; +} + +css::awt::DeviceInfo OutputDevice::GetDeviceInfo() const +{ + css::awt::DeviceInfo aInfo = GetCommonDeviceInfo(GetOutputSizePixel()); + + aInfo.LeftInset = 0; + aInfo.TopInset = 0; + aInfo.RightInset = 0; + aInfo.BottomInset = 0; + + return aInfo; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index fd7c2438eb47..967dc1375679 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -3944,6 +3944,13 @@ FactoryFunction Window::GetUITestFactory() const return WindowUIObject::create; } +css::awt::DeviceInfo Window::GetDeviceInfo() const +{ + css::awt::DeviceInfo aInfo = GetCommonDeviceInfo(GetSizePixel()); + GetBorder(aInfo.LeftInset, aInfo.TopInset, aInfo.RightInset, aInfo.BottomInset); + return aInfo; +} + } /* namespace vcl */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits