You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
libreoffice/0001-rhbz-980387-fix-filter...

64 lines
2.2 KiB

From 70376f610a7eb876739829e1f362bc94b21cb82f Mon Sep 17 00:00:00 2001
From: David Tardon <dtardon@redhat.com>
Date: Thu, 11 Jul 2013 09:25:16 +0200
Subject: [PATCH] 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
---
vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx b/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx
index 389e3f3..d237b86 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();
--
1.8.3.1