📄 rvervdata.pas
字号:
propinfo := GetPropInfo(SubObject.ClassInfo, PropList[i]);
OldValue := GetOrdProp(SubObject, propinfo);
NewValue := LongInt(PropList.Objects[i]);
if OldValue<>NewValue then begin
if ui<>nil then
ui.PropList.AddObject(PropList[i], TObject(OldValue));
SetOrdProp(SubObject, propinfo, NewValue);
end;
end;
finally
item.AfterUndoChangeProperty;
end;
if ui<>nil then begin
if ui.PropList.Count=0 then begin
ui.Free;
ui := nil;
end
else
List.AddInfo(ui);
end;
Result := ui;
end;
{------------------------------------------------------------------------------}
procedure TRVEditRVData.Do_NewLine(ItemNo: Integer; SameAsPrev: Boolean;
ParaNo: Integer;
var FullReformat: Boolean);
var item: TCustomRVItemInfo;
List: TRVUndoList;
ui: TRVUndoNewLineInfo;
LastAffectedItemNo: Integer;
FR: Boolean;
begin
FullReformat := False;
item := GetItem(ItemNo);
if Item.GetBoolValue(rvbpFullWidth) then
exit;
if not SameAsPrev and (item.SameAsPrev = SameAsPrev) then exit;
if SameAsPrev then begin
Do_BR(ItemNo, False, FR);
FullReformat := FullReformat or FR;
Do_PageBreak(ItemNo, False);
end;
if (ItemNo<Items.Count-1) and
not GetItem(ItemNo+1).CanBeBorderStart then
LastAffectedItemNo := GetParaEndItemNo(ItemNo+1)
else
LastAffectedItemNo := -1;
List := GetUndoList;
if List<>nil then begin
ui := TRVUndoNewLineInfo.Create;
ui.Action := rvuNewLine;
ui.ItemNo := ItemNo;
ui.WasSameAsPrev := item.SameAsPrev;
ui.WasParaNo := item.ParaNo;
ui.LastAffectedItemNo := LastAffectedItemNo;
List.AddInfo(ui);
end;
if LastAffectedItemNo=-1 then
LastAffectedItemNo := ItemNo;
if SameAsPrev then begin
if ItemNo>0 then begin
Do_Para(ItemNo,LastAffectedItemNo,
GetItemPara(ItemNo-1), FR);
FullReformat := FullReformat or FR;
end
end
else begin
if ParaNo<>-1 then begin
Do_Para(ItemNo,LastAffectedItemNo, ParaNo, FR);
FullReformat := FullReformat or FR;
end;
end;
item.SameAsPrev := SameAsPrev;
end;
{------------------------------------------------------------------------------}
procedure TRVEditRVData.Do_BR(ItemNo: Integer; BR: Boolean; var FullReformat: Boolean);
var item: TCustomRVItemInfo;
List: TRVUndoList;
ui: TRVUndoBRInfo;
OldWidth, NewWidth: Integer;
begin
FullReformat := False;
item := GetItem(ItemNo);
if item.SameAsPrev or item.BR=BR then
exit;
OldWidth := CalculateMinItemWidthPlusEx(ItemNo);
List := GetUndoList;
if List<>nil then begin
ui := TRVUndoBRInfo.Create;
ui.Action := rvuBR;
ui.ItemNo := ItemNo;
ui.WasBR := item.BR;
List.AddInfo(ui);
end;
item.BR := BR;
NewWidth := CalculateMinItemWidthPlusEx(ItemNo);
FullReformat := (OldWidth<>NewWidth) and
((NewWidth>DocumentWidth) or
(OldWidth>=DocumentWidth));
end;
{------------------------------------------------------------------------------}
procedure TRVEditRVData.Do_PageBreak(ItemNo: Integer; PageBreak: Boolean);
var item: TCustomRVItemInfo;
List: TRVUndoList;
ui: TRVUndoPageBreakInfo;
begin
{$IFNDEF RVDONOTUSELISTS}
if (ItemNo>0) and (GetItemStyle(ItemNo-1)=rvsListMarker) then
dec(ItemNo);
{$ENDIF}
item := GetItem(ItemNo);
if item.SameAsPrev or item.PageBreakBefore=PageBreak then
exit;
List := GetUndoList;
if List<>nil then begin
ui := TRVUndoPageBreakInfo.Create;
ui.Action := rvuPageBreak;
ui.ItemNo := ItemNo;
ui.WasPageBreak := item.PageBreakBefore;
List.AddInfo(ui);
end;
item.PageBreakBefore := PageBreak;
end;
{------------------------------------------------------------------------------}
procedure TRVEditRVData.Do_ExtraIntProperty(ItemNo: Integer; Prop: TRVExtraItemProperty; Value: Integer);
var item: TCustomRVItemInfo;
List: TRVUndoList;
ui: TRVUndoExtraIntProperty;
OldValue: Integer;
begin
item := GetItem(ItemNo);
if not item.GetExtraIntProperty(Prop,OldValue) or (OldValue=Value) then
exit;
List := GetUndoList;
if List<>nil then begin
ui := TRVUndoExtraIntProperty.Create;
ui.Action := rvuModifyItem;
ui.ItemNo := ItemNo;
ui.OldValue := OldValue;
ui.Prop := Prop;
List.AddInfo(ui);
end;
item.SetExtraIntProperty(Prop, Value);
end;
{------------------------------------------------------------------------------}
procedure TRVEditRVData.Do_Tag(ItemNo, Tag: Integer; AssignAsIs: Boolean);
var item: TCustomRVItemInfo;
List: TRVUndoList;
ui: TRVUndoTagInfo;
begin
item := GetItem(ItemNo);
if Tag=item.Tag then exit;
List := GetUndoList;
if List<>nil then begin
ui := TRVUndoTagInfo.Create;
ui.Action := rvuTag;
ui.ItemNo := ItemNo;
ui.WasTag := RV_CopyTag(item.Tag, rvoTagsArePChars in Options);
ui.TagsArePChars := rvoTagsArePChars in Options;
List.AddInfo(ui);
end;
if rvoTagsArePChars in Options then
StrDispose(PChar(item.Tag));
if AssignAsIs then
item.Tag := Tag
else
item.Tag := RV_CopyTag(Tag, rvoTagsArePChars in Options);
end;
{------------------------------------------------------------------------------}
procedure TRVEditRVData.Do_AddCP(ItemNo: Integer; Checkpoint: TRVCPInfo);
var item: TCustomRVItemInfo;
List: TRVUndoList;
ui: TRVUndoAddCPInfo;
begin
if ItemNo<>-1 then begin
item := GetItem(ItemNo);
if item.Checkpoint<>nil then
raise ERichViewError.Create(errRVCP);
end
else begin
item := nil;
if NotAddedCP<>nil then
raise ERichViewError.Create(errRVCP);
end;
if Checkpoint=nil then exit;
List := GetUndoList;
if List<>nil then begin
ui := TRVUndoAddCPInfo.Create;
ui.Action := rvuCheckpoint;
ui.ItemNo := ItemNo;
List.AddInfo(ui);
end;
if item<>nil then begin
item.Checkpoint := Checkpoint;
Checkpoint.ItemInfo := item;
end
else begin
NotAddedCP := Checkpoint;
Checkpoint.ItemInfo := nil;
end;
inc(CPCount);
UpdateCPPos(Checkpoint, ItemNo);
end;
{------------------------------------------------------------------------------}
procedure TRVEditRVData.Do_DeleteCP(ItemNo: Integer);
var item: TCustomRVItemInfo;
List: TRVUndoList;
ui: TRVUndoDeleteCPInfo;
CP: TRVCPInfo;
begin
if ItemNo<>-1 then begin
item := GetItem(ItemNo);
CP := item.Checkpoint;
end
else begin
item := nil;
CP := NotAddedCP;
end;
if CP=nil then
raise ERichViewError.Create(errRVCP);
List := GetUndoList;
if List<>nil then begin
ui := TRVUndoDeleteCPInfo.Create;
ui.Action := rvuCheckpoint;
ui.ItemNo := ItemNo;
ui.Checkpoint := CP;
ui.TagsArePChars := rvoTagsArePChars in Options;
List.AddInfo(ui);
UnlinkCheckpoint(CP,True);
end
else
FreeCheckpoint(CP,True,True);
if item<>nil then
item.Checkpoint := nil
else
NotAddedCP := nil;
end;
{------------------------------------------------------------------------------}
procedure TRVEditRVData.Do_Concate(FirstItemNo: Integer);
var // FullReformat,
FR: Boolean;
StyleNo: Integer;
SAP, BR: Boolean;
item: TCustomRVItemInfo;
CP: TRVCPInfo;
begin
// FullReformat := False;
if ((rvioUnicode in GetItemOptions(FirstItemNo))<>
(rvioUnicode in GetItemOptions(FirstItemNo+1))) and
(Items[FirstItemNo+1]<>'') then begin
item := GetItem(FirstItemNo);
BR := item.BR;
SAP := item.SameAsPrev;
if not SAP then begin
Do_NewLine(FirstItemNo+1, False, item.ParaNo, FR);
// FullReformat := FullReformat or FR;
end;
if BR then begin
Do_BR(FirstItemNo+1, True, FR);
// FullReformat := FullReformat or FR;
end;
if (GetItemCheckpoint(FirstItemNo)<>nil) and
(GetItemCheckpoint(FirstItemNo+1)=nil) then begin
CP := TRVCPInfo.Create;
CP.Assign(GetItemCheckpoint(FirstItemNo), rvoTagsArePChars in Options);
Do_AddCP(FirstItemNo+1, CP);
end;
Do_DeleteItem(FirstItemNo,FR);
// FullReformat := FullReformat or FR;
end
else begin
if Items[FirstItemNo]='' then
StyleNo := GetItemStyle(FirstItemNo+1)
else
StyleNo := -1;
Do_InsertSubstring(FirstItemNo, ItemLength(FirstItemNo)+1,Items[FirstItemNo+1]);
if (GetItemCheckpoint(FirstItemNo+1)<>nil) and
(GetItemCheckpoint(FirstItemNo)=nil) then begin
CP := TRVCPInfo.Create;
CP.Assign(GetItemCheckpoint(FirstItemNo+1), rvoTagsArePChars in Options);
Do_AddCP(FirstItemNo, CP);
end;
Do_DeleteItem(FirstItemNo+1, FR);
// FullReformat := FullReformat or FR;
if StyleNo<>-1 then
Do_StyleNo(FirstItemNo, StyleNo);
end;
// assuming FullReformat=False for text
end;
{------------------------------------------------------------------------------}
function TRVEditRVData.InsSomething(var info: TCustomRVItemInfo;
var s: String;
AutoTag: Boolean;
var InsertPoint, ItemsAdded: Integer;
var FullReformat: Boolean;
var NewListNo: Integer): Boolean;
{.............................................................}
procedure AdjustTag(cur: TCustomRVItemInfo);
begin
if AutoTag and (info.Tag=0) and (info.StyleNo>=0) and (info.StyleNo=cur.StyleNo) then
info.Tag := RV_CopyTag(cur.Tag, rvoTagsArePChars in Options)
end;
{.............................................................}
// Inserting before or after non-text item.
// If inserting a full-line item before the first item in bulleted paragraph,
// inserting a empty string before, so result will look like
// {bullet} {empty string (added)}
// {new full-line item}
// Special case: marker can be inserted only in place of empty line,
// not here
procedure IS_InsertNearNonText(CharPos: TRVCharPos;
dli: TRVDrawLineInfo;
var ItemParaNo: Integer;
var InsertPoint: Integer;
var ItemsAdded: Integer;
var FullReformat: Boolean);
var FR: Boolean;
begin
{$IFNDEF RVDONOTUSELISTS}
if info.StyleNo=rvsListMarker then begin
Result := True;
info.Free;
info := nil;
exit;
end;
{$ENDIF}
if CharPos.Offset=0 then begin // inserting before nontext
InsertPoint := dli.ItemNo;
if not GetItem(InsertPoint).SameAsPrev then begin
info.SameAsPrev := False;
info.BR := GetItem(InsertPoint).BR;
if info.BR then
ItemParaNo := -1;
if GetItem(InsertPoint).PageBreakBefore then
info.PageBreakBefore := True;
Do_NewLine(InsertPoint, True, -1, FR);
FullReformat := FullReformat or FR;
end
else begin
ItemParaNo := -1;
{$IFNDEF RVDONOTUSELISTS}
if info.GetBoolValue(rvbpFullWidth) and
(InsertPoint>0) and (GetItemStyle(InsertPoint-1)=rvsListMarker) then begin
InsEmptyString(InsertPoint, 0, GetItemPara(InsertPoint), FCurTextStyleNo, True, False);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -