Hi. I am trying to generate a index in a text document via UNO java API.
I am at a good point, but I need to generate the index from outline,
using custom Paragraph Style in association to Numbering Levels.

When I do this via OOo gui I execute these steps:
Insert -> Indexes and Tables
Check create from "Outline" checkbox and press on the "..." button.
Select Level 1 and change the associated Paragraph Style to a custom one.

Ok, I want to make this via UNO. I have some code that actually create
the index but it is empty cause associations are default ones, I need
to use custom ones.
Here I start:

        XMultiServiceFactory xmDocFactory = (XMultiServiceFactory) UnoRuntime
                .queryInterface(XMultiServiceFactory.class, textDocument);
        XPropertySet xIndex = (XPropertySet) UnoRuntime.queryInterface(
                XPropertySet.class, xmDocFactory
                        .createInstance("com.sun.star.text.ContentIndex"));
        xIndex.setPropertyValue("Level", new Short((short) 10));

I can read all propertySetInfo of the xIndex and they are
BackColor
BackGraphicFilter
BackGraphicLocation
[...]

Now I am a little confuse. I have set:

        xIndex.setPropertyValue("CreateFromOutline", Boolean.TRUE);
        xIndex.setPropertyValue("CreateFromLevelParagraphStyles", Boolean.TRUE);

but I do not know how to change Numbering Level -> Paragraph Style associations.

I think I need one of these two:

        XIndexReplace levelFormat = (XIndexReplace) UnoRuntime.queryInterface(
                XIndexReplace.class, xIndex.getPropertyValue("LevelFormat"));
        PropertyValue[][] byIndex = (PropertyValue[][]) 
levelFormat.getByIndex(0);
        assertEquals(0, byIndex.length);

        XIndexReplace levelParagraphStyle = (XIndexReplace) 
UnoRuntime.queryInterface(
                XIndexReplace.class, 
xIndex.getPropertyValue("LevelParagraphStyles"));
        assertEquals(10, levelParagraphStyle.getCount());

The assertions passes, but I do not know how to read/write correctly
to the XIndexReplace, nor what is the right one to use.
I think that LevelParagraphStyle is where I have to replace values, but how?

I also suspect that I could use com.sun.star.text.ChapterNumberingRule
but I do not know how to get it and how to use it.

I got here using mostly the reference doc here:
http://api.openoffice.org/docs/DevelopersGuide/Text/Text.xhtml
and I can't figure out how to go on.

Any help is appreciated :)
Thanks.

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

Reply via email to