JZA OOo Advocate


Joined: 01 Feb 2003 Posts: 432 Location: Mexico
|
Posted: Fri Mar 30, 2007 5:50 pm Post subject: |
|
|
I remember there is an ExportToPDF function in Basic, I wonder if you can search for an Export to Jpeg.
After looking around with the Andrew Pitonyak Macro Document.
I found the following snippet:
| Code: | Sub ExportCurrentPageOrSelection
REM Filter dependent filter properties
Dim aFilterData (4) As New com.sun.star.beans.PropertyValue
Dim sFileUrl As String
aFilterData(0).Name = "PixelWidth"
aFilterData(0).Value = 1000
aFilterData(1).Name = "PixelHeight"
aFilterData(1).Value = 1000
aFilterData(2).Name ="LogicalWidth"
aFilterData(2).Value = 1000
aFilterData(3).Name ="LogicalHeight"
aFilterData(3).Value = 1000
aFilterData(4).Name ="Quality"
aFilterData(4).Value = 60
sFileUrl = "file:///d:/test2.jpg"
REM A smart person would force this to be a Draw or Impress document
xDoc = ThisComponent
xView = xDoc.currentController
xSelection = xView.selection
If isEmpty( xSelection ) Then
xObj = xView.currentPage
Else
xObj = xSelection
End If
Export( xObj, sFileUrl, aFilterData() )
End Sub
Sub Export( xObject, sFileUrl As String, aFilterData )
Dim xExporter
xExporter = createUnoService( "com.sun.star.drawing.GraphicExportFilter" )
xExporter.SetSourceDocument( xObject )
Dim aArgs (2) As New com.sun.star.beans.PropertyValue
Dim aURL As New com.sun.star.util.URL
aURL.complete = sFileUrl
aArgs(0).Name = "MediaType"
aArgs(0).Value = "image/jpeg"
aArgs(1).Name = "URL"
aArgs(1).Value = aURL
aArgs(2).Name = "FilterData"
aArgs(2).Value = aFilterData
xExporter.filter( aArgs() )
End Sub |
The script is not exactly the one you were expecitng but is a big start. _________________ Alexandro Colorado
PPMC Apache OpenOffice
http://es.openoffice.org |
|