WPCubed Product Support

Copy formatting

Hi

How ca I copy-paste the format in wptools?
Like Ctrl-Shift-C in Word

Matthias

#1 ♥ 0
6.3k Views 2 users read 2 min
support

Hi,

That shortcut is not implemented but it is fairly easy to save/apply a set of properties.

You would use the WPSS ("WP Style Sheet") for this, i.e.

LastCopiedStyle := ActiveParagraph.AGetWPSS(false, true, true)

ActiveParagraph.ASetWPSS(LastCopiedStyle )

The WPSS strings are also supported by the TWPAttrInterface, i.e. SelectecedTextAttr!

Julian

#2 ♥ 0

Hi

I was unfortunately not succesfull with this.
I don't use styles.

I want to copy the format (like Fontname, Fontstyle)
at the cursor position and paste it later, either
to the current selected text or the active paragraph
(if there is no selection).

Thanks

#3 ♥ 0
support

I did not mean to use styles.

This code will implement Shift+Ctrl+C and V to copy and paste character and paragraph attributes.

I hope this helps,

var CopyAttrString, CopyParAttrString : String;

procedure TSomeForm.WPRichText1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
var s,e : TParagraph; sp, ep : Integer;
begin

   if (Key = Integer('C')) and (Shift = [ssshift , ssctrl]) then
  begin
    CopyAttrString := TWPCustomRTFEdit(Sender).TextCursor.CurrentCharAttr.AGetWPSS; 
    CopyParAttrString := TWPCustomRTFEdit(Sender).ActiveParagraph.AGetWPSS(false, false, true);
    Key := 0;
  end
  else if (Key = Integer('V')) and (Shift = [ssshift , ssctrl]) then
  begin
    TWPCustomRTFEdit(Sender).TextCursor.CurrAttribute.ASetWPSS( CopyAttrString );
    // modifies char attr only 
    TWPCustomRTFEdit(Sender).ActiveParagraph.ASetWPSS(CopyParAttrString);
    // loop selected or partly selected paragraphs
    s := TWPCustomRTFEdit(Sender).TextCursor.GetBlockStart(sp);
    e := TWPCustomRTFEdit(Sender).TextCursor.GetBlockEnd(ep);
    while (s<>nil) do
    begin
      s.ASetWPSS(CopyParAttrString);
      if s=e then break;
      s := s.next;
    end;
    Key := 0;
  end
#4 ♥ 0

I added the line
if (Key = Integer('V')) ...
Clipboard.AsText := '';

Thanks

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