Fernand Vanrie wrote:
> Fernand Vanrie wrote:
>> Andreas,
>>
>> forgot my previous message
>>
>> i got the location now (i suppose after restarting OO)
>>
>> your code works fine !
> 
> but the property is "read-only"  and the goal is to change this setting
> with the API , do you see any workaround ?
> 
>>

I copied the code provided by Thomas Lange and added a new function
setOOoSetupValue, complementary to my aready mentioned getOOoSetupValue.
In getOOoSetupValue I renamed argument "sValue" to sProperty. "sValue"
was misleading since the value of the given property name is the return
value of that function.
setOOoSetupValue returns False on any kind of error. Your calling
routine may handle this (or not).
<BASIC>
> Sub test_setOOoSetupValue()
> GlobalScope.BasicLibraries.loadLibrary("myTools")
>       sNode = 
> "org.openoffice.Setup/Office/Factories/com.sun.star.text.TextDocument"
>       sProperty = "ooSetupFactoryTemplateFile"
>       sValue = "$(user)/template/Vertrag.ott"
>       print setOOoSetupValue(sNode, sProperty, sValue)
> End Sub
> 
> Function setOOoSetupValue(sNodePath$, sProperty$, sValue$) as boolean
> on error goto exitErr
> Dim bReturn as Boolean, xconfig, xAccess
> dim aArgs(0) as  Object
> dim aPropValue as new  com.sun.star.beans.PropertyValue
>       xconfig = 
> createunoservice("com.sun.star.configuration.ConfigurationProvider")
>       aPropValue.Name = "nodepath"
>       aPropValue.Value = sNodePath '"org.openoffice.Office.Linguistic"
>       aArgs(0) = aPropValue
>       xAccess = 
> xconfig.createinstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess",aArgs())
>       xAccess.setPropertyValue(sProperty, sValue)
>       xAccess.commitchanges
>       bReturn = True
> exitErr:
>       setOOoSetupValue = bReturn
> End Function
> Function getOOoSetupValue(sNodePath$,sProperty$)
> Dim aConfigProvider, oNode, args(0) As new com.sun.star.beans.PropertyValue
>       aConfigProvider = 
> createUnoService("com.sun.star.configuration.ConfigurationProvider")
>       args(0).Name = "nodepath"
>       args(0).Value = sNodePath
>       oNode = 
> aConfigProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess",
>  args())
> getOOoSetupValue = oNode.getbyname(sProperty)
> End Function
</BASIC>
The testing routine sets Writer's default template. After restarting the
office, I call "File>New>Text Document" and get the set default template.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to