Posted on 2008-11-21 20:42:05-08 by jmgdoc in response to 9394
Re: finding elements by type

There is no direct method to find the logical coordinates of a given table cell.

But whatever the element, you can get its parent and its local position, using parent() and pos(). Beware, parent() and pos() are element methods (not document methods), so the local position of a cell is given by
$cell->pos()
and not
$doc->pos($cell)
Both are provided by the underlying XML::Twig module; see the XML::Twig documentation for more details. Alternatively, you could have a look at getLocalPosition(), an undocumented method in the OpenOffice::OODoc::Element package (XPath.pm); this method is a wrapper of pos(). Simply put, you cas get the position of a cell in the row (knowing that the cell's parent is a row), then the position of the row in the table [then the position of the table in its own context, and so on]. Be careful, the return values of pos() follow the XPath convention, not the Perl convention, i.e. they are one-based unlike Perl indices.

Don't forget that this approach works with normalized tables only.
Direct Responses: 9409 | Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.