Kaydet (Commit) ff3e41a5 authored tarafından Miklos Vajna's avatar Miklos Vajna

dbaccess: use already existing source storage in ODBFilter, if possible

Change-Id: I4378e229c771cf79a694086b7a4ba4ac2e36b8f7
üst c0e209bf
...@@ -431,31 +431,40 @@ bool ODBFilter::implImport( const Sequence< PropertyValue >& rDescriptor ) ...@@ -431,31 +431,40 @@ bool ODBFilter::implImport( const Sequence< PropertyValue >& rDescriptor )
{ {
OUString sFileName; OUString sFileName;
::comphelper::NamedValueCollection aMediaDescriptor( rDescriptor ); ::comphelper::NamedValueCollection aMediaDescriptor( rDescriptor );
if ( aMediaDescriptor.has( "URL" ) )
sFileName = aMediaDescriptor.getOrDefault( "URL", OUString() );
if ( sFileName.isEmpty() && aMediaDescriptor.has( "FileName" ) )
sFileName = aMediaDescriptor.getOrDefault( "FileName", sFileName );
OSL_ENSURE( !sFileName.isEmpty(), "ODBFilter::implImport: no URL given!" ); uno::Reference<embed::XStorage> xStorage = GetSourceStorage();
bool bRet = !sFileName.isEmpty();
bool bRet = true;
if (!xStorage.is())
{
if (aMediaDescriptor.has("URL"))
sFileName = aMediaDescriptor.getOrDefault("URL", OUString());
if (sFileName.isEmpty() && aMediaDescriptor.has("FileName"))
sFileName = aMediaDescriptor.getOrDefault("FileName", sFileName);
OSL_ENSURE(!sFileName.isEmpty(), "ODBFilter::implImport: no URL given!");
bRet = !sFileName.isEmpty();
}
if ( bRet ) if ( bRet )
{ {
uno::Reference<XComponent> xCom(GetModel(),UNO_QUERY); uno::Reference<XComponent> xCom(GetModel(),UNO_QUERY);
SfxMediumRef pMedium = new SfxMedium( SfxMediumRef pMedium(0);
sFileName, ( StreamMode::READ | StreamMode::NOCREATE ) ); if (!xStorage.is())
uno::Reference< embed::XStorage > xStorage;
try
{
xStorage.set( pMedium->GetStorage( false ), UNO_QUERY_THROW );
}
catch (const Exception&)
{ {
Any aError = ::cppu::getCaughtException(); pMedium = new SfxMedium(sFileName, (StreamMode::READ | StreamMode::NOCREATE));
if ( aError.isExtractableTo( ::cppu::UnoType< RuntimeException >::get() ) ) try
throw; {
throw lang::WrappedTargetRuntimeException( OUString(), *this, aError ); xStorage.set(pMedium->GetStorage(false), UNO_QUERY_THROW);
}
catch (const Exception&)
{
Any aError = ::cppu::getCaughtException();
if (aError.isExtractableTo(::cppu::UnoType<RuntimeException>::get()))
throw;
throw lang::WrappedTargetRuntimeException(OUString(), *this, aError);
}
} }
uno::Reference<sdb::XOfficeDatabaseDocument> xOfficeDoc(GetModel(),UNO_QUERY_THROW); uno::Reference<sdb::XOfficeDatabaseDocument> xOfficeDoc(GetModel(),UNO_QUERY_THROW);
......
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