trichview.com

trichview.support




Re: Add styles from RVStyle


Return to index


Author

Message

Sergey Tkachenko

Posted: 09/22/2004 19:21:20


Do you need simple copying of styles?


for i := 0 to RVStyle1.TextStyles.Count-1 do

   RVStyle2.TextStyles.Add.Assign(RVStyle1.TextStyles[i]);

The same is for other collections.


If you use NextStyleNo, NextParaNo, BaseStyleNo, DefStyleNo properties, you

need to adjust references as well.


TRVStyle's collections have method MergeWith. (TCustomRVInfos.MergeWith from

RVStyle.pas)

It performs smart style merging (for example, with parameter

rvs_merge_SmartMerge it can add only new styles)

This method is not described in the help file, but has comments in the

source file:


{ Adds items from Styles according to the method specified in the Mode.

  Mapping is filled: on exit, Mapping.Count = Styles.Count, and

  Mapping[i] is an index of the item of this collection which was created

basing

  on Styles[i].

  Reference properties (BaseStyleNo, NextStyleNo, NextParaNo, DefStyleNo)

are

  adjusted in the added items.

  If the global variable RichViewResetStandardFlag is True (default),

Standard

  properties of all added styles are set to False.

  This method assumes that Styles have the same type as Self.

  Notes:

  * in rvs_merge_Map mode:

    - SimilarityValue method of items is used;

    - the method tries to keep Jump and Unicode properties if possible.

  * in rvs_merge_SmartMerge mode:

    - the method tries to map the style to the style with the same index,

      if possible;

    - IsSimpleEqualEx method of items is used;

    - several styles can be mapped in the same style, except for numbered

lists:

      they are always mapped to the unique style.

}

procedure TCustomRVInfos.MergeWith(Styles: TCustomRVInfos;

  Mode: TRVStyleMergeMode; Mapping: TRVIntegerList;

  TextStyleMapping: TRVIntegerList);


TRVIntegerList is like TList but stores integers instead of pointers.



>

> how to add text and para styles from one RVStyle1 to RVSTyle2

>

> I only want to append all styles defined in RVStyle1 to RVStyle2.

> Can you give me some piece of code how to do it?

>

> Cheers

>

>





Powered by ABC Amber Outlook Express Converter