List Info

Thread: Table of contents (yet again)




Table of contents (yet again)
user name
2007-08-22 08:08:34
Hi,

I need to ideally update a table of contents existent in a
document (or
generate one if the update is not possible).
For that I tried to figure out how this was done in AODL.

For what I've read in the code and in the tests, it's only
possible to do
this by inserting another node in the right element.

The big problem with this is when the Headings are numbered.
If I set
Heading 1 to include numbering, then in the body of the
document it will
appear "1. Title". If I update the TOC inside
OpenOffice.org, the
corresponding entry will also somehow reflect this
numbering. But the XML of
the TOC displays this number as simple text. So, if I want
to add a new
entry to a TOC programatically by manipulating the XML
directly, I will need
to manually insert the chapter number for the TOC to remain
with the
original aspect. That is what you do in AODL.
For example, in IndexTest.cs there are the next lines to do
this:

string sHeading                    = "A first
headline";
//The corresponding text entry, here you need to set the
//chapter number
string sTocEntry                = "1. A first
headline";
...
//add the toc entry text as entry to the Table of contents
tableOfContents.InsertEntry(sTocEntry, 1);

This is adequate when I'm generating a new document from
scratch, when I
know and control what is the structure of the document. This
way I now the
correct sequence of the headings.
But, when I'm opening an existing document, adding some
contents to it and
then want this content to be reflected in the TOC, this
approach fails.
Because, being this numbering automatically rendered in
OpenOffice.org (and
that could even be in different formats - 1, A, a, I, i) I
don't know what
is the chapter number of each heading...so, there is no
place where, using
only the XML files, I can get the information that I need to
generate a
proper TOC. I can build a list of headings but how can I
know what is the
numbering of each one of them?

Is there a way to do what I need? Any hint would be helpful
even if it's not
related with AODL or odftoolkit project...

Another question: is there any way to discover the page of
each heading to
insert in the TOC?
In the InsertEntry method of the class TableOfContents I saw
that the page
number is always being inserted as "1" and the is
the following comment:
"add the tabstop and the page number, the number is
always set to 1, but
will be updated by the most word processors immediately to
the correct page
number.". I've tried this (inserting a new node to the
TOC with the page
number 1) and there was no update on loading...only after I
forced the TOC
update. Was this what it was meant by the comment above?


I really need someone to answer to this questions, even if
it's to say that
there's no way to do what I'm trying to do...

Best regards,
Nuno
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )