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

Newbie: Determine value of PageBreak ?

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


Joined: 09 Jan 2005
Posts: 2

PostPosted: Sun Jan 09, 2005 11:15 am    Post subject: Newbie: Determine value of PageBreak ? Reply with quote

I am using Star Office 7.
I want to create a macro that toggles the Paragraph option to enable a page break at the current paragraph. I used the record macro feature, and created a function to turn on the enable and another to turn it off.
To make this a toggle, I need to combine these two macros into one and determine the existing value so I can set the opposite.
Being an old crusty C programmer, I have searched the docs and found many complex examples, but nothing simple enough for me to understand how to query the existing value. I think the property is PageBreak and it might be in something called a service named com.sun.star.text.Paragraph. How do I retrieve the current value ?
The existing macro that turns the break enable on follows.
Thanks very much !!
Jeff Page

sub PageBreakOn
dim document as object
dim dispatcher as object
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Pagebreak"
args1(0).Value = com.sun.star.style.BreakType.PAGE_BEFORE
dispatcher.executeDispatch(document, ".uno:Pagebreak", "", 0, args1())
dim args2(1) as new com.sun.star.beans.PropertyValue
args2(0).Name = "AttributeParaModel.Auto"
args2(0).Value = false
args2(1).Name = "AttributeParaModel.Name"
args2(1).Value = ""
dispatcher.executeDispatch(document, ".uno:AttributeParaModel", "", 0, args2())
end sub
Back to top
View user's profile Send private message Send e-mail
ms777
Super User
Super User


Joined: 07 Feb 2004
Posts: 1355

PostPosted: Sun Jan 09, 2005 12:43 pm    Post subject: Reply with quote

I believe, with the Dispatchhelper you are not able to retrieve some properties. But as I am quite a newbie I recommend you to browse for some posts from Danny B or other senior experts on Dispatch helper

The direct way through API programming is quite short:
Code:
Sub ToggleBreak
  Dim oText
  Dim oViewCursor
         
  oText = ThisComponent.getText()
  oViewCursor = ThisComponent.CurrentController.getViewCursor()
  if (oViewCursor.BreakType = com.sun.star.style.BreakType.NONE) then
    oViewCursor.BreakType = com.sun.star.style.BreakType.PAGE_BEFORE
    else
    oViewCursor.BreakType = com.sun.star.style.BreakType.NONE
    endif

End Sub


P.S. If these are your first steps into OOo Basic I recommend the following from my experience as a newbie:

1. Install the SDK for local access to the API documentation
2. Then forget the documentation - Do not try to learn macro writing from the API documentation.
3. Browse through some general posts from Danny B or Andrew Pytoniak, read their macros
4. Install and understand XRay
5. Then (and only then) try o use the API documentation

The API doc is written from experts for experts. Even M$ help files are much easier to understand
Back to top
View user's profile Send private message
Jpage
Newbie
Newbie


Joined: 09 Jan 2005
Posts: 2

PostPosted: Sun Jan 09, 2005 2:37 pm    Post subject: re: Newbie: Determine value of PageBreak ? Reply with quote

Excellent. I pasted your code in to replace what I had and it works !
Nothing resembles what the macro recorded, so I guess the recording had me on the wrong track. I can't claim to understand what this does, but since it works, I am very happy !
Thanks.
Jeff Page
Back to top
View user's profile Send private message Send e-mail
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