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 )
{
OUString sFileName;
::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!" );
bool bRet = !sFileName.isEmpty();
uno::Reference<embed::XStorage> xStorage = GetSourceStorage();
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 )
{
uno::Reference<XComponent> xCom(GetModel(),UNO_QUERY);
SfxMediumRef pMedium = new SfxMedium(
sFileName, ( StreamMode::READ | StreamMode::NOCREATE ) );
uno::Reference< embed::XStorage > xStorage;
SfxMediumRef pMedium(0);
if (!xStorage.is())
{
pMedium = new SfxMedium(sFileName, (StreamMode::READ | StreamMode::NOCREATE));
try
{
xStorage.set( pMedium->GetStorage( false ), UNO_QUERY_THROW );
xStorage.set(pMedium->GetStorage(false), UNO_QUERY_THROW);
}
catch (const Exception&)
{
Any aError = ::cppu::getCaughtException();
if ( aError.isExtractableTo( ::cppu::UnoType< RuntimeException >::get() ) )
if (aError.isExtractableTo(::cppu::UnoType<RuntimeException>::get()))
throw;
throw lang::WrappedTargetRuntimeException( OUString(), *this, aError );
throw lang::WrappedTargetRuntimeException(OUString(), *this, aError);
}
}
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