Kaydet (Commit) 5c430093 authored tarafından Miklos Vajna's avatar Miklos Vajna

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
üst 068c4df4
...@@ -310,28 +310,18 @@ Reference< XInterface > ODatabaseContext::getRegisteredObject(const OUString& _ ...@@ -310,28 +310,18 @@ Reference< XInterface > ODatabaseContext::getRegisteredObject(const OUString& _
return loadObjectFromURL( _rName, sURL ); 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 ); 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 ) if ( aURL.GetProtocol() == INetProtocol::NotValid )
throw NoSuchElementException( _rName, *this ); throw NoSuchElementException( _rName, *this );
try try
{ {
::ucbhelper::Content aContent( _sURL, NULL, comphelper::getProcessComponentContext() ); ::ucbhelper::Content aContent( _sURL, NULL, comphelper::getProcessComponentContext() );
if ( !aContent.isDocument() ) bool bEmbeddedDataSource = _sURL.startsWithIgnoreAsciiCase("vnd.sun.star.pkg:");
if ( !aContent.isDocument() && !bEmbeddedDataSource )
throw InteractiveIOException( throw InteractiveIOException(
_sURL, *this, InteractionClassification_ERROR, IOErrorCode_NO_FILE _sURL, *this, InteractionClassification_ERROR, IOErrorCode_NO_FILE
); );
...@@ -373,8 +363,6 @@ Reference< XInterface > ODatabaseContext::loadObjectFromURL(const OUString& _rNa ...@@ -373,8 +363,6 @@ 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 (!sStreamRelPath.isEmpty())
aArgs.put("StreamRelPath", sStreamRelPath);
Sequence< PropertyValue > aResource( aArgs.getPropertyValues() ); Sequence< PropertyValue > aResource( aArgs.getPropertyValues() );
xLoad->load( aResource ); xLoad->load( aResource );
......
...@@ -453,12 +453,22 @@ bool ODBFilter::implImport( const Sequence< PropertyValue >& rDescriptor ) ...@@ -453,12 +453,22 @@ bool ODBFilter::implImport( const Sequence< PropertyValue >& rDescriptor )
SfxMediumRef pMedium(0); SfxMediumRef pMedium(0);
if (!xStorage.is()) 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)); pMedium = new SfxMedium(sFileName, (StreamMode::READ | StreamMode::NOCREATE));
try try
{ {
xStorage.set(pMedium->GetStorage(false), UNO_QUERY_THROW); xStorage.set(pMedium->GetStorage(false), UNO_QUERY_THROW);
OUString sStreamRelPath = aMediaDescriptor.getOrDefault("StreamRelPath", OUString());
if (!sStreamRelPath.isEmpty()) if (!sStreamRelPath.isEmpty())
xStorage = xStorage->openStorageElement(sStreamRelPath, embed::ElementModes::READ); xStorage = xStorage->openStorageElement(sStreamRelPath, embed::ElementModes::READ);
} }
......
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