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 (_a "fmt";_g "github.com/unidoc/unioffice/schema/soo/wml";_c "strconv";_b "strings";);func _fb (_ba string )(_cc []string ){for _cf :=0;_cf < len (_ba )-2;_cf ++{if string (_ba [_cf ])=="\u0025"{if !_b .Contains (string (_ba [_cf +2:]),"\u0025"){if _cf ==0{_cc =append (_cc ,_a .Sprintf ("\u0025\u0073\u0025\u0073\u0025\u0073",string (_ba [_cf ]),string (_ba [_cf +1]),string (_ba [_cf +2:])));
|
|
}else {_cc =append (_cc ,_a .Sprintf ("\u0025\u0073\u0025\u0073\u0025\u0073\u0025\u0073",string (_ba [_cf -1]),string (_ba [_cf ]),string (_ba [_cf +1]),string (_ba [_cf +2:])));};}else {_cc =append (_cc ,_a .Sprintf ("\u0025\u0073\u0025\u0073\u0025\u0073",string (_ba [_cf ]),string (_ba [_cf +1]),string (_ba [_cf +2])));
|
|
};};};return ;};var (_bd =[]string {"","\u0049","\u0049\u0049","\u0049\u0049\u0049","\u0049\u0056","\u0056","\u0056\u0049","\u0056\u0049\u0049","\u0056\u0049\u0049\u0049","\u0049\u0058"};_cca =[]string {"","\u0058","\u0058\u0058","\u0058\u0058\u0058","\u0058\u004c","\u004c","\u004c\u0058","\u004c\u0058\u0058","\u004c\u0058\u0058\u0058","\u0058\u0043"};
|
|
_ef =[]string {"","\u0043","\u0043\u0043","\u0043\u0043\u0043","\u0043\u0044","\u0044","\u0044\u0043","\u0044\u0043\u0043","\u0044\u0043\u0043\u0043","\u0043\u004d","\u004d"};_fd =[]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"};
|
|
_bb =[]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"};
|
|
_dc =[]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"};
|
|
_ff =[]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"};
|
|
_eb =[]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"};
|
|
_cgb ="\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 _ebd (_bc int64 ,_cb *_g .CT_NumFmt )(_aac string ){if _cb ==nil {return ;};_ca :=_cb .ValAttr ;
|
|
switch _ca {case _g .ST_NumberFormatNone :_aac ="";case _g .ST_NumberFormatDecimal :_aac =_c .Itoa (int (_bc ));case _g .ST_NumberFormatDecimalZero :_aac =_c .Itoa (int (_bc ));if _bc < 10{_aac ="\u0030"+_aac ;};case _g .ST_NumberFormatUpperRoman :var (_cd =_bc %10;
|
|
_gc =(_bc %100)/10;_ae =(_bc %1000)/100;_fbb =_bc /1000;);_aac =_fd [_fbb ]+_ef [_ae ]+_cca [_gc ]+_bd [_cd ];case _g .ST_NumberFormatLowerRoman :var (_db =_bc %10;_ac =(_bc %100)/10;_agb =(_bc %1000)/100;_acb =_bc /1000;);_aac =_fd [_acb ]+_ef [_agb ]+_cca [_ac ]+_bd [_db ];
|
|
_aac =_b .ToLower (_aac );case _g .ST_NumberFormatUpperLetter :_bee :=_bc %780;if _bee ==0{_bee =780;};_ebb :=(_bee -1)/26;_dg :=(_bee -1)%26;_ea :=_cgb [_ebb +_dg ];_aac =string (_ea );case _g .ST_NumberFormatLowerLetter :_dac :=_bc %780;if _dac ==0{_dac =780;
|
|
};_ace :=(_dac -1)/26;_gf :=(_dac -1)%26;_ffa :=_cgb [_ace +_gf ];_aac =_b .ToLower (string (_ffa ));default:_aac ="";};return ;};func FormatNumberingText (currentNumber int64 ,ilvl int64 ,lvlText string ,numFmt *_g .CT_NumFmt ,levelNumbers map[int64 ]int64 )string {_aa :=_fb (lvlText );
|
|
_f :=_ebd (currentNumber ,numFmt );_cg :=int64 (0);for _be ,_e :=range _aa {_da :=_a .Sprintf ("\u0025\u0025\u0025\u0064",_be +1);if len (_aa )==1{_da =_a .Sprintf ("\u0025\u0025\u0025\u0064",ilvl +1);_aa [_be ]=_b .Replace (_e ,_da ,_f ,1);break ;};if ilvl > 0&&ilvl > _cg &&_be < (len (_aa )-1){_ag :=_ebd (levelNumbers [_cg ],numFmt );
|
|
_aa [_be ]=_b .Replace (_e ,_da ,_ag ,1);_cg ++;}else {_aa [_be ]=_b .Replace (_e ,_da ,_f ,1);};};return _b .Join (_aa ,"");};func StringToNumbers (str string )(int ,bool ){_ge :=0;_eae :=false ;for _ ,_fde :=range []byte (str ){_fde -='0';if _fde > 9{continue ;
|
|
};_ge =_ge *10+int (_fde );_eae =true ;};return _ge ,_eae ;}; |