diff options
-rw-r--r-- | fpicker/source/win32/VistaFilePickerImpl.cxx | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/fpicker/source/win32/VistaFilePickerImpl.cxx b/fpicker/source/win32/VistaFilePickerImpl.cxx index ff0cf2c27956..6c168a244fa0 100644 --- a/fpicker/source/win32/VistaFilePickerImpl.cxx +++ b/fpicker/source/win32/VistaFilePickerImpl.cxx @@ -147,8 +147,17 @@ bailout: return sURL; } +// Vista file picker shows the filter mask next to filter name in the list; so we need to remove the +// mask from the filter name to avoid duplicating masks +static OUString lcl_AdjustFilterName(const OUString& sName) +{ + const sal_Int32 idx = sName.indexOf("(."); + return (idx > 0) ? sName.copy(0, idx).trim() : sName; +} -static ::std::vector< COMDLG_FILTERSPEC > lcl_buildFilterList(CFilterContainer& rContainer) +// rvStrings holds the OUStrings, pointers to which data are stored in returned COMDLG_FILTERSPEC +static ::std::vector<COMDLG_FILTERSPEC> lcl_buildFilterList(CFilterContainer& rContainer, + std::vector<OUString>& rvStrings) { ::std::vector< COMDLG_FILTERSPEC > lList ; CFilterContainer::FILTER_ENTRY_T aFilter; @@ -158,7 +167,8 @@ static ::std::vector< COMDLG_FILTERSPEC > lcl_buildFilterList(CFilterContainer& { COMDLG_FILTERSPEC aSpec; - aSpec.pszName = o3tl::toW(aFilter.first.getStr()) ; + rvStrings.push_back(lcl_AdjustFilterName(aFilter.first)); // to avoid dangling pointer + aSpec.pszName = o3tl::toW(rvStrings.back().getStr()); aSpec.pszSpec = o3tl::toW(aFilter.second.getStr()); lList.push_back(aSpec); @@ -824,7 +834,9 @@ void VistaFilePickerImpl::impl_sta_setFiltersOnDialog() // SYNCHRONIZED-> ::osl::ResettableMutexGuard aLock(m_aMutex); - ::std::vector< COMDLG_FILTERSPEC > lFilters = lcl_buildFilterList(m_lFilters); + std::vector<OUString> vStrings; // to hold the adjusted filter names, pointers to which will be + // stored in lFilters + ::std::vector< COMDLG_FILTERSPEC > lFilters = lcl_buildFilterList(m_lFilters, vStrings); OUString sCurrentFilter = m_lFilters.getCurrentFilter(); sal_Int32 nCurrentFilter = m_lFilters.getFilterPos(sCurrentFilter); TFileDialog iDialog = impl_getBaseDialogInterface(); @@ -991,7 +1003,9 @@ void VistaFilePickerImpl::impl_sta_ShowDialogModal(const RequestRef& rRequest) { // COM dialog base on 1 ... filter container on 0 .-) ::size_t nRealIndex = (nFileType-1); - ::std::vector< COMDLG_FILTERSPEC > lFilters = lcl_buildFilterList(m_lFilters); + std::vector<OUString> vStrings; + ::std::vector<COMDLG_FILTERSPEC> lFilters + = lcl_buildFilterList(m_lFilters, vStrings); if ( nRealIndex < lFilters.size() ) { PCWSTR lpFilterExt = lFilters[nRealIndex].pszSpec; |