Page 1 of 1

Deletion line/para

Posted: Sat May 05, 2012 6:02 am
by vit
Is it possible to delete line/para using SetSelectionBounds+DeleteSelection instead of DeleteItems+Format/DeleteParas?

I use DeleteItems and sometimes I get exception during the Format execution. I guess the cause is that document is incorrect.

Posted: Sat May 05, 2012 12:06 pm
by Sergey Tkachenko
Yes, DeleteItems may create invalid document (see http://www.trichview.com/help/valid_documents.html ).

However, if you use DeleteParas, it should be safe.

You can use SetSelectionBounds+DeleteSelection. Note that
- this operation is undoable; if you will use it in combination with non-undoable operations, the undo buffer will contain invalid data, and you need to clear it using ClearUndo;
- to delete the paragraphs from the M to N, y need to select either from the end of the paragraph M-1 to the end of the paragraph N, or from the beginning of the paragraph M to the beginning of the paragraph N+1.
If you select from the beginning of M to the end of N, DeleteSelection will produce an empty line in the place of deletion.

Posted: Sat May 05, 2012 12:48 pm
by vit
Thanks! I've tried to do like this

Code: Select all

RVData.SetSelectionBounds(FirstItemNo, RVData.GetOffsBeforeItem(FirstItemNo), LastItemNo + 1, RVData.GetOffsBeforeItem(LastItemNo + 1));
FRVE.DeleteSelection;
and it works properly!

Posted: Sat May 05, 2012 3:06 pm
by Sergey Tkachenko
Assuming that LastItemNo is not the last item, i.e. LastItemNo+1 < RVData.ItemCount

Posted: Sat May 05, 2012 4:07 pm
by vit
yes of course