summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-07-25 10:30:56 +0100
committerCaolán McNamara <caolanm@redhat.com>2019-07-25 13:24:11 +0200
commitb0cc179a728603d62fd62595f039d2d856f8c9c3 (patch)
treedae6ad2f37a41a2b8adc28aa81ac3cd50bb077d5
parent11b06f0e00fc21654384e2816842ab101e15010e (diff)
add XInitialization to allow setting explicit dialog parent
Change-Id: Icc2626b6b3defeb6c02a43cee14cdb97dc573870 Reviewed-on: https://gerrit.libreoffice.org/76290 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--extensions/source/scanner/scanner.cxx9
-rw-r--r--extensions/source/scanner/scanner.hxx7
-rw-r--r--extensions/source/scanner/scanunx.cxx4
-rw-r--r--sd/source/ui/view/drviews2.cxx15
-rw-r--r--sw/source/uibase/uiview/uivwimp.cxx16
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 <cppuhelper/supportsservice.hxx>
-
+#include <comphelper/namedvaluecollection.hxx>
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<css::uno::Any>& 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 <com/sun/star/uno/Reference.h>
#include <com/sun/star/uno/Sequence.h>
#include <com/sun/star/awt/XBitmap.hpp>
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/lang/XEventListener.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
@@ -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<css::awt::XWindow> mxDialogParent;
void* mpData;
static void AcquireData();
@@ -71,6 +74,8 @@ public:
css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
+ virtual void SAL_CALL initialize(const css::uno::Sequence<css::uno::Any>& 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 <sal/log.hxx>
#include <tools/solar.h>
#include <cppuhelper/queryinterface.hxx>
+#include <vcl/svapp.hxx>
#include <memory>
-
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 <com/sun/star/drawing/XMasterPagesSupplier.hpp>
#include <com/sun/star/drawing/XDrawPages.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
#include <com/sun/star/ui/dialogs/XSLTFilterDialog.hpp>
#include <com/sun/star/frame/XDispatchProvider.hpp>
@@ -36,6 +37,7 @@
#include <com/sun/star/document/XDocumentProperties.hpp>
#include <comphelper/processfactory.hxx>
+#include <comphelper/propertysequence.hxx>
#include <comphelper/scopeguard.hxx>
#include <editeng/editdata.hxx>
@@ -1730,6 +1732,19 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
if( aContexts.hasElements() )
{
css::scanner::ScannerContext aContext( aContexts.getConstArray()[ 0 ] );
+
+ Reference<lang::XInitialization> xInit(mxScannerManager, UNO_QUERY);
+ if (xInit.is())
+ {
+ // initialize dialog
+ weld::Window* pWindow = rReq.GetFrameWeld();
+ uno::Sequence<uno::Any> aSeq(comphelper::InitAnyPropertySequence(
+ {
+ {"ParentWindow", pWindow ? uno::Any(pWindow->GetXWindow()) : uno::Any(Reference<awt::XWindow>())}
+ }));
+ 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 <com/sun/star/scanner/XScannerManager2.hpp>
#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
+#include <comphelper/propertysequence.hxx>
#include <vcl/weld.hxx>
#include <vcl/svapp.hxx>
#include <vcl/wrkwin.hxx>
@@ -128,6 +129,19 @@ void SwView_Impl::ExecuteScan( SfxRequest& rReq )
{
Reference< XEventListener > xLstner = &rListener;
ScannerContext aContext( aContexts.getConstArray()[ 0 ] );
+
+ Reference<lang::XInitialization> xInit(xScanMgr, UNO_QUERY);
+ if (xInit.is())
+ {
+ // initialize dialog
+ weld::Window* pWindow = rReq.GetFrameWeld();
+ uno::Sequence<uno::Any> aSeq(comphelper::InitAnyPropertySequence(
+ {
+ {"ParentWindow", pWindow ? uno::Any(pWindow->GetXWindow()) : uno::Any(Reference<awt::XWindow>())}
+ }));
+ xInit->initialize( aSeq );
+ }
+
bDone = xScanMgr->configureScannerAndScan( aContext, xLstner );
}
}
@@ -170,7 +184,7 @@ void SwView_Impl::ExecuteScan( SfxRequest& rReq )
if( !bDone )
{
- std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(nullptr,
+ std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(rReq.GetFrameWeld(),
VclMessageType::Info, VclButtonsType::Ok,
SwResId(STR_SCAN_NOSOURCE)));
xBox->run();