Lotusphere 2010 : Lotus Symphony Development - Comparing UNO vs LotusScript

February 1 2010

One of my favorite slides at Lotusphere 2010 was in "AD207 IBM Lotus Symphony Technical Overview" when they were comparing the code needed by both UNO and LotusScript to create a table. Let's look at this in detail:

Here is a screenshot of the table to be created:

Image:Lotusphere 2010 : Lotus Symphony Development - Comparing UNO vs LotusScript

The code required in UNO to create this table:

Object desktop = factory.createInstance("com.sun.star.frame.Desktop");
XComponentLoader loader = ( XComponentLoader ) UnoRuntime.queryInterface(XComponentLoader.class, desktop);
PropertyValue[] args = new PropertyValue[1];
args[0] = new PropertyValue();
args[0].Name = "Hidden";
args[0].Value = Boolean.FALSE;
XComponent component = loader.loadComponentFromURL("private:factory/swriter", "_blank", 0, args);
XTextDocument document = ( XTextDocument ) UnoRuntime.queryInterface(XTextDocument.class, component);
XMultiServiceFactory docfactory = ( XMultiServiceFactory ) UnoRuntime.queryInterface(XMultiServiceFactory.class, document);
Object obj = docfactory.createInstance("com.sun.star.text.TextTable");
XTextTable table = ( XTextTable ) UnoRuntime.queryInterface(XTextTable.class, obj);
table.initialize(3, 3);
XTextRange start = document.getText().getStart();
document.getText().insertTextContent(start, table, false);
XCellRange range = ( XCellRange ) UnoRuntime.queryInterface(XCellRange.class, table);
XCell cell = range.getCellByPosition(0, 0);
XText text = ( XText ) UnoRuntime.queryInterface(XText.class, cell);
text.setString("Value of first cell");

The code required by the new LotusScript API that comes with Notes 8.5.1 and embedded Lotus Symphony 1.3:

Dim application as SymphonyApplication
Dim document as SymphonyDocument
Dim table as SymphonyTextTable

Set application = new SymphonyApplication
Set document = application.Documents.AddDocument( "", False, True )
Set table = document.Tables.add( document.Content.Start, 3, 3 )
table.Cell( 0, 0 ).Text = "Value of first cell"

That is 18 lines of code for UNO (without any object dimensions) and 7 for LotusScript including the 3 dimension lines. I think the LotusScript code also reads much nicer - especially for a Notes developer. Talk about a major improvement. Thank you IBM for this great API