OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Adding Paragraph style to Outline Numbering

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
newlearner
General User
General User


Joined: 21 Sep 2010
Posts: 28

PostPosted: Tue May 08, 2012 8:25 am    Post subject: Adding Paragraph style to Outline Numbering Reply with quote

Hi,

I used Andrew Pitonyak's openoffice macros and was able to configure outline numbering
I was able to edit character style, Numbering style. I want to add `Paragraph style` as well.

I want the each level to have corresponding Parastyle as HeadingX

like Level 1 with Paragraph style Heading1, Level 2 Heading 2 and soon

Code:

Sub CheckOutLine()
 Dim i%, j%
 Dim oRules
 Dim oRule()
 Dim oProp
 oRules = ThisComponent.getChapterNumberingRules()
 For i = 0 To oRules.getCount() - 1
 oRule() = oRules.getByIndex(i)
 REM I do not set the following:
 REM Adjust, StartWith, LeftMargin,
 REM SymbolTextDistance, FirstLineOffset
 For j = LBound(oRule()) To Ubound(oRule())
 REM oProp is only a copy of the property.
 REM You must assign the property back into the array.
 oProp = oRule(j)
 Select Case oProp.Name
' Case "ParagraphStyle"
' val = "Heading" & i
' oProp.Value = "Heading" & i
 Case "HeadingStyleName"
' val = "Heading" & i
' oProp.Value = "Heading" & i
 Case "NumberingType"
 oProp.Value = com.sun.star.style.NumberingType.ARABIC
 Case "ParentNumbering"
 oProp.Value = i + 1
 Case "Prefix"
 oProp.Value = ""
 Case "Suffix"
 oProp.Value = "."
 'Case "CharStyleName"
 ' oProp.Value =
 End Select
 oRule(j) = oProp
 Next
 oRules.replaceByIndex(i, oRule())
 Next
End Sub


The commented paragraph style lines n the code are my trails to add paragraph styles to the levels.

I was able to add custom Headings to the levels with other code in which custom styles can be passed in as array to add to outline numbering.
How can I add these Paragraph styles and not custom styles?

Any help is appreciated..

Regards,
Newlearner
Back to top
View user's profile Send private message
DVezina
OOo Advocate
OOo Advocate


Joined: 29 Sep 2006
Posts: 248
Location: Orlando

PostPosted: Tue May 08, 2012 10:02 am    Post subject: Reply with quote

You were close.

The property name that equates to Paragraph Style in the window is "HeadingStyleName".

However, you must make sure that the style you are applying exists. In your tests, you were assigning "Heading0", "Heading1", which don't exist so it looked like it wasn't working.

Code:


Case "HeadingStyleName"
    oProp.Value = "Heading " & (i+1)

 
Back to top
View user's profile Send private message
newlearner
General User
General User


Joined: 21 Sep 2010
Posts: 28

PostPosted: Tue May 08, 2012 10:56 am    Post subject: Reply with quote

Hi,

Thank you very much, it works. I should have checked that i starts from 0.

Smile Smile
Newlearner
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group