diff options
-rw-r--r-- | fpicker/source/win32/filepicker/FPentry.cxx | 4 | ||||
-rw-r--r-- | fpicker/source/win32/filepicker/SolarMutex.cxx | 58 | ||||
-rw-r--r-- | fpicker/source/win32/filepicker/SolarMutex.hxx | 33 | ||||
-rw-r--r-- | fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx | 1 | ||||
-rw-r--r-- | fpicker/source/win32/filepicker/asynceventnotifier.cxx | 5 | ||||
-rw-r--r-- | fpicker/source/win32/filepicker/asyncrequests.cxx | 2 | ||||
-rw-r--r-- | fpicker/source/win32/filepicker/makefile.mk | 3 | ||||
-rw-r--r-- | fpicker/source/win32/folderpicker/MtaFop.cxx | 34 | ||||
-rw-r--r-- | fpicker/source/win32/misc/WinImplHelper.cxx | 46 | ||||
-rw-r--r-- | fpicker/source/win32/misc/WinImplHelper.hxx | 2 | ||||
-rw-r--r-- | framework/source/uielement/toolbarmanager.cxx | 16 | ||||
-rw-r--r-- | sfx2/inc/sfx2/filedlghelper.hxx | 8 | ||||
-rw-r--r-- | sfx2/source/dialog/filedlghelper.cxx | 50 | ||||
-rw-r--r-- | sfx2/source/doc/docinsert.cxx | 26 |
14 files changed, 229 insertions, 59 deletions
diff --git a/fpicker/source/win32/filepicker/FPentry.cxx b/fpicker/source/win32/filepicker/FPentry.cxx index 48cc3cc53a50..bc3d020baaad 100644 --- a/fpicker/source/win32/filepicker/FPentry.cxx +++ b/fpicker/source/win32/filepicker/FPentry.cxx @@ -66,9 +66,9 @@ static Reference< XInterface > SAL_CALL createInstance( const Reference< XMultiServiceFactory >& rServiceManager ) { Reference< XInterface > xDlg; - bool bVista = IsWindowsVista(); + bool bVistaOrNewer = IsWindowsVistaOrNewer(); - if (bVista) + if (bVistaOrNewer) { fprintf(stdout, "use special (vista) system file picker ...\n"); xDlg.set( diff --git a/fpicker/source/win32/filepicker/SolarMutex.cxx b/fpicker/source/win32/filepicker/SolarMutex.cxx new file mode 100644 index 000000000000..3c446f412e46 --- /dev/null +++ b/fpicker/source/win32/filepicker/SolarMutex.cxx @@ -0,0 +1,58 @@ +/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: asynceventnotifier.cxx,v $
+ * $Revision: 1.16 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_fpicker.hxx"
+
+#include <vcl/svapp.hxx>
+#include <vos/mutex.hxx>
+#include <osl/thread.hxx>
+
+int ReleaseSolarMutexOnMainThreadContext(unsigned nThreadId)
+{
+ int nAcquireCount = 0;
+ vos::IMutex& rSolarMutex = Application::GetSolarMutex();
+ vos::OThread::TThreadIdentifier nMainThreadId = Application::GetMainThreadIdentifier();
+
+ if ( nMainThreadId == nThreadId )
+ {
+ ::vos::IMutex& rMutex = Application::GetSolarMutex();
+ if ( rMutex.tryToAcquire() )
+ nAcquireCount = Application::ReleaseSolarMutex() - 1;
+ }
+
+ return nAcquireCount;
+}
+
+void AcquireSolarMutex(int nAcquireCount)
+{
+ if ( nAcquireCount )
+ Application::AcquireSolarMutex( nAcquireCount );
+}
diff --git a/fpicker/source/win32/filepicker/SolarMutex.hxx b/fpicker/source/win32/filepicker/SolarMutex.hxx new file mode 100644 index 000000000000..95dcf13ecc3b --- /dev/null +++ b/fpicker/source/win32/filepicker/SolarMutex.hxx @@ -0,0 +1,33 @@ +/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: asynceventnotifier.cxx,v $
+ * $Revision: 1.16 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+int ReleaseSolarMutexOnMainThreadContext(unsigned nThreadId);
+
+void AcquireSolarMutex(int nAcquireCount);
diff --git a/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx b/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx index a22ef2bea143..38ca768da08b 100644 --- a/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx +++ b/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx @@ -401,7 +401,6 @@ void VistaFilePickerImpl::impl_sta_CreateOpenDialog(const RequestRef& rRequest) nFlags |= FOS_FILEMUSTEXIST; nFlags |= FOS_OVERWRITEPROMPT; nFlags |= FOS_DONTADDTORECENT; - nFlags |= FOS_ALLOWMULTISELECT; iDialog->SetOptions ( nFlags ); diff --git a/fpicker/source/win32/filepicker/asynceventnotifier.cxx b/fpicker/source/win32/filepicker/asynceventnotifier.cxx index a780eeaea52d..b715457b76dd 100644 --- a/fpicker/source/win32/filepicker/asynceventnotifier.cxx +++ b/fpicker/source/win32/filepicker/asynceventnotifier.cxx @@ -41,6 +41,7 @@ #include <process.h> #include <memory> +#include "SolarMutex.hxx" //------------------------------------------------ // @@ -159,7 +160,9 @@ bool SAL_CALL CAsyncEventNotifier::startup(bool bCreateSuspended) void SAL_CALL CAsyncEventNotifier::shutdown() { - OSL_PRECOND(GetCurrentThreadId() != m_ThreadId, "Method called in wrong thread context!"); + unsigned nThreadId = GetCurrentThreadId(); + + OSL_PRECOND(nThreadId != m_ThreadId, "Method called in wrong thread context!"); osl::ResettableMutexGuard aGuard(m_Mutex); diff --git a/fpicker/source/win32/filepicker/asyncrequests.cxx b/fpicker/source/win32/filepicker/asyncrequests.cxx index 17352345eb2b..dad19a629f7f 100644 --- a/fpicker/source/win32/filepicker/asyncrequests.cxx +++ b/fpicker/source/win32/filepicker/asyncrequests.cxx @@ -30,6 +30,7 @@ #include "asyncrequests.hxx" #include <vcl/svapp.hxx> +#include <vos/mutex.hxx> //----------------------------------------------------------------------------- // namespace @@ -68,6 +69,7 @@ void Request::wait(::sal_Int32 nMilliSeconds) void Request::waitProcessMessages() { + ::vos::OGuard aGuard( Application::GetSolarMutex() ); while (!m_aJoiner.check()) Application::Yield(); } diff --git a/fpicker/source/win32/filepicker/makefile.mk b/fpicker/source/win32/filepicker/makefile.mk index c23c08108e42..de192879b629 100644 --- a/fpicker/source/win32/filepicker/makefile.mk +++ b/fpicker/source/win32/filepicker/makefile.mk @@ -79,7 +79,8 @@ SLOFILES=$(SLO)$/FileOpenDlg.obj\ $(SLO)$/asyncrequests.obj\ $(SLO)$/VistaFilePickerEventHandler.obj\ $(SLO)$/VistaFilePickerImpl.obj\ - $(SLO)$/VistaFilePicker.obj + $(SLO)$/VistaFilePicker.obj\ + $(SLO)$/SolarMutex.obj # --- Targets ------------------------------------------------------ diff --git a/fpicker/source/win32/folderpicker/MtaFop.cxx b/fpicker/source/win32/folderpicker/MtaFop.cxx index 573036c74252..147e0ef09cdd 100644 --- a/fpicker/source/win32/folderpicker/MtaFop.cxx +++ b/fpicker/source/win32/folderpicker/MtaFop.cxx @@ -448,34 +448,22 @@ LPITEMIDLIST SAL_CALL CMtaFolderPicker::getItemIdListFromPath( const rtl::OUStri if ( !aDirectory.getLength( ) ) return NULL; - IMallocPtr pIMalloc; - SHGetMalloc(&pIMalloc); + LPITEMIDLIST lpItemIdList(NULL); - LPITEMIDLIST lpItemIdList = static_cast<LPITEMIDLIST>( - pIMalloc->Alloc(sizeof(ITEMIDLIST))); + IShellFolderPtr pIShellFolder; + SHGetDesktopFolder(&pIShellFolder); - if (lpItemIdList) + if (pIShellFolder.is()) { - IShellFolderPtr pIShellFolder; - SHGetDesktopFolder(&pIShellFolder); - - if (pIShellFolder.is()) - { - pIShellFolder->ParseDisplayName( - NULL, - NULL, - reinterpret_cast<LPOLESTR>(const_cast< sal_Unicode* >( aDirectory.getStr( ) )), - NULL, - &lpItemIdList, - NULL ); - } + pIShellFolder->ParseDisplayName( + NULL, + NULL, + reinterpret_cast<LPWSTR>(const_cast< sal_Unicode* >( aDirectory.getStr( ) )), + NULL, + &lpItemIdList, + NULL ); } - if (pIMalloc.is()) - pIMalloc->Free(lpItemIdList); - - lpItemIdList = NULL; - return lpItemIdList; } diff --git a/fpicker/source/win32/misc/WinImplHelper.cxx b/fpicker/source/win32/misc/WinImplHelper.cxx index befd02352243..e253385a3c3d 100644 --- a/fpicker/source/win32/misc/WinImplHelper.cxx +++ b/fpicker/source/win32/misc/WinImplHelper.cxx @@ -69,6 +69,7 @@ const sal_Unicode AMPERSAND_SIGN = L'&'; // Windows 2000 VER_PLATFORM_WIN32_NT 5 0 // Windows XP VER_PLATFORM_WIN32_NT 5 1 // Windows Vista VER_PLATFORM_WIN32_NT 6 0 +// Windows 7 VER_PLATFORM_WIN32_NT 6 1 // Windows 95 VER_PLATFORM_WIN32_WINDOWS 4 0 // Windows 98 VER_PLATFORM_WIN32_WINDOWS 4 10 // Windows ME VER_PLATFORM_WIN32_WINDOWS 4 90 @@ -94,25 +95,47 @@ bool SAL_CALL IsWindowsVersion(unsigned int PlatformId, unsigned int MajorVersio } //------------------------------------------------------------ -// determine if we are running under Win2000 +// determine if we are running under Vista or newer OS //------------------------------------------------------------ -bool SAL_CALL IsWindowsVista() +bool SAL_CALL IsWindowsVistaOrNewer() { - return IsWindowsVersion(VER_PLATFORM_WIN32_NT, 6, 0); + OSVERSIONINFO osvi; + osvi.dwOSVersionInfoSize = sizeof(osvi); + + if(!GetVersionEx(&osvi)) + return false; + + bool bRet = (VER_PLATFORM_WIN32_NT == osvi.dwPlatformId) && + (osvi.dwMajorVersion >= 6); + + bRet = bRet && + (osvi.dwMinorVersion >= + sal::static_int_cast< unsigned int >(0)); + + return bRet; } //------------------------------------------------------------ -// determine if we are running under Win2000 +// determine if we are running under Windows 7 //------------------------------------------------------------ -bool SAL_CALL IsWindows2000() +bool SAL_CALL IsWindows7() { - return IsWindowsVersion(VER_PLATFORM_WIN32_NT, 5, 0); + return IsWindowsVersion(VER_PLATFORM_WIN32_NT, 6, 1); } //------------------------------------------------------------ -// +// determine if we are running under Windows Vista +//------------------------------------------------------------ + +bool SAL_CALL IsWindowsVista() +{ + return IsWindowsVersion(VER_PLATFORM_WIN32_NT, 6, 0); +} + +//------------------------------------------------------------ +// determine if we are running under Windows XP //------------------------------------------------------------ bool SAL_CALL IsWindowsXP() @@ -121,6 +144,15 @@ bool SAL_CALL IsWindowsXP() } //------------------------------------------------------------ +// determine if we are running under Windows 2000 +//------------------------------------------------------------ + +bool SAL_CALL IsWindows2000() +{ + return IsWindowsVersion(VER_PLATFORM_WIN32_NT, 5, 0); +} + +//------------------------------------------------------------ // //------------------------------------------------------------ diff --git a/fpicker/source/win32/misc/WinImplHelper.hxx b/fpicker/source/win32/misc/WinImplHelper.hxx index 3a8bd3179c81..6f29a2bb1226 100644 --- a/fpicker/source/win32/misc/WinImplHelper.hxx +++ b/fpicker/source/win32/misc/WinImplHelper.hxx @@ -53,6 +53,8 @@ // deklarations //------------------------------------------------------------------------ +bool SAL_CALL IsWindowsVistaOrNewer(); +bool SAL_CALL IsWindows7(); bool SAL_CALL IsWindowsVista(); bool SAL_CALL IsWindows2000(); bool SAL_CALL IsWindowsXP(); diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx index a85cee3178c3..a105f7b281a1 100644 --- a/framework/source/uielement/toolbarmanager.cxx +++ b/framework/source/uielement/toolbarmanager.cxx @@ -336,11 +336,21 @@ void ToolBarManager::Destroy() delete static_cast< AddonsParams* >( m_pToolBar->GetItemData( nItemId )); } - /* #i99167# removed change for i93173 since there is some weird crash + /* #i99167# removed change for i93173 since there is some weird crash */ // #i93173# delete toolbar lazily as we can still be in one of its handlers m_pToolBar->doLazyDelete(); - */ - delete m_pToolBar; + + Link aEmpty; + m_pToolBar->SetSelectHdl( aEmpty ); + m_pToolBar->SetActivateHdl( aEmpty ); + m_pToolBar->SetDeactivateHdl( aEmpty ); + m_pToolBar->SetClickHdl( aEmpty ); + m_pToolBar->SetDropdownClickHdl( aEmpty ); + m_pToolBar->SetDoubleClickHdl( aEmpty ); + m_pToolBar->SetStateChangedHdl( aEmpty ); + m_pToolBar->SetDataChangedHdl( aEmpty ); + +// delete m_pToolBar; m_pToolBar = 0; } diff --git a/sfx2/inc/sfx2/filedlghelper.hxx b/sfx2/inc/sfx2/filedlghelper.hxx index c93af303158c..f9377f9908ea 100644 --- a/sfx2/inc/sfx2/filedlghelper.hxx +++ b/sfx2/inc/sfx2/filedlghelper.hxx @@ -229,8 +229,16 @@ public: void SetTitle( const String& rNewTitle ); String GetPath() const; + /** @deprected: Don't use this method to retrieve the selected files + There are file picker which can provide multiple selected file which belong + to different folders. As this method always provides the root folder for all selected + files this cannot work. + */ ::com::sun::star::uno::Sequence< ::rtl::OUString > GetMPath() const; + /** Provides the selected files with full path information */ + ::com::sun::star::uno::Sequence< ::rtl::OUString > GetSelectedFiles() const; + void AddFilter( const String& rFilterName, const String& rExtension ); void SetCurrentFilter( const String& rFilter ); diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index cf2ea488c126..da9bf4a8b04c 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -1358,6 +1358,7 @@ sal_Int16 FileDialogHelper_Impl::implDoExecute() //On MacOSX the native file picker has to run in the primordial thread because of drawing issues //On Linux the native gtk file picker, when backed by gnome-vfs2, needs to be run in the same //primordial thread as the ucb gnome-vfs2 provider was initialized in. +/* #ifdef WNT if ( mbSystemPicker ) { @@ -1371,9 +1372,18 @@ sal_Int16 FileDialogHelper_Impl::implDoExecute() } else #endif +*/ { try { +#ifdef WNT + if ( mbSystemPicker ) + { + OReleaseSolarMutex aSolarMutex; + nRet = mxFileDlg->execute(); + } + else +#endif nRet = mxFileDlg->execute(); } catch( const Exception& ) @@ -2582,6 +2592,46 @@ Sequence < OUString > FileDialogHelper::GetMPath() const } // ------------------------------------------------------------------------ +Sequence< ::rtl::OUString > FileDialogHelper::GetSelectedFiles() const +{ + // a) the new way (optional!) + uno::Sequence< ::rtl::OUString > aResultSeq; + uno::Reference< XFilePicker2 > xPickNew(mpImp->mxFileDlg, UNO_QUERY); + if (xPickNew.is()) + { + aResultSeq = xPickNew->getSelectedFiles(); + } + // b) the olde way ... non optional. + else + { + uno::Reference< XFilePicker > xPickOld(mpImp->mxFileDlg, UNO_QUERY_THROW); + Sequence< OUString > lFiles = xPickOld->getFiles(); + ::sal_Int32 nFiles = lFiles.getLength(); + if ( nFiles > 1 ) + { + aResultSeq = Sequence< ::rtl::OUString >( nFiles-1 ); + + INetURLObject aPath( lFiles[0] ); + aPath.setFinalSlash(); + + for (::sal_Int32 i = 1; i < nFiles; i++) + { + if (i == 1) + aPath.Append( lFiles[i] ); + else + aPath.setName( lFiles[i] ); + + aResultSeq[i-1] = ::rtl::OUString(aPath.GetMainURL( INetURLObject::NO_DECODE )); + } + } + else + aResultSeq = lFiles; + } + + return aResultSeq; +} + +// ------------------------------------------------------------------------ String FileDialogHelper::GetDisplayDirectory() const { return mpImp->getPath(); diff --git a/sfx2/source/doc/docinsert.cxx b/sfx2/source/doc/docinsert.cxx index 8fae29a1847c..ecd9ae7aee42 100644 --- a/sfx2/source/doc/docinsert.cxx +++ b/sfx2/source/doc/docinsert.cxx @@ -177,33 +177,17 @@ void impl_FillURLList( sfx2::FileDialogHelper* _pFileDlg, SvStringsDtor*& _rpURL { DBG_ASSERT( _pFileDlg, "DocumentInserter::fillURLList(): invalid file dialog" ); DBG_ASSERT( !_rpURLList, "DocumentInserter::fillURLList(): URLList already exists" ); - Sequence < ::rtl::OUString > aPathSeq = _pFileDlg->GetMPath(); + Sequence < ::rtl::OUString > aPathSeq = _pFileDlg->GetSelectedFiles(); if ( aPathSeq.getLength() ) { _rpURLList = new SvStringsDtor; - if ( aPathSeq.getLength() == 1 ) + for ( USHORT i = 0; i < aPathSeq.getLength(); ++i ) { - ::rtl::OUString sFileURL( aPathSeq[0] ); - String* pURL = new String( sFileURL ); - _rpURLList->Insert( pURL, 0 ); - } - else - { - INetURLObject aPathObj( aPathSeq[0] ); - aPathObj.setFinalSlash(); - - for ( USHORT i = 1; i < aPathSeq.getLength(); ++i ) - { - if ( i == 1 ) - aPathObj.Append( aPathSeq[i] ); - else - aPathObj.setName( aPathSeq[i] ); - - String* pURL = new String( aPathObj.GetMainURL( INetURLObject::NO_DECODE ) ); - _rpURLList->Insert( pURL, _rpURLList->Count() ); - } + INetURLObject aPathObj( aPathSeq[i] ); + String* pURL = new String( aPathObj.GetMainURL( INetURLObject::NO_DECODE ) ); + _rpURLList->Insert( pURL, _rpURLList->Count() ); } } } |