[Libreoffice-commits] core.git: dbaccess/source sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Fri May 8 08:13:40 PDT 2015
dbaccess/source/core/dataaccess/databasecontext.cxx | 16 +++++++++++-----
sw/source/uibase/dbui/dbmgr.cxx | 9 ++++++---
2 files changed, 17 insertions(+), 8 deletions(-)
New commits:
commit 12bb6a054d697efddee76269605ed2450a2fae9c
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Fri May 8 16:49:06 2015 +0200
dbaccess, sw: use vnd.sun.star.pkg:// for embedded data source handling
Change-Id: I69eaf2e4dd051d62f56caef962d40889cc3a3876
diff --git a/dbaccess/source/core/dataaccess/databasecontext.cxx b/dbaccess/source/core/dataaccess/databasecontext.cxx
index 4e6c185..2332ced 100644
--- a/dbaccess/source/core/dataaccess/databasecontext.cxx
+++ b/dbaccess/source/core/dataaccess/databasecontext.cxx
@@ -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 );
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index 042a0bd..3f81f2e 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -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);
}
More information about the Libreoffice-commits
mailing list