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

Programmatically Applying Ordered List

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


Joined: 14 Nov 2003
Posts: 34
Location: Cincinnati, OH

PostPosted: Mon Oct 04, 2004 12:23 pm    Post subject: Programmatically Applying Ordered List Reply with quote

I am looking to programatically apply an ordered list format to a user-selected set of text. I would normally just set the NumberingStyle - but this causes a continuation of list numbering throughout the document. I need numbering to restart for every list defined.

I can make the Numbering format dialog open by the code generated by recording a macro, but I would like to take it one more step and have is apply a lower case alphabetic list type with one click. Below is the code generated by the recorded macro:

Code:

dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:BulletsAndNumberingDialog", "", 0, Array())


Does anyone have any thoughs. This is the desired process:
1) User selects text
2) User presses "Apply List" button
3) Lower-case alphabetic ordered list is applied to selected text
4) If user repeats above steps on another set of text, the numbering is independent of previous lists.


Thanks in advance!
Aaron
Back to top
View user's profile Send private message AIM Address
pitonyak
Administrator
Administrator


Joined: 09 Mar 2004
Posts: 3618
Location: Columbus, Ohio, USA

PostPosted: Mon Oct 04, 2004 6:18 pm    Post subject: Reply with quote

Can you create a paragraph style (or styles) that will format the data as you desire? If so, then you need but set an appropriate paragraph style to all of the paragraphs that are selected.
_________________
--
Andrew Pitonyak
http://www.pitonyak.org/oo.php
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
Aaron
General User
General User


Joined: 14 Nov 2003
Posts: 34
Location: Cincinnati, OH

PostPosted: Tue Oct 05, 2004 4:21 am    Post subject: Reply with quote

Pitonyak,

Thanks for the reply (good to hear from a fellow Ohio person!). I have tried the paragraph style that you recommended. The problem is that the numbering will not restart when desired. Perhaps I should provide a more detailed example of what I am doing.

I am creating a template that will be used to markup quizzes. After being appropriately styled/marked up, the OOo native xml will be run through an XSL transformation.

This is an example of what I need styled:

Code:

This is a typical question. I will operate on the paragraph level.
a) Possible answer
b) Possible answer
c) Correct answer
d) Possible answer
This would be the rationale for why the correct answer is correct.


So above, in order to perform my transformation, I need 4 different styles: Question, Possible Answer, Correct Answer and Rationale. Since there are multiple questions in a file, I need the numbering (or lettering if you will) to restart for each question. When using a numbering style, the numbering just continues on without resetting to "a".

Any ideas?

Thanks,
Aaron
Back to top
View user's profile Send private message AIM Address
pitonyak
Administrator
Administrator


Joined: 09 Mar 2004
Posts: 3618
Location: Columbus, Ohio, USA

PostPosted: Tue Oct 05, 2004 10:16 am    Post subject: Reply with quote

Boy, what a surprise, I thought that if I checked the restart numbering option in the paragraph style that it caused the numbering to restart. What was I thinking.... I still think that it should, but it does not. OK, how about this little hint (Yes, I verified that this works).... Smile
Code:
Sub TestNumbering
  Dim oCursor
  oCursor = ThisComponent.getText().createTextCursor()
  oCursor.gotoStart(False)           REM Start of document
  oCursor.gotoNextParagraph(False)   REM Skip this paragraph
  oCursor.gotoNextParagraph(False)   REM Skip this paragraph
  oCursor.gotoNextParagraph(False)   REM Skip this paragraph
  oCursor.gotoEndOfParagraph(True)   REM Select to the end of this paragraph
  oCursor.NumberingStartValue = 1    REM Restart the numbering
End Sub

_________________
--
Andrew Pitonyak
http://www.pitonyak.org/oo.php
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
pitonyak
Administrator
Administrator


Joined: 09 Mar 2004
Posts: 3618
Location: Columbus, Ohio, USA

PostPosted: Tue Oct 05, 2004 10:16 am    Post subject: Reply with quote

Although I did not say it, I created some paragraphs that were numbered at the start of the document before I ran this macro.
_________________
--
Andrew Pitonyak
http://www.pitonyak.org/oo.php
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
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