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

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
üst 3dc20805
...@@ -495,7 +495,13 @@ void SwDoc::ChgDBData(const SwDBData& rNewData) ...@@ -495,7 +495,13 @@ void SwDoc::ChgDBData(const SwDBData& rNewData)
if( rNewData != maDBData ) if( rNewData != maDBData )
{ {
if (maDBData.sEmbeddedName != rNewData.sEmbeddedName && GetDocShell()) 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; maDBData = rNewData;
getIDocumentState().SetModified(); getIDocumentState().SetModified();
......
...@@ -2642,6 +2642,12 @@ OUString SwDBManager::LoadAndRegisterDataSource(const DBConnURITypes type, const ...@@ -2642,6 +2642,12 @@ OUString SwDBManager::LoadAndRegisterDataSource(const DBConnURITypes type, const
{"TargetStorage", uno::makeAny(xStorage)}, {"TargetStorage", uno::makeAny(xStorage)},
{"StreamRelPath", uno::makeAny(aStreamRelPath)} {"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); xStore->storeAsURL(sTmpName, aSequence);
} }
......
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