Hi
I want to do this: when the user creates a template (with fields in it),
they can select from a list of field, and I put the field italic+bold+underlined+overlined in the text.
When the user uses the template, the fields are filled in. This is the code
RVData.SetItemTexta(i, GetFieldValueFromDatabase(FieldName));
how can I remove the overline and underline from the value that will replace Fieldname?
Thanks
remove 1 or more font styles from the set of styles
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
not really
No
I cannot assign a style number, I do not know what style it will be.
The user may choose any style (i.e. bold, italic, underlined, overlined, and any size he likes).
I only want to do "whatever the user chooses, MINUS overline" for example. I want to take only overline off the styles, I do not know what's left.
I cannot assign a style number, I do not know what style it will be.
The user may choose any style (i.e. bold, italic, underlined, overlined, and any size he likes).
I only want to do "whatever the user chooses, MINUS overline" for example. I want to take only overline off the styles, I do not know what's left.
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Do I understand you right: you want, basing on the item text, change its font, for example making it not underlined?
The function below returns index of text style having all properties of RVStyle.TextStyles[BaseStyleNo], but with MinusStyles excluded from Style property
Using:
The function below returns index of text style having all properties of RVStyle.TextStyles[BaseStyleNo], but with MinusStyles excluded from Style property
Code: Select all
function GetStyleMinus(RVStyle: TRVStyle; BaseStyleNo: Integer;
MinusStyles: TFontStyles): Integer;
var ts: TFontInfo;
begin
ts := TFontInfo.Create(nil);
ts.Assign(RVStyle.TextStyles[BaseStyleNo]);
ts.Style := ts.Style-MinusStyles;
Result := RVStyle.TextStyles.FindSuchStyle(BaseStyleNo, ts,
RVAllFontInfoProperties);
if Result<0 then begin
RVStyle.TextStyles.Add;
Result := RVStyle.TextStyles.Count-1;
RVStyle.TextStyles[Result].Assign(ts);
RVStyle.TextStyles[Result].Standard := False;
end;
end;
Code: Select all
FieldValue := GetFieldValueFromDatabase(FieldName);
RVData.SetItemTexta(i, FieldValue);
if ShouldRemoveUnderline(FieldValue) then
RVData.GetItem(i).StyleNo := GetStyleMinus(RVData.GetRVStyle,
RVData.GetItemStyle(i), [fsUnderline]);
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
While the code in my previous reply still works, newer versions of TRichView allow to implement it simpler:
For paragraphs, it's the same. Instead of TFontInfo use TParaInfo, instead of FindTextStyle use FindParaStyle.
To "remove" all alignments, pass rvaLeft to the last parameter.
To change paragraph style as non-editing (i.e. not undoable) operation, assign the returned value to GetItem(I).ParaNo.
Important: all items in the same paragraph must have equal value of ParaNo! Paragraphs starts from items for which IsParaStart(I) return True.
Code: Select all
function GetStyleMinus(RVStyle: TRVStyle; BaseStyleNo: Integer;
MinusStyles: TFontStyles): Integer;
var ts: TFontInfo;
begin
ts := TFontInfo.Create(nil);
ts.Assign(RVStyle.TextStyles[BaseStyleNo]);
ts.Style := ts.Style-MinusStyles;
Result := RVStyle.FindTextStyle(ts);
end;
Code: Select all
function GetParaWithAlignment(RVStyle: TRVStyle; BaseParaNo: Integer;
Alignment: TRVAlignment): Integer;
var ps: TParaInfo;
begin
ps := TParaInfo.Create(nil);
ps.Assign(RVStyle.ParaStyles[BaseParaNo]);
ps.Alignment := Alignment;
Result := RVStyle.FindParaStyle(ps);
end;
To change paragraph style as non-editing (i.e. not undoable) operation, assign the returned value to GetItem(I).ParaNo.
Important: all items in the same paragraph must have equal value of ParaNo! Paragraphs starts from items for which IsParaStart(I) return True.