Detect page break in long tables (Writer)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Detect page break in long tables (Writer)

Ralf Heydenreich
Hi all,
I've a Writer document with a table an some placeholders in it. Now, if
I replace these placeholders from my Java application, the table
sometimes gets too long and split over multiple pages. Since it is a
kind of invoice table I want to put a subtotal at the end of each page.
How can I achieve this? How can I detect a page break while filling the
placeholders?

TIA,
Ralf.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Detect page break in long tables (Writer)

Bernard Marcelly
Hi Ralf,
You have to put the view cursor in a cell. The view cursor shows the page number
where it is situated.

Here is a proof of concept, in OpenOffice Basic.
In a Writer document, insert a table with only one row (the title row).
The macro will insert 100 lines and show you the row numbers where the page has
changed:

Sub Main1
Dim myDoc As Object, tb As Object, rws As Object
Dim vCurs As Object, curs1 As Object
Dim p1 As Long, p2 As Long, x As Long

myDoc = ThisComponent
tb = myDoc.getTextTables.getByIndex(0)
rws = tb.getRows
curs1 = tb.getCellByPosition(0,0)
myDoc.getCurrentController.select(curs1)
vCurs = myDoc.getCurrentController.getViewCursor
p1 = vCurs.getPage
for x = 1 to 100
   rws.insertByIndex(rws.getCount, 1)
   vCurs.goDown(1, False)
   p2 = vCurs.getPage
   if p2 <> p1  then
     MsgBox("New page at line " & x)
     p1 = p2
   end if
next
End Sub


Regards
   Bernard

Message de Ralf Heydenreich  date 2014-01-10 21:47 :

> Hi all,
> I've a Writer document with a table an some placeholders in it. Now, if
> I replace these placeholders from my Java application, the table
> sometimes gets too long and split over multiple pages. Since it is a
> kind of invoice table I want to put a subtotal at the end of each page.
> How can I achieve this? How can I detect a page break while filling the
> placeholders?
>
> TIA,
> Ralf.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]