richmemo: adding support for super and sub script into manually loading RTF. patch by Vladimir Rybant. (source: 783938acdd)

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7283 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
skalogryz
2020-01-13 15:39:38 +00:00
parent 274ebf2d71
commit d1956180b1
2 changed files with 26 additions and 1 deletions

View File

@ -451,6 +451,11 @@ begin
rtfFontSize: prm.fnt.Size:=round(aparam/2);
rtfUnderline: if aparam=0 then Exclude(prm.fnt.Style,fsUnderline) else Include(prm.fnt.Style, fsUnderline);
rtfNoUnderline: Exclude(prm.fnt.Style, fsUnderline);
rtfSuperScript: prm.fnt.VScriptPos:=vpSuperscript;
rtfSubScript : prm.fnt.VScriptPos:=vpSubScript;
rtfNoSuperSub : prm.fnt.VScriptPos:=vpNormal;
rtfHighlight: begin
prm.fnt.HasBkClr := (aparam>0) and (aparam<=high(HColor));
if prm.fnt.HasBkClr then begin
@ -720,6 +725,7 @@ var
isbold : Boolean;
isitalic : Boolean;
isuline : Boolean;
issupersub: Boolean;
isColor : integer;
pm : TParaMetric;
@ -796,6 +802,7 @@ begin
rng:=root;
isbold:=false;
isitalic:=false;
issupersub:=false;
iscolor:=0;
while Assigned(rng) do begin
u:=ARich.GetUText(rng.textStart, rng.textLength);
@ -826,6 +833,20 @@ begin
if isitalic then RtfOut('\i0');
isitalic:=false;
end;
if rng.font.VScriptPos=vpSuperScript then begin
RtfOut('\super');
issupersub:=true;
end;
if rng.font.VScriptPos=vpSubScript then begin
RtfOut('\sub');
issupersub:=true;
end;
if rng.font.VScriptPos=vpNormal then begin
if issupersub then RtfOut('\nosupersub');
issupersub:=false;
end;
RtfOut(' ');
i:=1;

View File

@ -335,6 +335,7 @@ const
rtfBackColor = 21;
rtfGray = 22;
rtfHighlight = 23;
rtfNoSuperSub = 24;
rtfPictAttr = 13;
rtfMacQD = 0;
@ -469,7 +470,7 @@ type
---------------------------------------------------------------------}
const
rtfKey : Array [0..284] of TRTFKey =
rtfKey : Array [0..287] of TRTFKey =
(
( rtfKMajor: RTFSPECIALCHAR; rtfKMinor : rtfCURHEADPICT; rtfKStr : 'chpict'; rtfKhash : 0),
( rtfKMajor: rtfSpecialChar; rtfKMinor: rtfCurHeadDate; rtfKstr : 'chdate'; rtfkHash : 0),
@ -529,6 +530,9 @@ const
( rtfKMajor: rtfCharAttr; rtfKMinor: rtfNoUnderline; rtfKstr : 'ulnone'; rtfkHash : 0),
( rtfKMajor: rtfCharAttr; rtfKMinor: rtfSuperScript; rtfKstr : 'up'; rtfkHash : 0),
( rtfKMajor: rtfCharAttr; rtfKMinor: rtfSubScript; rtfKstr : 'dn'; rtfkHash : 0),
( rtfKMajor: rtfCharAttr; rtfKMinor: rtfSuperScript; rtfKstr : 'super'; rtfkHash : 0),
( rtfKMajor: rtfCharAttr; rtfKMinor: rtfSubScript; rtfKstr : 'sub'; rtfkHash : 0),
( rtfKMajor: rtfCharAttr; rtfKMinor: rtfNoSuperSub; rtfKstr : 'nosupersub'; rtfkHash : 0),
( rtfKMajor: rtfCharAttr; rtfKMinor: rtfRevised; rtfKstr : 'revised'; rtfkHash : 0),
( rtfKMajor: rtfCharAttr; rtfKMinor: rtfForeColor; rtfKstr : 'cf'; rtfkHash : 0),
( rtfKMajor: rtfCharAttr; rtfKMinor: rtfBackColor; rtfKstr : 'cb'; rtfkHash : 0),