Filter Options

From Apache OpenOffice Wiki
< Documentation‎ | DevGuide
Revision as of 14:13, 20 December 2020 by DiGro (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search



The method filter() takes a sequence of PropertyValue structs describing the filter parameters. The following properties from the com.sun.star.document.MediaDescriptor are supported:

Properties of com.sun.star.document.MediaDescriptor supported by GraphicExportFilter
MediaType Depending on the export filters supported by this component, this is the mime type of the target graphic file. The mime types currently supported are:

image/x-MS-bmp application/dxf application/postscript image/gif image/jpeg image/png image/x-pict image/x-pcx image/x-portable-bitmap image/x-portable-graymap image/x-portable-pixmap image/x-cmu-raster image/targa image/tiff image/x-xbitmap image/x-xpixmap image/svg+xml

FilterName This property can been used if no MediaType exists with "Windows Metafile" or "Enhanced Metafile". FilterName has to be set to the extension of these graphic formats (WMF, EMF, BMP).
URL The target URL of the file that is created during export.
Documentation note.png If necessary, use the interface XMimeTypeInfo to get all mime types supported by the GraphicExportFilter. It offers the following methods:
  boolean supportsMimeType( [in] string MimeTypeName )
  sequence< string > getSupportedMimeTypeNames()

XMimeTypeInfo is currently not supported by the GraphicExportFilter.

The following example exports a draw page xPage from a given document xDrawDoc:

  //get draw pages
  com.sun.star.drawing.XDrawPagesSupplier xPageSupplier = (com.sun.star.drawing.XDrawPagesSupplier)
      UnoRuntime.queryInterface(com.sun.star.drawing.XDrawPagesSupplier.class, xDrawDoc);
  com.sun.star.drawing.XDrawPages xDrawPages = xPageSupplier.getDrawPages();
 
  // first page
  Object page = xDrawPages.getByIndex(0);
  com.sun.star.drawing.XDrawPage xPage = (com.sun.star.drawing.XDrawPage)UnoRuntime.queryInterface(
      com.sun.star.drawing.XDrawPage.class, page);
 
  Object GraphicExportFilter = xServiceFactory.createInstance(
      "com.sun.star.drawing.GraphicExportFilter");
 
  // use the XExporter interface to set xPage as source component 
  // for the GraphicExportFilter
  XExporter xExporter = (XExporter)UnoRuntime.queryInterface( 
      XExporter.class, GraphicExportFilter );
 
  XComponent xComp = (XComponent)UnoRuntime.queryInterface(XComponent.class, xPage);
  xExporter.setSourceDocument(xComp);
 
  // prepare the media descriptor for the filter() method in XFilter
  PropertyValue aProps[] = new PropertyValue[2];
 
  aProps[0] = new PropertyValue();
  aProps[0].Name = "MediaType";
  aProps[0].Value = "image/gif";
 
  // for some graphic formats, e.g. Windows Metafile, there is no Mime type,
  // therefore it is also possible to use the property FilterName with
  // Filter names as defined in the file TypeDetection.xml (see "Storing")
  /* aProps[0].Name = "FilterName";
     aProps[0].Value = "WMF - MS Windows Metafile";
   */
 
  aProps[1] = new PropertyValue();
  aProps[1].Name = "URL";
  aProps[1].Value = "file:///home/images/page1.gif";
 
  // get XFilter interface and launch the export
  XFilter xFilter = (XFilter) UnoRuntime.queryInterface(
      XFilter.class, GraphicExportFilter);
  xFilter.filter(aProps);
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages