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

Basic Macro: Adding captions to tables.

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


Joined: 07 Feb 2011
Posts: 1
Location: Colombia

PostPosted: Mon Feb 07, 2011 11:57 am    Post subject: Basic Macro: Adding captions to tables. Reply with quote

Hello, I want to know how to add a caption to a table created via a Basic macro instead of the menu Insert–Table. I’ve explored these three possibilities but definitively I’m stuck.

1. Change the OpenOffice AutoCaption Dialog using introspection for UI controls. According to the following forum post it is possible to change settings in the Options – OpenOffice.org Writer Dialog (Tools–Options) using object iterators that returns the UI controls in a hierarchical manner. I wanted to change the AutoCaption category but I don’t know how to change the selected item of the combo boxes.

http://www.oooforum.org/forum/viewtopic.phtml?t=22845

2. Control the Insert–Caption dialog using UNO commands. According with the following page it is possible to control a dialog of the OpenOffice application using beans properties and the dispatch object. However, I don’t know which the parameters for the Insert–Caption dialog are.

http://flylib.com/books/en/4.290.1.95/1/

3. Insert a table caption using an API method. I explored the API documentation looking for a method that allows adding a caption to a table, say Table.insertCaption() or Table.addCaption(), but the most similar method was Table.getAccesibleCaption():

http://api.openoffice.org/docs/common/ref/com/sun/star/accessibility/XAccessibleTable.html

So, I think in one of these two situations:
1. An API method does exist, but I don’t know the syntax.
2. Create an additional sub or function that attaches a text field or frame to the table, say myTable.attachFrame(). How complex this could be?

Do you have a better approach? Thanks for your reply.

Note: Do you know how a macro can control the numbering of tables when deleting or inserting them?
Back to top
View user's profile Send private message MSN Messenger
pitonyak
Administrator
Administrator


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

PostPosted: Mon Feb 14, 2011 9:23 pm    Post subject: Reply with quote

Wow, now that is a long list of things to which I could respond if I did not want to have a bit of sleep tonight.....

First, let me address your final question regarding numbering captions. I expect that captions will be numbered using a sequence field (variable). I always do this by hand.... For example:

Enter the text "Table ",

Use Insert > FIelds > Other to open the fields dialog.

Select the Variables tab.

Select the "Number Range" type (far right list).

Under selection, select Table. So, the "Name" at the bottom should read Table.

For the value, enter "Table + 1" (with no quotes).

Click Insert.

OK, now, you have just inserted this field. Now, you can type the rest of your table caption. What occurs when you let OOo insert a caption? It provides a dialog and then automates the process for you.

I have never used auto-captioning because I prefer how I do handle it (with my own styles and such). The reason that I started doing this is related to graphics. If you caption a graphic, OOo automatically places the graphic in a frame with the caption. If you think about it, it is pretty smart because then the caption stays with the graphic as you move it around. For my documents I stopped doing this because of a few bugs in OOo (don't know if they have been fixed or not, I mean, some have, but I have not tested). One bug caused OOo to crash based on how things were anchored, but that has been fixed for years (but now I have my habits). Also, it certainly used to be the case that if you saved an OOo file with graphics embedded in this way as a DOC file, the figures were simply lost. I needed to export large documents with multiple figures, so I wrote a macro to rip captions and figures out of the frame and moved on with my life....

My point is that Graphics are done in a specific way. I have not looked at Table captions well enough to know how they are related. The accessibility API is related to writing screen readers and such, and it is not clear to me that this relates to text tables (they only seem to discuss Calc tables from what little I saw). On a whim, I inspected a text table and I do not see the accessibility API for this in particular.

My uninformed opinion on this is that you need to simply insert the appropriate text and the sequence field in the correct locations. also, for a caption, you usually place this in a paragraph before or after the table and then set a specific paragraph style (my style will keep the caption with the next paragraph, which means the text table that immediately follows it).

Hope this helps at least a little.
_________________
--
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