日期:2014-05-19 浏览次数:20670 次
OOByteInputStream ooois = new OOByteInputStream(img.getImageData()); System.out.println("image data ----" + new String(img.getImageData()));//img.getImageData是能够取得保存在数据库中的值的 com.sun.star.beans.PropertyValue xValues[] = new com.sun.star.beans.PropertyValue[2]; xValues[0] = new PropertyValue(); xValues[0].Name = "InputStream"; xValues[0].Value = ooois; xValues[1] = new PropertyValue(); xValues[1].Name = "Hidden"; xValues[1].Value = new Boolean(true); // was boolean 'true' before xComponentLoader = (XComponentLoader)UnoRuntime.queryInterface(XComponentLoader.class, xDesktop); xComponent = xComponentLoader.loadComponentFromURL("private:stream", "_blank", 0, xValues); com.sun.star.text.XTextDocument aTextDocument = (com.sun.star.text.XTextDocument) UnoRuntime.queryInterface( com.sun.star.text.XTextDocument.class, xComponent);
import java.io.ByteArrayInputStream; import java.io.IOException; import com.sun.star.io.*; public class OOByteInputStream extends ByteArrayInputStream implements XInputStream,XSeekable { public OOByteInputStream(byte[] buf) { super(buf); } public void seek(long p1) throws IllegalArgumentException, com.sun.star.io.IOException { pos=(int)p1; } public long getPosition() throws com.sun.star.io.IOException { return pos; } public long getLength() throws com.sun.star.io.IOException { return count; } public int readBytes(byte[][] p1, int p2) throws NotConnectedException, BufferSizeExceededException, com.sun.star.io.IOException { try { byte[] b=new byte[p2]; int res=super.read(b); if(res>0) { if(res<p2) { byte[] b2=new byte[res]; System.arraycopy(b,0,b2,0,res); b=b2; } } else { b=new byte[0]; res=0; } p1[0]=b; return res; } catch (IOException e) {throw new com.sun.star.io.IOException(e.getMessage(),this);} } public int readSomeBytes(byte[][] p1, int p2) throws NotConnectedException, BufferSizeExceededException, com.sun.star.io.IOException { return readBytes(p1,p2); } public void skipBytes(int p1) throws NotConnectedException, BufferSizeExceededException, com.sun.star.io.IOException { skip(p1); } public int available() { return super.available(); } public void closeInput() throws NotConnectedException, com.sun.star.io.IOException { try { close(); } catch (IOException e) {throw new com.sun.star.io.IOException(e.getMessage(),this);} } }
XInputStream xInputStream = xSimpleFileAccess.openFileRead("file:///c:/test.docx"); PropertyValue[] loadProps = new PropertyValue[2]; loadProps[0] = new Proper