Hi,
I need to enumerate through paragraphs in a text document and process all numbered ones. I have hard times reading the API documentation and so far, I'm unable to find any way to obtain the number of a paragraph. Can anyone post a code that can do this? I use XEnumerationAccess to go through paragraphs.
Regards.
[Solved] Java - Getting the number of a paragraph
[Solved] Java - Getting the number of a paragraph
Last edited by stibbons on Wed Jun 13, 2012 5:00 pm, edited 5 times in total.
OpenOffice 3.3 on Windows XP
- Charlie Young
- Volunteer
- Posts: 1559
- Joined: Fri May 14, 2010 1:07 am
Re: Java - Getting the number of a paragraph
I think you want to look at each element's "ListLabelString" property.stibbons wrote:Hi,
I need to enumerate through paragraphs in a text document and process all numbered ones. I have hard times reading the API documentation and so far, I'm unable to find any way to obtain the number of a paragraph. Can anyone post a code that can do this? I use XEnumerationAccess to go through paragraphs.
Regards.
Apache OpenOffice 4.1.1
Windows XP
Windows XP
- Charlie Young
- Volunteer
- Posts: 1559
- Joined: Fri May 14, 2010 1:07 am
Re: [Solved] Java - Getting the number of a paragraph
I'm still playing with this actually.
There is also a NumberingIsNumber property.
There is also a NumberingIsNumber property.
Code: Select all
oDoc = UnoRuntime.queryInterface(XModel,XSCRIPTCONTEXT.getInvocationContext());
if ( !oDoc )
oDoc = XSCRIPTCONTEXT.getDocument();
xTextDoc = UnoRuntime.queryInterface(XTextDocument,oDoc);
xText = xTextDoc.getText();
xEnumerationAccess = UnoRuntime.queryInterface(XEnumerationAccess, xText);
xEnumeration = xEnumerationAccess.createEnumeration();
while(xEnumeration.hasMoreElements())
{
NextOne = xEnumeration.nextElement();
NextNumber = UnoRuntime.queryInterface(XPropertySet, NextOne);
isitNumbered = NextNumber.getPropertyValue("NumberingIsNumber");
//isitNumbered isn't java Boolean, so can't use it directly.
isNumbered = (isitNumbered.toString() == "true");
if(isNumbered) {
//process numbered paragraph.
}
}
Apache OpenOffice 4.1.1
Windows XP
Windows XP