rvico TRichView Reference | Classes

TRVDeleteUnusedStylesData

Top  Previous  Next

This class allows to delete unused text, paragraph and list styles in multiple documents (to delete styles that do not present in at least one of the documents)

Unit RVItem.

Syntax

TRVDeleteUnusedStylesData = class;

(introduced in version 10)

The only method of this class you need to use is the constructor:

constructor Create(ATextStyles, AParaStyles, AListStyles: Boolean);

Its parameters specify types of unused styles you want to delete.

 

The examples below assume that collections of text, paragraph and list styles are not saved in RVF documents (but stored in file or in the Registry). In this case, several documents share the same collections of styles. TCustomRichView.DeleteUnusedStyles cannot be used in this case, MarkStylesInUse and DeleteMarkedStyles must be used instead.

Note: usually it's much more simple (and recommended) to use one RVStyle per one RichView and store collections of styles inside RVF documents.

Example 1

How to remove unused styles in RichView1 and RichView2, linked to the same RVStyle.

uses RVItem;

 

  data := TRVDeleteUnusedStylesData.Create(True, True, True);

  RichView1.MarkStylesInUse(data);

  RichView2.MarkStylesInUse(data);

  RichView1.DeleteMarkedStyles(data);

  RichView2.DeleteMarkedStyles(data);

  data.Free;

Example 2

How to remove unused styles in several documents.

uses CRVData, RVItem;

 

  data := TRVDeleteUnusedStylesData.Create(True, True, True);

  RichView1.LoadRVF('Doc1.rvf');

  RichView1.MarkStylesInUse(data);

  RichView1.LoadRVF('Doc2.rvf');

  RichView1.MarkStylesInUse(data);

  ...

  RichViewDoNotCheckRVFStyleRefs := True;

  RichView1.LoadRVF('Doc1.rvf');

  RichView1.DeleteMarkedStyles(data);

  RichView1.SaveRVF('Doc1.rvf', False);

  RichView1.LoadRVF('Doc2.rvf');

  RichView1.DeleteMarkedStyles(data);

  RichView1.SaveRVF('Doc2.rvf', False);

  ...

  RichViewDoNotCheckRVFStyleRefs := False;

  data.Free;

 


TRichView © trichview.com