This is a collection of scraps for the Open Office project

The Open Office project is an attempt, largely financed by Sun Microsystems, to build an open-source retaliation or replacement to Microsoft Office. It runs on Windows, Linux, and Mac systems; and is based on Star Office, an office suite which enjoyed great popularity in Germany. I think competition is a fine thing, so here is my contribution to this project. This is a hobby. My main job is here

Here is a British English spelling dictionary

Other resources

There are a couple of pretty and clever calendar templates here . Admittedly, they're in German, but translating month names from German to English is a lot less painful that translating from English to the new API.

Word compatibility Notes

Used as a word processor, Open Office makes a startlingly good job of reading and writing MS Word documents. I have only found a couple of gotchas.

Useful macros

The old Star Office had a Basic language very similar to Microsoft's VBA. The new version 6, and Open Office, have kept the language and changed to an entirely new and largely impenetrable API. In other words, the syntax is the same, but the vocabulary has changed beyond recognition and no one from Sun / Open Office seems interested in helping people through the thickets of the new language, though there is a 2mb PDF manual available.

I have just discovered what looks like an excellent macro-writers' aid here. It is a macro, commented in German, which you should attach to a document. Select something in the document; run the macro: it will start a new Open Office spreadsheet in which all the properties and methods applicable to the thing you have selected will be listed.

The new API is so immensely frustrating that I have started a small collection of working macros, in the hope that they will be useful to others, who are encouraged to email me their own. I will post them here if they work.

Here are some to fill in obvious holes. Cut, paste, and enjoy.

  1. Trnaspose two characters each side of the cursor (I need this)
  2. Change the case of the word under the cursor
  3. Quick word count

Sub transpose

Dim oDocument, oDesktop as Object
Dim oText as Object
Dim oVCursor, oCursor As Object
Dim sWombat as string
' the two following lines get the active document
oDesktop = createUnoService("com.sun.star.frame.Desktop")
oDocument= oDesktop.getCurrentComponent()
oText = oDocument.Text
' after this, an obscure call gets the current cursor position
' but most cursor methods don't work with a view cursor
oVCursor = oDocument.currentcontroller.getViewCursor()
' so now I create an invisible cursor under it,
oCursor = oText.createTextCursorByRange(oVCursor.getstart())
' grab the next character
oCursor.goRight(1,TRUE)
' save a copy (no clipboard)
sWombat = ocursor.getString()
' delete the original (seems to be no obvious delete method)
' obviously, what I wanted was a method to cut to the clipboard
' but this doesn't seem possible
oCursor.setString("")
' next two lines move the invisible cursor
oCursor.CollapseToStart()
oCursor.goLeft(1,true)
' and now insert the cut character
oText.insertString(oCursor.getStart(),sWombat,false)
oVCursor.GoLeft(1,false) ' finally return the visible cursor whence it came
End Sub

Sub CaseChanger

' silly macro by Andrew Brown
' This works like the corresponding command in MS Word, though only on single words:
' if you assign it to a key, successive key presses
' will cycle through upper case, lower case and title case.
Dim oDocument, oDesktop as Object
Dim oText as Object
Dim oVCursor, oCursor As Object
Dim sWombat as string
' the two following lines get the active document
oDesktop = createUnoService("com.sun.star.frame.Desktop")
oDocument= oDesktop.getCurrentComponent()
oText = oDocument.Text
oVCursor = oDocument.currentcontroller.getViewCursor()
oCursor = oText.createTextCursorByRange(oVCursor.getstart())
oCursor.gotoStartOfWord(false)
oCursor.gotoEndOfWord(true)
' the next routine checks if the word has several cases in it,
' and irons them out. Otherwise everything works erratically lower down
if oCursor.GetPropertyState("CharCaseMap")>0 then
oCursor.SetPropertyToDefault("CharCaseMap")
oCursor.CharCaseMap=2
end if
sWombat=oCursor.getPropertyValue("CharCaseMap")
'msgbox "CharCaseMap is now " + sWombat
if sWombat="1" then ' we have lowercase text
oCursor.CharCaseMap = com.sun.star.style.CaseMap.TITLE
elseif sWombat="2" then ' already title case
oCursor.CharCaseMap=com.sun.star.style.CaseMap.UPPERCASE
elseif sWombat="3" then ' we have uppercase
oCursor.CharCaseMap = com.sun.star.style.CaseMap.LOWERCASE
else
oCursor.SetPropertyToDefault("CharCaseMap")
end if
End Sub

Sub QDWordCount

' simple word count macro by Andrew Brown
' for OO641, with hack to take accoutn of broken move-by-word
Dim oDocument, oDesktop as Object
Dim oText as Object
Dim oCursor As Object
Dim lwords as long
' the two following lines get the active document
oDesktop = createUnoService("com.sun.star.frame.Desktop")
oDocument= oDesktop.getCurrentComponent()
oText = oDocument.Text
oCursor=oText.createTextCursor()
oCursor.gotoStart(false)
lwords=0
do while oCursor.gotoNextWord(false)=true
lwords=lwords+1
loop
' because move-by-word is at the moemnt broken, this counter is
' counting the ends as well as the beginnings of words. So halve it.
msgbox "Word Count is " + str(int(lwords/2))
End Sub