Thanks,
but as you can see in the other post, the problem isn't the ContenIndex, but the Index Entry that i use to insert the index in the text...

Stephan Wunderlich ha scritto:
Hi Cristian,

I see in the developer's guide how create an index in a writer document with the JAVA API. i would add at every page number in the index (or eventually in the title) a hyperlink to the right section..
Someone know how can i do it (in JAVA)??
Thanks to all...

given that you have a textdocument with some nice headings inside the following macro should insert a TableOfContents with the first Level "HyperLinked" ...

------------------------------------------------------
xDoc = ThisComponent
xText = xDoc.getText()
xTextCursor = xText.createTextCursor
xIndex = xDoc.createInstance("com.sun.star.text.ContentIndex")
xIndex.createFromOutline=True
xText.insertTextContent(xTextCursor, xIndex, false)
LFormat = xIndex.LevelFormat.getByIndex(1)
elementcount = ubound(LFormat)
dim newFormat(elementcount+1) as Variant

dim cont(0) as Variant
dim aProp as new com.sun.star.beans.PropertyValue
aProp.Name="TokenType"
aProp.Value="TokenHyperlinkStart"
cont(0) = aProp
newFormat(0) = cont()

for i=0 to ubound(LFormat)
    newFormat(i+1)=LFormat(i)
next

dim cont2(0) as Variant
dim aProp2 as new com.sun.star.beans.PropertyValue
aProp2.Name="TokenType"
aProp2.Value="TokenHyperlinkEnd"
cont2(0) = aProp2
newFormat(ubound(LFormat)+1) = cont2()

xIndex.LevelFormat.replaceByIndex(1,newFormat())

xIndex.update
xText.removeTextContent(xIndex)

------------------------------------------------------

Hope that helps

Regards

Stephan

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dott. Cristian Fonti
mailto: [EMAIL PROTECTED]
Centro Elaborazione Dati (CED) - Resp. Web Area
SCM Group S.p.a. http://www.scmgroup.com
via Emilia, 77 - 47900 Rimini (RN), Italy
Tel.: +39 0541 700163 Interno: 2163
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to