Page 1 of 1

OpenOffice-Basic GraphicExportFilter documentation?

PostPosted: Sun Nov 22, 2015 7:39 pm
by smiropolsky
Hi everybody,

I am looking for a macro, capable of exporting the currently selected object or group to a fixed-dpi dpi bitmap with transparent background (e.g. with "image/png" media type, 300 DPI)" to a fixed file name, or directly to a clipboard, so that I can paste the image directly into external program.

Having read several old threads, I was able to write such macro using GraphicsExportFilter service.

Following code defines the Property-Value variable containing settings for graphics export filter for some MediaType:

Code: Select all   Expand viewCollapse view
' ... variable declaration and size calculations are omitted ...

Dim aFilterData(7) As New

   aFilterData(0).Name  = "PixelWidth"
   aFilterData(0).Value = pixelWidth
   aFilterData(1).Name  = "PixelHeight"
   aFilterData(1).Value = pixelHeight
   aFilterData(2).Name  = "LogicalWidth"
   aFilterData(2).Value = logicalWidth
   aFilterData(3).Name  = "LogicalHeight"
   aFilterData(3).Value = logicalHeight
   aFilterData(4).Name  = "Quality"
   aFilterData(4).Value = 100
   aFilterData(5).Name  = "ColorMode"
   aFilterData(5).Value = 1
   aFilterData(6).Name  = "ExportMode"
   aFilterData(6).Value = 1
   aFilterData(7).Name  = "Resolution"
   aFilterData(7).Value = 300

Following code defines another Property-Value variable with media type and filter settings (above):

Code: Select all   Expand viewCollapse view
Dim aURL As New
aURL.Complete  = ConvertToURL( fileName )

Dim aArgs(2) As New

   aArgs(0).Name = "MediaType"
   aArgs(0).Value = "image/png"
   aArgs(1).Name = "URL"
   aArgs(1).Value = aURL
   aArgs(2).Name = "FilterData"
   aArgs(2).Value = aFilterData ' ... defined above

Finally, following code calls the graphics filter with settings above

Code: Select all   Expand viewCollapse view
oDoc  = ThisComponent
oView = oDoc.CurrentController
oObj  = oView.Selection

oExporter = createUnoService("")
oExporter.SetSourceDocument( oObj )
oExporter.Filter( aArgs )

This creates PNGs with hard-coded file name and resolution. What I'm now looking for, is

1) Some documentation on FilterData properties/values accepted by .Filter() method of GraphicExportFilter service. (Context: what do these properties/values mean, and which one turns on the transparency of produced PNGs?)

2) Some documentation or perhaps a code snippet, capable of exporting the same PNG image not to a file, but to a clipboard?

Any idea?

Thanks in advance,

PS: I'm aware of File/Export... dialog. I'm looking for a way to reduce the export procedure to a single keyboard shortcut.

Re: OpenOffice-Basic GraphicExportFilter documentation?

PostPosted: Sat Apr 02, 2016 10:28 am
by Zizi64