diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-06-02 08:55:03 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-06-02 09:20:02 +0200 |
commit | 290cc96e98c8d66396402f9be51739646b1eafa7 (patch) | |
tree | a6e1cbb86663478b98d425b494c06c18f39555e9 /sw | |
parent | 3dc2080588a13cce7c9cca9621dfc0974c48ae60 (diff) |
SwDBManager: refer embedded data source from doc settings
So that next time the document is loaded, we can find it.
With this, the MM wizard can create embedded data source definitions
which can be saved / loaded back from/to ODF properly.
Change-Id: I5d012ce7fe878bb23ef6dac4526254cbee2683fb
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/doc/doc.cxx | 8 | ||||
-rw-r--r-- | sw/source/uibase/dbui/dbmgr.cxx | 6 |
2 files changed, 13 insertions, 1 deletions
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index c65309fec097..b427c93430f9 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -495,7 +495,13 @@ void SwDoc::ChgDBData(const SwDBData& rNewData) if( rNewData != maDBData ) { if (maDBData.sEmbeddedName != rNewData.sEmbeddedName && GetDocShell()) - SwDBManager::LoadAndRegisterEmbeddedDataSource(rNewData, *GetDocShell()); + { + uno::Reference<embed::XStorage> xStorage = GetDocShell()->GetStorage(); + // It's OK that we don't have the named sub-storage yet, in case + // we're in the process of creating it. + if (xStorage->hasByName(rNewData.sEmbeddedName)) + SwDBManager::LoadAndRegisterEmbeddedDataSource(rNewData, *GetDocShell()); + } maDBData = rNewData; getIDocumentState().SetModified(); diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx index 5f5c703723dd..38996db38074 100644 --- a/sw/source/uibase/dbui/dbmgr.cxx +++ b/sw/source/uibase/dbui/dbmgr.cxx @@ -2642,6 +2642,12 @@ OUString SwDBManager::LoadAndRegisterDataSource(const DBConnURITypes type, const {"TargetStorage", uno::makeAny(xStorage)}, {"StreamRelPath", uno::makeAny(aStreamRelPath)} }); + + // Refer to the sub-storage name in the document settings, so + // we can load it again next time the file is imported. + uno::Reference<lang::XMultiServiceFactory> xFactory(pDocShell->GetModel(), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xPropertySet(xFactory->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY); + xPropertySet->setPropertyValue("EmbeddedDatabaseName", uno::makeAny(aStreamRelPath)); } xStore->storeAsURL(sTmpName, aSequence); } |