{----------------------------------------------------------------------------- The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/MPL-1.1.html Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for the specific language governing rights and limitations under the License. The Original Code is: JvRichEditToHtml.PAS, released on 2001-02-28. The Initial Developer of the Original Code is Sébastien Buysse [sbuysse att buypin dott com] Portions created by Sébastien Buysse are Copyright (C) 2001 Sébastien Buysse. All Rights Reserved. Contributor(s): Michael Beck [mbeck att bigfoot dott com], Andreas Hausladen [Andreas dott Hausladen att gmx dott de]. You may retrieve the latest version of this file at the Project JEDI's JVCL home page, located at http://jvcl.sourceforge.net Known Issues: -----------------------------------------------------------------------------} // $Id: JvRichEditToHtml.pas 12015 2008-11-01 23:55:28Z ahuser $ unit JvRichEditToHtml2; {$I jvcl.inc} {$I windowsonly.inc} interface uses Windows, {$IFDEF UNITVERSIONING} JclUnitVersioning, {$ENDIF UNITVERSIONING} SysUtils, Classes, Graphics, Forms, ComCtrls, JvRgbToHtml, JvStrToHtml, JvRichEdit, JvComponentBase, JclStrings; type TJvParaAttributesRec = record Alignment: TAlignment; Numbering: TNumberingStyle; end; TJvRichEditParaAttributesRec = record Alignment: TParaAlignment; Numbering: TJvNumbering; end; TFontInfo = class(TPersistent) private FFontData: TFontData; FColor: TColor; FPixelsPerInch: Integer; FLink: Boolean; function GetSize: Integer; procedure SetSize(const Value: Integer); public constructor Create(APixelsPerInch: Integer); procedure Assign(Source: TPersistent); override; property Color: TColor read FColor write FColor; property Link: Boolean read FLink write FLink; property Size: Integer read GetSize write SetSize; property Height: Integer read FFontData.Height write FFontData.Height; property Pitch: TFontPitch read FFontData.Pitch write FFontData.Pitch; property Style: TFontStylesBase read FFontData.Style write FFontData.Style; property Charset: TFontCharset read FFontData.Charset write FFontData.Charset; property Name: TFontDataName read FFontData.Name write FFontData.Name; end; TJvRichEditToHtml = class(TJvComponent) private FCToH: TJvRgbToHtml; FCharToH: TJvStrToHtml; FEndSection: string; FEndPara: string; FTitle: string; FFooter: TStringList; FHeader: TStringList; FAttr: TStringList; // catch all AttToHtml calls to allow rebuilding into a css after conversion FCss: TStringList; // after the html has completed, this will contain css code function AttToHtml(Value: TFontInfo): string; function ParaToHtml(Value: TJvParaAttributesRec): string;overload; function ParaToHtml(Value: TJvRichEditParaAttributesRec): string;overload; function GetFooter: TStrings; function GetHeader: TStrings; procedure SetFooter(const Value: TStrings); procedure SetHeader(const Value: TStrings); function GetCss: TStrings; protected procedure AttrToCss(Strings: TStrings); virtual; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; procedure ConvertToHtml(Value: TRichEdit; const FileName: string);overload; procedure ConvertToHtml(Value: TJvRichEdit; const FileName: string);overload; procedure ConvertToHtmlStrings(Value: TRichEdit; Strings: TStrings);overload; procedure ConvertToHtmlStrings(Value: TJvRichEdit; Strings: TStrings);overload; published property Title: string read FTitle write FTitle; property Header: TStrings read GetHeader write SetHeader; property Footer: TStrings read GetFooter write SetFooter; property Css: TStrings read GetCss; end; {$IFDEF UNITVERSIONING} const UnitVersioning: TUnitVersionInfo = ( RCSfile: '$URL: https://jvcl.svn.sourceforge.net/svnroot/jvcl/branches/JVCL3_36_PREPARATION/run/JvRichEditToHtml.pas $'; Revision: '$Revision: 12015 $'; Date: '$Date: 2008-11-02 00:55:28 +0100 (dim., 02 nov. 2008) $'; LogPath: 'JVCL\run' ); {$ENDIF UNITVERSIONING} implementation {$IFNDEF COMPILER12_UP} uses JvJCLUtils; {$ENDIF ~COMPILER12_UP} const // (rom) needs renaming? // cHTMLHeadBegin = ''; // cHTMLBodyBegin = '
'; // cHTMLBodyEnd = ''; // cHTMLEnd = ''; // cHTMLTitleFmt = '