Kaydet (Commit) 93eefe54 authored tarafından Krisztian Pinter's avatar Krisztian Pinter Kaydeden (comit) Caolán McNamara

Make SvtHistoryOptions not return files if they can't be opened

Change-Id: I68cb3363a33b2d6ceb2330486e26d5cfa913c5e7
Reviewed-on: https://gerrit.libreoffice.org/5841Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 573d6255
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
#include <osl/file.hxx>
#include <unotools/historyoptions.hxx> #include <unotools/historyoptions.hxx>
#include <unotools/configmgr.hxx> #include <unotools/configmgr.hxx>
#include <unotools/configitem.hxx> #include <unotools/configitem.hxx>
...@@ -317,6 +318,18 @@ void SvtHistoryOptions_Impl::Clear( EHistoryType eHistory ) ...@@ -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 // public method
// get a sequence list from the items // get a sequence list from the items
...@@ -382,6 +395,8 @@ Sequence< Sequence< PropertyValue > > SvtHistoryOptions_Impl::GetList( EHistoryT ...@@ -382,6 +395,8 @@ Sequence< Sequence< PropertyValue > > SvtHistoryOptions_Impl::GetList( EHistoryT
xOrderList->getByName(OUString::number(nItem)) >>= xSet; xOrderList->getByName(OUString::number(nItem)) >>= xSet;
xSet->getPropertyValue(OUString(s_sHistoryItemRef)) >>= sUrl; xSet->getPropertyValue(OUString(s_sHistoryItemRef)) >>= sUrl;
if( !sUrl.startsWith("file://") || lcl_fileOpenable( sUrl ) )
{
xItemList->getByName(sUrl) >>= xSet; xItemList->getByName(sUrl) >>= xSet;
seqProperties[s_nOffsetURL ].Value <<= sUrl; seqProperties[s_nOffsetURL ].Value <<= sUrl;
xSet->getPropertyValue(OUString(s_sFilter)) >>= seqProperties[s_nOffsetFilter ].Value; xSet->getPropertyValue(OUString(s_sFilter)) >>= seqProperties[s_nOffsetFilter ].Value;
...@@ -389,6 +404,7 @@ Sequence< Sequence< PropertyValue > > SvtHistoryOptions_Impl::GetList( EHistoryT ...@@ -389,6 +404,7 @@ Sequence< Sequence< PropertyValue > > SvtHistoryOptions_Impl::GetList( EHistoryT
xSet->getPropertyValue(OUString(s_sPassword)) >>= seqProperties[s_nOffsetPassword ].Value; xSet->getPropertyValue(OUString(s_sPassword)) >>= seqProperties[s_nOffsetPassword ].Value;
aRet[nCount++] = seqProperties; aRet[nCount++] = seqProperties;
} }
}
catch(const css::uno::Exception& ex) catch(const css::uno::Exception& ex)
{ {
// <https://bugs.freedesktop.org/show_bug.cgi?id=46074> // <https://bugs.freedesktop.org/show_bug.cgi?id=46074>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment