Apache OpenOffice (AOO) Bugzilla – Issue 71060
Filter needs method to iterate over all objects in Writer document in order
Last modified: 2013-02-07 22:35:39 UTC
Chapter 7 of the developers guide discusses iterating over text in a Writer document. In particular: "Paragraphs also have an com.sun.star.container.XEnumerationAccess of their own. They can enumerate every single text portion that they contain. A text portion is a text range containing a uniform piece of information that appears within the text flow. An ordinary paragraph, formatted in a uniform manner and containing nothing but a string, enumerates just a single text portion. In a paragraph that has specially formatted words or other contents, the text portion enumeration returns one com.sun.star.text.TextPortion service for each differently formatted string, and for every other text content. Text portions include the service com.sun.star.text.TextRange and have the properties listed below:" Thus objects anchored at a character, such as graphic objects, can be found in their logical order by iterating over the containing paragraph, but objects such as graphic objects, that are anchored at a paragraph are not returned when iterating over the paragraphs of the document using the code illustration: // Here, we access this interface XEnumerationAccess xParaAccess = (XEnumerationAccess) UnoRuntime.queryInterface( XEnumerationAccess.class, mxDocText); // Call the XEnumerationAccess's only method to access the actual Enumeration XEnumeration xParaEnum = xParaAccess.createEnumeration(); // While there are paragraphs, do things to them while (xParaEnum.hasMoreElements()) { } There appears to be no documented method to iterate over all objects in a Writer document in order as is required for a filter. Ian
Such a method could be a nice enhancement.