diff options
author | Vladimir Glazounov <vg@openoffice.org> | 2006-11-22 09:55:55 +0000 |
---|---|---|
committer | Vladimir Glazounov <vg@openoffice.org> | 2006-11-22 09:55:55 +0000 |
commit | 0a8d1ab2b2914966a4fcf2ec378058f1d73fcfbd (patch) | |
tree | a2a79645b75eb29509848a4fa9a2b5774ad2bd68 /sfx2/source | |
parent | a99ee757f0b8a7b8c444a1cc2e088c56191329cd (diff) |
INTEGRATION: CWS asyncdialogs (1.41.110); FILE MERGED
2006/11/21 15:28:51 pb 1.41.110.9: RESYNC: (1.49-1.52); FILE MERGED
2006/10/31 17:55:46 pb 1.41.110.8: RESYNC: (1.47-1.49); FILE MERGED
2006/09/20 20:26:54 pb 1.41.110.7: RESYNC: (1.46-1.47); FILE MERGED
2006/07/12 20:48:37 pb 1.41.110.6: RESYNC: (1.45-1.46); FILE MERGED
2006/05/31 14:39:05 pb 1.41.110.5: RESYNC: (1.44-1.45); FILE MERGED
2006/03/22 11:43:28 pb 1.41.110.4: RESYNC: (1.43-1.44); FILE MERGED
2006/02/14 08:13:29 pb 1.41.110.3: RESYNC: (1.42-1.43); FILE MERGED
2005/12/08 08:23:58 kso 1.41.110.2: RESYNC: (1.41-1.42); FILE MERGED
2005/11/11 10:11:40 pb 1.41.110.1: fix: #i57125# asynchronous execute of file dialog
Diffstat (limited to 'sfx2/source')
-rw-r--r-- | sfx2/source/appl/shutdownicon.cxx | 275 |
1 files changed, 157 insertions, 118 deletions
diff --git a/sfx2/source/appl/shutdownicon.cxx b/sfx2/source/appl/shutdownicon.cxx index 588ece3a616a..79ef3d3d83b1 100644 --- a/sfx2/source/appl/shutdownicon.cxx +++ b/sfx2/source/appl/shutdownicon.cxx @@ -4,9 +4,9 @@ * * $RCSfile: shutdownicon.cxx,v $ * - * $Revision: 1.52 $ + * $Revision: 1.53 $ * - * last change: $Author: rt $ $Date: 2006-11-09 09:59:40 $ + * last change: $Author: vg $ $Date: 2006-11-22 10:55:55 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -114,10 +114,11 @@ #ifndef _UTL_BOOTSTRAP_HXX #include <unotools/bootstrap.hxx> #endif - +#include <tools/link.hxx> #ifdef UNX // need symlink #include <unistd.h> #endif + #include "sfxresid.hxx" using namespace ::com::sun::star::uno; @@ -152,7 +153,7 @@ SFX_IMPL_XSERVICEINFO( ShutdownIcon, "com.sun.star.office.Quickstart", "com.sun. SFX_IMPL_ONEINSTANCEFACTORY( ShutdownIcon ); bool ShutdownIcon::bModalMode = false; -ShutdownIcon* ShutdownIcon::pShutdownIcon = 0; +ShutdownIcon* ShutdownIcon::pShutdownIcon = NULL; // To remove conditionals extern "C" { @@ -245,7 +246,7 @@ void ShutdownIcon::deInitSystray() if (!m_bInitialized) return; if (m_pDeInitSystray) - m_pDeInitSystray(); + m_pDeInitSystray(); m_bVeto = false; m_pInitSystray = 0; @@ -253,6 +254,8 @@ void ShutdownIcon::deInitSystray() if (m_pPlugin) delete m_pPlugin; m_pPlugin = 0; + delete m_pFileDlg; + m_pFileDlg = NULL; m_bInitialized = false; } @@ -260,7 +263,8 @@ void ShutdownIcon::deInitSystray() ShutdownIcon::ShutdownIcon( Reference< XMultiServiceFactory > aSMgr ) : ShutdownIconServiceBase( m_aMutex ), m_bVeto ( false ), - m_pResMgr( 0 ), + m_pResMgr( NULL ), + m_pFileDlg( NULL ), m_xServiceManager( aSMgr ), m_pInitSystray( 0 ), m_pDeInitSystray( 0 ), @@ -320,118 +324,7 @@ void ShutdownIcon::FileOpen() { ::vos::OGuard aGuard( Application::GetSolarMutex() ); EnterModalMode(); - // use ctor for filling up filters automatically! #89169# - FileDialogHelper dlg( WB_OPEN | SFXWB_MULTISELECTION, String() ); - if ( ERRCODE_NONE == dlg.Execute() ) - { - Reference< XFilePicker > xPicker = dlg.GetFilePicker(); - - try - { - - if ( xPicker.is() ) - { - - Reference < XFilePickerControlAccess > xPickerControls ( xPicker, UNO_QUERY ); - Reference < XFilterManager > xFilterManager ( xPicker, UNO_QUERY ); - - Sequence< OUString > sFiles = xPicker->getFiles(); - int nFiles = sFiles.getLength(); - - int nArgs=0; - Sequence< PropertyValue > aArgs; - - // No default arguments anymore as they are provided by the dispatch - // provider automatically. - - // pb: #102643# use the filedlghelper to get the current filter name, - // because it removes the extensions before you get the filter name. - OUString aFilterName( dlg.GetCurrentFilter() ); - - if ( xPickerControls.is() ) - { - - // Set readonly flag - - sal_Bool bReadOnly = sal_False; - - - xPickerControls->getValue( ExtendedFilePickerElementIds::CHECKBOX_READONLY, 0 ) >>= bReadOnly; - - // #95239#: Only set porperty if readonly is set to TRUE - - if ( bReadOnly ) - { - aArgs.realloc( ++nArgs ); - aArgs[nArgs-1].Name = OUString::createFromAscii( "ReadOnly" ); - aArgs[nArgs-1].Value <<= bReadOnly; - } - - // Get version string - - sal_Int32 iVersion = -1; - - xPickerControls->getValue( ExtendedFilePickerElementIds::LISTBOX_VERSION, ControlActions::GET_SELECTED_ITEM_INDEX ) >>= iVersion; - - if ( iVersion >= 0 ) - { - sal_Int16 uVersion = (sal_Int16)iVersion; - - aArgs.realloc( ++nArgs ); - aArgs[nArgs-1].Name = OUString::createFromAscii( "Version" ); - aArgs[nArgs-1].Value <<= uVersion; - } - - // Retrieve the current filter - - if ( !aFilterName.getLength() ) - xPickerControls->getValue( CommonFilePickerElementIds::LISTBOX_FILTER, ControlActions::GET_SELECTED_ITEM ) >>= aFilterName; - - } - - - // Convert UI filter name to internal filter name - - if ( aFilterName.getLength() ) - { - const SfxFilter* pFilter = SFX_APP()->GetFilterMatcher().GetFilter4UIName( aFilterName, 0, SFX_FILTER_NOTINFILEDLG ); - - if ( pFilter ) - { - aFilterName = pFilter->GetFilterName(); - - if ( aFilterName.getLength() ) - { - aArgs.realloc( ++nArgs ); - aArgs[nArgs-1].Name = OUString::createFromAscii( "FilterName" ); - aArgs[nArgs-1].Value <<= aFilterName; - } - } - } - - if ( 1 == nFiles ) - OpenURL( sFiles[0], OUString( RTL_CONSTASCII_USTRINGPARAM( "_default" ) ), aArgs ); - else - { - OUString aBaseDirURL = sFiles[0]; - if ( aBaseDirURL.getLength() > 0 && aBaseDirURL[aBaseDirURL.getLength()-1] != '/' ) - aBaseDirURL += OUString::createFromAscii("/"); - - int iFiles; - for ( iFiles = 1; iFiles < nFiles; iFiles++ ) - { - OUString aURL = aBaseDirURL; - aURL += sFiles[iFiles]; - OpenURL( aURL, OUString( RTL_CONSTASCII_USTRINGPARAM( "_default" ) ), aArgs ); - } - } - } - } - catch ( ... ) - { - } - } - LeaveModalMode(); + getInstance()->StartFileDialog(); } } @@ -504,6 +397,152 @@ OUString ShutdownIcon::GetUrlDescription( const OUString& aUrl ) // --------------------------------------------------------------------------- +void ShutdownIcon::StartFileDialog() +{ + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + + if ( !m_pFileDlg ) + m_pFileDlg = new FileDialogHelper( WB_OPEN | SFXWB_MULTISELECTION, String() ); + m_pFileDlg->StartExecuteModal( STATIC_LINK( this, ShutdownIcon, DialogClosedHdl_Impl ) ); +} + +// --------------------------------------------------------------------------- + +IMPL_STATIC_LINK( ShutdownIcon, DialogClosedHdl_Impl, FileDialogHelper*, EMPTYARG ) +{ + DBG_ASSERT( pThis->m_pFileDlg, "ShutdownIcon, DialogClosedHdl_Impl(): no file dialog" ); + + // use ctor for filling up filters automatically! #89169# + if ( ERRCODE_NONE == pThis->m_pFileDlg->GetError() ) + { + Reference< XFilePicker > xPicker = pThis->m_pFileDlg->GetFilePicker(); + + try + { + + if ( xPicker.is() ) + { + + Reference < XFilePickerControlAccess > xPickerControls ( xPicker, UNO_QUERY ); + Reference < XFilterManager > xFilterManager ( xPicker, UNO_QUERY ); + + Sequence< OUString > sFiles = xPicker->getFiles(); + int nFiles = sFiles.getLength(); + + int nArgs=3; + Sequence< PropertyValue > aArgs(3); + + Reference < com::sun::star::task::XInteractionHandler > xInteraction( + ::comphelper::getProcessServiceFactory()->createInstance( OUString::createFromAscii("com.sun.star.task.InteractionHandler") ), + com::sun::star::uno::UNO_QUERY ); + + aArgs[0].Name = OUString::createFromAscii( "InteractionHandler" ); + aArgs[0].Value <<= xInteraction; + + sal_Int16 nMacroExecMode = ::com::sun::star::document::MacroExecMode::USE_CONFIG; + aArgs[1].Name = OUString::createFromAscii( "MacroExecutionMode" ); + aArgs[1].Value <<= nMacroExecMode; + + sal_Int16 nUpdateDoc = ::com::sun::star::document::UpdateDocMode::ACCORDING_TO_CONFIG; + aArgs[2].Name = OUString::createFromAscii( "UpdateDocMode" ); + aArgs[2].Value <<= nUpdateDoc; + + // pb: #102643# use the filedlghelper to get the current filter name, + // because it removes the extensions before you get the filter name. + OUString aFilterName( pThis->m_pFileDlg->GetCurrentFilter() ); + + if ( xPickerControls.is() ) + { + + // Set readonly flag + + sal_Bool bReadOnly = sal_False; + + + xPickerControls->getValue( ExtendedFilePickerElementIds::CHECKBOX_READONLY, 0 ) >>= bReadOnly; + + // #95239#: Only set porperty if readonly is set to TRUE + + if ( bReadOnly ) + { + aArgs.realloc( ++nArgs ); + aArgs[nArgs-1].Name = OUString::createFromAscii( "ReadOnly" ); + aArgs[nArgs-1].Value <<= bReadOnly; + } + + // Get version string + + sal_Int32 iVersion = -1; + + xPickerControls->getValue( ExtendedFilePickerElementIds::LISTBOX_VERSION, ControlActions::GET_SELECTED_ITEM_INDEX ) >>= iVersion; + + if ( iVersion >= 0 ) + { + sal_Int16 uVersion = (sal_Int16)iVersion; + + aArgs.realloc( ++nArgs ); + aArgs[nArgs-1].Name = OUString::createFromAscii( "Version" ); + aArgs[nArgs-1].Value <<= uVersion; + } + + // Retrieve the current filter + + if ( !aFilterName.getLength() ) + xPickerControls->getValue( CommonFilePickerElementIds::LISTBOX_FILTER, ControlActions::GET_SELECTED_ITEM ) >>= aFilterName; + + } + + + // Convert UI filter name to internal filter name + + if ( aFilterName.getLength() ) + { + const SfxFilter* pFilter = SFX_APP()->GetFilterMatcher().GetFilter4UIName( aFilterName, 0, SFX_FILTER_NOTINFILEDLG ); + + if ( pFilter ) + { + aFilterName = pFilter->GetFilterName(); + + if ( aFilterName.getLength() ) + { + aArgs.realloc( ++nArgs ); + aArgs[nArgs-1].Name = OUString::createFromAscii( "FilterName" ); + aArgs[nArgs-1].Value <<= aFilterName; + } + } + } + + if ( 1 == nFiles ) + OpenURL( sFiles[0], OUString( RTL_CONSTASCII_USTRINGPARAM( "_default" ) ), aArgs ); + else + { + OUString aBaseDirURL = sFiles[0]; + if ( aBaseDirURL.getLength() > 0 && aBaseDirURL[aBaseDirURL.getLength()-1] != '/' ) + aBaseDirURL += OUString::createFromAscii("/"); + + int iFiles; + for ( iFiles = 1; iFiles < nFiles; iFiles++ ) + { + OUString aURL = aBaseDirURL; + aURL += sFiles[iFiles]; + OpenURL( aURL, OUString( RTL_CONSTASCII_USTRINGPARAM( "_default" ) ), aArgs ); + } + } + } + } + catch ( ... ) + { + } + } + +#ifdef WNT + LeaveModalMode(); +#endif + return 0; +} + +// --------------------------------------------------------------------------- + void ShutdownIcon::addTerminateListener() { if ( getInstance() && getInstance()->m_xDesktop.is() ) |