invalid caret position

General TRichView support forum. Please post your questions here
Post Reply
tmMK
Posts: 18
Joined: Thu Sep 08, 2005 10:27 am
Location: Prague - Czech Republic

invalid caret position

Post 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...
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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)
tmMK
Posts: 18
Joined: Thu Sep 08, 2005 10:27 am
Location: Prague - Czech Republic

Post by tmMK »

ok,
i'll try to follow the instructions in Valid Document topic because Function NormalizeRichView() makes bad things with document...

thanks...
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Bad things? For example?
Post Reply