亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? compoundfile.java3

?? java開發文檔之excel:jexcelapi_2_6_3.tar
?? JAVA3
?? 第 1 頁 / 共 2 頁
字號:
/*********************************************************************
*
*      Copyright (C) 2002 Andrew Khan
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
***************************************************************************/

package jxl.write.biff;

import java.io.OutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.HashMap;

import common.Assert;
import common.Logger;
import jxl.biff.BaseCompoundFile;
import jxl.biff.IntegerHelper;
import jxl.read.biff.BiffException;

/**
 * Writes out a compound file
 * 
 * Header block is -1
 * Excel data is e..n (where is the head extension blocks, normally 0 and
 * n is at least 8)
 * Summary information (8 blocks)
 * Document summary (8 blocks)
 * BBD is block p..q (where p=e+n+16 and q-p+1 is the number of BBD blocks)
 * Property storage block is q+b...r (normally 1 block) (where b is the number
 * of BBD blocks)
 */
final class CompoundFile extends BaseCompoundFile
{
  /**
   * The logger
   */
  private static Logger logger = Logger.getLogger(CompoundFile.class);

  /**
   * The stream to which the jumbled up data is written to
   */
  private OutputStream out;
  /**
   * The organized biff records which form the actual excel data
   */
  private byte[] excelData;

  /**
   * The size of the array
   */
  private int    size;

  /**
   * The size the excel data should be in order to comply with the
   * general compound file format
   */
  private int    requiredSize;

  /**
   * The number of blocks it takes to store the big block depot
   */
  private int numBigBlockDepotBlocks;

  /**
   * The number of blocks it takes to store the small block depot chain
   */
  private int numSmallBlockDepotChainBlocks;

  /**
   * The number of blocks it takes to store the small block depot
   */
  private int numSmallBlockDepotBlocks;

  /**
   * The number of extension blocks required for the header to describe
   * the BBD
   */
  private int numExtensionBlocks;

  /**
   * The extension block for the header
   */
  private int extensionBlock;

  /**
   * The number of blocks it takes to store the excel data
   */
  private int excelDataBlocks;

  /**
   * The start block of the root entry
   */
  private int rootStartBlock;

  /**
   * The start block of the excel data
   */
  private int excelDataStartBlock;

  /**
   * The start block of the big block depot
   */
  private int bbdStartBlock;

  /**
   * The number of big blocks required for additional property sets
   */
  private int additionalPropertyBlocks;

  /**
   * The total number of property sets in this compound file
   */
  private int numPropertySets;

  /**
   * The number of blocks required to store the root entry property sets
   * and small block depot
   */
  private int numRootEntryBlocks;

  /**
   * The list of additional, non standard property sets names
   */
  private ArrayList additionalPropertySets;

  /**
   * A hash map of the original property sets keyed on name
   */
  private HashMap readPropertySets;

  /**
   * The array of standard property set mappings
   */
  private int[] standardPropertySetMappings;

  private ReadPropertyStorage rootEntryPropertySet;

  /**
   * Structure used to store the property set and the data
   */
  private static final class ReadPropertyStorage
  {
    PropertyStorage propertyStorage;
    byte[] data;
    int number;

    ReadPropertyStorage(PropertyStorage ps, byte[] d, int n)
    {
      propertyStorage = ps;
      data = d;
      number = n;
    }
  }


  // The following member variables are used across methods when
  // writing out the big block depot
  /**
   * The current position within the bbd.  Used when writing out the
   * BBD
   */
  private int bbdPos;

  /**
   * The current bbd block
   */
  private byte[] bigBlockDepot;


  /**
   * Constructor
   * 
   * @param l the length of the data
   * @param os the output stream to write to
   * @param data the excel data
   * @param rcf the read compound
   */
  public CompoundFile(byte[] data, int l, OutputStream os, 
                      jxl.read.biff.CompoundFile rcf) 
    throws CopyAdditionalPropertySetsException, IOException
  {
    super();
    size = l;
    excelData = data;

    readAdditionalPropertySets(rcf);

    numRootEntryBlocks = 1;
    numPropertySets = 4 + 
      (additionalPropertySets != null ? additionalPropertySets.size() : 0);

    if (additionalPropertySets != null)
    {
      try
      {
        rootEntryPropertySet = new ReadPropertyStorage(rcf.getPropertySet(ROOT_ENTRY_NAME), rcf.getStream(ROOT_ENTRY_NAME), 0);
        int blocks = rootEntryPropertySet.data.length >= SMALL_BLOCK_THRESHOLD ?
          getBigBlocksRequired(rootEntryPropertySet.data.length) :
          SMALL_BLOCK_THRESHOLD / BIG_BLOCK_SIZE;
        additionalPropertyBlocks += blocks;
      }
      catch(BiffException e)
      {
        e.printStackTrace();
      }

      numRootEntryBlocks += getBigBlocksRequired
        (additionalPropertySets.size() * PROPERTY_STORAGE_BLOCK_SIZE);
    }

    logger.debug("root entry requires " + numRootEntryBlocks + " blocks");

    int blocks  = getBigBlocksRequired(l);

    // First pad the data out so that it fits nicely into a whole number
    // of blocks
    if (l < SMALL_BLOCK_THRESHOLD)
    {
      requiredSize = SMALL_BLOCK_THRESHOLD;
    }
    else
    {
      requiredSize = blocks * BIG_BLOCK_SIZE;
    }
    
    out = os;

    //    logger.debug("smallBlockDepot requires  " + numSmallBlockDepotBlocks + " big blocks");

    // Do the calculations
    excelDataBlocks = requiredSize/BIG_BLOCK_SIZE;
    numBigBlockDepotBlocks = 1;

    int blockChainLength = (BIG_BLOCK_SIZE - BIG_BLOCK_DEPOT_BLOCKS_POS)/4;

    int startTotalBlocks = excelDataBlocks + 
      8 + // summary block
      8 + // document information
      additionalPropertyBlocks +
      numRootEntryBlocks;

    int totalBlocks = startTotalBlocks + numBigBlockDepotBlocks;

    // Calculate the number of BBD blocks needed to hold this info
    numBigBlockDepotBlocks = (int) Math.ceil( (double) totalBlocks / 
                                              (double) (BIG_BLOCK_SIZE/4));

    // Does this affect the total?
    totalBlocks = startTotalBlocks + numBigBlockDepotBlocks;

    // And recalculate
    numBigBlockDepotBlocks = (int) Math.ceil( (double) totalBlocks / 
                                              (double) (BIG_BLOCK_SIZE/4));

    // Does this affect the total?
    totalBlocks = startTotalBlocks + numBigBlockDepotBlocks;

    // See if the excel bbd chain can fit into the header block.
    // Remember to allow for the  end of chain indicator
    if (numBigBlockDepotBlocks > blockChainLength - 1 )
    {
      // Sod it - we need an extension block.  We have to go through
      // the whole tiresome calculation again
      extensionBlock = 0;

      // Compute the number of extension blocks
      int bbdBlocksLeft = numBigBlockDepotBlocks - blockChainLength + 1;

      numExtensionBlocks = (int) Math.ceil((double) bbdBlocksLeft /
                                           (double) (BIG_BLOCK_SIZE/4 - 1));

      // Modify the total number of blocks required and recalculate the
      // the number of bbd blocks
      totalBlocks = startTotalBlocks + 
                    numExtensionBlocks + 
                    numBigBlockDepotBlocks;
      numBigBlockDepotBlocks = (int) Math.ceil( (double) totalBlocks / 
                                                (double) (BIG_BLOCK_SIZE/4));

      // The final total
      totalBlocks = startTotalBlocks + 
                    numExtensionBlocks + 
                    numBigBlockDepotBlocks;
    }
    else
    {
      extensionBlock = -2;
      numExtensionBlocks = 0;
    }

    // Set the excel data start block to be after the header (and
    // its extensions)
    excelDataStartBlock = numExtensionBlocks;

    logger.debug("excelDataStartBlock " + excelDataStartBlock);

    // Set the bbd start block to be after all the excel data
    bbdStartBlock = excelDataStartBlock +
                      excelDataBlocks + 
                      additionalPropertyBlocks +
                      16;
      
    logger.debug("bbdStartBlock " + bbdStartBlock);
      
    // Set the root start block to be after all the big block depot blocks
    rootStartBlock = bbdStartBlock +
                     numBigBlockDepotBlocks;


    if (totalBlocks != rootStartBlock + numRootEntryBlocks)
    {
      logger.warn("Root start block and total blocks are inconsistent " + 
                  " generated file may be corrupt");
      logger.warn("RootStartBlock " + rootStartBlock + " totalBlocks " + totalBlocks);
    }
  }

  /**
   * Reads the additional property sets from the read in compound file
   *
   * @return the number of blocks needed to store these property sets
   */
  private void readAdditionalPropertySets
    (jxl.read.biff.CompoundFile readCompoundFile) 
    throws CopyAdditionalPropertySetsException, IOException
  {
    if (readCompoundFile == null)
    {
      return;
    }

    additionalPropertySets = new ArrayList();
    readPropertySets = new HashMap();

    String[] psnames = readCompoundFile.getPropertySetNames();
    int blocksRequired = 0;
    standardPropertySetMappings = new int[STANDARD_PROPERTY_SETS.length];

    for (int i = 0 ; i < psnames.length ; i++)
    {
      // Add it to the hash map for later
      PropertyStorage ps = readCompoundFile.getPropertySet(psnames[i]);

      // If the name is non standard, then retrieve the property set 
      // information
      boolean standard = false;
      for (int j = 0 ; j < STANDARD_PROPERTY_SETS.length && !standard ; j++)
      {
        if (psnames[i].equalsIgnoreCase(STANDARD_PROPERTY_SETS[j]))
        {
          standard = true;
          ReadPropertyStorage rps = new ReadPropertyStorage(ps, null, i);
          readPropertySets.put(psnames[i], rps);
        }
      }

      if (!standard)
      {
        try
        {
          byte[] data = null;
          if (ps.size > 0 )
          {
            data = readCompoundFile.getStream(ps.name);
          }
          else
          {
            data = new byte[0];
          }
          ReadPropertyStorage rps = new ReadPropertyStorage(ps, data, i);
          readPropertySets.put(psnames[i], rps);
          additionalPropertySets.add(rps);

          int blocks = data.length >= SMALL_BLOCK_THRESHOLD ?
            getBigBlocksRequired(data.length) :
            SMALL_BLOCK_THRESHOLD / BIG_BLOCK_SIZE;
          blocksRequired += blocks;
        }
        catch (BiffException e)
        {
          logger.error(e);
          throw new CopyAdditionalPropertySetsException();
        }
      }
    }

    additionalPropertyBlocks = blocksRequired;
  }


  /**
   * Writes out the excel file in OLE compound file format
   * 
   * @exception IOException 
   */
  public void write() throws IOException
  {
    writeHeader();
    writeExcelData();
    writeDocumentSummaryData();
    writeSummaryData();
    writeAdditionalPropertySets();
    writeBigBlockDepot();
    writePropertySets();
    
    // Don't flush or close the stream - this is handled by the enclosing File
    // object
  }

  /**
   * Writes out any additional property sets
   */
  private void writeAdditionalPropertySets() throws IOException
  {
    if (additionalPropertySets == null)
    {
      return;
    }

    
    logger.debug("Writing property set " + rootEntryPropertySet.propertyStorage.name);
    int numBlocks2 = rootEntryPropertySet.data.length >= SMALL_BLOCK_THRESHOLD ?
      getBigBlocksRequired(rootEntryPropertySet.data.length) : 
      SMALL_BLOCK_THRESHOLD / BIG_BLOCK_SIZE;
    int requiredSize2 = numBlocks2 * BIG_BLOCK_SIZE;

    out.write(rootEntryPropertySet.data, 0, rootEntryPropertySet.data.length);
      
    byte[] padding2 = new byte[requiredSize2 - rootEntryPropertySet.data.length];
    out.write(padding2, 0, padding2.length);

    logger.debug("data length " + rootEntryPropertySet.data.length + " Padding " + padding2.length);

    for (Iterator i = additionalPropertySets.iterator(); i.hasNext() ;)
    {
      ReadPropertyStorage rps = (ReadPropertyStorage) i.next();
      byte[] data = rps.data;
      
      logger.debug("Writing property set " + rps.propertyStorage.name);
      int numBlocks = data.length >= SMALL_BLOCK_THRESHOLD ?
        getBigBlocksRequired(data.length) : 
        SMALL_BLOCK_THRESHOLD / BIG_BLOCK_SIZE;
      int requiredSize = numBlocks * BIG_BLOCK_SIZE;

      out.write(data, 0, data.length);
      
      byte[] padding = new byte[requiredSize - data.length];
      out.write(padding, 0, padding.length);
    }
  }

  /**
   * Writes out the excel data, padding it out with empty bytes as
   * necessary
   * Also write out empty 
   * 
   * @exception IOException 
   */
  private void writeExcelData() throws IOException
  {
    logger.debug("num excel data blocks " + excelDataBlocks + " excelData size " + requiredSize);
    out.write(excelData, 0, size);

    byte[] padding = new byte[requiredSize - size];
    out.write(padding);
  }

  /**
   * Write out the document summary data.  This is just blank
   * 
   * @exception IOException 
   */
  private void writeDocumentSummaryData() throws IOException
  {
    byte[] padding = new byte[SMALL_BLOCK_THRESHOLD];

    // Write out the summary information
    out.write(padding);
  }

  /**
   * Write out the  summary data.  This is just blank
   * 
   * @exception IOException 
   */
  private void writeSummaryData() throws IOException
  {
    byte[] padding = new byte[SMALL_BLOCK_THRESHOLD];

    // Write out the summary information
    out.write(padding);
  }

  /**
   * Writes the compound file header
   * 
   * @exception IOException 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
美女视频网站久久| 一区二区三区精品视频在线| caoporm超碰国产精品| 五月天一区二区三区| 成人欧美一区二区三区1314| 91精品国产欧美一区二区成人| 国产精品白丝jk白祙喷水网站| 日韩综合在线视频| 亚洲精品免费在线播放| 亚洲欧美日韩电影| 国产在线一区二区| 亚洲日本va在线观看| 久久青草国产手机看片福利盒子| 五月综合激情网| 亚洲天堂av一区| 亚洲女同女同女同女同女同69| 久久久国产一区二区三区四区小说 | 这里只有精品电影| 91福利视频网站| 99精品久久免费看蜜臀剧情介绍| 国产麻豆精品在线| 高清成人免费视频| 成人va在线观看| 国产一区二区三区在线观看免费 | 国产精品色呦呦| 亚洲人精品午夜| 日韩精彩视频在线观看| 日韩av网站免费在线| 久久se精品一区精品二区| 麻豆精品国产传媒mv男同| 国产伦精品一区二区三区免费 | 欧美顶级少妇做爰| 26uuu国产电影一区二区| 国产精品乱人伦| 天天综合色天天综合| 久久爱www久久做| 91看片淫黄大片一级在线观看| 欧美日韩在线不卡| 久久久青草青青国产亚洲免观| 亚洲欧美精品午睡沙发| 日韩高清一级片| 91首页免费视频| 精品美女在线播放| 尤物视频一区二区| 国产成人在线免费| 91精品国产综合久久蜜臀| 中文av一区二区| 久久精品国产99国产精品| 色婷婷一区二区| 精品日韩欧美在线| 亚洲资源在线观看| 99热精品一区二区| 久久亚洲捆绑美女| 三级一区在线视频先锋 | 色哟哟一区二区在线观看| 精品国产91久久久久久久妲己| 亚洲综合视频在线| aaa亚洲精品| 欧美韩国一区二区| 国产成人亚洲精品狼色在线| 欧美大片在线观看一区二区| 亚洲线精品一区二区三区八戒| 成人丝袜视频网| 中文字幕av一区二区三区| 久久成人免费网站| 精品福利二区三区| 精品一二三四区| 日韩欧美在线网站| 久久精品99国产国产精| 欧美一区二区三区视频免费| 日日欢夜夜爽一区| 日韩欧美亚洲一区二区| 麻豆精品一区二区三区| 日韩欧美中文一区| 国产麻豆精品视频| 中文字幕亚洲成人| 欧美专区在线观看一区| 亚洲第一狼人社区| 日韩三级在线免费观看| 国产成人亚洲综合a∨婷婷图片| 国产精品色哟哟网站| 在线亚洲一区二区| 亚洲午夜精品久久久久久久久| 在线观看日韩电影| 乱中年女人伦av一区二区| 久久精品在线观看| 色悠悠亚洲一区二区| 另类专区欧美蜜桃臀第一页| 久久―日本道色综合久久| 91麻豆高清视频| 蜜臀av国产精品久久久久| 亚洲国产成人在线| 欧美肥妇bbw| 91色porny| 美腿丝袜一区二区三区| 亚洲视频电影在线| 26uuu色噜噜精品一区二区| 91视频xxxx| 国产福利一区在线| 免费观看91视频大全| 亚洲综合在线电影| 国产精品视频一二三| 日韩欧美国产不卡| 欧美日韩激情一区二区| 成人禁用看黄a在线| 激情综合网最新| 午夜一区二区三区视频| 国产欧美一区二区三区网站| 欧美一区二区三区在线观看视频| 不卡一二三区首页| 国产不卡免费视频| 久久99国产精品麻豆| 天堂av在线一区| 亚洲中国最大av网站| 一区二区三区欧美| 亚洲精品伦理在线| 中文字幕在线不卡| 亚洲视频免费在线观看| 亚洲人成影院在线观看| 国产在线视频精品一区| 亚洲欧洲精品一区二区三区| 久久新电视剧免费观看| 精品国产伦一区二区三区观看体验| 欧美日韩激情一区| 欧美久久高跟鞋激| 日韩免费看的电影| 精品电影一区二区| 亚洲精品在线观看网站| 国产日韩精品一区二区浪潮av| 久久众筹精品私拍模特| 国产欧美日韩精品a在线观看| 国产精品人人做人人爽人人添| 国产精品视频第一区| 亚洲婷婷在线视频| 一区二区高清免费观看影视大全| 亚洲五月六月丁香激情| 日韩电影免费在线观看网站| 狠狠色丁香久久婷婷综合_中| 国产高清在线精品| 一本一本大道香蕉久在线精品| 欧美性视频一区二区三区| 日韩午夜精品视频| 国产精品美女久久久久aⅴ| 亚洲成人资源在线| 国产福利91精品一区| 欧美午夜免费电影| 国产精品情趣视频| 丝袜亚洲另类欧美| 99久久精品久久久久久清纯| 3atv一区二区三区| 国产精品蜜臀av| 免费成人在线播放| 一本到一区二区三区| 国产丝袜在线精品| 理论片日本一区| 欧美日韩国产影片| 国产精品美女久久久久久久久久久| 日韩制服丝袜先锋影音| 91在线播放网址| 久久久电影一区二区三区| 日日摸夜夜添夜夜添国产精品| 91在线精品一区二区| 久久午夜电影网| 麻豆精品久久精品色综合| 欧美日本国产视频| 亚洲一区二区精品久久av| 色综合天天狠狠| 亚洲欧美精品午睡沙发| 97久久人人超碰| 亚洲色图一区二区| 91免费在线看| 一区二区三区在线视频播放| av在线不卡电影| 亚洲欧美在线另类| av电影在线不卡| 亚洲一区二区精品久久av| 欧美日韩黄视频| 久久成人综合网| 国产视频一区二区在线| a美女胸又www黄视频久久| 日韩一区在线看| 欧美精品vⅰdeose4hd| 美腿丝袜亚洲三区| 久久精品人人爽人人爽| 成人午夜又粗又硬又大| 综合av第一页| 欧美日韩一卡二卡三卡 | 亚洲美女在线国产| 欧美三级日韩三级| 国产精品亚洲第一| 亚洲激情图片一区| 欧美哺乳videos| 91丨九色丨蝌蚪富婆spa| 日韩和欧美的一区| 中文一区一区三区高中清不卡| 色综合久久久久综合| 久久99精品久久久久久动态图| 亚洲视频电影在线| 26uuu色噜噜精品一区| 欧美唯美清纯偷拍|