dbaccess/source/core/dataaccess/databasecontext.cxx | 18 +++--------------- dbaccess/source/filter/xml/xmlfilter.cxx | 12 +++++++++++- 2 files changed, 14 insertions(+), 16 deletions(-)
New commits: commit 5c430093a301b31174a81ad4437f0361c86cfe3c Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Fri May 8 17:35:37 2015 +0200 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 diff --git a/dbaccess/source/core/dataaccess/databasecontext.cxx b/dbaccess/source/core/dataaccess/databasecontext.cxx index 2332ced..6dd2efe 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 60fd9f3..6b1e16b 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); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits