incubator-odf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Devin Han <devin...@apache.org>
Subject Re: OdfDrawImage from OdfTableCell
Date Mon, 05 Dec 2011 03:20:03 GMT
2011/12/4 Peter Meulmeester <p.meulmeester@gmail.com>

> Hi Devin,
>
> Ok, thank, I did not read anywhere that the ODFDOM was deprecated.
>
>
ODFDOM is not deprecated, just the doc convenient API. See the chart in
this link[1], Simple API replaces the position of "ODF Document API".
Actually, Simple API depends on ODFDOM ;)

[1] http://incubator.apache.org/odftoolkit/odfdom/ProjectOverview.html



> As a good lazy programmer I started by using the Simple API. :-)  And I
> really liked the API.
>

Very happpy to hear that, thanks!


> But I found I could not iterate over a document and thought that I need to
> drop down to ODFDOM for that...
> Using the SimpleAPI I can iterate over all Tables, Paragraphs, Section but
> I could not collect info according to the structure of the document, to
> keep the info together.
>
> ex:
> I have a odt file from which I get information and expect the following
> structure:
>
> Header1 name-X
> Header2 name-XX
> Table
> Header2 name-XXX
>
> Header1 name-Y
> Header2 name-YY
> Table
> Header2 name-YYY
>
> I would like to find the Header1, use the "Name-X", then find and check the
> next Header2, then find and check the Table etc...
> Then go on to the next "Header1 Name-YYY"
>
> I just want to do pseudocode:
>
> Header 1.getNextElement()
> Ok, this is a Header 2
> Header 2.getNextElement()
> Ok, this is a Table, get my info....
>
> I could not find any examples of this in the Cookbook or am I missing
> something?
>

You need a document component navigator, isn't it?

Sorry, there is no API to support this requirement. We consider this
scenario before, and have created a class called
"org.odftoolkit.simple.Component", which  is the parent of classes that
present all kinds of document structures. But document component navigation
is not as simple as it looks.

How can we define component? all of the child of document root element? or
all of the paragraphs, tables and headers? Table cell can contain an
embeded table, but table cell may not be considered as a component in
general. Table can be inserted as the child of document root element, also
can be inserted in header/footer, chart and draw frame. Which table should
be considered as component, and which is not?

We need "level" parameter, such as level 1 returns all of the components,
which are the child of document root element, while level 2 contians the
child of level 1...

For your use case, I think you can use Simple API iterates over all Tables,
Paragraphs, Section, and get their OdfElements using method
getOdfElement(), then use ODFDOM to iterate the document and give these
components a right sort according to the location of their OdfElements.
This is my opinion, you could share yours with use?

To help more good lazy programmers, we welcome you contribute your code
back to ODF Toolkit ;)



> thanks,
> Jan
>
> On Sun, Dec 4, 2011 at 7:27 AM, Devin Han <devinhan@apache.org> wrote:
>
> > Hi Jan,
> >
> > I suppose you are using ODFDOM doc API, isn't it?
> > OK, ODFDOM doc API is deprecated in the coming release and we will not
> > maintain it in future.
> >
> > I suggest you replace it with Simple API[1], which is a new convenient
> API
> > for ODF Documnet and has very simliar design with ODFDOM doc API. But
> > Simple API has more powerful features and more performance tuning. You
> can
> > migrate to Simple API very easy.
> >
> > Let's back your question. If you migrate to Simple API, you can use the
> > following simple code:
> >
> > Image Cell.getImage() ;
> > Image.getOdfEelment();
> >
> > More information please reference the cookbook[2].
> >
> > Hope my answer can help you.
> >
> > [1] http://incubator.apache.org/odftoolkit/simple/index.html
> > [2]
> >
> >
> http://incubator.apache.org/odftoolkit/simple/document/cookbook/Cell.html#Set%20image
> >
> >
> > 2011/12/3 ikeamanual <ikeamanual@gmail.com>
> >
> > > Hi,
> > >
> > > I have a odf cell:
> > >
> > > OdfTableCell cell = table.getCellByPosition(0, 1);
> > >
> > > and in the document the cell only has a picture/Image inside.
> > >
> > > How to I get an OdfDrawImage from the cell?
> > >
> > > thanks,
> > > Jan
> > >
> >
> >
> >
> > --
> > -Devin
> >
>



-- 
-Devin

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