hi,

I'm looking for a way to pass a Java InputStream to an Macro inside a
document and implemented in Basic, the macro is based on DannyB post
Using UNO's Xml sax parser via the API
(http://www.oooforum.org/forum/viewtopic.phtml?t=4907).

the macro that will be invoked is:

Sub ReadXmlFromInputStream( oInputStream )
  ' Create a Sax Xml parser.
  oSaxParser = createUnoService( "com.sun.star.xml.sax.Parser" )

  ' Create a document event handler object.
  ' As methods of this object are called, Basic arranges
  '  for global routines (see below) to be called.
  oDocEventsHandler = CreateDocumentHandler()

  ' Plug our event handler into the parser.
  ' As the parser reads an Xml document, it calls methods
  '  of the object, and hence global subroutines below
  '  to notify them of what it is seeing within the Xml document.
  oSaxParser.setDocumentHandler( oDocEventsHandler )

  ' Create an InputSource structure.
  oInputSource = createUnoStruct( "com.sun.star.xml.sax.InputSource" )
  With oInputSource
     .aInputStream = oInputStream   ' plug in the input stream
  End With

  ' Now parse the document.
  ' This reads in the entire document.
  ' Methods of the oDocEventsHandler object are called as
  '  the document is scanned.
  oSaxParser.parseStream( oInputSource )
End Sub


I want to pass a Java InputStream to Sub ReadXmlFromInputStream(
oInputStream ), to execute this macro i'm using the method
executeMacro of this post
(http://www.oooforum.org/forum/viewtopic.phtml?p=189467#189467)

the code is:

/**
   * @param strMacroName The full macro uri to call
   * @param aParams A list of string parameters
   * @return Returns the return value of the macro.
   */
  public Object executeMacro(String strMacroName, Object[] aParams) {
     try {
        XScriptProviderSupplier xScriptPS =
(XScriptProviderSupplier)UnoRuntime.queryInterface(XScriptProviderSupplier.class,
this.mxDoc);
        XScriptProvider xScriptProvider = xScriptPS.getScriptProvider();
        XScript xScript =
xScriptProvider.getScript("vnd.sun.star.script:" + strMacroName);

        short[][] aOutParamIndex = new short[1][1];
        Object[][] aOutParam  = new Object[1][1];
        return xScript.invoke(aParams, aOutParamIndex, aOutParam);

     } catch (Exception e) {
        throw new RuntimeException(e);
     }
  }

inside another method i call:

com.sun.star.io.XInputStream xStream = new
com.sun.star.lib.uno.adapter.InputStreamToXInputStreamAdapter(iInStream);

executeMacro(strMacroName,new Object[] {xStream});

this execute de macro the message startDocument appears that is
handled by SAX, but strange thing occurs, without any error or message
the Macro Editor appears and highlight the line
oSaxParser.parseStream( oInputSource ) but
i dont know the reason.

Then i research the sources and found that inside the OOoBean the use
of InputStreamToXInputStreamAdapter is commented and changed to byte
array. in revision 1.4 is used but in 1.5 the use was removed. see
http://api.openoffice.org/source/browse/api/bean/com/sun/star/comp/beans/OOoBean.java?rev=1.4&view=markup

Then i dont know, what is wrong, anyonoe have an idea? because what
the use of InputStreamToXInputStreamAdapter was removed? its buggy?

Thanks for any help

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to