[Solved] How to change the page style

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Peter18
Posts: 102
Joined: Thu May 12, 2011 1:01 pm

[Solved] How to change the page style

Post by Peter18 »

A friendly hello to anybody,

I want to create a letter and if it gets an attachment, I want to make a footer with the text "Attachment" but only on the end of the letter. The following pages shall not have a footer.

Code: Select all

procedure AddOOAppendTxt( OO: T_OO; Fil: String; Err: T_Error );
var
	L: Variant;

begin
  OO.Cur.gotoEnd( False );
  OO.Cur.goRight(1, False);
  OO.Cur.BreakType := PAGE_AFTER;
  L:= OO.Fil.StyleFamilies.getByName('PageStyles').getByName('First Page');
  OO.Cur.ParaStyle := L;
  OO.Fil.Text.insertControlCharacter( OO.Cur, PARAGRAPH_BREAK, False );

  InsOONewPag( OO,      Err );
  OOInsertDoc( OO, Fil, Err );
end;
The line "OO.Cur.ParaStyle" does not work. If I switch off the footer, on all pages there is no footer. How can I set a new style with no footer.

Thank you for trying to help and greetings from a sunny north see.

Peter
Last edited by Peter18 on Tue Nov 22, 2011 7:31 pm, edited 1 time in total.
OpenOffice 3.3; OpenOffice 4.1.1
User avatar
Charlie Young
Volunteer
Posts: 1559
Joined: Fri May 14, 2010 1:07 am

Re: How to change the page style

Post by Charlie Young »

Peter18 wrote:A friendly hello to anybody,

I want to create a letter and if it gets an attachment, I want to make a footer with the text "Attachment" but only on the end of the letter. The following pages shall not have a footer.

Code: Select all

procedure AddOOAppendTxt( OO: T_OO; Fil: String; Err: T_Error );
var
	L: Variant;

begin
  OO.Cur.gotoEnd( False );
  OO.Cur.goRight(1, False);
  OO.Cur.BreakType := PAGE_AFTER;
  L:= OO.Fil.StyleFamilies.getByName('PageStyles').getByName('First Page');
  OO.Cur.ParaStyle := L;
  OO.Fil.Text.insertControlCharacter( OO.Cur, PARAGRAPH_BREAK, False );

  InsOONewPag( OO,      Err );
  OOInsertDoc( OO, Fil, Err );
end;
The line "OO.Cur.ParaStyle" does not work. If I switch off the footer, on all pages there is no footer. How can I set a new style with no footer.

Thank you for trying to help and greetings from a sunny north see.

Peter
I'm somewhat confused. I can't find a property called "ParaStyle" for starters. There is a string property called ParaStyleName, but that's for a paragraph style, and it looks like you're trying to assign a page style to a paragraph. If you want to assign a ParaStyleName with the same name as the First Page PageStyle, you could try

Code: Select all

OO.Cur.ParaStyleName := L.getName()
I hope I'm not leading you in the wrong direction.

My 'First Page' style has "FooterIsOn" set to False, as well.
Apache OpenOffice 4.1.1
Windows XP
Peter18
Posts: 102
Joined: Thu May 12, 2011 1:01 pm

Re: How to change the page style

Post by Peter18 »

Hello Charlie Young,

thank you for your answer. The property called "ParaStyle" I found in a OO tutorial as example. "ParaStyleName" did not work too and "Xray" told me, it is read only. (uno.exception) If I can not set a page style to a paragaph even if it is a page break, how can I set a page style?

Andrew D. Pitonyaks "Macros Explained" gives examples for enumeration but not how to change. In "StarOffice Programmer’s Tutorial" I cold not find how to do it too.

I hope anybody can show me the way.

Greetings

Peter
OpenOffice 3.3; OpenOffice 4.1.1
User avatar
floris v
Volunteer
Posts: 4422
Joined: Wed Nov 28, 2007 1:21 pm
Location: Netherlands

Re: How to change the page style

Post by floris v »

Maybe this will help, and else the source may:
com.sun.star.style.ParagraphProperties:PageDescName
[optional] string - If this property is set, it creates a page break before the paragraph it belongs to and assigns the value as the name of the new page style sheet to use.
Source: http://wiki.services.openoffice.org/w/i ... uments.odt
OpenOffice 4.1.11 on Ubuntu; LibreOffice 6.4 on Linux Mint, LibreOffice 7.6.2.1 on Ubuntu
If your problem has been solved or your question has been answered, please edit the first post in this thread and add [Solved] to the title bar.
Nederlandstalig forum
Peter18
Posts: 102
Joined: Thu May 12, 2011 1:01 pm

Re: How to change the page style

Post by Peter18 »

Hello floris v,

thank you for your answer. At
com.sun.star.style.ParagraphProperties:PageDescName
[optional] string - If this property is set, it creates a page break before the paragraph it belongs to and assigns the value as the name of the new page style sheet to use.
I did not find a description, but in the "StarOffice Programmer’s Tutorial" I found an information I searched several times for in this document.

So I found this solution:
When I open the doc, I go to start and set

Code: Select all

OO.Cur.PageDescName := 'First Page';
If there is an attachment, I switch on the Footer in the PageStyle "First Page". To append the attachment I use this procedure:

Code: Select all

procedure AddOOAppendTxt( OO: T_OO; Fil: String; Err: T_Error );
begin
  OO.Cur.gotoEnd( False );
  OO.Cur.BreakType := PAGE_AFTER;
  OO.Fil.Text.insertControlCharacter( OO.Cur, PARAGRAPH_BREAK, False );
  OO.Cur.gotoEnd( False );
  OO.Cur.PageDescName := 'Standard';
  OOInsertDoc( OO, Fil, Err );
end;
So I have got a footer at the letter and no footer with the attachments. :D

Greetings

Peter
OpenOffice 3.3; OpenOffice 4.1.1
Post Reply