parent
5dc201c1a2
commit
68ce759668
|
|
@ -12,9 +12,14 @@ public
|
||||||
function IsReComputeByCantSplit(): boolean;
|
function IsReComputeByCantSplit(): boolean;
|
||||||
function IfRemoveEmptyRectangle(): boolean;
|
function IfRemoveEmptyRectangle(): boolean;
|
||||||
|
|
||||||
|
private
|
||||||
|
function GetCellPrType(): string;
|
||||||
|
|
||||||
public
|
public
|
||||||
VMerge;
|
VMerge;
|
||||||
RemoveFlag;
|
RemoveFlag;
|
||||||
|
Row;
|
||||||
|
Col;
|
||||||
|
|
||||||
private
|
private
|
||||||
[weakref]parent_: TSPdfTableRange;
|
[weakref]parent_: TSPdfTableRange;
|
||||||
|
|
@ -78,7 +83,7 @@ begin
|
||||||
if element.LocalName = "p" then
|
if element.LocalName = "p" then
|
||||||
begin
|
begin
|
||||||
range := new TSPdfParagraphRange(docx_to_pdf_, page_, docx_components_ware_, element);
|
range := new TSPdfParagraphRange(docx_to_pdf_, page_, docx_components_ware_, element);
|
||||||
range.SetExtraStyleId(tbl_pr_.TblStyle.Val);
|
range.SetTblStyleIdAndType(tbl_pr_.TblStyle.Val, {self.}GetCellPrType());
|
||||||
end
|
end
|
||||||
else if element.LocalName = "tbl" then
|
else if element.LocalName = "tbl" then
|
||||||
begin
|
begin
|
||||||
|
|
@ -99,8 +104,16 @@ begin
|
||||||
page_ := range.GetLastPage();
|
page_ := range.GetLastPage();
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
{self.}EndY := cell_y;
|
{self.}EndY := cell_y - tbl_pr_.TblCellMar.Bottom.W;
|
||||||
{self.}DynamicHeight += tbl_pr_.TblCellMar.Top.W + tbl_pr_.TblCellMar.Bottom.W;
|
{self.}DynamicHeight += tbl_pr_.TblCellMar.Top.W + tbl_pr_.TblCellMar.Bottom.W;
|
||||||
|
if {self.}EndY < {self.}LowerBound then
|
||||||
|
begin
|
||||||
|
page_ := docx_to_pdf_.GetNextPage(page_);
|
||||||
|
if ifnil(page_) then page_ := docx_to_pdf_.AddTSPage();
|
||||||
|
point := docx_to_pdf_.GetCurrentTextPoint();
|
||||||
|
{self.}StartY := point.Y;
|
||||||
|
{self.}Calc();
|
||||||
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TSPdfCellRange.Do();override;
|
function TSPdfCellRange.Do();override;
|
||||||
|
|
@ -226,3 +239,10 @@ begin
|
||||||
if length(region_array_) < 2 then return false;
|
if length(region_array_) < 2 then return false;
|
||||||
return length(region_array_[0].RangeArr) ? false : true;
|
return length(region_array_[0].RangeArr) ? false : true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TSPdfCellRange.GetCellPrType(): string;
|
||||||
|
begin
|
||||||
|
if {self.}Row = 0 then return "firstRow";
|
||||||
|
else if ({self.}Row + 1) % 2 = 0 then return "band1Horz";
|
||||||
|
else return "band2Horz";
|
||||||
|
end;
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ public
|
||||||
function Create(docx_to_pdf: TSDocxToPdf; pg: TSPage; components: TSDocxComponentsWare; paragraph: P);
|
function Create(docx_to_pdf: TSDocxToPdf; pg: TSPage; components: TSDocxComponentsWare; paragraph: P);
|
||||||
function Calc();
|
function Calc();
|
||||||
function Do();override;
|
function Do();override;
|
||||||
function SetExtraStyleId(style_id: string);
|
function SetTblStyleIdAndType(style_id: string; type: string);
|
||||||
function SetNumPages(num: integer);
|
function SetNumPages(num: integer);
|
||||||
function RangesToLines();
|
function RangesToLines();
|
||||||
function FirstValidTSPage(): TSPage;
|
function FirstValidTSPage(): TSPage;
|
||||||
|
|
@ -17,6 +17,7 @@ private
|
||||||
function SetPPrByStyleId(var ppr: PPr; style_id: string);
|
function SetPPrByStyleId(var ppr: PPr; style_id: string);
|
||||||
function SetRPr(var rpr; ppr: PPrUnitDecorator);
|
function SetRPr(var rpr; ppr: PPrUnitDecorator);
|
||||||
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 SetLvlText();
|
function SetLvlText();
|
||||||
function GetImageFileType(data: binary): string;
|
function GetImageFileType(data: binary): string;
|
||||||
function GetImageData(id: string): PdfImage;
|
function GetImageData(id: string): PdfImage;
|
||||||
|
|
@ -43,13 +44,14 @@ private
|
||||||
[weakref]docx_components_ware_: TSDocxComponentsWare;
|
[weakref]docx_components_ware_: TSDocxComponentsWare;
|
||||||
[weakref]paragraph_: P;
|
[weakref]paragraph_: P;
|
||||||
[weakref]page_: TSPage;
|
[weakref]page_: TSPage;
|
||||||
extra_style_id_: string;
|
|
||||||
range_array_: array of TSPdfBasicRange;
|
range_array_: array of TSPdfBasicRange;
|
||||||
line_range_array_: array of TSPdfLineRange;
|
line_range_array_: array of TSPdfLineRange;
|
||||||
hyperlink_array_: tableArray;
|
hyperlink_array_: tableArray;
|
||||||
bookmark_array_: tableArray;
|
bookmark_array_: tableArray;
|
||||||
ppr_unit_decorator_: PPrUnitDecorator;
|
ppr_unit_decorator_: PPrUnitDecorator;
|
||||||
placeholder_array_: tableArray;
|
placeholder_array_: tableArray;
|
||||||
|
table_style_id_: string;
|
||||||
|
table_style_type_: string;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TSPdfParagraphRange.Create(docx_to_pdf: TSDocxToPdf; pg: TSPage; components: TSDocxComponentsWare; paragraph: P);
|
function TSPdfParagraphRange.Create(docx_to_pdf: TSDocxToPdf; pg: TSPage; components: TSDocxComponentsWare; paragraph: P);
|
||||||
|
|
@ -58,7 +60,8 @@ begin
|
||||||
page_ := pg;
|
page_ := pg;
|
||||||
docx_components_ware_ := components;
|
docx_components_ware_ := components;
|
||||||
paragraph_ := paragraph;
|
paragraph_ := paragraph;
|
||||||
extra_style_id_ := "";
|
table_style_id_ := "";
|
||||||
|
table_style_type_ := "";
|
||||||
range_array_ := array();
|
range_array_ := array();
|
||||||
line_range_array_ := array();
|
line_range_array_ := array();
|
||||||
hyperlink_array_ := array();
|
hyperlink_array_ := array();
|
||||||
|
|
@ -286,9 +289,10 @@ begin
|
||||||
line_range.Do();
|
line_range.Do();
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TSPdfParagraphRange.SetExtraStyleId(style_id: string);
|
function TSPdfParagraphRange.SetTblStyleIdAndType(style_id: string; type: string);
|
||||||
begin
|
begin
|
||||||
extra_style_id_ := style_id;
|
table_style_id_ := style_id;
|
||||||
|
table_style_type_ := type;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TSPdfParagraphRange.NewLineRange(): TSPdfLineRange;
|
function TSPdfParagraphRange.NewLineRange(): TSPdfLineRange;
|
||||||
|
|
@ -631,7 +635,7 @@ begin
|
||||||
styles := docx_components_ware_.GetStyles();
|
styles := docx_components_ware_.GetStyles();
|
||||||
new_ppr.Copy(styles.DocDefaults.PPrDefault.PPr);
|
new_ppr.Copy(styles.DocDefaults.PPrDefault.PPr);
|
||||||
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, table_style_id_);
|
||||||
{self.}SetPPrByStyleId(new_ppr, ppr.PStyle.Val);
|
{self.}SetPPrByStyleId(new_ppr, ppr.PStyle.Val);
|
||||||
if ifObj(ppr) then
|
if ifObj(ppr) then
|
||||||
begin
|
begin
|
||||||
|
|
@ -658,6 +662,7 @@ begin
|
||||||
new_rpr := new RPr();
|
new_rpr := new RPr();
|
||||||
styles := docx_components_ware_.GetStyles();
|
styles := docx_components_ware_.GetStyles();
|
||||||
new_rpr.Copy(styles.DocDefaults.RPrDefault.RPr);
|
new_rpr.Copy(styles.DocDefaults.RPrDefault.RPr);
|
||||||
|
{self.}SetRPrByTblStyleId(new_rpr, table_style_id_);
|
||||||
{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);
|
||||||
if ifObj(rpr) then
|
if ifObj(rpr) then
|
||||||
|
|
@ -667,6 +672,23 @@ begin
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TSPdfParagraphRange.SetRPrByTblStyleId(var rpr: RPr; style_id: string);
|
||||||
|
begin
|
||||||
|
styles := docx_components_ware_.GetStylesAdapter();
|
||||||
|
style := styles.GetStyleByStyleId(style_id);
|
||||||
|
if ifObj(style) then
|
||||||
|
begin
|
||||||
|
based_on := style.BasedOn.Val;
|
||||||
|
{self.}SetRPrByTblStyleId(rpr, based_on);
|
||||||
|
rpr.Copy(style.RPr);
|
||||||
|
end;
|
||||||
|
if table_style_type_ then
|
||||||
|
begin
|
||||||
|
tbl_style_pr := docx_components_ware_.GetTblStylePrByType(table_style_id_, table_style_type_);
|
||||||
|
if tbl_style_pr then rpr.Copy(tbl_style_pr.RPr);
|
||||||
|
end
|
||||||
|
end;
|
||||||
|
|
||||||
function TSPdfParagraphRange.SetRPrByStyleId(var rpr: RPr; style_id: string);
|
function TSPdfParagraphRange.SetRPrByStyleId(var rpr: RPr; style_id: string);
|
||||||
begin
|
begin
|
||||||
styles := docx_components_ware_.GetStylesAdapter();
|
styles := docx_components_ware_.GetStylesAdapter();
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ begin
|
||||||
for _,row in cell_range_array_ do
|
for _,row in cell_range_array_ do
|
||||||
begin
|
begin
|
||||||
flag := nil;
|
flag := nil;
|
||||||
for _,range in row do
|
for __,range in row do
|
||||||
begin
|
begin
|
||||||
if ifnil(flag) and ifObj(range) then flag := range.IfRemoveEmptyRectangle();
|
if ifnil(flag) and ifObj(range) then flag := range.IfRemoveEmptyRectangle();
|
||||||
if not ifObj(range) or flag <> range.IfRemoveEmptyRectangle() then
|
if not ifObj(range) or flag <> range.IfRemoveEmptyRectangle() then
|
||||||
|
|
@ -67,7 +67,7 @@ begin
|
||||||
break;
|
break;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for _,range in row do
|
for __,range in row do
|
||||||
begin
|
begin
|
||||||
if ifObj(range) then
|
if ifObj(range) then
|
||||||
begin
|
begin
|
||||||
|
|
@ -102,6 +102,8 @@ begin
|
||||||
begin
|
begin
|
||||||
{self.}SetTcPr(tc.TcPr);
|
{self.}SetTcPr(tc.TcPr);
|
||||||
if i = 0 then {self.}SetTblStylePr(tc.TcPr, "firstRow");
|
if i = 0 then {self.}SetTblStylePr(tc.TcPr, "firstRow");
|
||||||
|
else if (i + 1) % 2 = 0 then {self.}SetTblStylePr(tc.TcPr, "band1Horz");
|
||||||
|
else {self.}SetTblStylePr(tc.TcPr, "band2Horz");
|
||||||
vmerge := tc.TcPr.XmlChildVMerge.Val ? tc.TcPr.XmlChildVMerge.Val : tc.TcPr.VMerge;
|
vmerge := tc.TcPr.XmlChildVMerge.Val ? tc.TcPr.XmlChildVMerge.Val : tc.TcPr.VMerge;
|
||||||
if vmerge = "restart" then
|
if vmerge = "restart" then
|
||||||
begin
|
begin
|
||||||
|
|
@ -129,6 +131,8 @@ begin
|
||||||
cell_range.Width := grid_cols[pos].W;
|
cell_range.Width := grid_cols[pos].W;
|
||||||
cell_range.LowerBound := {self.}LowerBound;
|
cell_range.LowerBound := {self.}LowerBound;
|
||||||
cell_range.FixedHeight := tc_h;
|
cell_range.FixedHeight := tc_h;
|
||||||
|
cell_range.Row := i;
|
||||||
|
cell_range.Col := j;
|
||||||
cell_range_array_[i][pos] := cell_range;
|
cell_range_array_[i][pos] := cell_range;
|
||||||
grid_span := new GridSpanUnitDecorator(tc.TcPr.GridSpan);
|
grid_span := new GridSpanUnitDecorator(tc.TcPr.GridSpan);
|
||||||
pos++;
|
pos++;
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ end;
|
||||||
function TSPdfTextRange.Do();
|
function TSPdfTextRange.Do();
|
||||||
begin
|
begin
|
||||||
// println("text = {}, endx = {}, endy = {}, width = {}, page = {}", ansiToUtf8(text), endx, endy, width, page);
|
// println("text = {}, endx = {}, endy = {}, width = {}, page = {}", ansiToUtf8(text), endx, endy, width, page);
|
||||||
|
// println("Text = {}, sz = {}, szcs = {}, rpr.I = {}", ansiToUtf8({self.}Text), {self.}RPr.Sz.Val, {self.}RPr.SzCs.Val, {self.}RPr.I);
|
||||||
[r, g, b] := array(0, 0, 0);
|
[r, g, b] := array(0, 0, 0);
|
||||||
if {self.}RPr.Color.Val then [r, g, b] := TSColorToolKit.HexToRGB({self.}RPr.Color.Val);
|
if {self.}RPr.Color.Val then [r, g, b] := TSColorToolKit.HexToRGB({self.}RPr.Color.Val);
|
||||||
{self.}TSPage.PdfPage.SetRGBFill(r / 255, g / 255, b / 255);
|
{self.}TSPage.PdfPage.SetRGBFill(r / 255, g / 255, b / 255);
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ end;
|
||||||
|
|
||||||
function TSFontWare.GetBuiltInFont(name: string; bold: boolean; italic: boolean);
|
function TSFontWare.GetBuiltInFont(name: string; bold: boolean; italic: boolean);
|
||||||
begin
|
begin
|
||||||
font_name := substitution_rules_["name"];
|
font_name := substitution_rules_[name];
|
||||||
if ifnil(font_name) then font_name := "SimSun";
|
if ifnil(font_name) then font_name := "SimSun";
|
||||||
if bold and italic then
|
if bold and italic then
|
||||||
font_name += ",BoldItalic";
|
font_name += ",BoldItalic";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue