Kaydet (Commit) d611b2e0 authored tarafından Miklos Vajna's avatar Miklos Vajna

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
üst b79017f4
...@@ -376,6 +376,9 @@ public: ...@@ -376,6 +376,9 @@ public:
/// Load the embedded data source of the document and also register it. /// Load the embedded data source of the document and also register it.
void LoadAndRegisterEmbeddedDataSource(const SwDBData& rData, const SwDocShell& rDocShell); 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. /** 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. If this is not possible, the data source will be created through its name.
@param _xConnection @param _xConnection
......
...@@ -540,6 +540,11 @@ SwDoc::~SwDoc() ...@@ -540,6 +540,11 @@ SwDoc::~SwDoc()
mpCharFormatTable->erase( mpCharFormatTable->begin() ); mpCharFormatTable->erase( mpCharFormatTable->begin() );
#if HAVE_FEATURE_DBCONNECTIVITY #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 ); DELETEZ( mpDBManager );
#endif #endif
......
...@@ -2663,6 +2663,13 @@ OUString SwDBManager::LoadAndRegisterDataSource(const OUString &rURI, const OUSt ...@@ -2663,6 +2663,13 @@ OUString SwDBManager::LoadAndRegisterDataSource(const OUString &rURI, const OUSt
return LoadAndRegisterDataSource( type, aURLAny, pSettings, rURI, pPrefix, pDestDir ); 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) void SwDBManager::LoadAndRegisterEmbeddedDataSource(const SwDBData& rData, const SwDocShell& rDocShell)
{ {
uno::Reference<sdb::XDatabaseContext> xDatabaseContext = sdb::DatabaseContext::create(comphelper::getProcessComponentContext()); uno::Reference<sdb::XDatabaseContext> xDatabaseContext = sdb::DatabaseContext::create(comphelper::getProcessComponentContext());
...@@ -2673,8 +2680,7 @@ void SwDBManager::LoadAndRegisterEmbeddedDataSource(const SwDBData& rData, const ...@@ -2673,8 +2680,7 @@ void SwDBManager::LoadAndRegisterEmbeddedDataSource(const SwDBData& rData, const
if (sDataSource.isEmpty()) if (sDataSource.isEmpty())
sDataSource = "EmbeddedDatabase"; sDataSource = "EmbeddedDatabase";
if (xDatabaseContext->hasByName(rData.sDataSource)) SwDBManager::RevokeDataSource(rData.sDataSource);
xDatabaseContext->revokeObject(rData.sDataSource);
// Encode the stream name and the real path into a single URL. // Encode the stream name and the real path into a single URL.
const INetURLObject& rURLObject = rDocShell.GetMedium()->GetURLObject(); const INetURLObject& rURLObject = rDocShell.GetMedium()->GetURLObject();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment