diff options
author | David Tardon <dtardon@redhat.com> | 2013-07-11 09:25:16 +0200 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2013-07-11 09:29:49 +0200 |
commit | 70376f610a7eb876739829e1f362bc94b21cb82f (patch) | |
tree | 13a9d6ee3fa3f421b104e4272ede34f3888ca80c | |
parent | 9dfb46ae335c46bdf4b2e9df52cc443519230705 (diff) |
rhbz#980387 fix filter selection from file ext.
... for filters that have more than one extension associated with them
(e.g., JPEG).
Change-Id: Ic6b16d3b4aa17580404d02a9fb7b087b9aa52fc2
-rw-r--r-- | vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx b/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx index 389e3f3f952e..d237b8628a93 100644 --- a/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx +++ b/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx @@ -36,6 +36,7 @@ #include <com/sun/star/ui/dialogs/TemplateDescription.hpp> #include <com/sun/star/ui/dialogs/ControlActions.hpp> #include <com/sun/star/uno/Any.hxx> +#include <comphelper/string.hxx> #include <osl/mutex.hxx> #include "unx/gtk/gtkinst.hxx" @@ -790,6 +791,25 @@ uno::Sequence<OUString> SAL_CALL SalGtkFilePicker::getFiles() throw( uno::Runtim return aFiles; } +namespace +{ + +bool lcl_matchFilter( const rtl::OUString& rFilter, const rtl::OUString& rExt ) +{ + const int nCount = comphelper::string::getTokenCount( rFilter, ';' ); + + for ( int n = 0; n != nCount; ++n ) + { + const rtl::OUString aToken = comphelper::string::getToken( rFilter, n, ';' ); + if ( aToken == rExt ) + return true; + } + + return false; +} + +} + uno::Sequence<OUString> SAL_CALL SalGtkFilePicker::getSelectedFiles() throw( uno::RuntimeException ) { SolarMutexGuard g; @@ -852,7 +872,7 @@ uno::Sequence<OUString> SAL_CALL SalGtkFilePicker::getSelectedFiles() throw( uno ++aListIter ) { - if( aListIter->getFilter().equalsIgnoreAsciiCase( aStarDot+sExtension ) ) + if( lcl_matchFilter( aListIter->getFilter(), aStarDot+sExtension ) ) { if( aNewFilter.isEmpty() ) aNewFilter = aListIter->getTitle(); |