cui/source/dialogs/screenshotannotationdlg.cxx | 3 - include/vcl/syswin.hxx | 2 include/vcl/weld.hxx | 5 +- sc/source/ui/attrdlg/scdlgfact.cxx | 42 ++++++------------- sd/source/ui/dlg/sddlgfact.cxx | 54 ++++++++----------------- sfx2/source/dialog/tabdlg.cxx | 3 - test/source/screenshot_test.cxx | 3 - vcl/inc/salvtables.hxx | 6 +- vcl/source/app/salvtables.cxx | 12 +++-- vcl/source/window/syswin.cxx | 12 +++-- vcl/unx/gtk3/gtk3gtkinst.cxx | 40 ++++++++++++------ 11 files changed, 86 insertions(+), 96 deletions(-)
New commits: commit 19fd82ac6e08896bd17169d1b6ea090458fc18da Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Tue Jul 7 20:27:51 2020 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Wed Jul 8 13:39:11 2020 +0200 distinguish between dialog screenshoting and rendering a widget Change-Id: I43ee0c68d72c97a15d26e2ffea577c2a44ba91e8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98326 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/cui/source/dialogs/screenshotannotationdlg.cxx b/cui/source/dialogs/screenshotannotationdlg.cxx index 4054fa57336f..b0513931bde8 100644 --- a/cui/source/dialogs/screenshotannotationdlg.cxx +++ b/cui/source/dialogs/screenshotannotationdlg.cxx @@ -205,8 +205,7 @@ ScreenshotAnnotationDlg_Impl::ScreenshotAnnotationDlg_Impl( maPicture(this), maSaveAsText(CuiResId(RID_SVXSTR_SAVE_SCREENSHOT_AS)) { - VclPtr<VirtualDevice> xParentDialogSurface(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT)); - rParentDialog.draw(*xParentDialogSurface); + VclPtr<VirtualDevice> xParentDialogSurface(rParentDialog.screenshot()); maParentDialogSize = xParentDialogSurface->GetOutputSizePixel(); maParentDialogBitmap = xParentDialogSurface->GetBitmapEx(Point(), maParentDialogSize); maDimmedDialogBitmap = maParentDialogBitmap; diff --git a/include/vcl/syswin.hxx b/include/vcl/syswin.hxx index f1cb60015d4c..32f07c111187 100644 --- a/include/vcl/syswin.hxx +++ b/include/vcl/syswin.hxx @@ -217,7 +217,7 @@ public: virtual void doDeferredInit(WinBits nBits); // Screenshot interface - void createScreenshot(VirtualDevice& rOutput); + VclPtr<VirtualDevice> createScreenshot(); }; inline void SystemWindow::SetIdleDebugName( const char *pDebugName ) diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx index c4577d63c49d..7649accf8b2d 100644 --- a/include/vcl/weld.hxx +++ b/include/vcl/weld.hxx @@ -272,7 +272,7 @@ public: virtual void connect_get_property_tree(const Link<tools::JsonWriter&, void>& rLink) = 0; // render the widget to an output device - virtual void draw(VirtualDevice& rOutput) = 0; + virtual void draw(OutputDevice& rOutput, const tools::Rectangle& rRect) = 0; virtual ~Widget() {} }; @@ -468,6 +468,9 @@ public: // collect positions of widgets and their help ids for screenshot purposes virtual ScreenShotCollection collect_screenshot_data() = 0; + + // render the widget to an output device + virtual VclPtr<VirtualDevice> screenshot() = 0; }; class VCL_DLLPUBLIC WaitObject diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx index e947993cacd2..55340b185d8b 100644 --- a/sc/source/ui/attrdlg/scdlgfact.cxx +++ b/sc/source/ui/attrdlg/scdlgfact.cxx @@ -128,8 +128,7 @@ short AbstractScDataFormDlg_Impl::Execute() BitmapEx AbstractScDataFormDlg_Impl::createScreenshot() const { - VclPtr<VirtualDevice> xDialogSurface(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT)); - m_xDlg->getDialog()->draw(*xDialogSurface); + VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot()); return xDialogSurface->GetBitmapEx(Point(), xDialogSurface->GetOutputSizePixel()); } @@ -185,8 +184,7 @@ short AbstractScMoveTableDlg_Impl::Execute() BitmapEx AbstractScMoveTableDlg_Impl::createScreenshot() const { - VclPtr<VirtualDevice> xDialogSurface(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT)); - m_xDlg->getDialog()->draw(*xDialogSurface); + VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot()); return xDialogSurface->GetBitmapEx(Point(), xDialogSurface->GetOutputSizePixel()); } @@ -291,8 +289,7 @@ void AbstractScImportAsciiDlg_Impl::SaveParameters() BitmapEx AbstractScImportAsciiDlg_Impl::createScreenshot() const { - VclPtr<VirtualDevice> xDialogSurface(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT)); - m_xDlg->getDialog()->draw(*xDialogSurface); + VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot()); return xDialogSurface->GetBitmapEx(Point(), xDialogSurface->GetOutputSizePixel()); } @@ -323,8 +320,7 @@ bool AbstractScColRowLabelDlg_Impl::IsRow() BitmapEx AbstractScColRowLabelDlg_Impl::createScreenshot() const { - VclPtr<VirtualDevice> xDialogSurface(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT)); - m_xDlg->getDialog()->draw(*xDialogSurface); + VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot()); return xDialogSurface->GetBitmapEx(Point(), xDialogSurface->GetOutputSizePixel()); } @@ -340,8 +336,7 @@ void AbstractScDataPilotDatabaseDlg_Impl::GetValues( ScImportSourceDesc& rDesc ) BitmapEx AbstractScDataPilotDatabaseDlg_Impl::createScreenshot() const { - VclPtr<VirtualDevice> xDialogSurface(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT)); - m_xDlg->getDialog()->draw(*xDialogSurface); + VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot()); return xDialogSurface->GetBitmapEx(Point(), xDialogSurface->GetOutputSizePixel()); } @@ -377,8 +372,7 @@ void AbstractScDataPilotSourceTypeDlg_Impl::AppendNamedRange(const OUString& rNa BitmapEx AbstractScDataPilotSourceTypeDlg_Impl::createScreenshot() const { - VclPtr<VirtualDevice> xDialogSurface(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT)); - m_xDlg->getDialog()->draw(*xDialogSurface); + VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot()); return xDialogSurface->GetBitmapEx(Point(), xDialogSurface->GetOutputSizePixel()); } @@ -419,8 +413,7 @@ DelCellCmd AbstractScDeleteCellDlg_Impl::GetDelCellCmd() const BitmapEx AbstractScDeleteCellDlg_Impl::createScreenshot() const { - VclPtr<VirtualDevice> xDialogSurface(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT)); - m_xDlg->getDialog()->draw(*xDialogSurface); + VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot()); return xDialogSurface->GetBitmapEx(Point(), xDialogSurface->GetOutputSizePixel()); } @@ -441,8 +434,7 @@ InsertDeleteFlags AbstractScDeleteContentsDlg_Impl::GetDelContentsCmdBits() cons BitmapEx AbstractScDeleteContentsDlg_Impl::createScreenshot() const { - VclPtr<VirtualDevice> xDialogSurface(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT)); - m_xDlg->getDialog()->draw(*xDialogSurface); + VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot()); return xDialogSurface->GetBitmapEx(Point(), xDialogSurface->GetOutputSizePixel()); } @@ -553,8 +545,7 @@ InsCellCmd AbstractScInsertContentsDlg_Impl::GetMoveMode() BitmapEx AbstractScInsertContentsDlg_Impl::createScreenshot() const { - VclPtr<VirtualDevice> xDialogSurface(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT)); - m_xDlg->getDialog()->draw(*xDialogSurface); + VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot()); return xDialogSurface->GetBitmapEx(Point(), xDialogSurface->GetOutputSizePixel()); } @@ -600,8 +591,7 @@ const OUString* AbstractScInsertTableDlg_Impl::GetNextTable( sal_uInt16* pN ) BitmapEx AbstractScInsertTableDlg_Impl::createScreenshot() const { - VclPtr<VirtualDevice> xDialogSurface(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT)); - m_xDlg->getDialog()->draw(*xDialogSurface); + VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot()); return xDialogSurface->GetBitmapEx(Point(), xDialogSurface->GetOutputSizePixel()); } @@ -714,8 +704,7 @@ CreateNameFlags AbstractScNameCreateDlg_Impl::GetFlags() const BitmapEx AbstractScNameCreateDlg_Impl::createScreenshot() const { - VclPtr<VirtualDevice> xDialogSurface(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT)); - m_xDlg->getDialog()->draw(*xDialogSurface); + VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot()); return xDialogSurface->GetBitmapEx(Point(), xDialogSurface->GetOutputSizePixel()); } @@ -820,8 +809,7 @@ OUString AbstractScStringInputDlg_Impl::GetInputString() const BitmapEx AbstractScStringInputDlg_Impl::createScreenshot() const { - VclPtr<VirtualDevice> xDialogSurface(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT)); - m_xDlg->getDialog()->draw(*xDialogSurface); + VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot()); return xDialogSurface->GetBitmapEx(Point(), xDialogSurface->GetOutputSizePixel()); } @@ -837,8 +825,7 @@ void AbstractScTabBgColorDlg_Impl::GetSelectedColor( Color& rColor ) const BitmapEx AbstractScTabBgColorDlg_Impl::createScreenshot() const { - VclPtr<VirtualDevice> xDialogSurface(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT)); - m_xDlg->getDialog()->draw(*xDialogSurface); + VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot()); return xDialogSurface->GetBitmapEx(Point(), xDialogSurface->GetOutputSizePixel()); } @@ -869,8 +856,7 @@ bool AbstractScTextImportOptionsDlg_Impl::IsDateConversionSet() const BitmapEx AbstractScTextImportOptionsDlg_Impl::createScreenshot() const { - VclPtr<VirtualDevice> xDialogSurface(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT)); - m_xDlg->getDialog()->draw(*xDialogSurface); + VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot()); return xDialogSurface->GetBitmapEx(Point(), xDialogSurface->GetOutputSizePixel()); } diff --git a/sd/source/ui/dlg/sddlgfact.cxx b/sd/source/ui/dlg/sddlgfact.cxx index 8db686217c86..30b945a82e51 100644 --- a/sd/source/ui/dlg/sddlgfact.cxx +++ b/sd/source/ui/dlg/sddlgfact.cxx @@ -57,8 +57,7 @@ short SdAbstractGenericDialog_Impl::Execute() BitmapEx SdAbstractGenericDialog_Impl::createScreenshot() const { - VclPtr<VirtualDevice> xDialogSurface(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT)); - m_xDlg->getDialog()->draw(*xDialogSurface); + VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot()); return xDialogSurface->GetBitmapEx(Point(), xDialogSurface->GetOutputSizePixel()); } @@ -164,8 +163,7 @@ bool AbstractHeaderFooterDialog_Impl::StartExecuteAsync(AsyncContext &rCtx) BitmapEx AbstractHeaderFooterDialog_Impl::createScreenshot() const { - VclPtr<VirtualDevice> xDialogSurface(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT)); - m_xDlg->getDialog()->draw(*xDialogSurface); + VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot()); return xDialogSurface->GetBitmapEx(Point(), xDialogSurface->GetOutputSizePixel()); } @@ -196,8 +194,7 @@ short AbstractBreakDlg_Impl::Execute() BitmapEx AbstractBreakDlg_Impl::createScreenshot() const { - VclPtr<VirtualDevice> xDialogSurface(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT)); - m_xDlg->getDialog()->draw(*xDialogSurface); + VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot()); return xDialogSurface->GetBitmapEx(Point(), xDialogSurface->GetOutputSizePixel()); } @@ -218,8 +215,7 @@ short AbstractMasterLayoutDialog_Impl::Execute() BitmapEx AbstractMasterLayoutDialog_Impl::createScreenshot() const { - VclPtr<VirtualDevice> xDialogSurface(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT)); - m_xDlg->getDialog()->draw(*xDialogSurface); + VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot()); return xDialogSurface->GetBitmapEx(Point(), xDialogSurface->GetOutputSizePixel()); } @@ -235,8 +231,7 @@ void AbstractCopyDlg_Impl::GetAttr( SfxItemSet& rOutAttrs ) BitmapEx AbstractCopyDlg_Impl::createScreenshot() const { - VclPtr<VirtualDevice> xDialogSurface(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT)); - m_xDlg->getDialog()->draw(*xDialogSurface); + VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot()); return xDialogSurface->GetBitmapEx(Point(), xDialogSurface->GetOutputSizePixel()); } @@ -257,8 +252,7 @@ bool AbstractSdCustomShowDlg_Impl::IsCustomShow() const BitmapEx AbstractSdCustomShowDlg_Impl::createScreenshot() const { - VclPtr<VirtualDevice> xDialogSurface(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT)); - m_xDlg->getDialog()->draw(*xDialogSurface); + VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot()); return xDialogSurface->GetBitmapEx(Point(), xDialogSurface->GetOutputSizePixel()); } @@ -305,8 +299,7 @@ void SdAbstractTabController_Impl::SetText( const OUString& rStr ) BitmapEx SdAbstractTabController_Impl::createScreenshot() const { - VclPtr<VirtualDevice> xDialogSurface(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT)); - m_xDlg->getDialog()->draw(*xDialogSurface); + VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot()); return xDialogSurface->GetBitmapEx(Point(), xDialogSurface->GetOutputSizePixel()); } @@ -342,8 +335,7 @@ void AbstractBulletDialog_Impl::SetText( const OUString& rStr ) BitmapEx AbstractBulletDialog_Impl::createScreenshot() const { - VclPtr<VirtualDevice> xDialogSurface(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT)); - m_xDlg->getDialog()->draw(*xDialogSurface); + VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot()); return xDialogSurface->GetBitmapEx(Point(), xDialogSurface->GetOutputSizePixel()); } @@ -379,8 +371,7 @@ void SdPresLayoutTemplateDlg_Impl::SetText( const OUString& rStr ) BitmapEx SdPresLayoutTemplateDlg_Impl::createScreenshot() const { - VclPtr<VirtualDevice> xDialogSurface(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT)); - m_xDlg->getDialog()->draw(*xDialogSurface); + VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot()); return xDialogSurface->GetBitmapEx(Point(), xDialogSurface->GetOutputSizePixel()); } @@ -401,8 +392,7 @@ SfxItemSet AbstractSdModifyFieldDlg_Impl::GetItemSet() BitmapEx AbstractSdModifyFieldDlg_Impl::createScreenshot() const { - VclPtr<VirtualDevice> xDialogSurface(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT)); - m_xDlg->getDialog()->draw(*xDialogSurface); + VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot()); return xDialogSurface->GetBitmapEx(Point(), xDialogSurface->GetOutputSizePixel()); } @@ -438,8 +428,7 @@ void AbstractSdSnapLineDlg_Impl::SetText( const OUString& rStr ) BitmapEx AbstractSdSnapLineDlg_Impl::createScreenshot() const { - VclPtr<VirtualDevice> xDialogSurface(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT)); - m_xDlg->getDialog()->draw(*xDialogSurface); + VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot()); return xDialogSurface->GetBitmapEx(Point(), xDialogSurface->GetOutputSizePixel()); } @@ -460,8 +449,7 @@ void AbstractSdInsertLayerDlg_Impl::SetHelpId( const OString& rHelpId ) BitmapEx AbstractSdInsertLayerDlg_Impl::createScreenshot() const { - VclPtr<VirtualDevice> xDialogSurface(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT)); - m_xDlg->getDialog()->draw(*xDialogSurface); + VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot()); return xDialogSurface->GetBitmapEx(Point(), xDialogSurface->GetOutputSizePixel()); } @@ -487,8 +475,7 @@ bool AbstractSdInsertPagesObjsDlg_Impl::IsRemoveUnnessesaryMasterPages() const BitmapEx AbstractSdInsertPagesObjsDlg_Impl::createScreenshot() const { - VclPtr<VirtualDevice> xDialogSurface(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT)); - m_xDlg->getDialog()->draw(*xDialogSurface); + VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot()); return xDialogSurface->GetBitmapEx(Point(), xDialogSurface->GetOutputSizePixel()); } @@ -519,8 +506,7 @@ bool AbstractMorphDlg_Impl::IsOrientationFade() const BitmapEx AbstractMorphDlg_Impl::createScreenshot() const { - VclPtr<VirtualDevice> xDialogSurface(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT)); - m_xDlg->getDialog()->draw(*xDialogSurface); + VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot()); return xDialogSurface->GetBitmapEx(Point(), xDialogSurface->GetOutputSizePixel()); } @@ -536,8 +522,7 @@ void AbstractSdStartPresDlg_Impl::GetAttr( SfxItemSet& rOutAttrs ) BitmapEx AbstractSdStartPresDlg_Impl::createScreenshot() const { - VclPtr<VirtualDevice> xDialogSurface(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT)); - m_xDlg->getDialog()->draw(*xDialogSurface); + VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot()); return xDialogSurface->GetBitmapEx(Point(), xDialogSurface->GetOutputSizePixel()); } @@ -553,8 +538,7 @@ void AbstractSdPresLayoutDlg_Impl::GetAttr( SfxItemSet& rOutAttrs ) BitmapEx AbstractSdPresLayoutDlg_Impl::createScreenshot() const { - VclPtr<VirtualDevice> xDialogSurface(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT)); - m_xDlg->getDialog()->draw(*xDialogSurface); + VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot()); return xDialogSurface->GetBitmapEx(Point(), xDialogSurface->GetOutputSizePixel()); } @@ -580,8 +564,7 @@ const GDIMetaFile& AbstractSdVectorizeDlg_Impl::GetGDIMetaFile() const BitmapEx AbstractSdVectorizeDlg_Impl::createScreenshot() const { - VclPtr<VirtualDevice> xDialogSurface(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT)); - m_xDlg->getDialog()->draw(*xDialogSurface); + VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot()); return xDialogSurface->GetBitmapEx(Point(), xDialogSurface->GetOutputSizePixel()); } @@ -597,8 +580,7 @@ void AbstractSdPublishingDlg_Impl::GetParameterSequence( css::uno::Sequence< css BitmapEx AbstractSdPublishingDlg_Impl::createScreenshot() const { - VclPtr<VirtualDevice> xDialogSurface(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT)); - m_xDlg->getDialog()->draw(*xDialogSurface); + VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot()); return xDialogSurface->GetBitmapEx(Point(), xDialogSurface->GetOutputSizePixel()); } diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx index 7ced6461675b..22acd6791b25 100644 --- a/sfx2/source/dialog/tabdlg.cxx +++ b/sfx2/source/dialog/tabdlg.cxx @@ -1153,8 +1153,7 @@ BitmapEx SfxTabDialogController::createScreenshot() const const_cast<SfxTabDialogController*>(this)->Start_Impl(); } - VclPtr<VirtualDevice> xDialogSurface(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT)); - m_xDialog->draw(*xDialogSurface); + VclPtr<VirtualDevice> xDialogSurface(m_xDialog->screenshot()); return xDialogSurface->GetBitmapEx(Point(), xDialogSurface->GetOutputSizePixel()); } diff --git a/test/source/screenshot_test.cxx b/test/source/screenshot_test.cxx index 8e6a8775db05..ea26f80c47a6 100644 --- a/test/source/screenshot_test.cxx +++ b/test/source/screenshot_test.cxx @@ -112,8 +112,7 @@ void ScreenshotTest::saveScreenshot(VclAbstractDialog const & rDialog) void ScreenshotTest::saveScreenshot(weld::Window& rDialog) { - VclPtr<VirtualDevice> xDialogSurface(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT)); - rDialog.draw(*xDialogSurface); + VclPtr<VirtualDevice> xDialogSurface(rDialog.screenshot()); const BitmapEx aScreenshot(xDialogSurface->GetBitmapEx(Point(), xDialogSurface->GetOutputSizePixel())); if (!aScreenshot.IsEmpty()) diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx index 377653c291ec..062bf9bd66ee 100644 --- a/vcl/inc/salvtables.hxx +++ b/vcl/inc/salvtables.hxx @@ -387,7 +387,7 @@ public: virtual void set_highlight_background() override; - virtual void draw(VirtualDevice& rOutput) override; + virtual void draw(OutputDevice& rOutput, const tools::Rectangle& rRect) override; SystemWindow* getSystemWindow(); }; @@ -486,10 +486,10 @@ public: virtual void HandleEventListener(VclWindowEvent& rEvent) override; - virtual void draw(VirtualDevice& rOutput) override; - virtual weld::ScreenShotCollection collect_screenshot_data() override; + virtual VclPtr<VirtualDevice> screenshot() override; + virtual ~SalInstanceWindow() override; }; diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index f3778f91340c..81c2e38085c3 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -1133,10 +1133,12 @@ std::unique_ptr<weld::Container> SalInstanceWidget::weld_parent() const return std::make_unique<SalInstanceContainer>(pParent, m_pBuilder, false); } -void SalInstanceWidget::draw(VirtualDevice& rOutput) +void SalInstanceWidget::draw(OutputDevice& rOutput, const tools::Rectangle& rRect) { - rOutput.SetOutputSizePixel(m_xWidget->GetSizePixel()); - m_xWidget->PaintToDevice(&rOutput, Point()); + Size aOrigSize(m_xWidget->GetSizePixel()); + m_xWidget->SetSizePixel(rRect.GetSize()); + m_xWidget->Draw(&rOutput, rRect.TopLeft(), DrawFlags::NONE); + m_xWidget->SetSizePixel(aOrigSize); } namespace @@ -1321,11 +1323,11 @@ void SalInstanceWindow::HandleEventListener(VclWindowEvent& rEvent) SalInstanceContainer::HandleEventListener(rEvent); } -void SalInstanceWindow::draw(VirtualDevice& rOutput) +VclPtr<VirtualDevice> SalInstanceWindow::screenshot() { SystemWindow* pSysWin = dynamic_cast<SystemWindow*>(m_xWindow.get()); assert(pSysWin); - pSysWin->createScreenshot(rOutput); + return pSysWin->createScreenshot(); } weld::ScreenShotCollection SalInstanceWindow::collect_screenshot_data() diff --git a/vcl/source/window/syswin.cxx b/vcl/source/window/syswin.cxx index 3c154dd228c7..a3f5a2a933fd 100644 --- a/vcl/source/window/syswin.cxx +++ b/vcl/source/window/syswin.cxx @@ -1156,7 +1156,7 @@ void SystemWindow::doDeferredInit(WinBits /*nBits*/) SAL_WARN("vcl.layout", "SystemWindow in layout without doDeferredInit impl"); } -void SystemWindow::createScreenshot(VirtualDevice& rOutput) +VclPtr<VirtualDevice> SystemWindow::createScreenshot() { // same prerequisites as in Execute() setDeferredProperties(); @@ -1165,11 +1165,15 @@ void SystemWindow::createScreenshot(VirtualDevice& rOutput) ToTop(); ensureRepaint(); - Point aPos; Size aSize(GetOutputSizePixel()); - rOutput.SetOutputSizePixel(aSize); - rOutput.DrawOutDev(aPos, aSize, aPos, aSize, *this); + VclPtr<VirtualDevice> xOutput(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT)); + xOutput->SetOutputSizePixel(aSize); + + Point aPos; + xOutput->DrawOutDev(aPos, aSize, aPos, aSize, *this); + + return xOutput; } void SystemWindow::PrePaint(vcl::RenderContext& rRenderContext) diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 7ff4005af8b3..cba5c662baff 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -3038,7 +3038,7 @@ public: return xRet; } - virtual void draw(VirtualDevice& rOutput) override + virtual void draw(OutputDevice& rOutput, const tools::Rectangle& rRect) override { // detect if we have to manually setup its size bool bAlreadyRealized = gtk_widget_get_realized(m_pWidget); @@ -3046,30 +3046,43 @@ public: bool bAlreadyVisible = gtk_widget_get_visible(m_pWidget); // has to be mapped for draw to work bool bAlreadyMapped = gtk_widget_get_mapped(m_pWidget); + if (!bAlreadyVisible) gtk_widget_show(m_pWidget); - - GtkAllocation allocation; - if (!bAlreadyRealized) gtk_widget_realize(m_pWidget); - if (!bAlreadyMapped) gtk_widget_map(m_pWidget); + assert(gtk_widget_is_drawable(m_pWidget)); // all that should result in this holding + + Size aSize(rRect.GetSize()); + + GtkAllocation aOrigAllocation; + gtk_widget_get_allocation(m_pWidget, &aOrigAllocation); + + GtkAllocation aNewAllocation {aOrigAllocation.x, + aOrigAllocation.y, + static_cast<int>(aSize.Width()), + static_cast<int>(aSize.Height()) }; + gtk_widget_set_allocation(m_pWidget, &aNewAllocation); + if (GTK_IS_CONTAINER(m_pWidget)) gtk_container_resize_children(GTK_CONTAINER(m_pWidget)); - gtk_widget_get_allocation(m_pWidget, &allocation); - - rOutput.SetOutputSizePixel(Size(allocation.width, allocation.height)); - cairo_surface_t* pSurface = get_underlying_cairo_surface(rOutput); + VclPtr<VirtualDevice> xOutput(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT)); + xOutput->SetOutputSizePixel(aSize); + cairo_surface_t* pSurface = get_underlying_cairo_surface(*xOutput); cairo_t* cr = cairo_create(pSurface); gtk_widget_draw(m_pWidget, cr); cairo_destroy(cr); + gtk_widget_set_allocation(m_pWidget, &aOrigAllocation); + + rOutput.DrawOutDev(rRect.TopLeft(), aSize, Point(), aSize, *xOutput); + if (!bAlreadyVisible) gtk_widget_hide(m_pWidget); if (!bAlreadyMapped) @@ -4066,7 +4079,7 @@ public: g_signal_handler_unblock(m_pWidget, m_nToplevelFocusChangedSignalId); } - virtual void draw(VirtualDevice& rOutput) override + virtual VclPtr<VirtualDevice> screenshot() override { // detect if we have to manually setup its size bool bAlreadyRealized = gtk_widget_get_realized(GTK_WIDGET(m_pWindow)); @@ -4087,8 +4100,9 @@ public: gtk_widget_size_allocate(GTK_WIDGET(m_pWindow), &allocation); } - rOutput.SetOutputSizePixel(get_size()); - cairo_surface_t* pSurface = get_underlying_cairo_surface(rOutput); + VclPtr<VirtualDevice> xOutput(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT)); + xOutput->SetOutputSizePixel(get_size()); + cairo_surface_t* pSurface = get_underlying_cairo_surface(*xOutput); cairo_t* cr = cairo_create(pSurface); Point aOffset = get_csd_offset(GTK_WIDGET(m_pWindow)); @@ -4109,6 +4123,8 @@ public: gtk_widget_hide(GTK_WIDGET(m_pWindow)); if (!bAlreadyRealized) gtk_widget_unrealize(GTK_WIDGET(m_pWindow)); + + return xOutput; } virtual weld::ScreenShotCollection collect_screenshot_data() override _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits