完善range
This commit is contained in:
@@ -4,6 +4,7 @@ Uses TSDocxEnumerations;
|
||||
public
|
||||
Function Init(pr);
|
||||
Function Apply();virtual;
|
||||
Function ReWrite(pr);virtual;
|
||||
|
||||
protected
|
||||
pr_;
|
||||
@@ -11,15 +12,18 @@ protected
|
||||
color_;
|
||||
|
||||
public
|
||||
// Methods
|
||||
Function Grow();virtual;
|
||||
Function Reset();virtual;
|
||||
Function SetAsTemplateDefault();virtual;
|
||||
Function Shrink();virtual;
|
||||
|
||||
// Properties
|
||||
property AllCaps read ReadAllCaps write WriteAllCaps;
|
||||
property Bold read ReadBold write WriteBold;
|
||||
property BoldBi read ReadBoldBi write WriteBoldBi;
|
||||
property Borders read ReadBorders;
|
||||
property Color read ReadColor write WriteColor;
|
||||
property ColorIndex read ReadColorIndex write WriteColorIndex;
|
||||
property ColorIndexBi read ReadColorIndexBi write WriteColorIndexBi;
|
||||
property ContextualAlternates read ReadContextualAlternates write WriteContextualAlternates;
|
||||
@@ -144,6 +148,8 @@ public
|
||||
Function ReadColorIndexBi();virtual;
|
||||
Function WriteColorIndex(value);virtual;
|
||||
Function ReadColorIndex();virtual;
|
||||
Function WriteColor(value);virtual;
|
||||
Function ReadColor();virtual;
|
||||
Function ReadBorders();virtual;
|
||||
Function WriteBoldBi(value);virtual;
|
||||
Function ReadBoldBi();virtual;
|
||||
@@ -167,6 +173,16 @@ Begin
|
||||
pr_.Update("first");
|
||||
End;
|
||||
|
||||
Function TSDocxFont.ReWrite(pr);virtual;
|
||||
Begin
|
||||
self.Reset();
|
||||
rpr := pr.Root().FirstChildElement("w:rPr");
|
||||
if not ifObj(rpr) then return;
|
||||
marshal := rPr.Marshal()[0];
|
||||
node := class(TSXml).GetNode(pr_.Root(), "w:rPr", "first");
|
||||
class(TSXml).UpdateNode(node, marshal["attributes"], marshal["children"]);
|
||||
End;
|
||||
|
||||
// Methods
|
||||
Function TSDocxFont.Reset();virtual;
|
||||
Begin
|
||||
@@ -201,13 +217,23 @@ Begin
|
||||
return pr_.Value("bCs");
|
||||
End;
|
||||
|
||||
Function TSDocxFont.WriteColor(value);virtual;
|
||||
Begin
|
||||
val := color_index_[value];
|
||||
if ifnil(val) then val := color_[value];
|
||||
pr_.Color := val;
|
||||
End;
|
||||
Function TSDocxFont.ReadColor();virtual;
|
||||
Begin
|
||||
v := pr.Value("Color");
|
||||
value := color_index_[v];
|
||||
if ifnil(value) then return color_[v];
|
||||
End;
|
||||
|
||||
Function TSDocxFont.WriteColorIndex(value);virtual;
|
||||
Begin
|
||||
color := color_index_[value];
|
||||
if ifnil(color) then pr_.Root().DeleteChild("w:color");
|
||||
else begin
|
||||
pr_.Color := color;
|
||||
end
|
||||
val := color_index_[value];
|
||||
pr_.Color := val;
|
||||
End;
|
||||
Function TSDocxFont.ReadColorIndex();virtual;
|
||||
Begin
|
||||
@@ -283,7 +309,7 @@ End;
|
||||
Function TSDocxFont.ReadEmphasisMark();virtual;
|
||||
Begin
|
||||
case pr_.Value("first") of
|
||||
"none":
|
||||
"none", nil:
|
||||
return TSDocxEnumerations.wdEmphasisMarkNone;
|
||||
"comma":
|
||||
return TSDocxEnumerations.wdEmphasisMarkOverComma;
|
||||
@@ -701,3 +727,4 @@ Function TSDocxFont.ReadUnderlineColor();virtual;
|
||||
Begin
|
||||
return color_[pr_.Value("UColor")];
|
||||
End;
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ Uses TSDocxEnumerations;
|
||||
public
|
||||
Function Init(rangeObj);
|
||||
Function Apply();overload;
|
||||
Function ReWrite(pr);override;
|
||||
|
||||
private
|
||||
Function CallFunction(pf, value);overload;
|
||||
@@ -11,7 +12,6 @@ private
|
||||
|
||||
private
|
||||
range_obj_;
|
||||
split_flag_; // 写之前切割run,切割后设为true
|
||||
|
||||
public
|
||||
Function Reset();override;
|
||||
@@ -96,6 +96,8 @@ public
|
||||
Function ReadColorIndexBi();override;
|
||||
Function WriteColorIndex(value);override;
|
||||
Function ReadColorIndex();override;
|
||||
Function WriteColor(value);override;
|
||||
Function ReadColor();override;
|
||||
Function ReadBorders();override;
|
||||
Function WriteBoldBi(value);override;
|
||||
Function ReadBoldBi();override;
|
||||
@@ -118,30 +120,29 @@ Begin
|
||||
CallFunction(ThisFunction(class(TSDocxFont).Apply));
|
||||
End;
|
||||
|
||||
Function TSDocxFontRange.ReWrite(pr);override;
|
||||
Begin
|
||||
CallFunction(ThisFunction(class(TSDocxFont).ReWrite), pr);
|
||||
End;
|
||||
|
||||
Function TSDocxFontRange.CallFunction(pf, value);overload;
|
||||
Begin
|
||||
range_obj_.SplitRun();
|
||||
range_arr := range_obj_.GetInfo();
|
||||
for i:=0 to length(range_arr)-1 do
|
||||
for i:=0 to range_obj_.Size()-1 do
|
||||
begin
|
||||
paragraph := range_arr[i]["tparagraph"];
|
||||
pr_ := paragraph.pPr.rPr;
|
||||
pr_ := range_obj_[i].TParagraph.pPr.rPr;
|
||||
##pf(value);
|
||||
pr_ := range_obj_[i].TRun.rPr;
|
||||
##pf(value);
|
||||
for i:=0 to length(range_arr)-1 do
|
||||
begin
|
||||
pr_ := range_arr[i]["trun"].rPr;
|
||||
##pf(value);
|
||||
end
|
||||
end;
|
||||
End;
|
||||
|
||||
Function TSDocxFontRange.CallFunction(pf);overload;
|
||||
Begin
|
||||
ret := nil;
|
||||
range_arr := range_obj_.GetInfo();
|
||||
for i:=0 to length(range_arr)-1 do
|
||||
for i:=0 to range_obj_.Size()-1 do
|
||||
begin
|
||||
pr_ := range_arr[i]["trun"].rPr;
|
||||
pr_ := range_obj_[i].TRun.rPr;
|
||||
if not ifObj(pr_.Root()) then continue;
|
||||
cur := ##pf();
|
||||
if ifnil(ret) then ret := cur;
|
||||
@@ -509,13 +510,22 @@ End;
|
||||
|
||||
Function TSDocxFontRange.WriteColorIndex(value);override;
|
||||
Begin
|
||||
return CallFunction(ThisFunction(class(TSDocxFont).WriteColorIndex), value);
|
||||
CallFunction(ThisFunction(class(TSDocxFont).WriteColorIndex), value);
|
||||
End;
|
||||
Function TSDocxFontRange.ReadColorIndex();override;
|
||||
Begin
|
||||
return CallFunction(ThisFunction(class(TSDocxFont).ReadColorIndex));
|
||||
End;
|
||||
|
||||
Function TSDocxFontRange.WriteColor(value);override;
|
||||
Begin
|
||||
CallFunction(ThisFunction(class(TSDocxFont).WriteColor), value);
|
||||
End;
|
||||
Function TSDocxFontRange.ReadColor();override;
|
||||
Begin
|
||||
return CallFunction(ThisFunction(class(TSDocxFont).ReadColor));
|
||||
End;
|
||||
|
||||
Function TSDocxFontRange.ReadBorders();override;
|
||||
Begin
|
||||
return CallFunction(ThisFunction(class(TSDocxFont).ReadBorders));
|
||||
|
||||
Reference in New Issue
Block a user