Forum at OOoForum.orgThe Forum
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

How to access or change the user's profile

Post new topic   Reply to topic Forum Index -> Code Snippets
View previous topic :: View next topic  
Author Message

Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Wed Jun 15, 2005 7:36 am    Post subject: How to access or change the user's profile Reply with quote

Here is an example of how to play mind games with the user's profile.

This code started from this conversation.

Sub Main
End Sub

Sub ShowUserProfile()
   oConfigData_UserProfile = GetConfigAccess( "/org.openoffice.UserProfile/Data", False )
   cCR = Chr(13)
   MsgBox      "Country: " + oConfigData_UserProfile.c _
      + cCR + "Company: " + oConfigData_UserProfile.o _
      + cCR + "Name: " + oConfigData_UserProfile.givenname _
      + cCR + "Initials: " + oConfigData_UserProfile.initials
   ' Here is a list of properties found in the schema at...
   '    /opt/OpenOffice.org1.9.104/share/registry/schema/org/openoffice/UserProfile.xcs
   ' or for some systems...
   '    C:\Program Files\ 1.9.104\share\registry\schema\org\openoffice\UserProfile.xcs
   '   o         Specifies the name of the user's company.
   '   givenname   Specifies the first name of the user.
   '   sn         Specifies the last name of the user.
   '   initials   Specifies the user's initials.
   '   street      Specifies the street where the use lives.
   '   l         Specifies the city where the user lives.
   '   st         Specifies the state where the user lives.
   '   postalcode   Specifies the user's ZIP-code.
   '   c         Specifies the country where the user lives.
   '   title      Specifies the user's title.
   '   position   Specifies the users position. This field is only present for backward compatibility. It is not defined for ldap orgPerson.
   '   homephone   Specifies the user's private telephone number.
   '   telephonenumber   Specifies the user's telephone number at work.
   '   facsimiletelephonenumber Specifies the user's fax number.
   '   mail      Specifies the user's e-mail address.
   '   UserGroup   This field is kept for backwards compatibility.
End Sub

Sub ChangeUserProfile()
   oConfigData_UserProfile = GetConfigAccess( "/org.openoffice.UserProfile/Data", True, True, False )
   ' Change the user's country.
   'oConfigData_UserProfile.c = "United States of America"
   oConfigData_UserProfile.c = "Narnia"
   ' You must quit and re-launch the office to see the changes take effect.
   ' The data will be written to...
   '   /home/danny/OpenOffice.org1.9.104/user/registry/data/org/openoffice/UserProfile.xcu
   ' or for some systems...
   '   C:\Documents and Settings\dbrewer\Application Data\OpenOffice.org1.9.104\user\registry\data\org\openoffice\UserProfile.xcu
End Sub

Function GetConfigAccess( ByVal cNodePath As String,_
                     ByVal bWriteAccess As Boolean,_
                     Optional bEnableSync,_
                     Optional bLazyWrite ) As Object
   If IsMissing( bEnableSync ) Then
      bEnableSync = True
   If IsMissing( bLazyWrite ) Then
      bLazyWrite = False

'   If bWriteAccess  And  bEnableSync Then
      oConfigProvider = GetProcessServiceManager().createInstanceWithArguments(_
                     Array( MakePropertyValue( "enableasync", bEnableSync ) ) )
'   Else
'      oConfigProvider = createUnoService( "" )
'   EndIf
   If bWriteAccess Then
      cServiceName = ""
      cServiceName = ""
   oConfigAccess = oConfigProvider.createInstanceWithArguments( cServiceName,_
      Array( MakePropertyValue( "nodepath", cNodePath ),_
            MakePropertyValue( "lazywrite", bLazyWrite ) ) )
   GetConfigAccess = oConfigAccess
End Function

Function MakePropertyValue( Optional cName As String, Optional uValue ) As
   oPropertyValue = createUnoStruct( "" )
   If Not IsMissing( cName ) Then
      oPropertyValue.Name = cName
   If Not IsMissing( uValue ) Then
      oPropertyValue.Value = uValue
   MakePropertyValue() = oPropertyValue
End Function

Apologies for more lines of comments than lines of code.

In order to translate into a lauguage, such as VB, here are some pointers.

Below is a link for the MakePropertyValue in VB.
You'll have to translate the GetConfigAccess, based on the techniques described below.

See Also....

Visual Basic

A tutorial for Programming with Visual Basic

API OpenOffice and Visual Basic

General Visual Basic document conversion of Text...

Some translation notes

A particular translation problem to VB from MacroRecorder


Danny's MakePropertyValue in Visual Basic

Calc example

Mailmerge with VB

Printing, page range

SergeM's links

Access Windows Registry from VB...

Good code example...converting documents

VB: converting Excel files to txt files
General Visual Basic document conversion of Text...

Here are some other similar examples of monkeying with the Configuration Manager data....

Configuration Manager

How to access or change the user's profile

Use System File Dialog or OOo open file dialog

Number of times you can UNDO

Get rid of product registration

* The Configuration Manager chapter of the Developer's Guide.
* My post titled: ENLARGE THE SIZE OF YOUR recent files list

* My post titled: macro to make OOo listen for UNO connections
* UnoConnectionListener

* My post titled: Development of a Basic Macro Installer

* Example of creating top level menu items
How To Add Top Level Menu

* Example of creating new toolbar items

* Duplicate Shape installable draw tool

* Brief explanation of how Config API ties to XCU files

* Explanation of custom XCS and XCU files using pkgchk

* Addon.xcs, custom configuration schema, accessing from code,
how to put xcs/xcu files into your component.

* My post titled: Musings about the Configuration Manager

* Add On Tool

Development of a Basic macro installer

How to change default fonts programatically?

Dropdown Menus in Custom Toolbars

Description of TypeDetection.xcu
Example of how to use TypeDetection on an input stream

Disabling menus items at runtime

Configuring to listen for UNO connections
* UnoConnectionListener
More about listening for uno connections, the Setup.xcu file,
and how the UnoConnectionListener macro code relates to
the Setup.xcu file.

Unanswered...possible to specify alternate configuration at launch time?

What version of OOo is running?
Installed version of SOffice
How to get the OO Version?
get the OpenOffice version
Installed version of SOffice
Want to make OOo Drawings like the colored flower design to the left?
Back to top
View user's profile Send private message
General User
General User

Joined: 04 Dec 2006
Posts: 31
Location: Morelos, Mexico

PostPosted: Tue Jul 13, 2010 3:20 pm    Post subject: Reply with quote

I want to confirm that under OO ver. 3.2.1, the only properties that are not used by the "User Data" section of the Options dialog are: 'aparment', 'fathersname', and 'UserGroup'.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic Forum Index -> Code Snippets All times are GMT - 8 Hours
Page 1 of 1

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2001, 2005 phpBB Group