incubator-odf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Svante Schubert <>
Subject Re: Simple API and ODFDOM interoperability issue
Date Thu, 23 Feb 2012 23:48:28 GMT
Hi Ashok,

On 23.02.2012 13:04, Ashok Hariharan wrote:
> I am having an issue related to Simple API and ODFDOM interoperability ...
> My use case for ODFDOM and Simple API is a bit unusual :
> 1) We have been using ODFDOM for quite a while now for ODF processing, so
> we have helper APIs built on top of ODFDOM.
We all build such a helper API, once. Earlier it was called Document
API, the doc Java package of ODFDOM, wrapping the XML details from the
user. Later IBM forked this away to the Simple API and finally we
rejoined here again.
> 2) So recently for a particular use case, I found that Simple API provided
> a useful API (namely : TextSection paragraph iteration ) .
Simple API is the high level view you should be looking at. DOC API will
be removed soon by Devin, when we are certain we offer users similar
functionality with Simple and not loosing functionality (see automatic
style handling below).
> 3) I attempted using Simple API only in the context of use :
>      - I load the ODF document using OdfDocument.loadDocument() (i.e. an
>      - I iterate through the TextSectionElement in the file
>      - for each TextSectionElement i want to iterate the paragraphs, so i
> thought :
>            - Section.getInstance(TextSectionElement obj) would work , but
> it fails because :
> public static Section getInstance(TextSectionElement element) {
>     return new Section((Document) ((OdfFileDom)
> (element.getOwnerDocument())).getDocument(), element);
> }
> The API does a cast to simple API Document, while the TextSectionElement is
> from a underlying OdfTextDocument, I get a classcast exception :
> """
>  java.lang.ClassCastException:
> org.odftoolkit.odfdom.doc.OdfTextDocument cannot be cast to
> org.odftoolkit.simple.Document
> """
> Instead of assuming that the input document is always a Simple Document
> type , shouldnt the cast be more dynamic, and cast based on the type of the
> owner document ?  Or is this by design the APIs are not intended to be
> interoperable ?
Not intended to be interoperable it was a fork.
But forget the DOC API and move it over to Simple. If there is something
missing in Simple discuss it on the list.
IMHO an easy access to ODF automatic styles is still missing. Automatic
styles (or the hashmap of them) are an implementation detail and should
therefore not be part of the Simple API and are yet part of DOC to be
Therefore they should be generated into ODFDOM. Easy. Simply telling the
generator, whenever an element with multiple children exist, which have
an ID (or attributes we specify as ID - e.g. style:name and
style:family) a hash-map is being prepared for the parent and created &
filled during first access. Unfortunately this bold plan is blocked by

Long story short, stick with Simple, help to extend it, like
recontribute your helper API back to this project so we might grow.


View raw message