[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - fpicker/source include/sfx2 sfx2/source

Oliver Specht oliver.specht at cib.de
Mon May 23 08:12:53 UTC 2016


 fpicker/source/win32/filepicker/VistaFilePicker.cxx     |    9 ++++++-
 fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx |   19 ++++++++++++++++
 fpicker/source/win32/filepicker/VistaFilePickerImpl.hxx |    1 
 include/sfx2/filedlghelper.hxx                          |    3 +-
 sfx2/source/dialog/filedlghelper.cxx                    |    7 ++++-
 sfx2/source/doc/guisaveas.cxx                           |    4 ++-
 6 files changed, 38 insertions(+), 5 deletions(-)

New commits:
commit 6c933e37f5ad448b5a22ff43e6995d9c38e6fe0e
Author: Oliver Specht <oliver.specht at cib.de>
Date:   Wed May 4 11:51:58 2016 +0200

    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 at libreoffice.org>
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Reviewed-on: https://gerrit.libreoffice.org/25211
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/fpicker/source/win32/filepicker/VistaFilePicker.cxx b/fpicker/source/win32/filepicker/VistaFilePicker.cxx
index 4970b4e..742ebfd 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>
@@ -573,7 +574,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);
@@ -581,6 +586,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 cb98071..da5eb5a 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
@@ -479,6 +483,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 = 0;
+            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 47e1be6..7091d0b 100644
--- a/fpicker/source/win32/filepicker/VistaFilePickerImpl.hxx
+++ b/fpicker/source/win32/filepicker/VistaFilePickerImpl.hxx
@@ -93,6 +93,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 55c3790..a68c766 100644
--- a/include/sfx2/filedlghelper.hxx
+++ b/include/sfx2/filedlghelper.hxx
@@ -115,7 +115,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 540f8c2..0ba389c 100644
--- a/sfx2/source/dialog/filedlghelper.cxx
+++ b/sfx2/source/dialog/filedlghelper.cxx
@@ -1031,6 +1031,8 @@ FileDialogHelper_Impl::FileDialogHelper_Impl(
         if ( mbSystemPicker )
         {
             aInitArguments[0] <<= nTemplateDescription;
+            if ( mpPreferredParentWindow )
+                aInitArguments[1] <<= makeAny( VCLUnoHelper::GetInterface( mpPreferredParentWindow ) );
         }
         else
         {
@@ -2233,10 +2235,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 ddf888c..3667f7f 100644
--- a/sfx2/source/doc/guisaveas.cxx
+++ b/sfx2/source/doc/guisaveas.cxx
@@ -910,7 +910,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 );
     }
 


More information about the Libreoffice-commits mailing list