"Assign" contents of one TRVStyle to another.

General TRichView support forum. Please post your questions here
Post Reply
DickBryant
Posts: 148
Joined: Wed Dec 07, 2005 2:02 pm
Contact:

"Assign" contents of one TRVStyle to another.

Post by DickBryant »

I'm using a single TRVStyle for almost all of my instances of TRichViewEdit. However, I have one TRichViewEdit where I want to set all font sizes to a single size, independent of what they are in the document originally loaded into the rve WITHOUT changing these styles in the original TRVStyle.

My approach is to use a second TRVStyle and set it's contents to the main TRVStyle and then change the size of all its styles. I can't figure out how to make the contents of the second TRVStyle equal those of the first. Seems like it should be simple, but I can't find a way to do it.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

If you need to assign styles, it's simple:

Code: Select all

RVStyle2.TextStyles := RVStyle1.TextStyles;
RVStyle2.ParaStyles := RVStyle1.ParaStyles;
RVStyle2.ListStyles := RVStyle1.ListStyles;
DickBryant
Posts: 148
Joined: Wed Dec 07, 2005 2:02 pm
Contact:

Post by DickBryant »

Thanks, Sergey - tried

RVStyle2 := RVStyle1

but that DOESN'T work...

Now if you could answer

"Set Table Position To Actual Paper Location"

I promise I'll leave you alone for a (little) while :-)
shmp
Posts: 140
Joined: Sun Aug 28, 2005 10:19 am
Location: Sabah, Malaysia.
Contact:

Post by shmp »

I cannot understand why it doesn't work :shock:
I have been using TRVStyle1 := TRVStyle2 for ages.

Most probably you did not reformat rve.

Chao.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

"RVStyle2 := RVStyle1" simply assigns both RVStyle1 and RVStyle2 variables to the same TRVStyle object. Objects themselves remain unchanged.

As for my code

Code: Select all

RVStyle2.TextStyles := RVStyle1.TextStyles; 
RVStyle2.ParaStyles := RVStyle1.ParaStyles; 
RVStyle2.ListStyles := RVStyle1.ListStyles;
it actually produces the same actions as this code:

Code: Select all

RVStyle2.TextStyles.Assign(RVStyle1.TextStyles); 
RVStyle2.ParaStyles.Assign(RVStyle1.ParaStyles); 
RVStyle2.ListStyles.Assign(RVStyle1.ListStyles);
If you need to copy not only collections of styles, but also all other properties, use this code:

Code: Select all

Stream := TMemoryStream.Create;
Stream.WriteComponent(RVStyle1);
Stream.Position := 0;
Stream.ReadComponent(RVStyle2);
Stream.Free;
Post Reply