You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

OldCHPBinTable.java 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 java.util.Collections;
  17. import org.apache.poi.poifs.common.POIFSConstants;
  18. import org.apache.poi.util.Internal;
  19. import org.apache.poi.util.LittleEndian;
  20. /**
  21. * This class holds all of the character formatting
  22. * properties from Old (Word 6 / Word 95) documents.
  23. * Unlike with Word 97+, it all gets held in the
  24. * same stream.
  25. * In common with the rest of the old support, it
  26. * is read only
  27. */
  28. @Internal
  29. public final class OldCHPBinTable extends CHPBinTable
  30. {
  31. /**
  32. * Constructor used to read an old-style binTable
  33. * in from a Word document.
  34. *
  35. * @param documentStream
  36. * @param offset
  37. * @param size
  38. * @param fcMin
  39. */
  40. public OldCHPBinTable(byte[] documentStream, int offset,
  41. int size, int fcMin, OldTextPieceTable tpt)
  42. {
  43. PlexOfCps binTable = new PlexOfCps(documentStream, offset, size, 2);
  44. int length = binTable.length();
  45. for (int x = 0; x < length; x++)
  46. {
  47. GenericPropertyNode node = binTable.getProperty(x);
  48. int pageNum = LittleEndian.getUShort(node.getBytes());
  49. int pageOffset = POIFSConstants.SMALLER_BIG_BLOCK_SIZE * pageNum;
  50. CHPFormattedDiskPage cfkp = new CHPFormattedDiskPage(documentStream,
  51. pageOffset, tpt);
  52. for ( CHPX chpx : cfkp.getCHPXs() )
  53. {
  54. if ( chpx != null )
  55. _textRuns.add( chpx );
  56. }
  57. }
  58. Collections.sort( _textRuns, PropertyNode.StartComparator.instance );
  59. }
  60. }