[Libreoffice-commits] core.git: include/vcl toolkit/source vcl/source
Chris Sherlock (via logerrit)
logerrit at kemper.freedesktop.org
Sat Jan 2 14:00:26 UTC 2021
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 ab2d3462f412d5180e60512df0dfb9c3b13ebf0c
Author: Chris Sherlock <chris.sherlock79 at gmail.com>
AuthorDate: Tue Dec 22 10:54:27 2020 +1100
Commit: Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Sat Jan 2 14:59:49 2021 +0100
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.kaganski at collabora.com>
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index c0e0c8ec12f8..b909875a380f 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>
@@ -2017,6 +2018,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 517a9607f1c2..a74f1c5e6288 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 650503484bc9..bf4a8790ae25 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -1550,6 +1550,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 99931441de04..bb99579fcafc 100644
--- a/vcl/source/gdi/print.cxx
+++ b/vcl/source/gdi/print.cxx
@@ -1644,4 +1644,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 f2e19889d06b..729e322ec664 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
@@ -701,4 +703,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 81dbbf63670c..d897e94a0bea 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -3963,6 +3963,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: */
More information about the Libreoffice-commits
mailing list