WPCubed Product Support

Copying protected text question

I have some protected text in my document. If the user selects a range starting before the protected text and ending after it, they can't copy it. However if they select a range starting inside the protected text and ending outside then they can copy it.

I have tried every ProtectedProp but nothing changes this.

I thought perhaps the OnBeforeCopyText would be the place to prevent this but I can't figure out how.

Any help would be appreciated.
Tony

#1 ♥ 0
8.2k Views 2 users read 3 min
support

Hi,

Which protection attribute do you use?

If you protect fields the mentioned effect is possible. If the start of a field is not selected the field is not copied, just the text. The closing object will be ignored and not saved.

Julian Ziersch

#2 ♥ 0

I create the paragraphs like this:

if not Assigned(WorkingPar) then
        WorkingPar := Block.FirstPar
      else
      begin
        WorkingPar.NextPar := TParagraph.Create(Block);
        WorkingPar := WorkingPar.NextPar;
      end;
      WorkingPar.ParagraphType := wpIsXMLTopLevel;
      WorkingPar.ASet(WPAT_ParProtected, 1);
      WorkingPar.Name := '-1';
      WorkingPar.ASet(WPAT_CharFontSize, 1000);
      WorkingPar.SetText('Miscellaneous and Diagnosis', AttrIndex);
      if FieldByName('RichText').AsString <> '' then
        WorkingPar.LoadFromString(FieldByName('RichText').AsString,'AUTO', '', [wploadpar_AsChildrenPar])
      else
      begin
        WorkingPar.ChildPar := TParagraph.Create(block);
        WorkingPar.ChildPar.SetText(' ', DefaultAttr);
      end;

I have the following ProtectedProp setting:
[ppParProtected,ppCheckAllText,ppNoNewParagraphsInEditFields,ppProtected,ppIsMergedText,ppProtectSelectedTextToo,ppNoEditAfterProtection]

If I understand correctly, the protected text is not "field".

Tony

#3 ♥ 0
support

Now I understand - you are using the SubParagraph demo. I check that out.

The header should be not be copied, thats right.

Julian

#4 ♥ 0

Ah, but it is getting copied in the circumstance I oulined in my first post.

The difference between my code and your demo is that you didn't put any text in the wpIsXMLTopLevel paragraph, instead you painted the text yourself. My text is of varying length and may be more than one line, so I put the text into the paragraph to let the control handle word wrapping.

In the demo you can't copy part of the "header" paragraphs because the control doesn't know there are words there (since you painted them).

In mine however it is allowing the user to select part of the paragraph if the selection area extends outside of the wpIsXMLTopLevel paragraph. This is what I need to prevent, but have been unable to figure out.

Thanks for any help you can offer.
Tony

#5 ♥ 0
support

On second thought there is no option to switch off the copying of protected text - it cannot be changed or deleted, but it can be copied.
Í will add a new clipboard option though.

#6 ♥ 0

In an attempt to block this in my code I have added the following BeforeCopyText procedure to all my TWPRichText objects.

procedure TfmHospitalNecropsy.JournalBeforeCopyText(Sender: TObject;
  var doIt: Boolean);
var
  Stream: TStringStream;
begin
  doIt := True;

  Stream := TStringStream.Create('');
  try
    TWPRichText(Sender).SaveSelectionToStream(Stream, 'WPTOOLS-clipboardoperation');
    if Pos('ParProtected:1', Stream.DataString) > 0 then
      doIt := False;
  finally
    Stream.Free;
  end;
end;

Would this ever not work?

Thanks,
Tony

#7 ♥ 0
support

Did you download V5.18.7?

In history.txt you will find:

  • now ClipboardOption wpcoDontCopyProtectedText - do not copy / cut protected text

This was the option I announced in previous post. (Sun Sep 18, 2005)

Juklian

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