/// Internal method to recursively browse a structural element in preorder
public void browseElementRecursively( XInterface xElement, IConfigurationProcessor aProcessor )
throws com.sun.star.uno.Exception
{
// First process this as an element (preorder traversal)
XHierarchicalName xElementPath =
(XHierarchicalName) UnoRuntime.queryInterface(XHierarchicalName.class, xElement);
if ( null == xElementPath )
return;
String sPath = xElementPath.getHierarchicalName();
aProcessor.processStructuralElement( sPath, xElement);
// now process this as a container
XNameAccess xChildAccess =
(XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, xElement);
// get a list of child elements
String[] aElementNames = xChildAccess.getElementNames();
// and process them one by one
for(int i=0; i< aElementNames.length; ++i)
{
Object aChild = xChildAccess.getByName( aElementNames[i] );
AnyConverter aAnyConv = new AnyConverter();
// is it a structural element (object) ...
if ( aAnyConv.isObject(aChild) )
{
// then get an interface
XInterface xChildElement = (XInterface)UnoRuntime.queryInterface(XInterface.class, aChild);
// and continue processing child elements recursively
browseElementRecursively( xChildElement, aProcessor );
}
// ... or is it a simple value
else
{
// Build the path to it from the path of
// the element and the name of the child
String sChildPath;
sChildPath =
xElementPath.composeHierarchicalName(aElementNames[i]);
// and process the value
aProcessor.processValueElement( sChildPath, aChild );
}
}