summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-06-03 19:11:57 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-06-03 19:29:07 +0200
commitd611b2e0b2b713ffaf8b2ec75e6a74180316f50b (patch)
treeb17d096058f94ee99757609dd29f26da5897f887
parentb79017f49a487a3981b1cd9f488ed5062eeb880b (diff)
sw: add SwDBManager::RevokeDataSource()
And call it from the SwDoc dtor, so that embedded data source definitions registered on opening are deregistered on close. Change-Id: I40309389d44dcbc225f6f2ef98bb20579e12d650
-rw-r--r--sw/inc/dbmgr.hxx3
-rw-r--r--sw/source/core/doc/docnew.cxx5
-rw-r--r--sw/source/uibase/dbui/dbmgr.cxx10
3 files changed, 16 insertions, 2 deletions
diff --git a/sw/inc/dbmgr.hxx b/sw/inc/dbmgr.hxx
index e397e5777373..657e957e1e68 100644
--- a/sw/inc/dbmgr.hxx
+++ b/sw/inc/dbmgr.hxx
@@ -376,6 +376,9 @@ public:
/// Load the embedded data source of the document and also register it.
void LoadAndRegisterEmbeddedDataSource(const SwDBData& rData, const SwDocShell& rDocShell);
+ /// Unregister a data source.
+ static void RevokeDataSource(const OUString& rName);
+
/** try to get the data source from the given connection through the XChild interface.
If this is not possible, the data source will be created through its name.
@param _xConnection
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index ec44cb506d9b..302ebefd8b9e 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -540,6 +540,11 @@ SwDoc::~SwDoc()
mpCharFormatTable->erase( mpCharFormatTable->begin() );
#if HAVE_FEATURE_DBCONNECTIVITY
+ // On load, SwDBManager::setEmbeddedName() may register a data source.
+ // If we have an embedded one, then sDataSoure points to the registered name, so revoke it here.
+ if (!mpDBManager->getEmbeddedName().isEmpty() && !maDBData.sDataSource.isEmpty())
+ SwDBManager::RevokeDataSource(maDBData.sDataSource);
+
DELETEZ( mpDBManager );
#endif
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index b138730f5c46..d59d78be73a4 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -2663,6 +2663,13 @@ OUString SwDBManager::LoadAndRegisterDataSource(const OUString &rURI, const OUSt
return LoadAndRegisterDataSource( type, aURLAny, pSettings, rURI, pPrefix, pDestDir );
}
+void SwDBManager::RevokeDataSource(const OUString& rName)
+{
+ uno::Reference<sdb::XDatabaseContext> xDatabaseContext = sdb::DatabaseContext::create(comphelper::getProcessComponentContext());
+ if (xDatabaseContext->hasByName(rName))
+ xDatabaseContext->revokeObject(rName);
+}
+
void SwDBManager::LoadAndRegisterEmbeddedDataSource(const SwDBData& rData, const SwDocShell& rDocShell)
{
uno::Reference<sdb::XDatabaseContext> xDatabaseContext = sdb::DatabaseContext::create(comphelper::getProcessComponentContext());
@@ -2673,8 +2680,7 @@ void SwDBManager::LoadAndRegisterEmbeddedDataSource(const SwDBData& rData, const
if (sDataSource.isEmpty())
sDataSource = "EmbeddedDatabase";
- if (xDatabaseContext->hasByName(rData.sDataSource))
- xDatabaseContext->revokeObject(rData.sDataSource);
+ SwDBManager::RevokeDataSource(rData.sDataSource);
// Encode the stream name and the real path into a single URL.
const INetURLObject& rURLObject = rDocShell.GetMedium()->GetURLObject();