Difference between revisions of "Documentation/DevGuide/Drawings/Filter Options"
From Apache OpenOffice Wiki
< Documentation | DevGuide
Line 42: | Line 42: | ||
{{Note|If necessary, use the interface <tt>XMimeTypeInfo</tt> to get all mime types supported by the <tt>GraphicExportFilter</tt>. It offers the following methods: | {{Note|If necessary, use the interface <tt>XMimeTypeInfo</tt> to get all mime types supported by the <tt>GraphicExportFilter</tt>. It offers the following methods: | ||
− | + | <syntaxhighlight lang="java"> | |
boolean supportsMimeType( [in] string MimeTypeName ) | boolean supportsMimeType( [in] string MimeTypeName ) | ||
− | sequence< string > getSupportedMimeTypeNames() | + | sequence< string > getSupportedMimeTypeNames()</syntaxhighlight> |
<!--[BUG641+]--> | <!--[BUG641+]--> | ||
Line 51: | Line 51: | ||
The following example exports a draw page <code>xPage</code> from a given document <code>xDrawDoc</code>: | The following example exports a draw page <code>xPage</code> from a given document <code>xDrawDoc</code>: | ||
<!--[SOURCE:Drawing/GraphicExportDemo.java]--> | <!--[SOURCE:Drawing/GraphicExportDemo.java]--> | ||
− | + | <syntaxhighlight lang="java"> | |
//get draw pages | //get draw pages | ||
com.sun.star.drawing.XDrawPagesSupplier xPageSupplier = (com.sun.star.drawing.XDrawPagesSupplier) | com.sun.star.drawing.XDrawPagesSupplier xPageSupplier = (com.sun.star.drawing.XDrawPagesSupplier) | ||
Line 94: | Line 94: | ||
XFilter xFilter = (XFilter) UnoRuntime.queryInterface( | XFilter xFilter = (XFilter) UnoRuntime.queryInterface( | ||
XFilter.class, GraphicExportFilter); | XFilter.class, GraphicExportFilter); | ||
− | xFilter.filter(aProps); | + | xFilter.filter(aProps);</syntaxhighlight> |
{{PDL1}} | {{PDL1}} | ||
[[Category:Documentation/Developer's Guide/Drawing Documents and Presentation Documents]] | [[Category:Documentation/Developer's Guide/Drawing Documents and Presentation Documents]] |
Latest revision as of 14:13, 20 December 2020
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. |
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). |