Class: OLEStorageLitePPSRoot
- Inherits:
-
OLEStorageLitePPS
- Object
- OLEStorageLite
- OLEStorageLitePPS
- OLEStorageLitePPSRoot
- Defined in:
- lib/writeexcel/storage_lite.rb
Overview
:nodoc:
Constant Summary
Constants inherited from OLEStorageLite
OLEStorageLite::DATA_SIZE_SMALL, OLEStorageLite::LONG_INT_SIZE, OLEStorageLite::PPS_SIZE, OLEStorageLite::PPS_TYPE_DIR, OLEStorageLite::PPS_TYPE_FILE, OLEStorageLite::PPS_TYPE_ROOT
Instance Attribute Summary
Attributes inherited from OLEStorageLitePPS
#child, #data, #dir_pps, #name, #next_pps, #no, #pps_file, #prev_pps, #size, #start_block, #time_1st, #time_2nd, #type
Attributes inherited from OLEStorageLite
Instance Method Summary collapse
- #_saveBbd(iSbdSize, iBsize, iPpsCnt, rh_info) ⇒ Object
- #_saveBigData(iStBlk, aList, rh_info) ⇒ Object
-
#initialize(raTime1st, raTime2nd, raChild) ⇒ OLEStorageLitePPSRoot
constructor
A new instance of OLEStorageLitePPSRoot.
- #save(sFile, bNoAs = nil, rh_info = nil) ⇒ Object
Methods inherited from OLEStorageLite
#asc2ucs, #getNthPps, #getPpsSearch, #getPpsTree, #localDate2OLE, #oleData2Local, #ucs2asc
Constructor Details
#initialize(raTime1st, raTime2nd, raChild) ⇒ OLEStorageLitePPSRoot
Returns a new instance of OLEStorageLitePPSRoot.
547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 |
# File 'lib/writeexcel/storage_lite.rb', line 547 def initialize(raTime1st, raTime2nd, raChild) super( nil, asc2ucs('Root Entry'), PPS_TYPE_ROOT, nil, nil, nil, raTime1st, raTime2nd, nil, nil, nil, raChild) end |
Instance Method Details
#_saveBbd(iSbdSize, iBsize, iPpsCnt, rh_info) ⇒ Object
850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 |
# File 'lib/writeexcel/storage_lite.rb', line 850 def _saveBbd(iSbdSize, iBsize, iPpsCnt, rh_info) file = rh_info[:fileh] #0. Calculate Basic Setting iBbCnt = rh_info[:big_block_size] / LONG_INT_SIZE iBlCnt = iBbCnt - 1 i1stBdL = (rh_info[:big_block_size] - 0x4C) / LONG_INT_SIZE i1stBdMax = i1stBdL * iBbCnt - i1stBdL iBdExL = 0 iAll = iBsize + iPpsCnt + iSbdSize iAllW = iAll iBdCntW = iAllW / iBbCnt iBdCntW += 1 if iAllW % iBbCnt > 0 iBdCnt = 0 #0.1 Calculate BD count iBBleftover = iAll - i1stBdMax if iAll >i1stBdMax iBdCnt, iBdExL, iBBleftover = calc_idbcnt_idbexl_ibbleftover(iBBleftover, iBlCnt, iBdCnt, iBdExL) end iAllW += iBdExL iBdCnt += i1stBdL #print "iBdCnt = iBdCnt \n" #1. Making BD #1.1 Set for SBD if iSbdSize > 0 0.upto(iSbdSize-1-1) do |i| file.write([i + 1].pack('V')) end file.write([-2].pack('V')) end #1.2 Set for B 0.upto(iBsize-1-1) do |i| file.write([i + iSbdSize + 1].pack('V')) end file.write([-2].pack('V')) #1.3 Set for PPS 0.upto(iPpsCnt-1-1) do |i| file.write([i+iSbdSize+iBsize+1].pack("V")) end file.write([-2].pack('V')) #1.4 Set for BBD itself ( 0xFFFFFFFD : BBD) 0.upto(iBdCnt-1) do |i| file.write([0xFFFFFFFD].pack("V")) end #1.5 Set for ExtraBDList 0.upto(iBdExL-1) do |i| file.write([0xFFFFFFFC].pack("V")) end #1.6 Adjust for Block if (iAllW + iBdCnt) % iBbCnt > 0 file.write([-1].pack('V') * (iBbCnt - ((iAllW + iBdCnt) % iBbCnt))) end #2.Extra BDList if iBdCnt > i1stBdL iN = 0 iNb = 0 i1stBdL.upto(iBdCnt-1) do |i| if iN >= iBbCnt-1 iN = 0 iNb += 1 file.write([iAll+iBdCnt+iNb].pack("V")) end file.write([iBsize+iSbdSize+iPpsCnt+i].pack("V")) iN += 1 end if (iBdCnt-i1stBdL) % (iBbCnt-1) > 0 file.write([-1].pack("V") * ((iBbCnt-1) - ((iBdCnt-i1stBdL) % (iBbCnt-1)))) end file.write([-2].pack('V')) end end |
#_saveBigData(iStBlk, aList, rh_info) ⇒ Object
726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 |
# File 'lib/writeexcel/storage_lite.rb', line 726 def _saveBigData(iStBlk, aList, rh_info) file = rh_info[:fileh] #1.Write Big (ge 0x1000) Data into Block aList.each do |pps| if pps.type != PPS_TYPE_DIR #print "PPS: pps DEF:", defined(pps->{Data}), "\n" pps.size = pps._datalen #Mod if (pps.size >= rh_info[:small_size]) || ((pps.type == PPS_TYPE_ROOT) && !pps.data.nil?) #1.1 Write Data #Check for update if pps.pps_file iLen = 0 pps.pps_file.seek(0, 0) #To The Top while sBuff = pps.pps_file.read(4096) iLen += sBuff.bytesize file.write(sBuff) #Check for update end else file.write(pps.data) end if pps.size % rh_info[:big_block_size] > 0 file.write( "\x00" * (rh_info[:big_block_size] - (pps.size % rh_info[:big_block_size])) ) end #1.2 Set For PPS pps.start_block = iStBlk iStBlk += pps.size / rh_info[:big_block_size] iStBlk += 1 if pps.size % rh_info[:big_block_size] > 0 end end end end |
#save(sFile, bNoAs = nil, rh_info = nil) ⇒ Object
563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 |
# File 'lib/writeexcel/storage_lite.rb', line 563 def save(sFile, bNoAs = nil, rh_info = nil) #0.Initial Setting for saving rh_info = Hash.new unless rh_info if rh_info[:big_block_size] rh_info[:big_block_size] = 2 ** adjust2(rh_info[:big_block_size]) else rh_info[:big_block_size] = 2 ** 9 end if rh_info[:small_block_size] rh_info[:small_block_size] = 2 ** adjust2(rh_info[:small_block_size]) else rh_info[:small_block_size] = 2 ** 6 end rh_info[:small_size] = 0x1000 rh_info[:pps_size] = 0x80 close_file = true #1.Open File #1.1 sFile is Ref of scalar if sFile.respond_to?(:to_str) rh_info[:fileh] = open(sFile, "wb") else rh_info[:fileh] = sFile.binmode end #1. Make an array of PPS (for Save) aList=[] if bNoAs _savePpsSetPnt2([self], aList, rh_info) else _savePpsSetPnt([self], aList, rh_info) end iSBDcnt, iBBcnt, iPPScnt = _calcSize(aList, rh_info) #2.Save Header _saveHeader(rh_info, iSBDcnt, iBBcnt, iPPScnt) #3.Make Small Data string (write SBD) # Small Datas become RootEntry Data @data = _makeSmallData(aList, rh_info) #4. Write BB iBBlk = iSBDcnt _saveBigData(iBBlk, aList, rh_info) #5. Write PPS _savePps(aList, rh_info) #6. Write BD and BDList and Adding Header informations _saveBbd(iSBDcnt, iBBcnt, iPPScnt, rh_info) #7.Close File rh_info[:fileh].close if close_file end |