Type TSDocxBorderRange = Class(TSDocxBorder) Uses TSDocxEnumerations; public Function Init(rangeObj, borderType); private Function GetBorderObjectByNode(node); Function GetBorder(arr, hash); Function CallFunction(fname, value);overload; Function CallFunction(fname);overload; Function SplitRun(); private range_obj_; border_type_; 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; End; // ============== 实现 ================= // Function TSDocxBorderRange.Init(rangeObj, borderType); Begin range_obj_ := rangeObj; border_type_ := borderType; class(TSDocxBorder).Init(nil); End; Function TSDocxBorderRange.SplitRun(); Begin range_obj_.SplitRangeRun(); self.Parent.SetRangeObj(range_obj_); End; Function TSDocxBorderRange.GetBorder(arr, hash); Begin if arr["entirety"] then begin if not ifnil(hash[arr["entirety"]]) then nil; hash[arr["entirety"]] := true; border := GetBorderObjectByNode(arr["entirety"]); end else begin trun := arr["trun"]; if not ifObj(trun.Root()) then return nil; border := new TSDocxBorder(self.Application, self.Creator, self.Parent); border.Init(trun.rPr.Bdr); end return border; End; Function TSDocxBorderRange.GetBorderObjectByNode(node); Begin name := node.GetName(); if name = "w:p" then begin obj := TOfficeObj("TParagraph"); obj.Init(node); paragraph_obj := new TSDocxParagraph(self.Application, self.Creator, self.Parent); paragraph_obj.Init(nil, obj, nil); return paragraph_obj.Borders(border_type_); end else if name = "w:tbl" then begin obj := TOfficeObj("TTable"); obj.Init(node); table_obj := new TSDocxTable(self.Application, self.Creator, self.Parent); table_obj.Init(nil, obj); return table_obj.Borders(border_type_); end else if name = "w:tc" then begin cell_obj := new TSDocxCell(self.Application, self.Creator, self.Parent); cell_obj.Init(node); return cell_obj.Borders(border_type_); end End; Function TSDocxBorderRange.CallFunction(fname, value);overload; Begin SplitRun(); hash := array(); range_arr := rangeObj.GetInfo(); for i:=0 to length(range_arr)-1 do begin border := GetBorder(range_arr[i], hash); if ifnil(border) then continue; pf := FindFunction(fname, border); pf.Do(value); end End; Function TSDocxBorderRange.CallFunction(fname);overload; Begin hash := array(); range_arr := rangeObj.GetInfo(); ret := nil; for i:=0 to length(range_arr)-1 do begin border := GetBorder(range_arr[i], hash); if ifnil(border) then continue; pf := FindFunction(fname, border); r := pf.Do(); if ifnil(ret) then ret := r; if ret <> r then return TSDocxEnumerations.WdUnderline(); end return ret; End; // property Function TSDocxBorderRange.WriteVisible(value);override; Begin CallFunction("WriteVisible", value); End; Function TSDocxBorderRange.ReadVisible();override; Begin return CallFunction("ReadVisible"); End; Function TSDocxBorderRange.WriteLineWidth(value);override; Begin CallFunction("WriteLineWidth", value); End; Function TSDocxBorderRange.ReadLineWidth();override; Begin return CallFunction("ReadLineWidth"); End; Function TSDocxBorderRange.WriteLineStyle(value);override; Begin CallFunction("WriteLineStyle", value); End; Function TSDocxBorderRange.ReadLineStyle();override; Begin return CallFunction("ReadLineStyle"); End; Function TSDocxBorderRange.WriteColorIndex(value);override; Begin CallFunction("WriteColorIndex", value); End; Function TSDocxBorderRange.ReadColorIndex();override; Begin return CallFunction("ReadColorIndex"); End; Function TSDocxBorderRange.WriteColor(value);override; Begin CallFunction("WriteColor", value); End; Function TSDocxBorderRange.ReadColor();override; Begin return CallFunction("ReadColor"); End; Function TSDocxBorderRange.WriteArtWidth(value);override; Begin CallFunction("WriteArtWidth", value); End; Function TSDocxBorderRange.ReadArtWidth();override; Begin return CallFunction("ReadArtWidth"); End; Function TSDocxBorderRange.WriteArtStyle(value);override; Begin CallFunction("WriteArtStyle", value); End; Function TSDocxBorderRange.ReadArtStyle();override; Begin return CallFunction("ReadArtStyle"); End;