El vie, 21-04-2006 a las 13:13, Laurent Godard escribió:
> Hi
>
> i didn't try
>
> >
> > If Not oSpellChk.isValid(oTextCursor.getString(),
> > oTextCursor.getPropertyValue("CharLocale"), aProp()) Then
> >
>
> is your local property of your paragraph/characters set ?
Hi Laurent:
That seems to be the problem, bad definition of the CharLocale property
(more precisely, a lack of it). I used to think that it were ALWAYS
defined, but it seems not.
Dmitri: Could you test it with this corrected macro?
Best regards,
Santiago Bosio
REM ***** BASIC *****
Sub ListarPalabrasIncorrectas
Dim oDocModel as Variant
Dim oTextCursor as Variant
Dim oLinguSvcMgr as Variant
Dim oSpellChk as Variant
Dim oListDocFrame as Variant
Dim oListDocModel as Variant
Dim sListaPalabras as String
Dim aProp() As New com.sun.star.beans.PropertyValue
' Obtener acceso al documento actual
oDocModel = StarDesktop.CurrentFrame.Controller.getModel()
If IsNull(oDocModel) Then
MsgBox("No hay ningún documento activo." + Chr(13) + _
"Abra un documento de Writer antes de activar esta macro.")
Exit Sub
End If
' Verificar que este sea un documento de texto
If Not HasUnoInterfaces (oDocModel, "com.sun.star.text.XTextDocument") Then
MsgBox("Este documento no soporta la interfaz 'XTextDocument'." +
Chr(13) + _
"Utilice esta macro únicamente con documentos de Writer.")
Exit Sub
End If
' Obtener un cursor de texto y posicionarlo al principio del documento
oTextCursor = oDocModel.Text.createTextCursor()
oTextCursor.gotoStart(False)
' Obtener una referencia al corrector ortográfico o morir en el intento
oLinguSvcMgr =
createUnoService("com.sun.star.linguistic2.LinguServiceManager")
If Not IsNull(oLinguSvcMgr) Then
oSpellChk = oLinguSvcMgr.getSpellChecker()
End If
If IsNull (oSpellChk) Then
MsgBox("No se pudo acceder a un corrector ortográfico." + Chr(13) + _
"Verifique las opciones de lingüística de su instalación.")
Exit Sub
End If
' Iterar sobre todas las palabras que contiene el documento
Do
If oTextCursor.isStartOfWord() Then
oTextCursor.gotoEndOfWord(True)
' Verificar si la palabra está bien escrita
If Not isEmpty (oTextCursor.getPropertyValue("CharLocale")) Then
If Not oSpellChk.isValid(oTextCursor.getString(),
oTextCursor.getPropertyValue("CharLocale"), aProp()) Then
sListaPalabras = sListaPalabras + oTextCursor.getString() +
Chr(13)
End If
End If
oTextCursor.collapseToEnd()
End If
Loop While oTextCursor.gotoNextWord(False)
If Len(sListaPalabras) = 0 Then
MsgBox("No hay errores ortográficos en el documento.")
Exit Sub
End If
' Buscar el frame que contiene la lista (o crearlo)
oListDocFrame = StarDesktop.findFrame("fListarPalabrasIncorrectas",
com.sun.star.frame.FrameSearchFlag.ALL)
If IsNull(oListDocFrame) Then
oListDocModel =
StarDesktop.loadComponentFromURL("private:factory/swriter",
"fListarPalabrasIncorrectas", com.sun.star.frame.FrameSearchFlag.CREATE,
aProp())
oListDocFrame = oListDocModel.CurrentController.getFrame()
Else
oListDocModel = oListDocFrame.Controller.getModel()
End If
' Obtener un cursor de texto para este documento
oTextCursor = oListDocModel.Text.createTextCursor()
oTextCursor.gotoEnd(False)
' Escribir la lista
oListDocModel.Text.insertString (oTextCursor, sListaPalabras, False)
' Activar este frame
oListDocFrame.activate()
' ¡Y ya terminamos!
End Sub
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]