2022-04-09 14:27:46 +00:00
|
|
|
package convertutils ;import (_ga "bytes";_gab "errors";_de "fmt";_c "github.com/unidoc/unioffice/common/logger";_b "github.com/unidoc/unioffice/measurement";_gac "github.com/unidoc/unioffice/schema/soo/dml";_db "github.com/unidoc/unioffice/schema/soo/dml/chart";_ad "github.com/unidoc/unioffice/spreadsheet/format";_bg "github.com/unidoc/unipdf/v3/creator";_ea "github.com/unidoc/unipdf/v3/model";_df "github.com/unidoc/unipdf/v3/render";_fe "github.com/unidoc/unitype";_ge "image";_f "math";_dce "os";_af "sort";_e "strconv";_dc "strings";_a "sync";_d "unicode";);func GetPageFromCreator (c *_bg .Creator )(*_ea .PdfPage ,error ){_cabf :=_ga .NewBuffer ([]byte {});_cbea :=c .Write (_cabf );if _cbea !=nil {return nil ,_cbea ;};_eaeb :=_ga .NewReader (_cabf .Bytes ());_dagb ,_cbea :=_ea .NewPdfReader (_eaeb );if _cbea !=nil {return nil ,_cbea ;};return _dagb .GetPage (1);};func _egg (_defa ,_befc ,_agae uint8 )(float64 ,float64 ,float64 ){_dega ,_ddg ,_aec :=float64 (_defa )/255,float64 (_befc )/255,float64 (_agae )/255;_gdbb :=_dega ;if _ddg < _gdbb {_gdbb =_ddg ;};if _aec < _gdbb {_gdbb =_aec ;};var _ffa ,_fed bool ;_fggbb :=_dega ;if _ddg > _fggbb {_fggbb =_ddg ;_ffa =true ;};if _aec > _fggbb {_fggbb =_aec ;_ffa =false ;_fed =true ;};_efe :=(_gdbb +_fggbb )/2;var _dbd float64 ;if _gdbb !=_fggbb {if _efe <=0.5{_dbd =(_fggbb -_gdbb )/(_fggbb +_gdbb );}else {_dbd =(_fggbb -_gdbb )/(2.0-_fggbb -_gdbb );};};var _ddd float64 ;if _gdbb !=_fggbb {if _ffa {_ddd =2.0+(_aec -_dega )/(_fggbb -_gdbb );}else if _fed {_ddd =4.0+(_dega -_ddg )/(_fggbb -_gdbb );}else {_ddd =(_ddg -_aec )/(_fggbb -_gdbb );};_ddd *=60;if _ddd < 0{_ddd +=360;};};return _ddd ,_dbd ,_efe ;};type Rectangle struct{Top float64 ;Bottom float64 ;Left float64 ;Right float64 ;};func (_cecd 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 (_cecd )];};const _gdc =6.0;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 FromSTPercentage (st *_gac .ST_Percentage )float64 {if _fad :=st .ST_PercentageDecimal ;_fad !=nil {return float64 (*_fad )/100000;};return 0;};func AdjustColor (colorStr string ,EG_ColorTransform []*_gac .EG_ColorTransform )string {for _ ,_eagf :=range EG_ColorTransform {if _fbc :=_eagf .Tint ;_fbc !=nil {if _dgdc :=_fbc .ValAttr .ST_PositiveFixedPercentageDecimal ;_dgdc !=nil {colorStr =AdjustColorByTint (colorStr ,float64 (*_dgdc )/100000);};};if _fba :=_eagf .Shade ;_fba !=nil {if _aceg :=_fba .ValAttr .ST_PositiveFixedPercentageDecimal ;_aceg !=nil {colorStr =AdjustColorByShade (colorStr ,float64 (*_aceg )/100000);};};if _fgac :=_eagf .LumMod ;_fgac !=nil {if _bag :=_fgac .ValAttr .ST_PercentageDecimal ;_bag !=nil {colorStr =AdjustColorByLumMod (colorStr ,float64 (*_bag )/100000);};};};return colorStr ;};type serCategory struct{_adc string ;_aea []serValue ;};func _caab (_cce *_db .CT_SerAx )(uint32 ,_db .ST_AxPos ,_db .ST_TickMark ,_db .ST_TickLblPos ,*_db .CT_ChartLines ,uint32 ,*_gac .CT_ShapeProperties ,error ){var _gcb ,_defd uint32 ;var _cdg _db .ST_AxPos ;var _geg _db .ST_TickMark ;var _edc *_db .CT_ChartLines ;var _deea _db .ST_TickLblPos ;if _cce .AxId ==nil {return _gcb ,_cdg ,_geg ,_deea ,_edc ,_defd ,_cce .SpPr ,_gab .New ("\u004e\u006f\u0020x\u0020\u0061\u0078\u0069\u0073\u0020\u0049\u0044");}else {_gcb =_cce .AxId .ValAttr ;};if _cce .AxPos ==nil {return _gcb ,_cdg ,_geg ,_deea ,_edc ,_defd ,_cce .SpPr ,_gab .New ("\u004eo\u0020x\u0020\u0061\u0078\u0069\u0073 \u0070\u006fs\u0069\u0074\u0069\u006f\u006e");}else {_cdg =_cce .AxPos .ValAttr ;};if _cce .MajorTickMark !=nil {_geg =_cce .MajorTickMark .ValAttr ;};if _cce .TickLblPos !=nil {_deea =_cce .TickLblPos .ValAttr ;};if _cce .CrossAx ==nil {return _gcb ,_cdg ,_geg ,_deea ,_edc ,_defd ,_cce .SpPr ,_gab .New ("\u004e\u006f \u0063\u0072\u006fs\u0073\u0020\u0061\u0078\
|