Hi Julian,
In April 3rd, 2006, I sent you this message, with no answer since:
ZitatAlles anzeigen
Subject: Problem with TWPRTFEngineBasis.IsProtectedI have found a little issue about this procedure. It is not working fine with empty paragraphs.
Let's suppose this scenario.
1. I have five paragraphs.
2. The first paragraph is entirely protected (afsProtected). I set this attribute to pieces of text because I need to "protect" pieces of text to be like a "comments" or"notes" in my system. The user selects a piece of text, clicks a button and I add "afsProtected" to the selection (CurrAttr.AddStyle([afsProtected]);)
3. The second, third and forth paragraphs are "empty" (just an "Enter").
4. The fifth paragraph is anything, it doesn't matter.
5. Put the caret at the second, third or forth paragraph (the empty paragraphs).
6. Hit "DEL" to delete this paragraph, which should move the fifth paragraph one line up. You will note that nothing happens.This is caused because you use the CharAttr attribute from the last character of the last non-empty paragraph, instead of the current paragraph. If I remember well, in some situations (internal checks) the CharAttr value is based on the "previous character", and not "actual character". Maybe this is one of that situations.
I guess that in this particular situation you could change TWPRTFEnginePaint.InputString / procedure SetChar to have a special treatment if this happens.
I was thinking that using aCursor.CPAttr.HasStyle could solve the problem, but it is not returning TRUE for neither of the three empty paragraphs. Calling aCursor.CPAttr.HasStyle only works if I'm inside a non-empty paragraph.
The code that I use to protect the selected text, in this case the first paragraph, is also adding \wpprot1 tag to the second paragraph (the first empty paragraph). Maybe a bug in CurrAttr.AddStyle or in SelectParagraph. But even if I hit DEL in the third or forth paragraph (two empty paragraph with no \wpprot1 tag defined), it still don't delete that paragraph, because it only checks for the previous non-empty paragraph, and .HasStyle doesn't return true.
I guess that this problem happens because when a paragraph is empty, you don't store this kind of information in it.
How could I solve it?
Thanks for your help
Thanks in advance
So, with this update it is now oficially impossible to delete this empty paragraphs, and the users will not be able to edit the text? Or the protection is only about 'inserting text'?
Thanks for your help.
Alessandro