CALC Page Styles in macro

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
hellgiver
Posts: 2
Joined: Sun Dec 21, 2008 5:14 pm

CALC Page Styles in macro

Post by hellgiver »

Hey guys, I'm having trouble finding ANY information on how to change the scaling mode for pages (Format > Page > Sheet > Scale, then select "fit print ranges to width/height" and width=1, height=blank, then click OK)

The only thing I can find so far is this which just opens the dialog box, it does not change any settings for me.

Code: Select all

dispatcher.executeDispatch(document, ".uno:PageFormatDialog", "", 0, Array())

Any help would be great.
OOo 2.3.X on MS Windows Vista + Fedora 10, Ubuntu 8.10
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: CALC Page Styles in macro

Post by Villeroy »

The overall concept of templates and styles has been implemented in order to obsolete excessive macro programming. What the recorder records has nothing to do with macro programming. It records the user's actions on the interface (select this, call command, go down, call other command, ...).
Just prepare your own styles within your own templates and let the user double-click a style name instead of calling a macro.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
probe1
Volunteer
Posts: 277
Joined: Mon Oct 08, 2007 1:34 am
Location: Chonburi Thailand

Re: CALC Page Styles in macro

Post by probe1 »

Welcome to the forums.

Such information could be found -of course- in the documentation, API reference, see: TablePageStyles
Download and install the SDK from http://development.openoffice.org/


@Villeroy
Your post doesn't answer a valid question. You certainly did know the answer - why nagging the askers intentions you do not know?


Happy Holidays to everybody.
Cheers
Winfried

DateTime2 extension: insert date, time or timestamp, formatted to your needs
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: CALC Page Styles in macro

Post by Villeroy »

No, I don't know the answer.
Wild guess:

Code: Select all

view= thiscomponent.getCurrentController()
fam=thiscomponent.stylefamilies.getbyname("PageStyles")
sh=view.getActivesheet()
style=fam.getbyname(sh.PageStyle)
... and then some scale-property from http://api.openoffice.org/docs/common/r ... Style.html
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
hellgiver
Posts: 2
Joined: Sun Dec 21, 2008 5:14 pm

Re: CALC Page Styles in macro

Post by hellgiver »

Ok guys, so I've got this but it does not work. It completes without any errors, but the setting is not set correctly.

Code: Select all

Dim pageOptions(0) As New com.sun.star.beans.PropertyValue
pageOptions(0).Name = "ScaleToPagesX"
pageOptions(0).Value = 1
thisComponent.Printer = pageOptions()
BTW this has to run on OOo 2.3
OOo 2.3.X on MS Windows Vista + Fedora 10, Ubuntu 8.10
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: CALC Page Styles in macro

Post by Villeroy »

Code: Select all

view= thiscomponent.getCurrentController()
fam=thiscomponent.stylefamilies.getbyname("PageStyles")
sh=view.getActivesheet()
style=fam.getbyname(sh.PageStyle)
style.ScaleToPagesX = 1
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply