[Libreoffice-commits] core.git: Branch 'libreoffice-6-3-6' - sw/source
Mike Kaganski (via logerrit)
logerrit at kemper.freedesktop.org
Tue Apr 21 19:27:57 UTC 2020
sw/source/uibase/app/docsh.cxx | 57 +++++++++++++++++++++++------------------
1 file changed, 33 insertions(+), 24 deletions(-)
New commits:
commit 58af0207255d4937dea0878a1f557a9b9881f3e6
Author: Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Fri Apr 17 14:13:26 2020 +0300
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Apr 21 21:27:20 2020 +0200
tdf#131621: fix crash in mergedlo.dll
When the embedded database comes from the template this document was
created from, the document might not have old URL yet.
This backport does not try to handle template's data source's
relative reference right. This depends on commit
e0f20211a8048a87b078aa4cf0f28c0c847487ad, which is not backported to
6-4 and 6-3.
Co-authored-by: Julien Nabet <serval2412 at yahoo.fr>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92398
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
(cherry picked from commit 0a0c10c0502906bebf9ea8c732d63809d5080dd6)
Change-Id: I5607113e0ae88fdb825d8a645c0968d2fe22ebd7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92430
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl at cib.de>
(cherry picked from commit 87ceb9d1e6f5fa17064e3d3a172409a4d384b341)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92431
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>
Reviewed-by: Xisco Faulí <xiscofauli at libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Xisco Faulí <xiscofauli at libreoffice.org>
diff --git a/sw/source/uibase/app/docsh.cxx b/sw/source/uibase/app/docsh.cxx
index 96c7634ea5c3..083b4ec6c648 100644
--- a/sw/source/uibase/app/docsh.cxx
+++ b/sw/source/uibase/app/docsh.cxx
@@ -466,32 +466,41 @@ bool SwDocShell::SaveAs( SfxMedium& rMedium )
// We have an embedded data source definition, need to re-store it,
// otherwise relative references will break when the new file is in a
// different directory.
- uno::Reference<sdb::XDatabaseContext> xDatabaseContext = sdb::DatabaseContext::create(comphelper::getProcessComponentContext());
-
- const INetURLObject& rOldURLObject = GetMedium()->GetURLObject();
- auto xContext(comphelper::getProcessComponentContext());
- auto xUri = css::uri::UriReferenceFactory::create(xContext)
- ->parse(rOldURLObject.GetMainURL(INetURLObject::DecodeMechanism::NONE));
- assert(xUri.is());
- xUri = css::uri::VndSunStarPkgUrlReferenceFactory::create(xContext)->createVndSunStarPkgUrlReference(xUri);
- assert(xUri.is());
- OUString const aURL = xUri->getUriReference() + "/"
- + INetURLObject::encode(pMgr->getEmbeddedName(),
- INetURLObject::PART_FPATH, INetURLObject::EncodeMechanism::All);
-
- bool bCopyTo = GetCreateMode() == SfxObjectCreateMode::EMBEDDED;
- if (!bCopyTo)
+
+ OUString aURL(GetMedium()->GetURLObject().GetMainURL(INetURLObject::DecodeMechanism::NONE));
+
+ if (!aURL.isEmpty())
{
- if (const SfxBoolItem* pSaveToItem
- = SfxItemSet::GetItem(rMedium.GetItemSet(), SID_SAVETO, false))
- bCopyTo = pSaveToItem->GetValue();
- }
+ auto xContext(comphelper::getProcessComponentContext());
+ auto xUri = css::uri::UriReferenceFactory::create(xContext)->parse(aURL);
+ assert(xUri.is());
+ xUri = css::uri::VndSunStarPkgUrlReferenceFactory::create(xContext)
+ ->createVndSunStarPkgUrlReference(xUri);
+ assert(xUri.is());
+ aURL = xUri->getUriReference() + "/"
+ + INetURLObject::encode(pMgr->getEmbeddedName(), INetURLObject::PART_FPATH,
+ INetURLObject::EncodeMechanism::All);
+
+ bool bCopyTo = GetCreateMode() == SfxObjectCreateMode::EMBEDDED;
+ if (!bCopyTo)
+ {
+ if (const SfxBoolItem* pSaveToItem
+ = SfxItemSet::GetItem(rMedium.GetItemSet(), SID_SAVETO, false))
+ bCopyTo = pSaveToItem->GetValue();
+ }
- uno::Reference<sdb::XDocumentDataSource> xDataSource(xDatabaseContext->getByName(aURL), uno::UNO_QUERY);
- uno::Reference<frame::XStorable> xStorable(xDataSource->getDatabaseDocument(), uno::UNO_QUERY);
- SwDBManager::StoreEmbeddedDataSource(xStorable, rMedium.GetOutputStorage(),
- pMgr->getEmbeddedName(),
- rMedium.GetName(), bCopyTo);
+ auto xDatabaseContext = sdb::DatabaseContext::create(xContext);
+ uno::Reference<sdb::XDocumentDataSource> xDataSource(xDatabaseContext->getByName(aURL),
+ uno::UNO_QUERY);
+ if (xDataSource)
+ {
+ uno::Reference<frame::XStorable> xStorable(xDataSource->getDatabaseDocument(),
+ uno::UNO_QUERY);
+ SwDBManager::StoreEmbeddedDataSource(xStorable, rMedium.GetOutputStorage(),
+ pMgr->getEmbeddedName(), rMedium.GetName(),
+ bCopyTo);
+ }
+ }
}
// #i62875#
More information about the Libreoffice-commits
mailing list