Lodahl's blog

29 September 2009

Yet another city

Lyngby-Taarbaek switches to OpenOffice: Will prevent illegal downloading

All students and teachers in Lyngby-Taarbaek Municipality is now offered free office suite OpenOffice. It may be the same, and students are not tempted to illegal downloads of Microsoft Office, says the CIO.

Danish news (translated by Google): http://translate.google.com/translate?js=y&prev=_t&hl=da&ie=UTF-8&u=http%3A%2F%2Fwww.version2.dk%2Fartikel%2F12299-lyngby-taarbaek-skifter-til-openoffice-vil-undgaa-ulovlig-download&sl=da&tl=en&history_state0=da%7Cen%7CLyngby-Taarb%25C3%25A6k%2520skifter%2520til%2520OpenOffice%253A%2520Vil%2520undg%25C3%25A5%2520ulovlig%2520download%250A%250AAlle%2520elever%2520og%2520l%25C3%25A6rere%2520i%2520Lyngby-Taarb%25C3%25A6k%2520Kommune%2520tilbydes%2520nu%2520den%2520gratis%2520kontorpakke%2520Openoffice.%2520Den%2520kan%2520det%2520samme%252C%2520og%2520eleverne%2520fristes%2520ikke%2520til%2520ulovlig%2520download%2520af%2520Microsoft%2520Office%252C%2520lyder%2520argumentet.%2520

27 September 2009

OpenOffice.org Newsletter is out (Danish)

The Danish newsletter is published:
http://issuu.com/lodahl/docs/2009oktober?viewMode=presentation

26 September 2009

Extension help content

I have created a few extensions over the last few years. Some of them even include help content to help the users. One problem is, that the XML syntax are rather dificult to figure out. Even a simple document with a few headers and some paragraphs are rather difficult to create.

It would be rather nice if there where an export filter for xhp-files. I have head that such filter exists but I have never found it.

Expired by this article an Linux Magazine by Dimtri Popov ( http://www.linux-magazine.com/Online/Blogs/Productivity-Sauce-Dmitri-s-open-source-blend-of-productive-computing/Format-Writer-Documents-with-Any-Markup ) I decided to try to make a macro to export a document to xhp. So far I got headers, paragraphs and links. There is still some work to do because tables and pictures.

Also the macro will mess up the original document. It would be nice if it only exported the content leaving the original text untouched.

Here is the macro:


REM ***** BASIC *****

Sub HelpContent
If not ThisComponent.hasLocation Then
MsgBox ("Save document befor export", 0 ,"Export to Help content")
stop
End If


MarkupHeadingsFunc("Text body", "", "")
MarkupHeadingsFunc("Heading 1", "", "")
MarkupHeadingsFunc("Heading 2", "", "")
MarkupHeadingsFunc("Heading 3", "", "")
MarkupTextFunc("CharWeight", com.sun.star.awt.FontWeight.BOLD, "&")
MarkupURLFunc

AddText
ExportTheThing

End Sub

Function MarkupHeadingsFunc (StyleName, StartTag, EndTag)
ThisDoc=ThisComponent
ThisText=ThisDoc.Text
ParaEnum=ThisText.createEnumeration
While ParaEnum.hasmoreElements
Para=ParaEnum.nextElement
PortionEnum = Para.createEnumeration
While PortionEnum.hasMoreElements
Portion=PortionEnum.nextElement
If Portion.paraStyleName = StyleName then
Portion.String = StartTag + Portion.String + EndTag
End if
Wend
Wend
End Function

Function MarkupTextFunc(SearchAttrName, SearchAttrValue, ReplaceStr)
Dim SearchAttributes(0) As New com.sun.star.beans.PropertyValue
ThisDoc=ThisComponent
SearchAttributes(0).Name=SearchAttrName
SearchAttributes(0).Value=SearchAttrValue
ReplaceObj=ThisDoc.createReplaceDescriptor
ReplaceObj.SearchRegularExpression=true
ReplaceObj.searchStyles=false
ReplaceObj.searchAll=true
ReplaceObj.SetSearchAttributes(SearchAttributes)
ReplaceObj.SearchString=".*"
ReplaceObj.ReplaceString=ReplaceStr
ThisDoc.replaceAll(ReplaceObj)
End Function

Sub MarkupURLFunc
ThisDoc=ThisComponent
ThisText=ThisDoc.Text
ParaEnum=ThisText.createEnumeration
While ParaEnum.hasmoreElements
Para=ParaEnum.nextElement
PortionEnum=Para.createEnumeration
While PortionEnum.hasMoreElements
Portion=PortionEnum.nextElement
If Portion.HyperlinkURL <> "" then
Portion.String = "" +Portion.String + ""
End if
Wend
Wend
End Sub

function SetFileName() as String


Dim oDoc
Dim sDocURL
If (Not GlobalScope.BasicLibraries.isLibraryLoaded("Tools")) Then
GlobalScope.BasicLibraries.LoadLibrary("Tools")
End If

sDocURL = ThisComponent.getURL()
Directory = DirectoryNameoutofPath(sDocURL, "/")
File_Name = FileNameoutofPath(sDocURL, "/")
New_File_name = ConvertFromUrl(Left(File_Name, Len(File_Name)-4))


SetFileName = ""
boInitialized = false

oListener = CreateUnoListener("MyPick01_", "com.sun.star.ui.dialogs.XFilePickerListener")
oFP = CreateUnoService( "com.sun.star.ui.dialogs.FilePicker" )
With oFP
.setMultiSelectionMode(False)

.Initialize( Array(com.sun.star.ui.dialogs.TemplateDescription.FILESAVE_SIMPLE) )
.appendFilter("Help content", "*.xhp" )
.setTitle( "Help content ..." )
.setDisplayDirectory(Directory)
.setDefaultName(New_File_Name & ".xhp")



If .execute() Then OpenFile = .Files(0)

.removeFilePickerListener(oListener)
.Dispose()
End With
SetFileName = OpenFile

If SetFileName = "" Then
Stop
End if


end function

sub AddText


Starttext= "" & CHR$(10) & "" & CHR$(10) & "" & CHR$(10) & "" & CHR$(10) & "write title here" & CHR$(10) & "write filename here" & CHR$(10) & "" & CHR$(10) & "" & CHR$(10) & "" & CHR$(10) & "" & CHR$(10) & "xxx" & CHR$(10) & "xxx; yyy" & CHR$(10) & ""

EndText = CHR$(10) & "" & CHR$(10) & "
"

Dim oText As Object
oText = ThisComponent.Text

REM Insert some simple text at the start
oText.insertString(oText.getStart(), StartText & CHR$(13), False)
REM Append a new paragraph at the end
oText.insertString(oText.getEnd(), EndText & CHR$(13), False)



end sub

sub ExportTheThing
FileName = SetFilename()


Dim args(0) as new com.sun.star.beans.PropertyValue
args(0).Name = "FilterName"
args(0).Value = "Text"
ThisComponent.storeToURL(FileName,args())


end sub

REM ***** END BASIC *****

19 September 2009

Android - part II

I got my Android phone a few days ago; a HTC Hero from my regular tele provider: Telenor. They called me the day after I ordered it and said that I could pick it up the very next day.
The first thing I did, was to upgrade the firmware. To do that I had to be connected to a PC through the sync software. That is unfortunately a Windows application? Fortunately a have a dual boot pc at my job with Windows (paid and) installed, so I could upgrade the firmware.

I think it's a very nice phone and its very easy to change settings and so on and so forth. One of the first things i did, was to disable the automatic access to mobile internet connection. That kind of stuff is quite expensive here, so I would like to have completely control over that. Getting access to Wifi was easy. I normally use different Wifi connections and they are all set up. When I enter the office, I automatically go on line. Great.

The user interface is elegant but there are place for further improvements. How is is that I an use the touch screen for everything but closing the active window? Or am I just missing something?

Perhaps I need to read the instructions once more.

To navigate between the screens are very nice and its very easy to get around and find what I need. To start an application is just a cick, but how the f%¤# do I close an application again? I found out that I could download and install an application for that. Crazy that you need to have an application to be able to close other applications. Maybe I'm just misunderstanding the concept.

I tried to install a few applications from Android Market and I would like the list of applications to show a short summary fra the description. Some of the applications has quite mysterious names. Its very easy to install and uninstall applications.

The mail application is somehow strange. When I read mail, the mail content will not show national characters properly. Honestly I thought that problems with character encoding was so old school. The Google mail application is fine.

The Google stuff is great. Everybody is very impressed when I show the Google Live Street View.

And I have even tried to talk with someone. Do any of you remember the days, where phones was devices to use for telephone conversations?

17 September 2009

Export to Freemind part III

I just uploaded a new version of the Export Freemind extension. Now you can export any document with any headings. The mindmap structure will be based on the documents outline numbering (Tools - Outline numbering).

If a level is missing (e.g. if Heading 1 - Heading 3 (no Heading 3) the missing level is replaced with a 'dummy' heading with a red color.

New version available at http://extensions.services.openoffice.org/project/Freemind

Feel free to comment and vote.