WPCubed Product Support

ClearTextInbetween + single paragraph + wpNoDeletePar

WPTools version 6.13

Assume:

  • ppProtectSelectedTextToo on
  • Paragraph with TWPProtectedMode << wpNoDeletePar

If I select some text within the paragraph above and press Delete, the text is not deleted. Shouldn't TWPRTFDataCursor.ClearTextInbetween only check for wpNoDeletePar if a paragraph actually is going to be deleted (basically par_s != par_e)?

Regards
patrik.nyborg(a)genicore.se

#1 ♥ 0
6.2k Views 2 links 2 users read 4 min
support

If I select some text within the paragraph above and press Delete, the text is not deleted. Shouldn't TWPRTFDataCursor.ClearTextInbetween only check for wpNoDeletePar if a paragraph actually is going to be deleted (basically par_s != par_e)?

I cannot reproduce. I tried

WPRichText1.ActiveParagraph.ASet(WPAT_ParProtected, 1);
WPRichText1.ProtectedProp := [ppParProtected,ppProtectSelectedTextToo];

to protect one paragraph.

But, if you select text from one paragraph to the next, the deletion operation would remove the next paragraph and append the rest of the text in the delete paragraph to the one before. It actually deletes the second paragraph. Then it is correct not to perform the operation.

Julian

#2 ♥ 0

Basically what I'm suggesting is something like this:

Index: WPRteDefs.pas
===================================================================
--- WPRteDefs.pas	(revision 9147)
+++ WPRteDefs.pas	(working copy)
@@ -37219,7 +37219,7 @@
 var par: TParagraph;
   i, l, Flagvalue: Integer;
   oldundo: Boolean;
-  protmode: TWPProtectedMode;
+  protmode, disallowed_protmode: TWPProtectedMode;
   par_table: TParagraph;
   FOpenObjects: TList;
   obj: TWPTextObj;
@@ -37278,6 +37278,10 @@
 
   _SectionIsProtected := FALSE;
   Result := FALSE;
+  if((par_s <> nil) and (par_s = par_e) and (par_s.CharCount > 0) and (pos_s >= 0) and (pos_s <= pos_e) and (pos_e <= par_s.CharCount)) then
+    disallowed_protmode := [wpNoOverwrite, wpNoDeleteChar]
+  else
+    disallowed_protmode := [wpNoOverwrite, wpNoDeletePar, wpNoDeleteChar];
 
   if (par_s <> nil) and (par_e <> nil) and not OverrideProtection and
     (ppAllExceptForEditFields in ProtectedProp) then
@@ -37334,7 +37338,7 @@
       if par.CharCount = 0 then 
       begin
         protmode := FRTFEngine.IsProtected(par, -1, true);
-        if (protmode * [wpNoOverwrite, wpNoDeletePar, wpNoDeleteChar]) <> [] then
+        if (protmode * disallowed_protmode) <> [] then
         begin
           Result := TRUE;
           _SectionIsProtected := TRUE;
@@ -37345,7 +37349,7 @@
         while i < l do 
         begin
           protmode := FRTFEngine.IsProtected(par, i, true);
-          if ((protmode * [wpNoOverwrite, wpNoDeletePar, wpNoDeleteChar]) <> []) and
+          if ((protmode * disallowed_protmode) <> []) and
             ((ProtectedProp * [ppBookmarkKeepStructure, ppInsertpointKeepStructure]) <> []) then
           begin
             aObj := par.ObjectRef[i];
@@ -37360,7 +37364,7 @@
             end;
           end;
 
-          if (protmode * [wpNoOverwrite, wpNoDeletePar, wpNoDeleteChar]) <> [] then
+          if (protmode * disallowed_protmode) <> [] then
           begin
             Result := TRUE;
             _SectionIsProtected := TRUE;

Regards
patrik.nyborg(a)genicore.se

#4 ♥ 0
support

Hi,

I am sorry, but this is too much for the support forum. The RTF Engine is private code and not available to most of the WPTools users.

I value your input top the complícated "protection" check, but the current code is optimized for regular documents, not nested paragraphs. I cannot simply change the behavior.

Julian

#5 ♥ 0

First: This has nothing to do with nested paragraphs.
Second: I guess I could start patching more aggresivly. But if I interpret you correctly (optimized=works correctly for) subparagraph handling is poor which will require modifications all over the place. Adding the fact that it's really hard to debug (I have to move the methods of interest to the beginning of WPRteDefs.pas to be able to set a breakpoint - [](http://wpcubed.com/forum/viewtopic.php?t=5239&amp;sid=77a77089ddfcc4057d24788fd11fd305)), this feels like the beginning of the end.

patrik.nyborg(a)genicore.se

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