summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2016-09-23 22:10:29 +0100
committerMichael Meeks <michael.meeks@collabora.com>2016-09-24 10:36:32 +0000
commit3be5deadcb46e09d84d99b2b108b65b06ff356e9 (patch)
tree50606a8a2e26022992dff7f3c4dd51e339221a8f
parentc540ae79e0916479bc92b2659ff834adcad34041 (diff)
tdf#91043 - vcl: gtk file picker should tolerate empty filter list.
Apparently LibreLex creates a dialog through UNO and sets no filters. Change-Id: I518beef6f9c6ebab0d2e49bda78a33a283ad93d3 Reviewed-on: https://gerrit.libreoffice.org/29238 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
-rw-r--r--vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx88
1 files changed, 47 insertions, 41 deletions
diff --git a/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx b/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx
index 543195fcc3c8..26d6c74efe83 100644
--- a/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx
+++ b/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx
@@ -570,13 +570,16 @@ void SAL_CALL SalGtkFilePicker::setCurrentFilter( const OUString& aTitle )
void SalGtkFilePicker::updateCurrentFilterFromName(const gchar* filtername)
{
OUString aFilterName(filtername, strlen(filtername), RTL_TEXTENCODING_UTF8);
- FilterList::iterator aEnd = m_pFilterList->end();
- for (FilterList::iterator aIter = m_pFilterList->begin(); aIter != aEnd; ++aIter)
+ if (m_pFilterList)
{
- if (aFilterName == shrinkFilterName( aIter->getTitle()))
+ FilterList::iterator aEnd = m_pFilterList->end();
+ for (FilterList::iterator aIter = m_pFilterList->begin(); aIter != aEnd; ++aIter)
{
- m_aCurrentFilter = aIter->getTitle();
- break;
+ if (aFilterName == shrinkFilterName( aIter->getTitle()))
+ {
+ m_aCurrentFilter = aIter->getTitle();
+ break;
+ }
}
}
}
@@ -788,10 +791,11 @@ uno::Sequence<OUString> SAL_CALL SalGtkFilePicker::getSelectedFiles() throw( uno
OUString aNewFilter;
OUString aOldFilter = getCurrentFilter();
bool bChangeFilter = true;
- for ( FilterList::iterator aListIter = m_pFilterList->begin();
- aListIter != m_pFilterList->end();
- ++aListIter
- )
+ if ( m_pFilterList )
+ for ( FilterList::iterator aListIter = m_pFilterList->begin();
+ aListIter != m_pFilterList->end();
+ ++aListIter
+ )
{
if( lcl_matchFilter( aListIter->getFilter(), aStarDot+sExtension ) )
{
@@ -825,47 +829,49 @@ uno::Sequence<OUString> SAL_CALL SalGtkFilePicker::getSelectedFiles() throw( uno
OSL_TRACE( "2: current filter is %s\n",
OUStringToOString( sFilterName, RTL_TEXTENCODING_UTF8 ).getStr() );
- FilterList::iterator aListIter = ::std::find_if(
- m_pFilterList->begin(), m_pFilterList->end(), FilterTitleMatch(sFilterName) );
-
- OUString aFilter;
- if (aListIter != m_pFilterList->end())
- aFilter = aListIter->getFilter();
+ if (m_pFilterList)
+ {
+ FilterList::iterator aListIter = ::std::find_if(
+ m_pFilterList->begin(), m_pFilterList->end(), FilterTitleMatch(sFilterName) );
- OSL_TRACE( "turned into %s\n",
- OUStringToOString( aFilter, RTL_TEXTENCODING_UTF8 ).getStr() );
+ OUString aFilter;
+ if (aListIter != m_pFilterList->end())
+ aFilter = aListIter->getFilter();
- nTokenIndex = 0;
- OUString sToken;
- // OUString strExt;
- do
- {
- sToken = aFilter.getToken( 0, '.', nTokenIndex );
+ OSL_TRACE( "turned into %s\n",
+ OUStringToOString( aFilter, RTL_TEXTENCODING_UTF8 ).getStr() );
- if ( sToken.lastIndexOf( ';' ) != -1 )
+ nTokenIndex = 0;
+ OUString sToken;
+ do
{
- sal_Int32 nZero = 0;
- OUString aCurrentToken = sToken.getToken( 0, ';', nZero);
+ sToken = aFilter.getToken( 0, '.', nTokenIndex );
- sToken = aCurrentToken;
- break;
+ if ( sToken.lastIndexOf( ';' ) != -1 )
+ {
+ sal_Int32 nZero = 0;
+ OUString aCurrentToken = sToken.getToken( 0, ';', nZero);
+
+ sToken = aCurrentToken;
+ break;
+ }
}
- }
- while( nTokenIndex >= 0 );
+ while( nTokenIndex >= 0 );
- if( !bExtensionTypedIn && ( sToken != "*" ) )
- {
- //if the filename does not already have the auto extension, stick it on
- OUString sExtension = "." + sToken;
- OUString &rBase = aSelectedFiles[nIndex];
- sal_Int32 nExtensionIdx = rBase.getLength() - sExtension.getLength();
- SAL_INFO(
- "vcl.gtk",
- "idx are " << rBase.lastIndexOf(sExtension) << " "
+ if( !bExtensionTypedIn && ( sToken != "*" ) )
+ {
+ //if the filename does not already have the auto extension, stick it on
+ OUString sExtension = "." + sToken;
+ OUString &rBase = aSelectedFiles[nIndex];
+ sal_Int32 nExtensionIdx = rBase.getLength() - sExtension.getLength();
+ SAL_INFO(
+ "vcl.gtk",
+ "idx are " << rBase.lastIndexOf(sExtension) << " "
<< nExtensionIdx);
- if( rBase.lastIndexOf( sExtension ) != nExtensionIdx )
- rBase += sExtension;
+ if( rBase.lastIndexOf( sExtension ) != nExtensionIdx )
+ rBase += sExtension;
+ }
}
}