您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

CHPX.java 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* ====================================================================
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. ==================================================================== */
  15. package org.apache.poi.hwpf.model;
  16. import org.apache.poi.hwpf.usermodel.CharacterProperties;
  17. import org.apache.poi.hwpf.sprm.SprmBuffer;
  18. import org.apache.poi.hwpf.sprm.CharacterSprmUncompressor;
  19. /**
  20. * DANGER - works in bytes!
  21. *
  22. * Make sure you call getStart() / getEnd() when you want characters
  23. * (normal use), but getStartByte() / getEndByte() when you're
  24. * reading in / writing out!
  25. *
  26. * @author Ryan Ackley
  27. */
  28. public final class CHPX extends BytePropertyNode
  29. {
  30. public CHPX(int fcStart, int fcEnd, CharIndexTranslator translator, byte[] grpprl)
  31. {
  32. super(fcStart, translator.lookIndexBackward(fcEnd), translator, new SprmBuffer(grpprl));
  33. }
  34. public CHPX(int fcStart, int fcEnd, CharIndexTranslator translator, SprmBuffer buf)
  35. {
  36. super(fcStart, translator.lookIndexBackward(fcEnd), translator ,buf);
  37. }
  38. public byte[] getGrpprl()
  39. {
  40. return ((SprmBuffer)_buf).toByteArray();
  41. }
  42. public SprmBuffer getSprmBuf()
  43. {
  44. return (SprmBuffer)_buf;
  45. }
  46. public CharacterProperties getCharacterProperties(StyleSheet ss, short istd)
  47. {
  48. CharacterProperties baseStyle = ss.getCharacterStyle(istd);
  49. CharacterProperties props = CharacterSprmUncompressor.uncompressCHP(baseStyle, getGrpprl(), 0);
  50. return props;
  51. }
  52. public String toString() {
  53. return "CHPX from " + getStart() + " to " + getEnd() +
  54. " (in bytes " + getStartBytes() + " to " + getEndBytes() + ")";
  55. }
  56. }