Page 1 of 1

invalid caret position

Posted: Wed Oct 05, 2005 4:41 pm
by tmMK
hi Sergey,

I was working with list styles and invalid caret position exception appears. I have found that this exception raises when marker has one item with zero size... Please look at TRVEditRVData.OnChangeCaretLine.

There are CaretOffs variable (which was filled from constant VARGE_VALUE = 100000) and variables - First and Last. There is GetScreenLineBounds function which initializes First and Last... In this case the function returns same First as Last.

After that there is a decision wether item is rvsListMarker - result is True - so First is incremented... Following for cycle (for i := First to Last do) which should set CaretOffs not pass trough...

So in TRVEditRVData.ChangeCaret where is the decision wether exception will be risen {if (CaretOffs<0) or (CaretOffs>=CharEnds.Count) then} is clear what will follow... (CaretOffs = 100000)

i hope this will help you...

Posted: Wed Oct 05, 2005 7:35 pm
by Sergey Tkachenko
This exception occurs in some cases when the document violates rules listed in the help file "Valid Documents" topic.
For example, when the marker is added without a subsequent item (each marker must be followed by at least one item, may be an empty text item).
Documents never become incorrect after editing operations (if they were correct initially), But using some methods for document generation, it's possible to produce incorrect documents. RVHtmlImporter sometimes creates incorrect documents.

The simplest solution - to call NormalizeRichView(RichViewEdit1.RVData) after generation (or HTML import). This function is included in NormalizeRV.pas in RichViewActions (this unit can be used separately from RichViewActions)

Posted: Thu Oct 06, 2005 8:54 am
by tmMK
ok,
i'll try to follow the instructions in Valid Document topic because Function NormalizeRichView() makes bad things with document...

thanks...

Posted: Thu Oct 06, 2005 8:03 pm
by Sergey Tkachenko
Bad things? For example?