summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Specht <oliver.specht@cib.de>2016-05-04 11:51:58 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2016-05-11 14:40:23 +0000
commitb22ce3294695c7ef4c80f7ec4c4db10b13ad7ab2 (patch)
tree2f63fe6e7fb490e882844ca16f3fe9d9bd17210f
parent315aebd9706fde5c8d4a4b6d1f5587edf5607671 (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>
-rw-r--r--fpicker/source/win32/filepicker/VistaFilePicker.cxx9
-rw-r--r--fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx19
-rw-r--r--fpicker/source/win32/filepicker/VistaFilePickerImpl.hxx1
-rw-r--r--include/sfx2/filedlghelper.hxx3
-rw-r--r--sfx2/source/dialog/filedlghelper.cxx7
-rw-r--r--sfx2/source/doc/guisaveas.cxx4
6 files changed, 38 insertions, 5 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("------------------------------------------" );
diff --git a/include/sfx2/filedlghelper.hxx b/include/sfx2/filedlghelper.hxx
index 5f4a24e8ce44..d8a8fe97b14c 100644
--- a/include/sfx2/filedlghelper.hxx
+++ b/include/sfx2/filedlghelper.hxx
@@ -117,7 +117,8 @@ public:
SfxFilterFlags nMust,
SfxFilterFlags nDont,
const OUString& rStandardDir,
- const css::uno::Sequence< OUString >& rBlackList);
+ const css::uno::Sequence< OUString >& rBlackList,
+ vcl::Window* _pPreferredParent = nullptr);
FileDialogHelper( sal_Int16 nDialogType,
sal_Int64 nFlags,
diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx
index 1d6fe71d8431..be788616c6a2 100644
--- a/sfx2/source/dialog/filedlghelper.cxx
+++ b/sfx2/source/dialog/filedlghelper.cxx
@@ -1030,6 +1030,8 @@ FileDialogHelper_Impl::FileDialogHelper_Impl(
if ( mbSystemPicker )
{
aInitArguments[0] <<= nTemplateDescription;
+ if ( mpPreferredParentWindow )
+ aInitArguments[1] <<= makeAny( VCLUnoHelper::GetInterface( mpPreferredParentWindow ) );
}
else
{
@@ -2230,10 +2232,11 @@ FileDialogHelper::FileDialogHelper(
SfxFilterFlags nMust,
SfxFilterFlags nDont,
const OUString& rStandardDir,
- const css::uno::Sequence< OUString >& rBlackList)
+ const css::uno::Sequence< OUString >& rBlackList,
+ vcl::Window* _pPreferredParent)
: m_nError(0)
{
- mpImp = new FileDialogHelper_Impl( this, nDialogType, nFlags, nDialog, nullptr, rStandardDir, rBlackList );
+ mpImp = new FileDialogHelper_Impl( this, nDialogType, nFlags, nDialog, _pPreferredParent, rStandardDir, rBlackList );
mxImp = mpImp;
// create the list of filters
diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx
index e7507c619fcf..722d951191b5 100644
--- a/sfx2/source/doc/guisaveas.cxx
+++ b/sfx2/source/doc/guisaveas.cxx
@@ -909,7 +909,9 @@ bool ModelData_Impl::OutputFileDialog( sal_Int8 nStoreMode,
else
{
// This is the normal dialog
- pFileDlg.reset(new sfx2::FileDialogHelper( aDialogMode, aDialogFlags, aDocServiceName, nDialog, nMust, nDont, rStandardDir, rBlackList ));
+ vcl::Window* pWin = SfxStoringHelper::GetModelWindow( m_xModel );
+ pFileDlg.reset(new sfx2::FileDialogHelper( aDialogMode, aDialogFlags, aDocServiceName, nDialog,
+ nMust, nDont, rStandardDir, rBlackList, pWin ));
pFileDlg->CreateMatcher( aDocServiceName );
}