summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-09-28 12:10:33 +0100
committerCaolán McNamara <caolanm@redhat.com>2021-09-29 12:21:54 +0200
commit39a6ea1fea4c0a624d19b4a5f0bcfd0e4cad0a20 (patch)
tree412e8a0326c217046dfefe5d727b6a07a9104580 /vcl
parent8230731a4201419f32e80b22a576e8b2e1350277 (diff)
tdf#144139 don't crash when OutputDevice is a printer
Change-Id: Ia3843966949b8164b01cecd762ea2b5c5bf0339b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122777 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> (cherry picked from commit a0f6d3865dd113f38fd3aa673075e9fecd06f3cd) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122791 Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/app/salvtables.cxx28
-rw-r--r--vcl/unx/gtk3/gtkinst.cxx26
2 files changed, 50 insertions, 4 deletions
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index a66e95158aa4..ad46c0035e95 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -1285,7 +1285,19 @@ void SalInstanceWidget::DoRecursivePaint(vcl::Window* pWindow, const Point& rRen
Size aTempLogicSize(xOutput->PixelToLogic(aChildSizePixel));
Size aRenderLogicSize(rOutput.PixelToLogic(aChildSizePixel));
- xOutput->DrawOutDev(Point(), aTempLogicSize, rRenderLogicPos, aRenderLogicSize, rOutput);
+ switch (rOutput.GetOutDevType())
+ {
+ case OUTDEV_WINDOW:
+ case OUTDEV_VIRDEV:
+ xOutput->DrawOutDev(Point(), aTempLogicSize, rRenderLogicPos, aRenderLogicSize,
+ rOutput);
+ break;
+ case OUTDEV_PRINTER:
+ case OUTDEV_PDF:
+ xOutput->SetBackground(rOutput.GetBackground());
+ xOutput->Erase();
+ break;
+ }
//set ReallyVisible to match Visible, we restore the original state after Paint
WindowImpl* pImpl = pWindow->ImplGetWindowImpl();
@@ -1297,7 +1309,19 @@ void SalInstanceWidget::DoRecursivePaint(vcl::Window* pWindow, const Point& rRen
pImpl->mbReallyVisible = bRVisible;
- rOutput.DrawOutDev(rRenderLogicPos, aRenderLogicSize, Point(), aTempLogicSize, *xOutput);
+ switch (rOutput.GetOutDevType())
+ {
+ case OUTDEV_WINDOW:
+ case OUTDEV_VIRDEV:
+ rOutput.DrawOutDev(rRenderLogicPos, aRenderLogicSize, Point(), aTempLogicSize,
+ *xOutput);
+ break;
+ case OUTDEV_PRINTER:
+ case OUTDEV_PDF:
+ rOutput.DrawBitmapEx(rRenderLogicPos, aRenderLogicSize,
+ xOutput->GetBitmapEx(Point(), aTempLogicSize));
+ break;
+ }
xOutput.disposeAndClear();
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index 38205154be22..213ccfb8624c 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -4210,7 +4210,19 @@ public:
VclPtr<VirtualDevice> xOutput(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT));
xOutput->SetOutputSizePixel(aSize);
- xOutput->DrawOutDev(Point(), aSize, rPos, aSize, rOutput);
+
+ switch (rOutput.GetOutDevType())
+ {
+ case OUTDEV_WINDOW:
+ case OUTDEV_VIRDEV:
+ xOutput->DrawOutDev(Point(), aSize, rPos, aSize, rOutput);
+ break;
+ case OUTDEV_PRINTER:
+ case OUTDEV_PDF:
+ xOutput->SetBackground(rOutput.GetBackground());
+ xOutput->Erase();
+ break;
+ }
cairo_surface_t* pSurface = get_underlying_cairo_surface(*xOutput);
cairo_t* cr = cairo_create(pSurface);
@@ -4228,7 +4240,17 @@ public:
gtk_widget_size_allocate(m_pWidget, &aOrigAllocation, 0);
#endif
- rOutput.DrawOutDev(rPos, aSize, Point(), aSize, *xOutput);
+ switch (rOutput.GetOutDevType())
+ {
+ case OUTDEV_WINDOW:
+ case OUTDEV_VIRDEV:
+ rOutput.DrawOutDev(rPos, aSize, Point(), aSize, *xOutput);
+ break;
+ case OUTDEV_PRINTER:
+ case OUTDEV_PDF:
+ rOutput.DrawBitmapEx(rPos, xOutput->GetBitmapEx(Point(), aSize));
+ break;
+ }
if (bAnimations)
g_object_set(pSettings, "gtk-enable-animations", true, nullptr);