Yan Wu wrote:
Hi Carsten,
Hi Yan,
You should use the HierarchyAccess (look at
com.sun.star.configuration.HierarchyAccess) service of the
configuration which provides a com.sun.star.beans.XMultiPropertyState
interface. There you can call setAllPropertiesToDefault(). According
to Joerg Barfurth, the inventor of the OpenOffice.org configuration
implementation, this should be possible for whole sets. It's not
clear how well this part of the implementation is tested, therefore
you have to try out.
Solution 2 or 3 are nothing one would like to implement. We clearly
need support for this kind of operation from the configuration itself.
1)Currently, we can reset an updatable property to its default state
for group nodes, which support the interfaces
com.sun.star.beans.XPropertyState and
com.sun.star.beans.XMultiPropertyStates.
2)Individual set elements can not be reset because set nodes do not
support com.sun.star.beans.XPropertyState, while the confiuration
service supporting com.sun.star.beans.XPropertyWithState can be used
to reset the set as a whole.
1) and 2) have been documented in our
DevelopersGuide(http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Config/Updating_Configuration_Data)
And I wrote a marco as following, using method
setAllPropertiesToDefault() for a group node and found it works fine.
BUT set node still can not be removed indeed, using method
setToDefaultAsProperty(). The result is just like:
<node oor:name="Windows">
<node oor:name="SplitWindow0" oor:op="remove"/>
<node oor:name="SplitWindow2" oor:op="remove"/>
<node oor:name="SplitWindow1" oor:op="remove"/>
<node oor:name="SplitWindow3" oor:op="remove"/>
</node>
Besides, to iterate over the nodes of a set doesn't work correctly
when a set node of the user layer doesn't exist in the default layer.
So I suppose the feature for retrieving default value for set nodes is
still missing in the configmgr at present. Could you investigate it
further?
REM ***** BASIC *****
Sub retrieveDefaultCfgValue
Dim rProps(1) as new com.sun.star.beans.PropertyValue
aConfigProvider =
createUnoService("com.sun.star.configuration.ConfigurationProvider")
rProps(0).Name = "nodepath"
rProps(0).Value = "org.openoffice.Office.Common"
rProps(1).Name = "locale"
rProps(1).Value = "*"
aConfig =
aConfigProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess",
rProps())
obj = aConfig.getByHierarchicalName("Misc")
if hasUnoInterfaces(obj,
"com.sun.star.beans.XMultiPropertyStates") then
obj.setAllPropertiesToDefault()
endif
aConfig.commitChanges()
rProps(0).Value = "org.openoffice.Office.Views"
aConfig =
aConfigProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess",
rProps())
obj = aConfig.getByHierarchicalName("Windows")
if hasUnoInterfaces(obj,"com.sun.star.beans.XPropertyWithState") then
obj.setToDefaultAsProperty()
endif
aConfig.commitChanges()
End Sub
Hi Yan,
Up to now I was busy with other important things. I have just read your
current findings again and now I am not completely sure that I
understood you correctly. Please answer the following questions:
1.) Is there any way to reset all nodes of a set to default values
(means that only shared nodes are visible)?
2.) The proposed way using XMultiPropertyStates doesn't work correctly?
Regards,
Carsten
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@framework.openoffice.org
For additional commands, e-mail: dev-h...@framework.openoffice.org