Kaydet (Commit) 29da2639 authored tarafından Jens-Heiner Rechtien's avatar Jens-Heiner Rechtien

CWS-TOOLING: integrate CWS filepicker01

2009-07-03 13:21:25 +0200 cd  r273690 : #i102319# Use GetSelectedFiles() instead of GetMPath() to retrieve a set of selected files
2009-07-01 14:27:56 +0200 cd  r273582 : #i64800# Use ParseDisplayName correctly and don't allocate memory for an output parameter
2009-07-01 10:47:47 +0200 cd  r273553 : #i102701# Make P1 fix for CWS filepicker01, too.
2009-06-29 11:58:09 +0200 cd  r273463 : i102319# File picker should NOT set multi selection as a default.
2009-06-29 11:49:10 +0200 cd  r273461 : #i102319# Use XFilePicker2 interface to retrieve files from multi selection
2009-06-26 15:42:43 +0200 cd  r273423 : #i99759# Release solar mutex before blocking on execute() when using system file picker
2009-06-26 15:35:50 +0200 cd  r273422 : #i99759# Don't release solar mutex in shutdown(). Must be done before calling execute()
2009-06-23 11:40:02 +0200 cd  r273267 : #i95425# Fixed wrong initialization of TimeValue members
2009-06-23 10:35:20 +0200 cd  r273262 : #i99759# Fix deadlock on Windows XP/2000 because of removing Picker Thread from sfx2. Now CAsyncEventNotifierThread releases the solar mutex before blocking
2009-06-22 11:59:15 +0200 cd  r273209 : #i102948# Remove links from toolbar object when using lazy delete as the toolbar manager is now destroyed before the toolbar
2009-06-22 11:22:14 +0200 cd  r273204 : #i99759# Don't use a new thread to call the file picker. As a consequence this thread is also calling Application::Yield() and therefore is fighting with the main thread for messages
2009-06-22 11:13:32 +0200 cd  r273203 : #i99759# Solar mutex must be locked before calling Application::Yield()
2009-06-19 15:23:01 +0200 cd  r273161 : #i102948# Remove/add decorated window from/into old/new parent decorated window list
2009-06-19 12:49:37 +0200 cd  r273156 : #i101843# Use new COM based dialog implementation from Windows Vista on
üst 302383a9
...@@ -66,9 +66,9 @@ static Reference< XInterface > SAL_CALL createInstance( ...@@ -66,9 +66,9 @@ static Reference< XInterface > SAL_CALL createInstance(
const Reference< XMultiServiceFactory >& rServiceManager ) const Reference< XMultiServiceFactory >& rServiceManager )
{ {
Reference< XInterface > xDlg; Reference< XInterface > xDlg;
bool bVista = IsWindowsVista(); bool bVistaOrNewer = IsWindowsVistaOrNewer();
if (bVista) if (bVistaOrNewer)
{ {
fprintf(stdout, "use special (vista) system file picker ...\n"); fprintf(stdout, "use special (vista) system file picker ...\n");
xDlg.set( xDlg.set(
......
/*************************************************************************
*
* 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 );
}
/*************************************************************************
*
* 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);
...@@ -401,7 +401,6 @@ void VistaFilePickerImpl::impl_sta_CreateOpenDialog(const RequestRef& rRequest) ...@@ -401,7 +401,6 @@ void VistaFilePickerImpl::impl_sta_CreateOpenDialog(const RequestRef& rRequest)
nFlags |= FOS_FILEMUSTEXIST; nFlags |= FOS_FILEMUSTEXIST;
nFlags |= FOS_OVERWRITEPROMPT; nFlags |= FOS_OVERWRITEPROMPT;
nFlags |= FOS_DONTADDTORECENT; nFlags |= FOS_DONTADDTORECENT;
nFlags |= FOS_ALLOWMULTISELECT;
iDialog->SetOptions ( nFlags ); iDialog->SetOptions ( nFlags );
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include <process.h> #include <process.h>
#include <memory> #include <memory>
#include "SolarMutex.hxx"
//------------------------------------------------ //------------------------------------------------
// //
...@@ -159,7 +160,9 @@ bool SAL_CALL CAsyncEventNotifier::startup(bool bCreateSuspended) ...@@ -159,7 +160,9 @@ bool SAL_CALL CAsyncEventNotifier::startup(bool bCreateSuspended)
void SAL_CALL CAsyncEventNotifier::shutdown() 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); osl::ResettableMutexGuard aGuard(m_Mutex);
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "asyncrequests.hxx" #include "asyncrequests.hxx"
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
#include <vos/mutex.hxx>
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// namespace // namespace
...@@ -68,6 +69,7 @@ void Request::wait(::sal_Int32 nMilliSeconds) ...@@ -68,6 +69,7 @@ void Request::wait(::sal_Int32 nMilliSeconds)
void Request::waitProcessMessages() void Request::waitProcessMessages()
{ {
::vos::OGuard aGuard( Application::GetSolarMutex() );
while (!m_aJoiner.check()) while (!m_aJoiner.check())
Application::Yield(); Application::Yield();
} }
......
...@@ -79,7 +79,8 @@ SLOFILES=$(SLO)$/FileOpenDlg.obj\ ...@@ -79,7 +79,8 @@ SLOFILES=$(SLO)$/FileOpenDlg.obj\
$(SLO)$/asyncrequests.obj\ $(SLO)$/asyncrequests.obj\
$(SLO)$/VistaFilePickerEventHandler.obj\ $(SLO)$/VistaFilePickerEventHandler.obj\
$(SLO)$/VistaFilePickerImpl.obj\ $(SLO)$/VistaFilePickerImpl.obj\
$(SLO)$/VistaFilePicker.obj $(SLO)$/VistaFilePicker.obj\
$(SLO)$/SolarMutex.obj
# --- Targets ------------------------------------------------------ # --- Targets ------------------------------------------------------
......
...@@ -448,34 +448,22 @@ LPITEMIDLIST SAL_CALL CMtaFolderPicker::getItemIdListFromPath( const rtl::OUStri ...@@ -448,34 +448,22 @@ LPITEMIDLIST SAL_CALL CMtaFolderPicker::getItemIdListFromPath( const rtl::OUStri
if ( !aDirectory.getLength( ) ) if ( !aDirectory.getLength( ) )
return NULL; return NULL;
IMallocPtr pIMalloc; LPITEMIDLIST lpItemIdList(NULL);
SHGetMalloc(&pIMalloc);
LPITEMIDLIST lpItemIdList = static_cast<LPITEMIDLIST>( IShellFolderPtr pIShellFolder;
pIMalloc->Alloc(sizeof(ITEMIDLIST))); SHGetDesktopFolder(&pIShellFolder);
if (lpItemIdList) if (pIShellFolder.is())
{ {
IShellFolderPtr pIShellFolder; pIShellFolder->ParseDisplayName(
SHGetDesktopFolder(&pIShellFolder); NULL,
NULL,
if (pIShellFolder.is()) reinterpret_cast<LPWSTR>(const_cast< sal_Unicode* >( aDirectory.getStr( ) )),
{ NULL,
pIShellFolder->ParseDisplayName( &lpItemIdList,
NULL, NULL );
NULL,
reinterpret_cast<LPOLESTR>(const_cast< sal_Unicode* >( aDirectory.getStr( ) )),
NULL,
&lpItemIdList,
NULL );
}
} }
if (pIMalloc.is())
pIMalloc->Free(lpItemIdList);
lpItemIdList = NULL;
return lpItemIdList; return lpItemIdList;
} }
......
...@@ -69,6 +69,7 @@ const sal_Unicode AMPERSAND_SIGN = L'&'; ...@@ -69,6 +69,7 @@ const sal_Unicode AMPERSAND_SIGN = L'&';
// Windows 2000 VER_PLATFORM_WIN32_NT 5 0 // Windows 2000 VER_PLATFORM_WIN32_NT 5 0
// Windows XP VER_PLATFORM_WIN32_NT 5 1 // Windows XP VER_PLATFORM_WIN32_NT 5 1
// Windows Vista VER_PLATFORM_WIN32_NT 6 0 // 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 95 VER_PLATFORM_WIN32_WINDOWS 4 0
// Windows 98 VER_PLATFORM_WIN32_WINDOWS 4 10 // Windows 98 VER_PLATFORM_WIN32_WINDOWS 4 10
// Windows ME VER_PLATFORM_WIN32_WINDOWS 4 90 // Windows ME VER_PLATFORM_WIN32_WINDOWS 4 90
...@@ -94,25 +95,47 @@ bool SAL_CALL IsWindowsVersion(unsigned int PlatformId, unsigned int MajorVersio ...@@ -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() bool SAL_CALL IsWindowsXP()
...@@ -120,6 +143,15 @@ bool SAL_CALL IsWindowsXP() ...@@ -120,6 +143,15 @@ bool SAL_CALL IsWindowsXP()
return IsWindowsVersion(VER_PLATFORM_WIN32_NT, 5, 1); return IsWindowsVersion(VER_PLATFORM_WIN32_NT, 5, 1);
} }
//------------------------------------------------------------
// determine if we are running under Windows 2000
//------------------------------------------------------------
bool SAL_CALL IsWindows2000()
{
return IsWindowsVersion(VER_PLATFORM_WIN32_NT, 5, 0);
}
//------------------------------------------------------------ //------------------------------------------------------------
// //
//------------------------------------------------------------ //------------------------------------------------------------
......
...@@ -53,6 +53,8 @@ ...@@ -53,6 +53,8 @@
// deklarations // deklarations
//------------------------------------------------------------------------ //------------------------------------------------------------------------
bool SAL_CALL IsWindowsVistaOrNewer();
bool SAL_CALL IsWindows7();
bool SAL_CALL IsWindowsVista(); bool SAL_CALL IsWindowsVista();
bool SAL_CALL IsWindows2000(); bool SAL_CALL IsWindows2000();
bool SAL_CALL IsWindowsXP(); bool SAL_CALL IsWindowsXP();
......
...@@ -336,11 +336,21 @@ void ToolBarManager::Destroy() ...@@ -336,11 +336,21 @@ void ToolBarManager::Destroy()
delete static_cast< AddonsParams* >( m_pToolBar->GetItemData( nItemId )); 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 // #i93173# delete toolbar lazily as we can still be in one of its handlers
m_pToolBar->doLazyDelete(); 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; m_pToolBar = 0;
} }
......
...@@ -229,8 +229,16 @@ public: ...@@ -229,8 +229,16 @@ public:
void SetTitle( const String& rNewTitle ); void SetTitle( const String& rNewTitle );
String GetPath() const; 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; ::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 AddFilter( const String& rFilterName, const String& rExtension );
void SetCurrentFilter( const String& rFilter ); void SetCurrentFilter( const String& rFilter );
......
...@@ -1358,6 +1358,7 @@ sal_Int16 FileDialogHelper_Impl::implDoExecute() ...@@ -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 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 //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. //primordial thread as the ucb gnome-vfs2 provider was initialized in.
/*
#ifdef WNT #ifdef WNT
if ( mbSystemPicker ) if ( mbSystemPicker )
{ {
...@@ -1371,9 +1372,18 @@ sal_Int16 FileDialogHelper_Impl::implDoExecute() ...@@ -1371,9 +1372,18 @@ sal_Int16 FileDialogHelper_Impl::implDoExecute()
} }
else else
#endif #endif
*/
{ {
try try
{ {
#ifdef WNT
if ( mbSystemPicker )
{
OReleaseSolarMutex aSolarMutex;
nRet = mxFileDlg->execute();
}
else
#endif
nRet = mxFileDlg->execute(); nRet = mxFileDlg->execute();
} }
catch( const Exception& ) catch( const Exception& )
...@@ -2581,6 +2591,46 @@ Sequence < OUString > FileDialogHelper::GetMPath() const ...@@ -2581,6 +2591,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 String FileDialogHelper::GetDisplayDirectory() const
{ {
......
...@@ -177,33 +177,17 @@ void impl_FillURLList( sfx2::FileDialogHelper* _pFileDlg, SvStringsDtor*& _rpURL ...@@ -177,33 +177,17 @@ void impl_FillURLList( sfx2::FileDialogHelper* _pFileDlg, SvStringsDtor*& _rpURL
{ {
DBG_ASSERT( _pFileDlg, "DocumentInserter::fillURLList(): invalid file dialog" ); DBG_ASSERT( _pFileDlg, "DocumentInserter::fillURLList(): invalid file dialog" );
DBG_ASSERT( !_rpURLList, "DocumentInserter::fillURLList(): URLList already exists" ); DBG_ASSERT( !_rpURLList, "DocumentInserter::fillURLList(): URLList already exists" );
Sequence < ::rtl::OUString > aPathSeq = _pFileDlg->GetMPath(); Sequence < ::rtl::OUString > aPathSeq = _pFileDlg->GetSelectedFiles();
if ( aPathSeq.getLength() ) if ( aPathSeq.getLength() )
{ {
_rpURLList = new SvStringsDtor; _rpURLList = new SvStringsDtor;
if ( aPathSeq.getLength() == 1 ) for ( USHORT i = 0; i < aPathSeq.getLength(); ++i )
{ {
::rtl::OUString sFileURL( aPathSeq[0] ); INetURLObject aPathObj( aPathSeq[i] );
String* pURL = new String( sFileURL ); String* pURL = new String( aPathObj.GetMainURL( INetURLObject::NO_DECODE ) );
_rpURLList->Insert( pURL, 0 ); _rpURLList->Insert( pURL, _rpURLList->Count() );
}
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() );
}
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment