You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openoffice.apache.org by Олег Малёваный <de...@mail.ru> on 2012/05/31 16:38:40 UTC

How update table of contents in document?

Hi!
I am developing a script that will generate the document. provided in
the template "Table of Contents" of the document.
In development, I use perl and module
http://search.cpan.org/~jmgdoc/OpenOffice-OODoc-2.125/
Can I by means of this module, update the "Table of Contents" in a
document? 
If not, then how can one way to run a macro that will update the table
of contents with the help of this module or the unix command line?


Re: How update table of contents in document?

Posted by "F C. Costero" <fj...@gmail.com>.
On Thu, May 31, 2012 at 8:38 AM, Олег Малёваный <de...@mail.ru> wrote:
> Hi!
> I am developing a script that will generate the document. provided in
> the template "Table of Contents" of the document.
> In development, I use perl and module
> http://search.cpan.org/~jmgdoc/OpenOffice-OODoc-2.125/
> Can I by means of this module, update the "Table of Contents" in a
> document?
> If not, then how can one way to run a macro that will update the table
> of contents with the help of this module or the unix command line?
>
I know nothing about using Perl, but the code to update a table of
contents in OpenOffice Basic could be

oDoc = ThisComponent
oIndexes = oDoc.getDocumentIndexes()
oTableOfCont = oIndexes.getByName("Table of Contents1")
oTableOfCont.update()

I hope that helps.
Francis

Re: How update table of contents in document?

Posted by 程建宏 <sw...@gmail.com>.
Hi Oner,
Aoo provides APIs to update the table of contents of an odt document.Please
access http://wiki.services.openoffice.org/wiki/Documentation/Wiki_Books to
download the OO3.1 Dev Guide and go to page 851..The type
"com.sun.star.text.ContentIndex" of Index is for table of contents..Then
you can access
http://www.openoffice.org/api/docs/common/ref/com/sun/star/text/module-ix.html
to
refer services of ContentIndex,BaseIndex and TextDocument, and also UNO
interface of XDocumentIndex and XTextDocument.

In your sample,you have gotten the TextDocument instance,and then you will
be able to instance the ContentIndex through TextDocument..Thus, you can
use the API "update" provided by  XDocumentIndex to update the table of
contents of the odt document...

I don't write the script like yours, and just provide their relations and
rough method..I hope it helpful to solve your problem...Thanks.

On Thu, May 31, 2012 at 10:38 PM, Олег Малёваный <de...@mail.ru> wrote:

> Hi!
> I am developing a script that will generate the document. provided in
> the template "Table of Contents" of the document.
> In development, I use perl and module
> http://search.cpan.org/~jmgdoc/OpenOffice-OODoc-2.125/
> Can I by means of this module, update the "Table of Contents" in a
> document?
> If not, then how can one way to run a macro that will update the table
> of contents with the help of this module or the unix command line?
>
>