dbaccess, sw: use vnd.sun.star.pkg:// for embedded data source handling
Change-Id: I69eaf2e4dd051d62f56caef962d40889cc3a3876
This commit is contained in:
@@ -315,9 +315,15 @@ Reference< XInterface > ODatabaseContext::loadObjectFromURL(const OUString& _rNa
|
|||||||
OUString _sURL(rURL);
|
OUString _sURL(rURL);
|
||||||
INetURLObject aURL( _sURL );
|
INetURLObject aURL( _sURL );
|
||||||
|
|
||||||
OUString aMark = aURL.GetMark(INetURLObject::DECODE_WITH_CHARSET);
|
OUString sStreamRelPath;
|
||||||
if (!aMark.isEmpty())
|
if (_sURL.startsWithIgnoreAsciiCase("vnd.sun.star.pkg:"))
|
||||||
_sURL = aURL.GetURLNoMark();
|
{
|
||||||
|
// 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 );
|
||||||
@@ -367,8 +373,8 @@ 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 (!aMark.isEmpty())
|
if (!sStreamRelPath.isEmpty())
|
||||||
aArgs.put("StreamRelPath", aMark);
|
aArgs.put("StreamRelPath", sStreamRelPath);
|
||||||
|
|
||||||
Sequence< PropertyValue > aResource( aArgs.getPropertyValues() );
|
Sequence< PropertyValue > aResource( aArgs.getPropertyValues() );
|
||||||
xLoad->load( aResource );
|
xLoad->load( aResource );
|
||||||
|
@@ -2631,9 +2631,12 @@ void SwDBManager::LoadAndRegisterEmbeddedDataSource(const SwDBData& rData, const
|
|||||||
if (xDatabaseContext->hasByName(rData.sDataSource))
|
if (xDatabaseContext->hasByName(rData.sDataSource))
|
||||||
xDatabaseContext->revokeObject(rData.sDataSource);
|
xDatabaseContext->revokeObject(rData.sDataSource);
|
||||||
|
|
||||||
INetURLObject aURLObject(rDocShell.GetMedium()->GetURLObject());
|
// Encode the stream name and the real path into a single URL.
|
||||||
aURLObject.SetMark(rData.sEmbeddedName);
|
const INetURLObject& rURLObject = rDocShell.GetMedium()->GetURLObject();
|
||||||
OUString aURL = aURLObject.GetMainURL(INetURLObject::DECODE_WITH_CHARSET);
|
OUString aURL = "vnd.sun.star.pkg://";
|
||||||
|
aURL += INetURLObject::encode(rURLObject.GetMainURL(INetURLObject::DECODE_WITH_CHARSET), INetURLObject::PART_AUTHORITY, INetURLObject::ENCODE_ALL);
|
||||||
|
aURL += "/" + INetURLObject::encode(rData.sEmbeddedName, INetURLObject::PART_FPATH, INetURLObject::ENCODE_ALL);
|
||||||
|
|
||||||
uno::Reference<uno::XInterface> xDataSource(xDatabaseContext->getByName(aURL), uno::UNO_QUERY);
|
uno::Reference<uno::XInterface> xDataSource(xDatabaseContext->getByName(aURL), uno::UNO_QUERY);
|
||||||
xDatabaseContext->registerObject(rData.sDataSource, xDataSource);
|
xDatabaseContext->registerObject(rData.sDataSource, xDataSource);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user