grammar check: How to get TextRange of processed paragraph

Fred Kruse f.kruse at freenet.de
Thu Nov 9 12:17:08 UTC 2017


I found a way for a workaround. Get the XFlatParagraphIterator and 
iterate back with getParaBefore for the automatic iteration. Use the 
viewcursor for manual checks. It works so far.

For future development it could be interesting for both communities to 
work together closer, I think.

For some languages (e.g. German) LanguageTool is the best existing 
grammar checker. It supports LibreOffice (but not MS-Office). So its a 
real feature of LO.

There are developments on rules for LanguageTool on the level of full 
text, especially for stylistic questions. For a proof a reference of the 
whole document is needed. I wonder if this could be supported in future 
versions of LO.

There are some more Ideas, e.g. to underline stylistic matches in 
another color than grammar matches.

Are you involved in further development of the LO grammar checker or do 
you know someone who is?

Fred K.


Am 07.11.2017 um 16:31 schrieb Michael Stahl:
> 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?
>



More information about the LibreOffice mailing list