diff --git a/docs/index.adoc b/docs/index.adoc new file mode 100644 index 0000000..9240e30 --- /dev/null +++ b/docs/index.adoc @@ -0,0 +1,12 @@ += GUNO Extension Documentation + +== Introduction +UNO stands for Universal Network Objects and is the base component technology for Apache OpenOffice. + +GUNO stands for Groovy UNO and is an Apache Groovy language extension of the Java UNO API's. The artifact of this extension is a Java jar file that when used in a Groovy script or class adds convenience methods to the regular Java UNO API's. + +The goal of the Groovy UNO Extension is to allow UNO programming that is less verbose than using the Java UNO API's alone. + +These methods are implemented using Groovy Extension Modules. An extension module allows you to add new methods to existing classes, including classes which are precompiled, like classes from the JDK or in this case Java UNO classes. These new methods, unlike those defined through a metaclass or using a category, are available globally. + +Aside from a few general methods, initial efforts have been on enhancing the spreadsheet API's and future work will be on enhancing the other applications. \ No newline at end of file diff --git a/docs/index.html b/docs/index.html new file mode 100644 index 0000000..156d160 --- /dev/null +++ b/docs/index.html @@ -0,0 +1,474 @@ + + + + + + + +GUNO Extension Documentation + + + + + + +
+
+

Introduction

+
+
+

UNO stands for Universal Network Objects and is the base component technology for Apache OpenOffice.

+
+
+

GUNO stands for Groovy UNO and is an Apache Groovy language extension of the Java UNO API’s. The artifact of this extension is a Java jar file that when used in a Groovy script or class adds convenience methods to the regular Java UNO API’s.

+
+
+

The goal of the Groovy UNO Extension is to allow UNO programming that is less verbose than using the Java UNO API’s alone.

+
+
+

These methods are implemented using Groovy Extension Modules. An extension module allows you to add new methods to existing classes, including classes which are precompiled, like classes from the JDK or in this case Java UNO classes. These new methods, unlike those defined through a metaclass or using a category, are available globally.

+
+
+

Aside from a few general methods, initial efforts have been on enhancing the spreadsheet API’s and future work will be on enhancing the other applications.

+
+
+
+
+ + + + + + \ No newline at end of file diff --git a/docs/usage.adoc b/docs/usage.adoc new file mode 100644 index 0000000..f106500 --- /dev/null +++ b/docs/usage.adoc @@ -0,0 +1,39 @@ += Usage + +The best way to explain the differences between the Java UNO API's and using Groovy with and without the extension is with some example code. Many of the examples are spreadsheet examples are from SCalc.java that is included with the AOO SDK. + +=== Get an XComponentLoader + +Java way (assumes XComponentContext xComponentContext reference) +[source,java] +---- +XMultiComponentFactory mxRemoteServiceManager = null + XComponentLoader aLoader = null + mxRemoteServiceManager = xComponentContext.getServiceManager() + aLoader = UnoRuntime.queryInterface( + XComponentLoader.class, mxRemoteServiceManager.createInstanceWithContext( + "com.sun.star.frame.Desktop", self)) +---- + +Groovy Extension way +[source,java] +---- +XComponentLoader aLoader = mxRemoteContext.componentLoader +---- + +=== UnoRuntime.queryInterface +The UnoRuntime.queryInterface(ReturnObject.class, FromObject) method can be replaced with the new FromObject.guno(ReturnObject.class) method. +Java way (assumes we have a reference to XSpreadsheetDocument myDoc..) +[source,] +---- +XSpreadsheets xSheets = myDoc.getSheets() ; +XIndexAccess oIndexSheets = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xSheets); +xSheet = (XSpreadsheet) UnoRuntime.queryInterface(XSpreadsheet.class, oIndexSheets.getByIndex(0)); +---- + +Groovy Extension way [source,java] +---- +XSpreadsheets xSheets = myDoc.sheets +XIndexAccess oIndexSheets = xSheets.guno(XIndexAccess.class) +xSheet = oIndexSheets.getByIndex(0).guno(XSpreadsheet.class) +---- diff --git a/docs/usage.html b/docs/usage.html new file mode 100644 index 0000000..413f3ea --- /dev/null +++ b/docs/usage.html @@ -0,0 +1,509 @@ + + + + + + + +Usage + + + + + + +
+
+
+
+

The best way to explain the differences between the Java UNO API’s and using Groovy with and without the extension is with some example code. Many of the examples are spreadsheet examples are from SCalc.java that is included with the AOO SDK.

+
+
+
+
+

Get an XComponentLoader

+
+

Java way (assumes XComponentContext xComponentContext reference)

+
+
+
+
XMultiComponentFactory mxRemoteServiceManager = null
+    XComponentLoader aLoader = null
+    mxRemoteServiceManager = xComponentContext.getServiceManager()
+    aLoader = UnoRuntime.queryInterface(
+        XComponentLoader.class, mxRemoteServiceManager.createInstanceWithContext(
+        "com.sun.star.frame.Desktop", self))
+
+
+
+

Groovy Extension way

+
+
+
+
XComponentLoader aLoader = mxRemoteContext.componentLoader
+
+
+
+
+

UnoRuntime.queryInterface

+
+

The UnoRuntime.queryInterface(ReturnObject.class, FromObject) method can be replaced with the new FromObject.guno(ReturnObject.class) method. +Java way (assumes we have a reference to XSpreadsheetDocument myDoc..)

+
+
+
+
XSpreadsheets xSheets = myDoc.getSheets() ;
+XIndexAccess oIndexSheets = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xSheets);
+xSheet = (XSpreadsheet) UnoRuntime.queryInterface(XSpreadsheet.class, oIndexSheets.getByIndex(0));
+
+
+
+

Groovy Extension way [source,java]

+
+
+
+
XSpreadsheets xSheets = myDoc.sheets
+XIndexAccess oIndexSheets = xSheets.guno(XIndexAccess.class)
+xSheet = oIndexSheets.getByIndex(0).guno(XSpreadsheet.class)
+
+
+
+
+ + + + + + \ No newline at end of file