OpenOffice-Basic GraphicExportFilter documentation?

Discuss the drawing application
Post Reply
User avatar
smiropolsky
Posts: 10
Joined: Fri Feb 01, 2013 2:22 pm
Location: Dortmund, Germany

OpenOffice-Basic GraphicExportFilter documentation?

Post 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

 ' ... variable declaration and size calculations are omitted ...

Dim aFilterData(7) As New com.sun.star.beans.PropertyValue

   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

 Dim aURL As New com.sun.star.util.URL
aURL.Complete  = ConvertToURL( fileName )

Dim aArgs(2) As New com.sun.star.beans.PropertyValue

   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

oDoc  = ThisComponent
oView = oDoc.CurrentController
oObj  = oView.Selection

oExporter = createUnoService("com.sun.star.drawing.GraphicExportFilter")
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,
Sergey

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
Zizi64
Volunteer
Posts: 11360
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: OpenOffice-Basic GraphicExportFilter documentation?

Post by Zizi64 »

Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
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.
Post Reply