// // 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 convertutils ;import (_g "bytes";_ae "errors";_gf "fmt";_db "github.com/unidoc/unioffice/common/logger";_c "github.com/unidoc/unioffice/measurement";_ed "github.com/unidoc/unioffice/schema/soo/dml";_ac "github.com/unidoc/unioffice/schema/soo/dml/chart";_dd "github.com/unidoc/unioffice/spreadsheet/format";_bd "github.com/unidoc/unipdf/v3/creator";_da "github.com/unidoc/unipdf/v3/model";_ce "github.com/unidoc/unipdf/v3/render";_fbb "github.com/unidoc/unitype";_d "image";_a "math";_e "os";_bae "sort";_ba "strconv";_fg "strings";_fb "sync";_b "unicode";);func TwipsFromPoints (points float64 )float64 {return points /_c .Twips };type Rectangle struct{Top float64 ;Bottom float64 ;Left float64 ;Right float64 ;};func _gcae (_fgfg *_ac .CT_DateAx )(uint32 ,_ac .ST_AxPos ,_ac .ST_TickMark ,_ac .ST_TickLblPos ,*_ac .CT_ChartLines ,uint32 ,*_ed .CT_ShapeProperties ,error ){var _ace ,_gade uint32 ;var _gef _ac .ST_AxPos ;var _egge _ac .ST_TickMark ;var _gbe *_ac .CT_ChartLines ;var _feaa _ac .ST_TickLblPos ;if _fgfg .AxId ==nil {return _ace ,_gef ,_egge ,_feaa ,_gbe ,_gade ,_fgfg .SpPr ,_ae .New ("\u004e\u006f\u0020x\u0020\u0061\u0078\u0069\u0073\u0020\u0049\u0044");}else {_ace =_fgfg .AxId .ValAttr ;};if _fgfg .AxPos ==nil {return _ace ,_gef ,_egge ,_feaa ,_gbe ,_gade ,_fgfg .SpPr ,_ae .New ("\u004eo\u0020x\u0020\u0061\u0078\u0069\u0073 \u0070\u006fs\u0069\u0074\u0069\u006f\u006e");}else {_gef =_fgfg .AxPos .ValAttr ;};if _fgfg .MajorTickMark !=nil {_egge =_fgfg .MajorTickMark .ValAttr ;};if _fgfg .TickLblPos !=nil {_feaa =_fgfg .TickLblPos .ValAttr ;};if _fgfg .CrossAx ==nil {return _ace ,_gef ,_egge ,_feaa ,_gbe ,_gade ,_fgfg .SpPr ,_ae .New ("\u004e\u006f \u0063\u0072\u006fs\u0073\u0020\u0061\u0078\u0069\u0073\u0020\u0049\u0044");}else {_gade =_fgfg .CrossAx .ValAttr ;};_gbe =_fgfg .MajorGridlines ;return _ace ,_gef ,_egge ,_feaa ,_gbe ,_gade ,_fgfg .SpPr ,nil ;};func (_beef *Rectangle )scale (_dee float64 ){_beef .Top *=_dee ;_beef .Bottom *=_dee ;_beef .Left *=_dee ;_beef .Right *=_dee ;};func AdjustColorByShade (colorStr string ,shade float64 )string {var _bdbbf ,_feg ,_acf uint8 ;_fcff ,_ :=_gf .Sscanf (colorStr ,"\u0025\u0030\u0032x\u0025\u0030\u0032\u0078\u0025\u0030\u0032\u0078",&_bdbbf ,&_feg ,&_acf );if _fcff !=3{return "";};return _gaeg (_bdbbf ,shade )+_gaeg (_feg ,shade )+_gaeg (_acf ,shade );};func MakeBlockFromChartSpace (cs *_ac .ChartSpace ,width ,height float64 ,theme *_ed .Theme )(*_bd .Block ,error ){_ggba ,_ceb :=_edfb (cs ,width ,height ,theme ,false );if _ceb !=nil {return nil ,_ceb ;};_gad ,_ceb :=GetPageFromCreator (_ggba );if _ceb !=nil {return nil ,_ceb ;};_beff ,_ceb :=_bd .NewBlockFromPage (_gad );if _ceb !=nil {return nil ,_ceb ;};return _beff ,nil ;};func _dcg (_ffgf _ed .ST_SchemeColorVal ,_bfga *_ed .Theme )string {if _bfgaa :=_bfga .ThemeElements ;_bfgaa !=nil {if _eega :=_bfgaa .ClrScheme ;_eega !=nil {switch _ffgf {case _ed .ST_SchemeColorValLt1 :return GetColorStringFromDmlColor (_eega .Lt1 );case _ed .ST_SchemeColorValDk1 ,_ed .ST_SchemeColorValTx1 :return GetColorStringFromDmlColor (_eega .Dk1 );case _ed .ST_SchemeColorValLt2 :return GetColorStringFromDmlColor (_eega .Lt2 );case _ed .ST_SchemeColorValDk2 :return GetColorStringFromDmlColor (_eega .Dk2 );case _ed .ST_SchemeColorValAccent1 :return GetColorStringFromDmlColor (_eega .Accent1 );case _ed .ST_SchemeColorValAccent2 :return GetColorStringFromDmlColor (_eega .Accent2 );case _ed .ST_SchemeColorValAccent3 :return GetColorStringFromDmlColor (_eega .Accent3 );case _ed .ST_SchemeColorValAccent4 :return GetColorStringFromDmlColor (_eega .Accent4 );case _ed .ST_SchemeColorValAccent5 :return GetColorStringFromDmlColor (_eega .Accent5 );case _ed .ST_SchemeColorValAccent6 :return GetColorStringFromDmlColor (_eega .Accent6 );};};};return "";};func _abg (_gbg ,_ddg ,_bbg uint8 )(float64 ,float64 ,float64 ){_acd ,_fga ,_bdgf :=float64 (_gbg )/255,float64 (_ddg )/255,float64 (_bbg )/255;_cge :=_acd ;if _fga < _cge {_cge =_fga ;};if _bdgf < _cge {_cge =_bdgf ;};var _eca ,_edgd bool ;_gddf :=_acd ;if _fga > _gddf {_gddf =_fga ;_eca =true ;};if _bdgf > _gddf {_gddf =_bdgf ;_eca =false ;_edgd =true ;};_adg :=(_cge +_gddf )/2;var _fef float64 ;if _cge !=_gddf {if _adg <=0.5{_fef =(_gddf -_cge )/(_gddf +_cge );}else {_fef =(_gddf -_cge )/(2.0-_gddf -_cge );};};var _agf float64 ;if _cge !=_gddf {if _eca {_agf =2.0+(_bdgf -_acd )/(_gddf -_cge );}else if _edgd {_agf =4.0+(_acd -_fga )/(_gddf -_cge );}else {_agf =(_fga -_bdgf )/(_gddf -_cge );};_agf *=60;if _agf < 0{_agf +=360;};};return _agf ,_fef ,_adg ;};func (_aeb *creatorContext )drawBarChart (_gb *_ac .CT_BarChart ,_fa *Rectangle ,_edc *_ac .CT_PlotAreaChoice1 )([]*legendItem ,error ){var _gff bool ;if _aca :=_gb .BarDir ;_aca !=nil {_gff =_aca .ValAttr ==_ac .ST_BarDirBar ;};_cb :=_gb .Ser ;_bae .Sort (barSerByOrder (_cb ));_cbg :=map[string ]serCategory {};_ee :=[]string {};_gba :=[]*legendItem {};_bg :=_a .Inf (1);_gd :=_a .Inf (-1);for _ ,_fc :=range _cb {var _fce string ;if _fcg :=_fc .Tx ;_fcg !=nil {if _gc :=_fcg .Choice ;_gc !=nil {if _gc .V !=nil {_fce =*_gc .V ;}else if _fd :=_gc .StrRef ;_fd !=nil {if _ga :=_fd .StrCache ;_ga !=nil {for _ ,_gca :=range _ga .Pt {_fce =_gca .V ;};};};};};if _gdg :=_fc .Cat ;_gdg !=nil {if _fbd :=_gdg .Choice ;_fbd !=nil {if _ddb :=_fbd .StrRef ;_ddb !=nil {if _fcf :=_ddb .StrCache ;_fcf !=nil {for _ ,_fe :=range _fcf .Pt {_cf :=_fe .V ;if _ ,_fdg :=_cbg [_cf ];!_fdg {_cbg [_cf ]=serCategory {_bc :_cf ,_faa :[]serValue {}};_ee =append (_ee ,_cf );};};};}else if _ef :=_fbd .NumRef ;_ef !=nil {if _fde :=_ef .NumCache ;_fde !=nil {var _aa string ;if _fde .FormatCode !=nil {_aa =*_fde .FormatCode ;};for _ ,_cd :=range _fde .Pt {var _cbea string ;if _cd .FormatCodeAttr ==nil {_cbea =_aa ;}else {_cbea =*_cd .FormatCodeAttr ;};var _gg string ;_aeba ,_fge :=_ba .ParseFloat (_cd .V ,64);if _fge !=nil {_gg =_cd .V ;}else {_gg =_dd .Number (_aeba ,_cbea );};if _ ,_gbc :=_cbg [_gg ];!_gbc {_cbg [_gg ]=serCategory {_bc :_gg ,_faa :[]serValue {}};_ee =append (_ee ,_gg );};};};};};};if _cg :=_fc .Val ;_cg !=nil {if _bda :=_cg .Choice ;_bda !=nil {if _be :=_bda .NumRef ;_be !=nil {if _ea :=_be .NumCache ;_ea !=nil {for _de ,_bac :=range _ea .Pt {_aae ,_bf :=_ba .ParseFloat (_bac .V ,64);if _bf !=nil {_aae =0;_db .Log .Debug ("\u0070a\u0072s\u0065\u0020\u0065\u0072\u0072\u006f\u0072\u003a\u0020\u0025\u0073",_bf );};if _aae > _gd {_gd =_aae ;};if _aae < _bg {_bg =_aae ;};_eb :=_cbg [_ee [_de ]];_eb ._faa =append (_eb ._faa ,serValue {_gcc :_fce ,_dea :_aae ,_aef :_fc .SpPr });_cbg [_ee [_de ]]=_eb ;};};};};};_gba =append (_gba ,&legendItem {_bcb :_fce ,_fcgg :_fc .SpPr });};var _cga float64 ;var _dcc ,_cc float64 ;if _gd ==0&&_bg ==0{_cga =0.2;_cc =0;_dcc =1;}else {var _efg float64 ;if _fea :=_a .Abs (_bg );_gd < _fea {_efg =_fea ;}else {_efg =_gd ;};_ad :=_a .Pow (10,_a .Floor (_a .Log10 (_efg )));_fbbe :=_efg /_ad ;if _fbbe >=1.715&&_fbbe < 4.29{_cga =0.5;}else if _fbbe >=4.29&&_fbbe < 8.58{_cga =1;}else {_cga =2;};_cga *=_ad ;if _gd <=0{_dcc =0;}else {_dcc =(_a .Ceil (_gd /_cga )+1)*_cga ;};if _bg >=0{_cc =0;}else {_cc =(_a .Floor (_bg /_cga )-1)*_cga ;};};_ff :=_aeb .drawAxes (_edc ,_cc ,_dcc ,_cga ,_ee ,_fa ,_gff );if _ff !=nil {return nil ,_ff ;};_bfa :=0.0;if _gb .GapWidth !=nil {if _fbe :=_gb .GapWidth .ValAttr ;_fbe !=nil {if _cgb :=_fbe .ST_GapAmountUShort ;_cgb !=nil {_bfa =float64 (*_cgb )/100.0;};};};_cfa :=_fa .Right -_fa .Left ;_fca :=_fa .Bottom -_fa .Top ;_edce :=float64 (len (_ee ));if _gff {_gga :=_dcc /(_dcc -_cc )*_cfa ;_dcb :=-_cc /(_dcc -_cc )*_cfa ;_fbda :=_fa .Left +_dcb ;_fbf :=_fca /_edce ;for _cfd ,_eg :=range _ee {_ede :=_cbg [_eg ];_ec :=float64 (len (_ede ._faa ))+_bfa ;_dab :=_fbf /_ec ;_fgd :=_dab *_bfa ;_fgg :=_fa .Bottom -float64 (_cfd )*_fbf -_fgd /2-_dab ;for _ ,_cag :=range _ede ._faa {if _cag ._dea ==0{continue ;};var _ecc ,_gdd float64 ;if _cag ._dea > 0{_gdd =_cag ._dea /_dcc *_gga ;_aeb .drawRectangleWithProps (_cag ._aef ,_fbda ,_fgg ,_gdd ,_dab ,false );}else {_gdd =_cag ._dea /_cc *_dcb ;_ecc =_fbda -_gdd ;_aeb .drawRectangleWithProps (_cag ._aef ,_ecc ,_fgg ,_gdd ,_dab ,false );};_fgg -=_dab ;};};}else {_ggb :=_dcc /(_dcc -_cc )*_fca ;_bag :=-_cc /(_dcc -_cc )*_fca ;_bb :=_fa .Top +_ggb ;_cdc :=_cfa /_edce ;for _fec ,_edd :=range _ee {_dg :=_cbg [_edd ];_bef :=float64 (len (_dg ._faa ))+_bfa ;_gaf :=_cdc /_bef ;_cbd :=_gaf *_bfa ;_ada :=_fa .Left +float64 (_fec )*_cdc +_cbd /2;for _ ,_baa :=range _dg ._faa {var _aed ,_edf float64 ;if _baa ._dea > 0{_edf =_baa ._dea /_dcc *_ggb ;_aed =_bb -_edf ;_aeb .drawRectangleWithProps (_baa ._aef ,_ada ,_aed ,_gaf ,_edf ,false );}else {_edf =_baa ._dea /_cc *_bag ;_aeb .drawRectangleWithProps (_baa ._aef ,_ada ,_bb ,_gaf ,_edf ,false );};_ada +=_gaf ;};};};return _gba ,nil ;};func GetRegisteredFont (name string ,style FontStyle )*_da .PdfFont {_dfff ._fcfe .Lock ();defer _dfff ._fcfe .Unlock ();if _abgb ,_bgd :=_dfff ._dccf [name ];_bgd {if _dggb ,_ccb :=_abgb [style ];_ccb {return _dggb ;};};return nil ;};type FontStyle byte ;func GetOpacityFromColorTransform (trs []*_ed .EG_ColorTransform )float64 {for _ ,_cgbe :=range trs {if _cgbe !=nil {if _fbff :=_cgbe .Alpha ;_fbff !=nil {if _ddf :=_fbff .ValAttr .ST_PositiveFixedPercentageDecimal ;_ddf !=nil {return float64 (*_ddf )/100000;};};};};return 1.0;};type serValue struct{_gcc string ;_dea float64 ;_aef *_ed .CT_ShapeProperties ;};func Lighten (clr float64 )float64 {return 0.6+0.4*clr };func _edfb (_deb *_ac .ChartSpace ,_gfe ,_bdg float64 ,_ebg *_ed .Theme ,_deae bool )(*_bd .Creator ,error ){_ecb :=1.0;if _deae {_ecb =8.0;};_fgc :=&Rectangle {};_aee :=&Rectangle {Top :_fgc .Top ,Bottom :_bdg -_fgc .Bottom ,Left :_fgc .Left ,Right :_gfe -_fgc .Right };_edg :=MakeTempCreator (_gfe *_ecb +1,_bdg *_ecb +1);_gdb :=&creatorContext {_bff :_edg ,_bace :_ebg ,_aeda :_ecb };var _fgdf bool ;if _cde :=_deb .Chart ;_cde !=nil {_dcce :=_cde .PlotArea ;if _dcce ==nil {return nil ,_ae .New ("\u004e\u006f\u0020p\u006c\u006f\u0074\u0020\u0061\u0072\u0065\u0061");};_bdd :=&Rectangle {Top :_adgg (10),Bottom :_aee .Bottom -_adgg (15),Left :_adgg (10),Right :_aee .Right -_adgg (10)};var _gce *Rectangle ;_fac :=_cde .Legend ;if _fac !=nil {_ggae :=_fac .Overlay !=nil &&_fac .Overlay .ValAttr !=nil &&*_fac .Overlay .ValAttr ;if _aefd :=_fac .LegendPos ;_aefd !=nil {switch _aefd .ValAttr {case _ac .ST_LegendPosTr :if !_ggae {_bdd =&Rectangle {Top :_adgg (25),Bottom :_aee .Bottom -_adgg (10),Left :_adgg (10),Right :_aee .Right -_adgg (25)};};_gce =&Rectangle {Top :_adgg (2.5),Bottom :_adgg (22.5),Left :_aee .Right -_adgg (22.5),Right :_aee .Right -_adgg (2.5)};case _ac .ST_LegendPosT :_gce =&Rectangle {Top :_adgg (2.5),Bottom :_adgg (7.5),Left :(_aee .Right -_aee .Left )*0.25,Right :(_aee .Right -_aee .Left )*0.75};if !_ggae {_bdd =&Rectangle {Top :_adgg (12.5),Bottom :_aee .Bottom -_adgg (15),Left :_adgg (10),Right :_aee .Right -_adgg (5)};};_fgdf =true ;case _ac .ST_LegendPosB :_gce =&Rectangle {Top :_aee .Bottom -_adgg (7.5),Bottom :_aee .Bottom -_adgg (2.5),Left :(_aee .Right -_aee .Left )*0.25,Right :(_aee .Right -_aee .Left )*0.75};if !_ggae {_bdd =&Rectangle {Top :_adgg (5),Bottom :_aee .Bottom -_adgg (15),Left :_adgg (10),Right :_aee .Right -_adgg (5)};};_fgdf =true ;case _ac .ST_LegendPosR :_gce =&Rectangle {Top :(_aee .Bottom -_aee .Top )/2-_adgg (10),Bottom :(_aee .Bottom -_aee .Top )/2+_adgg (10),Left :_aee .Right -_adgg (22.5),Right :_aee .Right -_adgg (2.5)};if !_ggae {_bdd =&Rectangle {Top :_adgg (5),Bottom :_aee .Bottom -_adgg (12.5),Left :_adgg (10),Right :_aee .Right -_adgg (25)};};case _ac .ST_LegendPosL :_gce =&Rectangle {Top :(_aee .Bottom -_aee .Top )/2-_adgg (10),Bottom :(_aee .Bottom -_aee .Top )/2+_adgg (10),Left :_adgg (2.5),Right :_adgg (22.5)};if !_ggae {_bdd =&Rectangle {Top :_adgg (5),Bottom :_aee .Bottom -_adgg (12.5),Left :_adgg (30),Right :_aee .Right -_adgg (5)};};default:_gce =&Rectangle {Top :(_aee .Bottom -_aee .Top )/2-_adgg (10),Bottom :(_aee .Bottom -_aee .Top )/2+_adgg (10),Left :_aee .Right -_adgg (25),Right :_aee .Right -_adgg (5)};if !_ggae {_bdd =&Rectangle {Top :_adgg (5),Bottom :_aee .Bottom -_adgg (12.5),Left :_adgg (100),Right :_aee .Right -_adgg (25)};};};};};_bdd .scale (_ecb );_gdb .drawBorderWithProps (_dcce .SpPr ,_bdd ,_fbc );_ffg :=[]*legendItem {};var _dgg error ;_cgaf :=_dcce .CChoice ;for _ ,_bca :=range _dcce .Choice {if _ffgg :=_bca .BarChart ;_ffgg !=nil {_ffg ,_dgg =_gdb .drawBarChart (_ffgg ,_bdd ,_cgaf );if _dgg !=nil {return nil ,_dgg ;};};};if _fac !=nil {_gce .scale (_ecb );_gdb .drawBorderWithProps (_fac .SpPr ,_gce ,_fbc );if len (_ffg )!=0{_gdb .drawLegend (_gce ,_ffg ,_fgdf );};};};_aee .scale (_ecb );_gdb .drawBorderWithProps (_deb .SpPr ,_aee ,_fbc );return _edg ,nil ;};type fontsMap struct{_fcfe *_fb .Mutex ;_dccf map[string ]map[FontStyle ]*_da .PdfFont ;};func (_bee *creatorContext )drawLegend (_daa *Rectangle ,_aedc []*legendItem ,_eeb bool ){_abb :=_bee ._aeda ;_gfda :=_adgg (2.5)*_abb ;_dca :=_cff *_abb ;_gfef :=(_gfda -_dca )/2;_gda :=float64 (len (_aedc ));if _eeb {_fcgb :=&Rectangle {Top :_daa .Top +_adgg (1)*_abb ,Bottom :_daa .Bottom -_adgg (1)*_abb ,Left :_daa .Left +_adgg (2.5)*_abb ,Right :_daa .Right -_adgg (2.5)*_abb };var _aab float64 ;if _gda > 1{_aab =(_fcgb .Right -_fcgb .Left )/_gda ;};_acaf :=_fcgb .Left ;_cae :=_fcgb .Top ;for _ ,_fgf :=range _aedc {if _ggg :=_fgf ._fcgg ;_ggg !=nil {_bee .drawRectangleWithProps (_ggg ,_acaf ,_cae +_gfef ,_dca ,_dca ,false );_daf :=_acaf +_dca *2;_ge :=_bee ._bff .NewStyledParagraph ();_ge .SetPos (_daf ,_cae );_dbb :=_ge .Append (_fgf ._bcb );_egg ,_eba :=_da .NewStandard14Font (_da .HelveticaName );if _eba ==nil {_dbb .Style =_bd .TextStyle {FontSize :_gfda ,Font :_egg ,TextRise :0.4};_bee ._bff .Draw (_ge );};};_acaf +=_aab ;};}else {_ged :=&Rectangle {Top :_daa .Top +_adgg (2.5)*_abb ,Bottom :_daa .Bottom -_adgg (2.5)*_abb ,Left :_daa .Left +_adgg (2.5)*_abb ,Right :_daa .Right -_adgg (2.5)*_abb };var _dbg float64 ;if _gda > 1{_dbg =(_ged .Bottom -_ged .Top -_gfda )/(_gda -1);};_dfd :=_ged .Top ;_gab :=_ged .Left ;_gfed :=_gab +_dca *2;for _ ,_cca :=range _aedc {if _bcba :=_cca ._fcgg ;_bcba !=nil {_bee .drawRectangleWithProps (_bcba ,_gab ,_dfd +_gfef ,_dca ,_dca ,false );_gggb :=_bee ._bff .NewStyledParagraph ();_gggb .SetPos (_gfed ,_dfd );_ccc :=_gggb .Append (_cca ._bcb );_aebae ,_bab :=_da .NewStandard14Font (_da .HelveticaName );if _bab ==nil {_ccc .Style =_bd .TextStyle {FontSize :_gfda ,Font :_aebae ,TextRise :0.4};_bee ._bff .Draw (_gggb );};};_dfd +=_dbg ;};};};func FromSTCoordinate32 (st _ed .ST_Coordinate32 )int64 {if _adff :=st .ST_Coordinate32Unqualified ;_adff !=nil {return int64 (*_adff );};return 0;};func GetColorStringFromDmlColor (dmlColor *_ed .CT_Color )string {var _dde string ;if _cec :=dmlColor .SrgbClr ;_cec !=nil {_dde =_cec .ValAttr ;}else if _ccg :=dmlColor .SysClr ;_ccg !=nil {return "\u0030\u0030\u0030\u0030\u0030\u0030";};return _dde ;};func IsNoSpaceLanguage (symbol string )bool {for _ ,_afde :=range symbol {if _b .Is (_b .Han ,_afde ){return true ;};};return false ;};func _cbc (_aabg *_ac .CT_SerAx )(uint32 ,_ac .ST_AxPos ,_ac .ST_TickMark ,_ac .ST_TickLblPos ,*_ac .CT_ChartLines ,uint32 ,*_ed .CT_ShapeProperties ,error ){var _bcc ,_cab uint32 ;var _gccd _ac .ST_AxPos ;var _bcd _ac .ST_TickMark ;var _cccb *_ac .CT_ChartLines ;var _fba _ac .ST_TickLblPos ;if _aabg .AxId ==nil {return _bcc ,_gccd ,_bcd ,_fba ,_cccb ,_cab ,_aabg .SpPr ,_ae .New ("\u004e\u006f\u0020x\u0020\u0061\u0078\u0069\u0073\u0020\u0049\u0044");}else {_bcc =_aabg .AxId .ValAttr ;};if _aabg .AxPos ==nil {return _bcc ,_gccd ,_bcd ,_fba ,_cccb ,_cab ,_aabg .SpPr ,_ae .New ("\u004eo\u0020x\u0020\u0061\u0078\u0069\u0073 \u0070\u006fs\u0069\u0074\u0069\u006f\u006e");}else {_gccd =_aabg .AxPos .ValAttr ;};if _aabg .MajorTickMark !=nil {_bcd =_aabg .MajorTickMark .ValAttr ;};if _aabg .TickLblPos !=nil {_fba =_aabg .TickLblPos .ValAttr ;};if _aabg .CrossAx ==nil {return _bcc ,_gccd ,_bcd ,_fba ,_cccb ,_cab ,_aabg .SpPr ,_ae .New ("\u004e\u006f \u0063\u0072\u006fs\u0073\u0020\u0061\u0078\u0069\u0073\u0020\u0049\u0044");}else {_cab =_aabg .CrossAx .ValAttr ;};_cccb =_aabg .MajorGridlines ;return _bcc ,_gccd ,_bcd ,_fba ,_cccb ,_cab ,_aabg .SpPr ,nil ;};var _cbdc =_adgg (1);func _eebc (_caaa _ed .ST_SchemeColorVal ,_dgb *_ed .Theme )string {if _cdf :=_dgb .ThemeElements ;_cdf !=nil {if _dge :=_cdf .ClrScheme ;_dge !=nil {switch _caaa {case _ed .ST_SchemeColorValLt1 :return GetColorStringFromDmlColor (_dge .Lt1 );case _ed .ST_SchemeColorValDk1 ,_ed .ST_SchemeColorValTx1 :return GetColorStringFromDmlColor (_dge .Dk1 );case _ed .ST_SchemeColorValLt2 :return GetColorStringFromDmlColor (_dge .Lt2 );case _ed .ST_SchemeColorValDk2 :return GetColorStringFromDmlColor (_dge .Dk2 );case _ed .ST_SchemeColorValAccent1 :return GetColorStringFromDmlColor (_dge .Accent1 );case _ed .ST_SchemeColorValAccent2 :return GetColorStringFromDmlColor (_dge .Accent2 );case _ed .ST_SchemeColorValAccent3 :return GetColorStringFromDmlColor (_dge .Accent3 );case _ed .ST_SchemeColorValAccent4 :return GetColorStringFromDmlColor (_dge .Accent4 );case _ed .ST_SchemeColorValAccent5 :return GetColorStringFromDmlColor (_dge .Accent5 );case _ed .ST_SchemeColorValAccent6 :return GetColorStringFromDmlColor (_dge .Accent6 );};};};return "";};func _adgg (_eedb float64 )float64 {return _eedb *_c .Millimeter };func RegisterFontsFromFiles (files []string )error {for _ ,_fggf :=range files {if _fg .HasSuffix (_fggf ,"\u002e\u0074\u0074\u0066"){_abbb :=_ebc (_fggf );if _abbb !=nil {_db .Log .Debug ("\u0075\u006ea\u0062\u006c\u0065\u0020\u0074o\u0020\u0070\u0072\u006f\u0063e\u0073\u0073\u0020\u0061\u006e\u0064\u0020\u0072\u0065\u0067\u0069\u0073\u0074\u0065\u0072\u0020\u0066\u006f\u006e\u0074\u0020\u0066\u0072\u006f\u006d\u0020\u0054\u0054\u0046\u0020\u0066\u0069\u006c\u0065\u0020\u0025\u0073",_abbb );continue ;};};};return nil ;};func (_fcd *Rectangle )Translate (x ,y float64 ){_fcd .Left +=x ;_fcd .Right +=x ;_fcd .Top +=y ;_fcd .Bottom +=y ;};func (_efa *creatorContext )drawAxes (_daac *_ac .CT_PlotAreaChoice1 ,_fbec ,_cfc ,_gee float64 ,_feca []string ,_ggd *Rectangle ,_fee bool )error {_caf :=_efa ._bff ;_dag :=_efa ._aeda ;if _daac ==nil {return _ae .New ("\u004e\u006f\u0020\u0061xi\u0073\u0020\u0069\u006e\u0066\u006f\u0072\u006d\u0061\u0074\u0069\u006f\u006e");};if len (_daac .ValAx )==0||(len (_daac .CatAx )==0&&len (_daac .DateAx )==0&&len (_daac .SerAx )==0){return _ae .New ("\u004e\u006f\u0020\u0078\u0020\u006f\u0072\u0020\u0079 \u0061\u0078\u0069\u0073");};var _fda ,_aff ,_gdc ,_ebbe uint32 ;var _fff ,_abc _ac .ST_AxPos ;var _deg ,_gfc _ac .ST_TickMark ;var _adag ,_bfg *_ac .CT_ChartLines ;var _aaf ,_cea _ac .ST_TickLblPos ;var _dbf ,_bbb *_ed .CT_ShapeProperties ;var _eed error ;_dfa :=_ggd .Right -_ggd .Left ;_bbe :=_ggd .Bottom -_ggd .Top ;if len (_daac .ValAx )> 0{_aff ,_abc ,_gfc ,_cea ,_bfg ,_ebbe ,_bbb ,_eed =_efd (_daac .ValAx [0]);};if _abc !=_ac .ST_AxPosL &&_abc !=_ac .ST_AxPosB {return _ae .New ("\u004f\u006e\u006c\u0079\u0020l\u0065\u0066\u0074\u0020\u006f\u0072\u0020\u0062\u006f\u0074\u0074\u006f\u006d \u0079\u0020\u0061\u0078\u0069\u0073\u0020\u0073\u0075\u0070\u0070\u006f\u0072\u0074\u0020\u0073\u006f\u0020\u0066\u0061\u0072");};_eea :=_cfc -_fbec ;_ag :=int (_eea /_gee )+1;var _geb ,_aac float64 ;switch _gfc {case _ac .ST_TickMarkIn :_geb ,_aac =_cbdc ,0;case _ac .ST_TickMarkOut :_geb ,_aac =0,_cbdc ;case _ac .ST_TickMarkCross :_geb ,_aac =_cbdc ,_cbdc ;};_geb =_geb *_dag ;_aac =_aac *_dag ;var _cbdf *_ed .CT_ShapeProperties ;if _bfg !=nil {_cbdf =_bfg .SpPr ;};_aedca ,_bdf :=_aaf !=_ac .ST_TickLblPosNone ,_cea !=_ac .ST_TickLblPosNone ;_dcbd :=_fbec ;if len (_daac .CatAx )> 0{_fda ,_fff ,_deg ,_aaf ,_adag ,_gdc ,_dbf ,_eed =_gfgg (_daac .CatAx [0]);}else if len (_daac .DateAx )> 0{_fda ,_fff ,_deg ,_aaf ,_adag ,_gdc ,_dbf ,_eed =_gcae (_daac .DateAx [0]);}else if len (_daac .SerAx )> 0{_fda ,_fff ,_deg ,_aaf ,_adag ,_gdc ,_dbf ,_eed =_cbc (_daac .SerAx [0]);};if _eed !=nil {return _eed ;};if _fff !=_ac .ST_AxPosL &&_fff !=_ac .ST_AxPosB {return _ae .New ("\u004f\u006e\u006c\u0079\u0020l\u0065\u0066\u0074\u0020\u006f\u0072\u0020\u0062\u006f\u0074\u0074\u006f\u006d \u0078\u0020\u0061\u0078\u0069\u0073\u0020\u0073\u0075\u0070\u0070\u006f\u0072\u0074\u0020\u0073\u006f\u0020\u0066\u0061\u0072");};if _fda !=_ebbe ||_aff !=_gdc {return _ae .New ("a\u0078i\u0073\u0020\u0069\u0064\u0073\u0020\u0064\u006fn\u0027\u0074\u0020\u006dat\u0063\u0068");};_aedf :=len (_feca )+1;var _ddbc ,_befg float64 ;switch _deg {case _ac .ST_TickMarkIn :_ddbc ,_befg =_cbdc ,0;case _ac .ST_TickMarkOut :_ddbc ,_befg =0,_cbdc ;case _ac .ST_TickMarkCross :_ddbc ,_befg =_cbdc ,_cbdc ;};_ddbc =_ddbc *_dag ;_befg =_befg *_dag ;var _aaff *_ed .CT_ShapeProperties ;if _adag !=nil {_aaff =_adag .SpPr ;};if _fee {_bcf :=_bbe /float64 (len (_feca ));_eae :=_ggd .Left -_fbec *_dfa /_eea ;_ceac :=_eae -_eda *_dag ;if _aedca {var _gae float64 ;for _dfae :=0;_dfae < _aedf ;_dfae ++{_bbef :=_ggd .Bottom -float64 (_dfae )*_bcf ;if _dfae < _aedf -1{_daee :=_caf .NewParagraph (_feca [_dfae ]);_daee .SetFontSize (_dfg *_dag );_daee .SetPos (_ceac ,_bbef -_bcf /2-_fbeb *_dag );_caf .Draw (_daee );_fdb :=(_daee .Width ()/1000-_eda )*_dag ;if _fdb > 0&&_fdb > _gae {_gae =_fdb ;};};};if _gae > 0{_ggd .Left +=_gae +_af ;_eae =_ggd .Left -_fbec *_dfa /_eea ;_dfa =_ggd .Right -_ggd .Left ;};};_dac :=_eae -_befg ;_cagc :=_eae +_ddbc ;_ebge :=_ggd .Left ;_afa :=_ggd .Right ;for _eag :=0;_eag < _aedf ;_eag ++{_caa :=_ggd .Bottom -float64 (_eag )*_bcf ;_efa .drawLineWithProps (_dbf ,_dac ,_caa ,_cagc ,_caa ,true );_efa .drawLineWithProps (_aaff ,_ebge ,_caa ,_afa ,_caa ,true );};_gcad :=_dfa /_eea ;_aafb :=_ggd .Bottom -_geb ;_ddd :=_ggd .Bottom +_aac ;_befc :=_ggd .Top ;_afe :=_ggd .Bottom ;for _gfg :=0;_gfg < _ag ;_gfg ++{_dgge :=_ggd .Left +(_dcbd -_fbec )*_gcad ;_efa .drawLineWithProps (_bbb ,_dgge ,_aafb ,_dgge ,_ddd ,true );_efa .drawLineWithProps (_cbdf ,_dgge ,_befc ,_dgge ,_afe ,true );if _bdf {_dda :=_caf .NewParagraph (_ba .FormatFloat (_dcbd ,'g',-1,64));_dda .SetFontSize (_dfg *_dag );_dda .SetPos (_dgge -_fcec *_dag ,_afe +_cce *_dag );_caf .Draw (_dda );};_dcbd +=_gee ;};}else {_gafa :=_bbe /_eea ;_eeg :=_ggd .Left ;if _bdf {var _dbe float64 ;for _eagf :=0;_eagf < _ag ;_eagf ++{_babe :=_ggd .Bottom -(_dcbd -_fbec )*_gafa ;_edaa :=_caf .NewParagraph (_ba .FormatFloat (_dcbd ,'g',-1,64));_edaa .SetFontSize (_dfg *_dag );_edaa .SetPos (_eeg -_eda *_dag ,_babe -_fbeb *_dag );_caf .Draw (_edaa );_eff :=(_edaa .Width ()/1000-_eda )*_dag ;if _eff > 0&&_eff > _dbe {_dbe =_eff ;};_dcbd +=_gee ;};if _dbe > 0{_ggd .Left +=_dbe +_af ;_dfa =_ggd .Right -_ggd .Left ;};};_dcbd =_fbec ;_gge :=_ggd .Left -_aac ;_eec :=_ggd .Left +_geb ;_eeg =_ggd .Left ;_dfc :=_ggd .Right ;for _efae :=0;_efae < _ag ;_efae ++{_gbb :=_ggd .Bottom -(_dcbd -_fbec )*_gafa ;_efa .drawLineWithProps (_bbb ,_gge ,_gbb ,_eec ,_gbb ,true );_efa .drawLineWithProps (_cbdf ,_eeg ,_gbb ,_dfc ,_gbb ,true );_dcbd +=_gee ;};_ebbb :=_dfa /float64 (len (_feca ));_bdb :=_ggd .Bottom +_fbec *_bbe /_eea ;_dfgb :=_bdb -_ddbc ;_afag :=_bdb +_befg ;_aag :=_ggd .Top ;_fggd :=_ggd .Bottom ;_cbgd :=_bdb +_cce *_dag ;for _bdc :=0;_bdc < _aedf ;_bdc ++{_cgaff :=_ggd .Left +float64 (_bdc )*_ebbb ;_efa .drawLineWithProps (_dbf ,_cgaff ,_dfgb ,_cgaff ,_afag ,true );_efa .drawLineWithProps (_aaff ,_cgaff ,_aag ,_cgaff ,_fggd ,true );if _aedca &&_bdc < _aedf -1{_beee :=_caf .NewParagraph (_feca [_bdc ]);_beee .SetFontSize (_dfg *_dag );_beee .SetPos (_cgaff +_aeee *_dag ,_cbgd );_caf .Draw (_beee );};};};return nil ;};func AdjustColor (colorStr string ,EG_ColorTransform []*_ed .EG_ColorTransform )string {for _ ,_dgd :=range EG_ColorTransform {if _ffded :=_dgd .Tint ;_ffded !=nil {if _efe :=_ffded .ValAttr .ST_PositiveFixedPercentageDecimal ;_efe !=nil {colorStr =AdjustColorByTint (colorStr ,float64 (*_efe )/100000);};};if _daeb :=_dgd .Shade ;_daeb !=nil {if _bfc :=_daeb .ValAttr .ST_PositiveFixedPercentageDecimal ;_bfc !=nil {colorStr =AdjustColorByShade (colorStr ,float64 (*_bfc )/100000);};};if _fgcb :=_dgd .LumMod ;_fgcb !=nil {if _ece :=_fgcb .ValAttr .ST_PercentageDecimal ;_ece !=nil {colorStr =AdjustColorByLumMod (colorStr ,float64 (*_ece )/100000);};};};return colorStr ;};const _dfg =6.0;type creatorContext struct{_bff *_bd .Creator ;_bace *_ed .Theme ;_aeda float64 ;};const (FontStyle_Regular FontStyle =0;FontStyle_Bold FontStyle =1;FontStyle_Italic FontStyle =2;FontStyle_BoldItalic FontStyle =3;);func MakeImageFromChartSpace (cs *_ac .ChartSpace ,width ,height float64 ,theme *_ed .Theme )(_d .Image ,error ){_ab ,_adc :=_edfb (cs ,width ,height ,theme ,true );if _adc !=nil {return nil ,_adc ;};_bbd ,_adc :=GetPageFromCreator (_ab );if _adc !=nil {return nil ,_adc ;};return _ce .NewImageDevice ().Render (_bbd );};func AdjustColorByLumMod (colorStr string ,lum float64 )string {var _bbff ,_gceg ,_cabc uint8 ;_efad ,_ :=_gf .Sscanf (colorStr ,"\u0025\u0030\u0032x\u0025\u0030\u0032\u0078\u0025\u0030\u0032\u0078",&_bbff ,&_gceg ,&_cabc );if _efad !=3{return "";};_cfce ,_cbcb ,_eef :=_abg (_bbff ,_gceg ,_cabc );_eef =lum *_eef ;_bbff ,_gceg ,_cabc =_ebbg (_cfce ,_cbcb ,_eef );return _gf .Sprintf ("\u0025\u0030\u0032x\u0025\u0030\u0032\u0078\u0025\u0030\u0032\u0078",_bbff ,_gceg ,_cabc );};func _gaeg (_dcga uint8 ,_fdd float64 )string {_gabd :=float64 (_dcga );return _gf .Sprintf ("\u0025\u0030\u0032\u0078",int (_gabd *_fdd ));};var _fcec =_adgg (0.5);var _aeee =_adgg (5);func PointsFromTwips (twips int64 )float64 {return float64 (int64 (float64 (twips )*_c .Twips *10+0.5))/10};func (_adab barSerByOrder )Less (i ,j int )bool {return _adab [i ].Order .ValAttr < _adab [j ].Order .ValAttr ;};func _gfgg (_ffd *_ac .CT_CatAx )(uint32 ,_ac .ST_AxPos ,_ac .ST_TickMark ,_ac .ST_TickLblPos ,*_ac .CT_ChartLines ,uint32 ,*_ed .CT_ShapeProperties ,error ){var _fcc ,_bcad uint32 ;var _fggdb _ac .ST_AxPos ;var _bbc _ac .ST_TickMark ;var _dage *_ac .CT_ChartLines ;var _ffde _ac .ST_TickLblPos ;if _ffd .AxId ==nil {return _fcc ,_fggdb ,_bbc ,_ffde ,_dage ,_bcad ,_ffd .SpPr ,_ae .New ("\u004e\u006f\u0020x\u0020\u0061\u0078\u0069\u0073\u0020\u0049\u0044");}else {_fcc =_ffd .AxId .ValAttr ;};if _ffd .AxPos ==nil {return _fcc ,_fggdb ,_bbc ,_ffde ,_dage ,_bcad ,_ffd .SpPr ,_ae .New ("\u004eo\u0020x\u0020\u0061\u0078\u0069\u0073 \u0070\u006fs\u0069\u0074\u0069\u006f\u006e");}else {_fggdb =_ffd .AxPos .ValAttr ;};if _ffd .MajorTickMark !=nil {_bbc =_ffd .MajorTickMark .ValAttr ;};if _ffd .TickLblPos !=nil {_ffde =_ffd .TickLblPos .ValAttr ;};if _ffd .CrossAx ==nil {return _fcc ,_fggdb ,_bbc ,_ffde ,_dage ,_bcad ,_ffd .SpPr ,_ae .New ("\u004e\u006f \u0063\u0072\u006fs\u0073\u0020\u0061\u0078\u0069\u0073\u0020\u0049\u0044");}else {_bcad =_ffd .CrossAx .ValAttr ;};_dage =_ffd .MajorGridlines ;return _fcc ,_fggdb ,_bbc ,_ffde ,_dage ,_bcad ,_ffd .SpPr ,nil ;};func DrawRectangle (c *_bd .Creator ,r *Rectangle ,w float64 ,color _bd .Color ){if color ==nil {return ;};DrawLine (c ,r .Left ,r .Top ,r .Right ,r .Top ,w ,color );DrawLine (c ,r .Left ,r .Top ,r .Left ,r .Bottom ,w ,color );DrawLine (c ,r .Left ,r .Bottom ,r .Right ,r .Bottom ,w ,color );DrawLine (c ,r .Right ,r .Top ,r .Right ,r .Bottom ,w ,color );};const (BorderPositionTop BorderPosition =0;BorderPositionLeft BorderPosition =1;BorderPositionBottom BorderPosition =2;BorderPositionRight BorderPosition =3;);func (_fbdea *creatorContext )drawRectangleWithProps (_edb *_ed .CT_ShapeProperties ,_adaf ,_bgg ,_fbcb ,_fdf float64 ,_cege bool ){_gdaf :=_fbdea ._bff .NewRectangle (_adaf ,_bgg ,_fbcb ,_fdf );if _edb ==nil {if _cege {_gdaf .SetBorderWidth (_fbc );}else {return ;};}else {_bcac :=_fbdea .getPdfColorFromSolidFill (_edb .SolidFill );if _bcac !=nil {_gdaf .SetFillColor (_bcac );};if _bded :=_edb .Ln ;_bded !=nil {if _gdf :=_bded .WAttr ;_gdf !=nil {_abbd :=_c .FromEMU (int64 (*_gdf ));_gdaf .SetBorderWidth (_abbd );if _fbfe :=_bded .SolidFill ;_fbfe !=nil {_cfdb :=_fbdea .getPdfColorFromSolidFill (_fbfe );if _cfdb !=nil {_gdaf .SetBorderColor (_cfdb );};};}else {_gdaf .SetBorderWidth (0);};};};_fbdea ._bff .Draw (_gdaf );};func _efd (_cfbc *_ac .CT_ValAx )(uint32 ,_ac .ST_AxPos ,_ac .ST_TickMark ,_ac .ST_TickLblPos ,*_ac .CT_ChartLines ,uint32 ,*_ed .CT_ShapeProperties ,error ){var _feed ,_abf uint32 ;var _ddbb _ac .ST_AxPos ;var _gcadd _ac .ST_TickMark ;var _ebbd *_ac .CT_ChartLines ;var _eaee _ac .ST_TickLblPos ;if _cfbc .AxId ==nil {return _feed ,_ddbb ,_gcadd ,_eaee ,_ebbd ,_abf ,_cfbc .SpPr ,_ae .New ("\u004e\u006f\u0020x\u0020\u0061\u0078\u0069\u0073\u0020\u0049\u0044");}else {_feed =_cfbc .AxId .ValAttr ;};if _cfbc .AxPos ==nil {return _feed ,_ddbb ,_gcadd ,_eaee ,_ebbd ,_abf ,_cfbc .SpPr ,_ae .New ("\u004eo\u0020x\u0020\u0061\u0078\u0069\u0073 \u0070\u006fs\u0069\u0074\u0069\u006f\u006e");}else {_ddbb =_cfbc .AxPos .ValAttr ;};if _cfbc .MajorTickMark !=nil {_gcadd =_cfbc .MajorTickMark .ValAttr ;};if _cfbc .TickLblPos !=nil {_eaee =_cfbc .TickLblPos .ValAttr ;};if _cfbc .CrossAx ==nil {return _feed ,_ddbb ,_gcadd ,_eaee ,_ebbd ,_abf ,_cfbc .SpPr ,_ae .New ("\u004e\u006f \u0063\u0072\u006fs\u0073\u0020\u0061\u0078\u0069\u0073\u0020\u0049\u0044");}else {_abf =_cfbc .CrossAx .ValAttr ;};_ebbd =_cfbc .MajorGridlines ;return _feed ,_ddbb ,_gcadd ,_eaee ,_ebbd ,_abf ,_cfbc .SpPr ,nil ;};type barSerByOrder []*_ac .CT_BarSer ;var _dfgd =map[string ]FontStyle {"\u0052e\u0067\u0075\u006c\u0061\u0072":FontStyle_Regular ,"\u0042\u006f\u006c\u0064":FontStyle_Bold ,"\u0049\u0074\u0061\u006c\u0069\u0063":FontStyle_Italic ,"B\u006f\u006c\u0064\u0020\u0049\u0074\u0061\u006c\u0069\u0063":FontStyle_BoldItalic };func MakeTempCreator (width ,height float64 )*_bd .Creator {_bde :=_bd .New ();_bde .SetPageSize (_bd .PageSize {width ,height });_bde .SetPageMargins (0,0,0,0);return _bde ;};func CropImageByRect (sourceImg _d .Image ,rect _d .Rectangle )_d .Image {_cfbfe ,_gea ,_cegee ,_bggd :=rect .Min .X ,rect .Min .Y ,rect .Max .X ,rect .Max .Y ;_fbfd :=_d .NewNRGBA (_d .Rect (0,0,_cegee -_cfbfe ,_bggd -_gea ));for _gdbc :=_cfbfe ;_gdbc < _cegee ;_gdbc ++{for _feae :=_gea ;_feae < _bggd ;_feae ++{_fbfd .Set (_gdbc -_cfbfe ,_feae -_gea ,sourceImg .At (_gdbc ,_feae ));};};return _fbfd ;};func _dff (_afd uint8 ,_dad float64 )string {_bdbb :=float64 (_afd );var _fgb float64 ;if _dad < 0{_fgb =_bdbb *(1+_dad );}else {_fgb =_bdbb +(255-_bdbb )*_dad ;};return _gf .Sprintf ("\u0025\u0030\u0032\u0078",int (_fgb ));};func (_cgbc *creatorContext )drawLineWithProps (_afaa *_ed .CT_ShapeProperties ,_adf ,_gaff ,_bcdb ,_cbb float64 ,_cba bool ){if _afaa !=nil {if _bffg :=_afaa .Ln ;_bffg !=nil {_adgd :=_cgbc .getPdfColorFromSolidFill (_bffg .SolidFill );if _adgd ==nil &&_cba {_adgd =_bd .ColorBlack ;};if _adgd !=nil {var _cfbf float64 ;if _acee :=_bffg .WAttr ;_acee !=nil {_cfbf =_c .FromEMU (int64 (*_acee ));}else {_cfbf =_fbc ;};DrawLine (_cgbc ._bff ,_adf ,_gaff ,_bcdb ,_cbb ,_cfbf ,_adgd );};};};};func AssignStdFontByName (style _bd .TextStyle ,fontName string )*_da .PdfFont {_cgdg :=_da .StdFontName (fontName );return _da .NewStandard14FontMustCompile (_cgdg );};func GetDataFromXfrm (xfrm *_ed .CT_Transform2D )(float64 ,float64 ,float64 ,float64 ){var _dgbf ,_fgef ,_bdbg ,_eabe float64 ;if _agdg :=xfrm .Off ;_agdg !=nil {_dgbf =_c .FromEMU (FromSTCoordinate (_agdg .XAttr ));_fgef =_c .FromEMU (FromSTCoordinate (_agdg .YAttr ));};if _bacf :=xfrm .Ext ;_bacf !=nil {_bdbg =_c .FromEMU (_bacf .CxAttr );_eabe =_c .FromEMU (_bacf .CyAttr );};return _dgbf ,_fgef ,_bdbg ,_eabe ;};var _dfff =fontsMap {_fcfe :&_fb .Mutex {},_dccf :map[string ]map[FontStyle ]*_da .PdfFont {}};func (_abcc *creatorContext )getPdfColorFromSolidFill (_bccb *_ed .CT_SolidColorFillProperties )_bd .Color {if _bccb ==nil {return nil ;};_gaed :="";if _fdde :=_bccb .SrgbClr ;_fdde !=nil {_gaed =_fdde .ValAttr ;}else if _acfc :=_bccb .SchemeClr ;_acfc !=nil {_gaed =_dcg (_acfc .ValAttr ,_abcc ._bace );};if _gaed ==""{return nil ;};return _bd .ColorRGBFromHex ("\u0023"+_gaed );};func (_ebb barSerByOrder )Swap (i ,j int ){_ebb [i ],_ebb [j ]=_ebb [j ],_ebb [i ]};func _dbc (_gac ,_cda ,_cef float64 )float64 {if _gac *6< 1{return _cef +(_cda -_cef )*6*_gac ;}else if _gac *2< 1{return _cda ;}else if _gac *3< 2{return _cef +(_cda -_cef )*(2.0/3.0-_gac )*6;}else {return _cef ;};};const DefaultFontSize =12.0;func FromSTPercentage (st *_ed .ST_Percentage )float64 {if _cccd :=st .ST_PercentageDecimal ;_cccd !=nil {return float64 (*_cccd )/100000;};return 0;};func DrawLine (c *_bd .Creator ,x0 ,y0 ,x1 ,y1 ,width float64 ,color _bd .Color ){if color ==nil {return ;};_cdg :=c .NewLine (x0 ,y0 ,x1 ,y1 );_cdg .SetLineWidth (width );_cdg .SetColor (color );c .Draw (_cdg );};func RegisterFont (name string ,style FontStyle ,font *_da .PdfFont ){_dfff ._fcfe .Lock ();if _dfff ._dccf [name ]==nil {_dfff ._dccf [name ]=map[FontStyle ]*_da .PdfFont {};};_dfff ._dccf [name ][style ]=font ;_dfff ._fcfe .Unlock ();};type ImgPart byte ;var _fbeb =_adgg (1.5);func (_bcae *creatorContext )drawBorderWithProps (_gdde *_ed .CT_ShapeProperties ,_cbcc *Rectangle ,_fbbd float64 ){if _cbcc !=nil &&_gdde !=nil &&_gdde .Ln !=nil &&_gdde .Ln .SolidFill !=nil {_gbag :=_bcae .getPdfColorFromSolidFill (_gdde .Ln .SolidFill );DrawRectangle (_bcae ._bff ,_cbcc ,_fbbd ,_gbag );};};func GetPageFromCreator (c *_bd .Creator )(*_da .PdfPage ,error ){_ffdc :=_g .NewBuffer ([]byte {});_ecf :=c .Write (_ffdc );if _ecf !=nil {return nil ,_ecf ;};_cbdd :=_g .NewReader (_ffdc .Bytes ());_aebe ,_ecf :=_da .NewPdfReader (_cbdd );if _ecf !=nil {return nil ,_ecf ;};return _aebe .GetPage (1);};func _ebbg (_agd ,_cgc ,_dbbc float64 )(uint8 ,uint8 ,uint8 ){var _eagfc float64 ;if _dbbc < 0.5{_eagfc =_dbbc *(1+_cgc );}else {_eagfc =_dbbc +_cgc -_dbbc *_cgc ;};_adagf :=_dbbc *2-_eagfc ;_agd /=360.0;_ffe :=_fffa (_agd +1.0/3.0);_gbf :=_fffa (_agd );_ddbbb :=_fffa (_agd -1.0/3.0);_dafc :=_dbc (_ffe ,_eagfc ,_adagf );_cfdf :=_dbc (_gbf ,_eagfc ,_adagf );_bfb :=_dbc (_ddbbb ,_eagfc ,_adagf );return uint8 (255*_dafc ),uint8 (255*_cfdf ),uint8 (255*_bfb );};type serCategory struct{_bc string ;_faa []serValue ;};var _cce =_adgg (1.5);var _af =_adgg (2);func AdjustColorByTint (colorStr string ,tint float64 )string {var _fbca ,_acg ,_aeef uint8 ;_bbf ,_ :=_gf .Sscanf (colorStr ,"\u0025\u0030\u0032x\u0025\u0030\u0032\u0078\u0025\u0030\u0032\u0078",&_fbca ,&_acg ,&_aeef );if _bbf !=3{return "";};return _dff (_fbca ,tint )+_dff (_acg ,tint )+_dff (_aeef ,tint );};var _eda =_adgg (7.5);func (_cfb barSerByOrder )Len ()int {return len (_cfb )};func _fffa (_dafa float64 )float64 {if _dafa < 0{_dafa +=float64 (-int (_dafa )+1);}else if _dafa > 1{_dafa -=float64 (int (_dafa ));};return _dafa ;};type legendItem struct{_bcb string ;_fcgg *_ed .CT_ShapeProperties ;};func RegisterFontsFromDirectory (dirName string )error {_ebf ,_eab :=_e .Open (dirName );if _eab !=nil {return _eab ;};defer _ebf .Close ();_ccf ,_eab :=_ebf .Readdirnames (0);if _eab !=nil {return _eab ;};for _ ,_dga :=range _ccf {if _fg .HasSuffix (_dga ,"\u002e\u0074\u0074\u0066"){_eede :=dirName +"\u002f"+_dga ;_aeec :=_ebc (_eede );if _aeec !=nil {_db .Log .Debug ("\u0075\u006ea\u0062\u006c\u0065\u0020\u0074o\u0020\u0070\u0072\u006f\u0063e\u0073\u0073\u0020\u0061\u006e\u0064\u0020\u0072\u0065\u0067\u0069\u0073\u0074\u0065\u0072\u0020\u0066\u006f\u006e\u0074\u0020\u0066\u0072\u006f\u006d\u0020\u0054\u0054\u0046\u0020\u0066\u0069\u006c\u0065\u0020\u0025\u0073",_aeec );continue ;};};};return nil ;};func MakeBlockFromCreator (c *_bd .Creator )(*_bd .Block ,error ){_aea ,_aefa :=GetPageFromCreator (c );if _aefa !=nil {return nil ,_aefa ;};_eebe ,_aefa :=_bd .NewBlockFromPage (_aea );if _aefa !=nil {return nil ,_aefa ;};return _eebe ,nil ;};type BorderPosition byte ;func (_afea FontStyle )String ()string {return []string {"\u0052e\u0067\u0075\u006c\u0061\u0072","\u0042\u006f\u006c\u0064","\u0049\u0074\u0061\u006c\u0069\u0063","\u0042\u006f\u006c\u0064\u0049\u0074\u0061\u006c\u0069\u0063"}[int (_afea )];};func GetImage (c *_bd .Creator ,goImg _d .Image ,imgHeight ,imgWidth ,left ,top ,dividerX ,dividerY float64 ,part ImgPart )(*_bd .Image ,error ){if goImg ==nil {return nil ,nil ;};_gfgc :=goImg .Bounds ().Size ();_dffd :=_gfgc .X ;_gfcf :=_gfgc .Y ;if dividerX !=0{dividerX =dividerX /imgWidth *float64 (_dffd );};if dividerY !=0{dividerY =dividerY /imgHeight *float64 (_gfcf );};var _caef _d .Rectangle ;switch part {case ImgPart_t :_caef =_d .Rect (0,0,_dffd ,int (dividerY ));case ImgPart_b :_caef =_d .Rect (0,int (dividerY ),_dffd ,_gfcf );case ImgPart_l :_caef =_d .Rect (0,0,int (dividerX ),_gfcf );case ImgPart_r :_caef =_d .Rect (int (dividerX ),0,_dffd ,_gfcf );case ImgPart_lt :_caef =_d .Rect (0,0,int (dividerX ),int (dividerY ));case ImgPart_rt :_caef =_d .Rect (int (dividerX ),0,_dffd ,int (dividerY ));case ImgPart_lb :_caef =_d .Rect (0,int (dividerY ),int (dividerX ),_gfcf );case ImgPart_rb :_caef =_d .Rect (int (dividerX ),int (dividerY ),_dffd ,_gfcf );default:_caef =_d .Rect (0,0,_dffd ,_gfcf );};_fgbg :=CropImageByRect (goImg ,_caef );_cbca ,_gbgf :=c .NewImageFromGoImage (_fgbg );if _gbgf !=nil {return nil ,_gbgf ;};_cbca .Scale (imgWidth /float64 (_dffd ),imgHeight /float64 (_gfcf ));_cbca .SetPos (left ,top );return _cbca ,nil ;};var _cff =_adgg (1.5);var StdFontsMap =map[string ][]string {"\u0048e\u006c\u0076\u0065\u0074\u0069\u0063a":[]string {"\u0048e\u006c\u0076\u0065\u0074\u0069\u0063a","\u0048\u0065\u006c\u0076\u0065\u0074\u0069\u0063\u0061-\u0042\u006f\u006c\u0064","\u0048\u0065\u006c\u0076\u0065\u0074\u0069\u0063\u0061\u002d\u004f\u0062l\u0069\u0071\u0075\u0065","H\u0065\u006c\u0076\u0065ti\u0063a\u002d\u0042\u006f\u006c\u0064O\u0062\u006c\u0069\u0071\u0075\u0065"},"\u0043o\u0075\u0072\u0069\u0065\u0072":[]string {"\u0043o\u0075\u0072\u0069\u0065\u0072","\u0043\u006f\u0075r\u0069\u0065\u0072\u002d\u0042\u006f\u006c\u0064","\u0043o\u0075r\u0069\u0065\u0072\u002d\u004f\u0062\u006c\u0069\u0071\u0075\u0065","\u0043\u006f\u0075\u0072ie\u0072\u002d\u0042\u006f\u006c\u0064\u004f\u0062\u006c\u0069\u0071\u0075\u0065"},"\u0054i\u006de\u0073\u0020\u004e\u0065\u0077\u0020\u0052\u006f\u006d\u0061\u006e":[]string {"T\u0069\u006d\u0065\u0073\u002d\u0052\u006f\u006d\u0061\u006e","\u0054\u0069\u006d\u0065\u0073\u002d\u0042\u006f\u006c\u0064","\u0054\u0069\u006de\u0073\u002d\u0049\u0074\u0061\u006c\u0069\u0063","\u0054\u0069m\u0065\u0073\u002dB\u006f\u006c\u0064\u0049\u0074\u0061\u006c\u0069\u0063"},"\u0064e\u0066\u0061\u0075\u006c\u0074":[]string {"\u0048e\u006c\u0076\u0065\u0074\u0069\u0063a","\u0048\u0065\u006c\u0076\u0065\u0074\u0069\u0063\u0061-\u0042\u006f\u006c\u0064","\u0048\u0065\u006c\u0076\u0065\u0074\u0069\u0063\u0061\u002d\u004f\u0062l\u0069\u0071\u0075\u0065","H\u0065\u006c\u0076\u0065ti\u0063a\u002d\u0042\u006f\u006c\u0064O\u0062\u006c\u0069\u0071\u0075\u0065"}};const (ImgPart_whole ImgPart =0;ImgPart_t ImgPart =1;ImgPart_b ImgPart =2;ImgPart_l ImgPart =3;ImgPart_r ImgPart =4;ImgPart_lt ImgPart =5;ImgPart_rt ImgPart =6;ImgPart_lb ImgPart =7;ImgPart_rb ImgPart =8;);func FromSTCoordinate (st _ed .ST_Coordinate )int64 {if _cebf :=st .ST_CoordinateUnqualified ;_cebf !=nil {return *_cebf ;};return 0;};var _fbc =_adgg (0.125);func _ebc (_ddfa string )error {if !_fg .HasSuffix (_ddfa ,"\u002e\u0074\u0074\u0066"){_db .Log .Debug ("\u0055\u006es\u0075\u0070\u0070\u006f\u0072\u0074\u0065\u0064\u0020\u0066\u006f\u006e\u0074\u0020\u0066\u0069\u006c\u0065\u0020\u0066\u006f\u0072ma\u0074\u002e");return _gf .Errorf ("\u0055\u006e\u0073\u0075\u0070\u0070o\u0072\u0074\u0065\u0064\u0020f\u006f\u006e\u0074\u0020\u0066\u0069l\u0065\u0020\u0066\u006f\u0072m\u0061\u0074\u002c\u0020\u0063\u0075\u0072\u0072\u0065\u006e\u0074\u006cy\u0020\u006f\u006e\u006c\u0079\u0020\u0073\u0075\u0070\u0070\u006f\u0072\u0074\u0020\u0054T\u0046\u0020\u0066\u006f\u006e\u0074\u0020\u0066i\u006c\u0065\u002e");};_caad ,_dfe :=_fbb .ParseFile (_ddfa );if _dfe !=nil {_db .Log .Debug ("\u0043a\u006e\u006e\u006f\u0074\u0020\u0070\u0061\u0072\u0073\u0065\u0020T\u0054\u0046\u0020\u0066\u0069\u006c\u0065\u0020\u0025\u0073",_dfe );return _dfe ;};_dabe ,_dfe :=_da .NewCompositePdfFontFromTTFFile (_ddfa );if _dfe !=nil {return _dfe ;};_fbde :=_caad .GetNameRecords ();for _ ,_bgdg :=range _fbde {_fcad :=_bgdg [1];if _fcad ==""{return _gf .Errorf ("\u004e\u006f\u0020\u0066\u006fn\u0074\u0020\u0066\u0061\u006d\u0069\u006c\u0079\u0020\u0069\u006e\u0066\u006fr\u006d\u0061\u0074\u0069\u006f\u006e\u0020\u0069\u006e\u0020\u0074\u0068\u0065\u0020\u0066\u0069\u006c\u0065\u0020\u0025\u0073",_ddfa );};_dbeb :=make ([]byte ,0);for _cead :=0;_cead < len (_fcad );_cead ++{if _fcad [_cead ]==39||_fcad [_cead ]==92{continue ;};_cgd :=4;if _cead +_cgd < len (_fcad ){if _fcad [_cead :_cead +_cgd ]=="\u0000"{_cead =_cead +_cgd +1;continue ;};};_dbeb =append (_dbeb ,_fcad [_cead ]);};_fcad =_fg .Replace (string (_dbeb ),"\u0078\u0030\u0030","",-1);_dbd :=_bgdg [2];if _dbd ==""{return _gf .Errorf ("N\u006f\u0020\u0073\u0074\u0079\u006ce\u0020\u0069\u006e\u0066\u006f\u0072m\u0061\u0074\u0069\u006f\u006e\u0020\u0069n\u0020\u0074\u0068\u0065\u0020\u0066\u0069\u006c\u0065\u0020%\u0073",_ddfa );};_dbeb =make ([]byte ,0);for _dfec :=0;_dfec < len (_dbd );_dfec ++{if _dbd [_dfec ]==39||_dbd [_dfec ]==92{continue ;};_ffdb :=4;if _dfec +_ffdb < len (_dbd ){if _dbd [_dfec :_dfec +_ffdb ]=="\u0000"{_dfec =_dfec +_ffdb +1;continue ;};};_dbeb =append (_dbeb ,_dbd [_dfec ]);};_dbd =_fg .Replace (string (_dbeb ),"\u0078\u0030\u0030","",-1);RegisterFont (_fcad ,_dfgd [_dbd ],_dabe );};return nil ;};