[Solved] Java - Getting the number of a paragraph

Java, C++, C#, Delphi... - Using the UNO bridges
Post Reply
stibbons
Posts: 2
Joined: Tue Jun 12, 2012 2:18 pm

[Solved] Java - Getting the number of a paragraph

Post by stibbons »

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.
Last edited by stibbons on Wed Jun 13, 2012 5:00 pm, edited 5 times in total.
OpenOffice 3.3 on Windows XP
User avatar
Charlie Young
Volunteer
Posts: 1559
Joined: Fri May 14, 2010 1:07 am

Re: Java - Getting the number of a paragraph

Post by Charlie Young »

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.
I think you want to look at each element's "ListLabelString" property.
Apache OpenOffice 4.1.1
Windows XP
stibbons
Posts: 2
Joined: Tue Jun 12, 2012 2:18 pm

Re: Java - Getting the number of a paragraph

Post by stibbons »

This works - thanks.
OpenOffice 3.3 on Windows XP
User avatar
Charlie Young
Volunteer
Posts: 1559
Joined: Fri May 14, 2010 1:07 am

Re: [Solved] Java - Getting the number of a paragraph

Post by Charlie Young »

I'm still playing with this actually.

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
Post Reply