[Solved] Starbasic Macro for bullets and numbering look

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
yiorisos
Posts: 6
Joined: Fri Jul 22, 2016 10:32 pm

[Solved] Starbasic Macro for bullets and numbering look

Post 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!
Last edited by Hagar Delest on Sat Jul 30, 2016 9:49 pm, edited 1 time in total.
Reason: tagged [Solved].
OpenOffice3.1 on UBUNTU 12.04
FJCC
Moderator
Posts: 9248
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

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

Post 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
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
yiorisos
Posts: 6
Joined: Fri Jul 22, 2016 10:32 pm

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

Post by yiorisos »

super!! thanks!!!
OpenOffice3.1 on UBUNTU 12.04
_savage
Posts: 187
Joined: Sun Apr 21, 2013 12:55 am

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

Post 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?
Mac 10.14 using LO 7.2.0.2, Gentoo Linux using LO 7.2.3.2 headless.
Post Reply