With java I normally call basic and get objects back
for example text frames. 
First of all you need to make sure in Basic you are
using a Function not a sub. Only a function can return
a value.
Here is how I do it in java, I hope it helps.

      
// get the script, dispatch it, and conver the result
XScript createFrameScript =
this.macroDispatcher.getScript(
OpenOfficeMacroDispatcher.CREATE_FRAME );
Object result =
this.macroDispatcher.dispatchMacroReturnObject(
createFrameScript, objParams ); // you can figure out
objParams from the signature of the macro
XTextFrame  xTextFrame = ( XTextFrame )
AnyConverter.toObject( XTextFrame.class, result );


 /** Gets a script. If this script is in the HashMap
of active scripts it returns that instance.
   * @param macroName may not be <code>null</code>
   * @return the XScript for the given script
   * @throws CoreException
   */
  public XScript getScript( String macroName ) throws
CoreException
  {

    try
    {
      Assert.paramNotNull( MACRO_NAME, macroName );

      if ( this.activeScripts.containsKey( macroName )
)
      {
        return ( XScript ) this.activeScripts.get(
macroName );
      }

      // geting a masterscript factory and a script
provider
      XTextDocument document =
this.connection.getTextDocument();

      XMultiComponentFactory xMultiComponentFactory =
this.connection.getComponentContext()
                                                      
              .getServiceManager();

      Object oMSPFac =
xMultiComponentFactory.createInstanceWithContext(
MASTER_SCRIPT_PROVIDER_FACTORY,
                                                      
                 
this.connection.getComponentContext() );
      XScriptProviderFactory xScriptProviderFactory =
( XScriptProviderFactory ) UnoRuntime.queryInterface(
                                                      
                                                    
XScriptProviderFactory.class,
                                                      
                                                    
oMSPFac );

      Object oMSP =
xScriptProviderFactory.createScriptProvider( document
);

      XScriptProvider xScriptProvider = (
XScriptProvider ) UnoRuntime.queryInterface(
XScriptProvider.class, oMSP );

      XScript myScript = xScriptProvider.getScript(
macroName );

      this.activeScripts.put( macroName, myScript );

      return myScript;
    }
    catch ( java.lang.Exception e )
    {
      final String LOG_PREFIX = "getScript:";
//$NON-NLS-1$
      String errorMsg = Messages.getString(
"OpenOfficeMacroDispatcher.error.getScript" );
//$NON-NLS-1$
      getLog().error( LOG_PREFIX + errorMsg, e );
//$NON-NLS-1$
      IStatus status = StatusUtils.createError(
OpenOfficeMacroDispatcher.class, errorMsg, e );
      throw new CoreException( status );
    }
  }


  /** Dispatches a macro with a given script and an
array of params
   * @param script may not be <code>null</code>
   * @param params may not be <code>null</code>
   * @return the object - will normally be of type ANY
   * @throws CoreException
   */
  public Object dispatchMacroReturnObject( XScript
script, Object[] params ) throws CoreException
  {
    try
    {

      // minimal out params
      short[][] s = { { 0 } };

      // minimal inout params
      Object[][] object0 = { { null } };

      /* fire macro and return what ever it gives us
       * Note this might be ANY obect for example an
int[] or a String, or
       * a UNO Any object 
       * If this is an UNO Any object then the
AnyConverter needs to be used for example:
       * Long myLong = 
AnyConverter.toLong(theFramePropSet.getPropertyValue("FrameHeightAbsolute"));
       */
      return script.invoke( params, s, object0 );
    }

    catch ( java.lang.Exception e )
    {
      final String LOG_PREFIX = "dispatchMacro:";
//$NON-NLS-1$
      String errorMsg = Messages.getString(
"OpenOfficeMacroDispatcher.error.dispatchMacro" );
//$NON-NLS-1$
      getLog().error( LOG_PREFIX + errorMsg, e );
//$NON-NLS-1$
      IStatus status = StatusUtils.createError(
OpenOfficeMacroDispatcher.class, errorMsg, e );
      throw new CoreException( status );
    }
  }

REM This creates a frame from the given paramaters in
the body of the document. 
Function CreateFrame ( oDoc as Object, frameStyle as
String, backColor as Long,mirroring as Boolean,
sizeType as Long, frameIsAutomaticHeight as Boolean,
width as Long, height as Long, x as Long, y as Long,
transparent as Boolean) as TextFrame
        
        
        Dim oFrame As Object
        oFrame =
oDoc.createInstance("com.sun.star.text.TextFrame")
        oFrame.FrameStyleName= frameStyle
        oFrame.VertOrient = 0
        oFrame.HoriOrient = 0
        oFrame.AnchorType =
com.sun.star.text.TextContentAnchorType.AT_PARAGRAPH
        ' WrapTextMode.None and Throught are basically the
same however, Throught has shown to
        ' be MORE ROBUST, ie None can sometimes hang when we
insert the textcontent
        'oFrame.TextWrap =
com.sun.star.text.WrapTextMode.THROUGHT
        oFrame.TextWrap = com.sun.star.text.WrapTextMode.NONE
        oFrame.IsFollowingTextFlow= true
        oFrame.BackColor = backColor
                
                If transparent Then
                                oFrame.BackColorTransparency = 100      
                Else
                                oFrame.BackColorTransparency = 0
                End If
        
        oFrame.PageToggle = mirroring
        oFrame.HoriOrientPosition=  x
        oFrame.VertOrientPosition=  y
        oFrame.FrameIsAutomaticHeight=frameIsAutomaticHeight
        oFrame.SizeType = sizeType
        oFrame.width = width
        oFrame.height = height
                
        CreateFrame = oFrame 

end Function

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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

Reply via email to