Macros are small task-specific programs written in a language specific to OpenOffice.org. Macros can do things like open a file when you do a particular task, process data, or take your grandmother's credit cards and buy $3000 worth of cat toys. Pretty much whatever you want. You can hook them up to events, things like clicking the mouse button or putting the pointer in a field, as well as just run'em. There are a bunch of existing macros (see Figure A-1), as well, and the help provides a description of each one. Figure A-1. Existing macros you can use
You can also write your own in the macro composition window. Here's one in Figure A-2 that when filled in will export a single drawing page from a loaded Draw or Impress document to a wmf , from the great folks on the OpenOffice.org mailing lists. Figure A-2 Macro that exports a drawing from Draw or Impress to . wmf , from the OpenOffice.org archivesXDrawPage thePage = ...; String Url = ...; Object xPorterService = xMSF.createInstance("com.sun.star.drawing.GraphicExporterFilter"); XExporter xPorter = (XExporter) UnoRuntime.queryInterface(XExporter.class, xPorterService); XFilter xFilter = (XFilter) UnoRuntime.queryInterface(XFilter.class, xPorterService); XComponent xComp = (XComponent) UnoRuntime.queryInterface(XComponent.class,thePage); xPorter.setSourceDocument(xComp); PropertyValue propertyvalues[] = new PropertyValue[2]; propertyvalues[0] = new PropertyValue(); propertyvalues[0].Name = "FilterName"; propertyvalues[0].Value = "WMF"; propertyvalues[1] = new PropertyValue(); propertyvalues[1].Name = "URL"; propertyvalues[1].Value = Url; xFilter.filter(propertyvalues); |