Flisol 2007 in Guadalajara Part I


So I participated in the FLISOL 2007 event in LinuxCabal. My talk was about development of extensions in Linux. The talk was pretty good, but I guess the audience was too much of a newbie to connect with the talk. My talk was pretty technical yet it was just a descriptive talk, i didnt got into specifics of the development of extensions in OpenOffice.org (spanish).The talk guide the audience throught UI of OpenOffice.org to use the macros and the different bindings to languages that UNO support.I showed the file structure of OpenOffice.org to let users know how to load the code either locally or remotely.Here is an example in Python:

import unolocalContext = uno.getComponentContext()resolver = localContext.ServiceManager.createInstanceWithContext(                                          "com.sun.star.bridge.UnoUrlResolver", localContext )ctx = resolver.resolve( "uno:socket, host=localhost,                                                   port=2002;urp;StarOffice.ComponentContext" )

and how to add Python from the command line:

>> /opt/openoffice.org2.2/program/unopkg add Wavelet.uno.zip> > /opt/openoffice.org2.2/program/unopkg remove Wavelet.uno.zip>

Finally I gave the description of the IDL reference in OpenOffice.org and how the interfaces interact with uno.Unfortunately there were 2 things that went wrong, one is that OOo wouldnt show the IDE for Basic, and the samples I played around about the language which was ok in a sense since I wouldnt be able to finalize my presentation.I put some code in basic, difference between a plain script in Basic and a more powerful script with connectivity to API.

Parsing XML with OOoBasic

Passing the project


So since OOoAuthor was founded by Daniel Carrera, I was able to participate with ideos and small articles. When the spanish locale was formed I took the leadership of the project. However after some years of these, we get potential contributors that can outperform my leadership position in the project. So I will have a step back and give him the lead of the project. I think that his idea are interesting and powerful.First he mention that the documentation need a better standardization, the styles are not that great at the moment and a closer look at quality of the documentation might benefit the project.Plus this is what I been asking for a while, more involvement with the community and get a sense of ownership to the project will bring more strenght and dynamism as well as more efficiency.

Parsing XML with OOoBasic

OpenOffice.org is loaded with a full IDE and a language that even if it looks like a toy language. This weekend I have been reviweing a lot of code on OOoBasic and found that OOoBasic is a powerful script. One of the things that show the power of a very high level OOoBasic is parsing an XML file. Since OOo is made from XML it seems glorious that OOo could autoconfigure itself.

First is the powerful UNO framework which is lives in the inner pieces of OpenOffice.org. The UNO interface is conformed by interfaces, services and methods. The cool thing is the wide array of interfaces that OOoBasic can use and manipulate.

OOoBasic can parse XML on different ways, from SAX which is a smaller and simpler stream parser to a DOM parsing which will be a more indepth parsing based on the Document Object Model. This are both on the XML Module with hundred of tools that will be able to configure and reconfigure the code.

So here is the code that I was working with. First I needed to get an XML file, the file was a simple employee document.

<Employees>   <Employee id="101">       <Name>          <First>John</First>          <Last>Smith</Last>       </Name>       <Phone type="Home">785-555-1234</Phone>   </Employee></Employees>

Then here is the first stage of the code, we basically load the XML by the first interface which is the one that deals with external file manipulation:

Sub Main   cXmlFile = "/home/user/tmp/test.xml"      cXmlUrl = ConvertToURL( cXmlFile )      ReadXmlFromUrl( cXmlUrl )End Sub

We first create the ConverToURL function that will basically make the path to the file get used like a URL and then execute the function ReadXmlFromUrl that we will show next:

Sub ReadXmlFromUrl( cUrl )   oSFA = createUnoService( "com.sun.star.ucb.SimpleFileAccess" )   oInputStream = oSFA.openFileRead( cUrl )   ReadXmlFromInputStream( oInputStream )   oInputStream.closeInput()End Sub

This function use the SimplefileAccess to generate a Service using the createUnoSerive using the interface from the API. Then we will execute one of the methods called openFileRead this will get the file and to a variable and then implement the ReadXmlFromInputStream. Finally we close the the file using closeUput.

The next function is the ReadXmlFromInputStream, this is the one in charge of reading the XML.

Sub ReadXmlFromInputStream( oInputStream )   oSaxParser = createUnoService( "com.sun.star.xml.sax.Parser" )   oDocEventsHandler = CreateDocumentHandler()   oSaxParser.setDocumentHandler( oDocEventsHandler )   oInputSource = createUnoStruct( "com.sun.star.xml.sax.InputSource" )   With oInputSource      .aInputStream = oInputStream    End With   oSaxParser.parseStream( oInputSource )End Sub

This is the second function that is supposed to read the XML and will execute the parser itself. First we call the Parser service into a variable called oSaxParser. Then we have the CreateDocumentHandler then the parser will get the setDocumentHandler function.

Private goLocator As ObjectPrivate glLocatorSet As Boolean

We build an object as goLocator and make it as a boolean object, we later assign it to false under the DocumentHandler. We need to create the service for XDocumentHandler first.

Function CreateDocumentHandler()   oDocHandler = CreateUnoListener( "DocHandler_",_                                    "com.sun.star.xml.sax.XDocumentHandler" )   glLocatorSet = False   CreateDocumentHandler() = oDocHandlerEnd Function

Finally we have a series of functions where we specified the DocumentHandler to print out on the different elements of the XML. By default I comment all this handlers except for the character which is the one that specified the content. Unfortunately print will not just report the visible content such as John but all the invisible characters such as spaces, end of line and tab keys..

Sub DocHandler_startDocument()'   Print "Start document"End SubSub DocHandler_endDocument()'   Print "End document"End SubSub DocHandler_startElement( cName As String, oAttributes As _                             com.sun.star.xml.sax.XAttributeList )'    Print cName'Print oAttributes.LengthEnd SubSub DocHandler_endElement( cName As String )'   Print "End element", cNameEnd SubSub DocHandler_characters( cChars As String )Print "Contenido:",cCharsEnd Sub Sub DocHandler_ignorableWhitespace( cWhitespace As String )'Print cWhitespaceEnd SubSub DocHandler_processingInstruction( cTarget As String, cData As String )End Sub

Sub DocHandler_setDocumentLocator( oLocator As com.sun.star.xml.sax.XLocator )   goLocator = oLocator   glLocatorSet = TrueEnd Sub

Debo admitir que el proceso no es muy claro todavia pero haciendo una revision se puede ver que queremos 3 cosas:

  1. Invocar el servicio de parseo de XML
  2. Enviar nuestro llamado a una ventana dentro de OOo

Petter Quinn presentation finally on SlideShare

So I have this long time real good presentation from Peter Quinn. With Peter Quinn most important moment was when he wanted to standardize his department in the government of MA on the OpenDocument Format. This presentation was given on the SCALE conference in California. Finally I have it down at Slideshare.Here is the slide here in the blog, I will be commenting back in Slideshare but it is interesting how much benefit will OpenDocument would have meant for MA.

Birthday emergency

Bah no matter with how much anticipation you have, things might not run as perfect as you plan. This is what happened this week with my girlfriend birthday. Is funny, I really wanted my gf to know that I was present on her birthday, so I got prepared and got her presents almost a month after. Then I also put her date just in case on my calendar —- all my callendars. I got her on my presonal email calendar, to my phone calendar, and well pretty much all over the place. I also talk with her a day yesterday and was so excited that I congratulate her being that is not the day yet. Finally that night I wanted to call her but it was way too early, just 5:00am in Bulgaria. Then I start getting issues with my internet, having satelite internet it becomes really unstable when it rains and the internet might be fast one minute and death the next. This caused me to halt all my internet activities, and with nothing else on the menu and being midnight already at my place I started falling alseep and basically just woke up at 6am in the morning. I woke up and saw that my gf has been on for a couple of hours but she didnt msg me at all. Then I came in early to work and she comes online, just before that I recieve an email from the guy from germany saying that my gifts will take about 3 weeks to get there. I was pissed off and start telling my gf, all she could say is…. you can’t even say happy birthday. Now I wanted to say happy birthday but when I was talking to her, she wasn’t repliying so I guess she was out. Would it make sense to say happy birthday to a bot?Long story short I got into troubles because of that and she didn’t talk to me from then on to today. One day has passed and I still haven’t been able to wish her happy birthday and even if I have tried to call her constantly I dunno if she is just not willing to talk to me at all. If the latter case is whats going on is kind of stupid since well it was stil her birthday and why would she wanna be mad at me like that on that day?