REM  *****  BASIC  *****
REM Version 0.2
REM Author Chrys
sub GoToNextMissspelledWord
	rem -------------------------------------------------------------
	rem define variables

	dim found as boolean 
	Dim currCursor As Object
	dim viewCursor as object
	
	Dim emptyArgs(0) As New com.sun.star.beans.PropertyValue
	Dim aLocale As New com.sun.star.lang.Locale
	
	rem -------------------------------------------------------------
	rem go to next missspelled word
	found = false
	viewCursor = thisComponent.getCurrentController.getViewCursor
	currCursor = viewCursor.getText.createTextCursorByRange(viewCursor)
	oldCursor = viewCursor.getText.createTextCursorByRange(viewCursor)	
	vSpeller = createUnoService("com.sun.star.linguistic2.SpellChecker")
		
	aLocale.Language = "de"
	aLocale.Country = "DE"

	NextWord:
		currCursor.gotoNextWord(false) 
		currCursor.gotoStartOfWord(false)
		currCursor.gotoEndOfWord(true)
		found = not vSpeller.isvalid(currCursor.String , aLocale, emptyArgs()
		if not found then
			currCursor.gotoEndOfWord(false)
			if currCursor.goRight(1,false) then
				currCursor.goLeft(1,false)
				GoTo NextWord
			end if
		end if	
		
	if found then
		currCursor.gotoStartOfWord(false)
		viewCursor.gotoRange(currCursor, false)
	else
		msgbox("Keine weiteren Fehler gefunden. Gehe zum Anfang.")
		currCursor.gotoStart(false)
		viewCursor.gotoRange(currCursor, false)
	end if

end sub

