cui/source/options/optsave.cxx |   24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

New commits:
commit ccd8f402a79cbb43aa5bae7a11d3fcae92971c75
Author: Gian Domenico Ceccarini <gdceccar...@gmail.com>
Date:   Mon May 29 12:42:20 2017 +0200

    tdf#36747 Add extension in Tools > Options > Load / Save > General
    
    This commit take care about adding extension and not the order of the 
filters.
    
    Change-Id: Id776da2c2407037628007001af0a35e992791b1d
    Reviewed-on: https://gerrit.libreoffice.org/38134
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk>

diff --git a/cui/source/options/optsave.cxx b/cui/source/options/optsave.cxx
index a64a998a17a1..52a8d3893c29 100644
--- a/cui/source/options/optsave.cxx
+++ b/cui/source/options/optsave.cxx
@@ -42,6 +42,7 @@
 #include <unotools/optionsdlg.hxx>
 
 #include <vcl/msgbox.hxx>
+#include <sfx2/fcontnr.hxx>
 
 using namespace com::sun::star::uno;
 using namespace com::sun::star::util;
@@ -528,7 +529,7 @@ IMPL_LINK( SvxSaveTabPage, AutoClickHdl_Impl, Button*, 
pBox, void )
     }
 }
 
-static OUString lcl_ExtracUIName(const Sequence<PropertyValue> &rProperties)
+static OUString lcl_ExtracUIName(const Sequence<PropertyValue> &rProperties, 
const OUString& rExtension)
 {
     OUString sName;
     const PropertyValue* pPropVal = rProperties.getConstArray();
@@ -540,7 +541,16 @@ static OUString lcl_ExtracUIName(const 
Sequence<PropertyValue> &rProperties)
         {
             OUString sUIName;
             if ( ( pPropVal->Value >>= sUIName ) && sUIName.getLength() )
-                return sUIName;
+            {
+                if (!rExtension.isEmpty())
+                {
+                    return sUIName + " (" + rExtension + ")";
+                }
+                else
+                {
+                    return sUIName;
+                }
+            }
         }
         else if (rName == "Name")
         {
@@ -574,9 +584,17 @@ IMPL_LINK( SvxSaveTabPage, FilterHdl_Impl, ListBox&, rBox, 
void )
                 for(int nFilter = 0; nFilter < 
pImpl->aFilterArr[nData].getLength(); nFilter++)
                 {
                     Any aProps = pImpl->xFact->getByName(pFilters[nFilter]);
+                    // get the extension of the filter
+                    OUString extension;
+                    SfxFilterMatcher matcher;
+                    std::shared_ptr<const SfxFilter> pFilter = 
matcher.GetFilter4FilterName(pFilters[nFilter]);
+                    if (pFilter)
+                    {
+                        extension = 
pFilter->GetWildcard().getGlob().getToken(0, ';');
+                    }
                     Sequence<PropertyValue> aProperties;
                     aProps >>= aProperties;
-                    pUIFilters[nFilter] = lcl_ExtracUIName(aProperties);
+                    pUIFilters[nFilter] = lcl_ExtracUIName(aProperties, 
extension);
                 }
             }
             const OUString* pUIFilters = 
pImpl->aUIFilterArr[nData].getConstArray();
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to