[Libreoffice-commits] core.git: fpicker/source include/sfx2 sfx2/source

Oliver Specht oliver.specht at cib.de
Wed May 11 14:40:59 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 b22ce3294695c7ef4c80f7ec4c4db10b13ad7ab2
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>

diff --git a/fpicker/source/win32/filepicker/VistaFilePicker.cxx b/fpicker/source/win32/filepicker/VistaFilePicker.cxx
index 939ade4..2efdad5 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 9e24e9e..3018a08 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 5a7e7f4..c457e29 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 5f4a24e..d8a8fe97 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 1d6fe71..be78861 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 e7507c6..722d951 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 );
     }
 


More information about the Libreoffice-commits mailing list