1. 支持中文的“一二”等项目符号

2. 完善对页码类型的支持
This commit is contained in:
csh
2024-11-11 14:40:16 +08:00
parent 222577dd74
commit da65b2b6c3
2 changed files with 51 additions and 12 deletions
+20 -11
View File
@@ -20,7 +20,7 @@ private
function SetLvlText();
function GetImageFileType(data: binary): string;
function GetImageData(id: string): PdfImage;
function GetParagraphLineSpace(size: real; line: integer): real;
function GetParagraphLineSpace(size: real; line: integer; line_rule: string): real;
function BasicRangesToLineRange(): tableArray;
function CheckAndAddPage(y: real; offset: real): boolean;
function GetUtf8CharLength(byte: string): integer;
@@ -206,7 +206,7 @@ begin
end
if empty_flag then
begin
line_space := {self.}GetParagraphLineSpace(ppr_unit_decorator_.RPr.Sz.Val, ppr_unit_decorator_.Spacing.Line);
line_space := {self.}GetParagraphLineSpace(ppr_unit_decorator_.RPr.Sz.Val, ppr_unit_decorator_.Spacing.Line, ppr_unit_decorator_.Spacing.LineRule);
{self.}DynamicHeight += line_space;
{self.}EndY -= {self.}DynamicHeight;
empty_ := true;
@@ -254,7 +254,7 @@ begin
bottom := {self.}StartY;
x := arr[0].EndX;
y := arr[0].EndY;
if top - {self.}GetParagraphLineSpace(arr[0].RPr.Sz.Val, ppr.Spacing.Line) then
if top - {self.}GetParagraphLineSpace(arr[0].RPr.Sz.Val, ppr.Spacing.Line, ppr.Spacing.LineRule) then
begin
top := docx_to_pdf_.GetCurrentTextPoint().Y;
bottom := top;
@@ -263,7 +263,7 @@ begin
begin
if x + range.Width - {self.}StartX > {self.}Width + 1e-6 then // 换行
begin
line_space := {self.}GetParagraphLineSpace(max_size, ppr.Spacing.Line);
line_space := {self.}GetParagraphLineSpace(max_size, ppr.Spacing.Line, ppr.Spacing.LineRule);
bottom -= line_space;
max_size := 0;
if range.TSPage <> pg then
@@ -281,7 +281,7 @@ begin
end
font_name := ppr.RPr.RFonts.EastAsia ? ppr.RPr.RFonts.EastAsia : ppr.RPr.RFonts.Ascii;
font_obj := docx_to_pdf_.Font.GetCNSFont(font_name, ppr.RPr.B, ppr.RPr.I);
line_space := {self.}GetParagraphLineSpace(max_size, ppr.Spacing.Line);
line_space := {self.}GetParagraphLineSpace(max_size, ppr.Spacing.Line, ppr.Spacing.LineRule);
pg.PdfPage.SetFontAndSize(font_obj, max_size);
bottom -= line_space;
num_width := pg.PdfPage.TextWidth("." + tostring(pg.Number));
@@ -386,7 +386,7 @@ begin
if range is class(TSPdfTextRange) and range.RPr.Sz.Val > max_size then
max_size := range.RPr.Sz.Val;
if range.DynamicHeight > max_y then max_y := range.DynamicHeight;
line_space := {self.}GetParagraphLineSpace(max_size, ppr.Spacing.Line);
line_space := {self.}GetParagraphLineSpace(max_size, ppr.Spacing.Line, ppr.Spacing.LineRule);
diff := {self.}EndY - {self.}LowerBound;
if {self.}CheckAndAddPage({self.}EndY, max(line_space, range.DynamicHeight)) then
{self.}DynamicHeight += diff;
@@ -649,6 +649,8 @@ begin
fld_struct.NumPages := true;
else if instr_text = "\\* Arabic \\* MERGEFORMAT" then
fld_struct.ArabicMergeFormat := true;
else if instr_text = "NUMPAGES \\* Arabic \\* MERGEFORMAT" then
fld_struct.NumPages := fld_struct.ArabicMergeFormat := true;
end
if fld_struct.Quote then
begin
@@ -757,13 +759,20 @@ begin
return '';
end;
function TSPdfParagraphRange.GetParagraphLineSpace(size: real; line: integer): real;
function TSPdfParagraphRange.GetParagraphLineSpace(size: real; line: integer; line_rule: string): real;
begin
sect_ware := docx_to_pdf_.GetCurrentSectWare();
if not line then line := 12;
lines := roundto(line / 12, -1);
multi := ceil(size / sect_ware.BaseSize) * lines;
return sect_ware.SectPr.DocGrid.LinePitch * multi;
if not line then line := 240;
if line_rule = "exact" or line_rule = "atLeast" then
begin
lines := line / 240;
return size + lines;
end
else begin
lines := roundto(line / 240, -1);
multi := ceil(size / sect_ware.BaseSize) * lines;
return sect_ware.SectPr.DocGrid.LinePitch * multi;
end
end;
function TSPdfParagraphRange.SetPPr(var ppr: PPr);