2022-12-06 11:56:49 +00:00
|
|
|
package mscfb ;import (_e "bytes";_f "encoding/binary";_bf "fmt";_fb "github.com/richardlehane/msoleps/types";_c "github.com/unidoc/unioffice/internal/mscfb/rw";_gb "io";_ge "os";_g "strconv";_bc "time";_gd "unicode";_bb "unicode/utf16";);func (_dcg *Reader )Export ()([]byte ,error ){_baaed :=_c .NewWriter ();if _fgda :=_dcg .exportHeader (_baaed );_fgda !=nil {return nil ,_fgda ;};if _ffed :=_baaed .FillWithByte (512,_fbb );_ffed !=nil {return nil ,_ffed ;};_ccff :=[]uint32 {};if _ebed :=_dcg .exportDifats (_baaed );_ebed !=nil {return nil ,_ebed ;};_fbbf ,_aeg ,_efab :=_dcg .exportMiniStream ();if _efab !=nil {return nil ,_efab ;};_ccff =append (_ccff ,uint32 (_baaed .Len ())/_dcg ._agea );if _cdd :=_dcg .exportDirEntries (_baaed );_cdd !=nil {return nil ,_cdd ;};_ccff =append (_ccff ,uint32 (_baaed .Len ())/_dcg ._agea );if _ ,_bbb :=_fbbf .WriteTo (_baaed );_bbb !=nil {return nil ,_bbb ;};_ccff =append (_ccff ,uint32 (_baaed .Len ())/_dcg ._agea );if _ ,_abce :=_aeg .WriteTo (_baaed );_abce !=nil {return nil ,_abce ;};_ccff =append (_ccff ,uint32 (_baaed .Len ())/_dcg ._agea );if _bbae :=_dcg .exportFAT (_baaed ,_ccff );_bbae !=nil {return nil ,_bbae ;};return _baaed .Bytes (),nil ;};func _ggb (_da *File ){if _da ._bfe < 4||_da ._bfe > 64{return ;};_ea :=int (_da ._bfe /2-1);_da .Initial =_da ._ga [0];var _fca int ;if !_gd .IsPrint (rune (_da .Initial )){_fca =1;};_da .Name =string (_bb .Decode (_da ._ga [_fca :_ea ]));};func (_bbce *File )Read (b []byte )(int ,error ){if _bbce .Size < 1||_bbce ._ad >=_bbce .Size {return 0,_gb .EOF ;};_gbd :=len (b );if int64 (_gbd )> _bbce .Size -_bbce ._ad {_gbd =int (_bbce .Size -_bbce ._ad );};_cdf ,_cfg :=_bbce .stream (_gbd );if _cfg !=nil {return 0,_cfg ;};var _ac ,_ceb int ;for _ ,_gc :=range _cdf {_ege :=_ac +int (_gc [1]);if _ege < _ac ||_ege > _gbd {return 0,Error {ErrRead ,"\u0062a\u0064 \u0072\u0065\u0061\u0064\u0020\u006c\u0065\u006e\u0067\u0074\u0068",int64 (_ege )};};_eaf ,_acf :=_bbce ._bdg ._acbe .ReadAt (b [_ac :_ege ],_gc [0]);_ceb =_ceb +_eaf ;if _acf !=nil {_bbce ._ad +=int64 (_ceb );return _ceb ,Error {ErrRead ,"\u0075n\u0064\u0065\u0072\u006c\u0079\u0069\u006e\u0067\u0020\u0072\u0065a\u0064\u0065\u0072\u0020\u0066\u0061\u0069\u006c\u0020\u0028"+_acf .Error ()+"\u0029",int64 (_ac )};};_ac =_ege ;};_bbce ._ad +=int64 (_ceb );if _ceb !=_gbd {_cfg =Error {ErrRead ,"\u0062\u0079\u0074e\u0073\u0020\u0072\u0065\u0061\u0064\u0020\u0064\u006f\u0020\u006e\u006f\u0074\u0020\u006d\u0061\u0074\u0063\u0068\u0020\u0065\u0078\u0070\u0065\u0063\u0074\u0065\u0064\u0020r\u0065\u0061\u0064\u0020\u0073\u0069\u007a\u0065",int64 (_ceb )};}else if _ceb < len (b ){_cfg =_gb .EOF ;};return _ceb ,_cfg ;};func (_beb *Reader )setMiniStream ()error {if _beb ._bebd [0]._bbc ==_cfd ||_beb ._aacbb ._bdb ==_cfd ||_beb ._aacbb ._afd ==0{return nil ;};_fdd :=int (_beb ._aacbb ._afd );_beb ._aacbb ._dfd =make ([]uint32 ,_fdd );_beb ._aacbb ._dfd [0]=_beb ._aacbb ._bdb ;for _afb :=1;_afb < _fdd ;_afb ++{_egf ,_babg :=_beb .findNext (_beb ._aacbb ._dfd [_afb -1],false );if _babg !=nil {return Error {ErrFormat ,"s\u0065\u0074\u0074\u0069ng\u0020m\u0069\u006e\u0069\u0020\u0073t\u0072\u0065\u0061\u006d\u0020\u0028"+_babg .Error ()+"\u0029",int64 (_beb ._aacbb ._dfd [_afb -1])};};_beb ._aacbb ._dfd [_afb ]=_egf ;};_fdd =int (_beb ._agea /4*_beb ._aacbb ._afd );_beb ._aacbb ._daab =make ([]uint32 ,0,_fdd );_ggg :=_beb ._bebd [0]._bbc ;var _fag error ;for _ggg !=_cfd {_beb ._aacbb ._daab =append (_beb ._aacbb ._daab ,_ggg );_ggg ,_fag =_beb .findNext (_ggg ,false );if _fag !=nil {return Error {ErrFormat ,"s\u0065\u0074\u0074\u0069ng\u0020m\u0069\u006e\u0069\u0020\u0073t\u0072\u0065\u0061\u006d\u0020\u0028"+_fag .Error ()+"\u0029",int64 (_ggg )};};};return nil ;};func (_ebac fileInfo )Sys ()interface{}{return nil };func (_ffee *Reader )Next ()(*File ,error ){_ffee ._gbe ++;if _ffee ._gbe >=len (_ffee .File ){return nil ,_gb .EOF ;};return _ffee .File [_ffee ._gbe ],nil ;};const (_ged uint8 =0x0;_a uint8 =0x1;_fa uint8 =0x2;_d uint8 =0x5;);func (_bfc *File )seek (_gag int64 )error {var _bcd bool ;var _efc
|