From 60ae5f530c3123341a8c2d49793693c2cd4521c2 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 19 Feb 2018 16:33:35 +0000 Subject: make it possible to set parent window for printer error messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I0effa3645454ef9d03393ae8b256cd624ca04f03 Reviewed-on: https://gerrit.libreoffice.org/50008 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- include/vcl/oldprintadaptor.hxx | 2 +- include/vcl/print.hxx | 3 ++- sfx2/source/view/viewprn.cxx | 2 +- sw/inc/viewsh.hxx | 1 - toolkit/source/awt/vclxprinter.cxx | 3 ++- vcl/source/gdi/oldprintadaptor.cxx | 6 +++--- vcl/source/gdi/print3.cxx | 13 ++++++++++--- 7 files changed, 19 insertions(+), 11 deletions(-) diff --git a/include/vcl/oldprintadaptor.hxx b/include/vcl/oldprintadaptor.hxx index 59f2379d7e91..53e0d3d7bbfb 100644 --- a/include/vcl/oldprintadaptor.hxx +++ b/include/vcl/oldprintadaptor.hxx @@ -30,7 +30,7 @@ namespace vcl { std::unique_ptr mpData; public: - OldStylePrintAdaptor( const VclPtr< Printer >& ); + OldStylePrintAdaptor(const VclPtr&, const VclPtr&); virtual ~OldStylePrintAdaptor() override; void StartPage(); diff --git a/include/vcl/print.hxx b/include/vcl/print.hxx index ac15f1de4d0b..ae40d76ce96f 100644 --- a/include/vcl/print.hxx +++ b/include/vcl/print.hxx @@ -398,7 +398,7 @@ class VCL_DLLPUBLIC PrinterController std::unique_ptr mpImplData; protected: - PrinterController( const VclPtr& ); + PrinterController( const VclPtr&, const VclPtr& ); public: struct MultiPageSetup { @@ -440,6 +440,7 @@ public: virtual ~PrinterController(); const VclPtr& getPrinter() const; + const VclPtr& getWindow() const; /** For implementations: get current job properties as changed by e.g. print dialog diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx index 18557a41e1a1..a5be4fff8b7d 100644 --- a/sfx2/source/view/viewprn.cxx +++ b/sfx2/source/view/viewprn.cxx @@ -101,7 +101,7 @@ SfxPrinterController::SfxPrinterController( const VclPtr& i_rPrinter, SfxViewShell* pView, const uno::Sequence< beans::PropertyValue >& rProps ) - : PrinterController( i_rPrinter) + : PrinterController(i_rPrinter, pView ? pView->GetWindow() : nullptr) , maCompleteSelection( i_rComplete ) , maSelection( i_rSelection ) , mxRenderable( i_xRender ) diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx index e3329b4c931d..368f1849273e 100644 --- a/sw/inc/viewsh.hxx +++ b/sw/inc/viewsh.hxx @@ -82,7 +82,6 @@ class SwAccessibleMap; namespace vcl { typedef OutputDevice RenderContext; - class OldStylePrintAdaptor; } // Define for flags needed in ctor or layers below. diff --git a/toolkit/source/awt/vclxprinter.cxx b/toolkit/source/awt/vclxprinter.cxx index 3c61ad7b5fbd..7afe226f98de 100644 --- a/toolkit/source/awt/vclxprinter.cxx +++ b/toolkit/source/awt/vclxprinter.cxx @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -283,7 +284,7 @@ sal_Bool VCLXPrinter::start( const OUString& /*rJobName*/, sal_Int16 /*nCopies*/ if (mxPrinter.get()) { maInitJobSetup = mxPrinter->GetJobSetup(); - mxListener.reset(new vcl::OldStylePrintAdaptor(mxPrinter)); + mxListener.reset(new vcl::OldStylePrintAdaptor(mxPrinter, nullptr)); } return true; diff --git a/vcl/source/gdi/oldprintadaptor.cxx b/vcl/source/gdi/oldprintadaptor.cxx index a823a1be897c..8636034c6fbd 100644 --- a/vcl/source/gdi/oldprintadaptor.cxx +++ b/vcl/source/gdi/oldprintadaptor.cxx @@ -44,9 +44,9 @@ namespace vcl }; } -OldStylePrintAdaptor::OldStylePrintAdaptor( const VclPtr< Printer >& i_xPrinter ) - : PrinterController( i_xPrinter ) - , mpData( new ImplOldStyleAdaptorData ) +OldStylePrintAdaptor::OldStylePrintAdaptor(const VclPtr& i_xPrinter, const VclPtr& i_xWindow) + : PrinterController(i_xPrinter, i_xWindow) + , mpData(new ImplOldStyleAdaptorData) { } diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 8659de290fb7..22edd1734de9 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -140,6 +140,7 @@ public: typedef std::unordered_map< OUString, css::uno::Sequence< sal_Bool > > ChoiceDisableMap; VclPtr< Printer > mxPrinter; + VclPtr mxWindow; css::uno::Sequence< css::beans::PropertyValue > maUIOptions; std::vector< css::beans::PropertyValue > maUIProperties; std::vector< bool > maUIPropertyEnabled; @@ -207,10 +208,11 @@ public: void resetPaperToLastConfigured(); }; -PrinterController::PrinterController( const VclPtr& i_xPrinter ) +PrinterController::PrinterController(const VclPtr& i_xPrinter, const VclPtr& i_xWindow) : mpImplData( new ImplPrinterControllerData ) { mpImplData->mxPrinter = i_xPrinter; + mpImplData->mxWindow = i_xWindow; } static OUString queryFile( Printer const * pPrinter ) @@ -304,7 +306,7 @@ bool Printer::PreparePrintJob(std::shared_ptr xController, if (xController->isShowDialogs()) { ScopedVclPtrInstance aBox( - nullptr, "ErrorNoPrinterDialog", + xController->getWindow(), "ErrorNoPrinterDialog", "vcl/ui/errornoprinterdialog.ui"); aBox->Execute(); } @@ -455,7 +457,7 @@ bool Printer::PreparePrintJob(std::shared_ptr xController, if( xController->getFilteredPageCount() == 0 ) { ScopedVclPtrInstance aBox( - nullptr, "ErrorNoContentDialog", + xController->getWindow(), "ErrorNoContentDialog", "vcl/ui/errornocontentdialog.ui"); aBox->Execute(); return false; @@ -768,6 +770,11 @@ const VclPtr& PrinterController::getPrinter() const return mpImplData->mxPrinter; } +const VclPtr& PrinterController::getWindow() const +{ + return mpImplData->mxWindow; +} + void PrinterController::setPrinter( const VclPtr& i_rPrinter ) { mpImplData->mxPrinter = i_rPrinter; -- cgit