OfficeVba/docx/border/TSDocxBorderTable.tsf

188 lines
5.4 KiB
Plaintext

Type TSDocxBorderTable = Class(TSDocxBorder)
Uses TSDocxEnumerations;
public
Function Init(table, borderType);
private
Function CallFunction(pf, value);overload;
Function CallFunction(pf);overload;
public
Function WriteVisible(value);override;
Function ReadVisible();override;
Function WriteLineWidth(value);override;
Function ReadLineWidth();override;
Function WriteLineStyle(value);override;
Function ReadLineStyle();override;
Function WriteColorIndex(value);override;
Function ReadColorIndex();override;
Function WriteColor(value);override;
Function ReadColor();override;
Function WriteArtWidth(value);override;
Function ReadArtWidth();override;
Function WriteArtStyle(value);override;
Function ReadArtStyle();override;
private
table_;
border_type_;
cell_border_; // 对角线只需要处理cell
End;
// ============== 实现 ================= //
Function TSDocxBorderTable.Init(table, borderType);
Begin
table_ := table;
border_type_ := borderType;
cell_border_ := false;
case border_type_ of
TSDocxEnumerations.wdBorderBottom():
border_ := table_.TblPr.Borders.Bottom;
TSDocxEnumerations.wdBorderHorizontal():
border_ := table_.TblPr.Borders.InsideH;
TSDocxEnumerations.wdBorderLeft():
border_ := table_.TblPr.Borders.Left;
TSDocxEnumerations.wdBorderRight():
border_ := table_.TblPr.Borders.Right;
TSDocxEnumerations.wdBorderTop():
border_ := table_.TblPr.Borders.Top;
TSDocxEnumerations.wdBorderVertical():
border_ := table_.TblPr.Borders.InsideV;
TSDocxEnumerations.wdBorderDiagonalDown(),
TSDocxEnumerations.wdBorderDiagonalUp():
cell_border_ := true;
end;
End;
Function TSDocxBorderTable.CallFunction(pf, value);overload;
Begin
// 对角线时候只需要处理cell
if cell_border_ then
begin
for r:=1 to table_.Rows() do
begin
for c:=1 to table_.Cols() do
begin
cell_obj := new TSDocxCell(self.Application, self.Creator, self.Parent);
cell_obj.Init(nil, table_, r, c);
border := cell_obj.Borders(border_type_);
fun := FindFunction(pf, border);
fun.Do(value);
end
end
end
else begin
##pf(value);
end
End;
Function TSDocxBorderTable.CallFunction(pf);overload;
Begin
ret := nil;
cur := nil;
if cell_border_ then
begin
for r:=1 to table_.Rows() do
begin
for c:=1 to table_.Cols() do
begin
cell_obj := new TSDocxCell(self.Application, self.Creator, self.Parent);
cell_obj.Init(nil, table_, r, c);
border := cell_obj.Borders(border_type_);
fun := FindFunction(pf, border);
cur := fun.Do();
if ifnil(ret) then ret := cur;
if ret <> cur then return TSDocxEnumerations.wdUndefined();
end
end
end
else begin
ret := ##pf();
end
return ret;
End;
// property
Function TSDocxBorderTable.WriteVisible(value);override;
Begin
if cell_border_ then CallFunction("WriteVisible", value);
else CallFunction(ThisFunction(class(TSDocxBorder).WriteVisible), value);
End;
Function TSDocxBorderTable.ReadVisible();override;
Begin
if cell_border_ then return CallFunction("ReadVisible");
else return CallFunction(ThisFunction(class(TSDocxBorder).ReadVisible));
End;
Function TSDocxBorderTable.WriteLineWidth(value);override;
Begin
if cell_border_ then CallFunction("WriteLineWidth", value);
else CallFunction(ThisFunction(class(TSDocxBorder).WriteLineWidth), value);
End;
Function TSDocxBorderTable.ReadLineWidth();override;
Begin
if cell_border_ then return CallFunction("ReadLineWidth");
else return CallFunction(ThisFunction(class(TSDocxBorder).ReadLineWidth));
End;
Function TSDocxBorderTable.WriteLineStyle(value);override;
Begin
if cell_border_ then CallFunction("WriteLineStyle", value);
else CallFunction(ThisFunction(class(TSDocxBorder).WriteLineStyle), value);
End;
Function TSDocxBorderTable.ReadLineStyle();override;
Begin
if cell_border_ then return CallFunction("ReadLineStyle");
else return CallFunction(ThisFunction(class(TSDocxBorder).ReadLineStyle));
End;
Function TSDocxBorderTable.WriteColorIndex(value);override;
Begin
if cell_border_ then CallFunction("WriteColorIndex", value);
else CallFunction(ThisFunction(class(TSDocxBorder).WriteColorIndex), value);
End;
Function TSDocxBorderTable.ReadColorIndex();override;
Begin
if cell_border_ then return CallFunction("ReadColorIndex");
else return CallFunction(ThisFunction(class(TSDocxBorder).ReadColorIndex));
End;
Function TSDocxBorderTable.WriteColor(value);override;
Begin
if cell_border_ then CallFunction("WriteColor", value);
else CallFunction(ThisFunction(class(TSDocxBorder).WriteColor), value);
End;
Function TSDocxBorderTable.ReadColor();override;
Begin
if cell_border_ then return CallFunction("ReadColor");
else return CallFunction(ThisFunction(class(TSDocxBorder).ReadColor));
End;
Function TSDocxBorderTable.WriteArtWidth(value);override;
Begin
if cell_border_ then CallFunction("WriteArtWidth", value);
else CallFunction(ThisFunction(class(TSDocxBorder).WriteArtWidth), value);
End;
Function TSDocxBorderTable.ReadArtWidth();override;
Begin
if cell_border_ then return CallFunction("ReadArtWidth");
else return CallFunction(ThisFunction(class(TSDocxBorder).ReadArtWidth));
End;
Function TSDocxBorderTable.WriteArtStyle(value);override;
Begin
if cell_border_ then CallFunction("WriteArtStyle", value);
else CallFunction(ThisFunction(class(TSDocxBorder).WriteArtStyle), value);
End;
Function TSDocxBorderTable.ReadArtStyle();override;
Begin
if cell_border_ then return CallFunction("ReadArtStyle");
else return CallFunction(ThisFunction(class(TSDocxBorder).ReadArtStyle));
End;