diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-05-08 17:35:37 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-05-08 18:19:15 +0200 |
commit | 5c430093a301b31174a81ad4437f0361c86cfe3c (patch) | |
tree | baca4747328680a8502822979702a8046f4a03c6 /dbaccess | |
parent | 068c4df48fd1d9f4c42864733b80e7cbd7f5d006 (diff) |
dbaccess: move vnd.sun.star.pkg: handling from ODatabaseContext to ODBFilter
This way the data source's URL will be the vnd.sun.star.pkg: URL, that
gets stored in the user profile, and the data source will be usable when
we connect to the data source next time, too.
Change-Id: Ie2f45af453bfad4f813a1ea492edb633c148d08b
Diffstat (limited to 'dbaccess')
-rw-r--r-- | dbaccess/source/core/dataaccess/databasecontext.cxx | 18 | ||||
-rw-r--r-- | dbaccess/source/filter/xml/xmlfilter.cxx | 12 |
2 files changed, 14 insertions, 16 deletions
diff --git a/dbaccess/source/core/dataaccess/databasecontext.cxx b/dbaccess/source/core/dataaccess/databasecontext.cxx index 2332ced91a30..6dd2efec6253 100644 --- a/dbaccess/source/core/dataaccess/databasecontext.cxx +++ b/dbaccess/source/core/dataaccess/databasecontext.cxx @@ -310,28 +310,18 @@ Reference< XInterface > ODatabaseContext::getRegisteredObject(const OUString& _ return loadObjectFromURL( _rName, sURL ); } -Reference< XInterface > ODatabaseContext::loadObjectFromURL(const OUString& _rName,const OUString& rURL) +Reference< XInterface > ODatabaseContext::loadObjectFromURL(const OUString& _rName,const OUString& _sURL) { - OUString _sURL(rURL); INetURLObject aURL( _sURL ); - OUString sStreamRelPath; - if (_sURL.startsWithIgnoreAsciiCase("vnd.sun.star.pkg:")) - { - // In this case the host contains the real path, and the the path is the embedded stream name. - _sURL = aURL.GetHost(INetURLObject::DECODE_WITH_CHARSET); - sStreamRelPath = aURL.GetURLPath(INetURLObject::DECODE_WITH_CHARSET); - if (sStreamRelPath.startsWith("/")) - sStreamRelPath = sStreamRelPath.copy(1); - } - if ( aURL.GetProtocol() == INetProtocol::NotValid ) throw NoSuchElementException( _rName, *this ); try { ::ucbhelper::Content aContent( _sURL, NULL, comphelper::getProcessComponentContext() ); - if ( !aContent.isDocument() ) + bool bEmbeddedDataSource = _sURL.startsWithIgnoreAsciiCase("vnd.sun.star.pkg:"); + if ( !aContent.isDocument() && !bEmbeddedDataSource ) throw InteractiveIOException( _sURL, *this, InteractionClassification_ERROR, IOErrorCode_NO_FILE ); @@ -373,8 +363,6 @@ Reference< XInterface > ODatabaseContext::loadObjectFromURL(const OUString& _rNa aArgs.put( "URL", _sURL ); aArgs.put( "MacroExecutionMode", MacroExecMode::USE_CONFIG ); aArgs.put( "InteractionHandler", task::InteractionHandler::createWithParent(m_aContext, 0) ); - if (!sStreamRelPath.isEmpty()) - aArgs.put("StreamRelPath", sStreamRelPath); Sequence< PropertyValue > aResource( aArgs.getPropertyValues() ); xLoad->load( aResource ); diff --git a/dbaccess/source/filter/xml/xmlfilter.cxx b/dbaccess/source/filter/xml/xmlfilter.cxx index 60fd9f3eecd6..6b1e16b71cb9 100644 --- a/dbaccess/source/filter/xml/xmlfilter.cxx +++ b/dbaccess/source/filter/xml/xmlfilter.cxx @@ -453,12 +453,22 @@ bool ODBFilter::implImport( const Sequence< PropertyValue >& rDescriptor ) SfxMediumRef pMedium(0); if (!xStorage.is()) { + OUString sStreamRelPath; + if (sFileName.startsWithIgnoreAsciiCase("vnd.sun.star.pkg:")) + { + // In this case the host contains the real path, and the the path is the embedded stream name. + INetURLObject aURL(sFileName); + sFileName = aURL.GetHost(INetURLObject::DECODE_WITH_CHARSET); + sStreamRelPath = aURL.GetURLPath(INetURLObject::DECODE_WITH_CHARSET); + if (sStreamRelPath.startsWith("/")) + sStreamRelPath = sStreamRelPath.copy(1); + } + pMedium = new SfxMedium(sFileName, (StreamMode::READ | StreamMode::NOCREATE)); try { xStorage.set(pMedium->GetStorage(false), UNO_QUERY_THROW); - OUString sStreamRelPath = aMediaDescriptor.getOrDefault("StreamRelPath", OUString()); if (!sStreamRelPath.isEmpty()) xStorage = xStorage->openStorageElement(sStreamRelPath, embed::ElementModes::READ); } |