Sergey Tkachenko wrote: ↑Sun Aug 15, 2021 8:13 am
Did you include rvpiBackground_Color in rve.Style.StyleTemplates[0].ValidParaProperties?
Also, the result depends on selection and a kind of the paragraph style.
If Kind = rvstkText, this styletemplate is never applied to paragraph, its paragraph properties are ignored.
If Kind = rvstkParaText, results of ApplyStyleTemplate depends on selection. If a part of text inside a single paragraph is selected, it is applied to text, not paragraph.
If Kind = rvstkPara, ApplyStyleTemplate applies styletemplate to the paragraph.
I did not have the rvpiBackground_Color set. So I set that, and it sort of helps but I'm still having some issues.
First, if I do this:
Code: Select all
for i := 0 to rve.Style.StyleTemplates.Count-1 do
ShowMessage(rve.Style.StyleTemplates[i].Name + ' ' +
rve.Style.StyleTemplates[i].TextStyle.FontName);
in my app, I only get 1 style returned no matter how many I have added. If I put that in your StyleTemplates demo, it returns the list of templates as expected. I can find no obvious difference in settings between the rve or rvstyle in the demo app and mine.
Second, even in the demo app that does return data, for the demo app heading 1 template, rve.Style.StyleTemplates[ i ].TextStyle.FontName is always "Arial," and it should be "Courier New". I would expect rve.Style.StyleTemplates[ i ].TextStyle.FontName to return "Courier New" if that is set in the template. I did add rviFontName and rviColor to the valid text props.
In my app, to get this to work at all, I have to use this:
Code: Select all
rve.Style.StyleTemplates[0].ParaStyle.Background.Color := clMaroon;
rve.Style.StyleTemplates[0].TextStyle.Color := clWhite;
rve.Style.StyleTemplates[0].TextStyle.FontName := 'Courier New';
rve.ApplyStyleTemplate(0);
I would expect to not have to set all that again since it was all set that way in the design time settings. And in my app, the text never changes, only the paragraph background. In the demo app I had to add this into cmbStylesClick to get it to work:
Code: Select all
if cmbStyles.ItemIndex = 1 then
begin
rve.ApplyParaStyleConversion(PARA_COLOR);
FontName := 'Courier New'; //rvs.StyleTemplates[0].TextStyle.FontName;
FontColor := clWhite;
rve.ApplyStyleConversion( TEXT_APPLYFONTNAME );
rve.ApplyStyleConversion( TEXT_APPLYCOLOR );
end;
While that works in the demo app, I had to use ApplyStyleConversion which I prefer not to have to use, which was why I was trying the style templates. It looks like those should work on their own without all the ApplyStyleConversion code. I would expect this:
Code: Select all
rve.ApplyStyleTemplate(cmbStyles.ItemIndex);
alone to work (note that I changed the demo app heading 1 to have a paragraph color and courier new font, but those never seem to work).
Maybe you can tell me where I'm going wrong?