性能优化1: 单位转换由装饰器方式改为方法
This commit is contained in:
parent
5121a94b15
commit
4be804cb1b
|
|
@ -1,5 +1,5 @@
|
||||||
type TSDocxToPdf = class
|
type TSDocxToPdf = class
|
||||||
uses TSPdfEnumerations, DocxML, DocxMLAdapter, DocxMLUnitDecorator, DTPModules, DTPUtils, DTPAdvancedRanges;
|
uses TSPdfEnumerations, DocxML, DocxMLAdapter, DTPModules, DTPUtils, DTPAdvancedRanges;
|
||||||
public
|
public
|
||||||
function Create(alias: string; file: string);
|
function Create(alias: string; file: string);
|
||||||
function Destroy();
|
function Destroy();
|
||||||
|
|
@ -113,7 +113,7 @@ begin
|
||||||
if current_sect_module_ <> sect_module then
|
if current_sect_module_ <> sect_module then
|
||||||
begin
|
begin
|
||||||
current_sect_module_ := sect_module;
|
current_sect_module_ := sect_module;
|
||||||
current_sect_pr_adapter_ := new SectPrAdapter(current_sect_module_.SectPr.GetObject());
|
current_sect_pr_adapter_ := new SectPrAdapter(current_sect_module_.SectPr);
|
||||||
{self.}AddPage(true);
|
{self.}AddPage(true);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -182,6 +182,7 @@ begin
|
||||||
current_sect_pr_adapter_ := nil;
|
current_sect_pr_adapter_ := nil;
|
||||||
document := docx_components_module_.Document;
|
document := docx_components_module_.Document;
|
||||||
document.Deserialize();
|
document.Deserialize();
|
||||||
|
document.ConvertToPoint();
|
||||||
{self.}AllocateElementsToSectModule();
|
{self.}AllocateElementsToSectModule();
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
@ -191,7 +192,6 @@ begin
|
||||||
module := new DTPModules.SectModule();
|
module := new DTPModules.SectModule();
|
||||||
fp := function(module, sect);
|
fp := function(module, sect);
|
||||||
begin
|
begin
|
||||||
sect := new SectPrUnitDecorator(sect);
|
|
||||||
sect.PgSz.Orient := sect.PgSz.Orient ? "portrait" : "landscape";
|
sect.PgSz.Orient := sect.PgSz.Orient ? "portrait" : "landscape";
|
||||||
sect.Type.Val := sect.Type.Val ?: "nextPage";
|
sect.Type.Val := sect.Type.Val ?: "nextPage";
|
||||||
module.SectPr := sect;
|
module.SectPr := sect;
|
||||||
|
|
@ -322,9 +322,9 @@ function TSDocxToPdf.RangesSpacing(range: BasicRange);
|
||||||
begin
|
begin
|
||||||
if last_range_ then
|
if last_range_ then
|
||||||
begin
|
begin
|
||||||
if last_range_ is class(PRange) and not ifnil(last_range_.PPrUnitDecorator.OutlineLvl.Val) and (range is class(TblRange) or ifnil(range.PPrUnitDecorator.OutlineLvl.Val)) then
|
if last_range_ is class(PRange) and not ifnil(last_range_.P.PPr.OutlineLvl.Val) and (range is class(TblRange) or ifnil(range.P.PPr.OutlineLvl.Val)) then
|
||||||
begin
|
begin
|
||||||
if last_range_.PPrUnitDecorator.Spacing.AfterAutospacing then
|
if last_range_.P.PPr.Spacing.AfterAutospacing then
|
||||||
begin
|
begin
|
||||||
line_range := last_range_.PLineRanges();
|
line_range := last_range_.PLineRanges();
|
||||||
line_range := line_range[length(line_range)-1];
|
line_range := line_range[length(line_range)-1];
|
||||||
|
|
@ -332,9 +332,9 @@ begin
|
||||||
if y >= 0 then current_page_.TextPoint.Y := y;
|
if y >= 0 then current_page_.TextPoint.Y := y;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if range is class(PRange) and not ifnil(range.PPrUnitDecorator.OutlineLvl.Val) and (last_range_ is class(TblRange) or ifnil(last_range_.PPrUnitDecorator.OutlineLvl.Val)) then
|
if range is class(PRange) and not ifnil(range.P.PPr.OutlineLvl.Val) and (last_range_ is class(TblRange) or ifnil(last_range_.P.PPr.OutlineLvl.Val)) then
|
||||||
begin
|
begin
|
||||||
if range.PPrUnitDecorator.Spacing.BeforeAutospacing then
|
if range.P.PPr.Spacing.BeforeAutospacing then
|
||||||
begin
|
begin
|
||||||
line_range := range.PLineRanges();
|
line_range := range.PLineRanges();
|
||||||
line_range := line_range[length(line_range)-1];
|
line_range := line_range[length(line_range)-1];
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
unit DTPAdvancedRanges;
|
unit DTPAdvancedRanges;
|
||||||
interface
|
interface
|
||||||
uses DTPPrimitiveRanges, DTPUtils, DTPModules, SharedML, DocxML, DrawingMLUnitDecorator, DocxMLUnitDecorator, TSPdfEnumerations;
|
uses DTPPrimitiveRanges, DTPUtils, DTPModules, SharedML, DocxML, TSPdfEnumerations;
|
||||||
|
|
||||||
type AdvancedRange = class(BasicRange)
|
type AdvancedRange = class(BasicRange)
|
||||||
public
|
public
|
||||||
|
|
@ -98,7 +98,7 @@ public
|
||||||
function IsFirstLineOnNextPage(): boolean;
|
function IsFirstLineOnNextPage(): boolean;
|
||||||
function PLineRanges(): array of PLineRange;
|
function PLineRanges(): array of PLineRange;
|
||||||
|
|
||||||
property PPrUnitDecorator read ppr_unit_decorator_;
|
property P read p_;
|
||||||
|
|
||||||
private
|
private
|
||||||
function RangesToLines();
|
function RangesToLines();
|
||||||
|
|
@ -115,7 +115,7 @@ private
|
||||||
|
|
||||||
function SetPPPr(var p: P);
|
function SetPPPr(var p: P);
|
||||||
function SetPPrByStyleId(var ppr: PPr; style_id: string);
|
function SetPPrByStyleId(var ppr: PPr; style_id: string);
|
||||||
function SetRRPr(var r: R; ppr_unit_decorator: PPrUnitDecorator);
|
function SetRRPr(var r: R; ppr_: PPr);
|
||||||
function SetRPrByStyleId(var rpr: RPr; style_id: string);
|
function SetRPrByStyleId(var rpr: RPr; style_id: string);
|
||||||
function SetRPrByTblStyleId(var rpr: RPr; style_id: string);
|
function SetRPrByTblStyleId(var rpr: RPr; style_id: string);
|
||||||
function SetLvlText();
|
function SetLvlText();
|
||||||
|
|
@ -123,7 +123,7 @@ private
|
||||||
function GetImageFileType(data: binary): string;
|
function GetImageFileType(data: binary): string;
|
||||||
function GetImageData(id: string): PdfImage;
|
function GetImageData(id: string): PdfImage;
|
||||||
function GetParagraphLineSpace(size: real; line: integer; line_rule: string): real;
|
function GetParagraphLineSpace(size: real; line: integer; line_rule: string): real;
|
||||||
function SplitTextToTextRange(range_arr: array of BasicRange; text: string; rpr: RPrUnitDecorator; anchor: string);
|
function SplitTextToTextRange(range_arr: array of BasicRange; text: string; rpr: RPr; anchor: string);
|
||||||
|
|
||||||
function RBr(r: R);
|
function RBr(r: R);
|
||||||
function RFootnoteReference(r: R);
|
function RFootnoteReference(r: R);
|
||||||
|
|
@ -140,7 +140,7 @@ private
|
||||||
private
|
private
|
||||||
[weakref]docx_to_pdf_: TSDocxToPdf;
|
[weakref]docx_to_pdf_: TSDocxToPdf;
|
||||||
p_: P;
|
p_: P;
|
||||||
ppr_unit_decorator_: PPrUnitDecorator;
|
ppr_: PPr;
|
||||||
body_range_array_: array of BasicRange; // 正文range
|
body_range_array_: array of BasicRange; // 正文range
|
||||||
bullet_range_array_: array of BasicRange; // 项目符号的range
|
bullet_range_array_: array of BasicRange; // 项目符号的range
|
||||||
line_range_array_: array of PLineRange; // 行range
|
line_range_array_: array of PLineRange; // 行range
|
||||||
|
|
@ -187,7 +187,7 @@ private
|
||||||
[weakref]docx_to_pdf_: TSDocxToPdf;
|
[weakref]docx_to_pdf_: TSDocxToPdf;
|
||||||
tc_: Tc;
|
tc_: Tc;
|
||||||
trp_: TrProperty;
|
trp_: TrProperty;
|
||||||
tc_pr_unit_decorator_: TcPrUnitDecorator;
|
tc_pr_: TcPr;
|
||||||
content_next_page_: boolean;
|
content_next_page_: boolean;
|
||||||
range_array_: array of BasicRange;
|
range_array_: array of BasicRange;
|
||||||
region_array_: array of Region;
|
region_array_: array of Region;
|
||||||
|
|
@ -202,12 +202,12 @@ public
|
||||||
function Calc(): boolean;override;
|
function Calc(): boolean;override;
|
||||||
function Offset(x: real; y: real; page: Page);override;
|
function Offset(x: real; y: real; page: Page);override;
|
||||||
|
|
||||||
property TblPr read tbl_pr_unit_decorator_;
|
property TblPr read tbl_pr_;
|
||||||
property Rows read rows_;
|
property Rows read rows_;
|
||||||
property Cols read cols_;
|
property Cols read cols_;
|
||||||
|
|
||||||
private
|
private
|
||||||
function CreateTableMatrix(grid_cols: array of GridColUnitDecorator; trs: array of Tr);
|
function CreateTableMatrix(grid_cols: array of GridCol; trs: array of Tr);
|
||||||
function ResetCoordinates(tbl_pr: TblPr; grid_cols: array of GridCol);
|
function ResetCoordinates(tbl_pr: TblPr; grid_cols: array of GridCol);
|
||||||
function SetTblTblPr(var table: Tbl);
|
function SetTblTblPr(var table: Tbl);
|
||||||
function SetTblPrByStyleId(var tbl_pr: TblPr; style_id: string);
|
function SetTblPrByStyleId(var tbl_pr: TblPr; style_id: string);
|
||||||
|
|
@ -220,8 +220,8 @@ private
|
||||||
private
|
private
|
||||||
[weakref]docx_to_pdf_: TSDocxToPdf;
|
[weakref]docx_to_pdf_: TSDocxToPdf;
|
||||||
tbl_: Tbl;
|
tbl_: Tbl;
|
||||||
tbl_pr_unit_decorator_: TblPrUnitDecorator;
|
tbl_pr_: TblPr;
|
||||||
grid_cols_: array of GridColUnitDecorator;
|
grid_cols_: array of GridCol;
|
||||||
rows_: integer;
|
rows_: integer;
|
||||||
cols_: integer;
|
cols_: integer;
|
||||||
tc_range_matrix_: array of TcRange;
|
tc_range_matrix_: array of TcRange;
|
||||||
|
|
@ -713,7 +713,7 @@ begin
|
||||||
realtime_page_array_ := array();
|
realtime_page_array_ := array();
|
||||||
realtime_numpages_array_ := array();
|
realtime_numpages_array_ := array();
|
||||||
// 根据段落的间距确定新的坐标
|
// 根据段落的间距确定新的坐标
|
||||||
ppr := ppr_unit_decorator_;
|
ppr := ppr_;
|
||||||
sz := ppr.RPr.SzCs.Val ? : ppr.RPr.Sz.Val;
|
sz := ppr.RPr.SzCs.Val ? : ppr.RPr.Sz.Val;
|
||||||
{self.}Width -= ppr.Ind.LeftChars ? ppr.Ind.LeftChars * sz : ppr.Ind.Left;
|
{self.}Width -= ppr.Ind.LeftChars ? ppr.Ind.LeftChars * sz : ppr.Ind.Left;
|
||||||
{self.}Width -= ppr.Ind.RightChars ? ppr.Ind.RightChars * sz : ppr.Ind.Right;
|
{self.}Width -= ppr.Ind.RightChars ? ppr.Ind.RightChars * sz : ppr.Ind.Right;
|
||||||
|
|
@ -725,7 +725,7 @@ begin
|
||||||
line_range.Do();
|
line_range.Do();
|
||||||
|
|
||||||
// 段落边框
|
// 段落边框
|
||||||
if length(line_range_array_) > 0 and ppr_unit_decorator_.PBdr.Bottom.Val = "single" then
|
if length(line_range_array_) > 0 and ppr_.PBdr.Bottom.Val = "single" then
|
||||||
begin
|
begin
|
||||||
{self.}EndPage.PdfPage.SetLineWidth(0.5);
|
{self.}EndPage.PdfPage.SetLineWidth(0.5);
|
||||||
{self.}EndPage.PdfPage.SetGrayStroke(0.25);
|
{self.}EndPage.PdfPage.SetGrayStroke(0.25);
|
||||||
|
|
@ -747,8 +747,8 @@ function PRange.Calc(): boolean;override;
|
||||||
begin
|
begin
|
||||||
// ppr.rpr是无效的,应该以ppr.pStyle为准
|
// ppr.rpr是无效的,应该以ppr.pStyle为准
|
||||||
{self.}SetPPPr(p_);
|
{self.}SetPPPr(p_);
|
||||||
ppr_unit_decorator_ := new DocxMLUnitDecorator.PPrUnitDecorator(p_.PPr);
|
ppr_ := p_.PPr;
|
||||||
if not ppr_unit_decorator_.RPr.Sz.Val then ppr_unit_decorator_.RPr.Sz.Val := docx_to_pdf_.Font.GetDefaultSz();
|
if not ppr_.RPr.Sz.Val then ppr_.RPr.Sz.Val := docx_to_pdf_.Font.GetDefaultSz();
|
||||||
{self.}Init();
|
{self.}Init();
|
||||||
{self.}SetLvlText();
|
{self.}SetLvlText();
|
||||||
|
|
||||||
|
|
@ -769,7 +769,7 @@ begin
|
||||||
end
|
end
|
||||||
else if element.LocalName = "r" then
|
else if element.LocalName = "r" then
|
||||||
begin
|
begin
|
||||||
{self.}SetRRPr(element, ppr_unit_decorator_);
|
{self.}SetRRPr(element, ppr_);
|
||||||
if element.FldChar.FldCharType = "begin" then
|
if element.FldChar.FldCharType = "begin" then
|
||||||
begin
|
begin
|
||||||
fld_struct := new DTPUtils.FldStruct();
|
fld_struct := new DTPUtils.FldStruct();
|
||||||
|
|
@ -846,7 +846,6 @@ function PRange.RFootnoteReference(r: R);
|
||||||
begin
|
begin
|
||||||
return;
|
return;
|
||||||
docx_to_pdf_.Note.AddFootnoteId(r.FootnoteReference.Id);
|
docx_to_pdf_.Note.AddFootnoteId(r.FootnoteReference.Id);
|
||||||
rpr := new RPrUnitDecorator(r.RPr);
|
|
||||||
if not rpr.Sz.Val then rpr.Sz.Val := rpr.SzCs.Val ? rpr.SzCs.Val : docx_to_pdf_.Font.GetDefaultSz();
|
if not rpr.Sz.Val then rpr.Sz.Val := rpr.SzCs.Val ? rpr.SzCs.Val : docx_to_pdf_.Font.GetDefaultSz();
|
||||||
font_name := rpr.RFonts.Ascii ?: rpr.RFonts.EastAsia;
|
font_name := rpr.RFonts.Ascii ?: rpr.RFonts.EastAsia;
|
||||||
font_obj := docx_to_pdf_.Font.GetCNSFont(font_name, rpr.B.IsApplied, rpr.I.IsApplied);
|
font_obj := docx_to_pdf_.Font.GetCNSFont(font_name, rpr.B.IsApplied, rpr.I.IsApplied);
|
||||||
|
|
@ -871,14 +870,13 @@ begin
|
||||||
id := r.Drawing._Inline.Graphic.GraphicData.Pic.BlipFill.Blip.Embed;
|
id := r.Drawing._Inline.Graphic.GraphicData.Pic.BlipFill.Blip.Embed;
|
||||||
[image_type, image] := {self.}GetImageData(id);
|
[image_type, image] := {self.}GetImageData(id);
|
||||||
if not image then return;
|
if not image then return;
|
||||||
xfrm := new XfrmUnitDecorator(r.Drawing._Inline.Graphic.GraphicData.Pic.SpPr.Xfrm);
|
xfrm := r.Drawing._Inline.Graphic.GraphicData.Pic.SpPr.Xfrm;
|
||||||
rpr := new RPrUnitDecorator(r.RPr);
|
|
||||||
image_range := new ImageRange();
|
image_range := new ImageRange();
|
||||||
image_range.Image := image;
|
image_range.Image := image;
|
||||||
image_range.Type := image_type;
|
image_range.Type := image_type;
|
||||||
image_range.Width := xfrm.Ext.CX;
|
image_range.Width := xfrm.Ext.CX;
|
||||||
image_range.DynamicHeight := xfrm.Ext.CY;
|
image_range.DynamicHeight := xfrm.Ext.CY;
|
||||||
image_range.RPr := rpr;
|
image_range.RPr := r.RPr;
|
||||||
body_range_array_[length(body_range_array_)] := image_range;
|
body_range_array_[length(body_range_array_)] := image_range;
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
@ -895,13 +893,12 @@ begin
|
||||||
if startsStr("width:", str) then w := strtofloat(str[7:length(str)-2]);
|
if startsStr("width:", str) then w := strtofloat(str[7:length(str)-2]);
|
||||||
else if startsStr("height:", str) then h := strtofloat(str[8:length(str)-2]);
|
else if startsStr("height:", str) then h := strtofloat(str[8:length(str)-2]);
|
||||||
end
|
end
|
||||||
rpr := new RPrUnitDecorator(r.RPr);
|
|
||||||
image_range := new ImageRange();
|
image_range := new ImageRange();
|
||||||
image_range.Image := image;
|
image_range.Image := image;
|
||||||
image_range.Type := image_type;
|
image_range.Type := image_type;
|
||||||
image_range.Width := w;
|
image_range.Width := w;
|
||||||
image_range.DynamicHeight := h;
|
image_range.DynamicHeight := h;
|
||||||
image_range.RPr := rpr;
|
image_range.RPr := r.RPr;
|
||||||
body_range_array_[length(body_range_array_)] := image_range;
|
body_range_array_[length(body_range_array_)] := image_range;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
@ -940,9 +937,9 @@ begin
|
||||||
end
|
end
|
||||||
if fld_struct.Status = 1 then
|
if fld_struct.Status = 1 then
|
||||||
begin
|
begin
|
||||||
|
rpr := r.RPr;
|
||||||
if fld_struct.Type.Page then
|
if fld_struct.Type.Page then
|
||||||
begin
|
begin
|
||||||
rpr := new RPrUnitDecorator(r.RPr);
|
|
||||||
if not rpr.Sz.Val then rpr.Sz.Val := rpr.SzCs.Val ? rpr.SzCs.Val : docx_to_pdf_.Font.GetDefaultSz();
|
if not rpr.Sz.Val then rpr.Sz.Val := rpr.SzCs.Val ? rpr.SzCs.Val : docx_to_pdf_.Font.GetDefaultSz();
|
||||||
font_name := rpr.RFonts.EastAsia ? rpr.RFonts.EastAsia : rpr.RFonts.Ascii;
|
font_name := rpr.RFonts.EastAsia ? rpr.RFonts.EastAsia : rpr.RFonts.Ascii;
|
||||||
font_obj := docx_to_pdf_.Font.GetCNSFont(font_name, rpr.B.IsApplied, rpr.I.IsApplied);
|
font_obj := docx_to_pdf_.Font.GetCNSFont(font_name, rpr.B.IsApplied, rpr.I.IsApplied);
|
||||||
|
|
@ -957,7 +954,6 @@ begin
|
||||||
end
|
end
|
||||||
else if fld_struct.Type.NumPages then
|
else if fld_struct.Type.NumPages then
|
||||||
begin
|
begin
|
||||||
rpr := new RPrUnitDecorator(r.RPr);
|
|
||||||
if not rpr.Sz.Val then rpr.Sz.Val := rpr.SzCs.Val ? rpr.SzCs.Val : docx_to_pdf_.Font.GetDefaultSz();
|
if not rpr.Sz.Val then rpr.Sz.Val := rpr.SzCs.Val ? rpr.SzCs.Val : docx_to_pdf_.Font.GetDefaultSz();
|
||||||
font_name := rpr.RFonts.EastAsia ? rpr.RFonts.EastAsia : rpr.RFonts.Ascii;
|
font_name := rpr.RFonts.EastAsia ? rpr.RFonts.EastAsia : rpr.RFonts.Ascii;
|
||||||
font_obj := docx_to_pdf_.Font.GetCNSFont(font_name, rpr.B.IsApplied, rpr.I.IsApplied);
|
font_obj := docx_to_pdf_.Font.GetCNSFont(font_name, rpr.B.IsApplied, rpr.I.IsApplied);
|
||||||
|
|
@ -1003,12 +999,11 @@ begin
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
r := fld_simple.Rs(0);
|
r := fld_simple.Rs(0);
|
||||||
{self.}SetRRPr(r, ppr_unit_decorator_);
|
{self.}SetRRPr(r, ppr_);
|
||||||
if fld_struct.Type.NumPages then
|
if fld_struct.Type.NumPages then
|
||||||
begin
|
begin
|
||||||
if fld_struct.Arabic then
|
if fld_struct.Arabic then
|
||||||
begin
|
begin
|
||||||
rpr := new RPrUnitDecorator(r.RPr);
|
|
||||||
if not rpr.Sz.Val then rpr.Sz.Val := rpr.SzCs.Val ? rpr.SzCs.Val : docx_to_pdf_.Font.GetDefaultSz();
|
if not rpr.Sz.Val then rpr.Sz.Val := rpr.SzCs.Val ? rpr.SzCs.Val : docx_to_pdf_.Font.GetDefaultSz();
|
||||||
font_name := rpr.RFonts.EastAsia ? rpr.RFonts.EastAsia : rpr.RFonts.Ascii;
|
font_name := rpr.RFonts.EastAsia ? rpr.RFonts.EastAsia : rpr.RFonts.Ascii;
|
||||||
font_obj := docx_to_pdf_.Font.GetCNSFont(font_name, rpr.B.IsApplied, rpr.I.IsApplied);
|
font_obj := docx_to_pdf_.Font.GetCNSFont(font_name, rpr.B.IsApplied, rpr.I.IsApplied);
|
||||||
|
|
@ -1047,8 +1042,7 @@ begin
|
||||||
else if separate then
|
else if separate then
|
||||||
begin
|
begin
|
||||||
docx_to_pdf_.Toc.AddDocxPage(hyperlink.Anchor, r);
|
docx_to_pdf_.Toc.AddDocxPage(hyperlink.Anchor, r);
|
||||||
|
rpr := r.RPr;
|
||||||
rpr := new RPrUnitDecorator(r.RPr);
|
|
||||||
if not rpr.Sz.Val then rpr.Sz.Val := rpr.SzCs.Val ? rpr.SzCs.Val : docx_to_pdf_.Font.GetDefaultSz();
|
if not rpr.Sz.Val then rpr.Sz.Val := rpr.SzCs.Val ? rpr.SzCs.Val : docx_to_pdf_.Font.GetDefaultSz();
|
||||||
font_name := rpr.RFonts.EastAsia ? rpr.RFonts.EastAsia : rpr.RFonts.Ascii;
|
font_name := rpr.RFonts.EastAsia ? rpr.RFonts.EastAsia : rpr.RFonts.Ascii;
|
||||||
font_obj := docx_to_pdf_.Font.GetCNSFont(font_name, rpr.B.IsApplied, rpr.I.IsApplied);
|
font_obj := docx_to_pdf_.Font.GetCNSFont(font_name, rpr.B.IsApplied, rpr.I.IsApplied);
|
||||||
|
|
@ -1061,7 +1055,7 @@ begin
|
||||||
if not fld_stack.Empty() then continue;
|
if not fld_stack.Empty() then continue;
|
||||||
if r.T then
|
if r.T then
|
||||||
begin
|
begin
|
||||||
{self.}SetRRPr(r, ppr_unit_decorator_);
|
{self.}SetRRPr(r, ppr_);
|
||||||
r.RPr.Color.Val := nil;
|
r.RPr.Color.Val := nil;
|
||||||
{self.}RT(r);
|
{self.}RT(r);
|
||||||
end
|
end
|
||||||
|
|
@ -1099,7 +1093,6 @@ end;
|
||||||
|
|
||||||
function PRange.HyperlinkToToc();
|
function PRange.HyperlinkToToc();
|
||||||
begin
|
begin
|
||||||
ppr_ := ppr_unit_decorator_;
|
|
||||||
for anchor, arr in hyperlink_hash_ do
|
for anchor, arr in hyperlink_hash_ do
|
||||||
begin
|
begin
|
||||||
text := arr[0];
|
text := arr[0];
|
||||||
|
|
@ -1199,13 +1192,13 @@ function PRange.BasicRangesToPLineRange();
|
||||||
begin
|
begin
|
||||||
line_range_array_ := array();
|
line_range_array_ := array();
|
||||||
{self.}DynamicHeight := 0;
|
{self.}DynamicHeight := 0;
|
||||||
{self.}DynamicHeight += ppr_unit_decorator_.Spacing.Before;
|
{self.}DynamicHeight += ppr_.Spacing.Before;
|
||||||
// 段落的x偏移是缩进
|
// 段落的x偏移是缩进
|
||||||
{self.}XOffset := ppr_unit_decorator_.Ind.LeftChars ? ppr_unit_decorator_.Ind.LeftChars * ppr_unit_decorator_.RPr.Sz.Val : ppr_unit_decorator_.Ind.Left;
|
{self.}XOffset := ppr_.Ind.LeftChars ? ppr_.Ind.LeftChars * ppr_.RPr.Sz.Val : ppr_.Ind.Left;
|
||||||
{self.}YOffset := 0;
|
{self.}YOffset := 0;
|
||||||
|
|
||||||
pline_range := {self.}NewPLineRange();
|
pline_range := {self.}NewPLineRange();
|
||||||
pline_range.XOffset := ppr_unit_decorator_.Ind.FirstLine; // 首行有间距.用offsetx作为位置计算
|
pline_range.XOffset := ppr_.Ind.FirstLine; // 首行有间距.用offsetx作为位置计算
|
||||||
i := 0;
|
i := 0;
|
||||||
anchor := nil;
|
anchor := nil;
|
||||||
while i < length(body_range_array_) do
|
while i < length(body_range_array_) do
|
||||||
|
|
@ -1221,8 +1214,8 @@ begin
|
||||||
if range is class(TextRange) and range.RPr.Sz.Val > pline_range.TextMaxSize then
|
if range is class(TextRange) and range.RPr.Sz.Val > pline_range.TextMaxSize then
|
||||||
pline_range.TextMaxSize := range.RPr.Sz.Val;
|
pline_range.TextMaxSize := range.RPr.Sz.Val;
|
||||||
if range.DynamicHeight > pline_range.DynamicHeight then pline_range.DynamicHeight := range.DynamicHeight;
|
if range.DynamicHeight > pline_range.DynamicHeight then pline_range.DynamicHeight := range.DynamicHeight;
|
||||||
range.AdjustOffset(pline_range.XOffset, 0);
|
// range.AdjustOffset(pline_range.XOffset, 0);
|
||||||
// range.XOffset := pline_range.XOffset;
|
range.XOffset := pline_range.XOffset;
|
||||||
range.Parent := pline_range;
|
range.Parent := pline_range;
|
||||||
pline_range.AddRange(range);
|
pline_range.AddRange(range);
|
||||||
pline_range.XOffset += range.Width;
|
pline_range.XOffset += range.Width;
|
||||||
|
|
@ -1236,10 +1229,10 @@ begin
|
||||||
|
|
||||||
if length(line_range_array_) = 0 then
|
if length(line_range_array_) = 0 then
|
||||||
begin
|
begin
|
||||||
line_space := {self.}GetParagraphLineSpace(ppr_unit_decorator_.RPr.Sz.Val, ppr_unit_decorator_.Spacing.Line, ppr_unit_decorator_.Spacing.LineRule);
|
line_space := {self.}GetParagraphLineSpace(ppr_.RPr.Sz.Val, ppr_.Spacing.Line, ppr_.Spacing.LineRule);
|
||||||
{self.}DynamicHeight += line_space;
|
{self.}DynamicHeight += line_space;
|
||||||
end
|
end
|
||||||
{self.}DynamicHeight += ppr_unit_decorator_.Spacing.After;
|
{self.}DynamicHeight += ppr_.Spacing.After;
|
||||||
|
|
||||||
// println("line_range_array_ = {}", line_range_array_);
|
// println("line_range_array_ = {}", line_range_array_);
|
||||||
end;
|
end;
|
||||||
|
|
@ -1254,7 +1247,7 @@ end;
|
||||||
|
|
||||||
function PRange.AddPLineRange(pline_range: PLineRange);
|
function PRange.AddPLineRange(pline_range: PLineRange);
|
||||||
begin
|
begin
|
||||||
pline_range.LineSpace := {self.}GetParagraphLineSpace(pline_range.TextMaxSize, ppr_unit_decorator_.Spacing.Line, ppr_unit_decorator_.Spacing.LineRule);
|
pline_range.LineSpace := {self.}GetParagraphLineSpace(pline_range.TextMaxSize, ppr_.Spacing.Line, ppr_.Spacing.LineRule);
|
||||||
pline_range.DynamicHeight := max(pline_range.LineSpace, pline_range.DynamicHeight);
|
pline_range.DynamicHeight := max(pline_range.LineSpace, pline_range.DynamicHeight);
|
||||||
pline_range.Index := length(line_range_array_);
|
pline_range.Index := length(line_range_array_);
|
||||||
line_range_array_[length(line_range_array_)] := pline_range;
|
line_range_array_[length(line_range_array_)] := pline_range;
|
||||||
|
|
@ -1307,11 +1300,11 @@ begin
|
||||||
{self.}EndY := {self.}LowerBound;
|
{self.}EndY := {self.}LowerBound;
|
||||||
|
|
||||||
// 段前距只有不换页情况才计算
|
// 段前距只有不换页情况才计算
|
||||||
if not {self.}CheckAndAddPage({self.}EndY, ppr_unit_decorator_.Spacing.Before) then
|
if not {self.}CheckAndAddPage({self.}EndY, ppr_.Spacing.Before) then
|
||||||
{self.}EndY -= ppr_unit_decorator_.Spacing.Before;
|
{self.}EndY -= ppr_.Spacing.Before;
|
||||||
|
|
||||||
// 检查是否有段前分页
|
// 检查是否有段前分页
|
||||||
if ppr_unit_decorator_.PageBreakBefore then
|
if ppr_.PageBreakBefore then
|
||||||
{self.}CheckAndAddPage({self.}LowerBound, 1);
|
{self.}CheckAndAddPage({self.}LowerBound, 1);
|
||||||
|
|
||||||
for _,line_range in line_range_array_ do
|
for _,line_range in line_range_array_ do
|
||||||
|
|
@ -1320,7 +1313,7 @@ begin
|
||||||
if {self.}CheckAndAddPage(y, line_range.DynamicHeight) then // 行不够时候调整上一页LowerBound
|
if {self.}CheckAndAddPage(y, line_range.DynamicHeight) then // 行不够时候调整上一页LowerBound
|
||||||
docx_to_pdf_.PageManager[{self.}EndPage.Index - 1].LowerBound := y;
|
docx_to_pdf_.PageManager[{self.}EndPage.Index - 1].LowerBound := y;
|
||||||
line_range.Offset({self.}EndX, {self.}EndY, {self.}EndPage);
|
line_range.Offset({self.}EndX, {self.}EndY, {self.}EndPage);
|
||||||
line_range.Align(ppr_unit_decorator_.Jc.Val);
|
line_range.Align(ppr_.Jc.Val);
|
||||||
{self.}EndY := line_range.EndY;
|
{self.}EndY := line_range.EndY;
|
||||||
end
|
end
|
||||||
if not {self.}Parent is class(TcRange) then
|
if not {self.}Parent is class(TcRange) then
|
||||||
|
|
@ -1328,7 +1321,7 @@ begin
|
||||||
|
|
||||||
if length(line_range_array_) = 0 then // 空段落
|
if length(line_range_array_) = 0 then // 空段落
|
||||||
begin
|
begin
|
||||||
line_space := {self.}GetParagraphLineSpace(ppr_unit_decorator_.RPr.Sz.Val, ppr_unit_decorator_.Spacing.Line, ppr_unit_decorator_.Spacing.LineRule);
|
line_space := {self.}GetParagraphLineSpace(ppr_.RPr.Sz.Val, ppr_.Spacing.Line, ppr_.Spacing.LineRule);
|
||||||
{self.}EndY -= line_space;
|
{self.}EndY -= line_space;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -1336,7 +1329,7 @@ begin
|
||||||
{self.}DoAlternateContentAnchor();
|
{self.}DoAlternateContentAnchor();
|
||||||
{self.}DoToc();
|
{self.}DoToc();
|
||||||
|
|
||||||
{self.}EndY -= ppr_unit_decorator_.Spacing.After;
|
{self.}EndY -= ppr_.Spacing.After;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function PRange.DoToc();
|
function PRange.DoToc();
|
||||||
|
|
@ -1352,9 +1345,9 @@ begin
|
||||||
id := anchor.Graphic.GraphicData.Pic.BlipFill.Blip.Embed;
|
id := anchor.Graphic.GraphicData.Pic.BlipFill.Blip.Embed;
|
||||||
[image_type, image] := {self.}GetImageData(id);
|
[image_type, image] := {self.}GetImageData(id);
|
||||||
if not image then return;
|
if not image then return;
|
||||||
xfrm := new XfrmUnitDecorator(anchor.Graphic.GraphicData.Pic.SpPr.Xfrm);
|
xfrm := anchor.Graphic.GraphicData.Pic.SpPr.Xfrm;
|
||||||
position_h := new PositionHUnitDecorator(anchor.PositionH);
|
position_h := anchor.PositionH;
|
||||||
position_v := new PositionVUnitDecorator(anchor.PositionV);
|
position_v := anchor.PositionV;
|
||||||
[x, y] := {self.}GetXYCordinates();
|
[x, y] := {self.}GetXYCordinates();
|
||||||
if position_h.RelativeFrom = "paragraph" then
|
if position_h.RelativeFrom = "paragraph" then
|
||||||
x := {self.}StartY;
|
x := {self.}StartY;
|
||||||
|
|
@ -1378,9 +1371,9 @@ begin
|
||||||
begin
|
begin
|
||||||
wsp := anchor.Graphic.GraphicData.Wsp;
|
wsp := anchor.Graphic.GraphicData.Wsp;
|
||||||
[x, y] := {self.}GetXYCordinates();
|
[x, y] := {self.}GetXYCordinates();
|
||||||
xfrm := new XfrmUnitDecorator(wsp.SpPr.Xfrm);
|
xfrm := wsp.SpPr.Xfrm;
|
||||||
position_h := new PositionHUnitDecorator(anchor.PositionH);
|
position_h := anchor.PositionH;
|
||||||
position_v := new PositionVUnitDecorator(anchor.PositionV);
|
position_v := anchor.PositionV;
|
||||||
if position_h.RelativeFrom = "paragraph" then
|
if position_h.RelativeFrom = "paragraph" then
|
||||||
x := {self.}StartY;
|
x := {self.}StartY;
|
||||||
if position_v.RelativeFrom = "paragraph" then
|
if position_v.RelativeFrom = "paragraph" then
|
||||||
|
|
@ -1388,7 +1381,7 @@ begin
|
||||||
x += position_h.PosOffset.Text;
|
x += position_h.PosOffset.Text;
|
||||||
y -= position_v.PosOffset.Text;
|
y -= position_v.PosOffset.Text;
|
||||||
w := xfrm.Ext.CX;
|
w := xfrm.Ext.CX;
|
||||||
body_pr := new BodyPrUnitDecorator(wsp.BodyPr);
|
body_pr := wsp.BodyPr;
|
||||||
x += body_pr.LIns;
|
x += body_pr.LIns;
|
||||||
w -= (body_pr.LIns + body_pr.RIns);
|
w -= (body_pr.LIns + body_pr.RIns);
|
||||||
ps := wsp.Txbx.TxbxContent.Ps();
|
ps := wsp.Txbx.TxbxContent.Ps();
|
||||||
|
|
@ -1452,12 +1445,11 @@ end;
|
||||||
|
|
||||||
function PRange.RT(r: R; anchor: string);
|
function PRange.RT(r: R; anchor: string);
|
||||||
begin
|
begin
|
||||||
rpr := new DocxMLUnitDecorator.RPrUnitDecorator(r.RPr);
|
|
||||||
text := r.T.Text;
|
text := r.T.Text;
|
||||||
if text then {self.}SplitTextToTextRange(body_range_array_, text, rpr, anchor);
|
if text then {self.}SplitTextToTextRange(body_range_array_, text, r.rpr, anchor);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function PRange.SplitTextToTextRange(range_arr: array of BasicRange; text: string; rpr: RPrUnitDecorator; anchor: string);
|
function PRange.SplitTextToTextRange(range_arr: array of BasicRange; text: string; rpr: RPr; anchor: string);
|
||||||
begin
|
begin
|
||||||
pos := 1;
|
pos := 1;
|
||||||
if not rpr.Sz.Val then rpr.Sz.Val := rpr.SzCs.Val ? rpr.SzCs.Val : docx_to_pdf_.Font.GetDefaultSz();
|
if not rpr.Sz.Val then rpr.Sz.Val := rpr.SzCs.Val ? rpr.SzCs.Val : docx_to_pdf_.Font.GetDefaultSz();
|
||||||
|
|
@ -1551,14 +1543,14 @@ begin
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function PRange.SetRRPr(var r: R; ppr_unit_decorator: PPrUnitDecorator);
|
function PRange.SetRRPr(var r: R; ppr_: PPr);
|
||||||
begin
|
begin
|
||||||
new_rpr := new RPr();
|
new_rpr := new RPr();
|
||||||
styles := docx_to_pdf_.DocxComponents.GetStyles();
|
styles := docx_to_pdf_.DocxComponents.GetStyles();
|
||||||
new_rpr.Copy(styles.DocDefaults.RPrDefault.RPr);
|
new_rpr.Copy(styles.DocDefaults.RPrDefault.RPr);
|
||||||
if {self.}Parent is class(TcRange) then
|
if {self.}Parent is class(TcRange) then
|
||||||
{self.}SetRPrByTblStyleId(new_rpr, {self.}Parent.GetTblStyleId());
|
{self.}SetRPrByTblStyleId(new_rpr, {self.}Parent.GetTblStyleId());
|
||||||
{self.}SetRPrByStyleId(new_rpr, ppr_unit_decorator.PStyle.Val);
|
{self.}SetRPrByStyleId(new_rpr, ppr_.PStyle.Val);
|
||||||
{self.}SetRPrByStyleId(new_rpr, r.RPr.RStyle.Val);
|
{self.}SetRPrByStyleId(new_rpr, r.RPr.RStyle.Val);
|
||||||
new_rpr.Copy(r.RPr);
|
new_rpr.Copy(r.RPr);
|
||||||
r.RPr.Copy(new_rpr);
|
r.RPr.Copy(new_rpr);
|
||||||
|
|
@ -1600,10 +1592,9 @@ begin
|
||||||
if not ifObj(numbering_module) then return;
|
if not ifObj(numbering_module) then return;
|
||||||
[lvl_text, lvl] := numbering_module.GetNumberLvl(p_.PPr);
|
[lvl_text, lvl] := numbering_module.GetNumberLvl(p_.PPr);
|
||||||
if lvl_text = "" and ifnil(lvl) then return;
|
if lvl_text = "" and ifnil(lvl) then return;
|
||||||
{self.}SetRRPr(lvl, ppr_unit_decorator_);
|
{self.}SetRRPr(lvl, ppr_);
|
||||||
rpr := new RPrUnitDecorator(lvl.RPr);
|
|
||||||
// {self.}SplitTextToTextRange(bullet_range_array_, lvl_text, rpr);
|
// {self.}SplitTextToTextRange(bullet_range_array_, lvl_text, rpr);
|
||||||
{self.}SplitTextToTextRange(body_range_array_, lvl_text, rpr);
|
{self.}SplitTextToTextRange(body_range_array_, lvl_text, lvl.RPr);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function PRange.GetXYCordinates(): array of real;
|
function PRange.GetXYCordinates(): array of real;
|
||||||
|
|
@ -1691,8 +1682,8 @@ begin
|
||||||
else begin
|
else begin
|
||||||
lines := roundto(line / 240, -1);
|
lines := roundto(line / 240, -1);
|
||||||
multi := ceil(size / docx_to_pdf_.CurrentSect.BaseSize);
|
multi := ceil(size / docx_to_pdf_.CurrentSect.BaseSize);
|
||||||
if (not ifnil(ppr_unit_decorator_.SnapToGrid) and not ppr_unit_decorator_.SnapToGrid) or
|
if (not ifnil(ppr_.SnapToGrid) and not ppr_.SnapToGrid) or
|
||||||
((ifnil(ppr_unit_decorator_.SnapToGrid) or ppr_unit_decorator_.SnapToGrid) and lines > multi) then
|
((ifnil(ppr_.SnapToGrid) or ppr_.SnapToGrid) and lines > multi) then
|
||||||
multi *= lines;
|
multi *= lines;
|
||||||
return docx_to_pdf_.CurrentSect.SectPr.DocGrid.LinePitch * multi;
|
return docx_to_pdf_.CurrentSect.SectPr.DocGrid.LinePitch * multi;
|
||||||
end
|
end
|
||||||
|
|
@ -1704,7 +1695,7 @@ begin
|
||||||
docx_to_pdf_ := docx_to_pdf;
|
docx_to_pdf_ := docx_to_pdf;
|
||||||
tc_ := tc;
|
tc_ := tc;
|
||||||
trp_ := trp;
|
trp_ := trp;
|
||||||
tc_pr_unit_decorator_ := new TcPrUnitDecorator(tc_.TcPr);
|
tc_pr_ := tc_.TcPr;
|
||||||
content_next_page_ := false;
|
content_next_page_ := false;
|
||||||
top_ := false;
|
top_ := false;
|
||||||
end;
|
end;
|
||||||
|
|
@ -1793,7 +1784,7 @@ begin
|
||||||
region := new DTPUtils.Region();
|
region := new DTPUtils.Region();
|
||||||
region.BordersRange.Width := {self.}Width;
|
region.BordersRange.Width := {self.}Width;
|
||||||
region.BordersRange.FixedHeight := {self.}FixedHeight;
|
region.BordersRange.FixedHeight := {self.}FixedHeight;
|
||||||
region.BordersRange.TcPr := tc_pr_unit_decorator_;
|
region.BordersRange.TcPr := tc_pr_;
|
||||||
{self.}SetBorderRange(region.BordersRange);
|
{self.}SetBorderRange(region.BordersRange);
|
||||||
region_array_[length(region_array_)] := region;
|
region_array_[length(region_array_)] := region;
|
||||||
|
|
||||||
|
|
@ -1836,7 +1827,7 @@ begin
|
||||||
region.BordersRange.EndY := y;
|
region.BordersRange.EndY := y;
|
||||||
region.BordersRange.EndPage := pg;
|
region.BordersRange.EndPage := pg;
|
||||||
region.BordersRange.DynamicHeight := page_remaining_height;
|
region.BordersRange.DynamicHeight := page_remaining_height;
|
||||||
region.BordersRange.TcPr := tc_pr_unit_decorator_;
|
region.BordersRange.TcPr := tc_pr_;
|
||||||
region.BordersRange.Top := true;
|
region.BordersRange.Top := true;
|
||||||
region.BordersRange.Bottom := true;
|
region.BordersRange.Bottom := true;
|
||||||
{self.}SetBorderRange(region.BordersRange);
|
{self.}SetBorderRange(region.BordersRange);
|
||||||
|
|
@ -1855,7 +1846,7 @@ begin
|
||||||
region.BordersRange.EndY := y;
|
region.BordersRange.EndY := y;
|
||||||
region.BordersRange.EndPage := pg;
|
region.BordersRange.EndPage := pg;
|
||||||
region.BordersRange.DynamicHeight := surplus;
|
region.BordersRange.DynamicHeight := surplus;
|
||||||
region.BordersRange.TcPr := tc_pr_unit_decorator_;
|
region.BordersRange.TcPr := tc_pr_;
|
||||||
region.BordersRange.Top := true;
|
region.BordersRange.Top := true;
|
||||||
page_hash[pg.Index] := region;
|
page_hash[pg.Index] := region;
|
||||||
{self.}SetBorderRange(region.BordersRange);
|
{self.}SetBorderRange(region.BordersRange);
|
||||||
|
|
@ -1907,26 +1898,26 @@ begin
|
||||||
begin
|
begin
|
||||||
if tbl_pr.TblBorders.Top then
|
if tbl_pr.TblBorders.Top then
|
||||||
begin
|
begin
|
||||||
if not tc_pr_unit_decorator_.TcBorders.Top then
|
if not tc_pr_.TcBorders.Top then
|
||||||
tc_pr_unit_decorator_.TcBorders.Top.Copy(tbl_pr.TblBorders.Top);
|
tc_pr_.TcBorders.Top.Copy(tbl_pr.TblBorders.Top);
|
||||||
range.Top := true;
|
range.Top := true;
|
||||||
end
|
end
|
||||||
if tbl_pr.TblBorders.InsideH and {self.}VMerge <> {self.}Parent.Rows-1 then
|
if tbl_pr.TblBorders.InsideH and {self.}VMerge <> {self.}Parent.Rows-1 then
|
||||||
begin
|
begin
|
||||||
if not tc_pr_unit_decorator_.TcBorders.Bottom then
|
if not tc_pr_.TcBorders.Bottom then
|
||||||
tc_pr_unit_decorator_.TcBorders.Bottom.Copy(tbl_pr.TblBorders.InsideH);
|
tc_pr_.TcBorders.Bottom.Copy(tbl_pr.TblBorders.InsideH);
|
||||||
range.Bottom := true;
|
range.Bottom := true;
|
||||||
end
|
end
|
||||||
if tbl_pr.TblBorders.InsideV and {self.}Col <> {self.}Parent.Cols()-1 then
|
if tbl_pr.TblBorders.InsideV and {self.}Col <> {self.}Parent.Cols()-1 then
|
||||||
begin
|
begin
|
||||||
if not tc_pr_unit_decorator_.TcBorders.Right then
|
if not tc_pr_.TcBorders.Right then
|
||||||
tc_pr_unit_decorator_.TcBorders.Right.Copy(tbl_pr.TblBorders.InsideV);
|
tc_pr_.TcBorders.Right.Copy(tbl_pr.TblBorders.InsideV);
|
||||||
range.Right := true;
|
range.Right := true;
|
||||||
end
|
end
|
||||||
if tbl_pr.TblBorders.Bottom and {self.}VMerge = {self.}Parent.Rows-1 then
|
if tbl_pr.TblBorders.Bottom and {self.}VMerge = {self.}Parent.Rows-1 then
|
||||||
begin
|
begin
|
||||||
if not tc_pr_unit_decorator_.TcBorders.Bottom then
|
if not tc_pr_.TcBorders.Bottom then
|
||||||
tc_pr_unit_decorator_.TcBorders.Bottom.Copy(tbl_pr.TblBorders.Bottom);
|
tc_pr_.TcBorders.Bottom.Copy(tbl_pr.TblBorders.Bottom);
|
||||||
range.Bottom := true;
|
range.Bottom := true;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -1934,34 +1925,34 @@ begin
|
||||||
begin
|
begin
|
||||||
if tbl_pr.TblBorders.Bottom then
|
if tbl_pr.TblBorders.Bottom then
|
||||||
begin
|
begin
|
||||||
if not tc_pr_unit_decorator_.TcBorders.Bottom then
|
if not tc_pr_.TcBorders.Bottom then
|
||||||
tc_pr_unit_decorator_.TcBorders.Bottom.Copy(tbl_pr.TblBorders.Bottom);
|
tc_pr_.TcBorders.Bottom.Copy(tbl_pr.TblBorders.Bottom);
|
||||||
range.Bottom := true;
|
range.Bottom := true;
|
||||||
end
|
end
|
||||||
if tbl_pr.TblBorders.InsideV and {self.}Col <> {self.}Parent.Cols()-1 then
|
if tbl_pr.TblBorders.InsideV and {self.}Col <> {self.}Parent.Cols()-1 then
|
||||||
begin
|
begin
|
||||||
if not tc_pr_unit_decorator_.TcBorders.Right then
|
if not tc_pr_.TcBorders.Right then
|
||||||
tc_pr_unit_decorator_.TcBorders.Right.Copy(tbl_pr.TblBorders.InsideV);
|
tc_pr_.TcBorders.Right.Copy(tbl_pr.TblBorders.InsideV);
|
||||||
range.Right := true;
|
range.Right := true;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else begin
|
else begin
|
||||||
if tbl_pr.TblBorders.Bottom and {self.}VMerge = {self.}Parent.Rows-1 then
|
if tbl_pr.TblBorders.Bottom and {self.}VMerge = {self.}Parent.Rows-1 then
|
||||||
begin
|
begin
|
||||||
if not tc_pr_unit_decorator_.TcBorders.Bottom then
|
if not tc_pr_.TcBorders.Bottom then
|
||||||
tc_pr_unit_decorator_.TcBorders.Bottom.Copy(tbl_pr.TblBorders.Bottom);
|
tc_pr_.TcBorders.Bottom.Copy(tbl_pr.TblBorders.Bottom);
|
||||||
range.Bottom := true;
|
range.Bottom := true;
|
||||||
end
|
end
|
||||||
if tbl_pr.TblBorders.InsideH and {self.}VMerge <> {self.}Parent.Rows-1 then
|
if tbl_pr.TblBorders.InsideH and {self.}VMerge <> {self.}Parent.Rows-1 then
|
||||||
begin
|
begin
|
||||||
if not tc_pr_unit_decorator_.TcBorders.Bottom then
|
if not tc_pr_.TcBorders.Bottom then
|
||||||
tc_pr_unit_decorator_.TcBorders.Bottom.Copy(tbl_pr.TblBorders.InsideH);
|
tc_pr_.TcBorders.Bottom.Copy(tbl_pr.TblBorders.InsideH);
|
||||||
range.Bottom := true;
|
range.Bottom := true;
|
||||||
end
|
end
|
||||||
if tbl_pr.TblBorders.InsideV and {self.}Col <> {self.}Parent.Cols()-1 then
|
if tbl_pr.TblBorders.InsideV and {self.}Col <> {self.}Parent.Cols()-1 then
|
||||||
begin
|
begin
|
||||||
if not tc_pr_unit_decorator_.TcBorders.Right then
|
if not tc_pr_.TcBorders.Right then
|
||||||
tc_pr_unit_decorator_.TcBorders.Right.Copy(tbl_pr.TblBorders.InsideV);
|
tc_pr_.TcBorders.Right.Copy(tbl_pr.TblBorders.InsideV);
|
||||||
range.Right := true;
|
range.Right := true;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -1970,8 +1961,8 @@ begin
|
||||||
begin
|
begin
|
||||||
if tbl_pr.TblBorders.Left then
|
if tbl_pr.TblBorders.Left then
|
||||||
begin
|
begin
|
||||||
if not tc_pr_unit_decorator_.TcBorders.Left then
|
if not tc_pr_.TcBorders.Left then
|
||||||
tc_pr_unit_decorator_.TcBorders.Left.Copy(tbl_pr.TblBorders.Left);
|
tc_pr_.TcBorders.Left.Copy(tbl_pr.TblBorders.Left);
|
||||||
range.Left := true;
|
range.Left := true;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -1979,8 +1970,8 @@ begin
|
||||||
begin
|
begin
|
||||||
if tbl_pr.TblBorders.Right then
|
if tbl_pr.TblBorders.Right then
|
||||||
begin
|
begin
|
||||||
if not tc_pr_unit_decorator_.TcBorders.Right then
|
if not tc_pr_.TcBorders.Right then
|
||||||
tc_pr_unit_decorator_.TcBorders.Right.Copy(tbl_pr.TblBorders.Right);
|
tc_pr_.TcBorders.Right.Copy(tbl_pr.TblBorders.Right);
|
||||||
range.Right := true;
|
range.Right := true;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -2028,9 +2019,9 @@ end;
|
||||||
function TblRange.Calc();
|
function TblRange.Calc();
|
||||||
begin
|
begin
|
||||||
{self.}SetTblTblPr(tbl_);
|
{self.}SetTblTblPr(tbl_);
|
||||||
tbl_pr_unit_decorator_ := new TblPrUnitDecorator(tbl_.TblPr);
|
tbl_pr_:= tbl_.TblPr;
|
||||||
tbl_grid_unit_decorator := new TblGridUnitDecorator(tbl_.TblGrid);
|
tbl_grid_:= tbl_.TblGrid;
|
||||||
grid_cols_ := tbl_grid_unit_decorator.GridCols();
|
grid_cols_ := tbl_grid_.GridCols();
|
||||||
// 如果是根据内容自适应,应该计算并调整grid_cols的值
|
// 如果是根据内容自适应,应该计算并调整grid_cols的值
|
||||||
trs := tbl_.Trs();
|
trs := tbl_.Trs();
|
||||||
rows_ := length(trs);
|
rows_ := length(trs);
|
||||||
|
|
@ -2041,12 +2032,12 @@ begin
|
||||||
{self.}CreateTableMatrix(grid_cols_, trs);
|
{self.}CreateTableMatrix(grid_cols_, trs);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TblRange.CreateTableMatrix(grid_cols: array of GridColUnitDecorator; trs: array of Tr);
|
function TblRange.CreateTableMatrix(grid_cols: array of GridCol; trs: array of Tr);
|
||||||
begin
|
begin
|
||||||
for i,tr in trs do
|
for i,tr in trs do
|
||||||
begin
|
begin
|
||||||
{self.}SetTrTrPr(tr);
|
{self.}SetTrTrPr(tr);
|
||||||
tr_pr := new TrPrUnitDecorator(tr.TrPr);
|
tr_pr := tr.TrPr;
|
||||||
tc_x := 0;
|
tc_x := 0;
|
||||||
trp := new DTPUtils.TrProperty();
|
trp := new DTPUtils.TrProperty();
|
||||||
trp.TrPr := tr_pr;
|
trp.TrPr := tr_pr;
|
||||||
|
|
@ -2061,7 +2052,7 @@ begin
|
||||||
else if (i + 1) % 2 = 0 then {self.}OverrideTcPrByTblStylePrType(tc.TcPr, "band1Horz");
|
else if (i + 1) % 2 = 0 then {self.}OverrideTcPrByTblStylePrType(tc.TcPr, "band1Horz");
|
||||||
else {self.}OverrideTcPrByTblStylePrType(tc.TcPr, "band2Horz");
|
else {self.}OverrideTcPrByTblStylePrType(tc.TcPr, "band2Horz");
|
||||||
|
|
||||||
grid_span := new GridSpanUnitDecorator(tc.TcPr.GridSpan);
|
grid_span := tc.TcPr.GridSpan;
|
||||||
if tc.TcPr.VMerge.IsApplied and tc.TcPr.VMerge.Val <> "restart" then
|
if tc.TcPr.VMerge.IsApplied and tc.TcPr.VMerge.Val <> "restart" then
|
||||||
begin
|
begin
|
||||||
tc_x += grid_cols[pos++].W;
|
tc_x += grid_cols[pos++].W;
|
||||||
|
|
@ -2102,7 +2093,7 @@ begin
|
||||||
{self.}StartX := x + {self.}XOffset;
|
{self.}StartX := x + {self.}XOffset;
|
||||||
{self.}StartY := y + {self.}YOffset; // table的offset实际都为0
|
{self.}StartY := y + {self.}YOffset; // table的offset实际都为0
|
||||||
{self.}StartPage := page;
|
{self.}StartPage := page;
|
||||||
{self.}ResetCoordinates(tbl_pr_unit_decorator_, grid_cols_);
|
{self.}ResetCoordinates(tbl_pr_, grid_cols_);
|
||||||
{self.}EndX := {self.}StartX;
|
{self.}EndX := {self.}StartX;
|
||||||
{self.}EndY := {self.}StartY;
|
{self.}EndY := {self.}StartY;
|
||||||
{self.}EndPage := {self.}StartPage;
|
{self.}EndPage := {self.}StartPage;
|
||||||
|
|
@ -2209,7 +2200,7 @@ end;
|
||||||
function TblRange.OverrideTcPrByTblStylePrType(var tc_pr: TcPr; type: string);
|
function TblRange.OverrideTcPrByTblStylePrType(var tc_pr: TcPr; type: string);
|
||||||
begin
|
begin
|
||||||
// tc_pr应该是经过外层copy的
|
// tc_pr应该是经过外层copy的
|
||||||
tbl_style_pr := docx_to_pdf_.DocxComponents.GetTblStylePrByType(tbl_pr_unit_decorator_.TblStyle.Val, type);
|
tbl_style_pr := docx_to_pdf_.DocxComponents.GetTblStylePrByType(tbl_pr_.TblStyle.Val, type);
|
||||||
if tbl_style_pr then tc_pr.Copy(tbl_style_pr.TcPr);
|
if tbl_style_pr then tc_pr.Copy(tbl_style_pr.TcPr);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
@ -2236,7 +2227,7 @@ end;
|
||||||
function TblRange.SetTrTrPr(var tr: Tr);
|
function TblRange.SetTrTrPr(var tr: Tr);
|
||||||
begin
|
begin
|
||||||
new_tr_pr := new TrPr();
|
new_tr_pr := new TrPr();
|
||||||
{self.}SetTrPrByStyleId(new_tr_pr, tbl_pr_unit_decorator_.TblStyle.Val);
|
{self.}SetTrPrByStyleId(new_tr_pr, tbl_pr_.TblStyle.Val);
|
||||||
new_tr_pr.Copy(tr.TrPr);
|
new_tr_pr.Copy(tr.TrPr);
|
||||||
tr.TrPr.Copy(new_tr_pr);
|
tr.TrPr.Copy(new_tr_pr);
|
||||||
end;
|
end;
|
||||||
|
|
@ -2256,7 +2247,7 @@ end;
|
||||||
function TblRange.SetTcTcPr(var tc: Tc);
|
function TblRange.SetTcTcPr(var tc: Tc);
|
||||||
begin
|
begin
|
||||||
new_tc_pr := new TcPr();
|
new_tc_pr := new TcPr();
|
||||||
{self.}SetTcPrByStyleId(new_tc_pr, tbl_pr_unit_decorator_.TblStyle.Val);
|
{self.}SetTcPrByStyleId(new_tc_pr, tbl_pr_.TblStyle.Val);
|
||||||
new_tc_pr.Copy(tc.TcPr);
|
new_tc_pr.Copy(tc.TcPr);
|
||||||
tc.TcPr.Copy(new_tc_pr);
|
tc.TcPr.Copy(new_tc_pr);
|
||||||
end;
|
end;
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ public
|
||||||
function AddElement(element: tslobj);
|
function AddElement(element: tslobj);
|
||||||
|
|
||||||
public
|
public
|
||||||
SectPr: SectPrUnitDecorator;
|
SectPr: SectPr;
|
||||||
Elements: array of tslobj;
|
Elements: array of tslobj;
|
||||||
BaseSize: real;
|
BaseSize: real;
|
||||||
end;
|
end;
|
||||||
|
|
@ -142,7 +142,7 @@ public
|
||||||
public
|
public
|
||||||
Index: integer;
|
Index: integer;
|
||||||
Number: integer;
|
Number: integer;
|
||||||
SectPr: SectPrUnitDecorator;
|
SectPr: SectPr;
|
||||||
TextPoint: Point; // 正文坐标
|
TextPoint: Point; // 正文坐标
|
||||||
FtrPoint: Point; // 页脚坐标
|
FtrPoint: Point; // 页脚坐标
|
||||||
HdrPoint: Point; // 页眉坐标
|
HdrPoint: Point; // 页眉坐标
|
||||||
|
|
@ -185,6 +185,7 @@ function DocxComponentsModule.GetStyles(): Styles;
|
||||||
begin
|
begin
|
||||||
if styles_deserialize_flag_ then return {self.}Styles;
|
if styles_deserialize_flag_ then return {self.}Styles;
|
||||||
{self.}Styles.Deserialize();
|
{self.}Styles.Deserialize();
|
||||||
|
{self.}Styles.ConvertToPoint();
|
||||||
styles_deserialize_flag_ := true;
|
styles_deserialize_flag_ := true;
|
||||||
return {self.}Styles;
|
return {self.}Styles;
|
||||||
end;
|
end;
|
||||||
|
|
@ -209,6 +210,7 @@ begin
|
||||||
if numbering_module_ then return numbering_module_;
|
if numbering_module_ then return numbering_module_;
|
||||||
if not {self.}Numbering then return nil;
|
if not {self.}Numbering then return nil;
|
||||||
{self.}Numbering.Deserialize();
|
{self.}Numbering.Deserialize();
|
||||||
|
{self.}Numbering.ConvertToPoint();
|
||||||
numbering_module_ := new NumberingModule({self.}Numbering);
|
numbering_module_ := new NumberingModule({self.}Numbering);
|
||||||
return numbering_module_;
|
return numbering_module_;
|
||||||
end;
|
end;
|
||||||
|
|
@ -230,6 +232,7 @@ begin
|
||||||
index := replaceStr(replaceStr(target, "footer", ""), ".xml", "");
|
index := replaceStr(replaceStr(target, "footer", ""), ".xml", "");
|
||||||
obj := {self.}Footers(strtoint(index));
|
obj := {self.}Footers(strtoint(index));
|
||||||
obj.Deserialize();
|
obj.Deserialize();
|
||||||
|
obj.ConvertToPoint();
|
||||||
ftr_hash_[target] := obj;
|
ftr_hash_[target] := obj;
|
||||||
return obj;
|
return obj;
|
||||||
end;
|
end;
|
||||||
|
|
@ -240,6 +243,7 @@ begin
|
||||||
index := replaceStr(replaceStr(target, "header", ""), ".xml", "");
|
index := replaceStr(replaceStr(target, "header", ""), ".xml", "");
|
||||||
obj := {self.}Headers(strtoint(index));
|
obj := {self.}Headers(strtoint(index));
|
||||||
obj.Deserialize();
|
obj.Deserialize();
|
||||||
|
obj.ConvertToPoint();
|
||||||
hdr_hash_[target] := obj;
|
hdr_hash_[target] := obj;
|
||||||
return obj;
|
return obj;
|
||||||
end;
|
end;
|
||||||
|
|
@ -271,6 +275,7 @@ begin
|
||||||
if footnotes_adapter_ then return footnotes_adapter_;
|
if footnotes_adapter_ then return footnotes_adapter_;
|
||||||
obj := {self.}Footnotes;
|
obj := {self.}Footnotes;
|
||||||
obj.Deserialize();
|
obj.Deserialize();
|
||||||
|
obj.ConvertToPoint();
|
||||||
footnotes_adapter_ := new FootnotesAdapter(obj);
|
footnotes_adapter_ := new FootnotesAdapter(obj);
|
||||||
return footnotes_adapter_;
|
return footnotes_adapter_;
|
||||||
end;
|
end;
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ public
|
||||||
function Do();override;
|
function Do();override;
|
||||||
|
|
||||||
public
|
public
|
||||||
RPr: RPrUnitDecorator;
|
RPr: RPr;
|
||||||
Text: string;
|
Text: string;
|
||||||
Font: PdfFont;
|
Font: PdfFont;
|
||||||
Type: integer; // 0:默认,1: 数字,2:英文,3:中文,4:中文标点,5:,.英文逗号和点
|
Type: integer; // 0:默认,1: 数字,2:英文,3:中文,4:中文标点,5:,.英文逗号和点
|
||||||
|
|
@ -43,7 +43,7 @@ public
|
||||||
function DoFill();
|
function DoFill();
|
||||||
|
|
||||||
public
|
public
|
||||||
TcPr: TcPrUnitDecorator;
|
TcPr: TcPr;
|
||||||
Left: boolean;
|
Left: boolean;
|
||||||
Top: boolean;
|
Top: boolean;
|
||||||
Right: boolean;
|
Right: boolean;
|
||||||
|
|
@ -60,7 +60,7 @@ public
|
||||||
function Do();override;
|
function Do();override;
|
||||||
|
|
||||||
public
|
public
|
||||||
RPr: RPrUnitDecorator;
|
RPr: RPr;
|
||||||
Image: PdfImage;
|
Image: PdfImage;
|
||||||
Type: string;
|
Type: string;
|
||||||
end;
|
end;
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ public
|
||||||
function Create();
|
function Create();
|
||||||
|
|
||||||
public
|
public
|
||||||
TrPr: TrPrUnitDecorator;
|
TrPr: TrPr;
|
||||||
Height: real;
|
Height: real;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue