[Solved] Starbasic Macro for bullets and numbering look

Keyboard macros or custom scripts

[Solved] Starbasic Macro for bullets and numbering look

Postby yiorisos » Sat Jul 30, 2016 3:25 pm

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
yiorisos
 
Posts: 6
Joined: Fri Jul 22, 2016 10:32 pm

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

Postby FJCC » Sat Jul 30, 2016 5:02 pm

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   Expand viewCollapse view
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
AOO 3.4 or 4.1 on MS Windows XP ( before 2013-08-03) or Windows 7
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 6616
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

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

Postby yiorisos » Sat Jul 30, 2016 5:43 pm

super!! thanks!!!
OpenOffice3.1 on UBUNTU 12.04
yiorisos
 
Posts: 6
Joined: Fri Jul 22, 2016 10:32 pm

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

Postby _savage » Sun Mar 18, 2018 2:42 am

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.11 using LO 5.3.6.1, Gentoo Linux using LO 5.3.4.2 headless.
_savage
 
Posts: 162
Joined: Sun Apr 21, 2013 12:55 am


Return to OpenOffice Basic, Python, BeanShell, JavaScript

Who is online

Users browsing this forum: No registered users and 3 guests