Kaydet (Commit) 4101949b authored tarafından Miklos Vajna's avatar Miklos Vajna

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
üst 0648f2c2
...@@ -317,10 +317,10 @@ Reference< XInterface > ODatabaseContext::loadObjectFromURL(const OUString& _rNa ...@@ -317,10 +317,10 @@ Reference< XInterface > ODatabaseContext::loadObjectFromURL(const OUString& _rNa
if ( aURL.GetProtocol() == INetProtocol::NotValid ) if ( aURL.GetProtocol() == INetProtocol::NotValid )
throw NoSuchElementException( _rName, *this ); throw NoSuchElementException( _rName, *this );
bool bEmbeddedDataSource = _sURL.startsWithIgnoreAsciiCase("vnd.sun.star.pkg:");
try try
{ {
::ucbhelper::Content aContent( _sURL, NULL, comphelper::getProcessComponentContext() ); ::ucbhelper::Content aContent( _sURL, NULL, comphelper::getProcessComponentContext() );
bool bEmbeddedDataSource = _sURL.startsWithIgnoreAsciiCase("vnd.sun.star.pkg:");
if ( !aContent.isDocument() && !bEmbeddedDataSource ) if ( !aContent.isDocument() && !bEmbeddedDataSource )
throw InteractiveIOException( throw InteractiveIOException(
_sURL, *this, InteractionClassification_ERROR, IOErrorCode_NO_FILE _sURL, *this, InteractionClassification_ERROR, IOErrorCode_NO_FILE
...@@ -363,6 +363,12 @@ Reference< XInterface > ODatabaseContext::loadObjectFromURL(const OUString& _rNa ...@@ -363,6 +363,12 @@ Reference< XInterface > ODatabaseContext::loadObjectFromURL(const OUString& _rNa
aArgs.put( "URL", _sURL ); aArgs.put( "URL", _sURL );
aArgs.put( "MacroExecutionMode", MacroExecMode::USE_CONFIG ); aArgs.put( "MacroExecutionMode", MacroExecMode::USE_CONFIG );
aArgs.put( "InteractionHandler", task::InteractionHandler::createWithParent(m_aContext, 0) ); 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() ); Sequence< PropertyValue > aResource( aArgs.getPropertyValues() );
xLoad->load( aResource ); xLoad->load( aResource );
......
...@@ -502,7 +502,10 @@ void ODatabaseDocument::impl_import_nolck_throw( const Reference< XComponentCont ...@@ -502,7 +502,10 @@ void ODatabaseDocument::impl_import_nolck_throw( const Reference< XComponentCont
lcl_extractAndStartStatusIndicator( _rResource, xStatusIndicator, aFilterCreationArgs ); lcl_extractAndStartStatusIndicator( _rResource, xStatusIndicator, aFilterCreationArgs );
uno::Reference< beans::XPropertySet > xInfoSet( comphelper::GenericPropertySet_CreateInstance( new comphelper::PropertySetInfo( aExportInfoMap ) ) ); 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"))); xInfoSet->setPropertyValue("StreamName", uno::makeAny(OUString("content.xml")));
const sal_Int32 nCount = aFilterCreationArgs.getLength(); const sal_Int32 nCount = aFilterCreationArgs.getLength();
......
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