summaryrefslogtreecommitdiff
path: root/dbaccess
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-05-05 09:42:03 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-05-05 10:22:47 +0200
commitff3e41a5be2f104e2ea1497660938e5744ad6fba (patch)
tree4a0c6d992c2fa707ecd3db30a99065525f18ec12 /dbaccess
parentc0e209bf5f418f1564d16e234251783a0857a9d4 (diff)
dbaccess: use already existing source storage in ODBFilter, if possible
Change-Id: I4378e229c771cf79a694086b7a4ba4ac2e36b8f7
Diffstat (limited to 'dbaccess')
-rw-r--r--dbaccess/source/filter/xml/xmlfilter.cxx45
1 files changed, 27 insertions, 18 deletions
diff --git a/dbaccess/source/filter/xml/xmlfilter.cxx b/dbaccess/source/filter/xml/xmlfilter.cxx
index 03e94bab400c..4d2e8ccc60a5 100644
--- a/dbaccess/source/filter/xml/xmlfilter.cxx
+++ b/dbaccess/source/filter/xml/xmlfilter.cxx
@@ -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;
- try
- {
- xStorage.set( pMedium->GetStorage( false ), UNO_QUERY_THROW );
- }
- catch (const Exception&)
+ SfxMediumRef pMedium(0);
+ if (!xStorage.is())
{
- Any aError = ::cppu::getCaughtException();
- if ( aError.isExtractableTo( ::cppu::UnoType< RuntimeException >::get() ) )
- throw;
- throw lang::WrappedTargetRuntimeException( OUString(), *this, aError );
+ pMedium = new SfxMedium(sFileName, (StreamMode::READ | StreamMode::NOCREATE));
+ try
+ {
+ 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);