OpenOffice-Basic GraphicExportFilter documentation?

Discuss the drawing application

OpenOffice-Basic GraphicExportFilter documentation?

Postby smiropolsky » Sun Nov 22, 2015 7:39 pm

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.
OpenOffice 4.0.0 on Windows XP 32 Bit
User avatar
Posts: 8
Joined: Fri Feb 01, 2013 2:22 pm
Location: Dortmund, Germany

Re: OpenOffice-Basic GraphicExportFilter documentation?

Postby Zizi64 » Sat Apr 02, 2016 10:28 am

Tibor Kovacs, Hungary; LO6.1.6, 6.2.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-6.4.1; AOO4.1.6
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Posts: 8910
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Return to Draw

Who is online

Users browsing this forum: No registered users and 4 guests