2022-02-25 19:20:45 +00:00
|
|
|
package convertutils ;import (_bd "bytes";_ba "errors";_f "fmt";_beb "github.com/unidoc/unioffice/common/logger";_fb "github.com/unidoc/unioffice/measurement";_ec "github.com/unidoc/unioffice/schema/soo/dml";_fcg "github.com/unidoc/unioffice/schema/soo/dml/chart";_ff "github.com/unidoc/unioffice/spreadsheet/format";_g "github.com/unidoc/unipdf/v3/creator";_e "github.com/unidoc/unipdf/v3/model";_aa "github.com/unidoc/unipdf/v3/render";_af "github.com/unidoc/unitype";_d "image";_be "math";_a "os";_bge "sort";_fc "strconv";_bga "strings";_bg "sync";_c "unicode";);type ImgPart byte ;func _bgde (_bfc ,_cedb ,_gdf float64 )(uint8 ,uint8 ,uint8 ){var _cgg float64 ;if _gdf < 0.5{_cgg =_gdf *(1+_cedb );}else {_cgg =_gdf +_cedb -_gdf *_cedb ;};_fffea :=_gdf *2-_cgg ;_bfc /=360.0;_bcf :=_bbd (_bfc +1.0/3.0);_aefg :=_bbd (_bfc );_eddc :=_bbd (_bfc -1.0/3.0);_badg :=_dbf (_bcf ,_cgg ,_fffea );_eabd :=_dbf (_aefg ,_cgg ,_fffea );_bbb :=_dbf (_eddc ,_cgg ,_fffea );return uint8 (255*_badg ),uint8 (255*_eabd ),uint8 (255*_bbb );};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;);type legendItem struct{_bce string ;_fee *_ec .CT_ShapeProperties ;};const DefaultFontSize =12.0;func FromSTCoordinate32 (st _ec .ST_Coordinate32 )int64 {if _bag :=st .ST_Coordinate32Unqualified ;_bag !=nil {return int64 (*_bag );};return 0;};func _gceb (_fggc uint8 ,_bcge float64 )string {_ffa :=float64 (_fggc );return _f .Sprintf ("\u0025\u0030\u0032\u0078",int (_ffa *_bcge ));};func MakeImageFromChartSpace (cs *_fcg .ChartSpace ,width ,height float64 ,theme *_ec .Theme )(_d .Image ,error ){_afg ,_fde :=_aed (cs ,width ,height ,theme ,true );if _fde !=nil {return nil ,_fde ;};_edb ,_fde :=GetPageFromCreator (_afg );if _fde !=nil {return nil ,_fde ;};return _aa .NewImageDevice ().Render (_edb );};type serCategory struct{_gbc string ;_eff []serValue ;};var _egb =_adad (5);func _gcea (_bcb *_fcg .CT_SerAx )(uint32 ,_fcg .ST_AxPos ,_fcg .ST_TickMark ,_fcg .ST_TickLblPos ,*_fcg .CT_ChartLines ,uint32 ,*_ec .CT_ShapeProperties ,error ){var _eded ,_deed uint32 ;var _cbc _fcg .ST_AxPos ;var _bfb _fcg .ST_TickMark ;var _badb *_fcg .CT_ChartLines ;var _cfe _fcg .ST_TickLblPos ;if _bcb .AxId ==nil {return _eded ,_cbc ,_bfb ,_cfe ,_badb ,_deed ,_bcb .SpPr ,_ba .New ("\u004e\u006f\u0020x\u0020\u0061\u0078\u0069\u0073\u0020\u0049\u0044");}else {_eded =_bcb .AxId .ValAttr ;};if _bcb .AxPos ==nil {return _eded ,_cbc ,_bfb ,_cfe ,_badb ,_deed ,_bcb .SpPr ,_ba .New ("\u004eo\u0020x\u0020\u0061\u0078\u0069\u0073 \u0070\u006fs\u0069\u0074\u0069\u006f\u006e");}else {_cbc =_bcb .AxPos .ValAttr ;};if _bcb .MajorTickMark !=nil {_bfb =_bcb .MajorTickMark .ValAttr ;};if _bcb .TickLblPos !=nil {_cfe =_bcb .TickLblPos .ValAttr ;};if _bcb .CrossAx ==nil {return _eded ,_cbc ,_bfb ,_cfe ,_badb ,_deed ,_bcb .SpPr ,_ba .New ("\u004e\u006f \u0063\u0072\u006fs\u0073\u0020\u0061\u0078\u0069\u0073\u0020\u0049\u0044");}else {_deed =_bcb .CrossAx .ValAttr ;};_badb =_bcb .MajorGridlines ;return _eded ,_cbc ,_bfb ,_cfe ,_badb ,_deed ,_bcb .SpPr ,nil ;};func (_bcd *creatorContext )drawRectangleWithProps (_adcg *_ec .CT_ShapeProperties ,_efb ,_bgad ,_aff ,_egee float64 ,_bcaba bool ){_cgdb :=_bcd ._cebdb .NewRectangle (_efb ,_bgad ,_aff ,_egee );if _adcg ==nil {if _bcaba {_cgdb .SetBorderWidth (_eafd );}else {return ;};}else {_fcbg :=_bcd .getPdfColorFromSolidFill (_adcg .SolidFill );if _fcbg !=nil {_cgdb .SetFillColor (_fcbg );};if _ged :=_adcg .Ln ;_ged !=nil {if _cbb :=_ged .WAttr ;_cbb !=nil {_fcgf :=_fb .FromEMU (int64 (*_cbb ));_cgdb .SetBorderWidth (_fcgf );if _eafda :=_ged .SolidFill ;_eafda !=nil {_egd :=_bcd .getPdfColorFromSolidFill (_eafda );if _egd !=nil {_cgdb .SetBorderColor (_egd );};};}else {_cgdb .SetBorderWidth (0);};};};_bcd ._cebdb .Draw (_cgdb );};const (BorderPositionTop BorderPosition =0;BorderPositionLeft BorderPosition =1;BorderPositionBottom BorderPosition =2;BorderPositionRight BorderPosition =3;);func AdjustColorByTint (
|