diff options
Diffstat (limited to 'fpicker')
8 files changed, 107 insertions, 64 deletions
diff --git a/fpicker/source/win32/filepicker/IVistaFilePickerInternalNotify.hxx b/fpicker/source/win32/filepicker/IVistaFilePickerInternalNotify.hxx index a03e6f3fe23c..2414a6ff1229 100644 --- a/fpicker/source/win32/filepicker/IVistaFilePickerInternalNotify.hxx +++ b/fpicker/source/win32/filepicker/IVistaFilePickerInternalNotify.hxx @@ -67,6 +67,8 @@ class IVistaFilePickerInternalNotify public: virtual void onAutoExtensionChanged (bool bChecked) = 0; + + virtual bool onFileTypeChanged( UINT nTypeIndex ) = 0; }; }}} diff --git a/fpicker/source/win32/filepicker/VistaFilePicker.cxx b/fpicker/source/win32/filepicker/VistaFilePicker.cxx index 83b040f7edff..edb40f2e099b 100644 --- a/fpicker/source/win32/filepicker/VistaFilePicker.cxx +++ b/fpicker/source/win32/filepicker/VistaFilePicker.cxx @@ -225,7 +225,7 @@ void SAL_CALL VistaFilePicker::setTitle(const ::rtl::OUString& sTitle) //----------------------------------------------------------------------------------------- void SAL_CALL VistaFilePicker::appendFilter(const ::rtl::OUString& sTitle , - const ::rtl::OUString& sFilter) + const ::rtl::OUString& sFilter) throw(css::lang::IllegalArgumentException, css::uno::RuntimeException ) { @@ -264,17 +264,15 @@ void SAL_CALL VistaFilePicker::setCurrentFilter(const ::rtl::OUString& sTitle) //----------------------------------------------------------------------------------------- void SAL_CALL VistaFilePicker::appendFilterGroup(const ::rtl::OUString& /*sGroupTitle*/, - const css::uno::Sequence< css::beans::StringPair >& lFilters ) + const css::uno::Sequence< css::beans::StringPair >& rFilters ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException ) { - ::sal_Int32 c = lFilters.getLength(); - ::sal_Int32 i = 0; - for (i=0; i<c; ++i) - { - const css::beans::StringPair& rFilter = lFilters[i]; - appendFilter(rFilter.First, rFilter.Second); - } + RequestRef rRequest(new Request()); + rRequest->setRequest (VistaFilePickerImpl::E_APPEND_FILTERGROUP); + rRequest->setArgument(PROP_FILTER_GROUP, rFilters); + + m_aAsyncExecute.triggerRequestThreadAware(rRequest, AsyncRequests::NON_BLOCKED); } //----------------------------------------------------------------------------------------- diff --git a/fpicker/source/win32/filepicker/VistaFilePickerEventHandler.cxx b/fpicker/source/win32/filepicker/VistaFilePickerEventHandler.cxx index 541d1a166687..a0aa8ad0b8cf 100644 --- a/fpicker/source/win32/filepicker/VistaFilePickerEventHandler.cxx +++ b/fpicker/source/win32/filepicker/VistaFilePickerEventHandler.cxx @@ -264,33 +264,16 @@ STDMETHODIMP VistaFilePickerEventHandler::OnShareViolation(IFileDialog* } //----------------------------------------------------------------------------------------- -STDMETHODIMP VistaFilePickerEventHandler::OnTypeChange(IFileDialog* /*pDialog*/) +STDMETHODIMP VistaFilePickerEventHandler::OnTypeChange(IFileDialog* pDialog) { - /* - IFileDialogCustomize *iCustomize; - pDialog->QueryInterface(IID_IFileDialogCustomize, (void**)(&iCustomize)); + UINT nFileTypeIndex; + HRESULT hResult = pDialog->GetFileTypeIndex( &nFileTypeIndex ); - BOOL bValue = FALSE; - HRESULT hResult = iCustomize->GetCheckButtonState( css::ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, &bValue); - - if ( bValue ) + if ( hResult == S_OK ) { - UINT nIndex; - - pDialog->GetFileTypeIndex( &nIndex ); - - LPCWSTR lpFilterExt = lFilters[nIndex].pszSpec; - - lpFilterExt = wcschr( lpFilterExt, '.' ); - if ( lpFilterExt ) - lpFilterExt++; - pDialog->SetDefaultExtension( lpFilterExt ); + if ( m_pInternalNotify->onFileTypeChanged( nFileTypeIndex )) + impl_sendEvent(E_CONTROL_STATE_CHANGED, css::ui::dialogs::CommonFilePickerElementIds::LISTBOX_FILTER); } - return S_OK; - - */ - - impl_sendEvent(E_CONTROL_STATE_CHANGED, css::ui::dialogs::CommonFilePickerElementIds::LISTBOX_FILTER); return S_OK; } @@ -329,32 +312,9 @@ STDMETHODIMP VistaFilePickerEventHandler::OnCheckButtonToggled(IFileDialogCustom DWORD nIDCtl , BOOL bChecked ) { - /* - if (nIDCtl == css::ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION) - { - LPCWSTR lpFilterExt = 0; - if ( bChecked ) - { - UINT nIndex; - if (m_pDialog) - { - m_pDialog->GetFileTypeIndex( &nIndex ); - lpFilterExt = lFilters[nIndex].pszSpec; - lpFilterExt = wcschr( lpFilterExt, '.' ); - if ( lpFilterExt ) - lpFilterExt++; - } - } - - if (m_pDialog) - m_pDialog->SetDefaultExtension( lpFilterExt ); - } - */ - if (nIDCtl == css::ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION) m_pInternalNotify->onAutoExtensionChanged(bChecked); - impl_sendEvent(E_CONTROL_STATE_CHANGED, static_cast<sal_Int16>( nIDCtl)); return S_OK; diff --git a/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx b/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx index 1c48976a9951..6cc0d522b920 100644 --- a/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx +++ b/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx @@ -35,6 +35,7 @@ #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> #include <com/sun/star/ui/dialogs/ControlActions.hpp> #include <com/sun/star/ui/dialogs/TemplateDescription.hpp> +#include <com/sun/star/beans/StringPair.hpp> #include <comphelper/sequenceasvector.hxx> #include <osl/file.hxx> #include <osl/mutex.hxx> @@ -43,6 +44,8 @@ #endif #include "..\misc\WinImplHelper.hxx" +#include <Shlguid.h> + inline bool is_current_process_window(HWND hwnd) { DWORD pid; @@ -200,6 +203,10 @@ void VistaFilePickerImpl::doRequest(const RequestRef& rRequest) impl_sta_appendFilter(rRequest); break; + case E_APPEND_FILTERGROUP : + impl_sta_appendFilterGroup(rRequest); + break; + case E_SET_CURRENT_FILTER : impl_sta_setCurrentFilter(rRequest); break; @@ -332,6 +339,28 @@ void VistaFilePickerImpl::impl_sta_appendFilter(const RequestRef& rRequest) } //------------------------------------------------------------------------------- +void VistaFilePickerImpl::impl_sta_appendFilterGroup(const RequestRef& rRequest) +{ + const css::uno::Sequence< css::beans::StringPair > aFilterGroup = + rRequest->getArgumentOrDefault(PROP_FILTER_GROUP, css::uno::Sequence< css::beans::StringPair >()); + + // SYNCHRONIZED-> + ::rtl::OUString aEmpty; + ::osl::ResettableMutexGuard aLock(m_aMutex); + + if ( m_lFilters.numFilter() > 0 && aFilterGroup.getLength() > 0 ) + m_lFilters.addFilter( STRING_SEPARATOR, aEmpty, sal_True ); + + ::sal_Int32 c = aFilterGroup.getLength(); + ::sal_Int32 i = 0; + for (i=0; i<c; ++i) + { + const css::beans::StringPair& rFilter = aFilterGroup[i]; + m_lFilters.addFilter(rFilter.First, rFilter.Second); + } +} + +//------------------------------------------------------------------------------- void VistaFilePickerImpl::impl_sta_setCurrentFilter(const RequestRef& rRequest) { const ::rtl::OUString sTitle = rRequest->getArgumentOrDefault(PROP_FILTER_TITLE, ::rtl::OUString()); @@ -942,7 +971,7 @@ void VistaFilePickerImpl::impl_sta_ShowDialogModal(const RequestRef& rRequest) return; impl_sta_getSelectedFiles(rRequest); - rRequest->setArgument(PROP_DIALOG_SHOW_RESULT, (::sal_Bool)sal_True); + rRequest->setArgument(PROP_DIALOG_SHOW_RESULT, sal_True); } //------------------------------------------------------------------------------- @@ -1180,6 +1209,23 @@ void VistaFilePickerImpl::impl_SetDefaultExtension( const rtl::OUString& current } } +static void impl_refreshFileDialog( TFileDialog iDialog ) +{ + if ( SUCCEEDED(iDialog->SetFileName(L"")) && + SUCCEEDED(iDialog->SetFileName(L"*.*")) ) + { + IOleWindow* iOleWindow; + if (SUCCEEDED(iDialog->QueryInterface(IID_PPV_ARGS(&iOleWindow)))) + { + HWND hwnd; + if (SUCCEEDED(iOleWindow->GetWindow(&hwnd))) + { + PostMessage(hwnd, WM_COMMAND, IDOK, 0); + } + iOleWindow->Release(); + } + } +} //------------------------------------------------------------------------------- void VistaFilePickerImpl::onAutoExtensionChanged (bool bChecked) @@ -1208,6 +1254,11 @@ void VistaFilePickerImpl::onAutoExtensionChanged (bool bChecked) iDialog->SetDefaultExtension( pExt ); } +bool VistaFilePickerImpl::onFileTypeChanged( UINT /*nTypeIndex*/ ) +{ + return true; +} + } // namespace vista } // namespace win32 } // namespace fpicker diff --git a/fpicker/source/win32/filepicker/VistaFilePickerImpl.hxx b/fpicker/source/win32/filepicker/VistaFilePickerImpl.hxx index 1149c9657f22..14bf9fd8bfe0 100644 --- a/fpicker/source/win32/filepicker/VistaFilePickerImpl.hxx +++ b/fpicker/source/win32/filepicker/VistaFilePickerImpl.hxx @@ -105,12 +105,14 @@ static const ::rtl::OUString PROP_TEMPLATE_DESCR(RTL_CONSTASCII_USTRINGPARAM("te static const ::rtl::OUString PROP_FILTER_TITLE(RTL_CONSTASCII_USTRINGPARAM("filter_title" )); // [OUString] static const ::rtl::OUString PROP_FILTER_VALUE(RTL_CONSTASCII_USTRINGPARAM("filter_value" )); // [OUString] static const ::rtl::OUString PROP_FORCE(RTL_CONSTASCII_USTRINGPARAM("force" )); // [sal_Bool] +static const ::rtl::OUString PROP_FILTER_GROUP(RTL_CONSTASCII_USTRINGPARAM("filter-group" )); // [seq< css:beans::StringPair >] contains a group of filters static const ::rtl::OUString PROP_CONTROL_ID(RTL_CONSTASCII_USTRINGPARAM("control_id" )); // [sal_Int16] static const ::rtl::OUString PROP_CONTROL_ACTION(RTL_CONSTASCII_USTRINGPARAM("control_action" )); // [sal_Int16] static const ::rtl::OUString PROP_CONTROL_VALUE(RTL_CONSTASCII_USTRINGPARAM("control_value" )); // [Any] static const ::rtl::OUString PROP_CONTROL_LABEL(RTL_CONSTASCII_USTRINGPARAM("control_label" )); // [OUString] static const ::rtl::OUString PROP_CONTROL_ENABLE(RTL_CONSTASCII_USTRINGPARAM("control_enable" )); // [sal_Bool] true=ON, false=OFF +static const ::rtl::OUString STRING_SEPARATOR(RTL_CONSTASCII_USTRINGPARAM("------------------------------------------" )); //----------------------------------------------------------------------------- /** native implementation of the file picker on Vista and upcoming windows versions. @@ -150,7 +152,8 @@ class VistaFilePickerImpl : private ::cppu::BaseMutex E_GET_CONTROL_VALUE, E_SET_CONTROL_LABEL, E_GET_CONTROL_LABEL, - E_ENABLE_CONTROL + E_ENABLE_CONTROL, + E_APPEND_FILTERGROUP }; public: @@ -170,7 +173,10 @@ class VistaFilePickerImpl : private ::cppu::BaseMutex virtual void after(); //--------------------------------------------------------------------- + // IVistaFilePickerInternalNotify + //--------------------------------------------------------------------- virtual void onAutoExtensionChanged (bool bChecked); + virtual bool onFileTypeChanged( UINT nTypeIndex ); private: @@ -187,6 +193,10 @@ class VistaFilePickerImpl : private ::cppu::BaseMutex void impl_sta_appendFilter(const RequestRef& rRequest); //--------------------------------------------------------------------- + /// implementation of request E_APPEND_FILTERGROUP + void impl_sta_appendFilterGroup(const RequestRef& rRequest); + + //--------------------------------------------------------------------- /// implementation of request E_SET_CURRENT_FILTER void impl_sta_setCurrentFilter(const RequestRef& rRequest); diff --git a/fpicker/source/win32/filepicker/WinFileOpenImpl.cxx b/fpicker/source/win32/filepicker/WinFileOpenImpl.cxx index 7b0db4a451d9..6d8423910949 100644 --- a/fpicker/source/win32/filepicker/WinFileOpenImpl.cxx +++ b/fpicker/source/win32/filepicker/WinFileOpenImpl.cxx @@ -315,11 +315,24 @@ void SAL_CALL CWinFileOpenImpl::appendFilterGroup(const rtl::OUString& sGroupTit // XExtendedFilePicker //================================================================================================================= +// #i90917: Due to a different feature set for the system-dependent file pickers +// it's possible that generic code (e.g. sfx2) provides control ids +// (see ExtendedFilePickerElementIds::LISTBOX_FILTER_SELECTOR) which are NOT +// available on all platforms. This filter function should filter out control ids +// which are only available on KDE/GTK file pickers. +static bool filterControlCommand( sal_Int16 nControlId ) +{ + if ( nControlId == LISTBOX_FILTER_SELECTOR ) + return true; + return false; +} + void SAL_CALL CWinFileOpenImpl::setValue(sal_Int16 aControlId, sal_Int16 aControlAction, const uno::Any& aValue) throw(uno::RuntimeException) { OSL_ASSERT(m_FilePickerState); - m_FilePickerState->setValue(aControlId, aControlAction, aValue); + if ( !filterControlCommand( aControlId )) + m_FilePickerState->setValue(aControlId, aControlAction, aValue); } //----------------------------------------------------------------------------------------- @@ -331,7 +344,10 @@ uno::Any SAL_CALL CWinFileOpenImpl::getValue(sal_Int16 aControlId, sal_Int16 aCo throw(uno::RuntimeException) { OSL_ASSERT(m_FilePickerState); - return m_FilePickerState->getValue(aControlId, aControlAction); + if ( !filterControlCommand( aControlId )) + return m_FilePickerState->getValue(aControlId, aControlAction); + else + return uno::Any(); } //----------------------------------------------------------------------------------------- @@ -342,7 +358,8 @@ void SAL_CALL CWinFileOpenImpl::enableControl(sal_Int16 ControlID, sal_Bool bEna throw(uno::RuntimeException) { OSL_ASSERT(m_FilePickerState); - m_FilePickerState->enableControl(ControlID, bEnable); + if ( !filterControlCommand( ControlID )) + m_FilePickerState->enableControl(ControlID, bEnable); } //----------------------------------------------------------------------------------------- @@ -352,7 +369,9 @@ void SAL_CALL CWinFileOpenImpl::enableControl(sal_Int16 ControlID, sal_Bool bEna void SAL_CALL CWinFileOpenImpl::setLabel( sal_Int16 aControlId, const rtl::OUString& aLabel ) throw (uno::RuntimeException) { - m_FilePickerState->setLabel(aControlId, aLabel); + OSL_ASSERT(m_FilePickerState); + if ( !filterControlCommand( aControlId )) + m_FilePickerState->setLabel(aControlId, aLabel); } //----------------------------------------------------------------------------------------- @@ -362,7 +381,11 @@ void SAL_CALL CWinFileOpenImpl::setLabel( sal_Int16 aControlId, const rtl::OUStr rtl::OUString SAL_CALL CWinFileOpenImpl::getLabel( sal_Int16 aControlId ) throw (uno::RuntimeException) { - return m_FilePickerState->getLabel(aControlId); + OSL_ASSERT(m_FilePickerState); + if ( !filterControlCommand( aControlId )) + return m_FilePickerState->getLabel(aControlId); + else + return rtl::OUString(); } //----------------------------------------------------------------------------------------- diff --git a/fpicker/source/win32/filepicker/platform_vista.h b/fpicker/source/win32/filepicker/platform_vista.h index c6fd8688bbd7..a17f817163cd 100644 --- a/fpicker/source/win32/filepicker/platform_vista.h +++ b/fpicker/source/win32/filepicker/platform_vista.h @@ -48,7 +48,6 @@ #pragma warning(pop) #endif - #if defined _M_IX86 #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") #elif defined _M_IA64 diff --git a/fpicker/source/win32/filepicker/previewadapter.cxx b/fpicker/source/win32/filepicker/previewadapter.cxx index 7f4ee5d05d79..994a8ee6538e 100644 --- a/fpicker/source/win32/filepicker/previewadapter.cxx +++ b/fpicker/source/win32/filepicker/previewadapter.cxx @@ -307,7 +307,7 @@ void SAL_CALL CPreviewAdapterImpl::rearrangeLayout() // style bit of the FileOpen dialog must be set after that // message LONG lStyle = GetWindowLong(prvwnd,GWL_STYLE); - sal_Bool bIsVisible = (sal_Bool)(lStyle & WS_VISIBLE); + bool bIsVisible = ((lStyle & WS_VISIBLE) != 0); int cx = 0; |