diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2016-09-23 22:10:29 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-09-26 16:20:51 +0000 |
commit | 651c6aaa44c9748d6900296b1227c89c2a43e3ed (patch) | |
tree | 84b6f96d71136f4a3cff1203fbc6504d3300b8aa | |
parent | 6de338782529f65e3adb945a5e48cc6eb4f60603 (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>
(cherry picked from commit 3be5deadcb46e09d84d99b2b108b65b06ff356e9)
Reviewed-on: https://gerrit.libreoffice.org/29302
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx | 88 |
1 files changed, 47 insertions, 41 deletions
diff --git a/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx b/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx index 9798639e58f9..3703aa09d209 100644 --- a/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx +++ b/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx @@ -575,13 +575,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; + } } } } @@ -793,10 +796,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 ) ) { @@ -830,47 +834,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; + } } } |