unit frmRoate3DText;

interface

uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls, 
  Buttons, ExtCtrls, BigStringContainer, Spin, StrUtils, uCommon;

type
  TFormRotate3DText = class(TForm)
    OKBtn: TButton;
    CancelBtn: TButton;
    EdtText: TEdit;
    Label1: TLabel;
    SC: TBigStringContainer;
    SEdtLeft: TSpinEdit;
    SEdtTop: TSpinEdit;
    SEdtInterval: TSpinEdit;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
  private
    { Private declarations }
  public
    { Public declarations }
    function GetHTML: string;
  end;

  function GetPlugInHTML(AHandle: THandle;ASelectedText: PChar;
                   AResultHTHML: TResultHTML): Boolean;stdcall;
  procedure GetPlugInName(AValue: PChar);stdcall;
  procedure GetPlugInDescription(AValue: PChar);stdcall;

var
  FormRotate3DText: TFormRotate3DText;

implementation

{$R *.dfm}

{ TFormRotate3DText }
//注意javascript中未中断字符问题
function TFormRotate3DText.GetHTML: string;
var
  t: string;
begin
  t := SC.GetString;
  t := AnsiReplaceStr(t, '<!insert word here>', EdtText.Text);
  t := AnsiReplaceStr(t, '<!top>', SEdtTop.Text);
  t := AnsiReplaceStr(t, '<!left>', SEdtLeft.Text);
  t := AnsiReplaceStr(t, '<!interval>', SEdtInterval.Text);
  result := t;
end;

function GetPlugInHTML(AHandle: THandle;ASelectedText: PChar;
                   AResultHTHML: TResultHTML): Boolean;stdcall;
var
  Dlg: TFormRotate3DText;
begin
  result := false;
  AResultHTHML.ReplaceHTML[0] := #0;
  AResultHTHML.BodyHTML[0] := #0;
  AResultHTHML.BodyTagHTML[0] := #0;
  AResultHTHML.HeadHTML[0] := #0;
  if ASelectedText <> nil then
    StrLCopy(AResultHTHML.ReplaceHTML, ASelectedText, MAXHTMLSIZE);
  Dlg := TFormRotate3DText.Create(nil);
  Dlg.ParentWindow := AHandle;
  if Dlg.ShowModal = mrOK then
  begin
    result := true;
    FillMemory(AResultHTHML.BodyHTML, MAXHTMLSIZE, 0);
    StrLCopy(AResultHTHML.BodyHTML, PChar(Dlg.GetHTML), MAXHTMLSIZE);
  end;
end;

procedure GetPlugInName(AValue: PChar);stdcall;
begin
  FillMemory(AValue, MAXNAMEDESCSIZE, 0);
  StrLCopy(AValue, PChar('添加旋转立体字'), MAXNAMEDESCSIZE);
end;

procedure GetPlugInDescription(AValue: PChar);stdcall;
begin
  FillMemory(AValue, MAXNAMEDESCSIZE, 0);
  StrLCopy(AValue, PChar('本插件将为您选择的文字添加旋转立体字'),MAXNAMEDESCSIZE);
end;

end.
