[Solved] Insert pagebreak

The Application Programming Interface and the OASIS Open Document Format

[Solved] Insert pagebreak

Postby Peter18 » Thu Nov 03, 2011 5:32 pm

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
Peter18
 
Posts: 99
Joined: Thu May 12, 2011 1:01 pm

Re: Insert pagebreak

Postby FJCC » Thu Nov 03, 2011 6:13 pm

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   Expand viewCollapse view
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
AOO 3.4 or 4.1 on MS Windows XP ( before 2013-08-03) or Windows 7
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 6169
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Insert pagebreak

Postby Peter18 » Thu Nov 03, 2011 7:15 pm

Hello FJCC,

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

Greatings

Peter
OpenOffice 3.3; OpenOffice 4.1.1
Peter18
 
Posts: 99
Joined: Thu May 12, 2011 1:01 pm

Re: Insert pagebreak

Postby FJCC » Thu Nov 03, 2011 8:38 pm

Yes, a value of 0 means None. Youcan see the order here: http://api.openoffice.org/docs/common/ref/com/sun/star/style/BreakType.html
AOO 3.4 or 4.1 on MS Windows XP ( before 2013-08-03) or Windows 7
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 6169
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Insert pagebreak

Postby Peter18 » Fri Nov 04, 2011 10:16 am

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
Peter18
 
Posts: 99
Joined: Thu May 12, 2011 1:01 pm

Re: Insert pagebreak

Postby hanya » Fri Nov 04, 2011 11:47 am

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   Expand viewCollapse view
#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
hanya
Volunteer
 
Posts: 879
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: Insert pagebreak

Postby FJCC » Fri Nov 04, 2011 2:39 pm

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.
AOO 3.4 or 4.1 on MS Windows XP ( before 2013-08-03) or Windows 7
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 6169
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Insert pagebreak

Postby Peter18 » Mon Nov 14, 2011 11:24 am

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
Peter18
 
Posts: 99
Joined: Thu May 12, 2011 1:01 pm

Re: [Solved] Insert pagebreak

Postby hanya » Mon Nov 14, 2011 6:01 pm

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
hanya
Volunteer
 
Posts: 879
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: [Solved] Insert pagebreak

Postby _savage » Tue Feb 03, 2015 7:03 pm

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.11 using LO 5.3.6.1, Gentoo Linux using LO 5.3.4.2 headless.
_savage
 
Posts: 141
Joined: Sun Apr 21, 2013 12:55 am

Re: [Solved] Insert pagebreak

Postby FJCC » Tue Feb 03, 2015 11:21 pm

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   Expand viewCollapse view
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.
AOO 3.4 or 4.1 on MS Windows XP ( before 2013-08-03) or Windows 7
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 6169
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: [Solved] Insert pagebreak

Postby _savage » Wed Feb 04, 2015 2:35 am

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.11 using LO 5.3.6.1, Gentoo Linux using LO 5.3.4.2 headless.
_savage
 
Posts: 141
Joined: Sun Apr 21, 2013 12:55 am

Re: [Solved] Insert pagebreak

Postby FJCC » Wed Feb 04, 2015 4:31 am

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.
AOO 3.4 or 4.1 on MS Windows XP ( before 2013-08-03) or Windows 7
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 6169
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: [Solved] Insert pagebreak

Postby _savage » Wed Feb 04, 2015 8:17 am

Great, thank you :)
Mac 10.11 using LO 5.3.6.1, Gentoo Linux using LO 5.3.4.2 headless.
_savage
 
Posts: 141
Joined: Sun Apr 21, 2013 12:55 am


Return to UNO API and ODF

Who is online

Users browsing this forum: No registered users and 2 guests