diff options
author | Krisztian Pinter <pin.terminator@gmail.com> | 2013-09-06 14:45:13 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-09-09 12:53:42 +0000 |
commit | 93eefe54f5d6b6092371bad1e86444489d29eee2 (patch) | |
tree | e9756c4a783821bb35f31d363ba31cd002b0201d | |
parent | set mnemonic widgets (diff) | |
download | core-93eefe54f5d6b6092371bad1e86444489d29eee2.tar.gz core-93eefe54f5d6b6092371bad1e86444489d29eee2.zip |
Make SvtHistoryOptions not return files if they can't be opened
Change-Id: I68cb3363a33b2d6ceb2330486e26d5cfa913c5e7
Reviewed-on: https://gerrit.libreoffice.org/5841
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | unotools/source/config/historyoptions.cxx | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/unotools/source/config/historyoptions.cxx b/unotools/source/config/historyoptions.cxx index e552d8118407..bc935ad9ccd2 100644 --- a/unotools/source/config/historyoptions.cxx +++ b/unotools/source/config/historyoptions.cxx @@ -18,6 +18,7 @@ */ +#include <osl/file.hxx> #include <unotools/historyoptions.hxx> #include <unotools/configmgr.hxx> #include <unotools/configitem.hxx> @@ -317,6 +318,18 @@ void SvtHistoryOptions_Impl::Clear( EHistoryType eHistory ) } } +static bool lcl_fileOpenable(const OUString &rURL) +{ + osl::File aRecentFile(rURL); + if(!aRecentFile.open(osl_File_OpenFlag_Read)) + { + aRecentFile.close(); + return true; + } + else + return false; +} + //***************************************************************************************************************** // public method // get a sequence list from the items @@ -382,12 +395,15 @@ Sequence< Sequence< PropertyValue > > SvtHistoryOptions_Impl::GetList( EHistoryT xOrderList->getByName(OUString::number(nItem)) >>= xSet; xSet->getPropertyValue(OUString(s_sHistoryItemRef)) >>= sUrl; - xItemList->getByName(sUrl) >>= xSet; - seqProperties[s_nOffsetURL ].Value <<= sUrl; - xSet->getPropertyValue(OUString(s_sFilter)) >>= seqProperties[s_nOffsetFilter ].Value; - xSet->getPropertyValue(OUString(s_sTitle)) >>= seqProperties[s_nOffsetTitle ].Value; - xSet->getPropertyValue(OUString(s_sPassword)) >>= seqProperties[s_nOffsetPassword ].Value; - aRet[nCount++] = seqProperties; + if( !sUrl.startsWith("file://") || lcl_fileOpenable( sUrl ) ) + { + xItemList->getByName(sUrl) >>= xSet; + seqProperties[s_nOffsetURL ].Value <<= sUrl; + xSet->getPropertyValue(OUString(s_sFilter)) >>= seqProperties[s_nOffsetFilter ].Value; + xSet->getPropertyValue(OUString(s_sTitle)) >>= seqProperties[s_nOffsetTitle ].Value; + xSet->getPropertyValue(OUString(s_sPassword)) >>= seqProperties[s_nOffsetPassword ].Value; + aRet[nCount++] = seqProperties; + } } catch(const css::uno::Exception& ex) { |