dbaccess/source/core/dataaccess/databasecontext.cxx | 21 +++++++++++++------ dbaccess/source/core/dataaccess/databasedocument.cxx | 5 +++- 2 files changed, 19 insertions(+), 7 deletions(-)
New commits: commit cd33c5355f7c334e385595ba29adaa7844b252e2 Author: Miklos Vajna <[email protected]> Date: Mon Jun 8 09:41:18 2015 +0200 dbaccess: avoid pointless ucbhelper::Content instance in case of embedding Change-Id: Ibc3d7a0d9b3373f17aa8d1da081946814904e6d5 diff --git a/dbaccess/source/core/dataaccess/databasecontext.cxx b/dbaccess/source/core/dataaccess/databasecontext.cxx index 775ecb6..32c63a1 100644 --- a/dbaccess/source/core/dataaccess/databasecontext.cxx +++ b/dbaccess/source/core/dataaccess/databasecontext.cxx @@ -320,11 +320,14 @@ Reference< XInterface > ODatabaseContext::loadObjectFromURL(const OUString& _rNa bool bEmbeddedDataSource = _sURL.startsWithIgnoreAsciiCase("vnd.sun.star.pkg:"); try { - ::ucbhelper::Content aContent( _sURL, NULL, comphelper::getProcessComponentContext() ); - if ( !aContent.isDocument() && !bEmbeddedDataSource ) - throw InteractiveIOException( - _sURL, *this, InteractionClassification_ERROR, IOErrorCode_NO_FILE - ); + if (!bEmbeddedDataSource) + { + ::ucbhelper::Content aContent( _sURL, NULL, comphelper::getProcessComponentContext() ); + if ( !aContent.isDocument() ) + throw InteractiveIOException( + _sURL, *this, InteractionClassification_ERROR, IOErrorCode_NO_FILE + ); + } } catch ( const InteractiveIOException& e ) { commit 4101949b2a9fcf399a1fa10c2547f745a24f5a3d Author: Miklos Vajna <[email protected]> Date: Mon Jun 8 09:40:51 2015 +0200 dbaccess: set correct BaseURI for vnd.sun.star.pkg:// URLs on load With this, in case the embedded data source definition has an URL like: <db:file-based-database xlink:href="../../calc-data-source.ods/" db:media-type="application/vnd.oasis.opendocument.spreadsheet"/> That's resolved to file:///path/to/directory/of/Writer/doc/calc-data-source.ods correctly. Change-Id: Ieb67f9f5ae104689c6dadc14ec84c66bec70a687 diff --git a/dbaccess/source/core/dataaccess/databasecontext.cxx b/dbaccess/source/core/dataaccess/databasecontext.cxx index 6dd2efe..775ecb6 100644 --- a/dbaccess/source/core/dataaccess/databasecontext.cxx +++ b/dbaccess/source/core/dataaccess/databasecontext.cxx @@ -317,10 +317,10 @@ Reference< XInterface > ODatabaseContext::loadObjectFromURL(const OUString& _rNa if ( aURL.GetProtocol() == INetProtocol::NotValid ) throw NoSuchElementException( _rName, *this ); + bool bEmbeddedDataSource = _sURL.startsWithIgnoreAsciiCase("vnd.sun.star.pkg:"); try { ::ucbhelper::Content aContent( _sURL, NULL, comphelper::getProcessComponentContext() ); - bool bEmbeddedDataSource = _sURL.startsWithIgnoreAsciiCase("vnd.sun.star.pkg:"); if ( !aContent.isDocument() && !bEmbeddedDataSource ) throw InteractiveIOException( _sURL, *this, InteractionClassification_ERROR, IOErrorCode_NO_FILE @@ -363,6 +363,12 @@ 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 (bEmbeddedDataSource) + { + // In this case the host contains the real path, and the the path is the embedded stream name. + OUString sBaseURI = aURL.GetHost(INetURLObject::DECODE_WITH_CHARSET) + aURL.GetURLPath(INetURLObject::DECODE_WITH_CHARSET); + aArgs.put("BaseURI", sBaseURI); + } Sequence< PropertyValue > aResource( aArgs.getPropertyValues() ); xLoad->load( aResource ); diff --git a/dbaccess/source/core/dataaccess/databasedocument.cxx b/dbaccess/source/core/dataaccess/databasedocument.cxx index 43aa283..8c82907 100644 --- a/dbaccess/source/core/dataaccess/databasedocument.cxx +++ b/dbaccess/source/core/dataaccess/databasedocument.cxx @@ -502,7 +502,10 @@ void ODatabaseDocument::impl_import_nolck_throw( const Reference< XComponentCont lcl_extractAndStartStatusIndicator( _rResource, xStatusIndicator, aFilterCreationArgs ); uno::Reference< beans::XPropertySet > xInfoSet( comphelper::GenericPropertySet_CreateInstance( new comphelper::PropertySetInfo( aExportInfoMap ) ) ); - xInfoSet->setPropertyValue("BaseURI", uno::makeAny(_rResource.getOrDefault("URL",OUString()))); + OUString sBaseURI = _rResource.getOrDefault("BaseURI", OUString()); + if (sBaseURI.isEmpty()) + sBaseURI = _rResource.getOrDefault("URL",OUString()); + xInfoSet->setPropertyValue("BaseURI", uno::makeAny(sBaseURI)); xInfoSet->setPropertyValue("StreamName", uno::makeAny(OUString("content.xml"))); const sal_Int32 nCount = aFilterCreationArgs.getLength(); _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
