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

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

?? compoundfile.java3

?? java讀寫Excel文檔的API
?? 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一区二区三区免费野_久草精品视频
91看片淫黄大片一级在线观看| 国产剧情一区二区| 奇米精品一区二区三区四区| 国产99久久久精品| 欧美第一区第二区| 一区二区三区不卡视频| 国产成人在线看| 日韩欧美一区二区免费| 亚洲午夜免费视频| 丁香激情综合五月| 久久九九全国免费| 奇米影视在线99精品| 欧美色视频一区| 91精品国产综合久久精品| 国产最新精品精品你懂的| 捆绑变态av一区二区三区| 欧美日韩在线播| 亚洲精品成a人| aaa亚洲精品一二三区| 国产女人18水真多18精品一级做| 蜜臀久久99精品久久久久宅男| 欧美日韩中文字幕精品| 亚洲精选视频在线| 91丝袜美女网| 亚洲另类春色校园小说| 91同城在线观看| 亚洲免费在线视频| 日本黄色一区二区| 一区二区三区中文在线| 日本道精品一区二区三区| 亚洲视频小说图片| 在线观看一区不卡| 尤物av一区二区| 欧美日韩性生活| 亚瑟在线精品视频| 91精品国产综合久久精品性色| 亚洲v中文字幕| 日韩一区二区在线看| 日韩高清在线观看| 欧美mv日韩mv国产| 国产69精品久久777的优势| 国产校园另类小说区| 国产91对白在线观看九色| 中文字幕一区二区三区不卡在线| 成人动漫视频在线| 亚洲一线二线三线久久久| 欧美日韩不卡在线| 久久精品国产精品青草| www国产精品av| www.99精品| 午夜电影网亚洲视频| 欧美电视剧在线看免费| 成人精品视频一区| 亚洲二区在线视频| 久久综合av免费| 97se狠狠狠综合亚洲狠狠| 五月天视频一区| 久久精品人人做| 色噜噜狠狠色综合欧洲selulu| 亚洲国产日韩一级| 久久精品一区二区三区不卡牛牛| youjizz久久| 日本不卡一区二区三区高清视频| 337p粉嫩大胆噜噜噜噜噜91av| 成人的网站免费观看| 婷婷久久综合九色综合绿巨人| 2023国产一二三区日本精品2022| 91在线精品秘密一区二区| 奇米影视一区二区三区| 18涩涩午夜精品.www| 欧美变态tickle挠乳网站| 91美女片黄在线观看| 久久国产麻豆精品| 亚洲黄色性网站| 国产女主播视频一区二区| 欧美色老头old∨ideo| 国产成人在线视频免费播放| 亚洲成人激情自拍| 一区二区中文视频| 精品久久久网站| 欧美影院一区二区三区| 成人污污视频在线观看| 日韩电影一区二区三区四区| 国产精品成人一区二区艾草 | 国产日韩欧美高清| 精品视频1区2区3区| 高清不卡在线观看av| 麻豆91在线播放免费| 亚洲一区二区在线免费观看视频| 亚洲国产经典视频| 欧美一区二区三区四区视频| 欧美一区二区三区性视频| 日韩精彩视频在线观看| 亚洲另类中文字| 国产精品免费视频一区| 精品电影一区二区| 日韩欧美二区三区| 5566中文字幕一区二区电影| 久久综合久久综合久久| 91福利在线播放| 99国产精品久久久| 成人黄色电影在线| 成人综合激情网| 国产精品12区| 国产不卡免费视频| 丁香天五香天堂综合| 国产乱国产乱300精品| 精品一区二区精品| 国产永久精品大片wwwapp| 捆绑调教美女网站视频一区| 免费在线观看视频一区| 男女男精品网站| 美女在线观看视频一区二区| 免费国产亚洲视频| 九九精品一区二区| 狠狠色丁香婷婷综合久久片| 国产美女在线观看一区| 国产一区二区三区国产| 国产精品一二三四| 成人av动漫网站| 欧洲一区二区av| 欧美日韩www| 日韩免费成人网| 国产亚洲精品中文字幕| 中文在线免费一区三区高中清不卡| 国产欧美日韩在线看| 亚洲欧洲在线观看av| 亚洲电影在线免费观看| 日本不卡的三区四区五区| 韩国v欧美v亚洲v日本v| 成人性生交大片免费看中文| 97久久超碰精品国产| 中文字幕在线观看不卡| 一区二区三区四区在线免费观看 | 欧美日本免费一区二区三区| 欧美亚日韩国产aⅴ精品中极品| 欧美亚洲国产一区二区三区| 欧美高清www午色夜在线视频| 日韩一区二区在线观看视频 | 美女视频网站久久| 国产精品一二三区| 色八戒一区二区三区| 欧美日韩在线电影| 亚洲精品一区二区三区99| 国产精品午夜在线| 亚洲国产精品久久久久婷婷884 | 欧美性一二三区| 日韩欧美黄色影院| 国产精品电影一区二区| 视频在线观看91| 国内不卡的二区三区中文字幕| 99久久精品99国产精品| 欧美一区国产二区| 国产免费久久精品| 久久99精品一区二区三区| 国产一区二区三区免费在线观看| 99国产精品一区| 91精品国产综合久久精品性色 | 色狠狠av一区二区三区| 日韩免费一区二区| 亚洲乱码国产乱码精品精的特点| 美女视频黄a大片欧美| 91麻豆国产自产在线观看| 精品国产免费一区二区三区香蕉| 中文字幕一区二区三区四区不卡| 男女男精品视频网| 在线一区二区视频| 国产精品女主播在线观看| 午夜电影网一区| 色婷婷精品久久二区二区蜜臀av| 久久久久久久久久美女| 日本欧美一区二区在线观看| 99九九99九九九视频精品| 国产午夜亚洲精品午夜鲁丝片| 视频一区免费在线观看| 国产老肥熟一区二区三区| 91精品国产欧美日韩| 国产欧美精品在线观看| 在线一区二区三区做爰视频网站| 色噜噜狠狠色综合中国| 亚洲欧洲三级电影| 国产精品中文字幕欧美| 日韩视频在线一区二区| 亚洲成人黄色影院| 色8久久人人97超碰香蕉987| 中文字幕不卡在线观看| 国产曰批免费观看久久久| 精品久久久久久久久久久久久久久久久 | 色婷婷久久久综合中文字幕| 中文字幕av不卡| 成人激情午夜影院| 欧美高清在线精品一区| 国产成人免费网站| 中文字幕av一区二区三区| 成人免费精品视频| 国产精品国产三级国产aⅴ原创 | 亚洲欧美日韩国产成人精品影院| 久久国产视频网| 91免费版在线| 久久久久久一级片|