WPCubed Product Support

TWPRTFEngineBasis.IsProtected

Hi Julian,

In April 3rd, 2006, I sent you this message, with no answer since:

Subject: Problem with TWPRTFEngineBasis.IsProtected

I 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

#1 ♥ 0
4.2k Views 2 users read 5 min
support

Hi,

empty paragraph cannot hold the afsProtected style since this can be only applied to characters.

The update solves the problem of
a) insertion before protected text
b) insertion between protected texts at first position in par

It does not prohibt insertion into an empty paragraph

and about "I sent you this message, with no answer since" - I sent You 438 messages total and received 923. This is in fact a bit excessive. My last custom function for table_to_text did not get recognoced, despit the work which was involed. That is not encouraging.

Julian

#2 ♥ 0

Hi Julian,

It wasn't my intention to be rude. I was just showing since when I have this problem unanswered, and unfortunatelly, the error will not be fixed. At least it was my understanding, based on the description of your post. By the way, I was asking about 'DELETE', not 'INSERT' in empty paragraphs.

About the messages count, yes, its a bit excessive, but what can I do? If you remember, I use WPTools since version 3, starting in 2001. It sums about 7 years and 3 full version upgrades (3 -> 4 and 4 -> 5). And I have users that need my text editor, to be very close to MSWord in features and easy of use. Some features you did improve in basic WPTools. Others I code myself, and send you, and sometimes you accept my changes, and sometimes not, so I update the code myself. If I remember well, I have about 15 code changes in my custom WPTools compilation, without counting my own inheritance level. And besides one or other minor issue, I can tell you with no doubt, that WPTools is a great product. My only missing is to be much more MSWord compatible, behavioral speaking.

About the table_to_text routine, sorry, but while testing it, I get some msword incompatibilty behaviors, and since the 'undo problem' didn´t appears to be a big issue after all, was decided keep with my own code. I forgot to tell you, really sorry.

Alessandro

#3 ♥ 0
support

Hi,

If you need to handle the DELETE key please note the function

Memo.IsProtected

that receives a paragraph and position to be checked.

You can check a previous paragraph like this:

apar := aCursor.active_paragraph;
while (apar<>nil) and (apar.prev<>nil) and (apar.CharCount=0) do apar := apar.prev;
protmode := IsProtected(apar, apar.CharCount - 1);

I am using such code in SetChar in WPRTEPaint to improve the protection handling.

Julian

#4 ♥ 0
This category is archived. No new posts are possible.