Apache OpenOffice (AOO) Bugzilla – Issue 27268
textTable.anchor and compareRegionEnds fails
Last modified: 2013-02-24 21:07:05 UTC
Having a table in a document and running the following macro code: oDoc = ThisComponent oText = oDoc.Text oRange = oDoc.currentSelection(0) oTextTableAnchor = oDoc.TextTables(0).anchor msgbox oText.compareRegionEnds(oTextTableAnchor, oRange) produces the error: com.sun.star.lang.IllegalArgumentException when executing the msgbox line. Where as having a frame and running this code: oDoc = ThisComponent oText = oDoc.Text oRange = oDoc.currentSelection(0) oTextFrameAnchor = oDoc.TextFrames(0).anchor msgbox oText.compareRegionEnds(oTextFrameAnchor, oRange) doesn't produce an error. I first found this in OOo1.1.1rc1 for Linux, and have tried it in Star Office 7 for Linux, OOo1.1.1 for Linux and OOo1.1.1 for Windows. I have posted a topic to the Macros and API forums about this but haven't had a response: http://www.oooforum.org/forum/viewtopic.php?t=7331. It is quite possible that I am not understanding something but I think that this is a bug. The implications of the bug are that it isn't possible to determine whether a table is within a particular range. I have done a search on "table" in the issue list and could not find a similar issue reported. Thanks, Ian Laurenson
SW->TL: reproduced with src680_m32, could you please have a look at this
.
The basic reason for the problem is that anchors of text tables does not have a position in the text! That is implementation specific but cannot be changed without rewriting the core. Thus I added ome comments to the TextTable.idl and XTextContent::getAnchor. It loks like this: +++++++++++++++++++++++++++++++ Note: The anchor of the actual implementation for text tables does not have a position in the text. Thus that anchor can not be used for some operation like attach for example or insertTextContent or other function that require the object to have a position in the text. The reason why a text table still needs an anchor is that for example tables should be insertable via insertTextContent and that interface uses a parameter of that type. +++++++++++++++++++++++++++++++ Files changed: offapi: - com/sun/star/text/TextTable.idl new revision: 1.14.180.1 - com/sun/star/text/XTextContent.idl new revision: 1.9.212.1
I have not tried but I think in order to find out if a table is within a particular range you may compare the text range of the first/last cell.
new target OO2.0.1
Reassigned for verification re-open issue and reassign to sw@openoffice.org
idl-files have been adjusted => verified
idl-files have been adjusted in src680_m140 => closed
Created attachment 73290