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

Getting the caption of a table by content enumeration

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
harrybo
Power User
Power User


Joined: 27 Apr 2004
Posts: 75
Location: Germany

PostPosted: Mon Aug 21, 2006 3:51 pm    Post subject: Getting the caption of a table by content enumeration Reply with quote

Hello,

I'm trying to retrieve the captions of tables by enumerating a Writer document. It seems to me, that there is no way to get the caption from a table-paragraph object. The caption is internally represented by a standard formatted separate paragraph below or above the table, such as "Table 3: Holydays 2006". The caption itself is represented by 3 TextPortions with ParaStyleName "Table" and with the TextPortionTypes Text, TextField and again Text. The TextField is an increment field, so it does not lead me to the appropriate table.

Ok, I could look for such TextPortions below or above a table, but - as a table-caption can be on both places, what, if there's a table with a caption below, followed by a table with no caption?
Back to top
View user's profile Send private message Send e-mail Visit poster's website
probe1
Moderator
Moderator


Joined: 18 Aug 2004
Posts: 2560
Location: Chonburi Thailand Asia

PostPosted: Mon Aug 21, 2006 4:29 pm    Post subject: Reply with quote

The captions are automatically registered for a table index, so have a look at this: /openoffice.org2.0_sdk/docs/common/ref/com/sun/star/text/DocumentIndexMark.html

Does this help?
_________________
Cheers
Winfried
My Macros
DateTime2 extension: insert date, time or timestamp, formatted to your needs
Back to top
View user's profile Send private message Visit poster's website
harrybo
Power User
Power User


Joined: 27 Apr 2004
Posts: 75
Location: Germany

PostPosted: Tue Aug 22, 2006 1:45 am    Post subject: Reply with quote

Thank you probe1. The DocumentIndexMark didn't help me. May be, I'm not so experienced in handling IndexMarks.

What I try to find is a unique relation between the table and its caption - not only a 'neighborhood'. The questions I want to answer are:

1. Does a table has a caption (made with Insert Caption dialog)?
2. If it has a caption, what is the caption?
3. Is the caption placed above or below the table?

With other words, basic questions regarding tables. But as it seems to me, not at all trivial, to get these informations via the API.

Regards
Harry
Back to top
View user's profile Send private message Send e-mail Visit poster's website
probe1
Moderator
Moderator


Joined: 18 Aug 2004
Posts: 2560
Location: Chonburi Thailand Asia

PostPosted: Tue Aug 22, 2006 5:35 am    Post subject: Reply with quote

I don't think there is a relation (between a table and a caption).

The caption is placed to a table on creation and basta! Or not.
Only thing related is the numbering field. But this field could be anywhere (possibly more than one time) within a document.
_________________
Cheers
Winfried
My Macros
DateTime2 extension: insert date, time or timestamp, formatted to your needs
Back to top
View user's profile Send private message Visit poster's website
pitonyak
Administrator
Administrator


Joined: 09 Mar 2004
Posts: 3655
Location: Columbus, Ohio, USA

PostPosted: Tue Aug 22, 2006 11:02 am    Post subject: Reply with quote

check to see if it uses a specific paragraph style (MAYBE).
check to see if it uses a field number the tables (ALMOST POSITIVE).

You should be able to search the text, find the fields that contain the equation Table+1, and then remove those paragraphs. That is how I would try...
_________________
--
Andrew Pitonyak
http://www.pitonyak.org/oo.php
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
harrybo
Power User
Power User


Joined: 27 Apr 2004
Posts: 75
Location: Germany

PostPosted: Wed Aug 30, 2006 5:06 pm    Post subject: Reply with quote

Thanks for your replies. Yes, I can find the Textportions with ParaStyleName "Table", giving me the information, that the corresponding paragraph is a table-caption. One of these TextPortions has the TextPortionType "TextField" (the number within the caption), Unfortunately this Textfield only gives me the incremented number of the table-caption. Since a document can have tables without a caption the TextField do not give me an information like "this is the caption of tableX". I fear that probe1 is right, when he says:
Quote:
I don't think there is a relation (between a table and a caption).
Assuming, that the caption, if existing, is always placed under a table, I could walk through all tables and check, if there's a caption string right below. That wold be a solution if it wouldn't be also possible to set a caption above a table. So the case "table - caption - table" can not be clearly handled.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
pitonyak
Administrator
Administrator


Joined: 09 Mar 2004
Posts: 3655
Location: Columbus, Ohio, USA

PostPosted: Wed Aug 30, 2006 8:11 pm    Post subject: Reply with quote

You are correct, that the problem is NOT deterministic. The best that you can do is find fields of an appropriate type and look above or below for a table. You could go the other way, find the table, then look for the caption.
_________________
--
Andrew Pitonyak
http://www.pitonyak.org/oo.php
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
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