Lodahl's blog: 12/01/2013 - 01/01/2014

19 December 2013

I have been fooling around


I have been fooling around for a couple of days. 

Yes I admit it. From time to time I enjoy working with something totally different from what I do in my daily life and something that is absolutely irrational. This time I suddenly found my self playing around with ownCloud (https://www.owncloud.org ).

I found that I could launch a pre-configured cloud server on Amazon ( http://aws.amazon.com ) from Bitnami ( http://bitnami.com/stack/owncloud/cloud ).

It took me about half an hour to order and fire up the basic server and after another hour of configuration I had a safe and sound cloud server running. And it all comes in my native language (Danish) out of the box.

I wanted to install a few extra apps for different tasks e.g., a music player that for some reason isn't included in the standard edition of ownCloud 6. The only problem with that was that the music app depends on another apps 'App Framework'. Unfortunately that wasn't very clear in the instructions, and it took me a couple of hours to find the solution and implement it. I made another mistake by activating the app 'FluXX Compensator (Y)'. A friend of mine recommended it to me, but it seems to mess up ownCloud completely. It took me quite some time what caused the problem but when I found the cause it was pretty easy to disable it. I couldn't use the web interface (as it was messed up) but I could remove the app folder through SSH.

So now my family and I can store and share files in a relatively safe way. I know that Amazon might not be the safest place (in the Snowden years), but I somehow feel safer now where I son't have to use Dropbox or Google Drive. I don't like storing my private documents on a server that doesn't belong to me. 

Never mind.

I'n now using my ownCloud as family calendar completely sync'ed with my locally installed Thunderbird/Lightning. The only missing feature is the lack of inviting and accepting invitations directly in my mail and calendar program.
What I find extremely interesting is the way ownCloud can work with documents. First of all ownCloud supports WebDAV and I can open and save files directly from LibreOffice.

Open documents in LibreOffice

But more interesting is a new interesting feature in ownCloud 6: WebODF ( http://webodf.org/ )!

WebODF is a separate open source project that is a JavaScript implementation of the OpenDocument format. So far WebODF only implemented som very basic parts of text documents but its a nice first step. And a step in the right direction. I know that WebODF is working on a spreadsheet thing too and that's exiting.
Another extremely cool feature is that WebODF supports collaborative editing of rich-text documents. We are talking about two or more editors working on the same document at the same time.

Editing on line

WebODF is not a web version of LibreOffice but you can create and edit documents with basic formatting and styles. I even discovered that uploading a rather complicated ODT document from LibreOffice with a table of content and cross references works fine. Some visual features are visible in the browser version of the document, but even if not the unsupported features survives being edited with WebODF.

Conclusion

My conclusion is clearly 'enthusiasm'. I will certainly be using ownCloud as my private cloud server from now on and I can see some very cool ideas coming in the future. I'm exited about WebODF working with ODF documents using JavaScript and I can see many useful things to use it for. I can clearly see ownCloud useful for small business and e.g., schools and NGOs.

I give it a thumb up.

03 December 2013

LibreOffice now has a built in XML-parser

LibreOffice is using a XML based document format so of cause there is a built in XML parser. But until now it has been quite cumbersome to deal with XML in macros. You need to manually traverse through the entire XML structure like this example (thanks to Andrew Pitonyak):

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

'==================================================
' Methods of our document handler call these
' global functions.
' These methods look strangely similar to
' a SAX event handler. ;-)
' These global routines are called by the Sax parser
' as it reads in an XML document.
' These subroutines must be named with a prefix that is
' followed by the event name of the com.sun.star.xml.sax.XDocumentHandler interface.
'==================================================

Sub DocHandler_characters( cChars As String )

if xNode = "lipsum" then
oWrite=1
cChars= Left(cChars,len(cChars)-1)
if len(cChars)>1 then
cChars= cChars+ Chr$(13)
else
cChars=cChars
endif
WriteLoremipsum (cChars, oWrite)
Else oWrite=0
Endif
End Sub

Sub DocHandler_ignorableWhitespace( cWhitespace As String )
End Sub

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

Sub DocHandler_startDocument()
End Sub

Sub DocHandler_endDocument()
End Sub

Sub DocHandler_startElement( cName As String, oAttributes As com.sun.star.xml.sax.XAttributeList )
xNode = cName
End Sub

Sub DocHandler_endElement( cName As String )
End Sub

Sub DocHandler_setDocumentLocator( oLocator As com.sun.star.xml.sax.XLocator )
' Save the locator object in a global variable.
' The locator object has valuable methods that we can
' call to determine
goLocator = oLocator
glLocatorSet = True
End Sub

This example above is from the extension Lorem Ipsum generator that you can download from here: http://extensions.libreoffice.org/extension-center/magenta-lorem-ipsum-generator

But now its much easier as LibreOffice 4.2 comes with two new spreadsheet functions called WEBSERVICE and FILTERXML. In a macro it is possible to call and use such built in spreadsheet functions even when you are working with text documents.

The example below does pretty much the same as the one above

Sub Main
svc = createUnoService( "com.sun.star.sheet.FunctionAccess" ) 'Create a service to use Calc functions
XML_String = svc.callFunction("WEBSERVICE",array("http://www.lipsum.com/feed/xml?amount=2&what=paras&start=Yes"))
Lipsum = svc.callFunction("FILTERXML", array(XML_String, "/feed/lipsum" ))
Print Lipsum
End Sub

I'm really looking forward play around with these nifty little features in Calc.