[Libreoffice-commits] core.git: Branch 'libreoffice-6-2' - fpicker/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Dec 10 10:54:42 UTC 2018


 fpicker/source/win32/VistaFilePickerImpl.cxx |   22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

New commits:
commit 414246683899928014ea11ec07caebdfdf8aaee4
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Thu Dec 6 01:32:35 2018 +0300
Commit:     Katarina Behrens <Katarina.Behrens at cib.de>
CommitDate: Mon Dec 10 11:54:22 2018 +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.
    
    Change-Id: Iee5f09acd6b12c0ba8b7568b16f8ab07821006ee
    Reviewed-on: https://gerrit.libreoffice.org/64656
    Tested-by: Jenkins
    Reviewed-by: Katarina Behrens <Katarina.Behrens at cib.de>
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/64840

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;


More information about the Libreoffice-commits mailing list