Association between ToC index object and its paragraph content

Jens Tröger jens.troeger at light-speed.de
Thu Dec 7 18:51:56 UTC 2017


Two things.  First, I had to call update() on the ToC document index
object in order to get all links in the document.  Second, calling
update() _duplicated_ each and every entry in the ToC which looks like a
bug to me (LO 5.3.6.1)…

I’m still curious though: iterating over the paragraphs, is there any
other indication than the par’s name that the par is in fact part of the
ToC index object?  

Cheers,
Jens


On Thu, Dec 07, 2017 at 07:40:35PM +1000, Jens Tröger wrote:
> Thanks Miklos,
> 
> Actually, what I find odd is that I don’t see any `text.HyperLinkURL` attributes with internal references—all text portions in paragraphs of the ToC are empty strings.
> 
> Yet, the document does have a ToC index object, but I somehow I can’t associate that object with the text paragraphs of the ToC lines, nor with the bookmarks scattered throughout the document. Or vice versa…
> 
> Cheers,
> Jens
> 
> 
> > On Dec 7, 2017, at 18:58, Miklos Vajna <vmiklos at collabora.co.uk> wrote:
> > Let's say you have a ToC, then a Heading 1 paragraphs, Foo.
> > 
> > Then the ToC refers to hidden RefHeading bookmark for Foo. You can see
> > this reference at an UNO API level. Basic code for this:
> > 
> > oParas = ThisComponent.Text.createEnumeration
> > oPara = oParas.nextElement ' Table of Contents
> > oPara = oParas.nextElement ' Foo
> > oPortions = oPara.createEnumeration
> > oPortion = oPortions.nextElement
> > xray oPortion.HyperlinkURL ' gives #__RefHeading___Toc...
> > 
> > If you want to see the bookmarks the ToC refers to, it's similar:
> > 
> > ...
> > oPara = oParas.nextElement ' Foo
> > oPortions = oPara.createEnumeration
> > oPortion = oPortions.nextElement
> > xray oPortion.TextPortionType ' gives Bookmark
> > xray oPortion.Bookmark.Name ' gives #__RefHeading___Toc...
> > 
> > In most cases if you see some information serialized into ODT, then you
> > can assume the same information is available via the UNO API. You can
> > always read (most of) the ODT filter in xmloff/ to see what exact UNO
> > API is used to write a given ODT markup.
> > 
> > Regards,
> > Miklos
> 

-- 
Jens Tröger
http://savage.light-speed.de/


More information about the LibreOffice mailing list