mirror of
https://github.com/unidoc/unioffice.git
synced 2025-04-25 13:48:53 +08:00
12 lines
6.2 KiB
Go
12 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 (_d "fmt";_cb "github.com/unidoc/unioffice/schema/soo/wml";_c "strconv";_g "strings";);func _f (_eg string )(_eb []string ){for _cc :=0;_cc < len (_eg )-2;_cc ++{if string (_eg [_cc ])=="\u0025"{if !_g .Contains (string (_eg [_cc +2:]),"\u0025"){if _cc ==0{_eb =append (_eb ,_d .Sprintf ("\u0025\u0073\u0025\u0073\u0025\u0073",string (_eg [_cc ]),string (_eg [_cc +1]),string (_eg [_cc +2:])));}else {_eb =append (_eb ,_d .Sprintf ("\u0025\u0073\u0025\u0073\u0025\u0073\u0025\u0073",string (_eg [_cc -1]),string (_eg [_cc ]),string (_eg [_cc +1]),string (_eg [_cc +2:])));};}else {_eb =append (_eb ,_d .Sprintf ("\u0025\u0073\u0025\u0073\u0025\u0073",string (_eg [_cc ]),string (_eg [_cc +1]),string (_eg [_cc +2])));};};};return ;};var (_df =[]string {"","\u0049","\u0049\u0049","\u0049\u0049\u0049","\u0049\u0056","\u0056","\u0056\u0049","\u0056\u0049\u0049","\u0056\u0049\u0049\u0049","\u0049\u0058"};_ef =[]string {"","\u0058","\u0058\u0058","\u0058\u0058\u0058","\u0058\u004c","\u004c","\u004c\u0058","\u004c\u0058\u0058","\u004c\u0058\u0058\u0058","\u0058\u0043"};_gd =[]string {"","\u0043","\u0043\u0043","\u0043\u0043\u0043","\u0043\u0044","\u0044","\u0044\u0043","\u0044\u0043\u0043","\u0044\u0043\u0043\u0043","\u0043\u004d","\u004d"};_ga =[]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"};_ae =[]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"};_fc =[]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"};_bb =[]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"};_fg =[]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"};_bf ="\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 ){_ecg :=0;_gac :=false ;for _ ,_edf :=range []byte (str ){_edf -='0';if _edf > 9{continue ;};_ecg =_ecg *10+int (_edf );_gac =true ;};return _ecg ,_gac ;};func FormatNumberingText (currentNumber int64 ,ilvl int64 ,lvlText string ,numFmt *_cb .CT_NumFmt ,levelNumbers map[int64 ]int64 )string {_b :=_f (lvlText );_ca :=_cbf (currentNumber ,numFmt );_e :=int64 (0);for _ea ,_ec :=range _b {_cd :=_d .Sprintf ("\u0025\u0025\u0025\u0064",_ea +1);if len (_b )==1{_cd =_d .Sprintf ("\u0025\u0025\u0025\u0064",ilvl +1);_b [_ea ]=_g .Replace (_ec ,_cd ,_ca ,1);break ;};if ilvl > 0&&ilvl > _e &&_ea < (len (_b )-1){_dd :=_cbf (levelNumbers [_e ],numFmt );_b [_ea ]=_g .Replace (_ec ,_cd ,_dd ,1);_e ++;}else {_b [_ea ]=_g .Replace (_ec ,_cd ,_ca ,1);};};return _g .Join (_b ,"");};func _cbf (_gc int64 ,_bfg *_cb .CT_NumFmt )(_gae string ){if _bfg ==nil {return ;};_gde :=_bfg .ValAttr ;switch _gde {case _cb .ST_NumberFormatNone :_gae ="";case _cb .ST_NumberFormatDecimal :_gae =_c .Itoa (int (_gc ));case _cb .ST_NumberFormatDecimalZero :_gae =_c .Itoa (int (_gc ));if _gc < 10{_gae ="\u0030"+_gae ;};case _cb .ST_NumberFormatUpperRoman :var (_eca =_gc %10;_gdg =(_gc %100)/10;_ab =(_gc %1000)/100;_db =_gc /1000;);_gae =_ga [_db ]+_gd [_ab ]+_ef [_gdg ]+_df [_eca ];case _cb .ST_NumberFormatLowerRoman :var (_ee =_gc %10;_da =(_gc %100)/10;_gb =(_gc %1000)/100;_ed =_gc /1000;);_gae =_ga [_ed ]+_gd [_gb ]+_ef [_da ]+_df [_ee ];_gae =_g .ToLower (_gae );case _cb .ST_NumberFormatUpperLetter :_be :=_gc %780;if _be ==0{_be =780;};_ad :=(_be -1)/26;_efe :=(_be -1)%26;_gf :=_bf [_ad +_efe ];_gae =string (_gf );case _cb .ST_NumberFormatLowerLetter :_fge :=_gc %780;if _fge ==0{_fge =780;};_gfa :=(_fge -1)/26;_eaa :=(_fge -1)%26;_eee :=_bf [_gfa +_eaa ];_gae =_g .ToLower (string (_eee ));default:_gae ="";};return ;}; |