Hi Luís,

you have posted your question to a mailing list where subscription is necessary. You are currently not subscibred and won't get any replies automatically.

You can easy subscribe under http://api.openoffice.org/servlets/ProjectMailingListList

Regards

Juergen

On 7/5/10 2:02 PM, Luís Alves wrote:
Hello, here is my code:

   public void processFile(NodeRef nodeRef) {
        SocketOpenOfficeConnection conectionToOO = new
SocketOpenOfficeConnection();
        ServiceRegistry srvResgitry =
Repository.getServiceRegistry(FacesContext.getCurrentInstance());
        FileFolderService ffService  = srvResgitry.getFileFolderService();
        ContentWriter cWriter = ffService.getWriter(nodeRef);

        try {
            // Open the input file.
            FileChannel fileChannel = cWriter.getFileChannel(false);
            InputStream is = Channels.newInputStream(fileChannel);

            //convert to OOInputStream //not sure if it's mandatory or
InputStream it's supported
            ByteArrayOutputStream bytes = new ByteArrayOutputStream();
            byte[] byteBuffer = new byte[4096];
            int byteBufferLength = 0;
            while ((byteBufferLength = is.read(byteBuffer))>  0) {
                    bytes.write(byteBuffer,0,byteBufferLength);
            }
            OOInputStream inputStream = new
OOInputStream(bytes.toByteArray());
            //is.close();
            //fileChannel.close();

            //comnect
            conectionToOO.connect();

            PropertyValue[] loadProperties = new PropertyValue[3];
            loadProperties[0] = new PropertyValue();
            loadProperties[1] = new PropertyValue();
            loadProperties[2] = new PropertyValue();

            loadProperties[0].Name = "Hidden";
            loadProperties[0].Value = Boolean.TRUE;
            loadProperties[1].Name = "ReadOnly";
            loadProperties[1].Value = Boolean.FALSE; //I need to write
            loadProperties[2].Name = "InputStream";
            loadProperties[2].Value = new
ByteArrayToXInputStreamAdapter(IOUtils.toByteArray(inputStream));
//OOInputStream //InputStream is supported?

            //get a desktop
            XComponentLoader xComponentLoader = conectionToOO.getDesktop();

            //load file
            XComponent xComponent =
xComponentLoader.loadComponentFromURL("private:stream", "_blank", 0,
loadProperties);
            XTextDocument mxDoc = (XTextDocument)
UnoRuntime.queryInterface(com.sun.star.text.XTextDocument.class,
xComponent);

            //....code to relpace some text....TODO

            conectionToOO.disconnect();
            }
                 catch (Exception e )
            {
                e.printStackTrace();
            }
            finally{
                conectionToOO.disconnect();
            }
      }


always get com.sun.star.lang.IllegalArgumentException: URL seems to be an
unsupported one. and I can't figure out what is the problem...
Trying to open an docx File...to do some text replacements
On a first stage I used the Apache POI library and I successfully opened the
file.

best regards



--
Oracle <http://www.oracle.com>
Jürgen Schmidt | Software Development
Oracle Office GBU

ORACLE Deutschland B.V. & Co. KG | Nagelsweg 55 | 20097 Hamburg

ORACLE Deutschland B.V. & Co. KG
Hauptverwaltung: Riesstr. 25, D-80992 München
Registergericht: Amtsgericht München, HRA 95603

Komplementärin: ORACLE Deutschland Verwaltung B.V.
Rijnzathe 6, 3454PV De Meern, Niederlande
Handelsregister der Handelskammer Midden-Niederlande, Nr. 30143697
Geschäftsführer: Jürgen Kunz, Marcel van de Molen, Alexander van der Ven

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org
For additional commands, e-mail: dev-h...@api.openoffice.org

Reply via email to