完善range

This commit is contained in:
csh
2023-12-20 09:06:40 +08:00
parent f0560b2330
commit b9e419541b
29 changed files with 1553 additions and 494 deletions
+10 -10
View File
@@ -3,6 +3,7 @@ Uses TSDocxEnumerations;
public
Function Init(borders);
Function Apply();virtual;
protected
border_;
@@ -10,6 +11,7 @@ protected
color_index_;
public
// Properties
property ArtStyle read ReadArtStyle write WriteArtStyle;
property ArtWidth read ReadArtWidth write WriteArtWidth;
property Color read ReadColor write WriteColor;
@@ -45,6 +47,11 @@ Begin
color_ := TSWdColor();
End;
Function TSDocxBorder.Apply();virtual;
Begin
border_.Update("first");
End
// property
Function TSDocxBorder.WriteArtStyle(value);virtual;
Begin
@@ -215,7 +222,6 @@ Begin
// TSDocxEnumerations.wdArtZigZag():
// TSDocxEnumerations.wdArtZigZagStitch():
end;
border_.Update("first");
End;
Function TSDocxBorder.ReadArtStyle();virtual;
Begin
@@ -228,7 +234,6 @@ End;
Function TSDocxBorder.WriteArtWidth(value);virtual;
Begin
border_.Size := value;
border_.Update("first");
End;
Function TSDocxBorder.ReadArtWidth();virtual;
Begin
@@ -238,7 +243,6 @@ End;
Function TSDocxBorder.WriteColor(value);virtual;
Begin
border_.Color := color_[value];
border_.Update("first");
End;
Function TSDocxBorder.ReadColor();virtual;
Begin
@@ -247,11 +251,10 @@ End;
Function TSDocxBorder.WriteColorIndex(value);virtual;
Begin
color := color_index_[value];
if ifnil(color) then border_.Root().DeleteAttribute("w:color");
color_index := color_index_[value];
if ifnil(color_index) then border_.Root().DeleteAttribute("w:color");
else begin
border_.Color := color;
border_.Update("first");
border_.Color := color_index;
end
End;
Function TSDocxBorder.ReadColorIndex();virtual;
@@ -338,7 +341,6 @@ Begin
border_.Val := "triple";
end;
border_.Update("first");
End;
@@ -426,7 +428,6 @@ End;
Function TSDocxBorder.WriteLineWidth(value);virtual;
Begin
border_.Size := value;
border_.Update("first");
End;
Function TSDocxBorder.ReadLineWidth();virtual;
Begin
@@ -436,7 +437,6 @@ End;
Function TSDocxBorder.WriteVisible(value);virtual;
Begin
v := value ? "single" : "nil";
border_.Update("first");
End;
Function TSDocxBorder.ReadVisible();virtual;
Begin
+15 -11
View File
@@ -3,6 +3,7 @@ Uses TSDocxEnumerations;
public
Function Init(rangeObj, borderType);
Function Apply();override;
private
Function GetBorderObjectByNode(node);
@@ -42,6 +43,11 @@ Begin
class(TSDocxBorder).Init(nil);
End;
Function TSDocxBorderRange.Apply();override;
Begin
CallFunction(ThisFunction(class(TSDocxBorder).Apply));
End;
Function TSDocxBorderRange.SplitRun();
Begin
range_obj_.SplitRangeRun();
@@ -50,14 +56,14 @@ End;
Function TSDocxBorderRange.GetBorder(arr, hash);
Begin
if arr["entirety"] then
if arr.Entirety then
begin
if not ifnil(hash[arr["entirety"]]) then nil;
hash[arr["entirety"]] := true;
border := GetBorderObjectByNode(arr["entirety"]);
if not ifnil(hash[arr.Entirety]) then nil;
hash[arr.Entirety] := true;
border := GetBorderObjectByNode(arr.Entirety);
end
else begin
trun := arr["trun"];
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);
@@ -96,10 +102,9 @@ Function TSDocxBorderRange.CallFunction(fname, value);overload;
Begin
SplitRun();
hash := array();
range_arr := rangeObj.GetInfo();
for i:=0 to length(range_arr)-1 do
for i:=0 to range_obj_.Size()-1 do
begin
border := GetBorder(range_arr[i], hash);
border := GetBorder(range_obj_[i], hash);
if ifnil(border) then continue;
pf := FindFunction(fname, border);
pf.Do(value);
@@ -109,11 +114,10 @@ End;
Function TSDocxBorderRange.CallFunction(fname);overload;
Begin
hash := array();
range_arr := rangeObj.GetInfo();
ret := nil;
for i:=0 to length(range_arr)-1 do
for i:=0 to range_obj_.Size()-1 do
begin
border := GetBorder(range_arr[i], hash);
border := GetBorder(range_obj_[i], hash);
if ifnil(border) then continue;
pf := FindFunction(fname, border);
r := pf.Do();
+2
View File
@@ -5,9 +5,11 @@ public
Function GetBorder(index);virtual;
public
// Methods
Function ApplyPageBordersToAllSections();
Function Item(Index);virtual;
// Properties
property AlwaysInFront read ReadAlwaysInFront write WriteAlwaysInFront;
property Count read ReadCount;
property DistanceFrom read ReadDistanceFrom write WriteDistanceFrom;