[Solved] Java - Getting the number of a paragraph

Java, C++, C#, Delphi, ??? - Using the UNO bridges

[Solved] Java - Getting the number of a paragraph

Postby stibbons » Tue Jun 12, 2012 2:31 pm

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
stibbons
 
Posts: 2
Joined: Tue Jun 12, 2012 2:18 pm

Re: Java - Getting the number of a paragraph

Postby Charlie Young » Tue Jun 12, 2012 11:06 pm

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
User avatar
Charlie Young
Volunteer
 
Posts: 1559
Joined: Fri May 14, 2010 1:07 am

Re: Java - Getting the number of a paragraph

Postby stibbons » Wed Jun 13, 2012 4:59 pm

This works - thanks.
OpenOffice 3.3 on Windows XP
stibbons
 
Posts: 2
Joined: Tue Jun 12, 2012 2:18 pm

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

Postby Charlie Young » Wed Jun 13, 2012 6:18 pm

I'm still playing with this actually.

There is also a NumberingIsNumber property.

Code: Select all   Expand viewCollapse view
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
User avatar
Charlie Young
Volunteer
 
Posts: 1559
Joined: Fri May 14, 2010 1:07 am


Return to External Programs

Who is online

Users browsing this forum: No registered users and 3 guests