unioffice/internal/formatutils/formatutils.go
2024-05-04 18:48:06 +00:00

28 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 (_c "fmt";_f "github.com/unidoc/unioffice/schema/soo/wml";_cc "strconv";_ae "strings";);var (_gc =[]string {"","\u0049","\u0049\u0049","\u0049\u0049\u0049","\u0049\u0056","\u0056","\u0056\u0049","\u0056\u0049\u0049","\u0056\u0049\u0049\u0049","\u0049\u0058"};
_aea =[]string {"","\u0058","\u0058\u0058","\u0058\u0058\u0058","\u0058\u004c","\u004c","\u004c\u0058","\u004c\u0058\u0058","\u004c\u0058\u0058\u0058","\u0058\u0043"};_gb =[]string {"","\u0043","\u0043\u0043","\u0043\u0043\u0043","\u0043\u0044","\u0044","\u0044\u0043","\u0044\u0043\u0043","\u0044\u0043\u0043\u0043","\u0043\u004d","\u004d"};
_ag =[]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"};
_fd =[]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"};
_e =[]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"};
_b =[]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"};
_fa =[]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"};
_ada ="\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 _eb (_fe int64 ,_bb *_f .CT_NumFmt )(_aa string ){if _bb ==nil {return ;};_dg :=_bb .ValAttr ;
switch _dg {case _f .ST_NumberFormatNone :_aa ="";case _f .ST_NumberFormatDecimal :_aa =_cc .Itoa (int (_fe ));case _f .ST_NumberFormatDecimalZero :_aa =_cc .Itoa (int (_fe ));if _fe < 10{_aa ="\u0030"+_aa ;};case _f .ST_NumberFormatUpperRoman :var (_ed =_fe %10;
_gce =(_fe %100)/10;_db =(_fe %1000)/100;_ce =_fe /1000;);_aa =_ag [_ce ]+_gb [_db ]+_aea [_gce ]+_gc [_ed ];case _f .ST_NumberFormatLowerRoman :var (_ebe =_fe %10;_fde =(_fe %100)/10;_fb =(_fe %1000)/100;_be =_fe /1000;);_aa =_ag [_be ]+_gb [_fb ]+_aea [_fde ]+_gc [_ebe ];
_aa =_ae .ToLower (_aa );case _f .ST_NumberFormatUpperLetter :_bf :=_fe %780;if _bf ==0{_bf =780;};_fc :=(_bf -1)/26;_ge :=(_bf -1)%26;_dd :=_ada [_fc +_ge ];_aa =string (_dd );case _f .ST_NumberFormatLowerLetter :_ceg :=_fe %780;if _ceg ==0{_ceg =780;
};_cfb :=(_ceg -1)/26;_dbg :=(_ceg -1)%26;_ec :=_ada [_cfb +_dbg ];_aa =_ae .ToLower (string (_ec ));default:_aa ="";};return ;};func StringToNumbers (str string )(int ,bool ){_bc :=0;_cbf :=false ;for _ ,_bg :=range []byte (str ){_bg -='0';if _bg > 9{continue ;
};_bc =_bc *10+int (_bg );_cbf =true ;};return _bc ,_cbf ;};func FormatNumberingText (currentNumber int64 ,ilvl int64 ,lvlText string ,numFmt *_f .CT_NumFmt ,levelNumbers map[int64 ]int64 )string {_aeb :=_cg (lvlText );_af :=_eb (currentNumber ,numFmt );
_ca :=int64 (0);for _cb ,_g :=range _aeb {_cf :=_c .Sprintf ("\u0025\u0025\u0025\u0064",_cb +1);if len (_aeb )==1{_cf =_c .Sprintf ("\u0025\u0025\u0025\u0064",ilvl +1);_aeb [_cb ]=_ae .Replace (_g ,_cf ,_af ,1);break ;};if ilvl > 0&&ilvl > _ca &&_cb < (len (_aeb )-1){_ad :=_eb (levelNumbers [_ca ],numFmt );
_aeb [_cb ]=_ae .Replace (_g ,_cf ,_ad ,1);_ca ++;}else {_aeb [_cb ]=_ae .Replace (_g ,_cf ,_af ,1);};};return _ae .Join (_aeb ,"");};func _cg (_d string )(_ac []string ){for _adc :=0;_adc < len (_d )-2;_adc ++{if string (_d [_adc ])=="\u0025"{if !_ae .Contains (string (_d [_adc +2:]),"\u0025"){if _adc ==0{_ac =append (_ac ,_c .Sprintf ("\u0025\u0073\u0025\u0073\u0025\u0073",string (_d [_adc ]),string (_d [_adc +1]),string (_d [_adc +2:])));
}else {_ac =append (_ac ,_c .Sprintf ("\u0025\u0073\u0025\u0073\u0025\u0073\u0025\u0073",string (_d [_adc -1]),string (_d [_adc ]),string (_d [_adc +1]),string (_d [_adc +2:])));};}else {_ac =append (_ac ,_c .Sprintf ("\u0025\u0073\u0025\u0073\u0025\u0073",string (_d [_adc ]),string (_d [_adc +1]),string (_d [_adc +2])));
};};};return ;};