https://bugs.documentfoundation.org/show_bug.cgi?id=158420
Bug ID: 158420
Summary: com.sun.star.text.ContentIndex seems to be missing
boolean to enable AdditionalStyles
Product: LibreOffice
Version: 7.6.3.2 release
Hardware: All
OS: All
Status: UNCONFIRMED
Severity: normal
Priority: medium
Component: BASIC
Assignee: [email protected]
Reporter: [email protected]
Description:
When adding a Table of Contents (TOC) I use com.sun.star.text.ContentIndex
together with the property LevelParagraphStyles to add a heading style to the
TOC.
Example:
oIndex = ThisComponent.createInstance("com.sun.star.text.ContentIndex")
oIndex.CreateFromOutline = True
oIndex.LevelParagraphStyles.replaceByIndex(0, Array("Heading 1"))
However, there seems to be no property to enable "Additional Styles" (you can
only set the heading with levelParagraphStyles), present in the Table of
Contents dialog. There is a boolean for CreateFromOutline, CreateFromMarks, but
no CreateFromParagraphStyles.
Steps to Reproduce:
1. Have a document with "Microsoft Word headings", so a paragraph with the
styling "Heading 1".
2. Insert --> Table of Contents and Indexes --> Tables of Contents, Index or
Bibliography...
3. See a default unchecked additional styles.
4. Run the following code snippet and see that the boolean is still false,
while the additional styles are set.
Sub InsertATOCWithHyperlinks
REM Author: Andrew Pitonyak
Dim oCurs 'Used to insert the text content.
Dim oIndexes 'All of the existing indexes.
Dim oIndex 'TOC if it exists and a new one if not.
Dim i% 'Find an existing TOC.
Dim bIndexFound As Boolean 'Flag to track if the TOC was found.
Dim iLevel
REM Find TOC if it exists.
oIndexes = ThisComponent.getDocumentIndexes()
bIndexFound = False
For i = 0 To oIndexes.getCount() - 1
oIndex = oIndexes.getByIndex(i)
If oIndex.supportsService("com.sun.star.text.ContentIndex") Then
bIndexFound = True
Exit For
End If
Next
If Not bIndexFound Then
REM Create and insert a new TOC.
REM The new TOC must be created by the document that will contain the TOC.
oIndex = ThisComponent.createInstance("com.sun.star.text.ContentIndex")
oIndex.CreateFromOutline = True
oIndex.LevelParagraphStyles.replaceByIndex(0, Array("Heading 1"))
' Ignore level 0
For iLevel = 1 To oIndex.LevelFormat.getCount() - 1
oIndex.LevelFormat.replaceByIndex(iLevel, CreateTOCColumnEntries())
Next
oCurs = ThisComponent.getText().createTextCursor()
oCurs.gotoRange(ThisComponent.CurrentController.ViewCursor, False)
ThisComponent.getText().insertTextContent(oCurs, oIndex, False)
End If
REM Even the newly inserted index is not updated until right HERE!
oIndex.update()
End Sub
Function CreateTOCColumnEntries()
Dim o
o = Array( Array(MakeProperty("TokenType", "TokenEntryNumber"), _
MakeProperty("CharacterStyleName", "")), _
Array(MakeProperty("TokenType", "TokenHyperlinkStart"), _
MakeProperty("CharacterStyleName", "Internet link")), _
Array(MakeProperty("TokenType", "TokenEntryText"), _
MakeProperty("CharacterStyleName", "")), _
Array(MakeProperty("TokenType", "TokenHyperlinkEnd")), _
Array(MakeProperty("TokenType", "TokenTabStop"), _
MakeProperty("TabStopRightAligned", TRUE), _
MakeProperty("TabStopFillCharacter", "."), _
MakeProperty("CharacterStyleName", ""), _
MakeProperty("WithTab", TRUE)), _
Array(MakeProperty("TokenType", "TokenPageNumber"), _
MakeProperty("CharacterStyleName", "")))
CreateTOCColumnEntries() = o
End Function
Function MakeProperty(sName$, value)
Dim oProp
oProp = CreateObject("com.sun.star.beans.PropertyValue")
oProp.Name = sName
oProp.Value = value
MakeProperty = oProp
End Function
-------------------------------
You get a TOC, but when you right click on the TOC and click on "Edit index"
the additional styles boolean is still set to false. If manually set to true
and you look into the styles you see that "Heading 1" is set to level 1.
The problem: how to set the additional styles boolean? It seems to be missing.
Actual Results:
A TOC is generated without the boolean "Additional styles" set to true.
Expected Results:
A way to set "Additional styles" to true, as you can also set the other
properties.
Reproducible: Always
User Profile Reset: Yes
Additional Info:
I tried this in multiple OS'es (linux and windows) on the LibreOffice 6.2.3 and
5.8 with clean profiles.
--
You are receiving this mail because:
You are the assignee for the bug.