Page 1 of 1

[Solved] Starbasic Macro for bullets and numbering look

Posted: Sat Jul 30, 2016 3:25 pm
by yiorisos
I'm looking in the Forum and the documentation for quite some time and couldn't find it...

I have managed to create a TOC with the use of levels
oCurs.NumberingLevel = "Level 2" 'attribute of the text, in order to include it in the TOC
oCurs.ParaStyleName = "Heading 2" 'attribute of the text, so that it looks like heading
and the appropriate command in the end

I have managed to change the properties of lines or paragraphs using both a view and a text cursor, for example with
xTextCursor.CharPosture=com.sun.star.awt.FontSlant.ITALIC (the xTextcursor has already a selection).

I cannot find a way to do the same with bullets and numbering. I already tried:

fvc.ParaStyleName = "Numbering 1" (fvc is a text or view cursor)

This changed the style of the lines (1,5 lines pro line) but I see no Numbering (or bullets, when i use "List 1" instead of "numbering 1")

Does somebody have an idea, how to create a macro like this, a starbasic macro that creates bullets or numbering in the current selection (when possible using a text or view cursor)?

PS. I already tried to use the macro record function, didn't help in this case...

thanks!

Re: How does a starbasic Macro for bullets and numbering loo

Posted: Sat Jul 30, 2016 5:02 pm
by FJCC
This code adds numbering and bullets to the first two paragraphs of a document. The first paragraph just gets numbering turned on, so it gets the zero level numbering default, which is an Arabic number. The second paragraph gets set to level 1 which the code has modified to get a bullet.

Code: Select all

oNumRules = ThisComponent.createInstance("com.sun.star.text.NumberingRules") 'create numbering rules
'Get the Level 1 rule and change it to show a bullet 
oRule1 = oNumRules.getByIndex(1)
for i = 0 to UBOUND(oRule1)
	if oRule1(i).Name = "NumberingType" Then
		oRule1(i).Value = com.sun.star.style.NumberingType.CHAR_SPECIAL
	End If
next i
oNumRules.replaceByIndex(1, oRule1)

oText = ThisComponent.Text
oCurs = oText.createTextCursor()
oCurs.NumberingRules = oNumRules
oCurs.gotoNextParagraph(False) ' go to 2nd paragraph
oCurs.NumberingRules = oNumRules
oCurs.NumberingLevel = 1

Re: How does a starbasic Macro for bullets and numbering loo

Posted: Sat Jul 30, 2016 5:43 pm
by yiorisos
super!! thanks!!!

Re: How does a starbasic Macro for bullets and numbering loo

Posted: Sun Mar 18, 2018 2:42 am
by _savage
FJCC wrote:The first paragraph just gets numbering turned on, so it gets the zero level numbering default, which is an Arabic number. The second paragraph gets set to level 1 which the code has modified to get a bullet.
Thank you FJCC, it looks like your comment is an indirect answer to my question at the bottom of this comment.

Is it correct to say that there is a max level of nesting for lists, 0…9, which relates to the number of NumberingRules per paragraph? And if a numbering paragraph has a NumberingLevel value of N then rule N applies to that particular paragraph?