⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stylesheet.java

📁 Office格式转换代码
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2003 The Apache Software Foundation.  All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in *    the documentation and/or other materials provided with the *    distribution. * * 3. The end-user documentation included with the redistribution, *    if any, must include the following acknowledgment: *       "This product includes software developed by the *        Apache Software Foundation (http://www.apache.org/)." *    Alternately, this acknowledgment may appear in the software itself, *    if and wherever such third-party acknowledgments normally appear. * * 4. The names "Apache" and "Apache Software Foundation" and *    "Apache POI" must not be used to endorse or promote products *    derived from this software without prior written permission. For *    written permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache", *    "Apache POI", nor may "Apache" appear in their name, without *    prior written permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation.  For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */package org.apache.poi.hdf.extractor;import java.util.*;/** * Comment me * * @author Ryan Ackley  */public class StyleSheet{  private static final int NIL_STYLE = 4095;  private static final int PAP_TYPE = 1;  private static final int CHP_TYPE = 2;  private static final int SEP_TYPE = 4;  private static final int TAP_TYPE = 5;  //Vector _styleDescriptions;  StyleDescription _nilStyle = new StyleDescription();  StyleDescription[] _styleDescriptions;  public StyleSheet(byte[] styleSheet)  {      int stshiLength = Utils.convertBytesToShort(styleSheet, 0);      int stdCount = Utils.convertBytesToShort(styleSheet, 2);      int baseLength = Utils.convertBytesToShort(styleSheet, 4);      int[] rgftc = new int[3];      rgftc[0] = Utils.convertBytesToInt(styleSheet, 14);      rgftc[1] = Utils.convertBytesToInt(styleSheet, 18);      rgftc[2] = Utils.convertBytesToInt(styleSheet, 22);      int offset = 0;      _styleDescriptions = new StyleDescription[stdCount];      for(int x = 0; x < stdCount; x++)      {          int stdOffset = (2 + stshiLength) + offset;          int stdSize = Utils.convertBytesToShort(styleSheet, stdOffset);          if(stdSize > 0)          {              byte[] std = new byte[stdSize];              //get past the size              stdOffset += 2;              System.arraycopy(styleSheet, stdOffset, std, 0, stdSize);              StyleDescription aStyle = new StyleDescription(std, baseLength, true);              _styleDescriptions[x] = aStyle;          }          offset += stdSize + 2;      }      for(int x = 0; x < _styleDescriptions.length; x++)      {          if(_styleDescriptions[x] != null)          {              createPap(x);              createChp(x);          }      }  }  private void createPap(int istd)  {      StyleDescription sd = _styleDescriptions[istd];      PAP pap = sd.getPAP();      byte[] papx = sd.getPAPX();      int baseIndex = sd.getBaseStyle();      if(pap == null && papx != null)      {          PAP parentPAP = _nilStyle.getPAP();          if(baseIndex != NIL_STYLE)          {              parentPAP = _styleDescriptions[baseIndex].getPAP();              if(parentPAP == null)              {                  createPap(baseIndex);                  parentPAP = _styleDescriptions[baseIndex].getPAP();              }          }          pap = (PAP)uncompressProperty(papx, parentPAP, this);          sd.setPAP(pap);      }  }  private void createChp(int istd)  {      StyleDescription sd = _styleDescriptions[istd];      CHP chp = sd.getCHP();      byte[] chpx = sd.getCHPX();      int baseIndex = sd.getBaseStyle();      if(chp == null && chpx != null)      {          CHP parentCHP = _nilStyle.getCHP();          if(baseIndex != NIL_STYLE)          {              parentCHP = _styleDescriptions[baseIndex].getCHP();              if(parentCHP == null)              {                  createChp(baseIndex);                  parentCHP = _styleDescriptions[baseIndex].getCHP();              }          }          chp = (CHP)uncompressProperty(chpx, parentCHP, this);          sd.setCHP(chp);      }  }  public StyleDescription getStyleDescription(int x)  {      return _styleDescriptions[x];  }  static void doCHPOperation(CHP oldCHP, CHP newCHP, int operand, int param,                             byte[] varParam, byte[] grpprl, int offset,                             StyleSheet styleSheet)  {      switch(operand)      {          case 0:               newCHP._fRMarkDel = getFlag(param);               break;          case 0x1:               newCHP._fRMark = getFlag(param);               break;          case 0x2:               break;          case 0x3:               newCHP._fcPic = param;               newCHP._fSpec = true;               break;          case 0x4:               newCHP._ibstRMark = (short)param;               break;          case 0x5:               newCHP._dttmRMark[0] = Utils.convertBytesToShort(grpprl, (offset - 4));               newCHP._dttmRMark[1] = Utils.convertBytesToShort(grpprl, (offset - 2));               break;          case 0x6:               newCHP._fData = getFlag(param);               break;          case 0x7:               //don't care about this               break;          case 0x8:               short chsDiff = (short)((param & 0xff0000) >>> 8);               newCHP._fChsDiff = getFlag(chsDiff);               newCHP._chse = (short)(param & 0xffff);               break;          case 0x9:               newCHP._fSpec = true;               newCHP._ftcSym = (short)Utils.convertBytesToShort(varParam, 0);               newCHP._xchSym = (short)Utils.convertBytesToShort(varParam, 2);               break;          case 0xa:               newCHP._fOle2 = getFlag(param);               break;          case 0xb:               //?               break;          case 0xc:               newCHP._icoHighlight = (byte)param;               newCHP._highlighted = getFlag(param);               break;          case 0xd:               break;          case 0xe:               newCHP._fcObj = param;               break;          case 0xf:               break;          case 0x10:               //?               break;          case 0x11:               break;          case 0x12:               break;          case 0x13:               break;          case 0x14:               break;          case 0x15:               break;          case 0x16:               break;          case 0x17:               break;          case 0x18:               break;          case 0x19:               break;          case 0x1a:               break;          case 0x1b:               break;          case 0x1c:               break;          case 0x1d:               break;          case 0x1e:               break;          case 0x1f:               break;          case 0x20:               break;          case 0x21:               break;          case 0x22:               break;          case 0x23:               break;          case 0x24:               break;          case 0x25:               break;          case 0x26:               break;          case 0x27:               break;          case 0x28:               break;          case 0x29:               break;          case 0x2a:               break;          case 0x2b:               break;          case 0x2c:               break;          case 0x2d:               break;          case 0x2e:               break;          case 0x2f:               break;          case 0x30:               newCHP._istd = param;               break;          case 0x31:               //permutation vector for fast saves who cares!               break;          case 0x32:               newCHP._bold = false;               newCHP._italic = false;               newCHP._fOutline = false;               newCHP._fStrike = false;               newCHP._fShadow = false;               newCHP._fSmallCaps = false;               newCHP._fCaps = false;               newCHP._fVanish = false;               newCHP._kul = 0;               newCHP._ico = 0;               break;          case 0x33:               newCHP.copy(oldCHP);               return;          case 0x34:               break;          case 0x35:               newCHP._bold = getCHPFlag((byte)param, oldCHP._bold);               break;          case 0x36:               newCHP._italic = getCHPFlag((byte)param, oldCHP._italic);               break;          case 0x37:               newCHP._fStrike = getCHPFlag((byte)param, oldCHP._fStrike);               break;          case 0x38:               newCHP._fOutline = getCHPFlag((byte)param, oldCHP._fOutline);               break;          case 0x39:               newCHP._fShadow = getCHPFlag((byte)param, oldCHP._fShadow);               break;          case 0x3a:               newCHP._fSmallCaps = getCHPFlag((byte)param, oldCHP._fSmallCaps);               break;          case 0x3b:               newCHP._fCaps = getCHPFlag((byte)param, oldCHP._fCaps);               break;          case 0x3c:               newCHP._fVanish = getCHPFlag((byte)param, oldCHP._fVanish);               break;          case 0x3d:               newCHP._ftc = (short)param;               break;          case 0x3e:               newCHP._kul = (byte)param;               break;          case 0x3f:               int hps = param & 0xff;               if(hps != 0)               {                  newCHP._hps = hps;               }               byte cInc = (byte)(((byte)(param & 0xfe00) >>> 4) >> 1);               if(cInc != 0)               {                  newCHP._hps = Math.max(newCHP._hps + (cInc * 2), 2);               }               byte hpsPos = (byte)((param & 0xff0000) >>> 8);               if(hpsPos != 0x80)               {                  newCHP._hpsPos = hpsPos;               }               boolean fAdjust = (param & 0x0100) > 0;               if(fAdjust && hpsPos != 128 && hpsPos != 0 && oldCHP._hpsPos == 0)               {                  newCHP._hps = Math.max(newCHP._hps + (-2), 2);               }               if(fAdjust && hpsPos == 0 && oldCHP._hpsPos != 0)               {                  newCHP._hps = Math.max(newCHP._hps + 2, 2);               }               break;          case 0x40:               newCHP._dxaSpace = param;               break;          case 0x41:               newCHP._lidDefault = (short)param;               break;          case 0x42:               newCHP._ico = (byte)param;               break;          case 0x43:               newCHP._hps = param;               break;          case 0x44:               byte hpsLvl = (byte)param;               newCHP._hps = Math.max(newCHP._hps + (hpsLvl * 2), 2);               break;          case 0x45:               newCHP._hpsPos = (short)param;               break;          case 0x46:               if(param != 0)               {                  if(oldCHP._hpsPos == 0)                  {                      newCHP._hps = Math.max(newCHP._hps + (-2), 2);                  }               }               else               {                  if(oldCHP._hpsPos != 0)                  {                      newCHP._hps = Math.max(newCHP._hps + 2, 2);                  }               }               break;          case 0x47:               CHP genCHP = new CHP();               genCHP._ftc = 4;               genCHP = (CHP)uncompressProperty(varParam, genCHP, styleSheet);               CHP styleCHP = styleSheet.getStyleDescription(oldCHP._baseIstd).getCHP();               if(genCHP._bold == newCHP._bold)               {                  newCHP._bold = styleCHP._bold;               }               if(genCHP._italic == newCHP._italic)               {                  newCHP._italic = styleCHP._italic;               }               if(genCHP._fSmallCaps == newCHP._fSmallCaps)               {                  newCHP._fSmallCaps = styleCHP._fSmallCaps;               }               if(genCHP._fVanish == newCHP._fVanish)               {                  newCHP._fVanish = styleCHP._fVanish;               }               if(genCHP._fStrike == newCHP._fStrike)               {                  newCHP._fStrike = styleCHP._fStrike;               }               if(genCHP._fCaps == newCHP._fCaps)               {                  newCHP._fCaps = styleCHP._fCaps;               }               if(genCHP._ftcAscii == newCHP._ftcAscii)               {                  newCHP._ftcAscii = styleCHP._ftcAscii;               }               if(genCHP._ftcFE == newCHP._ftcFE)               {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -