From b0cc179a728603d62fd62595f039d2d856f8c9c3 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 25 Jul 2019 10:30:56 +0100 Subject: add XInitialization to allow setting explicit dialog parent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Icc2626b6b3defeb6c02a43cee14cdb97dc573870 Reviewed-on: https://gerrit.libreoffice.org/76290 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- extensions/source/scanner/scanner.cxx | 9 ++++++++- extensions/source/scanner/scanner.hxx | 7 ++++++- extensions/source/scanner/scanunx.cxx | 4 ++-- sd/source/ui/view/drviews2.cxx | 15 +++++++++++++++ sw/source/uibase/uiview/uivwimp.cxx | 16 +++++++++++++++- 5 files changed, 46 insertions(+), 5 deletions(-) diff --git a/extensions/source/scanner/scanner.cxx b/extensions/source/scanner/scanner.cxx index e03cf30e9737..d51fca0b1ef9 100644 --- a/extensions/source/scanner/scanner.cxx +++ b/extensions/source/scanner/scanner.cxx @@ -20,7 +20,7 @@ #include "scanner.hxx" #include - +#include Reference< XInterface > ScannerManager_CreateInstance( const Reference< css::lang::XMultiServiceFactory >& /*rxFactory*/ ) { @@ -83,4 +83,11 @@ sal_Bool SAL_CALL ScannerManager::configureScanner( ScannerContext& rContext ) return configureScannerAndScan( rContext, nullptr ); } +void SAL_CALL ScannerManager::initialize(const css::uno::Sequence& rArguments) +{ + ::comphelper::NamedValueCollection aProperties(rArguments); + if (aProperties.has("ParentWindow")) + aProperties.get("ParentWindow") >>= mxDialogParent; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/scanner/scanner.hxx b/extensions/source/scanner/scanner.hxx index 9ae7821af3c0..854bb07e8db4 100644 --- a/extensions/source/scanner/scanner.hxx +++ b/extensions/source/scanner/scanner.hxx @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include #include #include @@ -39,9 +41,10 @@ using namespace com::sun::star::scanner; class ScannerManager final : public cppu::WeakImplHelper< - XScannerManager2, css::awt::XBitmap, css::lang::XServiceInfo> + XScannerManager2, css::awt::XBitmap, css::lang::XServiceInfo, css::lang::XInitialization> { osl::Mutex maProtector; + css::uno::Reference mxDialogParent; void* mpData; static void AcquireData(); @@ -71,6 +74,8 @@ public: css::uno::Sequence SAL_CALL getSupportedServiceNames() override; + virtual void SAL_CALL initialize(const css::uno::Sequence& rArguments) override; + // Misc static OUString getImplementationName_Static() throw(); static Sequence< OUString > getSupportedServiceNames_Static() throw(); diff --git a/extensions/source/scanner/scanunx.cxx b/extensions/source/scanner/scanunx.cxx index dd439dc3c9bf..a9ee05e5164e 100644 --- a/extensions/source/scanner/scanunx.cxx +++ b/extensions/source/scanner/scanunx.cxx @@ -23,9 +23,9 @@ #include #include #include +#include #include - BitmapTransporter::BitmapTransporter() { SAL_INFO("extensions.scanner", "BitmapTransporter"); @@ -264,7 +264,7 @@ sal_Bool ScannerManager::configureScannerAndScan( ScannerContext& scanner_contex ); pHolder->m_bBusy = true; - SaneDlg aDlg(nullptr, pHolder->m_aSane, listener.is()); + SaneDlg aDlg(Application::GetFrameWeld(mxDialogParent), pHolder->m_aSane, listener.is()); bRet = aDlg.run(); bScan = aDlg.getDoScan(); pHolder->m_bBusy = false; diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx index 3c70dc1596c6..34fcc56b2243 100644 --- a/sd/source/ui/view/drviews2.cxx +++ b/sd/source/ui/view/drviews2.cxx @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -36,6 +37,7 @@ #include #include +#include #include #include @@ -1730,6 +1732,19 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) if( aContexts.hasElements() ) { css::scanner::ScannerContext aContext( aContexts.getConstArray()[ 0 ] ); + + Reference xInit(mxScannerManager, UNO_QUERY); + if (xInit.is()) + { + // initialize dialog + weld::Window* pWindow = rReq.GetFrameWeld(); + uno::Sequence aSeq(comphelper::InitAnyPropertySequence( + { + {"ParentWindow", pWindow ? uno::Any(pWindow->GetXWindow()) : uno::Any(Reference())} + })); + xInit->initialize( aSeq ); + } + mxScannerManager->configureScannerAndScan( aContext, mxScannerListener ); } } diff --git a/sw/source/uibase/uiview/uivwimp.cxx b/sw/source/uibase/uiview/uivwimp.cxx index 01a48a3cba35..7b2130939798 100644 --- a/sw/source/uibase/uiview/uivwimp.cxx +++ b/sw/source/uibase/uiview/uivwimp.cxx @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -128,6 +129,19 @@ void SwView_Impl::ExecuteScan( SfxRequest& rReq ) { Reference< XEventListener > xLstner = &rListener; ScannerContext aContext( aContexts.getConstArray()[ 0 ] ); + + Reference xInit(xScanMgr, UNO_QUERY); + if (xInit.is()) + { + // initialize dialog + weld::Window* pWindow = rReq.GetFrameWeld(); + uno::Sequence aSeq(comphelper::InitAnyPropertySequence( + { + {"ParentWindow", pWindow ? uno::Any(pWindow->GetXWindow()) : uno::Any(Reference())} + })); + xInit->initialize( aSeq ); + } + bDone = xScanMgr->configureScannerAndScan( aContext, xLstner ); } } @@ -170,7 +184,7 @@ void SwView_Impl::ExecuteScan( SfxRequest& rReq ) if( !bDone ) { - std::unique_ptr xBox(Application::CreateMessageDialog(nullptr, + std::unique_ptr xBox(Application::CreateMessageDialog(rReq.GetFrameWeld(), VclMessageType::Info, VclButtonsType::Ok, SwResId(STR_SCAN_NOSOURCE))); xBox->run(); -- cgit v1.2.3