dbaccess, sw: use vnd.sun.star.pkg:// for embedded data source handling

Change-Id: I69eaf2e4dd051d62f56caef962d40889cc3a3876
This commit is contained in:
Miklos Vajna
2015-05-08 16:49:06 +02:00
parent 40ad68bbe7
commit 12bb6a054d
2 changed files with 17 additions and 8 deletions

View File

@@ -315,9 +315,15 @@ Reference< XInterface > ODatabaseContext::loadObjectFromURL(const OUString& _rNa
OUString _sURL(rURL);
INetURLObject aURL( _sURL );
OUString aMark = aURL.GetMark(INetURLObject::DECODE_WITH_CHARSET);
if (!aMark.isEmpty())
_sURL = aURL.GetURLNoMark();
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 );
@@ -367,8 +373,8 @@ 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 (!aMark.isEmpty())
aArgs.put("StreamRelPath", aMark);
if (!sStreamRelPath.isEmpty())
aArgs.put("StreamRelPath", sStreamRelPath);
Sequence< PropertyValue > aResource( aArgs.getPropertyValues() );
xLoad->load( aResource );

View File

@@ -2631,9 +2631,12 @@ void SwDBManager::LoadAndRegisterEmbeddedDataSource(const SwDBData& rData, const
if (xDatabaseContext->hasByName(rData.sDataSource))
xDatabaseContext->revokeObject(rData.sDataSource);
INetURLObject aURLObject(rDocShell.GetMedium()->GetURLObject());
aURLObject.SetMark(rData.sEmbeddedName);
OUString aURL = aURLObject.GetMainURL(INetURLObject::DECODE_WITH_CHARSET);
// Encode the stream name and the real path into a single URL.
const INetURLObject& rURLObject = rDocShell.GetMedium()->GetURLObject();
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);
xDatabaseContext->registerObject(rData.sDataSource, xDataSource);
}