OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org 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    OOoForum.org Forum Index -> OpenOffice.org Code Snippets
View previous topic :: View next topic  
Author Message
DannyB
Moderator
Moderator


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.
http://www.oooforum.org/forum/viewtopic.phtml?p=82006#82006



Code:
Sub Main
   ShowUserProfile()
   'ChangeUserProfile()
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\OpenOffice.org 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.
   oConfigData_UserProfile.commitChanges()
   
   ' 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
   EndIf
   If IsMissing( bLazyWrite ) Then
      bLazyWrite = False
   EndIf

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


Function MakePropertyValue( Optional cName As String, Optional uValue ) As com.sun.star.beans.PropertyValue
   oPropertyValue = createUnoStruct( "com.sun.star.beans.PropertyValue" )
   If Not IsMissing( cName ) Then
      oPropertyValue.Name = cName
   EndIf
   If Not IsMissing( uValue ) Then
      oPropertyValue.Value = uValue
   EndIf
   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 OpenOffice.org with Visual Basic
http://www.oooforum.org/forum/viewtopic.php?t=11854

API OpenOffice and Visual Basic
http://www.oooforum.org/forum/viewtopic.php?t=11439

http://www.oooforum.org/forum/viewtopic.php?t=4968
http://www.oooforum.org/forum/viewtopic.php?p=12256#12256
http://www.oooforum.org/forum/viewtopic.php?t=4587

General Visual Basic document conversion of Text...
http://www.oooforum.org/forum/viewtopic.php?p=22034#22034

Some translation notes
http://www.oooforum.org/forum/viewtopic.php?t=5217

A particular translation problem to VB from MacroRecorder
http://www.oooforum.org/forum/viewtopic.php?t=4956

Scripting.FileSystemObject
http://www.oooforum.org/forum/viewtopic.php?t=1669

http://www.oooforum.org/forum/viewtopic.php?p=13834#13834

http://www.oooforum.org/forum/viewtopic.php?t=3993
http://www.oooforum.org/forum/viewtopic.php?t=4038
http://www.oooforum.org/forum/viewtopic.php?t=3976
http://www.oooforum.org/forum/viewtopic.php?t=3893
http://www.oooforum.org/forum/viewtopic.php?t=3194

Danny's MakePropertyValue in Visual Basic
http://www.oooforum.org/forum/viewtopic.php?p=22029#22029
PropertyValue
http://www.oooforum.org/forum/viewtopic.php?t=3453
http://www.oooforum.org/forum/viewtopic.php?p=12231
http://www.oooforum.org/forum/viewtopic.php?p=12259#12259
Bridge_GetStruct
http://www.oooforum.org/forum/viewtopic.php?t=3510

Calc example
http://www.oooforum.org/forum/viewtopic.php?p=14408#14408
http://www.oooforum.org/forum/viewtopic.php?t=3554

Mailmerge with VB
http://www.oooforum.org/forum/viewtopic.php?t=3313

Printing, page range
http://www.oooforum.org/forum/viewtopic.php?t=5124

SergeM's links
http://www.oooforum.org/forum/viewtopic.php?t=5816

Access Windows Registry from VB...
http://www.oooforum.org/forum/viewtopic.php?t=6221
http://www.oooforum.org/forum/viewtopic.php?t=6768

Good code example...converting documents
http://www.oooforum.org/forum/viewtopic.php?t=7673


VB: converting Excel files to txt files
http://www.oooforum.org/forum/viewtopic.php?t=3194
General Visual Basic document conversion of Text...
http://www.oooforum.org/forum/viewtopic.php?p=22034#22034











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


Configuration Manager
=====================

How to access or change the user's profile
http://www.oooforum.org/forum/viewtopic.phtml?t=21107

Use System File Dialog or OOo open file dialog
http://www.oooforum.org/forum/viewtopic.phtml?p=71961#71961

Number of times you can UNDO
http://www.oooforum.org/forum/viewtopic.php?p=45487#45487

Get rid of product registration
http://www.oooforum.org/forum/viewtopic.php?t=2267

* The Configuration Manager chapter of the Developer's Guide.
* My post titled: ENLARGE THE SIZE OF YOUR recent files list
http://www.oooforum.org/forum/viewtopic.php?t=3559

* My post titled: FYI...new macro to make OOo listen for UNO connections
* UnoConnectionListener
http://www.oooforum.org/forum/viewtopic.php?t=3754

* My post titled: Development of a Basic Macro Installer
http://www.oooforum.org/forum/viewtopic.php?t=4255

* Example of creating top level menu items
http://www.oooforum.org/forum/viewtopic.php?t=6310
How To Add Top Level Menu
http://www.oooforum.org/forum/viewtopic.phtml?t=16759

* Example of creating new toolbar items
http://www.oooforum.org/forum/viewtopic.php?p=29341#29341

* Duplicate Shape installable draw tool
http://www.ooomacros.org/user.php#115800

* Brief explanation of how Config API ties to XCU files
http://www.oooforum.org/forum/viewtopic.php?p=24558#24558

* Explanation of custom XCS and XCU files using pkgchk
http://www.oooforum.org/forum/viewtopic.php?p=27922#27922

* Addon.xcs, custom configuration schema, accessing from code,
how to put xcs/xcu files into your component.
http://www.oooforum.org/forum/viewtopic.php?p=62655#62655

* My post titled: Musings about the Configuration Manager
http://www.oooforum.org/forum/viewtopic.php?t=4028

* Add On Tool
http://www.oooforum.org/forum/viewtopic.php?t=4059

Development of a Basic macro installer
http://www.oooforum.org/forum/viewtopic.php?t=4255

How to change default fonts programatically?
http://www.oooforum.org/forum/viewtopic.php?p=16982#16982

Dropdown Menus in Custom Toolbars
http://www.oooforum.org/forum/viewtopic.php?t=4008

TypeDetection.xml
http://www.oooforum.org/forum/viewtopic.php?t=3692
Description of TypeDetection.xcu
http://www.oooforum.org/forum/viewtopic.php?t=10111
Example of how to use TypeDetection on an input stream
http://www.oooforum.org/forum/viewtopic.phtml?p=80918#80918

Disabling menus items at runtime
http://www.oooforum.org/forum/viewtopic.php?t=3558

Configuring to listen for UNO connections
http://www.oooforum.org/forum/viewtopic.php?p=12370#12370
http://www.oooforum.org/forum/viewtopic.php?t=9768
* UnoConnectionListener
http://www.oooforum.org/forum/viewtopic.php?t=3754
More about listening for uno connections, the Setup.xcu file,
and how the UnoConnectionListener macro code relates to
the Setup.xcu file.
http://www.oooforum.org/forum/viewtopic.phtml?p=79020#79020

Unanswered...possible to specify alternate configuration at launch time?
http://www.oooforum.org/forum/viewtopic.php?t=6798

What version of OOo is running?
Installed version of SOffice
http://www.oooforum.org/forum/viewtopic.php?p=37431
How to get the OO Version?
http://www.oooforum.org/forum/viewtopic.phtml?t=19060
get the OpenOffice version
http://www.oooforum.org/forum/viewtopic.php?t=12008
Installed version of SOffice
http://www.oooforum.org/forum/viewtopic.phtml?t=10003
_________________
Want to make OOo Drawings like the colored flower design to the left?
Back to top
View user's profile Send private message
jcd
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    OOoForum.org Forum Index -> OpenOffice.org 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