diff options
author | Oliver Specht <oliver.specht@cib.de> | 2016-05-04 11:51:58 +0200 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2016-05-11 14:40:23 +0000 |
commit | b22ce3294695c7ef4c80f7ec4c4db10b13ad7ab2 (patch) | |
tree | 2f63fe6e7fb490e882844ca16f3fe9d9bd17210f /fpicker/source/win32 | |
parent | 315aebd9706fde5c8d4a4b6d1f5587edf5607671 (diff) |
set parent window of windows system file picker on save(as)
If no parent is provided the Windows system file picker uses either the current
foreground window or the desktop. The decision depends on the thread id of
the foreground window. To make sure the document window is used as parent this
is now also sent to the system file picker as it was already done for the
internal file picker.
Change-Id: Id589cbc1f91db30e065175aaea42ef1512ffb1b9
Reviewed-on: https://gerrit.libreoffice.org/24635
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'fpicker/source/win32')
-rw-r--r-- | fpicker/source/win32/filepicker/VistaFilePicker.cxx | 9 | ||||
-rw-r--r-- | fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx | 19 | ||||
-rw-r--r-- | fpicker/source/win32/filepicker/VistaFilePickerImpl.hxx | 1 |
3 files changed, 28 insertions, 1 deletions
diff --git a/fpicker/source/win32/filepicker/VistaFilePicker.cxx b/fpicker/source/win32/filepicker/VistaFilePicker.cxx index 939ade408e3a..2efdad5af545 100644 --- a/fpicker/source/win32/filepicker/VistaFilePicker.cxx +++ b/fpicker/source/win32/filepicker/VistaFilePicker.cxx @@ -30,6 +30,7 @@ #include "../misc/WinImplHelper.hxx" #include "shared.hxx" +#include <com/sun/star/awt/XWindow.hpp> #include <com/sun/star/lang/DisposedException.hpp> #include <com/sun/star/ui/dialogs/TemplateDescription.hpp> #include <com/sun/star/ui/dialogs/XFilePickerNotifier.hpp> @@ -524,7 +525,11 @@ void SAL_CALL VistaFilePicker::initialize(const css::uno::Sequence< css::uno::An } break; } - + css::uno::Reference<css::awt::XWindow> xParentWindow; + if(lArguments.getLength() > 1) + { + lArguments[1] >>= xParentWindow; + } RequestRef rRequest(new Request()); if (bFileOpenDialog) rRequest->setRequest (VistaFilePickerImpl::E_CREATE_OPEN_DIALOG); @@ -532,6 +537,8 @@ void SAL_CALL VistaFilePicker::initialize(const css::uno::Sequence< css::uno::An rRequest->setRequest (VistaFilePickerImpl::E_CREATE_SAVE_DIALOG); rRequest->setArgument(PROP_FEATURES, nFeatures); rRequest->setArgument(PROP_TEMPLATE_DESCR, nTemplate); + if(xParentWindow.is()) + rRequest->setArgument(PROP_PARENT_WINDOW, xParentWindow); if ( ! m_aAsyncExecute.isRunning()) m_aAsyncExecute.create(); m_aAsyncExecute.triggerRequestThreadAware(rRequest, AsyncRequests::NON_BLOCKED); diff --git a/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx b/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx index 9e24e9e352ed..3018a08282c2 100644 --- a/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx +++ b/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx @@ -26,9 +26,13 @@ #include <com/sun/star/ui/dialogs/ControlActions.hpp> #include <com/sun/star/ui/dialogs/TemplateDescription.hpp> #include <com/sun/star/beans/StringPair.hpp> +#include <com/sun/star/awt/XWindow.hpp> +#include <com/sun/star/awt/XSystemDependentWindowPeer.hpp> +#include <com/sun/star/lang/SystemDependent.hpp> #include <comphelper/sequence.hxx> #include <osl/file.hxx> #include <osl/mutex.hxx> +#include <rtl/process.h> #ifdef __MINGW32__ #include <limits.h> #endif @@ -477,6 +481,21 @@ void VistaFilePickerImpl::impl_sta_CreateSaveDialog(const RequestRef& rRequest) ::sal_Int32 nFeatures = rRequest->getArgumentOrDefault(PROP_FEATURES, (::sal_Int32)0); ::sal_Int32 nTemplate = rRequest->getArgumentOrDefault(PROP_TEMPLATE_DESCR, (::sal_Int32)0); + css::uno::Reference<css::awt::XWindow> xWindow = rRequest->getArgumentOrDefault(PROP_PARENT_WINDOW, css::uno::Reference<css::awt::XWindow>()); + if(xWindow.is()) + { + css::uno::Reference<css::awt::XSystemDependentWindowPeer> xSysDepWin(xWindow,css::uno::UNO_QUERY); + if(xSysDepWin.is()) { + css::uno::Sequence<sal_Int8> aProcessIdent(16); + rtl_getGlobalProcessId((sal_uInt8*)aProcessIdent.getArray()); + css::uno::Any aAny = xSysDepWin->getWindowHandle(aProcessIdent,css::lang::SystemDependent::SYSTEM_WIN32); + sal_Int64 tmp; + aAny >>= tmp; + if(tmp != 0) + m_hParentWindow = (HWND) tmp; + } + } + impl_sta_enableFeatures(nFeatures, nTemplate); VistaFilePickerEventHandler* pHandlerImpl = (VistaFilePickerEventHandler*)iHandler.get(); diff --git a/fpicker/source/win32/filepicker/VistaFilePickerImpl.hxx b/fpicker/source/win32/filepicker/VistaFilePickerImpl.hxx index 5a7e7f44d97e..c457e290064d 100644 --- a/fpicker/source/win32/filepicker/VistaFilePickerImpl.hxx +++ b/fpicker/source/win32/filepicker/VistaFilePickerImpl.hxx @@ -90,6 +90,7 @@ static const OUString PROP_CONTROL_ACTION("control_action" ); // [sal_Int16] static const OUString PROP_CONTROL_VALUE("control_value" ); // [Any] static const OUString PROP_CONTROL_LABEL("control_label" ); // [OUString] static const OUString PROP_CONTROL_ENABLE("control_enable" ); // [sal_Bool] true=ON, false=OFF +static const OUString PROP_PARENT_WINDOW("ParentWindow"); //[css::awt::XWindow] preferred parent window static const OUString STRING_SEPARATOR("------------------------------------------" ); |