对依赖的OfficeXml性能优化版本做调整
This commit is contained in:
parent
0417669eb2
commit
448bbfc7e2
|
|
@ -33,4 +33,4 @@ TSDocxToPdf中的[Font](./ware/TSFontWare.tsf)属性是设置转PDF时的一些
|
||||||
|
|
||||||
1. `office_plugin.dll`
|
1. `office_plugin.dll`
|
||||||
2. [PDF](https://git.mytsl.cn/tinysoft/Pdf)相关包
|
2. [PDF](https://git.mytsl.cn/tinysoft/Pdf)相关包
|
||||||
3. [Office](https://git.mytsl.cn/tinysoft/Office)相关包
|
3. [Office](https://git.mytsl.cn/tinysoft/OfficeXml)相关包
|
||||||
|
|
|
||||||
|
|
@ -118,8 +118,8 @@ begin
|
||||||
elements := sect_ware.Elements();
|
elements := sect_ware.Elements();
|
||||||
for _,element in elements do
|
for _,element in elements do
|
||||||
begin
|
begin
|
||||||
// if _ = 3 then break;
|
// if _ = 4 then break;
|
||||||
// if _ <> 4 then continue;
|
// if _ = 624 then
|
||||||
// println("_ = {}, xml_file_ = {}", _, xml_file_);
|
// println("_ = {}, xml_file_ = {}", _, xml_file_);
|
||||||
if element.LocalName = "p" then {self.}TransformP(text_point_, element, w, lb);
|
if element.LocalName = "p" then {self.}TransformP(text_point_, element, w, lb);
|
||||||
else if element.LocalName = "tbl" then {self.}TransformTbl(text_point_, element, w, lb);
|
else if element.LocalName = "tbl" then {self.}TransformTbl(text_point_, element, w, lb);
|
||||||
|
|
|
||||||
|
|
@ -24,10 +24,11 @@ private
|
||||||
function BasicRangesToLineRange(): tableArray;
|
function BasicRangesToLineRange(): tableArray;
|
||||||
function CheckAndAddPage(y: real; offset: real): boolean;
|
function CheckAndAddPage(y: real; offset: real): boolean;
|
||||||
function GetUtf8CharLength(byte: string): integer;
|
function GetUtf8CharLength(byte: string): integer;
|
||||||
function RToTextRange(r: R; link: string);
|
|
||||||
function SplitTextToTextRange(text: string; rpr: RPrUnitDecorator; link: string);
|
function SplitTextToTextRange(text: string; rpr: RPrUnitDecorator; link: string);
|
||||||
|
function RToTextRange(r: R; link: string);
|
||||||
function RToDrawingRange(r: R);
|
function RToDrawingRange(r: R);
|
||||||
function RAlternateContentToRange(r: R);
|
function RAlternateContentToRange(r: R);
|
||||||
|
function RFootnoteReference(r: R);
|
||||||
function SetLinesAlignment();
|
function SetLinesAlignment();
|
||||||
function ResetCoordinates();
|
function ResetCoordinates();
|
||||||
function NewLineRange(): TSPdfLineRange;
|
function NewLineRange(): TSPdfLineRange;
|
||||||
|
|
@ -118,6 +119,7 @@ begin
|
||||||
{self.}CheckAndAddPage({self.}LowerBound, 1);
|
{self.}CheckAndAddPage({self.}LowerBound, 1);
|
||||||
else if ifObj(element.Drawing.XmlNode) then {self.}RToDrawingRange(element);
|
else if ifObj(element.Drawing.XmlNode) then {self.}RToDrawingRange(element);
|
||||||
else if ifObj(element.AlternateContent.XmlNode) then {self.}RAlternateContentToRange(element);
|
else if ifObj(element.AlternateContent.XmlNode) then {self.}RAlternateContentToRange(element);
|
||||||
|
else if ifObj(element.FootnoteReference.XmlNode) then {self.}RFootnoteReference(element);
|
||||||
else if not fld then {self.}RToTextRange(element, bookmark_name);
|
else if not fld then {self.}RToTextRange(element, bookmark_name);
|
||||||
end
|
end
|
||||||
else if element.LocalName = "fldSimple" then
|
else if element.LocalName = "fldSimple" then
|
||||||
|
|
@ -261,8 +263,11 @@ begin
|
||||||
for _,r in rs do
|
for _,r in rs do
|
||||||
begin
|
begin
|
||||||
if r.FldChar.FldCharType = "begin" then break;
|
if r.FldChar.FldCharType = "begin" then break;
|
||||||
r.RPr := new RPr();
|
// TODO:officexml项目是否应该保留赋值接口,如何统一
|
||||||
|
r.RPr.Lang.Val := "zh-CN";
|
||||||
|
// r.RPr := new RPr();
|
||||||
{self.}SetRPr(r.RPr, ppr_unit_decorator_);
|
{self.}SetRPr(r.RPr, ppr_unit_decorator_);
|
||||||
|
r.RPr.Color.Val := nil;
|
||||||
{self.}RToTextRange(r, hyperlink.Anchor);
|
{self.}RToTextRange(r, hyperlink.Anchor);
|
||||||
end
|
end
|
||||||
arr := array();
|
arr := array();
|
||||||
|
|
@ -502,6 +507,18 @@ begin
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TSPdfParagraphRange.RFootnoteReference(r: R);
|
||||||
|
begin
|
||||||
|
id := R.FootnoteReference.Id;
|
||||||
|
footnotes_adapter := docx_components_ware_.GetFootnotesAdapter();
|
||||||
|
footnote := footnotes_adapter.GetFootnoteById(id);
|
||||||
|
sect_ware := docx_to_pdf_.GetCurrentSectWare();
|
||||||
|
w := sect_ware.SectPr.PgSz.W - sect_ware.SectPr.PgMar.Right - sect_ware.SectPr.PgMar.Left;
|
||||||
|
lb := 0;
|
||||||
|
[x, y] := docx_to_pdf_.CalculateTextCoordinates();
|
||||||
|
// range := new TSPdfParagraphRange(self, page_, docx_components_ware_, );
|
||||||
|
end;
|
||||||
|
|
||||||
function TSPdfParagraphRange.GetXYCordinates(): array of real;
|
function TSPdfParagraphRange.GetXYCordinates(): array of real;
|
||||||
begin
|
begin
|
||||||
xml_file := docx_to_pdf_.GetCurrentXmlFile();
|
xml_file := docx_to_pdf_.GetCurrentXmlFile();
|
||||||
|
|
@ -585,8 +602,11 @@ begin
|
||||||
new_ppr.RPr.Copy(styles.DocDefaults.RPrDefault.RPr);
|
new_ppr.RPr.Copy(styles.DocDefaults.RPrDefault.RPr);
|
||||||
{self.}SetPPrByStyleId(new_ppr, extra_style_id_);
|
{self.}SetPPrByStyleId(new_ppr, extra_style_id_);
|
||||||
{self.}SetPPrByStyleId(new_ppr, ppr.PStyle.Val);
|
{self.}SetPPrByStyleId(new_ppr, ppr.PStyle.Val);
|
||||||
new_ppr.Copy(ppr);
|
if ifObj(ppr) then
|
||||||
ppr.Copy(new_ppr);
|
begin
|
||||||
|
new_ppr.Copy(ppr);
|
||||||
|
ppr.Copy(new_ppr);
|
||||||
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TSPdfParagraphRange.SetPPrByStyleId(var ppr: PPr; style_id: string);
|
function TSPdfParagraphRange.SetPPrByStyleId(var ppr: PPr; style_id: string);
|
||||||
|
|
@ -609,8 +629,11 @@ begin
|
||||||
new_rpr.Copy(styles.DocDefaults.RPrDefault.RPr);
|
new_rpr.Copy(styles.DocDefaults.RPrDefault.RPr);
|
||||||
{self.}SetRPrByStyleId(new_rpr, ppr.PStyle.Val);
|
{self.}SetRPrByStyleId(new_rpr, ppr.PStyle.Val);
|
||||||
{self.}SetRPrByStyleId(new_rpr, rpr.RStyle.Val);
|
{self.}SetRPrByStyleId(new_rpr, rpr.RStyle.Val);
|
||||||
new_rpr.Copy(rpr);
|
if ifObj(rpr) then
|
||||||
rpr.Copy(new_rpr);
|
begin
|
||||||
|
new_rpr.Copy(rpr);
|
||||||
|
rpr.Copy(new_rpr);
|
||||||
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TSPdfParagraphRange.SetRPrByStyleId(var rpr: RPr; style_id: string);
|
function TSPdfParagraphRange.SetRPrByStyleId(var rpr: RPr; style_id: string);
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ private
|
||||||
[weakref]docx_components_ware_: Components;
|
[weakref]docx_components_ware_: Components;
|
||||||
[weakref]table_: Tbl;
|
[weakref]table_: Tbl;
|
||||||
[weakref]page_: TSPage;
|
[weakref]page_: TSPage;
|
||||||
|
tbl_pr_unit_decorator_: TblPrUnitDecorator;
|
||||||
cell_range_array_: tableArray;
|
cell_range_array_: tableArray;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
@ -41,11 +42,11 @@ end;
|
||||||
function TSPdfTableRange.Calc();
|
function TSPdfTableRange.Calc();
|
||||||
begin
|
begin
|
||||||
{self.}SetTblPr(table_.TblPr);
|
{self.}SetTblPr(table_.TblPr);
|
||||||
table_.TblPr := new TblPrUnitDecorator(table_.TblPr);
|
tbl_pr_unit_decorator_ := new TblPrUnitDecorator(table_.TblPr);
|
||||||
grid_cols := table_.TblGrid.GridCols();
|
grid_cols := table_.TblGrid.GridCols();
|
||||||
for i:=0 to length(grid_cols)-1 do
|
for i:=0 to length(grid_cols)-1 do
|
||||||
grid_cols[i] := new GridColUnitDecorator(grid_cols[i]);
|
grid_cols[i] := new GridColUnitDecorator(grid_cols[i]);
|
||||||
{self.}ResetCoordinates(table_.TblPr, grid_cols);
|
{self.}ResetCoordinates(tbl_pr_unit_decorator_, grid_cols);
|
||||||
{self.}EndX := {self.}StartX;
|
{self.}EndX := {self.}StartX;
|
||||||
{self.}EndY := {self.}StartY;
|
{self.}EndY := {self.}StartY;
|
||||||
// 如果是根据内容自适应,应该计算并调整grid_cols的值
|
// 如果是根据内容自适应,应该计算并调整grid_cols的值
|
||||||
|
|
@ -123,7 +124,7 @@ begin
|
||||||
cell_range_array_[vmerge_arr[pos][0]][pos].VMerge := vmerge_arr[pos][1];
|
cell_range_array_[vmerge_arr[pos][0]][pos].VMerge := vmerge_arr[pos][1];
|
||||||
vmerge_arr[pos] := nil;
|
vmerge_arr[pos] := nil;
|
||||||
end
|
end
|
||||||
cell_range := new TSPdfCellRange(self, docx_to_pdf_, page_, docx_components_ware_, tc, table_.TblPr, tr.TrPr);
|
cell_range := new TSPdfCellRange(self, docx_to_pdf_, page_, docx_components_ware_, tc, tbl_pr_unit_decorator_, tr.TrPr);
|
||||||
cell_range.StartX := tc_x;
|
cell_range.StartX := tc_x;
|
||||||
cell_range.Width := grid_cols[pos].W;
|
cell_range.Width := grid_cols[pos].W;
|
||||||
cell_range.LowerBound := {self.}LowerBound;
|
cell_range.LowerBound := {self.}LowerBound;
|
||||||
|
|
@ -234,7 +235,7 @@ end;
|
||||||
function TSPdfTableRange.SetTblStylePr(var tc_pr: TcPr; type: string);
|
function TSPdfTableRange.SetTblStylePr(var tc_pr: TcPr; type: string);
|
||||||
begin
|
begin
|
||||||
{self.}SetTcPr(tc_pr);
|
{self.}SetTcPr(tc_pr);
|
||||||
tbl_style_pr := docx_components_ware_.GetTblStylePrByType(table_.TblPr.TblStyle.Val, type);
|
tbl_style_pr := docx_components_ware_.GetTblStylePrByType(tbl_pr_unit_decorator_.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;
|
||||||
|
|
||||||
|
|
@ -244,7 +245,7 @@ begin
|
||||||
for _,grid_col in grid_cols do
|
for _,grid_col in grid_cols do
|
||||||
total_width += grid_col.W;
|
total_width += grid_col.W;
|
||||||
diff := total_width - {self.}Width;
|
diff := total_width - {self.}Width;
|
||||||
case tbl_pr.jc.Val of
|
case tbl_pr.Jc.Val of
|
||||||
"center":
|
"center":
|
||||||
begin
|
begin
|
||||||
offset := diff/2;
|
offset := diff/2;
|
||||||
|
|
@ -281,9 +282,12 @@ end;
|
||||||
function TSPdfTableRange.SetTrPr(var tr_pr: TrPr);
|
function TSPdfTableRange.SetTrPr(var tr_pr: TrPr);
|
||||||
begin
|
begin
|
||||||
new_tr_pr := new TrPr();
|
new_tr_pr := new TrPr();
|
||||||
{self.}SetTrPrByStyleId(new_tr_pr, table_.TblPr.TblStyle.Val);
|
{self.}SetTrPrByStyleId(new_tr_pr, tbl_pr_unit_decorator_.TblStyle.Val);
|
||||||
new_tr_pr.Copy(tr_pr);
|
if ifObj(tr_pr) then
|
||||||
tr_pr.Copy(new_tr_pr);
|
begin
|
||||||
|
new_tr_pr.Copy(tr_pr);
|
||||||
|
tr_pr.Copy(new_tr_pr);
|
||||||
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TSPdfTableRange.SetTrPrByStyleId(var tr_pr: TrPr; style_id: string);
|
function TSPdfTableRange.SetTrPrByStyleId(var tr_pr: TrPr; style_id: string);
|
||||||
|
|
@ -301,9 +305,12 @@ end;
|
||||||
function TSPdfTableRange.SetTcPr(var tc_pr: TcPr);
|
function TSPdfTableRange.SetTcPr(var tc_pr: TcPr);
|
||||||
begin
|
begin
|
||||||
new_tc_pr := new TcPr();
|
new_tc_pr := new TcPr();
|
||||||
{self.}SetTcPrByStyleId(new_tc_pr, table_.TblPr.TblStyle.Val);
|
{self.}SetTcPrByStyleId(new_tc_pr, tbl_pr_unit_decorator_.TblStyle.Val);
|
||||||
new_tc_pr.Copy(tc_pr);
|
if ifObj(tc_pr) then
|
||||||
tc_pr.Copy(new_tc_pr);
|
begin
|
||||||
|
new_tc_pr.Copy(tc_pr);
|
||||||
|
tc_pr.Copy(new_tc_pr);
|
||||||
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TSPdfTableRange.SetTcPrByStyleId(var tc_pr: TcPr; style_id: string);
|
function TSPdfTableRange.SetTcPrByStyleId(var tc_pr: TcPr; style_id: string);
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ public
|
||||||
function GetHdr(target: string): Hdr;
|
function GetHdr(target: string): Hdr;
|
||||||
function GetFtrRelsAdapter(target: string): RelationShipsAdapter;
|
function GetFtrRelsAdapter(target: string): RelationShipsAdapter;
|
||||||
function GetHdrRelsAdapter(target: string): RelationShipsAdapter;
|
function GetHdrRelsAdapter(target: string): RelationShipsAdapter;
|
||||||
|
function GetFootnotesAdapter(): FootnotesAdapter;
|
||||||
|
|
||||||
private
|
private
|
||||||
styles_deserialize_flag_: boolean;
|
styles_deserialize_flag_: boolean;
|
||||||
|
|
@ -21,6 +22,7 @@ private
|
||||||
hdr_hash_: array of Hdr;
|
hdr_hash_: array of Hdr;
|
||||||
hdr_rel_hash_: array of RelationShipsAdapter;
|
hdr_rel_hash_: array of RelationShipsAdapter;
|
||||||
ftr_rel_hash_: array of RelationShipsAdapter;
|
ftr_rel_hash_: array of RelationShipsAdapter;
|
||||||
|
footnotes_adapter_: FootnotesAdapter;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TSDocxComponentsWare.Create();
|
function TSDocxComponentsWare.Create();
|
||||||
|
|
@ -117,3 +119,12 @@ begin
|
||||||
ftr_rel_hash_[target] := rels_adapter;
|
ftr_rel_hash_[target] := rels_adapter;
|
||||||
return rels_adapter;
|
return rels_adapter;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TSDocxComponentsWare.GetFootnotesAdapter(): FootnotesAdapter;
|
||||||
|
begin
|
||||||
|
if footnotes_adapter_ then return footnotes_adapter_;
|
||||||
|
obj := {self.}Footnotes;
|
||||||
|
obj.Deserialize();
|
||||||
|
footnotes_adapter_ := new FootnotesAdapter();
|
||||||
|
return footnotes_adapter_;
|
||||||
|
end;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue