:Start of OOoAutomation <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN"> <html><head><META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>OOoAutomation.dsc</title><STYLE>BODY{FONT-SIZE: 12px; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; BACKGROUND-COLOR: #ffffed } A{COLOR: Blue} A:active {FONT-WEIGHT: bold; COLOR: #008000} A:visited{FONT-WEIGHT: bold; COLOR: #400000} A:hover{ FONT-WEIGHT: bold; COLOR: #008000;} H1{COLOR: #400000; TEXT-ALIGN: left FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif} #copyright { border-top: 2px solid rgb(165, 82, 0); width: 100%; } DIV.left{TEXT-ALIGN: left} DIV.centered{TEXT-ALIGN: center}</STYLE></head><body bgcolor=#ffffed><table width="100%" height="133"><tr height="129"><th width="173"><a href = "http://www.dragonsphere.net" target = "_blank"><img style="Z-INDEX: 100; LEFT: 25px; POSITION: absolute; TOP: 40px" height="124" alt="DragonSphere" src="http://www.dragonsphere.net/images/dragonfly.png" width="169" align="left" border="0"></a></th><th><a href = "http://www.dragonsphere.net" target = "_blank"><img style="Z-INDEX: 100; LEFT: 200px; POSITION: absolute; TOP: 40px" height="124" alt="Software" src="http://www.dragonsphere.net/images/dslogotext.png" width="473" align="left" border="0"></a></th></tr></table><br/><!--

#DEFINE COMMAND,<!--
#DEFINE COMMAND,-->
<!-- This is crazy but now we should be able to see this script in the browser and run it in VDS too without changing the source code. --><h1>DragonSphere Software Demos</h1><br/><p>If you are viewing this script in your browser you can save it as a VDS 5.x source file (*.dsc) to run it.</p><br/><hr><br/><pre>
#
# <a href = "http://www.dragonsphere.net" target = "_blank">DragonSphere Software's Home Page</a>
#  
# <a href = "http://www.dragonsphere.net/products/gadgetx/demos/OOoAutomation.zip">All Source Files for this demo</a>
Title OpenOffice.org Example
################################################ DESCRIPTION #################################################
#                                                                                                            #
#  This is a very simple example for automating the OpenOffice.org Writer application                        #
#  OpenOffice.org is a opensource Office Suite maintained and developed by the JAVA community                #
##############################################################################################################


# Below is the VBScript we will attempt to translate into GadgetX syntax

# Dim objServiceManager As Object 
# Dim objDesktop As Object 
# Dim args() 

# Set objServiceManager= CreateObject("com.sun.star.ServiceManager") 
# Set Stardesktop= objServiceManager.createInstance("com.sun.star.frame.Desktop") 
# Set doc = Stardesktop.loadComponentFromURL("private:factory/swriter", "_blank", 0, args) 
# Set text = doc.getText() 
# text.setString("Hello World") 
# REM You can get the full example in the SDK (under OLE examples) 
# REM Read the Automation Bridge part of the Developer's Guide for writing code with WSH or JScript, 
# both are very similiar to VBScript 

# Below is the GadgetX version of the VBScript above.
If @Greater(@Name(@SYSINFO(DSVER)),4)
<!-- GadgetX --><a href = "http://www.dragonsphere.net/products/gadgetx/gadgetx.zip">
  External GadgetX.dll,@SYSINFO(DSVER)
<!-- GadgetX --></a>
  # GadgetX command and functions
  #DEFINE COMMAND,GADGETX,DEFINE,SET,OLE
  #DEFINE FUNCTION,GADGETX,GET,OLE,SIZEOF,ADDROF
End

# Initialize OLE
Ole Init

# Define the objects and variables needed
Define Variable,Object,objServiceManager
Define Variable,Object,Stardesktop
Define Variable,Object,doc
Define Variable,Object,text
# This is a Variant of type SafeArray
Define Variable,Variant,args,^a
# Set the SafeArray Variant to NULL
Set args,NULL,^a
# Create the OpenOffice.org ServiceManager Object
<!-- OpenOffice.org --><a href = "http://www.openoffice.org">
Set objServiceManager,@Ole(Create,com.sun.star.ServiceManager,NULL)
<!-- OpenOffice.org --></a>
# Create an instance of the Service Manager Desktop Object
Set Stardesktop,@Ole(Call,objServiceManager,^o,"createInstance(^B)","com.sun.star.frame.Desktop")
# Get the document object from the desktop
Set doc,@Ole(Call,Stardesktop,^o,"loadComponentFromURL(^B,^B,^d,^a)","private:factory/swriter", "_blank", 0, args)
# Get the Text object from the document
Set text,@Ole(Get,doc,^o,"getText()")
# Place some text on the Text object 
Ole Call,text,"setString(^B)","GadgetX Rocks OpenOffice.org!!!"
# That's it we are done
Info Click Ok to close this OpenOffice Text Document example.
:CLOSE
  # Cleanup and close out everything
  Ole Call,doc,"Close(^B)",false
  Ole Call,Stardesktop,"terminate()"
  Ole Free,Object,text
  Ole Free,Object,doc
  Ole Free,Object,Stardesktop
  Ole Free,Object,objServiceManager
  # Uninitialize OLE
  Ole UnInit
Exit
<!-- This is crazy but now we should be able to see this script in the browser. --></pre><div id="copyright"><p>copyright &copy; DragonSphere Software 2000-2006<br><a href="http://www.dragonsphere.net/terms.html" target="_blank">Terms and Conditions</a></p></div></body></html><!--
:-->
:<!--
  
Exit 
# -->End of OOoAutomation
