diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2018-12-06 01:32:35 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2018-12-06 13:50:42 +0100 |
commit | f553e34aff94fd9bce9cce77e0a723021be7c38a (patch) | |
tree | a2650cc49ba163e0f1bf503742cf5b0b33d4d684 /fpicker/source/win32 | |
parent | 38a47bc3a4f618da4613968d28c08c8dda064cea (diff) |
tdf#119747 FileSaveDialog: remove duplicate extension on Windows
This properly reimplements the fix, only changing the display strings
sent to native dialog, and never modifying the filter names as seen
by LibreOffice code.
Change-Id: Iee5f09acd6b12c0ba8b7568b16f8ab07821006ee
Reviewed-on: https://gerrit.libreoffice.org/64656
Tested-by: Jenkins
Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'fpicker/source/win32')
-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; |