Skip navigation.

Open Life

Opendocuments, Web Office, Office suites

Closer look at ODF vs. OOoXML

, , , ...

Sam Hiser is one of the original founders of the OpenOffice.org community, he has been available to the community since early 2000-2001. He has also co write one of the very first OpenOffice.org books. Using of course, OpenOffice.org.

Now he launches a great in depth analysis of OpenDocument format and the OpenXML format from Microsoft. He goes into topics such as true openness, study of the components and legacy dependency. This is a great topic that also has much to do with a recent interview by Gary Edwards at IT Conversations.

Very good read to jump on board with what's going on at the Open Standard camp.

http://fussnotes.typepad.com/Achieving_Openness_1point0.html

Python- OpenOffice.org RAD

Recently I have strenghten my will to start developing seriously under the PyUNO platform. For that i want to generate a series of tools that will allow me to achieve the applications that I have talked and dream for so much.

Recently I have been documenting the Python scripts that are packed with OpenOffice.org at the OOo's Wiki page. I have also asked for peer review from Laurent Godard so the documentation can be as easy to understand as possible. However the experience was very eye-opener since I was able to learn about some modules that let me save some code regarding the scripting framework called XSCRIPTCONTEXT.

I have also looked at one of the best PyUNO scripts around called PyXray. I like this script because it has a very complex GUI and uses a lot of the widgets available on the VCL (OOo's toolkt). One thing that I learned is the use of all these different widgets on the python code, here is some snippets from the code:
#create the dialog model and set the properties
dialog_model = self.smgr.createInstanceWithContext(
'com.sun.star.awt.UnoControlDialogModel',
self.ctx)
dialog_model.PositionX = 50
dialog_model.Step = 1
dialog_model.TabIndex = 7
dialog_model.Width = 270
dialog_model.Height = 261
dialog_model.PositionY = 63
dialog = self.smgr.createInstanceWithContext(
'com.sun.star.awt.UnoControlDialog',
self.ctx)

Here is a snippet that will generate the UnoControlDialog which is one of the main ones, another the main widgets is the ListBox Modules.
a_list= dialog_model.createInstance(
'com.sun.star.awt.UnoControlListBoxModel')
a_list.PositionX = 38
a_list.TabIndex = 14
a_list.Width = 230
a_list.Height = 10
a_list.PositionY = 73
a_list.HelpText = self.gui_rsc['ListObj']
a_list.Dropdown = True
a_list.LineCount = 15
a_list.Tag = ''
dialog_model.insertByName('ListObj', a_list )


Then there were the listeners which basically put the ListObj and add a listener that will wait for us to generate a signal, this signal is the one for listen to objects. The signal is also referred as an Action such as a_control.addActionListener(the_listener). We also have to remove the listeners by a method called removeItemListener(self.lst_listeners['ListObj']). All this things go into just one object, our interface has somewhere around 10 widgets hold on the dialog which is a widget itself.

I would need to better understand this model so I can be more proficient on PyUNO space and GUI programming to create extensions. I started by making a class to automatically instantiate the OOo service so Python can connect within it. The next step is to instantiate the Python modules so python can directly write into the document as opposed to be on the application layer. The process of instantiation is this:

import uno
import unohelper localContext = uno.getComponentContext()
resolver = localContext.ServiceManager.createInstanceWithContext(
"com.sun.star.bridge.UnoUrlResolver", localContext )
ctx = resolver.resolve( "uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext" )
smgr = ctx.ServiceManager
desktop = smgr.createInstanceWithContext( "com.sun.star.frame.Desktop",ctx)
model = desktop.getCurrentComponent()


The original idea is to create a class that will open, connect and instantiate OOo and make it ready for Python to just code directly into the Document. Another point would be to simplify the functions to write in the document, either generate tables, frames, text or insert an image in the document. But when constructing this code I hit some hit and miss so I can generate definitions and where to put what code. I sent an email to my friend that has more expertise in python and hope I can get it solved soon. So far there seem to be opportunities on this space.

Rafaella Calls for Translation

A couple of days ago I got an email from Rafaella Braconi of the localization team for OpenOffice.org, she recently announced on the Localization team the schedule for the OpenOffice.org 2.3 release and the localization time frame for the language release.

The translation seemed to be done but we will need to go through all the 17,000 words through a month period. The revision should be done by July 26th. The translation most be reviewed by a team formed by the community. After a couple of emails that I sent asking for support a good crowd gather and offer their services. This is awesome by the way. The community once again step up and a team of 15 and counting will be joining this efforts.

We think that we will get those 17,000 words reviewed in totality by the beginning of July but we will still need to get organized. I am waiting for the language lead to get
done with her vacations and come and join us and get the development organized and help me split the work.

As far as I know there is no reason to panic, we do have time and we will have enough time to get everything setup. So fast your seat belts because OpenOffice.org 2.3 promise to have a top notch localization for Spanish.

Digging into OLPC

, , , ...

So today I actually got into OLPC site once again, it all started when I was bored and download the FOSDEM video about the OLPC. One graph on the presentation of the video woke up my curiosity. It was a map of the earth with each country having different colors, like a rating for each country.
I wanted to download the presentation but failed, so my second choice was going to the website. However I found something better, a wiki of the OLPC project.
So decided to find what this colors actually meant, I start doing some searches for keywords related to ratings which gave me no result. The next step is to search for the country, I did a search for mexico and that gave me a whole profile page and it indeed had the grading.
Now that I saw that I look for the link where you can link up to the grading scale. In this case mexico was a red and there was other colors. The grades were the following:
  • Green
  • Red
  • Orange
  • Yellow
  • Gray

With the Green it means they will inmediately adopt Linux, in this countries there were already some interesting countries with not so lagging technical knowledge and with a great pump of technology.

Some other countries that were close to the challenge actually declined adopting linux such as Romania. Mexico, had an interesting stage, it was a 'Red' country which means that they might adopt it once is already working.

Interesting question is what will this make to the country waiting a few years. If they adopt it, there is also the challenge from the same government and just administration within the education.

The education ministry has had bad ventures within education and technology, it will be a shame projects such as OLPC get dirty under the bureacratic and corrupted government that can turn a good idea into uselessness.

Recently I read a post about a wikipedia scandal where government officials were deleting and modifiying posts of some of the government projects such as the same Enciclomedia which is an Encarta hooked into more interacting blackboards.

Unfortunately there had been many issues on that way. kOLPC

Missing a fallen soldier

, , , ...

Today I woke up to the news that a member of the OpenOffice.org community, Gerry Roderick Singleton passed away from a heart stroke on May 12th. The shocking part for me at least, was that I got his Linkedin invitation that same day.
The email from Charles Schultz:

Date: Tue, 15 May 2007 12:13:47 +0200
From: Charles-H. SCHULZ <charles-h.schulz@laposte.net>
Content-Type: text/plain; charset=UTF-8
Subject: Gerry Singleton passed away

Apologies for cross-posting.
Gerry Singleton, our documentation project co-lead
(http://documentation.openoffice.org), just passed away from a sudden
heart attack.
More information on the dev@documentation lists. It’s a very sad day for
OpenOffice.org as we lost an invaluable volunteer; Gerry was one of our
oldest contributors and although I’ve never met him physically, I felt
that he was a friendly and warm presence in our Noosphere. My thoughts
go to his family and his friends.

May he rest in peace. Goodbye Gerry, see you one of these days up there.

Charles-H. Schulz.


After that I followed to verify he was the same person, in shock I discovered that he was the same person. I most say that I didn’t have a strong link to him since he worked in a different project.

His project was the documentation project at http://documentation.openoffice.org. The documentation recently was reinventing itself with the help of OOoAuthors.

I was so interested that I went on to view his linkedin which gave me links to his blogs and his website. I discover that he is also involved in other FLOSS groups like CLUE in Canada which is a group to enforce open source in the Canadian government. He also was an independent consultant owning his own firm PATH tech.

At a senior stage age, he seemed very modern and Web 2.0′ish. On a note at CLUE I also discover he was into Drupal. His friend Evan made a post that describe him earlier that day where they went to DrupalCon in Toronto.

I spent some time at his comany site where he also had some pictures from his family. It seems his family is already on a third generation of off-springs and he was full of new grandkids. All in all even thoght I never met him I could picture him as a happy exciting geek that geekout till the last day.

I am happy of seen that he lived a full and plenty life and he really went all the way till the last day about changing the world and making it more open.

Disabling the Proxy on my Opera from BASH

, , , ...

Usually I dont blog other than OpenOffice.org but having this blog on an Opera community and this been a Opera hack, I think it deserved the attention.

So I don't know much of bash script and I am learning so doing a simple script that will allow me to get rid of some of Opera annoyances --- or GUI annoyances really.

The Problem
My damn employer network force us to use a Proxy everytime we want to access he interweb. So every morning I come in the office I need to run Opera and quickly get the Alt-P keystroke go to Advanced > Network > Proxy Servers and check the HTTP/FTP/HTTPS checkbox to enable the proxy in all. This is quite irritating.

The Research
Asking on the forum I remember that most of this preferences are ASCII parameters in .ini files. So I asked on the forum looking for the right .ini until I found it under ~/.opera/opera6.ini

Did a less opera6.ini |grep Proxy gave me what I was looking for:
[Proxy]
Use WAIS=0
Use Automatic Proxy Configuration=0
HTTP server=internet.ps.net:80
HTTPS server=internet.ps.net:80
Gopher server
WAIS server
Automatic Proxy Configuration URL=
No Proxy Servers=
No Proxy Servers Check=0
FTP server=internet.ps.net:80
Use GOPHER=0
Enable HTTP 1.1 for proxy=0
Use HTTP=1
Use HTTPS=1
Use FTP=1


The last 3 is what I was looking for, so it seems the script should not need any complex XML parser/Regular expression script to a complish this. So instead I used vim command line interface with bash. I end up with vim + bash and some advanced flags will let me be able to perform:
  • Open the file
  • Position on the exact line
  • do a search and replace from 1 to 0 and viceversa
  • Save and Quit


VIM is a very popular editor so a friend suggest me this external flags, specifically the -c flag that stand for command.


The Solution
I finally got something like this:
 vim -c "601" -c "s/1/0/" ~/.opera/opera6.ini


This enabled me to do a search and replace the 0 by 1, but now I need the opposite but instead of having another 1 liner I tried to just use an if... else and have it run.

The code end up like this:
if [ "$1" = "-e" ]; then
        vi -c "610" -c "s/1/0/" 
           -c "611" -c "s/1/0/" 
           -c "612" -c "s/1/0/" 
           -c "wq" ~/.opera/opera6.ini;
   else
        vi -c "610" -c "s/0/1/" 
           -c "611" -c "s/0/1/" 
           -c "612" -c "s/0/1/" 
           -c "wq" ~/.opera/opera6.ini;
   fi


I finally got this script stored on a command I called unproxy stored at /usr/local/bin with everything hardcoding and no 'intelligence on the script'. Ths mean that it doesnt validate that there is indeed a proxy, it's just a dumb command.

using the iff I can switch it on or off depending on the flag I show it:
unproxy -e (-e for enable) 

unproxy 

In the end the configuration profiles changed to just 0:
Use HTTP=0
Use HTTPS=0
Use FTP=0

Got Interviewed at TLLTS

, , , ...

So last wednesday I got interviewed on TLLTS. This is one of the longest ongoing podcasts in the history of Linux podcasting.

The interview hosted Louis Suarez-Potts, who to my surprise is also Mexican which I thought his mother is Mexican but it comes out he also is. We went back and forth about Mexican food and stuff. We put down the 5 de mayo celebration in the United States.

With OpenOffice.org reaching mainstream, we will be able to push forward some of the features of what's comming from the office suite. The extension project, the odftoolkit, and many other things that are going around the world on the ODF adoption.

We spent some time talking about KOffice and a round up around the office suites including Abiword and ODF standarization.

If you are interested on listening to the whole interview please download it here.

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 uno

localContext = 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

, , ,

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 Object
Private 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() = oDocHandler
End 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 Sub

Sub DocHandler_endDocument()
'   Print "End document"
End Sub

Sub DocHandler_startElement( cName As String, oAttributes As _
                             com.sun.star.xml.sax.XAttributeList )
'    Print cName
'Print oAttributes.Length
End Sub

Sub DocHandler_endElement( cName As String )
'   Print "End element", cName
End Sub

Sub DocHandler_characters( cChars As String )
Print "Contenido:",cChars
End Sub 

Sub DocHandler_ignorableWhitespace( cWhitespace As String )
'Print cWhitespace
End Sub

Sub DocHandler_processingInstruction( cTarget As String, cData As String )
End Sub


Sub DocHandler_setDocumentLocator( oLocator As com.sun.star.xml.sax.XLocator )
   goLocator = oLocator
   glLocatorSet = True
End 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

Automating work with Basic II

, , ,

So this is the second part of my blog where I explain the logic used and how I got my script to run in OpenOffice.org.

The first thing I did was take a look and search on Andrew Pitonyak Macro book, to find a code that will come close to do what I have in mind.

The code is simple, this time I found a snippet that was able to select a cell. The original code was the following:
  Dim oCell
  Dim oSheet

  REM Get the first sheet.
  oSheet = ThisComponent.getSheets().getByIndex(0)
  REM Get cell A2
  oCell = oSheet.GetCellbyPosition( 0, 1 )
  REM Move the selection to cell A2
  ThisComponent.CurrentController.Select(oCell)


We can see in this snippet that the process is simple, simply get the sheet from the document and position the cursor on the sheet. Finally call on the CurrentController and use the native function of select.

Here we can see how this script go and how will it fit with our original design. My script needed to switch pages and go incrementally through the ammount of sheets in the spreadsheet.

What I did was obvious, I did a loop, my only concern was, what kind of loop. So far I found the for...next however there are the Do while, and Do Loop. I also needed a range since the loop can't go forever, and finally a way where it can get the data for the population of such things like the title.

I was going in a way to recreate the mail merge for spreads, the data however would be store in an array. The book also came handy at this point since I didn't exactly how to create arrays in OOoBasic.

The samples showed me the path and I was able to make a script that will look like this:
  firstDoc = ThisComponent
  for x = 0 to 14
  y= x
  oSheet= firstDoc.getSheets().getByIndex(y)
  
REM GetCellbyPosition will indicate the cell of the title 
REM SetString will insert the text into the cell
  
  oCell=oSheet.GetCellbyPosition( 1,2 )
  firstDoc.CurrentController.Select(oCell)
  oCell.SetString(title(x))

REM for additional modification include the following:
REM    Position of the cell -> GetCellPosition
REM    Content of the cell  -> SetString
  
  oCell2=oSheet.GetCellbyPosition( 0,1 )
  firstDoc.CurrentController.Select(oCell2)
  oCell2.SetString("Account 1")
  
  
  Next x


Of course that was not all their script and I also need to expand the script to not just label the first array but also static cell content that will be reapeated without major changes. In my script, this was the case with the title of the account, this required no datasource as the content should stay in place.

I also didn't show here the datasource but you can see how the datasource is handled, the array 'title' was able to have a counter instead of their values so the loop registration worked sequensially.

This script is extremely simple since you dont really need any UNO components and is basic loops will go through the created sheets, position on their cells and finally populate it with the infrmation of the array.

In the end the script looked like this:
REM  *****  BASIC  *****
REM
REM Script to insert sequencially the list of servers
REM to execute you need to select the starting page +1
REM and then select the ending page on the 'for Loop'
REM

'Load all the variables including the array
Sub LabelSheet
Dim oCell as Variant
Dim firstDoc as Variant
Dim oSheet as Variant
Dim title() as Variant
Dim titulo()
Dim x
REM title array takes the list from a CSV dump
title=Array("otherhost1",_
"otherhost2",_
"otherhost3",_
"otherhost4",_
"otherhost5",_
"otherhost6")


REM x works as a range, it start from the begining of the ARRAY
REM y is used to put the final starting page adding the value of
REM the "first page"

  firstDoc = ThisComponent
  for x = 0 to 6
  y= x
  oSheet= firstDoc.getSheets().getByIndex(y)
  
REM GetCellbyPosition will indicate the cell of the title 
REM SetString will insert the text into the cell
  
  oCell=oSheet.GetCellbyPosition( 1,2 )
  firstDoc.CurrentController.Select(oCell)
  oCell.SetString(title(x))

REM for additional modification include the following:
REM    Position of the cell -> GetCellPosition
REM    Content of the cell  -> SetString
  
  oCell2=oSheet.GetCellbyPosition( 0,1 )
  firstDoc.CurrentController.Select(oCell2)
  oCell2.SetString("Server")
  
  Next x
End Sub


So lets have an overview of the script:
  • Select a variable
  • Populate the array
  • get the document
  • for loop with the start of the number of array data
  • y variable was put in case you need to start in a document other than 0
  • oSheet selects the sheet in the document
  • oCell gets in the cell
  • Select the cell
  • Insert value with set string from the Array
  • Repeat the process but this time with static as opposed to the loopy title array
  • finish the sub
December 2009
S M T W T F S
November 2009January 2010
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31