[Libreoffice-commits] core.git: sw/source

Miklos Vajna vmiklos at collabora.co.uk
Thu Jun 11 00:50:26 PDT 2015


 sw/source/uibase/dbui/dbmgr.cxx |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

New commits:
commit 12783429cfa5984adf02efdfcbe6e1653d58365f
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Jun 11 09:42:29 2015 +0200

    SwDBManager: avoid registering two data sources when creating an emebedded one
    
    SwDBManager::LoadAndRegisterDataSource() calls
    SwXDocumentSettings::setPropertyValue() to set its EmbeddedDatabaseName
    UNO property, when creating the embedded data source definition. OTOH,
    during load, SwXDocumentSettings calls
    SwDBManager::LoadAndRegisterEmbeddedDataSource() to register the data
    source. The result is that when creating the embedded definition using
    the MM wizard, we registered two data sources.
    
    Fix the problem by first setting the UNO property, and only then storing
    the data source definition.
    
    Change-Id: I3efc141d9ab94828007a48a8bf5949b4f3b6510a

diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index 48077f6..eb2c9c0 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -2692,13 +2692,14 @@ OUString SwDBManager::LoadAndRegisterDataSource(const DBConnURITypes type, const
                 OUString aStreamRelPath = "EmbeddedDatabase";
                 uno::Reference<embed::XStorage> xStorage = pDocShell->GetStorage();
 
-                SwDBManager::StoreEmbeddedDataSource(xStore, xStorage, aStreamRelPath, aOwnURL);
-
                 // 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));
+
+                // Store it only after setting the above property, so that only one data source gets registered.
+                SwDBManager::StoreEmbeddedDataSource(xStore, xStorage, aStreamRelPath, aOwnURL);
             }
         }
         xDBContext->registerObject( sFind, xNewInstance );


More information about the Libreoffice-commits mailing list