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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? compoundfile.java3

?? 這套API是純Java的
?? JAVA3
?? 第 1 頁 / 共 2 頁
字號(hào):
/*********************************************************************
*
*      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 

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人免费在线观看入口| 欧美成人伊人久久综合网| 欧美mv和日韩mv的网站| 亚洲欧美另类久久久精品| 精品亚洲国产成人av制服丝袜 | 国产精品的网站| 七七婷婷婷婷精品国产| 91日韩在线专区| 国产日韩欧美在线一区| 蜜桃视频在线一区| 欧美午夜精品免费| 最新高清无码专区| 国产成人亚洲精品青草天美| 欧美日本在线观看| 悠悠色在线精品| 国产成人免费xxxxxxxx| 精品国产一区二区三区久久久蜜月| 一区二区三区四区视频精品免费 | 香蕉乱码成人久久天堂爱免费| 粉嫩av一区二区三区在线播放| 日韩欧美成人午夜| 亚洲成a人片在线观看中文| 91蝌蚪porny九色| 国产精品欧美一区二区三区| 精品一区二区国语对白| 欧美成人女星排行榜| 日本中文字幕一区二区视频| 欧美视频精品在线观看| 亚洲激情在线激情| 99精品视频一区| 国产精品不卡视频| 成人国产免费视频| 日本一区二区三区久久久久久久久不 | 国产欧美一区二区三区沐欲| 精一区二区三区| 日韩欧美国产午夜精品| 老司机精品视频在线| 欧美一级高清片在线观看| 日欧美一区二区| 日韩一区二区三区电影在线观看| 日韩不卡一区二区| 91精品婷婷国产综合久久| 日韩av电影免费观看高清完整版在线观看| 欧美午夜片在线观看| 亚洲成a人片在线观看中文| 欧美人牲a欧美精品| 午夜久久电影网| 7777精品伊人久久久大香线蕉超级流畅| 亚洲成人激情自拍| 91精品国产入口在线| 麻豆精品精品国产自在97香蕉| 日韩欧美中文字幕精品| 久久99国产精品麻豆| 国产日产亚洲精品系列| 成人av网站在线观看免费| 亚洲欧美日韩国产另类专区| 欧美体内she精高潮| 日韩国产在线一| 日韩亚洲欧美高清| 国产精品一区二区在线观看网站| 国产清纯在线一区二区www| 99久久精品免费看| 亚洲黄网站在线观看| 欧美日本精品一区二区三区| 精品一区二区免费看| 国产精品久久久久毛片软件| 91浏览器在线视频| 视频一区二区欧美| 久久色.com| 成人丝袜高跟foot| 一区二区三区中文在线观看| 欧美日韩一区二区在线观看 | 国产欧美精品区一区二区三区| 本田岬高潮一区二区三区| 亚洲乱码国产乱码精品精可以看| 欧美日韩久久久一区| 国产麻豆欧美日韩一区| 国产精品理论在线观看| 欧美日韩中字一区| 激情综合一区二区三区| 国产精品久久影院| 欧美另类一区二区三区| 国产激情一区二区三区| 伊人夜夜躁av伊人久久| 日韩一区二区麻豆国产| 风间由美一区二区av101| 一区二区三区在线播放| 日韩欧美国产精品| av午夜一区麻豆| 日韩成人免费电影| 中文字幕在线免费不卡| 制服丝袜亚洲网站| 成人av动漫在线| 免费成人深夜小野草| 中文av一区特黄| 91精品午夜视频| av电影一区二区| 美国十次了思思久久精品导航| 亚洲欧美综合色| 日韩精品一区二区在线| 色妹子一区二区| 国内精品免费在线观看| 亚洲一区二区在线免费观看视频 | 欧美日韩亚洲国产综合| 成人免费视频视频| 美国精品在线观看| 亚洲欧美成人一区二区三区| 26uuu色噜噜精品一区| 欧美在线小视频| 国产99久久久久久免费看农村| 亚洲影院在线观看| 欧美精彩视频一区二区三区| 欧美顶级少妇做爰| 91丨porny丨首页| 国产精品小仙女| 日本aⅴ亚洲精品中文乱码| 亚洲视频你懂的| 国产视频一区在线播放| 91超碰这里只有精品国产| 97aⅴ精品视频一二三区| 韩日精品视频一区| 婷婷成人激情在线网| 亚洲欧美偷拍卡通变态| 日本一区二区三区国色天香| 精品蜜桃在线看| 欧美一区二区啪啪| 欧美写真视频网站| 91一区二区三区在线观看| 国产夫妻精品视频| 久久精品国产久精国产爱| 亚洲不卡在线观看| 亚洲黄网站在线观看| 1区2区3区国产精品| 日本一区二区三区免费乱视频| 精品国产一区二区三区久久久蜜月| 91精品婷婷国产综合久久竹菊| 欧美日韩综合色| 91久久香蕉国产日韩欧美9色| 成人黄色免费短视频| 国产九色sp调教91| 九九**精品视频免费播放| 蜜桃传媒麻豆第一区在线观看| 亚洲高清在线视频| 亚洲成人综合视频| 亚洲h精品动漫在线观看| 亚洲综合成人网| 又紧又大又爽精品一区二区| 国产精品女同一区二区三区| 中文字幕精品在线不卡| 国产精品少妇自拍| 国产精品乱人伦| 国产精品九色蝌蚪自拍| 日本一区二区三区电影| 亚洲国产成人午夜在线一区| 日韩电影一区二区三区| 日韩电影免费在线观看网站| 日本一不卡视频| 秋霞av亚洲一区二区三| 久久精品国产99久久6| 看电影不卡的网站| 黄色资源网久久资源365| 久久国产生活片100| 久久99精品久久久久| 国产一区二区女| 国产白丝精品91爽爽久久| 国产不卡视频一区| av亚洲精华国产精华精华| 91视频国产资源| 欧亚一区二区三区| 欧美日韩国产免费一区二区| 欧美理论电影在线| 精品欧美一区二区三区精品久久| www精品美女久久久tv| 久久久美女艺术照精彩视频福利播放| 久久精品欧美一区二区三区不卡 | 国产精品国产三级国产有无不卡| 中文在线资源观看网站视频免费不卡| 国产精品国产精品国产专区不片| 亚洲色图清纯唯美| 亚洲午夜成aⅴ人片| 日本中文字幕不卡| 国产主播一区二区| 91小视频在线观看| 欧美日韩精品欧美日韩精品一综合| 91精品在线观看入口| 久久久午夜精品理论片中文字幕| 国产精品久久久久久久久搜平片| 一区二区三区欧美亚洲| 日韩国产精品久久| 国产成人8x视频一区二区| 99国产精品一区| 在线成人免费观看| 国产亚洲女人久久久久毛片| 亚洲视频一区二区在线| 日韩成人一区二区三区在线观看| 国产mv日韩mv欧美| 欧美色欧美亚洲另类二区| 欧美不卡在线视频| 亚洲四区在线观看| 日韩av一二三|