How do I create an XTextTable in OpenOffice.org uno using C#? -


Using Pyro in Python, I can do it like this:

  table = self.model.createInstance ("com.sun.star.text.TextTable")  

It does not seem to work in C #. Here's my test code (I know I probably do not have to use all those statements, but I'm optimizing the code for someone else):

  Using the system ; Using unoidl.com.sun.star.lang; Using unoidl.com.sun.star.uno; Using Unoidl.com.sun.star.bridge; Using unoidl.com.sun.star.frame; Using unoidl.com.sun.star.document; Using unoidl.com.sun.star.text; Using unoidl.com.sun.star.container; Using unoidl.com.sun.star.util; Using Unoidl.com.sun.star.table; Using unoidl.com.sun.star.beans; Namespace to skirt {class main class {public static zero main (string [] arg) {XComponentContext componentContext = uno.util.Bootstrap.bootstrap (); XMultiServiceFactory multiServiceFactory = (XMultiServiceFactory) component Context.getServiceManager (); XTextDocument document; XComponentLoader Loader = (XComponentLoader) multiServiceFactory.createInstance ("com.sun.star.frame.Desktop"); Document = (XTextDocument) loader.loadComponentFromURL ("private: factory / author", "_blank", 0, new property value [0]); XText Text = Document.getText (); XTextCursor cursor = text.createTextCursor (); XTextTable table = (XTextTable) multiServiceFactory.createInstance ("com.sun.star.text.TextTable"); Table Interlise (2, 2); Text.insertTextContent (cursor, table, incorrect); }}}  

Most of them work fine, but when it goes to this line:

  table.in initialize (2, 2) ;  

I get a runtime error:

  Unchecked exception: System.NullReferenceException: Object references are not set to a presentation of an object. In the main class.man (System.String [] args) [0x00063] /home/matthew/Desktop/OpenOfficeSample/FromScratch/Main.cs:37  

Apparently, this line:

  XTextTable table = (XTextTable) multiServiceFactory.createInstance ("com.sun.star.text.TextTable");  

Actually does not set anything to the table.

What's going on here?

Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -