Hello Dany,

I must admit, I could not follow your layout comparison in full detail - I
guess your mail program exchanged some references. ;)
But anyway, there are several ways to do it..

First you may take a look at the existing API, a believe the IBM folks
added some ToC functionality to the Simple API. Take a look at the test
case of
simple/src/test/java/org/odftoolkit/simple/text/TableOfContentTest.java
after running the test(s) you will find the output document at
simple/target/test-classes/DefaultTOC.odt

In case it is not what you desire, I may extent / adopt the existing simple
API sources.

Regarding a good layout, I would choose a WYSIWYG editor, therefore the ODF
application of your choice (at minimum I test a feature with the latest
LibreOffice and Microsoft Office), create a ToC of your taste and save it
to an ODT document.
Afterwards adopt the existing XML manually in an editor to make it reusable
(e.g. adopt style names to your choice, use templates to be exchanged for
the variable parts). As editor for this task I prefer JEdit with Archive
and XML (indent) extension, which allows to save the document directly into
the ZIP (won't work for MS Office create packages).

Finally, you may use the new XML for automation on the XML via ODFDOM, or
reuse it in the Simple API.

Does this clarify your question?

Best regards,
Svante

PS: I would omit page numbers as the ODF Toolkit does not have a layout
ability, which is required for a solid calculation of pages.



2016-06-03 10:03 GMT+02:00 Dany Bouça Nova <[email protected]>:

> Hi Odf-Users,
>
>
> I m new in Apache Foundation and in asking help in that type of process
> but I really don't know how to achieve what I want to do and I think I am
> in the good place to ask my question.
>
>
> I am generating a ODT document for a professionnal project. The problem is
> that I need to have a table of content with hyperlinks to paragraphs for
> each single part of my Table Of Content.
>
> This is not really complicated and I already achieved this.
>
>
> The problem is that when I want to load another ODT file in my master
> document, I don't know how to format my Table of Content well. I ended up
> having something like :
>
> "
>
> Table of Contents
>
> 1.This is a tmp paragraph<
> https://outlook.office.com/owa/?realm=epitech.eu&path=/mail/drafts#__RefHeading__7098_971365491
> >.........<https://outlook.office.com/owa/#__RefHeading__7100_971365491
> >.........<https://outlook.office.com/owa/#__RefHeading__7100_971365491
> >.........<https://outlook.office.com/owa/#__RefHeading__7100_971365491
> >....<https://outlook.office.com/owa/#__RefHeading__7100_971365491>...................
> 1
>
> Test1<
> https://outlook.office.com/owa/?realm=epitech.eu&path=/mail/drafts#__RefHeading__7100_971365491
> >.........<https://outlook.office.com/owa/#__RefHeading__7100_971365491
> >.........<https://outlook.office.com/owa/#__RefHeading__7100_971365491
> >.........<https://outlook.office.com/owa/#__RefHeading__7100_971365491
> >.........<https://outlook.office.com/owa/#__RefHeading__7100_971365491
> >.........<https://outlook.office.com/owa/#__RefHeading__7100_971365491
> >.........<https://outlook.office.com/owa/#__RefHeading__7100_971365491
> >.........<https://outlook.office.com/owa/#__RefHeading__7100_971365491
> >.......<https://outlook.office.com/owa/#__RefHeading__7100_971365491
> >.............2
>
> Test2<
> https://outlook.office.com/owa/?realm=epitech.eu&path=/mail/drafts#__RefHeading__7102_971365491
> >.........<https://outlook.office.com/owa/#__RefHeading__7100_971365491
> >.........<https://outlook.office.com/owa/#__RefHeading__7100_971365491
> >.........<https://outlook.office.com/owa/#__RefHeading__7100_971365491
> >.........<https://outlook.office.com/owa/#__RefHeading__7100_971365491
> >.........<https://outlook.office.com/owa/#__RefHeading__7100_971365491
> >.........<https://outlook.office.com/owa/#__RefHeading__7100_971365491
> >.........<https://outlook.office.com/owa/#__RefHeading__7100_971365491
> >....................4
>
> "
> instead of something like :
>
>
> "
>
> Table of Contents
>
> 1.This is a tmp paragraph<
> https://outlook.office.com/owa/#__RefHeading__7098_971365491>.........<
> https://outlook.office.com/owa/#__RefHeading__7100_971365491>.........<
> https://outlook.office.com/owa/#__RefHeading__7100_971365491>.........<
> https://outlook.office.com/owa/#__RefHeading__7100_971365491>....<
> https://outlook.office.com/owa/#__RefHeading__7100_971365491>......................
> 1
>
>        2.Test1<
> https://outlook.office.com/owa/#__RefHeading__7100_971365491>.........<
> https://outlook.office.com/owa/#__RefHeading__7100_971365491>.........<
> https://outlook.office.com/owa/#__RefHeading__7100_971365491>.........<
> https://outlook.office.com/owa/#__RefHeading__7100_971365491>.........<
> https://outlook.office.com/owa/#__RefHeading__7100_971365491>.........<
> https://outlook.office.com/owa/#__RefHeading__7100_971365491>.........<
> https://outlook.office.com/owa/#__RefHeading__7100_971365491>.........<
> https://outlook.office.com/owa/#__RefHeading__7100_971365491>.......<
> https://outlook.office.com/owa/#__RefHeading__7100_971365491>.......2
>
>        3.Test2<
> https://outlook.office.com/owa/#__RefHeading__7102_971365491>.........<
> https://outlook.office.com/owa/#__RefHeading__7100_971365491>.........<
> https://outlook.office.com/owa/#__RefHeading__7100_971365491>.........<
> https://outlook.office.com/owa/#__RefHeading__7100_971365491>.........<
> https://outlook.office.com/owa/#__RefHeading__7100_971365491>.........<
> https://outlook.office.com/owa/#__RefHeading__7100_971365491>.........<
> https://outlook.office.com/owa/#__RefHeading__7100_971365491>.........<
> https://outlook.office.com/owa/#__RefHeading__7100_971365491
> >..............4
>
> "
>
> My code is formated like this :
>
>
> TextDocument doc = TextDocument.newTextDocument();
>
>
> Paragraph tmp = doc.addParagraph("1.This is a tmp paragraph");
>
> tmp.applyHeading();
>
>
> while (...) {
>
> TextDocument layout = TextDocument.loadDocument("./layout.odt");
>
>  // process modification in document before adding it to my main document
>
> }
>
>
> tmp.applyHeading(true, 2);
>
> doc.insertContentFromDocumentAfter(layout, tmp, true);
>
> ++i;
>
> }
>
>
> My problem is that I don't know how to format or access the strings
> ("Test1", "Test2"), pushed automatically with
> "insertContentFromDocumentAfter" method, into the table of content to
> format them.
>
>
> Thank you for giving me your time to help me on my problem,
>

Reply via email to