From bf38dd800e6e4e820a0cef84e082d9bcee8e8133 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Wed, 8 Dec 2021 19:12:05 +0200 Subject: Simplify some Optional handling Change-Id: I2ba326faa47531c1d7c71ac05a8dd211cebac199 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126513 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- wizards/source/tools/Misc.xba | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/wizards/source/tools/Misc.xba b/wizards/source/tools/Misc.xba index 2f06e92a5938..9aa6d2e2f380 100644 --- a/wizards/source/tools/Misc.xba +++ b/wizards/source/tools/Misc.xba @@ -58,7 +58,7 @@ End Function ' Connects to a registered Database -Function ConnecttoDatabase(DSName as String, UserID as String, Password as String, Optional Propertylist(), Optional DriverProperties() as New com.sun.star.beans.PropertyValue) +Function ConnectToDatabase(DSName as String, UserID as String, Password as String, Optional Propertylist(), Optional DriverProperties() as New com.sun.star.beans.PropertyValue) Dim oDBContext as Object Dim oDBSource as Object ' On Local Error Goto NOCONNECTION @@ -68,11 +68,7 @@ Dim oDBSource as Object ConnectToDatabase = oDBSource.GetConnection(UserID, Password) Else If Not IsMissing(Propertylist()) Then - If Not IsMissing(DriverProperties()) Then - RegisterNewDataSource(DSName, PropertyList(), DriverProperties()) - Else - RegisterNewDataSource(DSName, PropertyList()) - End If + RegisterNewDataSource(DSName, PropertyList(), DriverProperties()) oDBSource = oDBContext.GetByName(DSName) ConnectToDatabase = oDBSource.GetConnection(UserID, Password) Else @@ -114,14 +110,11 @@ Dim aNodePath(0) as new com.sun.star.beans.PropertyValue oConfigProvider = createUnoService("com.sun.star.configuration.ConfigurationProvider") aNodePath(0).Name = "nodepath" aNodePath(0).Value = sKeyName - If IsMissing(bForUpdate) Then - GetRegistryKeyContent() = oConfigProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", aNodePath()) + If IsMissing(bForUpdate) Then bForUpdate = False + If bForUpdate Then + GetRegistryKeyContent() = oConfigProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess", aNodePath()) Else - If bForUpdate Then - GetRegistryKeyContent() = oConfigProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess", aNodePath()) - Else - GetRegistryKeyContent() = oConfigProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", aNodePath()) - End If + GetRegistryKeyContent() = oConfigProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", aNodePath()) End If End Function -- cgit