Page 1 of 1
Change line spacing in Runtime
Posted: Sat Jan 09, 2021 8:05 pm
by Ceprotec
[Português]
Como alterar as duas opções marcadas a baixo em tempo de execução?
Obrigado!
[English]
Hi Sergey,
How to change the two options marked below at run time?
Thanks!
Re: Change line spacing in Runtime
Posted: Sat Jan 09, 2021 8:23 pm
by Sergey Tkachenko
Do you want to change it for the selected paragraphs?
If you use RichViewActions, the simplest way is using TrvActionParagraph without a dialog.
For example, to apply double line spacing:
Code: Select all
rvActionParagraph1.UserInterface := False;
rvActionParagraph1.LineSpacingType := rvlsPercent;
rvActionParagraph1.LineSpacing := 200;
rvActionParagraph1.ValidProperties := [rvpimLineSpacing];
rvActionParagraph1.ExecuteTarget(RichViewEdit1);
rvActionParagraph1.UserInterface := True;
Without RichViewActions, use ApplyParaStyleConversion method + OnParaStyleConversion event, like it is shown in TRichView demo Editors\Editor2\
You need to return the index of paragraph style having the proper values of LineSpacing and LineSpacingType properties.
Re: Change line spacing in Runtime
Posted: Mon Jan 11, 2021 12:45 pm
by Ceprotec
[Portugues]
Funcionou apenas para o parágrafo selecionado.
Como faço para alterar o todo o texto?
[English]
It only worked for the selected paragraph.
How do I change all the text?
Re: Change line spacing in Runtime
Posted: Tue Jan 12, 2021 11:10 am
by Sergey Tkachenko
If you want to make it as an editing operation, select the whole text (call RichViewEdit1.SelectAll), then call the code above.
If you want to make it as a fast not undoable operation, call:
(assuming that RichViewEdit1.Style = RVStyle1)
Code: Select all
RichViewEdit1.ClearUndo;
RichViewEdit1.DeleteUnusedStyles(True, True, True);
for i := 0 to RVStyle1.ParaStyles.Count - 1 do
begin
RVStyle1.ParaStyles[i]LineSpacingType := rvlsPercent;
RVStyle1.ParaStyles[i]LineSpacing := 200;
end;
RichViewEdit1.Format;
This code works for TRichView as well, just remove the call of ClearUndo. The call of DeleteUnusedStyles is optional.
If you need to create a new document with specific line spacing, just create items in RVStyle1.ParaStyles with the proper properties, and use their indexes when calling Add methods (like AddNL or AddPicture).