RVItem.pas
上传用户:daoqigc
上传日期:2021-04-20
资源大小:2795k
文件大小:179k
- {*******************************************************}
- { }
- { RichView }
- { Basic item types. }
- { }
- { Copyright (c) Sergey Tkachenko }
- { svt@trichview.com }
- { http://www.trichview.com }
- { }
- {*******************************************************}
- unit RVItem;
- interface
- {$I RV_Defs.inc}
- uses SysUtils, Classes, Windows, Graphics, Controls, Forms,
- CommCtrl,
- {$IFNDEF RVDONOTUSEJPEGIMAGE}
- Jpeg,
- {$ENDIF}
- {$IFDEF RICHVIEWDEF4}
- ImgList,
- {$ENDIF}
- {$IFNDEF RVDONOTUSELIVESPELL}
- RVWordPaint,
- {$ENDIF}
- RVClasses, RVFuncs, RVScroll, RVStyle, DLines;
- type
- { Exception class }
- ERichViewError = class(Exception);
- { Options for RichViewItems }
- TRVItemOption = (
- rvioSameAsPrev, // item is not a first item on the paragraph [section]
- rvioPageBreakBefore, // item starts a page (rvioSameAsPrev must be excluded)
- rvioBR, // item starts a paragraph section, but not a paragraph
- // (rvioSameAsPrev must be excluded)
- rvioUnicode, // this is an Unicode text item
- rvioGroupWithNext); // item is grouped with next item
- TRVItemOptions = set of TRVItemOption;
- TRVItemState = (
- rvisSpellChecked); // this item is completely spell-checked (live spell)
- TRVItemStates = set of TRVItemState;
- { Item drawing states. Used in item.Paint() }
- TRVItemDrawState = (
- rvidsSelected, // the item is selected
- rvidsCurrent, // the item is current (active) - at the caret position
- rvidsHover, // the item is a hypertext item under the mouse pointer
- rvidsPrinting, // this is not drawing but printing (or previewing)
- rvidsPreview, // this is drawing for print preview
- rvidsPreviewCorrection, // this is drawing for print preview with preview
- // correction
- rvidsControlFocused, // RichView has input focus
- rvidsCanUseCustomPPI,// rvflCanUseCustomPPI is in RVData.Flags
- rvidsRTL, // Current paragraph is RTL
- rvidsShowSpecialCharacters); // rvoShowSpecialCharacters in RVData.Options
- TRVItemDrawStates = set of TRVItemDrawState;
- { RVF reading: reading mode }
- TRVFReadMode = (
- rmText, // reading ANSI text
- rmBeforeBinary, // reading line break after ANSI text before binary data
- rmBinary, // reading binary data
- rmBeforeUnicode, // reading line break after ANSI text before Unicode text
- rmUnicode, // reading Unicode text
- rmAfterUnicode); // reading line break after Unicode text before ANSI text
- { RVF reading: reading state }
- TRVFReadState = (
- rstHeader, // reading item header
- rstData, // reading item data lines
- rstSkip); // skipping unknown lines
- { Identifiers of item boolean properties, for item.GetBoolValue() }
- TRVItemBoolProperty = (
- rvbpFullWidth, // full line item (such as "break" or table) [y/n?]
- rvbpValid, // the item is valid (has correct data)
- rvbpRequiresRVFLines, // the item has one or more data lines in RVF
- rvbpDisplayActiveState, // the item shows its active state (at the position
- // of caret)
- rvbpDrawingChangesFont, // drawing of item may change Canvas.Font
- rvbpCanSaveUnicode, // the item can represent itself in Unicode
- // (item.AsText() returns a "raw" Unicode, if Unicode
- // parameter is True), so RichView does not need
- // to convert the result of item.AsText() to Unicode
- rvbpAlwaysInText, // the item must be saved in text, event when saving
- // the selection
- rvbpImmediateControlOwner, // this item directly owns a VCL control
- rvbpResizable, // the item can be resized by mouse (RichViewEdit
- // must create a resizer for it, if this item is selected)
- rvbpResizeHandlesOutside, // resize handles must be drawn not inside, but
- // outside of item rectangle
- rvbpHasSubRVData, // item has subdocuments
- rvbpClickSelect, // item is selected on single click (resizable items
- // are always selected on single click)
- rvbpNoHTML_P, // this item cannot be nested in HTML's <p>...</p>
- // (<div>...</div> must be used)
- rvbpSwitchToAssStyleNo); // when this item is current, editor must set
- // current text style to the value of AssociatedTextStyleNo
- // (if it's >=0)
- { Identifiers of item boolean properties, for item.GetBoolValueEx() }
- TRVItemBoolPropertyEx = (
- rvbpPrintToBMP, // item.PrintToBitmap() must be used instead of item.Print()
- rvbpJump, // this is a hypertext item
- rvbpAllowsFocus, // this item can have input focus
- rvbpHotColdJump, // this hypertext item can be highlighted under
- // the mouse pointer
- rvbpXORFocus, // RichView must draw XOR dotted frame, if this item
- // has input focus
- rvbpActualPrintSize // item.OnDocWidthChange() returns item size in printer
- // (not screen) resolution
- );
- { From there the caret enters into the item, for method EnterItem() }
- TRVEnterDirection = (rvedLeft, rvedRight, rvedTop, rvedBottom);
- { Extra item integer properties }
- TRVExtraItemProperty = (
- rvepUnknown, // (none)
- rvepVShift, // vertical offset, in pixels or %
- rvepVShiftAbs, // if <>0, vertical offset is in pixels
- rvepImageWidth, // image width (for stretching)
- rvepImageHeight, // image height (for stretching)
- rvepTransparent, // bitmap image is transparent, see TBitmap.Transparent
- rvepTransparentMode, // see TBitmep.TransparentMode
- rvepTransparentColor,// see TBitmap.TransparentColor
- rvepMinHeightOnPage, // if <>0, the item can be splitted between pages
- // if the rest of page > this value; such items
- // are always printed from the new line
- rvepSpacing, // spacing around the item
- rvepResizable, // this item (control) is resizable
- rvepDeleteProtect, // this item cannot be deleted by editing operations
- rvepNoHTMLImageSize, // if<>0, image size is not saved in HTML,
- // even if rvsoImageSizes is included in Options
- // for SaveHTML
- // (this option is ignored if rvepImageWidth or Height
- // are non-zero
- rvepAnimationInterval, // for bitmap image items. If nonzero and
- // imagewidth and/or imageheight are defined,
- // plaing bitmap animation (in imagewidth x imageheight)
- // frame
- rvepVisible); // for controls: replacement of TControl.Visible property
- TRVExtraItemStrProperty = (
- rvespUnknown, // (none)
- rvespHint, // hint
- rvespAlt, // text representation of images
- rvespImageFileName); // image file name
- { Type of style changing operation }
- TRVEStyleConversionType = (
- rvscParaStyle, // ApplyParaStyle
- rvscTextStyle, // ApplyTextStyle
- rvscParaStyleConversion, // ApplyParaStyleConversion
- rvscTextStyleConversion, // ApplyStyleConversion
- rvscParaStyleTemplate, // ApplyParaStyleTemplate
- rvscTextStyleTemplate); // ApplyTextStyleTemplate
- { ----------------------------------------------------------------------------
- TRVMultiDrawItemPart: ancestor class of items in
- TRVMultiDrawItemInfo.PartsList.
- Inherited classes:
- - TRVImagePrintPart (for TRVMultiImagePrintInfo.PartsList);
- - TRVTablePrintPart (for TRVTablePrintInfo.PartsList).
- }
- TRVMultiDrawItemPart = class
- public
- Height: Integer;
- function GetSoftPageBreakInfo: Integer; dynamic;
- end;
- TRVDeleteUnusedStylesData = class
- private
- FInitialized, FConvertedToShifts: Boolean;
- FUsedTextStyles, FUsedParaStyles, FUsedListStyles: TRVIntegerList;
- FTextStyles, FParaStyles, FListStyles: Boolean;
- public
- constructor Create(ATextStyles, AParaStyles, AListStyles: Boolean);
- destructor Destroy; override;
- procedure Init(RVStyle: TRVStyle);
- procedure ConvertFlagsToShifts(RVStyle: TRVStyle);
- property UsedTextStyles: TRVIntegerList read FUsedTextStyles;
- property UsedParaStyles: TRVIntegerList read FUsedParaStyles;
- property UsedListStyles: TRVIntegerList read FUsedListStyles;
- property TextStyles: Boolean read FTextStyles;
- property ParaStyles: Boolean read FParaStyles;
- property ListStyles: Boolean read FListStyles;
- property ConvertedToShifts: Boolean read FConvertedToShifts;
- end;
- {------------------------------------------------------------------------------}
- TRVCPInfo = class;
- TCustomRVItemInfo = class;
- TRVCPInfo = class
- public
- Name: String;
- Next, Prev: TRVCPInfo;
- RaiseEvent, Persistent: Boolean;
- ItemInfo : TCustomRVItemInfo;
- ItemNo: Integer; // <- not maintained automatically
- Tag: Integer;
- procedure Assign(Source: TRVCPInfo; TagsArePChars: Boolean);
- function CreateCopy(TagsArePChars: Boolean): TRVCPInfo;
- end;
- {------------------------------------------------------------------------------}
- TRVSubRVDataPos = (rvdFirst, rvdLast, rvdChosenUp, rvdChosenDown, rvdNext, rvdPrev);
- TRVStoreSubRVData = class
- function Duplicate: TRVStoreSubRVData; dynamic;
- function Compare(StoreSub: TRVStoreSubRVData): Integer; dynamic;
- end;
- {------------------------------------------------------------------------------}
- TCustomRVItemInfo = class (TPersistent)
- private
- function GetSameAsPrev: Boolean;
- procedure SetSameAsPrev(const Value: Boolean);
- function GetBR: Boolean;
- procedure SetBR(Value: Boolean);
- function GetPageBreakBefore: Boolean;
- procedure SetPageBreakBefore(const Value: Boolean);
- protected
- function SaveRVFHeaderTail(RVData: TPersistent): String; dynamic;
- function GetRVFExtraPropertyCount: Integer; dynamic;
- procedure SaveRVFExtraProperties(Stream: TStream); dynamic;
- procedure SetExtraPropertyFromRVFStr(const Str: String);
- function GetAssociatedTextStyleNo: Integer; virtual;
- procedure SetAssociatedTextStyleNo(Value: Integer); virtual;
- public
- StyleNo,ParaNo: Integer;
- ItemOptions: TRVItemOptions;
- {$IFNDEF RVDONOTUSELIVESPELL}
- ItemState: TRVItemStates;
- WordPaintList: TRVWordPainterList;
- {$ENDIF}
- Checkpoint: TRVCPInfo;
- JumpID: Integer;
- Tag: Integer;
- DrawItemNo: Integer;
- {$IFNDEF RVDONOTUSEITEMHINTS}
- Hint: String;
- {$ENDIF}
- constructor Create(RVData: TPersistent); virtual;
- {$IFNDEF RVDONOTUSELIVESPELL}
- destructor Destroy; override;
- procedure ClearLiveSpellingResult;
- procedure ClearWordPainters(Index: Integer);
- function AdjustWordPaintersOnInsert(Index: Integer; ch: Char; RVData: TPersistent): Boolean;
- function AdjustWordPaintersOnDelete(Index, Count: Integer): Boolean;
- function GetMisspelling(Offs: Integer; var MisOffs, MisLength: Integer): Boolean;
- procedure AddMisspelling(StartOffs, Length: Integer);
- function IsMisspelled(Index: Integer): Boolean;
- function ValidateMisspelledWord(const AItemText, AWord: String): Boolean;
- {$ENDIF}
- procedure Assign(Source: TCustomRVItemInfo); {$IFDEF RICHVIEWDEF4} reintroduce; {$ENDIF} dynamic;
- procedure TransferProperties(Source: TCustomRVItemInfo; RVData: TPersistent); dynamic;
- function GetSubRVDataAt(X,Y: Integer): TPersistent; dynamic;
- function GetMinWidth(sad: PRVScreenAndDevice; Canvas: TCanvas;
- RVData: TPersistent): Integer; virtual;
- function OwnsControl(AControl: TControl): Boolean; dynamic;
- function OwnsInplaceEditor(AEditor: TControl): Boolean; dynamic;
- function CanBeBorderStart: Boolean;
- function ParaStart(CountBR: Boolean): Boolean;
- property SameAsPrev: Boolean read GetSameAsPrev write SetSameAsPrev;
- function AsImage: TGraphic; virtual;
- {$IFNDEF RVDONOTUSEHTML}
- procedure SaveToHTML(Stream: TStream; RVData: TPersistent;
- ItemNo: Integer; const Text, Path: String;
- const imgSavePrefix: String; var imgSaveNo: Integer;
- CurrentFileColor: TColor; SaveOptions: TRVSaveOptions;
- UseCSS: Boolean; Bullets: TRVList); dynamic;
- {$ENDIF}
- function AsText(LineWidth: Integer; RVData: TPersistent;
- const Text, Path: String; TextOnly,Unicode: Boolean): String; dynamic;
- procedure UpdatePaletteInfo(PaletteAction: TRVPaletteAction;
- ForceRecreateCopy: Boolean; Palette: HPALETTE;
- LogPalette: PLogPalette); dynamic;
- function ReadRVFHeader(var P: PChar; RVData: TPersistent): Boolean; dynamic;
- function GetBoolValue(Prop: TRVItemBoolProperty): Boolean; virtual;
- function GetBoolValueEx(Prop: TRVItemBoolPropertyEx;
- RVStyle: TRVStyle): Boolean; virtual;
- function ReadRVFLine(const s: String; RVData: TPersistent;
- ReadType, LineNo, LineCount: Integer; var Name: String;
- var ReadMode: TRVFReadMode; var ReadState: TRVFReadState): Boolean; dynamic;
- procedure SaveRVF(Stream: TStream; RVData: TPersistent;
- ItemNo, ParaNo: Integer; const Name: String; Part: TRVMultiDrawItemPart;
- ForceSameAsPrev: Boolean); dynamic;
- procedure SaveRTF(Stream: TStream; const Path: String;
- RVData: TPersistent; ItemNo: Integer;
- const Name: String; TwipsPerPixel: Double; Level: Integer;
- ColorList: TRVColorList;
- StyleToFont, ListOverrideOffsetsList1,
- ListOverrideOffsetsList2: TRVIntegerList; FontTable: TRVList); dynamic;
- procedure FillRTFTables(ColorList: TRVColorList;
- ListOverrideCountList: TRVIntegerList; RVData: TPersistent); dynamic;
- procedure PaintFullWidth(Left, Right, Top: Integer; Canvas: TCanvas;
- State: TRVItemDrawStates;
- Style: TRVStyle; const ClipRect: TRect;
- dli: TRVDrawLineInfo); virtual;
- procedure Paint(x,y: Integer; Canvas: TCanvas; State: TRVItemDrawStates;
- Style: TRVStyle; dli: TRVDrawLineInfo); virtual;
- function PrintToBitmap(Bkgnd: TBitmap; Preview: Boolean;
- RichView: TRVScroller; dli: TRVDrawLineInfo; Part: Integer;
- ColorMode: TRVColorMode):Boolean; virtual;
- procedure Print(Canvas: TCanvas; x,y,x2: Integer;
- Preview, Correction: Boolean; const sad: TRVScreenAndDevice;
- RichView: TRVScroller; dli: TRVDrawLineInfo;
- Part: Integer; ColorMode: TRVColorMode; RVData: TPersistent); virtual;
- function GetImageWidth(RVStyle: TRVStyle): Integer; virtual;
- function GetImageHeight(RVStyle: TRVStyle): Integer; virtual;
- function GetBorderWidth: Integer; virtual;
- function GetBorderHeight: Integer; virtual;
- procedure MovingToUndoList(ItemNo: Integer;
- RVData, AContainerUndoItem: TObject); dynamic;
- procedure MovingFromUndoList(ItemNo: Integer; RVData: TObject); dynamic;
- procedure FinalizeUndoGroup; dynamic;
- function MouseMove(Shift: TShiftState; X,Y, ItemNo: Integer;
- RVData: TObject):Boolean; dynamic;
- function MouseDown(Button: TMouseButton; Shift: TShiftState;
- X,Y, ItemNo: Integer; RVData: TObject):Boolean; dynamic;
- function MouseUp(Button: TMouseButton; Shift: TShiftState;
- X,Y, ItemNo: Integer; RVData: TObject):Boolean; dynamic;
- procedure BeforeLoading(FileFormat: TRVLoadFormat); dynamic;
- procedure AfterLoading(FileFormat: TRVLoadFormat); dynamic;
- procedure DeselectPartial; dynamic;
- function PartiallySelected: Boolean; dynamic;
- function CanDeletePartiallySelected: Boolean; dynamic;
- procedure DeletePartiallySelected; dynamic;
- procedure ApplyStyleConversionToSubRVDatas(UserData: Integer;
- SelectedOnly: Boolean; ConvType: TRVEStyleConversionType);dynamic;
- procedure ApplyStyleConversion(RVData: TPersistent; ItemNo,
- UserData: Integer); dynamic;
- function CreatePrintingDrawItem(RVData: TObject;
- const sad: TRVScreenAndDevice): TRVDrawLineInfo; virtual;
- procedure StartExport; dynamic;
- procedure EndExport; dynamic;
- procedure Inserting(RVData: TObject; var Text: String; Safe: Boolean); virtual;
- procedure Inserted(RVData: TObject; ItemNo: Integer); virtual;
- procedure BeforeUndoChangeProperty; dynamic;
- procedure AfterUndoChangeProperty; dynamic;
- function EnterItem(From: TRVEnterDirection; Coord: Integer): Boolean; dynamic;
- function GetHypertextCursor(RVStyle: TRVStyle): TCursor; dynamic;
- procedure BuildJumps(Left,Top: Integer; var StartJumpNo: Integer; jumps: TList); dynamic;
- procedure Focusing;dynamic;
- function MoveFocus(GoForward: Boolean; var TopLevelRVData: TPersistent;
- var TopLevelItemNo: Integer): Boolean; dynamic;
- procedure ClearFocus; dynamic;
- procedure Execute(RVData:TPersistent);dynamic;
- function AdjustFocusToControl(Control: TControl;
- var TopLevelRVData: TPersistent;
- var TopLevelItemNo: Integer):Boolean;dynamic;
- procedure OnDocWidthChange(DocWidth: Integer; dli: TRVDrawLineInfo;
- Printing: Boolean; Canvas: TCanvas; RVData: TPersistent;
- sad: PRVScreenAndDevice; var HShift, Desc: Integer;
- NoCaching, Reformatting: Boolean); virtual;
- procedure MarkStylesInUse(Data: TRVDeleteUnusedStylesData); dynamic;
- procedure UpdateStyles(Data: TRVDeleteUnusedStylesData); dynamic;
- function GetSubRVData(var StoreState: TRVStoreSubRVData;
- Position: TRVSubRVDataPos): TPersistent; dynamic;
- procedure ChooseSubRVData(StoreState: TRVStoreSubRVData); dynamic;
- procedure CleanUpChosen; dynamic;
- procedure ResetSubCoords; dynamic;
- function SetExtraIntProperty(Prop: TRVExtraItemProperty;
- Value: Integer): Boolean; dynamic;
- function GetExtraIntProperty(Prop: TRVExtraItemProperty;
- var Value: Integer): Boolean; dynamic;
- function SetExtraStrProperty(Prop: TRVExtraItemStrProperty;
- const Value: String): Boolean; dynamic;
- function GetExtraStrProperty(Prop: TRVExtraItemStrProperty;
- var Value: String): Boolean; dynamic;
- function SetExtraCustomProperty(const PropName, Value: String): Boolean; dynamic;
- function GetSoftPageBreakDY(Data: Integer): Integer; dynamic;
- function GetActualStyleNo(RVStyle: TRVStyle): Integer;
- procedure DrawBackgroundForPrinting(Canvas: TCanvas;
- const Rect, FullRect: TRect; ColorMode: TRVColorMode;
- ItemBackgroundLayer: Integer); virtual;
- {$IFNDEF RVDONOTUSEANIMATION}
- procedure UpdateAnimator(RVData: TObject); dynamic;
- {$ENDIF}
- property BR: Boolean read GetBR write SetBR;
- property PageBreakBefore: Boolean read GetPageBreakBefore write SetPageBreakBefore;
- property AssociatedTextStyleNo: Integer read GetAssociatedTextStyleNo write SetAssociatedTextStyleNo;
- end;
- TCustomRVItemInfoClass = class of TCustomRVItemInfo;
- TRVTextItemInfo = class (TCustomRVItemInfo)
- public
- function GetBoolValueEx(Prop: TRVItemBoolPropertyEx; RVStyle: TRVStyle): Boolean; override;
- procedure Execute(RVData:TPersistent);override;
- procedure MarkStylesInUse(Data: TRVDeleteUnusedStylesData); override;
- procedure UpdateStyles(Data: TRVDeleteUnusedStylesData); override;
- function ReadRVFHeader(var P: PChar; RVData: TPersistent): Boolean; override;
- end;
- TRVTextItemInfoClass = class of TRVTextItemInfo;
- TRVNonTextItemInfo = class (TCustomRVItemInfo)
- protected
- function GetHeight: Integer; virtual;
- function GetWidth: Integer; virtual;
- function GetRVFExtraPropertyCount: Integer; override;
- procedure SaveRVFExtraProperties(Stream: TStream); override;
- public
- DeleteProtect: Boolean;
- function GetLeftOverhang: Integer; virtual;
- procedure AdjustInserted(x,y: Integer; adjusty: Boolean); virtual;
- procedure Assign(Source: TCustomRVItemInfo); override;
- function SetExtraIntProperty(Prop: TRVExtraItemProperty; Value: Integer): Boolean; override;
- function GetExtraIntProperty(Prop: TRVExtraItemProperty; var Value: Integer): Boolean; override;
- property Height: Integer read GetHeight;
- property Width: Integer read GetWidth;
- end;
- TRVFullLineItemInfo = class (TRVNonTextItemInfo)
- public
- function GetBoolValue(Prop: TRVItemBoolProperty): Boolean; override;
- end;
- TRVRectItemInfo = class (TRVNonTextItemInfo)
- protected
- FMinHeightOnPage: Integer;
- function GetDescent: Integer; virtual; // not used
- function SaveRVFHeaderTail(RVData: TPersistent): String; override;
- function GetRVFExtraPropertyCount: Integer; override;
- procedure SaveRVFExtraProperties(Stream: TStream); override;
- function GetVShiftCSS(RVStyle: TRVStyle): String;
- public
- VAlign: TRVVAlign;
- VShift: Integer;
- VShiftAbs: Boolean;
- Spacing: Integer;
- constructor Create(RVData: TPersistent); override;
- procedure Assign(Source: TCustomRVItemInfo); override;
- function SetExtraIntProperty(Prop: TRVExtraItemProperty; Value: Integer): Boolean; override;
- function GetExtraIntProperty(Prop: TRVExtraItemProperty; var Value: Integer): Boolean; override;
- function ReadRVFHeader(var P: PChar; RVData: TPersistent): Boolean; override;
- function GetBorderWidth: Integer; override;
- function GetBorderHeight: Integer; override;
- property Descent: Integer read GetDescent;
- end;
- TRVTabItemInfo = class (TRVRectItemInfo)
- private
- procedure DrawTab(Canvas: TCanvas; x, y: Integer; dli: TRVDrawLineInfo;
- Style: TRVStyle; TextDrawState: TRVTextDrawStates;
- CanUseCustomPPI, RTL, SpecialChars, Printing: Boolean;
- ColorMode: TRVColorMode);
- protected
- function GetAssociatedTextStyleNo: Integer; override;
- procedure SetAssociatedTextStyleNo(Value: Integer); override;
- function SaveRVFHeaderTail(RVData: TPersistent): String; override;
- public
- TextStyleNo: Integer;
- Leader: String;
- function ReadRVFHeader(var P: PChar; RVData: TPersistent): Boolean; override;
- function GetBoolValueEx(Prop: TRVItemBoolPropertyEx;
- RVStyle: TRVStyle): Boolean; override;
- function GetBoolValue(Prop: TRVItemBoolProperty): Boolean; override;
- procedure MarkStylesInUse(Data: TRVDeleteUnusedStylesData); override;
- procedure UpdateStyles(Data: TRVDeleteUnusedStylesData); override;
- procedure Paint(x,y: Integer; Canvas: TCanvas; State: TRVItemDrawStates;
- Style: TRVStyle; dli: TRVDrawLineInfo); override;
- procedure Print(Canvas: TCanvas; x,y,x2: Integer;
- Preview, Correction: Boolean; const sad: TRVScreenAndDevice;
- RichView: TRVScroller; dli: TRVDrawLineInfo;
- Part: Integer; ColorMode: TRVColorMode; RVData: TPersistent); override;
- procedure ApplyStyleConversion(RVData: TPersistent; ItemNo, UserData: Integer); override;
- procedure OnDocWidthChange(DocWidth: Integer; dli: TRVDrawLineInfo;
- Printing: Boolean; Canvas: TCanvas; RVData: TPersistent;
- sad: PRVScreenAndDevice; var HShift, Desc: Integer;
- NoCaching, Reformatting: Boolean); override;
- procedure SaveRVF(Stream: TStream; RVData: TPersistent; ItemNo, ParaNo: Integer;
- const Name: String; Part: TRVMultiDrawItemPart;
- ForceSameAsPrev: Boolean); override;
- procedure SaveRTF(Stream: TStream; const Path: String;
- RVData: TPersistent; ItemNo: Integer;
- const Name: String; TwipsPerPixel: Double; Level: Integer;
- ColorList: TRVColorList;
- StyleToFont, ListOverrideOffsetsList1,
- ListOverrideOffsetsList2: TRVIntegerList; FontTable: TRVList); override;
- {$IFNDEF RVDONOTUSEHTML}
- procedure SaveToHTML(Stream: TStream; RVData: TPersistent;
- ItemNo: Integer; const Text, Path: String;
- const imgSavePrefix: String; var imgSaveNo: Integer;
- CurrentFileColor: TColor; SaveOptions: TRVSaveOptions;
- UseCSS: Boolean; Bullets: TRVList); override;
- {$ENDIF}
- function AsText(LineWidth: Integer; RVData: TPersistent;
- const Text, Path: String; TextOnly, Unicode: Boolean): String; override;
- end;
- TRVControlItemInfo = class (TRVRectItemInfo)
- protected
- FResizable, FVisible: Boolean;
- function GetHeight: Integer; override;
- function GetWidth: Integer; override;
- function GetRVFExtraPropertyCount: Integer; override;
- procedure SaveRVFExtraProperties(Stream: TStream); override;
- public
- Control: TControl;
- PercentWidth: Integer;
- constructor CreateEx(RVData: TPersistent;AControl: TControl; AVAlign: TRVVAlign);
- constructor Create(RVData: TPersistent); override;
- procedure Assign(Source: TCustomRVItemInfo); override;
- destructor Destroy; override;
- function GetMinWidth(sad: PRVScreenAndDevice; Canvas: TCanvas; RVData: TPersistent): Integer; override;
- procedure AdjustInserted(x,y: Integer; adjusty: Boolean); override;
- function PrintToBitmap(Bkgnd: TBitmap; Preview: Boolean; RichView: TRVScroller;
- dli: TRVDrawLineInfo; Part: Integer; ColorMode: TRVColorMode):Boolean; override;
- function CreatePrintingDrawItem(RVData: TObject; const sad: TRVScreenAndDevice): TRVDrawLineInfo; override;
- procedure Paint(x,y: Integer; Canvas: TCanvas; State: TRVItemDrawStates;
- Style: TRVStyle; dli: TRVDrawLineInfo); override;
- function OwnsControl(AControl: TControl): Boolean; override;
- function AsText(LineWidth: Integer;
- RVData: TPersistent;
- const Text, Path: String;
- TextOnly,Unicode: Boolean): String; override;
- {$IFNDEF RVDONOTUSEHTML}
- procedure SaveToHTML(Stream: TStream; RVData: TPersistent;
- ItemNo: Integer;
- const Text, Path: String;
- const imgSavePrefix: String;
- var imgSaveNo: Integer;
- CurrentFileColor: TColor;
- SaveOptions: TRVSaveOptions;
- UseCSS: Boolean;
- Bullets: TRVList); override;
- {$ENDIF}
- function ReadRVFLine(const s: String; RVData: TPersistent;
- ReadType, LineNo, LineCount: Integer;
- var Name: String;
- var ReadMode: TRVFReadMode;
- var ReadState: TRVFReadState): Boolean; override;
- procedure SaveRVF(Stream: TStream; RVData: TPersistent; ItemNo, ParaNo: Integer;
- const Name: String; Part: TRVMultiDrawItemPart;
- ForceSameAsPrev: Boolean); override;
- function SetExtraIntProperty(Prop: TRVExtraItemProperty; Value: Integer): Boolean; override;
- function GetExtraIntProperty(Prop: TRVExtraItemProperty; var Value: Integer): Boolean; override;
- procedure SaveRTF(Stream: TStream; const Path: String;
- RVData: TPersistent; ItemNo: Integer;
- const Name: String; TwipsPerPixel: Double; Level: Integer; ColorList: TRVColorList;
- StyleToFont, ListOverrideOffsetsList1, ListOverrideOffsetsList2: TRVIntegerList;
- FontTable: TRVList); override;
- function GetBoolValue(Prop: TRVItemBoolProperty): Boolean; override;
- function GetBoolValueEx(Prop: TRVItemBoolPropertyEx; RVStyle: TRVStyle): Boolean; override;
- function GetImageHeight(RVStyle: TRVStyle): Integer; override;
- function GetImageWidth(RVStyle: TRVStyle): Integer; override;
- procedure MovingToUndoList(ItemNo: Integer; RVData, AContainerUndoItem: TObject); override;
- procedure MovingFromUndoList(ItemNo: Integer; RVData: TObject); override;
- procedure Inserting(RVData: TObject; var Text: String; Safe: Boolean); override;
- procedure Focusing; override;
- procedure OnDocWidthChange(DocWidth: Integer; dli: TRVDrawLineInfo; Printing: Boolean;
- Canvas: TCanvas; RVData: TPersistent; sad: PRVScreenAndDevice;
- var HShift, Desc: Integer; NoCaching, Reformatting: Boolean); override;
- property MinHeightOnPage: Integer read FMinHeightOnPage write FMinHeightOnPage;
- end;
- TRVGraphicItemInfo = class (TRVRectItemInfo)
- protected
- {$IFNDEF RVDONOTUSEANIMATION}
- FAnimator: TObject;
- {$ENDIF}
- function GetHeight: Integer; override;
- function GetWidth: Integer; override;
- function GetRVFExtraPropertyCount: Integer; override;
- procedure SaveRVFExtraProperties(Stream: TStream); override;
- public
- Image, ImageCopy: TGraphic;
- ImageWidth, ImageHeight, Interval : Integer;
- NoHTMLImageSize: Boolean;
- Alt, ImageFileName: String;
- constructor CreateEx(RVData: TPersistent; AImage: TGraphic; AVAlign: TRVVAlign); virtual;
- procedure Assign(Source: TCustomRVItemInfo); override;
- procedure TransferProperties(Source: TCustomRVItemInfo;
- RVData: TPersistent); override;
- function SetExtraIntProperty(Prop: TRVExtraItemProperty;
- Value: Integer): Boolean; override;
- function GetExtraIntProperty(Prop: TRVExtraItemProperty;
- var Value: Integer): Boolean; override;
- function SetExtraStrProperty(Prop: TRVExtraItemStrProperty;
- const Value: String): Boolean; override;
- function GetExtraStrProperty(Prop: TRVExtraItemStrProperty;
- var Value: String): Boolean; override;
- procedure UpdatePaletteInfo(PaletteAction: TRVPaletteAction;
- ForceRecreateCopy: Boolean; Palette: HPALETTE;
- LogPalette: PLogPalette); override;
- function GetMinWidth(sad: PRVScreenAndDevice; Canvas: TCanvas;
- RVData: TPersistent): Integer; override;
- destructor Destroy; override;
- function AsImage: TGraphic; override;
- procedure Paint(x,y: Integer; Canvas: TCanvas; State: TRVItemDrawStates;
- Style: TRVStyle; dli: TRVDrawLineInfo); override;
- function GetBoolValue(Prop: TRVItemBoolProperty): Boolean; override;
- function GetBoolValueEx(Prop: TRVItemBoolPropertyEx; RVStyle: TRVStyle): Boolean; override;
- {$IFNDEF RVDONOTUSEHTML}
- procedure SaveToHTML(Stream: TStream; RVData: TPersistent;
- ItemNo: Integer; const Text, Path: String; const imgSavePrefix: String;
- var imgSaveNo: Integer; CurrentFileColor: TColor;
- SaveOptions: TRVSaveOptions; UseCSS: Boolean; Bullets: TRVList); override;
- {$ENDIF}
- function ReadRVFLine(const s: String; RVData: TPersistent;
- ReadType, LineNo, LineCount: Integer; var Name: String;
- var ReadMode: TRVFReadMode; var ReadState: TRVFReadState): Boolean; override;
- procedure SaveRVF(Stream: TStream; RVData: TPersistent; ItemNo, ParaNo: Integer;
- const Name: String; Part: TRVMultiDrawItemPart;
- ForceSameAsPrev: Boolean); override;
- procedure SaveRTF(Stream: TStream; const Path: String;
- RVData: TPersistent; ItemNo: Integer;
- const Name: String; TwipsPerPixel: Double; Level: Integer; ColorList: TRVColorList;
- StyleToFont, ListOverrideOffsetsList1, ListOverrideOffsetsList2: TRVIntegerList;
- FontTable: TRVList); override;
- function PrintToBitmap(Bkgnd: TBitmap; Preview: Boolean; RichView: TRVScroller;
- dli: TRVDrawLineInfo; Part: Integer; ColorMode: TRVColorMode):Boolean; override;
- procedure Print(Canvas: TCanvas; x,y,x2: Integer; Preview, Correction: Boolean;
- const sad: TRVScreenAndDevice; RichView: TRVScroller; dli: TRVDrawLineInfo;
- Part: Integer; ColorMode: TRVColorMode; RVData: TPersistent); override;
- function GetImageHeight(RVStyle: TRVStyle): Integer; override;
- function GetImageWidth(RVStyle: TRVStyle): Integer; override;
- procedure MovingToUndoList(ItemNo: Integer; RVData, AContainerUndoItem: TObject); override;
- function CreatePrintingDrawItem(RVData: TObject; const sad: TRVScreenAndDevice): TRVDrawLineInfo; override;
- {$IFNDEF RVDONOTUSEANIMATION}
- procedure UpdateAnimator(RVData: TObject); override;
- {$ENDIF}
- property MinHeightOnPage: Integer read FMinHeightOnPage write FMinHeightOnPage;
- end;
- TRVGraphicItemInfoClass = class of TRVGraphicItemInfo;
- TRVHotGraphicItemInfo = class(TRVGraphicItemInfo)
- public
- function GetBoolValueEx(Prop: TRVItemBoolPropertyEx; RVStyle: TRVStyle): Boolean; override;
- constructor CreateEx(RVData: TPersistent; AImage: TGraphic; AVAlign: TRVVAlign); override;
- procedure Execute(RVData:TPersistent); override;
- end;
- TRVBulletItemInfo = class (TRVRectItemInfo)
- protected
- function GetHeight: Integer; override;
- function GetWidth: Integer; override;
- function GetImageIndex(Hot: Boolean): Integer; virtual;
- function SaveRVFHeaderTail(RVData: TPersistent): String; override;
- function GetRVFExtraPropertyCount: Integer; override;
- procedure SaveRVFExtraProperties(Stream: TStream); override;
- public
- ImageList: TCustomImageList;
- ImageIndex: Integer;
- NoHTMLImageSize: Boolean;
- Alt: String;
- constructor CreateEx(RVData: TPersistent; AImageIndex: Integer;
- AImageList: TCustomImageList; AVAlign: TRVVAlign);
- {$IFNDEF RVDONOTUSEHTML}
- procedure SaveToHTML(Stream: TStream; RVData: TPersistent; ItemNo: Integer;
- const Text, Path: String; const imgSavePrefix: String;
- var imgSaveNo: Integer; CurrentFileColor: TColor;
- SaveOptions: TRVSaveOptions; UseCSS: Boolean; Bullets: TRVList); override;
- {$ENDIF}
- procedure Assign(Source: TCustomRVItemInfo); override;
- function GetMinWidth(sad: PRVScreenAndDevice; Canvas: TCanvas;
- RVData: TPersistent): Integer; override;
- procedure Paint(x,y: Integer; Canvas: TCanvas; State: TRVItemDrawStates;
- Style: TRVStyle; dli: TRVDrawLineInfo); override;
- function PrintToBitmap(Bkgnd: TBitmap; Preview: Boolean; RichView: TRVScroller;
- dli: TRVDrawLineInfo; Part: Integer; ColorMode: TRVColorMode):Boolean; override;
- function ReadRVFHeader(var P: PChar; RVData: TPersistent): Boolean; override;
- function ReadRVFLine(const s: String; RVData: TPersistent;
- ReadType, LineNo, LineCount: Integer; var Name: String;
- var ReadMode: TRVFReadMode; var ReadState: TRVFReadState): Boolean; override;
- procedure SaveRVF(Stream: TStream; RVData: TPersistent; ItemNo, ParaNo: Integer;
- const Name: String; Part: TRVMultiDrawItemPart;
- ForceSameAsPrev: Boolean); override;
- procedure SaveRTF(Stream: TStream; const Path: String;
- RVData: TPersistent; ItemNo: Integer;
- const Name: String; TwipsPerPixel: Double; Level: Integer; ColorList: TRVColorList;
- StyleToFont, ListOverrideOffsetsList1, ListOverrideOffsetsList2: TRVIntegerList;
- FontTable: TRVList); override;
- function GetBoolValue(Prop: TRVItemBoolProperty): Boolean; override;
- function SetExtraIntProperty(Prop: TRVExtraItemProperty;
- Value: Integer): Boolean; override;
- function GetExtraIntProperty(Prop: TRVExtraItemProperty;
- var Value: Integer): Boolean; override;
- function SetExtraStrProperty(Prop: TRVExtraItemStrProperty;
- const Value: String): Boolean; override;
- function GetExtraStrProperty(Prop: TRVExtraItemStrProperty;
- var Value: String): Boolean; override;
- function GetImageHeight(RVStyle: TRVStyle): Integer; override;
- function GetImageWidth(RVStyle: TRVStyle): Integer; override;
- end;
- TRVHotspotItemInfo = class (TRVBulletItemInfo)
- protected
- function GetImageIndex(Hot: Boolean): Integer; override;
- function SaveRVFHeaderTail(RVData: TPersistent): String; override;
- public
- HotImageIndex: Integer;
- constructor CreateEx(RVData: TPersistent; AImageIndex, AHotImageIndex: Integer;
- AImageList: TCustomImageList; AVAlign: TRVVAlign);
- procedure Assign(Source: TCustomRVItemInfo); override;
- function ReadRVFHeader(var P: PChar; RVData: TPersistent): Boolean; override;
- procedure SaveRVF(Stream: TStream; RVData: TPersistent; ItemNo, ParaNo: Integer;
- const Name: String; Part: TRVMultiDrawItemPart;
- ForceSameAsPrev: Boolean); override;
- function GetBoolValueEx(Prop: TRVItemBoolPropertyEx; RVStyle: TRVStyle): Boolean;override;
- procedure Execute(RVData:TPersistent);override;
- end;
- TRVBreakItemInfo = class (TRVFullLineItemInfo)
- protected
- function SaveRVFHeaderTail(RVData: TPersistent): String; override;
- public
- LineWidth: Byte;
- Style: TRVBreakStyle;
- Color: TColor;
- constructor CreateEx(RVData: TPersistent; ALineWidth: Byte; AStyle: TRVBreakStyle; AColor: TColor);
- procedure Assign(Source: TCustomRVItemInfo); override;
- procedure PaintFullWidth(Left, Right, Top: Integer; Canvas: TCanvas;
- State: TRVItemDrawStates;
- Style: TRVStyle; const ClipRect: TRect;
- dli: TRVDrawLineInfo); override;
- procedure Print(Canvas: TCanvas; x,y,x2: Integer; Preview, Correction: Boolean;
- const sad: TRVScreenAndDevice; RichView: TRVScroller; dli: TRVDrawLineInfo;
- Part: Integer; ColorMode: TRVColorMode; RVData: TPersistent); override;
- function AsText(LineWidth: Integer;
- RVData: TPersistent;
- const Text, Path: String;
- TextOnly,Unicode: Boolean): String; override;
- {$IFNDEF RVDONOTUSEHTML}
- procedure SaveToHTML(Stream: TStream; RVData: TPersistent;
- ItemNo: Integer;
- const Text, Path: String;
- const imgSavePrefix: String;
- var imgSaveNo: Integer;
- CurrentFileColor: TColor;
- SaveOptions: TRVSaveOptions;
- UseCSS: Boolean;
- Bullets: TRVList); override;
- {$ENDIF}
- function ReadRVFHeader(var P: PChar; RVData: TPersistent): Boolean; override;
- procedure SaveRVF(Stream: TStream; RVData: TPersistent; ItemNo, ParaNo: Integer;
- const Name: String; Part: TRVMultiDrawItemPart;
- ForceSameAsPrev: Boolean); override;
- procedure SaveRTF(Stream: TStream; const Path: String;
- RVData: TPersistent; ItemNo: Integer;
- const Name: String; TwipsPerPixel: Double; Level: Integer; ColorList: TRVColorList;
- StyleToFont, ListOverrideOffsetsList1, ListOverrideOffsetsList2: TRVIntegerList;
- FontTable: TRVList); override;
- procedure FillRTFTables(ColorList: TRVColorList; ListOverrideCountList: TRVIntegerList;
- RVData: TPersistent); override;
- function GetBoolValue(Prop: TRVItemBoolProperty): Boolean; override;
- function GetBoolValueEx(Prop: TRVItemBoolPropertyEx; RVStyle: TRVStyle): Boolean;override;
- end;
- function RV_DuplicateItem(Source: TCustomRVItemInfo;
- RVData: TPersistent; DuplicateCheckpoint: Boolean): TCustomRVItemInfo;
- procedure RegisterRichViewItemClass(StyleNo: Integer; ItemClass: TCustomRVItemInfoClass);
- function CreateRichViewItem(StyleNo: Integer; RVData: TPersistent): TCustomRVItemInfo;
- function RVFGetItemOptions(ItemOptions: TRVItemOptions; ForceSameAsPrev: Boolean): TRVItemOptions;
- procedure RVSaveImageToRTF(Stream: TStream; TwipsPerPixel: Double;
- Image: TGraphic; ImageWidth, ImageHeight: Integer; Options: TRVRTFOptions);
- procedure RVSaveImageListImageToRTF(Stream: TStream;
- TwipsPerPixel: Double; ImageList: TCustomImageList; ImageIndex: Integer;
- RTFOptions: TRVRTFOptions);
- {$IFNDEF RVDONOTUSEHTML}
- procedure RVSaveImageSharedImageInHTML(ImageList: TCustomImageList;
- ImageIndex: Integer; Graphic: TGraphic; var Location: String;
- RVData: TPersistent; const Path,
- imgSavePrefix: String; var imgSaveNo: Integer; CurrentFileColor: TColor;
- SaveOptions: TRVSaveOptions;
- Bullets: TRVList);
- function RV_GetExtraIMGStr(SaveOptions: TRVSaveOptions; Width, Height: Integer;
- NoHTMLImageSize: Boolean): String;
- {$ENDIF}
- var
- RichViewTextItemClass: TRVTextItemInfoClass;
- const
- RVItemOptionsMask = $0F;
- procedure WriteRVFExtraIntPropertyStr(Stream: TStream; Prop: TRVExtraItemProperty;
- Value: Integer);
- procedure WriteRVFExtraStrPropertyStr(Stream: TStream; Prop: TRVExtraItemStrProperty;
- const Value: String);
- implementation
- uses RVFMisc,RichView, PtblRV, PtRVData, CRVData, CRVFData, RVUni, RVStr, CtrlImg,
- RVAnimate
- {$IFNDEF RVDONOTUSELISTS}
- , RVMarker
- {$ENDIF}
- ;
- procedure RichView_InitializeList; forward;
- {============================= TRVDeleteUnusedStylesData ======================}
- constructor TRVDeleteUnusedStylesData.Create(ATextStyles, AParaStyles,
- AListStyles: Boolean);
- begin
- inherited Create;
- FTextStyles := ATextStyles;
- FParaStyles := AParaStyles;
- FListStyles := AListStyles;
- end;
- {------------------------------------------------------------------------------}
- destructor TRVDeleteUnusedStylesData.Destroy;
- begin
- FUsedTextStyles.Free;
- FUsedParaStyles.Free;
- FUsedListStyles.Free;
- inherited;
- end;
- {------------------------------------------------------------------------------}
- procedure TRVDeleteUnusedStylesData.Init(RVStyle: TRVStyle);
- {............................................}
- procedure MarkStandardStyles(Styles: TCustomRVInfos; Used: TRVIntegerList);
- var i: Integer;
- begin
- for i := 0 to Used.Count-1 do
- if TCustomRVInfo(Styles.Items[i]).Standard then
- Used[i] := 1;
- end;
- {............................................}
- begin
- if FInitialized then
- exit;
- FUsedTextStyles := TRVIntegerList.CreateEx(RVStyle.TextStyles.Count, ord(not FTextStyles));
- FUsedParaStyles := TRVIntegerList.CreateEx(RVStyle.ParaStyles.Count, ord(not FParaStyles));
- FUsedListStyles := TRVIntegerList.CreateEx(RVStyle.ListStyles.Count, ord(not FListStyles));
- {$IFNDEF RVDONOTUSEUNICODE}
- if FTextStyles and (RVStyle.DefUnicodeStyle>=0) then
- if RVStyle.DefUnicodeStyle>=FUsedTextStyles.Count then
- RVStyle.DefUnicodeStyle := -1
- else
- FUsedTextStyles[RVStyle.DefUnicodeStyle] := 1;
- {$ENDIF}
- if FTextStyles then
- MarkStandardStyles(RVStyle.TextStyles, FUsedTextStyles);
- if FParaStyles then
- MarkStandardStyles(RVStyle.ParaStyles, FUsedParaStyles);
- if FListStyles then
- MarkStandardStyles(RVStyle.ListStyles, FUsedListStyles);
- FInitialized := True;
- end;
- {------------------------------------------------------------------------------}
- procedure TRVDeleteUnusedStylesData.ConvertFlagsToShifts(RVStyle: TRVStyle);
- {............................................}
- procedure UpdStyles(Styles: TCustomRVInfos; Used: TRVIntegerList);
- var i,idx,val: Integer;
- IsTextStyle, IsParaStyle: Boolean;
- begin
- IsTextStyle := Styles is TFontInfos;
- IsParaStyle := Styles is TParaInfos;
- idx := 1;
- for i := 0 to Used.Count-1 do
- if Used[i]=0 then
- inc(idx)
- else
- Used[i] := idx;
- for i := Used.Count-1 downto 0 do
- if Used[i]=0 then
- Styles.Items[i].Free;
- for i := 0 to Styles.Count-1 do begin
- val := TCustomRVInfo(Styles.Items[i]).BaseStyleNo;
- if val>=0 then
- if val>=Used.Count then
- TCustomRVInfo(Styles.Items[i]).BaseStyleNo := -1
- else
- TCustomRVInfo(Styles.Items[i]).BaseStyleNo := val-Used[val]+1;
- if IsTextStyle then begin
- val := TFontInfo(Styles.Items[i]).NextStyleNo;
- if val>=0 then
- if val>=Used.Count then
- TFontInfo(Styles.Items[i]).NextStyleNo := -1
- else
- TFontInfo(Styles.Items[i]).NextStyleNo := val-Used[val]+1;
- end
- else if IsParaStyle then begin
- val := TParaInfo(Styles.Items[i]).NextParaNo;
- if val>=0 then
- if val>=Used.Count then
- TParaInfo(Styles.Items[i]).NextParaNo := -1
- else
- TParaInfo(Styles.Items[i]).NextParaNo := val-Used[val]+1;
- end;
- end;
- end;
- {............................................}
- begin
- if FConvertedToShifts then
- exit;
- if FTextStyles then
- UpdStyles(RVStyle.TextStyles, FUsedTextStyles);
- if FParaStyles then
- UpdStyles(RVStyle.ParaStyles, FUsedParaStyles);
- if FListStyles then
- UpdStyles(RVStyle.ListStyles, FUsedListStyles);
- FConvertedToShifts := True;
- end;
- {============================= TRVCPInfo ======================================}
- procedure TRVCPInfo.Assign(Source: TRVCPInfo; TagsArePChars: Boolean);
- begin
- Name := Source.Name;
- RaiseEvent := Source.RaiseEvent;
- Tag := RV_CopyTag(Source.Tag, TagsArePChars);
- Persistent := Source.Persistent;
- //DrawItemNo, Next, Prev, ItemInfo are not copied
- end;
- {------------------------------------------------------------------------------}
- function TRVCPInfo.CreateCopy(TagsArePChars: Boolean): TRVCPInfo;
- begin
- Result := TRVCPInfo.Create;
- Result.Assign(Self,TagsArePChars);
- end;
- {========================= TRVImagePrintPart ==================================}
- type
- TRVImagePrintPart = class (TRVMultiDrawItemPart)
- public
- ImgTop, ImgHeight: Integer;
- function GetSoftPageBreakInfo: Integer; override;
- end;
- function TRVImagePrintPart.GetSoftPageBreakInfo: Integer;
- begin
- Result := ImgTop;
- end;
- {========================= TRVMultiImagePrintInfo =============================}
- type
- TRVMultiImagePrintInfo = class (TRVMultiDrawItemInfo)
- private
- sad: TRVScreenAndDevice;
- FItem: TRVRectItemInfo;
- public
- constructor Create(AItem: TRVRectItemInfo);
- procedure SetSize(AWidth, AHeight: Integer); override;
- function InitSplit: Boolean; override;
- function CanSplitFirst(Y: Integer): Boolean; override;
- function SplitAt(Y: Integer): Boolean; override;
- end;
- {------------------------------------------------------------------------------}
- constructor TRVMultiImagePrintInfo.Create(AItem: TRVRectItemInfo);
- begin
- inherited Create;
- FItem := AItem;
- end;
- {------------------------------------------------------------------------------}
- function TRVMultiImagePrintInfo.CanSplitFirst(Y: Integer): Boolean;
- begin
- Y := MulDiv(Y, sad.ppiyScreen, sad.ppiyDevice);
- Result :=
- (Y>0) and
- FItem.GetBoolValueEx(rvbpPrintToBMP, nil) and
- (FItem.FMinHeightOnPage>0) and
- (Y>=FItem.FMinHeightOnPage) and
- ((FItem.GetImageHeight(nil)-Y >= FItem.FMinHeightOnPage) or
- (Y>FItem.GetImageHeight(nil)));
- end;
- {------------------------------------------------------------------------------}
- function TRVMultiImagePrintInfo.InitSplit: Boolean;
- var part: TRVImagePrintPart;
- begin
- Result := FItem.FMinHeightOnPage<>0;
- if not Result then
- exit;
- part := TRVImagePrintPart.Create;
- part.ImgTop := 0;
- part.ImgHeight := FItem.GetImageHeight(nil);
- part.Height := MulDiv(part.ImgHeight, sad.ppiyDevice, sad.ppiyScreen);
- PartsList.Add(part);
- end;
- {------------------------------------------------------------------------------}
- function TRVMultiImagePrintInfo.SplitAt(Y: Integer): Boolean;
- var PrevHeight, NewHeight, PrevTop: Integer;
- part: TRVImagePrintPart;
- begin
- if FItem.FMinHeightOnPage<=0 then begin
- Result := False;
- exit;
- end;
- if PartsList.Count=0 then
- raise ERichViewError.Create(errRVPrint);
- part := TRVImagePrintPart(PartsList[PartsList.Count-1]);
- if (part.ImgHeight<=FItem.FMinHeightOnPage) then begin
- Result := False;
- exit;
- end;
- PrevHeight := MulDiv(Y, sad.ppiyScreen, sad.ppiyDevice);
- NewHeight := part.ImgHeight-PrevHeight;
- if (NewHeight<FItem.FMinHeightOnPage) or (PrevHeight<FItem.FMinHeightOnPage) then begin
- Result := False;
- exit;
- end;
- part.ImgHeight := PrevHeight;
- part.Height := MulDiv(part.ImgHeight, sad.ppiyDevice, sad.ppiyScreen);
- PrevTop := part.ImgTop;
- part := TRVImagePrintPart.Create;
- part.ImgTop := PrevTop+PrevHeight;
- part.ImgHeight := NewHeight;
- part.Height := MulDiv(part.ImgHeight, sad.ppiyDevice, sad.ppiyScreen);
- PartsList.Add(part);
- Result := True;
- end;
- {------------------------------------------------------------------------------}
- procedure TRVMultiImagePrintInfo.SetSize(AWidth, AHeight: Integer);
- begin
- // do nothing
- end;
- {==============================================================================}
- type
- TRichViewItemTypeInfo = class
- public
- StyleNo: Integer;
- ItemClass: TCustomRVItemInfoClass;
- end;
- const RichViewItemClassesList: TList = nil;
- {------------------------------------------------------------------------------}
- const RVFExtraItemIntPropNames: array [TRVExtraItemProperty] of String =
- ('', 'vshift', 'vshiftabs', 'width', 'height', 'transparent', 'tmode',
- 'tcolor', 'minheightonpage', 'spacing', 'resizable', 'unremovable',
- 'nohtmlsize', 'ainterval', 'visible');
- const RVFExtraItemStrPropNames: array [TRVExtraItemStrProperty] of String =
- ('', 'hint', 'alt', 'filename');
- function GetRVFExtraIntPropertyByName(const PropName: String):TRVExtraItemProperty;
- var i: TRVExtraItemProperty;
- begin
- Result := rvepUnknown;
- for i := Low(TRVExtraItemProperty) to High(TRVExtraItemProperty) do
- if RVFExtraItemIntPropNames[i]=PropName then begin
- Result := i;
- exit;
- end;
- end;
- {------------------------------------------------------------------------------}
- function GetRVFExtraStrPropertyByName(const PropName: String):TRVExtraItemStrProperty;
- var i: TRVExtraItemStrProperty;
- begin
- Result := rvespUnknown;
- for i := Low(TRVExtraItemStrProperty) to High(TRVExtraItemStrProperty) do
- if RVFExtraItemStrPropNames[i]=PropName then begin
- Result := i;
- exit;
- end;
- end;
- {------------------------------------------------------------------------------}
- procedure WriteRVFExtraIntPropertyStr(Stream: TStream; Prop: TRVExtraItemProperty;
- Value: Integer);
- begin
- RVFWriteLine(Stream, Format('%s=%d', [RVFExtraItemIntPropNames[Prop], Value]));
- end;
- {------------------------------------------------------------------------------}
- procedure WriteRVFExtraStrPropertyStr(Stream: TStream; Prop: TRVExtraItemStrProperty;
- const Value: String);
- begin
- RVFWriteLine(Stream, Format('%s=%s', [RVFExtraItemStrPropNames[Prop], Value]));
- end;
- {------------------------------------------------------------------------------}
- procedure RegisterRichViewItemClass(StyleNo: Integer; ItemClass: TCustomRVItemInfoClass);
- var i: Integer;
- item: TRichViewItemTypeInfo;
- begin
- if RichViewItemClassesList=nil then
- RichView_InitializeList;
- if StyleNo>=-9 then
- raise ERichViewError.Create(errRVItemReg2);
- for i := 0 to RichViewItemClassesList.Count-1 do
- if TRichViewItemTypeInfo(RichViewItemClassesList[i]).StyleNo=StyleNo then begin
- if TRichViewItemTypeInfo(RichViewItemClassesList[i]).ItemClass=ItemClass then
- exit;
- raise ERichViewError.Create(errRVItemReg2);
- end;
- item := TRichViewItemTypeInfo.Create;
- item.StyleNo := StyleNo;
- item.ItemClass := ItemClass;
- RichViewItemClassesList.Add(item);
- end;
- {------------------------------------------------------------------------------}
- function CreateRichViewItem(StyleNo: Integer; RVData: TPersistent): TCustomRVItemInfo;
- var i: Integer;
- begin
- if StyleNo>=0 then begin
- Result := RichViewTextItemClass.Create(RVData);
- Result.StyleNo := StyleNo;
- exit;
- end;
- Result := nil;
- case StyleNo of
- rvsBullet:
- Result := TRVBulletItemInfo.Create(RVData);
- rvsHotspot:
- Result := TRVHotspotItemInfo.Create(RVData);
- rvsPicture:
- Result := TRVGraphicItemInfo.Create(RVData);
- rvsComponent:
- Result := TRVControlItemInfo.Create(RVData);
- rvsBreak:
- Result := TRVBreakItemInfo.Create(RVData);
- rvsHotPicture:
- Result := TRVHotGraphicItemInfo.Create(RVData);
- {$IFNDEF RVDONOTUSELISTS}
- rvsListMarker:
- Result := TRVMarkerItemInfo.Create(RVData);
- {$ENDIF}
- rvsTab:
- Result := TRVTabItemInfo.Create(RVData);
- end;
- if Result<>nil then begin
- Result.StyleNo := StyleNo;
- exit;
- end;
- for i := 0 to RichViewItemClassesList.Count-1 do
- if TRichViewItemTypeInfo(RichViewItemClassesList[i]).StyleNo=StyleNo then begin
- Result := TRichViewItemTypeInfo(RichViewItemClassesList[i]).ItemClass.Create(RVData);
- Result.StyleNo := StyleNo;
- exit;
- end;
- Result := nil;
- end;
- {------------------------------------------------------------------------------}
- procedure RichView_InitializeList;
- begin
- if RichViewItemClassesList=nil then
- RichViewItemClassesList := TList.Create;
- end;
- {------------------------------------------------------------------------------}
- procedure RichView_FinalizeList;
- var i: Integer;
- begin
- for i := 0 to RichViewItemClassesList.Count-1 do
- TRichViewItemTypeInfo(RichViewItemClassesList.Items[i]).Free;
- RichViewItemClassesList.Free;
- end;
- {==============================================================================}
- function RV_DuplicateItem(Source: TCustomRVItemInfo; RVData: TPersistent;
- DuplicateCheckpoint: Boolean): TCustomRVItemInfo;
- var TagsArePChars: Boolean;
- begin
- TagsArePChars := rvoTagsArePChars in TCustomRVData(RVData).Options;
- Result := TCustomRVItemInfoClass(Source.ClassType).Create(RVData);
- Result.StyleNo := Source.StyleNo;
- Result.Assign(Source);
- if DuplicateCheckpoint and (Source.Checkpoint<>nil) then begin
- Result.Checkpoint := TRVCPInfo.Create;
- Result.Checkpoint.Assign(Source.Checkpoint, TagsArePChars);
- end;
- Result.Tag := RV_CopyTag(Source.Tag, TagsArePChars)
- end;
- {------------------------------------------------------------------------------}
- {$IFNDEF RVDONOTUSEHTML}
- function GetHTMLImageAlign(Align: TRVVAlign; SaveOptions: TRVSaveOptions; CSSVersion: Boolean): String;
- begin
- case Align of
- rvvaMiddle:
- if CSSVersion and (rvsoXHTML in SaveOptions) then
- Result := ' align="middle"'
- else
- Result := ' align=middle';
- else
- Result := '';
- end;
- end;
- {$ENDIF}
- {======================= TCustomRVItemInfo ====================================}
- constructor TCustomRVItemInfo.Create;
- begin
- inherited Create;
- DrawItemNo := -1;
- end;
- {------------------------------------------------------------------------------}
- {$IFNDEF RVDONOTUSELIVESPELL}
- destructor TCustomRVItemInfo.Destroy;
- begin
- WordPaintList.Free;
- inherited Destroy;
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.ClearLiveSpellingResult;
- var i: Integer;
- begin
- Exclude(ItemState, rvisSpellChecked);
- if WordPaintList<>nil then begin
- for i := WordPaintList.Count-1 downto 0 do
- if WordPaintList[i] is TRVWordMisspellPainter then
- WordPaintList.Delete(i);
- if WordPaintList.Count=0 then begin
- WordPaintList.Free;
- WordPaintList := nil;
- end;
- end;
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.ClearWordPainters(Index: Integer);
- var i: Integer;
- begin
- Exclude(ItemState, rvisSpellChecked);
- if WordPaintList<>nil then begin
- if Index<=1 then begin
- WordPaintList.Free;
- WordPaintList := nil;
- end
- else begin
- for i := WordPaintList.Count-1 downto 0 do
- if WordPaintList[i].StartOffs+WordPaintList[i].Length>Index then
- WordPaintList.Delete(i);
- if WordPaintList.Count=0 then begin
- WordPaintList.Free;
- WordPaintList := nil;
- end;
- end;
- end;
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.AdjustWordPaintersOnInsert(Index: Integer; ch: Char;
- RVData: TPersistent): Boolean;
- var i, d: Integer;
- begin
- Result := TCustomRVData(RVData).IsDelimiterA(ch);
- if Result then
- d := 0
- else
- d := 1;
- if WordPaintList<>nil then begin
- for i := WordPaintList.Count-1 downto 0 do
- if WordPaintList[i].StartOffs+WordPaintList[i].Length+d>Index then
- if WordPaintList[i].StartOffs<Index+d then begin
- WordPaintList.Delete(i);
- Result := True;
- end
- else
- inc(WordPaintList[i].StartOffs);
- if WordPaintList.Count=0 then begin
- WordPaintList.Free;
- WordPaintList := nil;
- end;
- end;
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.AdjustWordPaintersOnDelete(Index, Count: Integer): Boolean;
- var i: Integer;
- begin
- Result := False;
- if WordPaintList<>nil then begin
- for i := WordPaintList.Count-1 downto 0 do
- if WordPaintList[i].StartOffs+WordPaintList[i].Length+1>Index+Count-1 then
- if WordPaintList[i].StartOffs<=Index+1 then begin
- WordPaintList.Delete(i);
- Result := True;
- end
- else
- dec(WordPaintList[i].StartOffs, Count);
- if WordPaintList.Count=0 then begin
- WordPaintList.Free;
- WordPaintList := nil;
- end;
- end;
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.GetMisspelling(Offs: Integer;
- var MisOffs, MisLength: Integer): Boolean;
- var i: Integer;
- begin
- Result := False;
- if WordPaintList<>nil then begin
- for i := WordPaintList.Count-1 downto 0 do
- if (WordPaintList[i].StartOffs+WordPaintList[i].Length+1>Offs) and
- (WordPaintList[i].StartOffs<=Offs) then begin
- Result := True;
- MisOffs := WordPaintList[i].StartOffs;
- MisLength := WordPaintList[i].Length;
- exit;
- end;
- end;
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.IsMisspelled(Index: Integer): Boolean;
- var i: Integer;
- begin
- Result := False;
- if WordPaintList<>nil then
- for i := 0 to WordPaintList.Count-1 do begin
- Result := (WordPaintList[i].StartOffs<=Index) and
- (WordPaintList[i].StartOffs+WordPaintList[i].Length>Index);
- if Result then
- exit;
- end;
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.ValidateMisspelledWord(const AItemText, AWord: String): Boolean;
- var i: Integer;
- painter: TRVWordPainter;
- begin
- Result := False;
- if WordPaintList<>nil then begin
- for i := WordPaintList.Count-1 downto 0 do begin
- painter := WordPaintList[i];
- if (painter is TRVWordMisspellPainter) and
- (Copy(AItemText, painter.StartOffs, painter.Length)=AWord) then begin
- WordPaintList.Delete(i);
- Result := True;
- end;
- end;
- if WordPaintList.Count=0 then begin
- WordPaintList.Free;
- WordPaintList := nil;
- end;
- end;
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.AddMisspelling(StartOffs, Length: Integer);
- var painter: TRVWordMisspellPainter;
- begin
- painter := TRVWordMisspellPainter.Create(StartOffs, Length);
- if WordPaintList=nil then
- WordPaintList := TRVWordPainterList.Create;
- WordPaintList.Add(painter)
- end;
- {$ENDIF}
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.Assign(Source: TCustomRVItemInfo);
- begin
- StyleNo := Source.StyleNo;
- ParaNo := Source.ParaNo;
- ItemOptions := Source.ItemOptions;
- {$IFNDEF RVDONOTUSEITEMHINTS}
- Hint := Source.Hint;
- {$ENDIF}
- // Checkpoint, JumpID and Tag are not assigned
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.TransferProperties(Source: TCustomRVItemInfo;
- RVData: TPersistent);
- begin
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.ReadRVFHeader(var P: PChar;
- RVData: TPersistent): Boolean;
- begin
- Result := True;
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.GetSameAsPrev: Boolean;
- begin
- Result := (rvioSameAsPrev in ItemOptions);
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.SetSameAsPrev(const Value: Boolean);
- begin
- if Value then begin
- Exclude(ItemOptions, rvioPageBreakBefore);
- Exclude(ItemOptions, rvioBR);
- Include(ItemOptions , rvioSameAsPrev);
- end
- else
- Exclude(ItemOptions, rvioSameAsPrev);
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.SetBR(Value: Boolean);
- begin
- if GetBoolValue(rvbpFullWidth) then
- Value := False;
- if Value then begin
- Exclude(ItemOptions, rvioSameAsPrev);
- Include(ItemOptions, rvioBR);
- end
- else
- Exclude(ItemOptions, rvioBR);
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.GetBR: Boolean;
- begin
- Result := (rvioBR in ItemOptions);
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.GetPageBreakBefore: Boolean;
- begin
- Result := (rvioPageBreakBefore in ItemOptions);
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.SetPageBreakBefore(const Value: Boolean);
- begin
- if Value then begin
- Exclude(ItemOptions, rvioSameAsPrev);
- Exclude(ItemOptions, rvioBR);
- Include(ItemOptions, rvioPageBreakBefore);
- end
- else
- Exclude(ItemOptions, rvioPageBreakBefore);
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.CanBeBorderStart: Boolean;
- begin
- Result := not (rvioSameAsPrev in ItemOptions) and
- not (rvioBR in ItemOptions)
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.ParaStart(CountBR: Boolean): Boolean;
- begin
- Result := not (rvioSameAsPrev in ItemOptions) and
- (CountBR or not (rvioBR in ItemOptions));
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.UpdatePaletteInfo(PaletteAction: TRVPaletteAction;
- ForceRecreateCopy: Boolean; Palette: HPALETTE; LogPalette: PLogPalette);
- begin
- // nothing to do here
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.AsImage: TGraphic;
- begin
- Result := nil;
- end;
- {------------------------------------------------------------------------------}
- {$IFNDEF RVDONOTUSEHTML}
- procedure TCustomRVItemInfo.SaveToHTML(Stream: TStream; RVData: TPersistent;
- ItemNo: Integer; const Text, Path: String; const imgSavePrefix: String;
- var imgSaveNo: Integer; CurrentFileColor: TColor;
- SaveOptions: TRVSaveOptions; UseCSS: Boolean; Bullets: TRVList);
- begin
- // nothing to do here
- end;
- {$ENDIF}
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.AsText(LineWidth: Integer; RVData: TPersistent;
- const Text, Path: String; TextOnly,Unicode: Boolean): String;
- begin
- Result := '';
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.OwnsControl(AControl: TControl): Boolean;
- begin
- Result := False;
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.GetSubRVDataAt(X,Y: Integer): TPersistent;
- begin
- Result := nil;
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.OwnsInplaceEditor(AEditor: TControl): Boolean;
- begin
- Result := False;
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.ReadRVFLine(const s: String; RVData: TPersistent;
- ReadType, LineNo, LineCount: Integer; var Name: String;
- var ReadMode: TRVFReadMode; var ReadState: TRVFReadState): Boolean;
- begin
- Result := True;
- SetExtraPropertyFromRVFStr(s);
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.SaveRVFHeaderTail(RVData: TPersistent): String;
- begin
- // nothing to do here
- Result := '';
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.GetRVFExtraPropertyCount: Integer;
- begin
- Result := 0;
- {$IFNDEF RVDONOTUSEITEMHINTS}
- if Hint<>'' then
- inc(Result);
- {$ENDIF}
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.SaveRVFExtraProperties(Stream: TStream);
- begin
- {$IFNDEF RVDONOTUSEITEMHINTS}
- if Hint<>'' then
- WriteRVFExtraStrPropertyStr(Stream, rvespHint, Hint);
- {$ENDIF}
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.SetExtraPropertyFromRVFStr(const Str: String);
- var PropName, PropValStr: String;
- PropVal: Integer;
- IntProp: TRVExtraItemProperty;
- StrProp: TRVExtraItemStrProperty;
- p: Integer;
- begin
- p := Pos('=', Str);
- if p=0 then
- exit;
- PropName := Copy(Str,1,p-1);
- PropValStr := Copy(Str,p+1, Length(Str));
- IntProp := GetRVFExtraIntPropertyByName(PropName);
- if IntProp<>rvepUnknown then begin
- PropVal := StrToIntDef(PropValStr,0);
- SetExtraIntProperty(IntProp, PropVal);
- end
- else begin
- StrProp := GetRVFExtraStrPropertyByName(PropName);
- if StrProp<>rvespUnknown then begin
- SetExtraStrProperty(StrProp, PropValStr);
- end
- else
- SetExtraCustomProperty(PropName,PropValStr);
- end;
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.SaveRVF(Stream: TStream; RVData: TPersistent;
- ItemNo, ParaNo: Integer; const Name: String; Part: TRVMultiDrawItemPart;
- ForceSameAsPrev: Boolean);
- begin
- // nothing to do here
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.SaveRTF(Stream: TStream; const Path: String;
- RVData: TPersistent; ItemNo: Integer; const Name: String; TwipsPerPixel: Double;
- Level: Integer; ColorList: TRVColorList;
- StyleToFont, ListOverrideOffsetsList1, ListOverrideOffsetsList2: TRVIntegerList;
- FontTable: TRVList);
- begin
- // nothing to do here
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.FillRTFTables(ColorList: TRVColorList;
- ListOverrideCountList: TRVIntegerList; RVData: TPersistent);
- begin
- // nothing to do here
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.PrintToBitmap(Bkgnd: TBitmap; Preview: Boolean;
- RichView: TRVScroller; dli: TRVDrawLineInfo; Part: Integer;
- ColorMode: TRVColorMode):Boolean;
- begin
- // nothing was printed
- Result := False;
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.Print(Canvas: TCanvas; x, y, x2: Integer;
- Preview, Correction: Boolean; const sad: TRVScreenAndDevice;
- RichView: TRVScroller; dli: TRVDrawLineInfo;
- Part: Integer; ColorMode: TRVColorMode;
- RVData: TPersistent);
- begin
- // nothing to do here
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.GetBoolValue(Prop: TRVItemBoolProperty): Boolean;
- begin
- case Prop of
- rvbpFullWidth,rvbpDisplayActiveState,rvbpDrawingChangesFont,
- rvbpCanSaveUnicode,rvbpAlwaysInText,rvbpImmediateControlOwner,
- rvbpResizable, rvbpResizeHandlesOutside, rvbpHasSubRVData,
- rvbpClickSelect, rvbpNoHTML_P:
- Result := False;
- else
- Result := True;
- end;
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.GetBoolValueEx(Prop: TRVItemBoolPropertyEx;
- RVStyle: TRVStyle): Boolean;
- begin
- case Prop of
- rvbpPrintToBMP:
- Result := True;
- else
- Result := False;
- end;
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.PaintFullWidth(Left, Right, Top: Integer;
- Canvas: TCanvas; State: TRVItemDrawStates; Style: TRVStyle;
- const ClipRect: TRect; dli: TRVDrawLineInfo);
- begin
- // nothing to do here
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.Paint(x, y: Integer; Canvas: TCanvas;
- State: TRVItemDrawStates; Style: TRVStyle; dli: TRVDrawLineInfo);
- begin
- // nothing to do here
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.GetImageHeight(RVStyle: TRVStyle): Integer;
- begin
- Result := 0;
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.GetImageWidth(RVStyle: TRVStyle): Integer;
- begin
- Result := 0;
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.GetBorderHeight: Integer;
- begin
- Result := 0;
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.GetBorderWidth: Integer;
- begin
- Result := 0;
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.MovingToUndoList(ItemNo: Integer;
- RVData, AContainerUndoItem: TObject);
- var s: String;
- begin
- s := TCustomRVFormattedData(RVData).GetItemText(ItemNo);
- TCustomRVData(RVData).ItemAction(rviaMovingToUndoList, Self, s, TCustomRVData(RVData));
- {$IFNDEF RVDONOTUSELIVESPELL}
- ClearWordPainters(0);
- {$ENDIF}
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.MovingFromUndoList(ItemNo: Integer; RVData: TObject);
- begin
- // nothing to do here
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.FinalizeUndoGroup;
- begin
- // nothing to do here
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.BeforeLoading(FileFormat: TRVLoadFormat);
- begin
- // nothing to do here // currently only fo RVF and RTF
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.AfterLoading(FileFormat: TRVLoadFormat);
- begin
- // nothing to do here // currently only fo RVF and RTF
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.MouseMove(Shift: TShiftState; X, Y, ItemNo: Integer;
- RVData: TObject): Boolean;
- var s,s2: String;
- pt: TPoint;
- begin
- if rvoShowItemHints in TCustomRVData(RVData).Options then begin
- s := TCustomRVData(RVData).GetAbsoluteRootData.GetItemHint(
- TCustomRVData(RVData), ItemNo, '');
- s2 := TCustomRVData(RVData).GetAbsoluteRootData.GetParentControl.Hint;
- TCustomRVData(RVData).GetAbsoluteRootData.GetParentControl.Hint := s;
- if s='' then
- Application.CancelHint
- else if s<>s2 then begin
- GetCursorPos(pt);
- {$IFDEF RICHVIEWDEF5}
- Application.ActivateHint(pt);
- {$ENDIF}
- end;
- end;
- Result := False; // default cursor;
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.MouseDown(Button: TMouseButton;
- Shift: TShiftState; X, Y, ItemNo: Integer; RVData: TObject): Boolean;
- begin
- Result := False; // default cursor;
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.MouseUp(Button: TMouseButton;
- Shift: TShiftState; X, Y, ItemNo: Integer; RVData: TObject): Boolean;
- begin
- Result := False; // default cursor;
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.GetMinWidth(sad: PRVScreenAndDevice; Canvas: TCanvas;
- RVData: TPersistent): Integer;
- begin
- Result := 20; // min width of doc - 20 pixels
- if sad<>nil then
- Result := MulDiv(Result, sad.ppixDevice, sad.ppixScreen);
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.DeselectPartial;
- begin
- // nothing to do here
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.BuildJumps(Left,Top: Integer; var StartJumpNo: Integer;
- jumps: TList);
- begin
- // nothing to do here
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.Focusing;
- begin
- // nothing to do here
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.MoveFocus(GoForward: Boolean;
- var TopLevelRVData: TPersistent; var TopLevelItemNo: Integer): Boolean;
- begin
- Result := False;
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.ClearFocus;
- begin
- // nothing to do here
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.Execute(RVData: TPersistent);
- begin
- // nothing to do here
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.AdjustFocusToControl(Control: TControl;
- var TopLevelRVData: TPersistent; var TopLevelItemNo: Integer):Boolean;
- begin
- Result := False;
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.PartiallySelected: Boolean;
- begin
- Result := False;
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.CanDeletePartiallySelected: Boolean;
- begin
- Result := False;
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.DeletePartiallySelected;
- begin
- // nothing to do here
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.ApplyStyleConversionToSubRVDatas(
- UserData: Integer; SelectedOnly: Boolean; ConvType: TRVEStyleConversionType);
- begin
- // nothing to do here
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.ApplyStyleConversion(RVData: TPersistent;
- ItemNo, UserData: Integer);
- begin
- // Currently, there is no difference between the implementation of
- // rvscTextStyleConversion and rvscTextStyleConversion
- ApplyStyleConversionToSubRVDatas(UserData, False, rvscTextStyleConversion);
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.CreatePrintingDrawItem(RVData: TObject;
- const sad: TRVScreenAndDevice): TRVDrawLineInfo;
- begin
- Result := TRVDrawLineInfo.Create;
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.StartExport;
- begin
- // nothing to do here
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.EndExport;
- begin
- // nothing to do here
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.Inserting(RVData: TObject; var Text: String; Safe: Boolean);
- begin
- if RVData<>nil then
- TCustomRVData(RVData).ItemAction(rviaInserting, Self, Text, TCustomRVData(RVData));
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.Inserted(RVData: TObject; ItemNo: Integer);
- var s: String;
- begin
- if RVData<>nil then begin
- {$IFNDEF RVDONOTUSEANIMATION}
- UpdateAnimator(RVData);
- {$ENDIF}
- s := '';
- TCustomRVData(RVData).ItemAction(rviaInserted, Self, s, TCustomRVData(RVData));
- end;
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.AfterUndoChangeProperty;
- begin
- // nothing to do here
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.BeforeUndoChangeProperty;
- begin
- // nothing to do here
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.EnterItem(From: TRVEnterDirection; Coord: Integer): Boolean;
- begin
- Result := False;
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.GetHypertextCursor(RVStyle: TRVStyle): TCursor;
- begin
- Result := RVStyle.JumpCursor;
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.OnDocWidthChange(DocWidth: Integer;
- dli: TRVDrawLineInfo; Printing: Boolean; Canvas: TCanvas;
- RVData: TPersistent; sad: PRVScreenAndDevice; var HShift, Desc: Integer;
- NoCaching, Reformatting: Boolean);
- begin
- HShift := 0;
- Desc := 1;
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.MarkStylesInUse(Data: TRVDeleteUnusedStylesData);
- begin
- Data.UsedParaStyles[ParaNo] := 1;
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.UpdateStyles(Data: TRVDeleteUnusedStylesData);
- begin
- dec(ParaNo, Data.UsedParaStyles[ParaNo]-1);
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.GetSubRVData(var StoreState: TRVStoreSubRVData;
- Position: TRVSubRVDataPos): TPersistent;
- begin
- Result := nil;
- StoreState := nil;
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.ChooseSubRVData(StoreState: TRVStoreSubRVData);
- begin
- // nothing to do here
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.CleanUpChosen;
- begin
- // nothing to do here
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.ResetSubCoords;
- begin
- // nothing to do here
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.SetExtraIntProperty(Prop: TRVExtraItemProperty; Value: Integer): Boolean;
- begin
- Result := False;
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.GetExtraIntProperty(Prop: TRVExtraItemProperty; var Value: Integer): Boolean;
- begin
- Result := False;
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.GetExtraStrProperty(Prop: TRVExtraItemStrProperty;
- var Value: String): Boolean;
- begin
- Result := False;
- {$IFNDEF RVDONOTUSEITEMHINTS}
- case Prop of
- rvespHint:
- begin
- Value := Hint;
- Result := True;
- end;
- end;
- {$ENDIF}
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.SetExtraStrProperty(Prop: TRVExtraItemStrProperty;
- const Value: String): Boolean;
- begin
- Result := False;
- {$IFNDEF RVDONOTUSEITEMHINTS}
- case Prop of
- rvespHint:
- begin
- Hint := Value;
- Result := True;
- end;
- end;
- {$ENDIF}
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.GetSoftPageBreakDY(Data: Integer): Integer;
- begin
- Result := Data;
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.SetExtraCustomProperty(const PropName,
- Value: String): Boolean;
- begin
- Result := False;
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.DrawBackgroundForPrinting(Canvas: TCanvas;
- const Rect, FullRect: TRect; ColorMode: TRVColorMode;
- ItemBackgroundLayer: Integer);
- begin
- // This method is only for items containing subdocuments, i.e. tables.
- // Used for drawing background in bitmap
- // ItemBackgroundLayer: 0 - do not draw; -1 - draw completely; others - item specific
- end;
- {------------------------------------------------------------------------------}
- {$IFNDEF RVDONOTUSEANIMATION}
- procedure TCustomRVItemInfo.UpdateAnimator(RVData: TObject);
- begin
- end;
- {$ENDIF}
- {------------------------------------------------------------------------------}
- function TCustomRVItemInfo.GetActualStyleNo(RVStyle: TRVStyle): Integer;
- begin
- Result := StyleNo;
- if Result=rvsDefStyle then begin
- if RVStyle.ParaStyles[ParaNo].DefStyleNo>=0 then
- Result := RVStyle.ParaStyles[ParaNo].DefStyleNo
- else
- Result := 0;
- end;
- end;
- {------------------------------------------------------------------------------}
- // For non-text items, can return the associated text style. It will be used
- // for saving in RTF and HTML
- function TCustomRVItemInfo.GetAssociatedTextStyleNo: Integer;
- begin
- Result := -1;
- end;
- {------------------------------------------------------------------------------}
- procedure TCustomRVItemInfo.SetAssociatedTextStyleNo(Value: Integer);
- begin
- end;
- {============================= TRVNonTextItemInfo =============================}
- procedure TRVNonTextItemInfo.AdjustInserted(x, y: Integer; adjusty: Boolean);
- begin
- // nothing to do here
- end;
- {------------------------------------------------------------------------------}
- function TRVNonTextItemInfo.GetHeight: Integer;
- begin
- Result := 0;
- end;
- {------------------------------------------------------------------------------}
- function TRVNonTextItemInfo.GetWidth: Integer;
- begin
- Result := 0;
- end;
- {------------------------------------------------------------------------------}
- function TRVNonTextItemInfo.GetLeftOverhang: Integer;
- begin
- Result := 0;
- end;
- {------------------------------------------------------------------------------}
- procedure TRVNonTextItemInfo.Assign(Source: TCustomRVItemInfo);
- begin
- if Source is TRVNonTextItemInfo then begin
- DeleteProtect := TRVNonTextItemInfo(Source).DeleteProtect;
- end;
- inherited;
- end;
- {------------------------------------------------------------------------------}
- function TRVNonTextItemInfo.GetExtraIntProperty(Prop: TRVExtraItemProperty;
- var Value: Integer): Boolean;
- begin
- case Prop of
- rvepDeleteProtect:
- begin
- Value := ord(DeleteProtect);
- Result := True;
- end;
- else
- Result := inherited GetExtraIntProperty(Prop, Value);
- end;
- end;
- {------------------------------------------------------------------------------}
- function TRVNonTextItemInfo.SetExtraIntProperty(Prop: TRVExtraItemProperty;
- Value: Integer): Boolean;
- begin
- case Prop of
- rvepDeleteProtect:
- begin
- DeleteProtect := Value<>0;
- Result := True;
- end;
- else
- Result := inherited SetExtraIntProperty(Prop, Value);
- end;
- end;
- {------------------------------------------------------------------------------}
- function TRVNonTextItemInfo.GetRVFExtraPropertyCount: Integer;
- begin
- Result := inherited GetRVFExtraPropertyCount;
- if DeleteProtect then
- inc(Result);
- end;
- {------------------------------------------------------------------------------}
- procedure TRVNonTextItemInfo.SaveRVFExtraProperties(Stream: TStream);
- begin
- inherited;
- if DeleteProtect then
- WriteRVFExtraIntPropertyStr(Stream, rvepDeleteProtect, ord(DeleteProtect));
- end;
- {=========================== TRVFullLineItemInfo ==============================}
- function TRVFullLineItemInfo.GetBoolValue(Prop: TRVItemBoolProperty): Boolean;
- begin
- case Prop of
- rvbpFullWidth:
- Result := True;
- else
- Result := inherited GetBoolValue(Prop);
- end;
- end;
- {=============================== TRVRectItemInfo ==============================}
- constructor TRVRectItemInfo.Create(RVData: TPersistent);
- begin
- inherited Create(RVData);
- Spacing := 1;
- end;
- {------------------------------------------------------------------------------}
- procedure TRVRectItemInfo.Assign(Source: TCustomRVItemInfo);
- begin
- if Source is TRVRectItemInfo then begin
- FMinHeightOnPage := TRVRectItemInfo(Source).FMinHeightOnPage;
- VAlign := TRVRectItemInfo(Source).VAlign;
- VShift := TRVRectItemInfo(Source).VShift;
- VShiftAbs := TRVRectItemInfo(Source).VShiftAbs;
- Spacing := TRVRectItemInfo(Source).Spacing;
- end;
- inherited Assign(Source);
- end;
- {------------------------------------------------------------------------------}
- function TRVRectItemInfo.GetDescent: Integer;
- begin
- Result := Spacing;
- end;
- {------------------------------------------------------------------------------}
- function TRVRectItemInfo.GetBorderHeight: Integer;
- begin
- Result := Spacing;
- end;
- {------------------------------------------------------------------------------}
- function TRVRectItemInfo.GetBorderWidth: Integer;
- begin
- Result := Spacing;
- end;
- {------------------------------------------------------------------------------}
- function TRVRectItemInfo.ReadRVFHeader(var P: PChar;
- RVData: TPersistent): Boolean;
- var va: Integer;
- begin
- Result := True;
- if not (P^ in [#0, #10, #13]) then begin
- Result := RVFReadInteger(P,va);
- if Result then
- VAlign := TRVVAlign(va);
- end
- else
- VAlign := rvvaBaseLine;
- end;
- {------------------------------------------------------------------------------}
- function TRVRectItemInfo.SaveRVFHeaderTail(RVData: TPersistent): String;
- begin
- Result := IntToStr(ord(VAlign));
- end;
- {------------------------------------------------------------------------------}
- function TRVRectItemInfo.GetRVFExtraPropertyCount: Integer;
- begin
- Result := inherited GetRVFExtraPropertyCount;
- if VShift<>0 then
- inc(Result);
- if VShiftAbs then
- inc(Result);
- if Spacing<>1 then
- inc(Result);
- end;
- {------------------------------------------------------------------------------}
- procedure TRVRectItemInfo.SaveRVFExtraProperties(Stream: TStream);
- begin
- inherited;
- if VShift<>0 then
- WriteRVFExtraIntPropertyStr(Stream, rvepVShift, VShift);
- if VShiftAbs then
- WriteRVFExtraIntPropertyStr(Stream, rvepVShiftAbs, 1);
- if Spacing<>1 then
- WriteRVFExtraIntPropertyStr(Stream, rvepSpacing, Spacing);
- end;
- {------------------------------------------------------------------------------}
- function TRVRectItemInfo.GetVShiftCSS(RVStyle: TRVStyle): String;
- begin
- Result := '';
- if (VShift=0) or (GetImageHeight(RVStyle)=0) or (VAlign<>rvvaBaseLine) then
- exit;
- if VShiftAbs then
- Result := Format('vertical-align : %d', [VShift])
- else
- Result := Format('vertical-align : %d', [MulDiv(GetImageHeight(RVStyle),VShift,100)])
- end;
- {------------------------------------------------------------------------------}
- function TRVRectItemInfo.SetExtraIntProperty(Prop: TRVExtraItemProperty; Value: Integer): Boolean;
- begin
- Result := True;
- case Prop of
- rvepVShift:
- VShift := Value;
- rvepVShiftAbs:
- VShiftAbs := Value<>0;
- rvepSpacing:
- begin
- Spacing := Value;
- if Spacing<0 then
- Spacing := 0;
- end;
- else
- Result := inherited SetExtraIntProperty(Prop, Value);
- end;
- end;
- {------------------------------------------------------------------------------}
- function TRVRectItemInfo.GetExtraIntProperty(Prop: TRVExtraItemProperty; var Value: Integer): Boolean;
- begin
- Result := True;
- case Prop of
- rvepVShift:
- Value := VShift;
- rvepVShiftAbs:
- Value := ord(VShiftAbs);
- rvepSpacing:
- Value := Spacing;
- else
- Result := inherited GetExtraIntProperty(Prop, Value);
- end;
- end;
- {================================ TRVControlItemInfo ==========================}
- constructor TRVControlItemInfo.CreateEx(RVData: TPersistent; AControl: TControl; AVAlign: TRVVAlign);
- begin
- inherited Create(RVData);
- StyleNo := rvsComponent;
- Control := AControl;
- VAlign := AVAlign;
- FVisible := True;
- end;
- {------------------------------------------------------------------------------}
- constructor TRVControlItemInfo.Create(RVData: TPersistent);
- begin
- inherited Create(RVData);
- StyleNo := rvsComponent;
- FVisible := True;
- end;
- {------------------------------------------------------------------------------}
- destructor TRVControlItemInfo.Destroy;
- begin
- Control.Free;
- inherited Destroy;
- end;
- {------------------------------------------------------------------------------}
- procedure TRVControlItemInfo.Assign(Source: TCustomRVItemInfo);
- begin
- if Source is TRVControlItemInfo then begin
- PercentWidth := TRVControlItemInfo(Source).PercentWidth;
- FResizable := TRVControlItemInfo(Source).FResizable;
- FVisible := TRVControlItemInfo(Source).FVisible;
- end;
- inherited Assign(Source);
- end;
- {------------------------------------------------------------------------------}
- procedure TRVControlItemInfo.AdjustInserted(x, y: Integer; adjusty: Boolean);
- begin
- Control.Left := x+Spacing;
- Control.Tag := y+Spacing;
- if adjusty then
- RV_Tag2Y(Control);
- Control.Visible := FVisible;
- end;
- {------------------------------------------------------------------------------}
- function TRVControlItemInfo.GetHeight: Integer;
- begin
- Result := Control.Height+Spacing*2;
- end;
- {------------------------------------------------------------------------------}
- function TRVControlItemInfo.GetImageHeight(RVStyle: TRVStyle): Integer;
- begin
- Result := Control.Height;
- end;
- {------------------------------------------------------------------------------}
- function TRVControlItemInfo.GetWidth: Integer;
- begin
- Result := Control.Width+Spacing*2;
- end;
- {------------------------------------------------------------------------------}
- function TRVControlItemInfo.GetImageWidth(RVStyle: TRVStyle): Integer;
- begin
- Result := Control.Width;
- end;
- {------------------------------------------------------------------------------}
- function TRVControlItemInfo.GetMinWidth(sad: PRVScreenAndDevice; Canvas: TCanvas;
- RVData: TPersistent): Integer;
- begin
- if PercentWidth<>0 then
- Result := 20
- else
- Result := Control.Width+Spacing*2;
- if sad<>nil then
- Result := MulDiv(Result, sad.ppixDevice, sad.ppixScreen);
- end;
- {------------------------------------------------------------------------------}
- function TRVControlItemInfo.CreatePrintingDrawItem(RVData: TObject; const sad: TRVScreenAndDevice): TRVDrawLineInfo;
- begin
- if not GetBoolValueEx(rvbpPrintToBMP, nil) or (MinHeightOnPage=0) then begin
- Result := TRVDrawLineInfo.Create;
- exit;
- end;
- Result := TRVMultiImagePrintInfo.Create(Self);
- Result.Width := MulDiv(GetWidth, sad.ppixDevice, sad.ppixScreen);
- Result.Height := MulDiv(GetHeight, sad.ppiyDevice, sad.ppiyScreen);
- TRVMultiImagePrintInfo(Result).sad := sad;
- end;
- {------------------------------------------------------------------------------}
- function TRVControlItemInfo.PrintToBitmap(Bkgnd: TBitmap; Preview: Boolean;
- RichView: TRVScroller; dli: TRVDrawLineInfo; Part: Integer;
- ColorMode: TRVColorMode): Boolean;
- var ctrlbmp: TBitmap;
- Top: Integer;
- begin
- Result := False;
- if not FVisible then
- exit;
- ctrlbmp := nil;
- if Assigned(TPrintableRV(RichView).RVPrint.OnPrintComponent) then
- TPrintableRV(RichView).RVPrint.OnPrintComponent(TPrintableRV(RichView).RVPrint, Control, ctrlbmp)
- else
- ctrlbmp := DrawControl(Control);
- if (dli is TRVMultiImagePrintInfo) and (Part>=0) then
- Top := -TRVImagePrintPart(TRVMultiImagePrintInfo(dli).PartsList[Part]).ImgTop
- else
- Top := 0;
- if (ctrlbmp<>nil) then
- try
- Result := True;
- if MinHeightOnPage<=0 then begin
- if ctrlbmp.Width>bkgnd.Width then
- bkgnd.Width := ctrlbmp.Width;
- if ctrlbmp.Height>bkgnd.Height then
- bkgnd.Height := ctrlbmp.Height;
- Bkgnd.Canvas.Draw((Bkgnd.Width-ctrlbmp.Width) div 2,
- (Bkgnd.Height-ctrlbmp.Height) div 2, ctrlbmp);
- end
- else
- Bkgnd.Canvas.Draw(0, Top, ctrlbmp);
- finally
- ctrlbmp.Free;
- end;
- end;
- {------------------------------------------------------------------------------}
- procedure TRVControlItemInfo.Paint(x, y: Integer; Canvas: TCanvas;
- State: TRVItemDrawStates; Style: TRVStyle; dli: TRVDrawLineInfo);
- begin
- if not FVisible then
- exit;
- if (rvidsCurrent in State) and (Style.CurrentItemColor<>clNone) then begin
- Canvas.Pen.Width := 1;
- Canvas.Pen.Color := Style.CurrentItemColor;
- Canvas.Pen.Style := psSolid;
- Canvas.Rectangle(x-1,y-1,
- x+Control.Width+Spacing*2+1, y+Control.Height+Spacing*2+1);
- end;
- if (rvidsSelected in State) then begin
- if rvidsControlFocused in State then
- Canvas.Pen.Color := Style.SelColor
- else
- Canvas.Pen.Color := Style.InactiveSelColor;
- if Canvas.Pen.Color<>clNone then begin
- Canvas.Pen.Width := 1;
- Canvas.Pen.Style := psSolid;
- Canvas.Rectangle(x,y,
- x+Control.Width+Spacing*2, y+Control.Height+Spacing*2);
- end;
- end
- end;
- {------------------------------------------------------------------------------}
- function TRVControlItemInfo.OwnsControl(AControl: TControl): Boolean;
- begin
- Result := (AControl=Control);
- end;
- {------------------------------------------------------------------------------}
- {$IFNDEF RVDONOTUSEHTML}
- procedure TRVControlItemInfo.SaveToHTML(Stream: TStream; RVData: TPersistent;
- ItemNo: Integer; const Text, Path: String; const imgSavePrefix: String;
- var imgSaveNo: Integer; CurrentFileColor: TColor; SaveOptions: TRVSaveOptions;
- UseCSS: Boolean; Bullets: TRVList);
- var s: String;
- begin
- s := TCustomRVData(RVData).SaveComponentToFile(Path, Control, rvsfHTML);
- if s<>'' then
- RVWrite(Stream,s);
- end;
- {$ENDIF}
- {------------------------------------------------------------------------------}
- function TRVControlItemInfo.ReadRVFLine(const s: String;
- RVData: TPersistent; ReadType, LineNo, LineCount: Integer;
- var Name: String; var ReadMode: TRVFReadMode;
- var ReadState: TRVFReadState): Boolean;
- var ControlClass: TControlClass;
- begin
- Result := True;
- case ReadType of
- 1: // ask owner
- begin
- case LineNo of
- 0:
- begin
- Name := s;
- Control := TCustomRVData(RVData).RVFControlNeeded(s, Tag);