1. 支持分栏

2. 支持简单的单个脚注
This commit is contained in:
csh
2024-12-13 17:19:52 +08:00
parent a677e5a843
commit 4c002f803f
8 changed files with 359 additions and 68 deletions
+1 -2
View File
@@ -11,7 +11,6 @@ public
function GetFtrRelsAdapter(target: string): RelationShipsAdapter;
function GetHdrRelsAdapter(target: string): RelationShipsAdapter;
function GetFootnotesAdapter(): FootnotesAdapter;
private
styles_deserialize_flag_: boolean;
styles_adapter_: StylesAdapter;
@@ -125,6 +124,6 @@ begin
if footnotes_adapter_ then return footnotes_adapter_;
obj := {self.}Footnotes;
obj.Deserialize();
footnotes_adapter_ := new FootnotesAdapter();
footnotes_adapter_ := new FootnotesAdapter(obj);
return footnotes_adapter_;
end;
-13
View File
@@ -1,7 +1,6 @@
type TSFontWare = class
public
function Create(pdf: PdfFile);
function GetFontByText(text: string; name: string; bold: boolean; italic: boolean): PdfFont;
function GetAsciiFont(name: string; bold: boolean; italic: boolean): PdfFont;
function GetCNSFont(name: string; bold: boolean; italic: boolean): PdfFont;
function GetSymbolFont(): PdfFont;
@@ -18,7 +17,6 @@ private
private
[weakref]pdf_: PdfFile;
is_linux_: boolean; // 是否是linux
use_built_in_font_: boolean; // 是否使用内置字体
substitution_rules_: array of string; // 替换规则
external_reference_: array of string;
@@ -60,27 +58,16 @@ begin
if not ifnil(external_font_cache_[name]) then return external_font_cache_[name];
value := external_reference_[name];
if ifnil(value) then return nil;
// if ifnil(value) then raise name + " is unsupported font.";
if value["ext"] = ".ttf" then
font_name := pdf_.LoadTTFontFromFile("", value["path"], true);
else if value["ext"] = ".ttc" then
font_name := pdf_.LoadTTFontFromFile2("", value["path"], 0, true);
// if not ifString(font_name) then raise "Load font error : " + format("%x", font_name);
if not ifString(font_name) then return nil;
font := pdf_.GetFont(font_name, "UTF-8");
external_font_cache_[name] := font;
return font;
end;
function TSFontWare.GetFontByText(text: string; name: string; bold: boolean; italic: boolean): PdfFont;
begin
len := length(text);
if len > 1 then
return {self.}GetCNSFont(name, bold, italic);
else
return {self.}GetAsciiFont(name, bold, italic);
end;
function TSFontWare.GetCNSFont(name: string; bold: boolean; italic: boolean): PdfFont;
begin
return use_built_in_font_ ? {self.}GetBuiltInCNSFont(name, bold, italic) : {self.}GetExternalFont(name, bold, italic);
+60
View File
@@ -0,0 +1,60 @@
type TSNoteWare = class
public
function Create(sect_ware: TSSectWare);
function GetFootnoteOrderNumber(): string;
function GetIndex(): string;
private
function CalculateNumber(num_fmt: string; num: integer): string;
function ChineseCountingThousand(n: integer): string;
private
[weakref]sect_ware_: TSSectWare;
index_: integer;
end;
function TSNoteWare.Create(sect_ware: TSSectWare);
begin
sect_ware_ := sect_ware;
index_ := 0;
end;
function TSNoteWare.GetFootnoteOrderNumber();
begin
num_fmt := sect_ware_.SectPr.FootnotePr.NumFmt.Val;
if ifnil(num_fmt) then num_fmt := "decimal";
return CalculateNumber(num_fmt, ++index_);
end;
function TSNoteWare.GetIndex(): string;
begin
return inttostr(index_);
end;
function TSNoteWare.CalculateNumber(num_fmt: string; num: integer): string;
begin
if num_fmt = "decimal" then
return format("%d", num);
else if num_fmt = "chineseCountingThousand" then
return {self.}ChineseCountingThousand(num);
else
return format("%d", num);
end;
function TSNoteWare.ChineseCountingThousand(n: integer): string;
begin
chinese_digits := array("零", "一", "二", "三", "四", "五", "六", "七", "八", "九");
chinese_units := array("", "十", "百", "千");
if n < 10 then return chinese_digits[n];
result := "";
num_str := inttostr(n);
len := length(num_str);
for i:=1 to len do
begin
digit_int := strtoint(num_str[i]);
if digit_int <> 0 then
result += chinese_digits[digit_int] + chinese_units[len - i];
end
if length(result) >= 6 and result[:6] = "一十" then result := result[4:];
return result;
end;