incubator-odf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ashok Hariharan <as...@parliaments.info>
Subject Simple API and ODFDOM interoperability issue
Date Thu, 23 Feb 2012 12:04:47 GMT
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.
2) So recently for a particular use case, I found that Simple API provided
a useful API (namely : TextSection paragraph iteration ) .
3) I attempted using Simple API only in the context of use :
     - I load the ODF document using OdfDocument.loadDocument() (i.e. an
ODFDOM API )
     - 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 ?

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message