Page 1 of 1

"Assign" contents of one TRVStyle to another.

Posted: Fri Sep 01, 2006 4:49 pm
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.

Posted: Sat Sep 02, 2006 11:59 am
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;

Posted: Sun Sep 03, 2006 4:08 pm
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 :-)

Posted: Mon Sep 04, 2006 1:07 am
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.

Posted: Mon Sep 04, 2006 1:11 pm
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;