本文整理汇总了Java中com.sun.star.lib.uno.adapter.ByteArrayToXInputStreamAdapter类的典型用法代码示例。如果您正苦于以下问题:Java ByteArrayToXInputStreamAdapter类的具体用法?Java ByteArrayToXInputStreamAdapter怎么用?Java ByteArrayToXInputStreamAdapter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ByteArrayToXInputStreamAdapter类属于com.sun.star.lib.uno.adapter包,在下文中一共展示了ByteArrayToXInputStreamAdapter类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadAndExport
import com.sun.star.lib.uno.adapter.ByteArrayToXInputStreamAdapter; //导入依赖的package包/类
/**
* Load and export.
* @param inputStream
* the input stream
* @param importOptions
* the import options
* @param outputStream
* the output stream
* @param exportOptions
* the export options
* @throws Exception
* the exception
*/
@SuppressWarnings("unchecked")
private void loadAndExport(InputStream inputStream, Map/* <String,Object> */importOptions,
OutputStream outputStream, Map/* <String,Object> */exportOptions) throws Exception {
XComponentLoader desktop = openOfficeConnection.getDesktopObject();
Map/* <String,Object> */loadProperties = new HashMap();
loadProperties.putAll(getDefaultLoadProperties());
loadProperties.putAll(importOptions);
// doesn't work using InputStreamToXInputStreamAdapter; probably because
// it's not XSeekable
// property("InputStream", new
// InputStreamToXInputStreamAdapter(inputStream))
loadProperties.put("InputStream", new ByteArrayToXInputStreamAdapter(IOUtils.toByteArray(inputStream))); //$NON-NLS-1$
XComponent document = desktop.loadComponentFromURL(
"private:stream", "_blank", 0, toPropertyValues(loadProperties)); //$NON-NLS-1$ //$NON-NLS-2$
if (document == null) {
throw new OPException(Messages.getString("ooconverter.StreamOpenOfficeDocumentConverter.6")); //$NON-NLS-1$
}
refreshDocument(document);
Map/* <String,Object> */storeProperties = new HashMap();
storeProperties.putAll(exportOptions);
storeProperties.put("OutputStream", new OutputStreamToXOutputStreamAdapter(outputStream)); //$NON-NLS-1$
try {
XStorable storable = (XStorable) UnoRuntime.queryInterface(XStorable.class, document);
storable.storeToURL("private:stream", toPropertyValues(storeProperties)); //$NON-NLS-1$
} finally {
document.dispose();
}
}
示例2: buildImageProperties
import com.sun.star.lib.uno.adapter.ByteArrayToXInputStreamAdapter; //导入依赖的package包/类
protected XPropertySet buildImageProperties(XGraphicProvider xGraphicProvider, Object oImage, byte[] imageContent)
throws Exception {
XPropertySet imageProperties = as(XPropertySet.class, oImage);
PropertyValue[] propValues = new PropertyValue[]{new PropertyValue()};
propValues[0].Name = "InputStream";
propValues[0].Value = new ByteArrayToXInputStreamAdapter(imageContent);
XGraphic graphic = xGraphicProvider.queryGraphic(propValues);
if (graphic != null) {
imageProperties.setPropertyValue("Graphic", graphic);
imageProperties.setPropertyValue("HoriOrient", HoriOrientation.NONE);
imageProperties.setPropertyValue("VertOrient", HoriOrientation.NONE);
imageProperties.setPropertyValue("HoriOrientPosition", 0);
imageProperties.setPropertyValue("VertOrientPosition", 0);
}
return imageProperties;
}