1. 支持中文的“一二”等项目符号
2. 完善对页码类型的支持
This commit is contained in:
@@ -3,6 +3,10 @@ public
|
||||
function Create(number: NumberingAdapter);
|
||||
function GetNumberLvl(ppr: PPr);
|
||||
|
||||
private
|
||||
function CalculateNumber(num_fmt: string; num: integer): string;
|
||||
function ChineseCountingThousand(n: integer): string;
|
||||
|
||||
private
|
||||
numbering_adapter_: NumberingAdapter;
|
||||
num_hash_: array of tslobj;
|
||||
@@ -44,7 +48,7 @@ begin
|
||||
num_hash_[num_id][j] := 0;
|
||||
end
|
||||
n := i = ilvl_int ? num_hash_[num_id][i] + 1 : num_hash_[num_id][i];
|
||||
dest_str := format("%d", n);
|
||||
dest_str := {self.}CalculateNumber(v.NumFmt.Val, n);
|
||||
lvl_text := replaceStr(lvl_text, source_str, dest_str);
|
||||
end
|
||||
num_hash_[num_id][ilvl_int]++;
|
||||
@@ -54,3 +58,29 @@ begin
|
||||
end
|
||||
return array("", nil);
|
||||
end
|
||||
|
||||
function TSNumberingWare.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);
|
||||
end;
|
||||
|
||||
function TSNumberingWare.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;
|
||||
|
||||
Reference in New Issue
Block a user