1. 修复段落有首行间距,居中算法不对问题

2. 修复段前分页失效
This commit is contained in:
csh 2024-12-19 10:31:20 +08:00
parent 4c002f803f
commit bdbd201e44
4 changed files with 8 additions and 27 deletions

View File

@ -15,8 +15,6 @@ public
function GetNextPage(page: TSPage): TSPage;
function GetCurrentXmlFile(): string;
function AddTSPageWare(flag: boolean): TSPage;
function AddTSPage(flag: boolean): TSPage;
function LinkToToc(anchor: string; page: TSPage; left: real; top: real);
function AddToc(anchor: string; toc: TSToc);
@ -25,7 +23,6 @@ public
function CalculateTextCoordinates(): array of real;
function GetSymbol(symbol: string);
function AddDocxPage(pg: TSPage; r: R);
function CalcParams(): real;
function AddColIndex();
function UpdateDocxPageNumpages();
@ -130,24 +127,6 @@ begin
return pdf_.SaveToFile(alias, file);
end;
function TSDocxToPdf.CalcParams(): real;
begin
cols := current_sect_ware_.SectPr.Cols.Cols();
// println("cols = {}", cols);
w := 0;
if cols then
begin
for i:=0 to col_index_ do
begin
w := cols[i].W;
if i > 0 then text_point_.X += (cols[i-1].W + cols[i-1].Space);
end
end
else
w := current_sect_ware_.SectPr.PgSz.W - current_sect_ware_.SectPr.PgMar.Right - current_sect_ware_.SectPr.PgMar.Left;
return w;
end;
function TSDocxToPdf.Transform();
begin
for _,sect_ware in sect_ware_array_ do

View File

@ -52,7 +52,7 @@ begin
last := range_array_[length(range_array_)-1];
case jc of
"center":
offset := ({self.}Width - last.EndX + first.EndX - last.Width) / 2;
offset := ({self.}Width + StartX - last.EndX - last.Width) / 2;
"right":
offset := {self.}Width - last.EndX + first.EndX - last.Width;
end;

View File

@ -147,10 +147,10 @@ begin
if ifnil(paragraph_.XmlChildPPr) then paragraph_.XmlChildPPr := new PPr();
{self.}SetPPr(paragraph_.PPr);
ppr_unit_decorator_ := new PPrUnitDecorator(paragraph_.PPr);
{self.}Init();
if not ppr_unit_decorator_.RPr.Sz.Val then ppr_unit_decorator_.RPr.Sz.Val := docx_to_pdf_.Font.GetDefaultSz();
if paragraph_.PPr.PageBreakBefore then
{self.}CheckAndAddPage({self.}LowerBound, 1);
{self.}Init();
elements := paragraph_.Elements();
empty_flag := true;
@ -826,7 +826,10 @@ begin
end
else begin
lines := roundto(line / 240, -1);
multi := ceil(size / sect_ware.BaseSize) * lines;
multi := ceil(size / sect_ware.BaseSize);
if (not ifnil(ppr_unit_decorator_.SnapToGrid) and not ppr_unit_decorator_.SnapToGrid) or
((ifnil(ppr_unit_decorator_.SnapToGrid) or ppr_unit_decorator_.SnapToGrid) and lines > multi) then
multi *= lines;
return sect_ware.SectPr.DocGrid.LinePitch * multi;
end
end;

View File

@ -49,9 +49,8 @@ function TSPdfTableRange.Calc();
begin
{self.}SetTblTblPr(table_);
tbl_pr_unit_decorator_ := new TblPrUnitDecorator(table_.TblPr);
grid_cols := table_.TblGrid.GridCols();
for i:=0 to length(grid_cols)-1 do
grid_cols[i] := new GridColUnitDecorator(grid_cols[i]);
tbl_grid_unit_decorator := new TblGridUnitDecorator(table_.TblGrid);
grid_cols := tbl_grid_unit_decorator.GridCols();
{self.}ResetCoordinates(tbl_pr_unit_decorator_, grid_cols);
{self.}EndX := {self.}StartX;
{self.}EndY := {self.}StartY;