OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

How to determine if a table is within a selection?

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
Iannz
OOo Advocate
OOo Advocate


Joined: 14 Feb 2004
Posts: 494
Location: Christchurch, New Zealand

PostPosted: Wed Mar 31, 2004 1:37 am    Post subject: How to determine if a table is within a selection? Reply with quote

I am trying to write a routine that searches within a selection. My problem is in determining when the found object is within a table is that table within the original selection.
I can determine if the found object is in a table with:
Code:
if not isEmpty(oFound.cell) then


I can find where the table is anchored with:
Code:
oFound.textTable.anchor

This returns a text range (SwxTextRange) object.

However, when I try and do anything with oFound.textTable.anchor like compare its location with a textCursor in the bodytext, or create a textCursor that's in the body text or get a textCursor to go this location I get an exception error.

The string that is returned from oFound.textTable.anchor.text.string and ThisDocument.text.string are identical (i.e the body text of the document).

I have searched the issues and not found it listed as a bug. I am running OOo1.1.1rc1 for Linux. I will download OOo1.1.1 tonight (at my connection speed it will take all night).

Any help would be greatly appreciated.
_________________
Cheers, Ian

http://wiki.services.openoffice.org/wiki/Extensions_development_basic a wiki about writing OpenOffice.org extensions.
Back to top
View user's profile Send private message
Iannz
OOo Advocate
OOo Advocate


Joined: 14 Feb 2004
Posts: 494
Location: Christchurch, New Zealand

PostPosted: Wed Mar 31, 2004 4:30 pm    Post subject: textTable.anchor and compareRegionEnds fails Reply with quote

I have now posted this as an issue:
http://www.openoffice.org/issues/show_bug.cgi?id=27268

Below is a copy of my issue posting.

Having a table in a document and running the following macro code:

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:

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.

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.
_________________
Cheers, Ian

http://wiki.services.openoffice.org/wiki/Extensions_development_basic a wiki about writing OpenOffice.org extensions.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group