Re: [api-dev] How to identify and remove empty pages in writer document.

2005-05-14 Thread malcolm cooke
Hi Paolo,
I would if I could :-)
Unfortunately the adding / removing of text to/from the template document 
(which in itself contains a lot of formatted text) is database driven and 
dependent upon a whole host of factors based around a particular customers 
geographic location. Obviously the template has to cater for all 
possibilities and as large amounts of text get added / removed the original 
page boundaries fluctuate.

Malcolm
 At 22:21 13/05/2005, you wrote:
Hi Malcom,
Alle 18:02, venerdì 13 maggio 2005, malcolm cooke ha scritto:
 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)
[]
Bingo!
the pages of a document are the consequence.
You should act on the cause instead.
empty rows?  wrong page style? wrong paragraph style? or manual page breaks?
Ask yourself what is the cause of empty pages in your document and remove it
using API's
ciao
Paolo Mantovani
-
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.9 - Release Date: 12/05/2005

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


Re: [api-dev] How to identify and remove empty pages in writer document.

2005-05-14 Thread Christian Junker
Hi Malcolm,

maybe the macro I just wrote will help you. Please note that it is by
no means 'perfect' because I have not tested all possible situations.
The problem is that there is no such API function as to recognize
whether a page is empty, so you have to check it on your own. Because
there are many ways to skip a page it is also not doable in one
specific and simple way.

My macro checks the first 'chars' characters on the page, if they are
all whitespace or if there is none but a page break it will remove the
page. You can set the value to whatever you want (I check for the first
50 characters), depending on how well your document is structured. For
example if you don't have messy formatting (messy means i.e. if some
pages only have text in the middle and don't start at the top) then you
can set it be low, otherwise set this value much higher.

code
Private chars as Integer 'specifies the number of characters checked at the beginning of every page

Function emptypage
Dim i as Integer
chars = 50

odoc = thisComponent 
'if you have problems with thisComponent for the new OOo 2.0 builds, 
'use Stardesktop.getCurrentComponent() instead

otext = odoc.getText()
cur = otext.createTextCursor() 
cur.goToStart(False)

view = odoc.getCurrentController()
viewcursor = view.getViewCursor()

'retrieve total page number
viewcursor.jumpToLastPage()
npages = viewcursor.getPage()
viewcursor.jumpToFirstPage()

For i = 1 to npages
 cur.goRight(chars, True)
 txt = Trim(cur.String)
 If len(txt) = 0 Then
  DeletePage(cur, i)
 Else
  If Asc(txt) = 32 Then 
   DeletePage(cur, i)
  Else
   viewcursor.jumpToNextPage() 
   cur.goToRange(viewcursor.getStart(), False)
  End If
 End If 
 
Next i

End Function

Function DeletePage(cur, i as Integer)
cur.goLeft(chars, False)
cur.goToNextWord(True)
cur.setString()
i =+ 1
End Function/code

Hope this helps you.
2005/5/14, malcolm cooke [EMAIL PROTECTED]:
Hi Paolo,I would if I could :-)Unfortunately the adding / removing of text to/from the template document(which in itself contains a lot of formatted text) is database driven anddependent upon a whole host of factors based around a particular customers
geographic location. Obviously the template has to cater for allpossibilities and as large amounts of text get added / removed the originalpage boundaries fluctuate.MalcolmAt 22:21 13/05/2005, you wrote:
Hi Malcom,Alle 18:02, venerdì 13 maggio 2005, malcolm cooke ha scritto:  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 textadded / 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)
[]Bingo!the pages of a document are the consequence.You should act on the cause instead.empty rows?wrong page style? wrong paragraph style? or manual page breaks?
Ask yourself what is the cause of empty pages in your document and remove itusing API'sciaoPaolo Mantovani-
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.9 - Release Date: 12/05/2005
--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 RegardsChristian Junker


Re: [api-dev] How to identify and remove empty pages in writer document.

2005-05-14 Thread Christian Junker
U, this works better I guess:
REM * BASIC *

Private chars as Integer 'specifies the number of characters checked at the beginning of every page

Function Delete_empty_pages
Dim i as Integer
chars = 50

odoc = thisComponent 
'if you have problems with thisComponent for the new OOo 2.0 builds, 
'use Stardesktop.getCurrentComponent() instead

otext = odoc.getText()
cur = otext.createTextCursor() 
cur.goToStart(False)

view = odoc.getCurrentController()
viewcursor = view.getViewCursor()

'retrieve total page number
viewcursor.jumpToLastPage()
npages = viewcursor.getPage()
viewcursor.jumpToFirstPage()

For i = 1 to npages
 cur.goRight(chars, True)
 txt = Trim(cur.String)
 If len(txt) = 0 Then
  DeletePage(cur, i)
 Else
  If Asc(txt) = 32 Then 
   DeletePage(cur, i)
  End If
 End If 
 viewcursor.jumpToNextPage() 
 cur.goToRange(viewcursor.getStart(), False)
Next i

End Function

Function DeletePage(cur, i as Integer)
cur.goLeft(chars, False)
cur.goToNextWord(True)
cur.setString()
i =+ 1
End Function2005/5/14, Christian Junker [EMAIL PROTECTED]:
Hi Malcolm,

maybe the macro I just wrote will help you. Please note that it is by
no means 'perfect' because I have not tested all possible situations.
The problem is that there is no such API function as to recognize
whether a page is empty, so you have to check it on your own. Because
there are many ways to skip a page it is also not doable in one
specific and simple way.

My macro checks the first 'chars' characters on the page, if they are
all whitespace or if there is none but a page break it will remove the
page. You can set the value to whatever you want (I check for the first
50 characters), depending on how well your document is structured. For
example if you don't have messy formatting (messy means i.e. if some
pages only have text in the middle and don't start at the top) then you
can set it be low, otherwise set this value much higher.

code
Private chars as Integer 'specifies the number of characters checked at the beginning of every page

Function emptypage
Dim i as Integer
chars = 50

odoc = thisComponent 
'if you have problems with thisComponent for the new OOo 2.0 builds, 
'use Stardesktop.getCurrentComponent() instead

otext = odoc.getText()
cur = otext.createTextCursor() 
cur.goToStart(False)

view = odoc.getCurrentController()
viewcursor = view.getViewCursor()

'retrieve total page number
viewcursor.jumpToLastPage()
npages = viewcursor.getPage()
viewcursor.jumpToFirstPage()

For i = 1 to npages
 cur.goRight(chars, True)
 txt = Trim(cur.String)
 If len(txt) = 0 Then
  DeletePage(cur, i)
 Else
  If Asc(txt) = 32 Then 
   DeletePage(cur, i)
  Else
   viewcursor.jumpToNextPage() 
   cur.goToRange(viewcursor.getStart(), False)
  End If
 End If 
 
Next i

End Function

Function DeletePage(cur, i as Integer)
cur.goLeft(chars, False)
cur.goToNextWord(True)
cur.setString()
i =+ 1
End Function/code

Hope this helps you.
2005/5/14, malcolm cooke [EMAIL PROTECTED]
:
Hi Paolo,I would if I could :-)Unfortunately the adding / removing of text to/from the template document(which in itself contains a lot of formatted text) is database driven anddependent upon a whole host of factors based around a particular customers
geographic location. Obviously the template has to cater for allpossibilities and as large amounts of text get added / removed the originalpage boundaries fluctuate.MalcolmAt 22:21 13/05/2005, you wrote:
Hi Malcom,Alle 18:02, venerdì 13 maggio 2005, malcolm cooke ha scritto:  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 textadded / 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)
[]Bingo!the pages of a document are the consequence.You should act on the cause instead.empty rows?wrong page style? wrong paragraph style? or manual page breaks?
Ask yourself what is the cause of empty pages in your document and remove itusing API'sciaoPaolo Mantovani-
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.9 - Release Date: 12/05/2005

--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 RegardsChristian Junker

-- Best RegardsChristian Junker


[api-dev] Accessing metadata.

2005-05-14 Thread Brian Raymond
I have a need to strip all metadata on a document programmatically that's
not required for operation. I currently use the DocumentInfo interface and
can access the properties and set everything that isn't required to anemptty
sring however I have a couple of small problems.

I check to see if attributes are removable and if so I'd like to take them
out however I haven't figured out how to actually delete them, can someone
provide some help on how it can be done given a handle to the property.

I also noticed that the DocumentInfo interface doesn't include the Info1-4
tags that are present in the properties of all documents. I didn't notice
this at first because I thought DocumentInfo helf it all. Is there any
generic interface applicable to all documents which also contains these?

Any help would be appreciated.

Thanks...

- Brian

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