How do I change the preferred mozilla address book user profile?
Table of Content
Background
OpenOffic.org features a database driver which allows access to a variety of address data sources (mozilla address data, Outlook/Outlook Express address data, LDAP data).When accessing the mozilla database, by default the first user profile found is choosen. On systems where more than one profile exists, this may not be what the user wants.
Configuration
There is a configuration entry which tells the SDBC driver accessing the address data which profile to use when logging on to mozilla (I use the term "log on" here, because for every access to any of the above-mentioned data types a connection to mozilla, which provides all the data, is necessary).Setting this entry to a mozilla profile name string forces the driver to prefer this profile – if it is existent.
This entry is located in the configuration module /org.openoffice.Office.DataAccess. There is a key /DriverSettings/com.sun.star.comp.sdbc.MozabDriver, which stores settings for the SDBC address book driver (the second part of the kay is the it's implementation name).
Thereunder, there is a key MozillaPreferences/ProfileName, which is of type string. If this string is a valid mozilla profiles name, this profile is used when logging on to mozilla.
Restrictions
As mozilla does not allow to change the profile name of a session while the session is running, after changing the configuration entry OpenOffice.org must be restarted if it already opened a mozilla session – i.e. if you already connected to any of the above-mentioned address data source types. If you did not do this before, your change in the configuration will take effect immediately.Sample Basic Macro
The following Basic function will change the configuration entry in question to the string passed to it (You can download this macro in the Tools section):Sub ChangeMozillaAddressBookProfile( sProfileName as String )
' access the global configuration provider
Dim aConfigProvider As Object
aConfigProvider = createUnoService( _
"com.sun.star.configuration.ConfigurationProvider" )
' create an access object for the driver settings key
Dim aParams(0) As new com.sun.star.beans.PropertyValue
aParams(0).Name = "nodepath"
aParams(0).Value = _
"/org.openoffice.Office.DataAccess/DriverSettings/com.sun.star.comp.sdbc.MozabDriver"
Dim aDriverSettings As Object
aDriverSettings = aConfigProvider.createInstanceWithArguments( _
"com.sun.star.configuration.ConfigurationUpdateAccess", _
aParams() )
' create an access object for the mozilla preferences node
Dim aMozPrefs As Object
aMozPrefs = aDriverSettings.getByName( "MozillaPreferences" )
' set the preferred profile name
aMozPrefs.replaceByName( "ProfileName", sProfileName )
' commit the changes done
aDriverSettings.commitChanges()
End Sub