summaryrefslogtreecommitdiff
path: root/sw/source/uibase
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-06-06 12:59:58 +0100
committerAndras Timar <andras.timar@collabora.com>2018-06-11 15:16:37 +0200
commitfdf33e7f00e8d7e90183a89de54e36c4ec615f90 (patch)
treef9b46e621266e723f4e72b84fefbf2c6a09bd897 /sw/source/uibase
parent92f0922f320d7cb1cb1e735d2c20dd4f1ec0705d (diff)
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@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> (cherry picked from commit a432a2e481baffa77e6f25584efbfbb3b68bc9a6) Reviewed-on: https://gerrit.libreoffice.org/55407 Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> (cherry picked from commit 9ae93085c90bdd00bcbf796ab399154bb7ab9e39)
Diffstat (limited to 'sw/source/uibase')
-rw-r--r--sw/source/uibase/dbui/dbmgr.cxx20
1 files changed, 20 insertions, 0 deletions
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index a5269e241dd4..861504c28031 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>
@@ -2916,11 +2917,30 @@ OUString SwDBManager::LoadAndRegisterDataSource(const OUString &rURI, const OUSt
return LoadAndRegisterDataSource_Impl( DBConnURIType::UNKNOWN, nullptr, INetURLObject(rURI), nullptr, 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)