// XIndexAccess interface
XIndexAccess xNum = (XIndexAccess) UnoRuntime.queryInterface( XIndexAccess.class,
mxDocFactory.createInstance( "com.sun.star.text.NumberingRules" ) );
// Also get the NumberingRule's XIndexReplace interface
XIndexReplace xReplace = (XIndexReplace) UnoRuntime.queryInterface(
XIndexReplace.class, xNum );
// Create an array of XPropertySets, one for each of the three paragraphs we're about
// to create
XPropertySet xParas[] = new XPropertySet [ 3 ];
for ( int i = 0 ; i < 3 ; ++ i )
{
// Create a new paragraph
XTextContent xNewPara = (XTextContent) UnoRuntime.queryInterface(
XTextContent.class, mxDocFactory.createInstance(
"com.sun.star.text.Paragraph" ) );
// Get the XPropertySet interface of the new paragraph and put it in our array
xParas[i] = (XPropertySet) UnoRuntime.queryInterface(
XPropertySet.class, xNewPara );
// Insert the new paragraph into the document after the fish section. As it is
// an insert
// relative to the fish section, the first paragraph inserted will be below
// the next two
xRelative.insertTextContentAfter ( xNewPara, mxFishSection );
// Separate from the above, but also needs to be done three times
// Get the PropertyValue sequence for this numbering level
PropertyValue [] aProps = (PropertyValue [] ) xNum.getByIndex ( i );
// Iterate over the PropertyValue's for this numbering level, looking for the
// 'NumberingType' property
for ( int j = 0 ; j < aProps.length ; ++j )
{
if ( aProps[j].Name.equals ( "NumberingType" ) )
{
// Once we find it, set it's value to a new type,
// dependent on which
// numbering level we're currently on
switch ( i )
{
case 0 : aProps[j].Value =
new Short(NumberingType.ROMAN_UPPER);
break;
case 1 : aProps[j].Value =
new Short(NumberingType.CHARS_UPPER_LETTER);
break;
case 2 : aProps[j].Value =
new Short(NumberingType.ARABIC);
break;
}
// Put the updated PropertyValue sequence back into the
// NumberingRules service
xReplace.replaceByIndex ( i, aProps );
break;
}
}
}
// Get the XParagraphCursor interface of our text cursro