[Solved] Insert pagebreak

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] Insert pagebreak

Post by Peter18 »

A friendly hello to anybody,

I want to Insert at the end of a document a pagebreak. I found a method named setPageBreak but it did not work. It looks like a part of a package for a specific programming language. The "StarOffice Programmer’s Tutorial" told me a pagebreak is a property of a paragraph. So I tried to get the properties. Any testwhith the cursor object I tried failed.

Now I have 3 problems:
  • How to get the last paragraph
    How to get the property values of the last paragraph (I want to remove a pagebreak too)
    How to set the breakType with Delphi
The list of breakTypes lists only textual types, but no values I can set from Delphi.

Who can help??

Greetings

Peter
Last edited by Peter18 on Mon Nov 14, 2011 11:24 am, edited 1 time in total.
OpenOffice 3.3; OpenOffice 4.1.1
FJCC
Moderator
Posts: 9273
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Insert pagebreak

Post by FJCC »

Enums are listed in order of their numeric values. In Basic, I can set the BreakType to either PAGE_BEFORE or PAGE_AFTER like this:

Code: Select all

oText = ThisComponent.Text
Curs = oText.createTextCursor()
Curs.gotoEnd(false)
'Curs.BreakType = 4 'com.sun.star.style.BreakType.PAGE_BEFORE
Curs.BreakType = 5 'com.sun.star.style.BreakType.PAGE_AFTER
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Peter18
Posts: 102
Joined: Thu May 12, 2011 1:01 pm

Re: Insert pagebreak

Post by Peter18 »

Hello FJCC,

thank you for your answer. Is "Curs.BreakType = 0" no pagebreak???

Greatings

Peter
OpenOffice 3.3; OpenOffice 4.1.1
FJCC
Moderator
Posts: 9273
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Insert pagebreak

Post by FJCC »

Yes, a value of 0 means None. Youcan see the order here: http://api.openoffice.org/docs/common/r ... kType.html
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Peter18
Posts: 102
Joined: Thu May 12, 2011 1:01 pm

Re: Insert pagebreak

Post by Peter18 »

Hello FJCC,

thank you!I'll try it. I found the page your link is pointing to, but there are no values.

Greetings

Peter
OpenOffice 3.3; OpenOffice 4.1.1
hanya
Volunteer
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: Insert pagebreak

Post by hanya »

but there are no values.
see: http://wiki.services.openoffice.org/wik ... alues#enum

I have not seen any enum which has specified value in IDL Reference.
If an IDL defined as follows, autodoc generates "BAR = 10," in the description of BAR element.

Code: Select all

#ifndef __Myenum__
#define __Myenum__

published enum Myenum
{ 
	NONE, 
	FOO, 
	BAR = 10, 
	HOGE, 
};

#endif
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
FJCC
Moderator
Posts: 9273
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Insert pagebreak

Post by FJCC »

I'm sorry I was unclear. The values are not shown on the linked page, just the order of the enum list. I deduced the value from that order. I got the values for PAGE_BEFORE and PAGE_AFTER just by counting down the list, starting with zero. I read somewhere that enums are always listed in the order of their value. I don't recommend using those values normally, but since I don't know how to get Delphi to recognize the value of com.sun.star.style.BreakType.PAGE_BEFORE, I mentioned this trick.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Peter18
Posts: 102
Joined: Thu May 12, 2011 1:01 pm

Re: Insert pagebreak

Post by Peter18 »

Hello,

I'm sorry I could not look at the board for some days.

Hello FJCC,

thank you for your answer. "com.sun.star.style.BreakType.PAGE_BEFORE" did not work, but I declared a const and it worked. I think you are right, the code is the index of enumeration.

Hello hanya,

thank you too for your answer.
hanya wrote:I have not seen any enum which has specified value in IDL Reference.
I saw a enumeration with corresponding number, but I don't remember in what context. If I find it again I'll give you the link,

Greetings

Peter
OpenOffice 3.3; OpenOffice 4.1.1
hanya
Volunteer
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: [Solved] Insert pagebreak

Post by hanya »

Peter18 wrote:I saw a enumeration with corresponding number, but I don't remember in what context. If I find it again I'll give you the link,
I found an enum having a value specified: http://api.openoffice.org/docs/common/r ... Depth.html .
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
_savage
Posts: 187
Joined: Sun Apr 21, 2013 12:55 am

Re: [Solved] Insert pagebreak

Post by _savage »

Where do I find these breaks in a given document? I mean, when I iterate over all paragraphs how do I detect that there is such a page break in the text?
Mac 10.14 using LO 7.2.0.2, Gentoo Linux using LO 7.2.3.2 headless.
FJCC
Moderator
Posts: 9273
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: [Solved] Insert pagebreak

Post by FJCC »

Each paragraph has a BreakType property. If I make a two paragraph document with a page break before the second paragraph and I run

Code: Select all

oText = ThisComponent.Text
oCurs = oText.createTextCursor()
oCurs.gotoStart(False)
print oCurs.BreakType
oCurs.gotoNextParagraph(False)
print oCurs.BreakType
the first print statement returns the value zero and the second one returns four. The numeric values are assigned according to the order here.. The first paragraph in my document has BreakType=NONE and the second has BreakType=PAGE_BEFORE.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
_savage
Posts: 187
Joined: Sun Apr 21, 2013 12:55 am

Re: [Solved] Insert pagebreak

Post by _savage »

Thanks, got it.

Then what's the difference between a SoftPageBreak as a TextPortion type, and a PAGE_BREAK as a BreakType of a paragraph?
Mac 10.14 using LO 7.2.0.2, Gentoo Linux using LO 7.2.3.2 headless.
FJCC
Moderator
Posts: 9273
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: [Solved] Insert pagebreak

Post by FJCC »

A soft pagebreak is created by Writer itself as text reaches the end of one page and starts on another. The BreakType of a paragraph is inserted manually by the user.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
_savage
Posts: 187
Joined: Sun Apr 21, 2013 12:55 am

Re: [Solved] Insert pagebreak

Post by _savage »

Great, thank you :)
Mac 10.14 using LO 7.2.0.2, Gentoo Linux using LO 7.2.3.2 headless.
Post Reply