’ this is a version that does not use charcasemap at all
’ to get around the broken export features
’ which otherwise make my copy look ridiculous
’ see bug #17056 in IZ
’ acb, July 22 2003
’ updated September 3 2003 with routines to get round the broken
’ word iterators which otherwise made it look silly when words start or end
’ with punctuation of almost any sort.
Dim oDocument, oDesktop as Object
Dim oText, alpha, omega as Object
Dim oVCursor, mySelection As Object
Dim snot as string,changeme as string, test1 as string, test2 as string
’error handling stolen from Paolo Mantovani
On Error GoTo ErrH:
oDocument = thisComponent
oVCursor = oDocument.currentcontroller.getViewCursor()
oText=oVCursor.getText() ’ AP’s trick to get text anywhere.
If len(snot)>0 Then ’ there is a selection: use that
mySelection = oText.createTextCursorByRange(alpha)
else ’ the cursor is a point; grab the word it’s in.
’ Grabbing the word would be simple, except that that breakiterator is broken
’ in OOo 1.1 and I have had to build in workarounds for when there is any
’ punctuation immediatealy before or after the word.
mySelection = oText.createTextCursorByRange(oVCursor.getstart())
’ at the next line, it ought to work to do gotoStartOfWord(FALSE)
’ but the cursor does not move at all if it is between a word and any punctuation
’ so I have first to check if it did move
if len(mySelection.getString())=0 then
’ we have the pnctuation after word bug
mySelection.goLeft(1,FALSE) ’ move into the word and then go
’ we’re good, and can just go
’ here a routine to check for quotes and other punctuation at the start of the word ...
’ msgbox("Changeme now holds " + changeme +" before the fix")
if len(changeme)=0 then ’ there was a quote at the start of the word.
mySelection.goRight(1,TRUE) ’ so move manually because move-by-word broken
’ and end of the complicated workarounds.
’ changeme is now the word that the cursor was in
test1=left(changeme,1)’ first char of word of selection
test2=right(changeme,1) ’ last char of word or selection
if asc(test1)>90 then ’ word / selection must be lowercase, so turn to title case
’ the first letter is upper case. Is the last?
if asc(test2)>90 then’ no, so this is in title case. Make it upper case
else ’it was all upper case. flip it over
MsgBox "Error " & err & ": " & error$ & chr(13) & _
"In line : " & Erl & chr(13)