You've already forked lazarus-ccr
richmemo: support for deflang and parameters group
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7291 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -82,6 +82,7 @@ type
|
|||||||
prm : TRTFParams;
|
prm : TRTFParams;
|
||||||
lang : Integer;
|
lang : Integer;
|
||||||
langproc : TEncConvProc;
|
langproc : TEncConvProc;
|
||||||
|
deflang : integer;
|
||||||
|
|
||||||
procedure AddText(const atext: string);
|
procedure AddText(const atext: string);
|
||||||
protected
|
protected
|
||||||
@@ -92,14 +93,18 @@ type
|
|||||||
procedure classEof;
|
procedure classEof;
|
||||||
procedure doChangePara(aminor, aparam: Integer);
|
procedure doChangePara(aminor, aparam: Integer);
|
||||||
|
|
||||||
|
procedure doDestination(aminor, aparam: Integer);
|
||||||
procedure doSpecialChar;
|
procedure doSpecialChar;
|
||||||
procedure doChangeCharAttr(aminor, aparam: Integer);
|
procedure doChangeCharAttr(aminor, aparam: Integer);
|
||||||
|
|
||||||
|
procedure SetLanguage(AlangCode: integer);
|
||||||
|
|
||||||
function DefaultTextColor: TColor;
|
function DefaultTextColor: TColor;
|
||||||
procedure PushText;
|
procedure PushText;
|
||||||
public
|
public
|
||||||
Memo : TCustomRichMemo;
|
Memo : TCustomRichMemo;
|
||||||
constructor Create(AMemo: TCustomRichMemo; AStream: TStream);
|
constructor Create(AMemo: TCustomRichMemo; AStream: TStream);
|
||||||
|
destructor Destroy; override;
|
||||||
procedure StartReading;
|
procedure StartReading;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -338,6 +343,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
//writeln('ctrl: ', rtfClass,' ', rtfMajor, ' ', Self.GetRtfText, ' ',rtfMinor,' ', rtfParam);
|
//writeln('ctrl: ', rtfClass,' ', rtfMajor, ' ', Self.GetRtfText, ' ',rtfMinor,' ', rtfParam);
|
||||||
case rtfMajor of
|
case rtfMajor of
|
||||||
|
rtfDestination: doDestination(rtfMinor, rtfParam);
|
||||||
rtfSpecialChar: doSpecialChar;
|
rtfSpecialChar: doSpecialChar;
|
||||||
rtfCharAttr: doChangeCharAttr(rtfMinor, rtfParam);
|
rtfCharAttr: doChangeCharAttr(rtfMinor, rtfParam);
|
||||||
rtfParAttr: doChangePara(rtfMinor, rtfParam);
|
rtfParAttr: doChangePara(rtfMinor, rtfParam);
|
||||||
@@ -350,20 +356,19 @@ var
|
|||||||
begin
|
begin
|
||||||
if not Assigned(prm) then exit;
|
if not Assigned(prm) then exit;
|
||||||
|
|
||||||
//todo:
|
|
||||||
Exit;
|
|
||||||
case rtfMajor of
|
case rtfMajor of
|
||||||
rtfBeginGroup: begin
|
rtfBeginGroup: begin
|
||||||
t:=TRTFParams.Create(prm);
|
t:=TRTFParams.Create(prm);
|
||||||
prm:=t;
|
prm:=t;
|
||||||
end;
|
end;
|
||||||
rtfEndGroup: begin
|
rtfEndGroup: begin
|
||||||
|
if Assigned(prm) then begin
|
||||||
t:=prm.prev;
|
t:=prm.prev;
|
||||||
prm.Free;
|
prm.Free;
|
||||||
prm:=t;
|
prm:=t;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
//writeln('group: ', rtfMajor, ' ',rtfMinor,' ', rtfParam, ' ', GetRtfText);
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TRTFMemoParser.classEof;
|
procedure TRTFMemoParser.classEof;
|
||||||
@@ -371,6 +376,14 @@ begin
|
|||||||
PushText;
|
PushText;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TRTFMemoParser.doDestination(aminor, aparam: Integer);
|
||||||
|
begin
|
||||||
|
case aminor of
|
||||||
|
rtfDefaultLanguage:
|
||||||
|
deflang:=aparam;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TRTFMemoParser.doChangePara(aminor, aparam: Integer);
|
procedure TRTFMemoParser.doChangePara(aminor, aparam: Integer);
|
||||||
begin
|
begin
|
||||||
case aminor of
|
case aminor of
|
||||||
@@ -394,9 +407,7 @@ begin
|
|||||||
// \slN - surprise! the "line spacing" is actually a multiplier based on the FONT size, not linesize
|
// \slN - surprise! the "line spacing" is actually a multiplier based on the FONT size, not linesize
|
||||||
// where linesize = fontsize * 1.2
|
// where linesize = fontsize * 1.2
|
||||||
rtfLanguage: begin
|
rtfLanguage: begin
|
||||||
lang:=rtfParam;
|
SetLanguage(rtfParam);
|
||||||
langproc:=nil;
|
|
||||||
LangConvGet(lang, langproc);
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@@ -414,7 +425,11 @@ begin
|
|||||||
case rtfMinor of
|
case rtfMinor of
|
||||||
rtfOptDest: SkipGroup;
|
rtfOptDest: SkipGroup;
|
||||||
rtfLine: AddText(CharLine);
|
rtfLine: AddText(CharLine);
|
||||||
rtfPar: AddText(CharPara);
|
rtfPar: begin
|
||||||
|
AddText(CharPara);
|
||||||
|
if deflang<>0 then
|
||||||
|
SetLanguage(deflang);
|
||||||
|
end;
|
||||||
rtfTab: AddText(CharTab);
|
rtfTab: AddText(CharTab);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@@ -479,6 +494,13 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TRTFMemoParser.SetLanguage(AlangCode: integer);
|
||||||
|
begin
|
||||||
|
lang:=AlangCode;
|
||||||
|
langproc:=nil;
|
||||||
|
LangConvGet(lang, langproc);
|
||||||
|
end;
|
||||||
|
|
||||||
function TRTFMemoParser.DefaultTextColor:TColor;
|
function TRTFMemoParser.DefaultTextColor:TColor;
|
||||||
begin
|
begin
|
||||||
Result:=ColorToRGB(Memo.Font.Color);
|
Result:=ColorToRGB(Memo.Font.Color);
|
||||||
@@ -523,8 +545,7 @@ begin
|
|||||||
|
|
||||||
// Memo.GetTextAttributes(selst, font);
|
// Memo.GetTextAttributes(selst, font);
|
||||||
pf:=Fonts[prm.fnum];
|
pf:=Fonts[prm.fnum];
|
||||||
if Assigned(pf) then
|
if Assigned(pf) then prm.fnt.Name:=pf^.rtfFName;
|
||||||
prm.fnt.Name:=pf^.rtfFName;
|
|
||||||
//prm.fnt.Size:=round(fsz);
|
//prm.fnt.Size:=round(fsz);
|
||||||
//prm.fnt.Style:=fst;
|
//prm.fnt.Style:=fst;
|
||||||
//prm.fnt.Color:=ColorToRGB(fColor);
|
//prm.fnt.Color:=ColorToRGB(fColor);
|
||||||
@@ -544,6 +565,19 @@ begin
|
|||||||
ClassCallBacks[rtfEof]:=@classEof;
|
ClassCallBacks[rtfEof]:=@classEof;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
destructor TRTFMemoParser.Destroy;
|
||||||
|
var
|
||||||
|
t: TRTFParams;
|
||||||
|
begin
|
||||||
|
// cleanup
|
||||||
|
while Assigned(prm) do begin
|
||||||
|
t:=prm;
|
||||||
|
prm:=prm.prev;
|
||||||
|
t.Free;
|
||||||
|
end;
|
||||||
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TRTFMemoParser.StartReading;
|
procedure TRTFMemoParser.StartReading;
|
||||||
var
|
var
|
||||||
t : TRTFParams;
|
t : TRTFParams;
|
||||||
|
Reference in New Issue
Block a user