Hi Stephan,
I am newer in OpenOffice. Could you give me some example that use
XTextDocument?
Because I am understanding. Below theres is a pience of code that I am using
but it doesn't work.
public OutputStream comporDocumentosDocParaDoc(List colecao)
throws java.io.IOException, DocumentException, IOException,
IllegalArgumentException, BootstrapException
{
ConversorDeDocumento conversor = new ConversorDeDocumento();
//prepare base document
//move the document to byteArray
InputStream docBase = (InputStream)colecao.get(0);
ByteArrayOutputStream arrayByteDocBase = new ByteArrayOutputStream();
docBase.toString();
IOUtils.copy(docBase,arrayByteDocBase);
//via URL
File arqBase = new File("M:\\Aloizio_SS\\SINF2\\DOCS\\arq0.doc");
FileOutputStream fout = new FileOutputStream(arqBase,true);
fout.write(arrayByteDocBase.toByteArray());
fout.close();
//upload the base document into open office
XComponent docFinal =
carregarDocumentoOpenOffice(arqBase, "DOC");
//iterator over document list
for(int i = 1; i < colecao.size(); i++)
{
InputStream arqDoc = (InputStream)colecao.get(i);
//move the document to byte array
ByteArrayOutputStream arrayByteDoc = new ByteArrayOutputStream();
IOUtils.copy(arqDoc,arrayByteDoc);
//via URL
File arqDocAux = new
File("M:\\Aloizio_SS\\SINF2\\DOCS\\arq"+i+".doc");
FileOutputStream foutAux = new FileOutputStream(arqDocAux);
foutAux.write(arrayByteDoc.toByteArray());
foutAux.close();
//consulta a interface XTextDocument para obter o texto
XTextDocument mxDoc =
(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, docFinal);
XText mxDocText = mxDoc.getText();
// create a cursor
XTextCursor mxDocCursor = mxDocText.createTextCursor();
mxDocCursor.gotoEnd(false);
XDocumentInsertable lXDocInsertable = (XDocumentInsertable)UnoRuntime.
queryInterface(XDocumentInsertable.class, mxDocCursor);
PropertyValue[] loadProps = new PropertyValue[0];
String url = createUNOFileURL(arqDocAux.getAbsolutePath());
OOInputStream oois = new OOInputStream(arrayByteDoc.toByteArray());
PropertyValue[] loadProps = new PropertyValue[3];
loadProps[0] = new PropertyValue();
loadProps[0].Name = "Hidden";
loadProps[0].Value = new Boolean(true);
loadProps[1] = new PropertyValue();
loadProps[1].Name = "FilterName";
loadProps[1].Value = new Boolean(true);
loadProps[2] = new PropertyValue();
loadProps[2].Name = "InputStream";
loadProps[2].Value = oois;
lXDocInsertable.insertDocumentFromURL("private:stream", loadProps);
}
XStorable xstorable = ( XStorable ) UnoRuntime.queryInterface(
XStorable.class,
docFinal );
XComponent xComponent = ( XComponent ) UnoRuntime.queryInterface(
XComponent.class, xstorable );
xComponent.dispose();
byte[] docFundido = obterDocumentoComposto(docFinal);
InputStream fim = new ByteArrayInputStream(docFundido);
OutputStream out = new ByteArrayOutputStream();
IOUtils.copy(fim,out);
return out;
}
thanks.
Stephan Wunderlich wrote:
>
> Hi there,
>
>> I need to merge some Word files that are streams. I receive it as a
>> InputStream collection and I must generate a OutputStream.
>>
>> I am already able to load them as XInputStream into OpenOffice I
>> but How can
>> I write a new word document that contains the previous merged?
>
> After merging your documents into one you should have an
> XTextDocument which supports the Interface XStorable.
> So you should be able to store the Document with code like the
> following in MS Word format.
>
> Dim args(0) as new com.sun.star.beans.PropertyValue
> args(0).Name = "FilterName"
> args(0).Value = "MS Word 97"
> destination = "file:///myhome/documents/output.doc"
> xStorable.storeAsURL(destination,args())
>
> Hope that helps
>
> Regards
>
> Stephan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
--
View this message in context:
http://www.nabble.com/How-can-I-concatenate-a-stream-word-collection-tf2197851.html#a6098023
Sent from the openoffice - api dev forum at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]