[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - sw/source
Caolán McNamara
caolanm at redhat.com
Thu Jun 7 11:55:33 UTC 2018
sw/source/uibase/dbui/dbmgr.cxx | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
New commits:
commit 34a3231103adcbcc71e0cc5e8b8f8b0bc1edb520
Author: Caolán McNamara <caolanm at redhat.com>
Date: Wed Jun 6 12:59:58 2018 +0100
tdf#117824 switch embedded database storage away from doc on revoke
otherwise the database document still has the embedded storage
open when the attempt to remove the storage is made
Change-Id: Ie313923b969bdbc53b27b00e379ac20240ffb6e3
Reviewed-on: https://gerrit.libreoffice.org/55388
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
(cherry picked from commit a432a2e481baffa77e6f25584efbfbb3b68bc9a6)
Reviewed-on: https://gerrit.libreoffice.org/55406
Tested-by: Caolán McNamara <caolanm at redhat.com>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index bae61f7e5be1..9b29507fa46b 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -100,6 +100,7 @@
#include <com/sun/star/mail/MailAttachment.hpp>
#include <comphelper/processfactory.hxx>
#include <comphelper/property.hxx>
+#include <comphelper/storagehelper.hxx>
#include <comphelper/string.hxx>
#include <comphelper/types.hxx>
#include <mailmergehelper.hxx>
@@ -2995,11 +2996,30 @@ OUString SwDBManager::LoadAndRegisterDataSource(const OUString &rURI, const OUSt
return LoadAndRegisterDataSource_Impl( DBConnURIType::UNKNOWN, nullptr, INetURLObject(rURI), pDestDir, nullptr );
}
+namespace
+{
+ // tdf#117824 switch the embedded database away from using its current storage and point it to temporary storage
+ // which allows the original storage to be deleted
+ void switchEmbeddedDatabaseStorage(uno::Reference<sdb::XDatabaseContext>& rDatabaseContext, const OUString& rName)
+ {
+ uno::Reference<sdb::XDocumentDataSource> xDS(rDatabaseContext->getByName(rName), uno::UNO_QUERY);
+ if (!xDS)
+ return;
+ uno::Reference<document::XStorageBasedDocument> xStorageDoc(xDS->getDatabaseDocument(), uno::UNO_QUERY);
+ if (!xStorageDoc)
+ return;
+ xStorageDoc->switchToStorage(comphelper::OStorageHelper::GetTemporaryStorage());
+ }
+}
+
void SwDBManager::RevokeDataSource(const OUString& rName)
{
uno::Reference<sdb::XDatabaseContext> xDatabaseContext = sdb::DatabaseContext::create(comphelper::getProcessComponentContext());
if (xDatabaseContext->hasByName(rName))
+ {
+ switchEmbeddedDatabaseStorage(xDatabaseContext, rName);
xDatabaseContext->revokeObject(rName);
+ }
}
void SwDBManager::LoadAndRegisterEmbeddedDataSource(const SwDBData& rData, const SwDocShell& rDocShell)
More information about the Libreoffice-commits
mailing list