Paragraph style and ApplyParaStyleConversion

General TRichView support forum. Please post your questions here
Post Reply
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Paragraph style and ApplyParaStyleConversion

Post by jgkoehn »

Greetings,
I'm working on a doing some quick format buttons for users and when I use ApplyParaStyleConversion from a demo
Specifically: RichViewEdit.ApplyParaStyleConversion(PARA_SPACE_DEFAULT); Note: GApplyStyle is set to rvs style before calling ApplyParaStyleCovnersion.

See the code below. Also see the attachment. I get a red border and multiline spacing, plus paragraph alignment, etc. when I'm just wanting to change spacing before and after the paragraph. Is it the combination of Actions and this?

Code: Select all

procedure TMainForm.rveParaStyleConversion(Sender: TCustomRichViewEdit; rvstyle: TRVStyle;
  StyleNo, UserData: Integer; AppliedToText: Boolean; var NewStyleNo: Integer);
var
  ParaInfo: TParaInfo;
begin

  ParaInfo := TParaInfo.Create(nil);
  try
    ParaInfo.Assign(GApplyStyle.ParaStyles[StyleNo]);
    case UserData of
      PARA_ALIGNMENT:
        ParaInfo.Alignment := GApplyStyle.ParaStyles[StyleNo].Alignment;
      PARA_INDENTINC:
        begin
          ParaInfo.LeftIndent := ParaInfo.LeftIndent + 20;
          if ParaInfo.LeftIndent > 200 then
            ParaInfo.LeftIndent := 200;
        end;
      PARA_INDENTDEC:
        begin
          ParaInfo.LeftIndent := ParaInfo.LeftIndent - 20;
          if ParaInfo.LeftIndent < 0 then
            ParaInfo.LeftIndent := 0;
      end;
      PARA_COLOR: ParaInfo.Background.Color := PParaColor;
      PARA_LINESPACE: ParaInfo.LineSpacing := PParaLineSpaceInt;
      PARA_SPACE_DEFAULT:
           begin
           ParaInfo.SpaceBefore:=0;
           ParaInfo.SpaceAfter:= 6;
       end;
      // add your code here....
    end;
    NewStyleNo := GApplyStyle.FindParaStyle(ParaInfo);
  finally
    ParaInfo.Free;
  end;
end; 
Attachments
test.rvf
(9.75 KiB) Downloaded 1007 times
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Paragraph style and ApplyParaStyleConversion

Post by Sergey Tkachenko »

Is this the exact code?
OnParaStyleConversion does not have rvstyle parameter.
The code looks correct, if GApplyStyle really equals to Sender.Style.
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: Paragraph style and ApplyParaStyleConversion

Post by jgkoehn »

Greetings Sergey,
It is the code, I will need to revisit the rvstyle I think I added that but apparently don't use. I will double check a few things. Thank you
Post Reply