fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx | 21 ++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)
New commits: commit b2fdea0bcb3b5edb824c8d725f7f37521ff890ef Author: Mike Kaganski <[email protected]> AuthorDate: Thu Dec 6 01:32:35 2018 +0300 Commit: Ilhan Yesil <[email protected]> CommitDate: Wed Jan 23 10:32:30 2019 +0100 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. Reviewed-on: https://gerrit.libreoffice.org/64656 Tested-by: Jenkins Reviewed-by: Katarina Behrens <[email protected]> Reviewed-by: Thorsten Behrens <[email protected]> Reviewed-by: Mike Kaganski <[email protected]> (cherry picked from commit f553e34aff94fd9bce9cce77e0a723021be7c38a) Change-Id: Iee5f09acd6b12c0ba8b7568b16f8ab07821006ee Reviewed-on: https://gerrit.libreoffice.org/66777 Reviewed-by: Ilhan Yesil <[email protected]> Tested-by: Ilhan Yesil <[email protected]> diff --git a/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx b/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx index 26d237491655..418a968d431f 100644 --- a/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx +++ b/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx @@ -127,8 +127,16 @@ OUString lcl_getURLFromShellItem (IShellItem* pItem) 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; +} -::std::vector< COMDLG_FILTERSPEC > lcl_buildFilterList(CFilterContainer& rContainer) +::std::vector< COMDLG_FILTERSPEC > lcl_buildFilterList(CFilterContainer& rContainer, + std::vector<OUString>& rvStrings) { ::std::vector< COMDLG_FILTERSPEC > lList ; CFilterContainer::FILTER_ENTRY_T aFilter; @@ -138,7 +146,8 @@ OUString lcl_getURLFromShellItem (IShellItem* pItem) { COMDLG_FILTERSPEC aSpec; - aSpec.pszName = reinterpret_cast<LPCTSTR>(aFilter.first.getStr()) ; + rvStrings.push_back(lcl_AdjustFilterName(aFilter.first)); // to avoid dangling pointer + aSpec.pszName = reinterpret_cast<LPCTSTR>(rvStrings.back().getStr()) ; aSpec.pszSpec = reinterpret_cast<LPCTSTR>(aFilter.second.getStr()); lList.push_back(aSpec); @@ -788,7 +797,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(); @@ -945,7 +956,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() ) { LPCWSTR lpFilterExt = lFilters[nRealIndex].pszSpec; _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
