📄 stylesheet.java
字号:
param = LittleEndian.getShort(grpprl, offset); break; case 3: opSize = 4; param = LittleEndian.getInt(grpprl, offset); break; case 4: case 5: opSize = 2; param = LittleEndian.getShort(grpprl, offset); break; case 6://variable size //there is one sprm that is a very special case if(sprm != (short)0xd608) { opSize = LittleEndian.getUnsignedByte(grpprl, offset); offset++; } else { opSize = LittleEndian.getShort(grpprl, offset) - 1; offset += 2; } varParam = new byte[opSize]; System.arraycopy(grpprl, offset, varParam, 0, opSize); break; case 7: opSize = 3; byte threeByteInt[] = new byte[4]; threeByteInt[0] = grpprl[offset]; threeByteInt[1] = grpprl[offset + 1]; threeByteInt[2] = grpprl[offset + 2]; threeByteInt[3] = (byte)0; param = LittleEndian.getInt(threeByteInt, 0); break; default: throw new RuntimeException("unrecognized pap opcode"); } offset += opSize; short operand = (short)(sprm & 0x1ff); byte type = (byte)((sprm & 0x1c00) >> 10); switch(propertyType) { case PAP_TYPE: if(type == 1)//papx stores TAP sprms along with PAP sprms { doPAPOperation((ParagraphProperties)newProperty, operand, param, varParam, grpprl, offset, spra); } break; case CHP_TYPE: doCHPOperation((CharacterProperties)parent, (CharacterProperties)newProperty, operand, param, varParam, grpprl, offset, styleSheet); break; case SEP_TYPE: doSEPOperation((SectionProperties)newProperty, operand, param, varParam); break; case TAP_TYPE: if(type == 5) { doTAPOperation((TableProperties)newProperty, operand, param, varParam); } break; } } return newProperty; } /** * Performs an operation on a ParagraphProperties object. Used to uncompress * from a papx. * * @param newPAP The ParagraphProperties object to perform the operation on. * @param operand The operand that defines the operation. * @param param The operation's parameter. * @param varParam The operation's variable length parameter. * @param grpprl The original papx. * @param offset The current offset in the papx. * @param spra A part of the sprm that defined this operation. */ static void doPAPOperation(ParagraphProperties newPAP, int operand, int param, byte[] varParam, byte[] grpprl, int offset, int spra) { switch(operand) { case 0: newPAP.setIstd(param); break; case 0x1: //permuteIstd(newPAP, varParam); break; case 0x2: if(newPAP.getIstd() <=9 || newPAP.getIstd() >=1) { newPAP.setIstd(newPAP.getIstd() + param); if(param > 0) { newPAP.setIstd(Math.max(newPAP.getIstd(), 9)); } else { newPAP.setIstd(Math.min(newPAP.getIstd(), 1)); } } break; case 0x3: newPAP.setJc((byte)param); break; case 0x4: newPAP.setFSideBySide((byte)param); break; case 0x5: newPAP.setFKeep((byte)param); break; case 0x6: newPAP.setFKeepFollow((byte)param); break; case 0x7: newPAP.setFPageBreakBefore((byte)param); break; case 0x8: newPAP.setBrcl((byte)param); break; case 0x9: newPAP.setBrcp((byte)param); break; case 0xa: newPAP.setIlvl((byte)param); break; case 0xb: newPAP.setIlfo(param); break; case 0xc: newPAP.setFNoLnn((byte)param); break; case 0xd: /**@todo handle tabs*/ break; case 0xe: newPAP.setDxaRight(param); break; case 0xf: newPAP.setDxaLeft(param); break; case 0x10: newPAP.setDxaLeft(newPAP.getDxaLeft() + param); newPAP.setDxaLeft(Math.max(0, newPAP.getDxaLeft())); break; case 0x11: newPAP.setDxaLeft1(param); break; case 0x12: short[] lspd = newPAP.getLspd(); lspd[0] = LittleEndian.getShort(grpprl, offset - 4); lspd[1] = LittleEndian.getShort(grpprl, offset - 2); break; case 0x13: newPAP.setDyaBefore(param); break; case 0x14: newPAP.setDyaAfter(param); break; case 0x15: /**@todo handle tabs*/ break; case 0x16: newPAP.setFInTable((byte)param); break; case 0x17: newPAP.setFTtp((byte)param); break; case 0x18: newPAP.setDxaAbs(param); break; case 0x19: newPAP.setDyaAbs(param); break; case 0x1a: newPAP.setDxaWidth(param); break; case 0x1b: /** @todo handle paragraph postioning*/ /*byte pcVert = (param & 0x0c) >> 2; byte pcHorz = param & 0x03; if(pcVert != 3) { newPAP._pcVert = pcVert; } if(pcHorz != 3) { newPAP._pcHorz = pcHorz; }*/ break; case 0x1c: //newPAP.setBrcTop1((short)param); break; case 0x1d: //newPAP.setBrcLeft1((short)param); break; case 0x1e: //newPAP.setBrcBottom1((short)param); break; case 0x1f: //newPAP.setBrcRight1((short)param); break; case 0x20: //newPAP.setBrcBetween1((short)param); break; case 0x21: //newPAP.setBrcBar1((byte)param); break; case 0x22: newPAP.setDxaFromText(param); break; case 0x23: newPAP.setWr((byte)param); break; case 0x24: short[] brcTop = newPAP.getBrcTop(); brcTop[0] = (short)LittleEndian.getShort(grpprl, offset - 4); brcTop[1] = (short)LittleEndian.getShort(grpprl, offset - 2); break; case 0x25: short[] brcLeft = newPAP.getBrcLeft(); brcLeft[0] = (short)LittleEndian.getShort(grpprl, offset - 4); brcLeft[1] = (short)LittleEndian.getShort(grpprl, offset - 2); break; case 0x26: short[] brcBottom = newPAP.getBrcBottom(); brcBottom[0] = (short)LittleEndian.getShort(grpprl, offset - 4); brcBottom[1] = (short)LittleEndian.getShort(grpprl, offset - 2); break; case 0x27: short[] brcRight = newPAP.getBrcRight(); brcRight[0] = (short)LittleEndian.getShort(grpprl, offset - 4); brcRight[1] = (short)LittleEndian.getShort(grpprl, offset - 2); break; case 0x28: short[] brcBetween = newPAP.getBrcBetween(); brcBetween[0] = (short)LittleEndian.getShort(grpprl, offset - 4); brcBetween[1] = (short)LittleEndian.getShort(grpprl, offset - 2); break; case 0x29: short[] brcBar = newPAP.getBrcBar(); brcBar[0] = (short)LittleEndian.getShort(grpprl, offset - 4); brcBar[1] = (short)LittleEndian.getShort(grpprl, offset - 2); break; case 0x2a: newPAP.setFNoAutoHyph((byte)param); break; case 0x2b: newPAP.setDyaHeight(param); break; case 0x2c: newPAP.setDcs((short)param); break; case 0x2d: newPAP.setShd((short)param); break; case 0x2e: newPAP.setDyaFromText(param); break; case 0x2f: newPAP.setDxaFromText(param); break; case 0x30: newPAP.setFLocked((byte)param); break; case 0x31: newPAP.setFWidowControl((byte)param); break; case 0x32: //undocumented break; case 0x33: newPAP.setFKinsoku((byte)param); break; case 0x34: newPAP.setFWordWrap((byte)param); break; case 0x35: newPAP.setFOverflowPunct((byte)param); break; case 0x36: newPAP.setFTopLinePunct((byte)param); break; case 0x37: newPAP.setFAutoSpaceDE((byte)param); break; case 0x38: newPAP.setFAutoSpaceDN((byte)param); break; case 0x39: newPAP.setWAlignFont(param); break; case 0x3a: newPAP.setFontAlign((short)param); break; case 0x3b: //obsolete break; case 0x3e: newPAP.setAnld(varParam); break; case 0x3f: //don't really need this. spec is confusing regarding this //sprm break; case 0x40: //newPAP._lvl = param; break; case 0x41: //? break; case 0x43: //? break; case 0x44: //? break; case 0x45: if(spra == 6) { newPAP.setNumrm(varParam); } else { /**@todo handle large PAPX from data stream*/ } break; case 0x47: newPAP.setFUsePgsuSettings((byte)param); break; case 0x48: newPAP.setFAdjustRight((byte)param); break; default: break; } } /** * Used to uncompress a table property. Performs an operation defined * by a sprm stored in a tapx. * * @param newTAP The TableProperties object to perform the operation on. * @param operand The operand that defines this operation. * @param param The parameter for this operation. * @param varParam Variable length parameter for this operation. */ static void doTAPOperation(TableProperties newTAP, int operand, int param, byte[] varParam) { switch(operand) { case 0: newTAP.setJc((short)param); break; case 0x01: { short[] rgdxaCenter = newTAP.getRgdxaCenter(); short itcMac = newTAP.getItcMac(); int adjust = param - (rgdxaCenter[0] + newTAP.getDxaGapHalf()); for(int x = 0; x < itcMac; x++) { rgdxaCenter[x] += adjust; } break; } case 0x02: {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -