表格边框优化

This commit is contained in:
csh 2024-11-25 09:54:41 +08:00
parent b1cb66fd48
commit f251782186
2 changed files with 37 additions and 13 deletions

View File

@ -268,21 +268,25 @@ begin
begin
if tbl_pr_.TblBorders.Top then
begin
if not tc_pr_unit_decorator_.TcBorders.Top then
tc_pr_unit_decorator_.TcBorders.Top.Copy(tbl_pr_.TblBorders.Top);
range.Top := true;
end
if tbl_pr_.TblBorders.InsideH and {self.}VMerge <> parent_.Rows()-1 then
begin
if not tc_pr_unit_decorator_.TcBorders.Bottom then
tc_pr_unit_decorator_.TcBorders.Bottom.Copy(tbl_pr_.TblBorders.InsideH);
range.Bottom := true;
end
if tbl_pr_.TblBorders.InsideV and {self.}Col <> parent_.Cols()-1 then
begin
if not tc_pr_unit_decorator_.TcBorders.Right then
tc_pr_unit_decorator_.TcBorders.Right.Copy(tbl_pr_.TblBorders.InsideV);
range.Right := true;
end
if tbl_pr_.TblBorders.Bottom and {self.}VMerge = parent_.Rows()-1 then
begin
if not tc_pr_unit_decorator_.TcBorders.Bottom then
tc_pr_unit_decorator_.TcBorders.Bottom.Copy(tbl_pr_.TblBorders.Bottom);
range.Bottom := true;
end
@ -291,11 +295,13 @@ begin
begin
if tbl_pr_.TblBorders.Bottom then
begin
if not tc_pr_unit_decorator_.TcBorders.Bottom then
tc_pr_unit_decorator_.TcBorders.Bottom.Copy(tbl_pr_.TblBorders.Bottom);
range.Bottom := true;
end
if tbl_pr_.TblBorders.InsideV and {self.}Col <> parent_.Cols()-1 then
begin
if not tc_pr_unit_decorator_.TcBorders.Right then
tc_pr_unit_decorator_.TcBorders.Right.Copy(tbl_pr_.TblBorders.InsideV);
range.Right := true;
end
@ -303,16 +309,19 @@ begin
else begin
if tbl_pr_.TblBorders.Bottom and {self.}VMerge = parent_.Rows()-1 then
begin
if not tc_pr_unit_decorator_.TcBorders.Bottom then
tc_pr_unit_decorator_.TcBorders.Bottom.Copy(tbl_pr_.TblBorders.Bottom);
range.Bottom := true;
end
if tbl_pr_.TblBorders.InsideH and {self.}VMerge <> parent_.Rows()-1 then
begin
if not tc_pr_unit_decorator_.TcBorders.Bottom then
tc_pr_unit_decorator_.TcBorders.Bottom.Copy(tbl_pr_.TblBorders.InsideH);
range.Bottom := true;
end
if tbl_pr_.TblBorders.InsideV and {self.}Col <> parent_.Cols()-1 then
begin
if not tc_pr_unit_decorator_.TcBorders.Right then
tc_pr_unit_decorator_.TcBorders.Right.Copy(tbl_pr_.TblBorders.InsideV);
range.Right := true;
end
@ -322,6 +331,7 @@ begin
begin
if tbl_pr_.TblBorders.Left then
begin
if not tc_pr_unit_decorator_.TcBorders.Left then
tc_pr_unit_decorator_.TcBorders.Left.Copy(tbl_pr_.TblBorders.Left);
range.Left := true;
end
@ -330,6 +340,7 @@ begin
begin
if tbl_pr_.TblBorders.Right then
begin
if not tc_pr_unit_decorator_.TcBorders.Right then
tc_pr_unit_decorator_.TcBorders.Right.Copy(tbl_pr_.TblBorders.Right);
range.Right := true;
end

View File

@ -28,16 +28,29 @@ end;
function TSPdfBordersRange.Do();override;
begin
// println("Left = {}, Top = {}, Right = {}, Bottom = {}, Tl2Br = {}, Tr2Bl = {}", Left, Top, Right, Bottom, Tl2Br, Tr2Bl);
borders := {self.}TcPr.TcBorders;
if {self.}TcPr.Shd.Fill and {self.}TcPr.Shd.Fill <> "auto" then
begin
[r, g, b] := TSColorToolKit.HexToRGB({self.}TcPr.Shd.Fill);
{self.}TSPage.PdfPage.SetRGBFill(r/255, g/255, b/255);
{self.}TSPage.PdfPage.Rectangle({self.}EndX, {self.}EndY - {self.}DynamicHeight, {self.}Width, {self.}DynamicHeight);
x := {self.}EndX;
y := {self.}EndY - {self.}DynamicHeight;
w := {self.}Width;
h := {self.}DynamicHeight;
tmp := borders.Left.Sz ? borders.Left.Sz / 2 : 0.25;
x += tmp;
w -= tmp;
w -= borders.Right.Sz ? borders.Right.Sz / 2 : 0.25;
tmp := borders.Bottom.Sz ? borders.Bottom.Sz / 2 : 0.25;
y += tmp;
h -= tmp;
h -= borders.Top.Sz ? borders.Top.Sz / 2 : 0.25;
{self.}TSPage.PdfPage.Rectangle(x, y, w, h);
{self.}TSPage.PdfPage.Fill();
{self.}TSPage.PdfPage.SetRGBFill(0, 0, 0);
{self.}Left := true;
end
borders := {self.}TcPr.TcBorders;
if {self.}Left then
{self.}DrawLine(borders.Left, {self.}EndX, {self.}EndY, {self.}EndX, {self.}EndY - {self.}DynamicHeight);
if {self.}Top then