How to set default ListStyle for documents?

General TRichView support forum. Please post your questions here
Post Reply
edwinyzh
Posts: 104
Joined: Sun Jun 05, 2022 2:22 pm

How to set default ListStyle for documents?

Post 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!
edwinyzh
Posts: 104
Joined: Sun Jun 05, 2022 2:22 pm

Re: How to set default ListStyle for documents?

Post by edwinyzh »

OK, I found TrvActionParaBullets.ListLevels, I guess that's what I need? :D
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: How to set default ListStyle for documents?

Post 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.
edwinyzh
Posts: 104
Joined: Sun Jun 05, 2022 2:22 pm

Re: How to set default ListStyle for documents?

Post 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...

Image

Thanks!
standay
Posts: 274
Joined: Fri Jun 18, 2021 3:07 pm

Re: How to set default ListStyle for documents?

Post 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;
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: How to set default ListStyle for documents?

Post 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;
edwinyzh
Posts: 104
Joined: Sun Jun 05, 2022 2:22 pm

Re: How to set default ListStyle for documents?

Post 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?
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: How to set default ListStyle for documents?

Post 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.
Post Reply