Hi Malcolm,

thanks for your input. I forgot to say that I expected fornatted text only, thus the macro is not really sophisticated yet, but by such valuable input as you gave for the texttable it might be getting to that point some time.
Process details will be found on the page I posted (at oooforum.org).

2005/5/16, malcolm cooke <[EMAIL PROTECTED]>:
Hi Christian,

I've modified one method to recognise the presence of a text table and it now appears to do what I want in my particular instance. ie inserted the following inside the Do While loop:

        if Not isEmpty(cur.TextTable) Then
           bEmptyPage = False
           Exit Do
        End If  

Here is the code modification for the complete method:

Was:

Function DealWithPage(cur)
 'recursive function, watch out for the recursion limit which used to be around 500, but
 'should have been increased by the time.
 
 Dim charcount as Integer, currentpage as Integer
 Dim bEmptyPage as Boolean

 charcount = 0
 bEmptyPage = True
 currentpage = cur.getPage()
 
 cur.jumpToEndOfPage()
 
 Do While cur.getPage() = currentpage
    If cur.goLeft(1, True) Then
       charcount = charcount + 1     
        s = cur.getString()
        If Not IsWhitespace(s) Then
           bEmptyPage = False
           Exit Do
        End If
     Else
        'first page must be empty! Exit loop and handle later.
        charcount = charcount + 1
        Exit Do
     End If            
 Loop
 
 If bEmptyPage Then
    DeletePage(cur, charcount, (currentpage = 1))
 Else
    cur.jumpToPreviousPage()   
 End If   
 
 If currentpage = 1 Then Exit Function 'careful, only exit condition!
 
 DealWithPage(cur)

End Function

NOW:

Function DealWithPage(cur)
 'recursive function, watch out for the recursion limit which used to be around 500, but
 'should have been increased by the time.
 
 Dim charcount as Integer, currentpage as Integer
 Dim bEmptyPage as Boolean

 charcount = 0
 bEmptyPage = True
 currentpage = cur.getPage()
 
 cur.jumpToEndOfPage()
 
 Do While cur.getPage() = currentpage
    If cur.goLeft(1, True) Then
       charcount = charcount + 1
        if Not isEmpty(cur.TextTable) Then
           bEmptyPage = False
           Exit Do
        End If        
        s = cur.getString()
        If Not IsWhitespace(s) Then
           bEmptyPage = False
           Exit Do
        End If
     Else
        'first page must be empty! Exit loop and handle later.
        charcount = charcount + 1
        Exit Do
     End If            
 Loop
 
 If bEmptyPage Then
    DeletePage(cur, charcount, (currentpage = 1))
 Else
    cur.jumpToPreviousPage()   
 End If   
 
 If currentpage = 1 Then Exit Function 'careful, only exit condition!
 
 DealWithPage(cur)

End Function

I will carry on testing this out and let you know if I find anything else. (Now to create a java version for my needs :-) )

Many thanks for the help.

Malcolm


 At 12:12 16/05/2005, you wrote:
Hi Christian

I've tried the code and it's not quite working at the moment. It appears to be getting stuck within a blank table cell (first cell in a row) - though why this should be the case I don't know as later cells (eg those I'd expect to be processed first if working backwards) have text inside them so it should have tripped the logic to go to the previous page.

I am presuming that the cur.getString method does return something for text in a table cell. (Still trying to find some info on this method for cursors)

Thanks for all help so far.

Malcolm.

 At 15:54 15/05/2005, you wrote:

Alright, after some replies with code that was just out of the box, meaning it wasn't well thought about, I decided to spend some more time on this coming up with a hopefully complete-working macro. The result can be seen on:
http://www.oooforum.org/forum/viewtopic.phtml?t=20153

As a remark: It is nice to see how much can be done with just the viewcursors, no need for a textcursor to accomplish such a task.

Tom, if you want to include this into your snippets page you can go ahead.
As said on the linked page, please give me some input if you encounter problems with this macro, I have not done any extensive tests yet.

2005/5/13, malcolm cooke < [EMAIL PROTECTED] >:
Hi,
I wonder if anyone can give me pointers how to do this?
Background - a document is created programmatically from a template and in
the process text  added / removed. As a result now end up with empty pages
because of the way text is now flowing through the document. There is a
need to remove the extra blank pages.
I have looked at content xml to see if anything obvious to identify the
blank page and there isn't (which I suppose is understandable because the
blanks pages are a symptom of the 'presentation' of the content)
I have looked through the api and there is nothing obvious there either.
One possibility comes to mind but I'm not experienced enough with the api's
to know if it is a feasible approach or not :
identify number of pages in doc.
for each page in doc
        use XpageCursor to jump to page
        somehow extract the text range for each page (? create a text cursor for
the page)
        if text range is empty
                store page number
for each stored page number (processed in reverse order)
        remove the page from the document (?how)
Perhaps someone with more knowledge could comment on what I'm trying to do
or point to some other part of the api which might do what I want to do.
Thanks
Malcolm
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.11.9 - Release Date: 12/05/2005
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
Best Regards
Christian Junker

No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.11.10 - Release Date: 13/05/2005


No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.11.10 - Release Date: 13/05/2005


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.11.10 - Release Date: 13/05/2005



No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.11.10 - Release Date: 13/05/2005


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
Best Regards
Christian Junker

Reply via email to