| View previous topic :: View next topic |
| Author |
Message |
harrybo Power User


Joined: 27 Apr 2004 Posts: 75 Location: Germany
|
Posted: Mon Aug 21, 2006 3:51 pm Post subject: Getting the caption of a table by content enumeration |
|
|
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 |
|
 |
probe1 Moderator


Joined: 18 Aug 2004 Posts: 2465 Location: Chonburi Thailand Asia
|
Posted: Mon Aug 21, 2006 4:29 pm Post subject: |
|
|
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 |
|
 |
harrybo Power User


Joined: 27 Apr 2004 Posts: 75 Location: Germany
|
Posted: Tue Aug 22, 2006 1:45 am Post subject: |
|
|
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 |
|
 |
probe1 Moderator


Joined: 18 Aug 2004 Posts: 2465 Location: Chonburi Thailand Asia
|
Posted: Tue Aug 22, 2006 5:35 am Post subject: |
|
|
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 |
|
 |
pitonyak Administrator


Joined: 09 Mar 2004 Posts: 3618 Location: Columbus, Ohio, USA
|
Posted: Tue Aug 22, 2006 11:02 am Post subject: |
|
|
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 |
|
 |
harrybo Power User


Joined: 27 Apr 2004 Posts: 75 Location: Germany
|
Posted: Wed Aug 30, 2006 5:06 pm Post subject: |
|
|
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 |
|
 |
pitonyak Administrator


Joined: 09 Mar 2004 Posts: 3618 Location: Columbus, Ohio, USA
|
Posted: Wed Aug 30, 2006 8:11 pm Post subject: |
|
|
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 |
|
 |
|