📄 rvitem.pas
字号:
Result := False;
exit;
end;
if PartsList.Count=0 then
raise ERichViewError.Create(errPrint);
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 RVFExtraItemPropNames: array [TRVExtraItemProperty] of String =
('', 'vshift', 'vshiftabs', 'width', 'height', 'transparent', 'tmode', 'tcolor', 'minheightonpage');
function GetRVFExtraPropertyByName(const PropName: String):TRVExtraItemProperty;
var i: TRVExtraItemProperty;
begin
Result := rvepUnknown;
for i := Low(TRVExtraItemProperty) to High(TRVExtraItemProperty) do
if RVFExtraItemPropNames[i]=PropName then begin
Result := i;
exit;
end;
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}
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): TCustomRVItemInfo;
var TagsArePChars: Boolean;
begin
TagsArePChars := rvoTagsArePChars in TCustomRVData(RVData).Options;
Result := TCustomRVItemInfoClass(Source.ClassType).Create(RVData);
Result.Assign(Source);
if Source.Checkpoint<>nil then begin
Result.Checkpoint := TRVCPInfo.Create;
Result.Checkpoint.Assign(Source.Checkpoint, TagsArePChars);
end;
Result.Tag := RV_CopyTag(Source.Tag, TagsArePChars)
end;
{------------------------------------------------------------------------------}
function GetHTMLImageAlign(Align: TRVVAlign): String;
begin
case Align of
rvvaMiddle:
Result := ' align=middle';
else
Result := '';
end;
end;
{======================= TCustomRVItemInfo ====================================}
constructor TCustomRVItemInfo.Create;
begin
inherited Create;
DrawItemNo := -1;
end;
{------------------------------------------------------------------------------}
procedure TCustomRVItemInfo.Assign(Source: TCustomRVItemInfo);
begin
StyleNo := Source.StyleNo;
ParaNo := Source.ParaNo;
ItemOptions := Source.ItemOptions;
// Checkpoint, JumpID and Tag are not assigned
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;
{------------------------------------------------------------------------------}
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;
{------------------------------------------------------------------------------}
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;
end;
{------------------------------------------------------------------------------}
function TCustomRVItemInfo.SaveRVFHeaderTail(RVData: TPersistent): String;
begin
// nothing to do here
Result := '';
end;
{------------------------------------------------------------------------------}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -