grammar check: How to get TextRange of processed paragraph

Michael Stahl mstahl at redhat.com
Tue Nov 7 15:31:32 UTC 2017


On 03.11.2017 14:00, Fred Kruse wrote:
> I'm working on LanguageTool an international grammar checker (java based 
> extension for LibreOffice). Till now the environment of a sentences is 
> checked only for the surrounding paragraph. But some rules need to check 
> the whole text. To implement such a check I need to know which paragraph 
> is currently checked (TextRange).
> 
> Is there a possibility to get the TextRange for the checked paragraph 
> while doProofreading is processed?

not currently, and i wonder if it's intentional.

the string that is passed to doProofreading is pre-processed and doesn't
correspond 1:1 to the text in the paragraph, so you can't really know
where any given XTextRange is relative to that string, and not every
position in the string has a corresponding XTextRange...

the GrammarCheckingIterator iterator uses the SwXFlatParagraphIterator
to get the "dirty" paragraphs, and there doesn't appear to be any way to
get XTextRange for them.

on the other hand, there are XFlatParagraph methods like changeText and
changeAttributes that don't do this mapping, which looks like a bug?
these aren't used by the GrammarCheckingIterator, i wonder why they exist?

-- 
DDJ: You've mentioned Edsger Dijkstra. What do you think of his work?
DK:  His great strength is that he is uncompromising. It would make
     him physically ill to think of programming in C++.


More information about the LibreOffice mailing list