diff options
author | Gülşah Köse <gulsah.kose@collabora.com> | 2022-07-08 14:48:27 +0300 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2022-07-26 14:55:53 +0200 |
commit | cd38c23ed291e52fbb3cf0ce6070081e6aecff22 (patch) | |
tree | b424dc22b3dfb190ca75323e89bcb16f5db9290d | |
parent | 1b97f2ce4d5f3b3cbfd3a826c12557bbdcc07e1f (diff) |
tdf#149915 Proper creation of vnd.sun.star.pkg:// URL
Using different methods of creation (one using DecodeMechanism::NONE,
another using DecodeMechanism::WithCharset) gave differently encoded
end results, comparing unequal.
The proper way is using DecodeMechanism::NONE on the document's URL,
as implemented in commit 06756e412b2a02030ce3355b3fe4e2ecc71d2301
Author Mike Kaganski <mike.kaganski@collabora.com>
Date Sat Nov 18 22:41:40 2017 +0300
One more proper construction of vnd.sun.star.pkg URL
Co-authored-by: Mike Kaganski <mike.kaganski@collabora.com>
Change-Id: I272f277ef8b4bd23e6cb7884e68f3c79f742683a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136901
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
(cherry picked from commit 9790585a62cb55e0e0024819596592193a6de269)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137429
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Andras Timar <andras.timar@collabora.com>
-rw-r--r-- | sw/source/uibase/dbui/dbmgr.cxx | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx index 9323c52770b2..aa9937065325 100644 --- a/sw/source/uibase/dbui/dbmgr.cxx +++ b/sw/source/uibase/dbui/dbmgr.cxx @@ -136,6 +136,21 @@ void lcl_emitEvent(SfxEventHintId nEventId, sal_Int32 nStrId, SfxObjectShell* pD pDocShell)); } +// Construct vnd.sun.star.pkg:// URL +OUString ConstructVndSunStarPkgUrl(const OUString& rMainURL, std::u16string_view rStreamRelPath) +{ + auto xContext(comphelper::getProcessComponentContext()); + auto xUri = css::uri::UriReferenceFactory::create(xContext)->parse(rMainURL); + assert(xUri.is()); + xUri = css::uri::VndSunStarPkgUrlReferenceFactory::create(xContext) + ->createVndSunStarPkgUrlReference(xUri); + assert(xUri.is()); + return xUri->getUriReference() + "/" + + INetURLObject::encode( + rStreamRelPath, INetURLObject::PART_FPATH, + INetURLObject::EncodeMechanism::All); +} + } std::vector<std::pair<SwDocShell*, OUString>> SwDBManager::s_aUncommittedRegistrations; @@ -256,10 +271,9 @@ void SAL_CALL SwDataSourceRemovedListener::revokedDatabaseLocation(const sdb::Da if (!pDocShell) return; - OUString aOwnURL = pDocShell->GetMedium()->GetURLObject().GetMainURL(INetURLObject::DecodeMechanism::WithCharset); - OUString sTmpName = "vnd.sun.star.pkg://" + - INetURLObject::encode(aOwnURL, INetURLObject::PART_AUTHORITY, INetURLObject::EncodeMechanism::All); - sTmpName += "/" + m_pDBManager->getEmbeddedName(); + const OUString sTmpName = ConstructVndSunStarPkgUrl( + pDocShell->GetMedium()->GetURLObject().GetMainURL(INetURLObject::DecodeMechanism::NONE), + m_pDBManager->getEmbeddedName()); if (sTmpName != rEvent.OldLocation) return; @@ -2760,21 +2774,6 @@ OUString LoadAndRegisterDataSource_Impl(DBConnURIType type, const uno::Reference } return sFind; } - -// Construct vnd.sun.star.pkg:// URL -OUString ConstructVndSunStarPkgUrl(const OUString& rMainURL, std::u16string_view rStreamRelPath) -{ - auto xContext(comphelper::getProcessComponentContext()); - auto xUri = css::uri::UriReferenceFactory::create(xContext)->parse(rMainURL); - assert(xUri.is()); - xUri = css::uri::VndSunStarPkgUrlReferenceFactory::create(xContext) - ->createVndSunStarPkgUrlReference(xUri); - assert(xUri.is()); - return xUri->getUriReference() + "/" - + INetURLObject::encode( - rStreamRelPath, INetURLObject::PART_FPATH, - INetURLObject::EncodeMechanism::All); -} } OUString SwDBManager::LoadAndRegisterDataSource(weld::Window* pParent, SwDocShell* pDocShell) |