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

📄 stylesheet.java

📁 java 读写word excel ppt
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* ====================================================================   Licensed to the Apache Software Foundation (ASF) under one or more   contributor license agreements.  See the NOTICE file distributed with   this work for additional information regarding copyright ownership.   The ASF licenses this file to You under the Apache License, Version 2.0   (the "License"); you may not use this file except in compliance with   the License.  You may obtain a copy of the License at       http://www.apache.org/licenses/LICENSE-2.0   Unless required by applicable law or agreed to in writing, software   distributed under the License is distributed on an "AS IS" BASIS,   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   See the License for the specific language governing permissions and   limitations under the License.==================================================================== */        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)               {                  newCHP._ftcFE = styleCHP._ftcFE;               }               if(genCHP._ftcOther == newCHP._ftcOther)               {                  newCHP._ftcOther = styleCHP._ftcOther;               }               if(genCHP._hps == newCHP._hps)               {                  newCHP._hps = styleCHP._hps;               }               if(genCHP._hpsPos == newCHP._hpsPos)               {                  newCHP._hpsPos = styleCHP._hpsPos;               }               if(genCHP._kul == newCHP._kul)               {                  newCHP._kul = styleCHP._kul;               }               if(genCHP._dxaSpace == newCHP._dxaSpace)               {                  newCHP._dxaSpace = styleCHP._dxaSpace;               }               if(genCHP._ico == newCHP._ico)

⌨️ 快捷键说明

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