Page 1 of 1
How to set default ListStyle for documents?
Posted: Mon Jun 27, 2022 11:02 am
by edwinyzh
So I noticed the first character of a bullet/numbering item is too close to the bullet/number and I want to increase the indent.
I know the end user can use the "Bullet and Numbering" action to set indent for each level for an individual list item, but it's not clear to me as to how to achieve the following:
- To have a TRvStyle.ListStyle[0] as the default ListStyle for an editor, so that whenever a user created a nested list, this ListStyle will be used.
- And, the Styles window shown by`TrvActionStyleTemplates` should include this style and let the end user to edit it and affect all list items for the entire document.
Thanks!
Re: How to set default ListStyle for documents?
Posted: Mon Jun 27, 2022 11:12 am
by edwinyzh
OK, I found TrvActionParaBullets.ListLevels, I guess that's what I need?
Re: How to set default ListStyle for documents?
Posted: Mon Jun 27, 2022 12:36 pm
by Sergey Tkachenko
Yes, this is what you need.
Please note that TrvActionParaList updates TrvActionParaBullets.ListLevel after applying bulleted lists.
If you do not want it, assign rvActionParaList.UpdateAllActionsOnForm := False.
Re: How to set default ListStyle for documents?
Posted: Mon Jun 27, 2022 2:28 pm
by edwinyzh
Ok, tried setting the FirstIndent property of all levels, like following, it doesn't work - the first character is still too close to the bullet...
question 2 - How can I use point instead of px as the unit here? In other places, I've set them to use points instead already, not sure why here it's not pt but px...
Thanks!
Re: How to set default ListStyle for documents?
Posted: Mon Jun 27, 2022 3:02 pm
by standay
I ran into a lot of this too. I don't think I ever really got it right, but I made it work for what I needed. I'll put some sample code below. It may not do just what you are after, but it gives you an idea of what parameters you'll need to address. Setting only the FirstIndent probably will not do what you want it to (that was what I tried first as well!). This code runs in the rveParaStyleConversion procedure of my rve:
Code: Select all
for i := FStart to FEnd do
begin
if Sender.GetListMarkerInfo(i, ListNo, Level, StartFrom, Reset) > -1 then
begin
if Level > Sender.Style.ListStyles[ListNo].Levels.Count-1 then
Level := Sender.Style.ListStyles[ListNo].Levels.Count-1;
Sender.Style.ListStyles[ListNo].Levels[Level].Font.Size := Sender.Style.TextStyles[0].Size;
Sender.Style.ListStyles[ListNo].Levels[Level].MarkerIndent := ParaInfo.LeftIndent;
Sender.Style.ListStyles[ListNo].Levels[Level].LeftIndent := 24 + Sender.Style.ListStyles[ListNo].Levels[Level].MarkerIndent;//ParaInfo.LeftIndent;
Sender.Style.ListStyles[ListNo].Levels[Level].FirstIndent := 0;
end;
end;
Re: How to set default ListStyle for documents?
Posted: Mon Jun 27, 2022 3:50 pm
by Sergey Tkachenko
Please make sure that you understand LeftIndent, FirstIndent, MarkerIndent of list levels correctly:
https://www.trichview.com/help/idh_trvl ... ndent.html
About the units of measure for actions.
All such RichViewActions properties are measured in RVAControlPanel.UnitsProgram.
By default they are pixels, but can be changed to twips (1/20 of a point) or EMU (even a smaller unit).
See:
https://www.trichview.com/help/units_of ... ement.html
If you want to change units of measure at designtime, I highly recommend to assign the action's ControlPanel property explicitly, to make sure that the proper ControlPanel is used at designtime.
But please note that if you change RVAControlPanel.UnitsProgram at designtime, you will need to update nonzero values of ALL length properties of ALL actions manually (convert them from pixels to new units), so I do not recommend to do it.
It's better to leave values in pixels by default, and convert them to another units at runtime, if necessary.
For example, in ActionTest demos, by default a unit for display is pixel, and UnitsProgram is pixel as well. If you change units for display to another value (mm, cm, points, etc.), RichViewActions convert UnitsProgram to EMU:
Code: Select all
RVA_ConvertToEMU(Self, RVStyle1);
RVAControlPanel1.UnitsProgram := rvstuEMU;
Re: How to set default ListStyle for documents?
Posted: Tue Jun 28, 2022 7:18 am
by edwinyzh
Thank you Standay and Sergey, now I achieved almost perfect list item indentations
@Sergey,
Just to confirm, TrvActionParaBullets won't read ListStyle[0] from TRichViewEdit.Style and apply to itself, right?
Re: How to set default ListStyle for documents?
Posted: Tue Jun 28, 2022 10:43 am
by Sergey Tkachenko
No, TrvActionParaBullets is not updated from TRichViewEdit.Style.
When executed, TrvActionParaBullets creates a new list in TRichViewEdit.Style (or re-use an existing list, if there is already a list with properties like in TrvActionParaBullets.ListLevels).
TrvActionParaBullets.ListLevels can only be changed by TrvActionParaList.