mirror of
https://github.com/unidoc/unioffice.git
synced 2025-04-25 13:48:53 +08:00
27 lines
6.2 KiB
Go
27 lines
6.2 KiB
Go
//
|
|
// Copyright 2020 FoxyUtils ehf. All rights reserved.
|
|
//
|
|
// This is a commercial product and requires a license to operate.
|
|
// A trial license can be obtained at https://unidoc.io
|
|
//
|
|
// DO NOT EDIT: generated by unitwist Go source code obfuscator.
|
|
//
|
|
// Use of this source code is governed by the UniDoc End User License Agreement
|
|
// terms that can be accessed at https://unidoc.io/eula/
|
|
|
|
package formatutils ;import (_e "fmt";_dd "github.com/unidoc/unioffice/schema/soo/wml";_ga "strconv";_d "strings";);func _ad (_ce string )(_gf []string ){for _ea :=0;_ea < len (_ce )-2;_ea ++{if string (_ce [_ea ])=="\u0025"{if !_d .Contains (string (_ce [_ea +2:]),"\u0025"){if _ea ==0{_gf =append (_gf ,_e .Sprintf ("\u0025\u0073\u0025\u0073\u0025\u0073",string (_ce [_ea ]),string (_ce [_ea +1]),string (_ce [_ea +2:])));
|
|
}else {_gf =append (_gf ,_e .Sprintf ("\u0025\u0073\u0025\u0073\u0025\u0073\u0025\u0073",string (_ce [_ea -1]),string (_ce [_ea ]),string (_ce [_ea +1]),string (_ce [_ea +2:])));};}else {_gf =append (_gf ,_e .Sprintf ("\u0025\u0073\u0025\u0073\u0025\u0073",string (_ce [_ea ]),string (_ce [_ea +1]),string (_ce [_ea +2])));
|
|
};};};return ;};var (_gb =[]string {"","\u0049","\u0049\u0049","\u0049\u0049\u0049","\u0049\u0056","\u0056","\u0056\u0049","\u0056\u0049\u0049","\u0056\u0049\u0049\u0049","\u0049\u0058"};_abd =[]string {"","\u0058","\u0058\u0058","\u0058\u0058\u0058","\u0058\u004c","\u004c","\u004c\u0058","\u004c\u0058\u0058","\u004c\u0058\u0058\u0058","\u0058\u0043"};
|
|
_b =[]string {"","\u0043","\u0043\u0043","\u0043\u0043\u0043","\u0043\u0044","\u0044","\u0044\u0043","\u0044\u0043\u0043","\u0044\u0043\u0043\u0043","\u0043\u004d","\u004d"};_f =[]string {"","\u004d","\u004d\u004d","\u004d\u004d\u004d","\u004d\u004d\u004d\u004d","\u004d\u004d\u004dM\u004d","\u004d\u004d\u004d\u004d\u004d\u004d","\u004dM\u004d\u004d\u004d\u004d\u004d","\u004d\u004d\u004d\u004d\u004d\u004d\u004d\u004d","\u004dM\u004d\u004d\u004d\u004d\u004d\u004dM","\u004d\u004d\u004d\u004d\u004d\u004d\u004d\u004d\u004d\u004d"};
|
|
_af =[]string {"\u006f\u006e\u0065","\u0074\u0077\u006f","\u0074\u0068\u0072e\u0065","\u0066\u006f\u0075\u0072","\u0066\u0069\u0076\u0065","\u0073\u0069\u0078","\u0073\u0065\u0076e\u006e","\u0065\u0069\u0067h\u0074","\u006e\u0069\u006e\u0065","\u0074\u0065\u006e","\u0065\u006c\u0065\u0076\u0065\u006e","\u0074\u0077\u0065\u006c\u0076\u0065","\u0074\u0068\u0069\u0072\u0074\u0065\u0065\u006e","\u0066\u006f\u0075\u0072\u0074\u0065\u0065\u006e","\u0066i\u0066\u0074\u0065\u0065\u006e","\u0073i\u0078\u0074\u0065\u0065\u006e","\u0073e\u0076\u0065\u006e\u0074\u0065\u0065n","\u0065\u0069\u0067\u0068\u0074\u0065\u0065\u006e","\u006e\u0069\u006e\u0065\u0074\u0065\u0065\u006e"};
|
|
_dde =[]string {"\u0074\u0065\u006e","\u0074\u0077\u0065\u006e\u0074\u0079","\u0074\u0068\u0069\u0072\u0074\u0079","\u0066\u006f\u0072t\u0079","\u0066\u0069\u0066t\u0079","\u0073\u0069\u0078t\u0079","\u0073e\u0076\u0065\u006e\u0074\u0079","\u0065\u0069\u0067\u0068\u0074\u0079","\u006e\u0069\u006e\u0065\u0074\u0079"};
|
|
_eg =[]string {"\u0066\u0069\u0072s\u0074","\u0073\u0065\u0063\u006f\u006e\u0064","\u0074\u0068\u0069r\u0064","\u0066\u006f\u0075\u0072\u0074\u0068","\u0066\u0069\u0066t\u0068","\u0073\u0069\u0078t\u0068","\u0073e\u0076\u0065\u006e\u0074\u0068","\u0065\u0069\u0067\u0068\u0074\u0068","\u006e\u0069\u006et\u0068","\u0074\u0065\u006et\u0068","\u0065\u006c\u0065\u0076\u0065\u006e\u0074\u0068","\u0074w\u0065\u006c\u0066\u0074\u0068","\u0074\u0068\u0069\u0072\u0074\u0065\u0065\u006e\u0074\u0068","\u0066\u006f\u0075\u0072\u0074\u0065\u0065\u006e\u0074\u0068","\u0066i\u0066\u0074\u0065\u0065\u006e\u0074h","\u0073i\u0078\u0074\u0065\u0065\u006e\u0074h","s\u0065\u0076\u0065\u006e\u0074\u0065\u0065\u006e\u0074\u0068","\u0065\u0069\u0067\u0068\u0074\u0065\u0065\u006e\u0074\u0068","\u006e\u0069\u006e\u0065\u0074\u0065\u0065\u006e\u0074\u0068"};
|
|
_bf =[]string {"\u0074\u0065\u006et\u0068","\u0074w\u0065\u006e\u0074\u0069\u0065\u0074h","\u0074h\u0069\u0072\u0074\u0069\u0065\u0074h","\u0066\u006f\u0072\u0074\u0069\u0065\u0074\u0068","\u0066\u0069\u0066\u0074\u0069\u0065\u0074\u0068","\u0073\u0069\u0078\u0074\u0069\u0065\u0074\u0068","\u0073\u0065\u0076\u0065\u006e\u0074\u0069\u0065\u0074\u0068","\u0065i\u0067\u0068\u0074\u0069\u0065\u0074h","\u006ei\u006e\u0065\u0074\u0069\u0065\u0074h"};
|
|
_eae ="\u0041\u0042\u0043\u0044\u0045\u0046\u0047\u0048\u0049\u004a\u004bL\u004d\u004e\u004f\u0050\u0051\u0052\u0053\u0054\u0055\u0056W\u0058\u0059\u005a";);func StringToNumbers (str string )(int ,bool ){_fdg :=0;_gad :=false ;for _ ,_bc :=range []byte (str ){_bc -='0';
|
|
if _bc > 9{continue ;};_fdg =_fdg *10+int (_bc );_gad =true ;};return _fdg ,_gad ;};func _be (_ba int64 ,_ff *_dd .CT_NumFmt )(_gbc string ){if _ff ==nil {return ;};_fg :=_ff .ValAttr ;switch _fg {case _dd .ST_NumberFormatNone :_gbc ="";case _dd .ST_NumberFormatDecimal :_gbc =_ga .Itoa (int (_ba ));
|
|
case _dd .ST_NumberFormatDecimalZero :_gbc =_ga .Itoa (int (_ba ));if _ba < 10{_gbc ="\u0030"+_gbc ;};case _dd .ST_NumberFormatUpperRoman :var (_de =_ba %10;_gcc =(_ba %100)/10;_dg =(_ba %1000)/100;_aba =_ba /1000;);_gbc =_f [_aba ]+_b [_dg ]+_abd [_gcc ]+_gb [_de ];
|
|
case _dd .ST_NumberFormatLowerRoman :var (_adf =_ba %10;_cd =(_ba %100)/10;_ee =(_ba %1000)/100;_ceg =_ba /1000;);_gbc =_f [_ceg ]+_b [_ee ]+_abd [_cd ]+_gb [_adf ];_gbc =_d .ToLower (_gbc );case _dd .ST_NumberFormatUpperLetter :_fge :=_ba %780;if _fge ==0{_fge =780;
|
|
};_fd :=(_fge -1)/26;_agg :=(_fge -1)%26;_ae :=_eae [_fd +_agg ];_gbc =string (_ae );case _dd .ST_NumberFormatLowerLetter :_ddd :=_ba %780;if _ddd ==0{_ddd =780;};_fff :=(_ddd -1)/26;_ccb :=(_ddd -1)%26;_db :=_eae [_fff +_ccb ];_gbc =_d .ToLower (string (_db ));
|
|
default:_gbc ="";};return ;};func FormatNumberingText (currentNumber int64 ,ilvl int64 ,lvlText string ,numFmt *_dd .CT_NumFmt ,levelNumbers map[int64 ]int64 )string {_c :=_ad (lvlText );_a :=_be (currentNumber ,numFmt );_gc :=int64 (0);for _ag ,_ca :=range _c {_cc :=_e .Sprintf ("\u0025\u0025\u0025\u0064",_ag +1);
|
|
if len (_c )==1{_cc =_e .Sprintf ("\u0025\u0025\u0025\u0064",ilvl +1);_c [_ag ]=_d .Replace (_ca ,_cc ,_a ,1);break ;};if ilvl > 0&&ilvl > _gc &&_ag < (len (_c )-1){_ab :=_be (levelNumbers [_gc ],numFmt );_c [_ag ]=_d .Replace (_ca ,_cc ,_ab ,1);_gc ++;
|
|
}else {_c [_ag ]=_d .Replace (_ca ,_cc ,_a ,1);};};return _d .Join (_c ,"");}; |