Bonjour,
Je travail sur une extension pour Open Office, écrite principalement en
StarBasic, il s'agit d'un correcteur. J'ai un comportement assez étrange que
je n'arrive pas à m'expliquer et encore moins à corriger. Lors du parcours
d'une document (ou d'une portion de texte), l'extension commence par le
"bas" du document et non par le début.
Voilà comment s'effectue cet itération "à l'envers":
Dim oCursors(), i%
If Not CreateFullTextIterator(ThisComponent, oCursors()) Then Exit Sub
For i% = LBound(oCursors()) To UBound(oCursors())
CheckWord(oCursors(i%, 0), oCursors(i%, 1), ThisComponent.Text)
Next
J'ai essayé d'inverser LBound et UBound, sans succès. Je pense que le
problème est dans la création de l'itérateur:
Function CreateFullTextIterator(oDoc As Object, oCursors()) As Boolean
Dim oLCurs 'Cursor to the left of the current selection.
Dim oRCurs 'Cursor to the right of the current selection.
CreateFullTextIterator = True
oLCurs = oDoc.getText().createTextCursor()
oLCurs.gotoStart(False)
oRCurs = oDoc.getText().createTextCursor()
oRCurs.gotoEnd(False)
oCursors = DimArray(0, 1)
oCursors(0, 0) = oLCurs
oCursors(0, 1) = oRCurs
End Function
J'avoue ne pas très bien comprendre cette notion de curseurs. Il y'a une
inversion quelques part (vraisemblablement) mais après moult essaie, je n'ai
pas réussi à trouver d'où vient le problème... Une idée ?
--
Romain PELISSE,
"The trouble with having an open mind, of course, is that people will insist
on coming along and trying to put things in it" -- Terry Pratchett
http://belaran.eu/