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.

EscherRecordTypes.java 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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.ddf;
  16. import java.util.Map;
  17. import java.util.function.Function;
  18. import java.util.function.Supplier;
  19. import java.util.stream.Collectors;
  20. import java.util.stream.Stream;
  21. public enum EscherRecordTypes {
  22. // records greater then 0xF000 belong to Microsoft Office Drawing format also known as Escher
  23. /**
  24. * {@link EscherContainerRecord Container} for all OfficeArt file records that contain document-wide data.
  25. * <p>
  26. * Contains, amongst others children, a {@link #BSTORE_CONTAINER}.
  27. * <p>
  28. * Referred to as an {@code OfficeArtDggContainer} in {@code [MS-ODRAW].pdf v20201117}.
  29. */
  30. DGG_CONTAINER(0xF000, "DggContainer", null, EscherContainerRecord::new),
  31. /**
  32. * {@link EscherContainerRecord Container} for all BLIPs (binary large image or picture) that are used in the
  33. * drawings associated with the parent {@link #DGG_CONTAINER}.
  34. * <p>
  35. * Contains a list of {@link EscherBSERecord}s.
  36. * <p>
  37. * Referred to as an {@code OfficeArtBStoreContainer} in {@code [MS-ODRAW].pdf v20201117}.
  38. */
  39. BSTORE_CONTAINER(0xf001, "BStoreContainer", null, EscherContainerRecord::new),
  40. /**
  41. * {@link EscherContainerRecord Container} for all the file records for the objects in a drawing.
  42. * <p>
  43. * Referred to as an {@code OfficeArtDgContainer} in {@code [MS-ODRAW].pdf v20201117}.
  44. */
  45. DG_CONTAINER(0xf002, "DgContainer", null, EscherContainerRecord::new),
  46. SPGR_CONTAINER(0xf003, "SpgrContainer", null, EscherContainerRecord::new),
  47. SP_CONTAINER(0xf004, "SpContainer", null, EscherContainerRecord::new),
  48. SOLVER_CONTAINER(0xf005, "SolverContainer", null, EscherContainerRecord::new),
  49. DGG(0xf006, "Dgg", "MsofbtDgg", EscherDggRecord::new),
  50. BSE(0xf007, "BSE", "MsofbtBSE", EscherBSERecord::new),
  51. DG(0xf008, "Dg", "MsofbtDg", EscherDgRecord::new),
  52. SPGR(0xf009, "Spgr", "MsofbtSpgr", EscherSpgrRecord::new),
  53. SP(0xf00a, "Sp", "MsofbtSp", EscherSpRecord::new),
  54. OPT(0xf00b, "Opt", "msofbtOPT", EscherOptRecord::new),
  55. TEXTBOX(0xf00c, null, null, EscherTextboxRecord::new),
  56. CLIENT_TEXTBOX(0xf00d, "ClientTextbox", "msofbtClientTextbox", EscherTextboxRecord::new),
  57. ANCHOR(0xf00e, null, null, null),
  58. CHILD_ANCHOR(0xf00f, "ChildAnchor", "MsofbtChildAnchor", EscherChildAnchorRecord::new),
  59. CLIENT_ANCHOR(0xf010, "ClientAnchor", "MsofbtClientAnchor", EscherClientAnchorRecord::new),
  60. CLIENT_DATA(0xf011, "ClientData", "MsofbtClientData", EscherClientDataRecord::new),
  61. CONNECTOR_RULE(0xf012, null, null, null),
  62. ALIGN_RULE(0xf013, null, null, null),
  63. ARC_RULE(0xf014, null, null, null),
  64. CLIENT_RULE(0xf015, null, null, null),
  65. CLSID(0xf016, null, null, null),
  66. CALLOUT_RULE(0xf017, null, null, null),
  67. BLIP_START(0xf018, "Blip", "msofbtBlip", null),
  68. BLIP_EMF(0xf018 + 2 /* 0xf01a */, "BlipEmf", null, EscherMetafileBlip::new),
  69. BLIP_WMF(0xf018 + 3 /* 0xf01b */, "BlipWmf", null, EscherMetafileBlip::new),
  70. BLIP_PICT(0xf018 + 4 /* 0xf01c */, "BlipPict", null, EscherMetafileBlip::new),
  71. BLIP_JPEG(0xf018 + 5 /* 0xf01d */, "BlipJpeg", null, EscherBitmapBlip::new),
  72. BLIP_PNG(0xf018 + 6 /* 0xf01e */, "BlipPng", null, EscherBitmapBlip::new),
  73. BLIP_DIB(0xf018 + 7 /* 0xf01f */, "BlipDib", null, EscherBitmapBlip::new),
  74. BLIP_TIFF(0xf018 + 17 /* 0xf029 */, "BlipTiff", null, EscherBitmapBlip::new),
  75. BLIP_END(0xf117, "Blip", "msofbtBlip", null),
  76. REGROUP_ITEMS(0xf118, null, null, null),
  77. SELECTION(0xf119, null, null, null),
  78. COLOR_MRU(0xf11a, null, null, null),
  79. DELETED_PSPL(0xf11d, null, null, null),
  80. SPLIT_MENU_COLORS(0xf11e, "SplitMenuColors", "MsofbtSplitMenuColors", EscherSplitMenuColorsRecord::new),
  81. OLE_OBJECT(0xf11f, null, null, null),
  82. COLOR_SCHEME(0xf120, null, null, null),
  83. // same as EscherTertiaryOptRecord.RECORD_ID
  84. USER_DEFINED(0xf122, "TertiaryOpt", null, EscherTertiaryOptRecord::new),
  85. UNKNOWN(0xffff, "unknown", "unknown", UnknownEscherRecord::new);
  86. public final short typeID;
  87. public final String recordName;
  88. public final String description;
  89. public final Supplier<? extends EscherRecord> constructor;
  90. EscherRecordTypes(int typeID, String recordName, String description, Supplier<? extends EscherRecord> constructor) {
  91. this.typeID = (short) typeID;
  92. this.recordName = recordName;
  93. this.description = description;
  94. this.constructor = constructor;
  95. }
  96. private Short getTypeId() {
  97. return typeID;
  98. }
  99. private static final Map<Short, EscherRecordTypes> LOOKUP =
  100. Stream.of(values()).collect(Collectors.toMap(EscherRecordTypes::getTypeId, Function.identity()));
  101. public static EscherRecordTypes forTypeID(int typeID) {
  102. // Section 2.2.23: 0xF02A is treated as 0xF01D
  103. if (typeID == 0xF02A) {
  104. return EscherRecordTypes.BLIP_JPEG;
  105. }
  106. EscherRecordTypes rt = LOOKUP.get((short)typeID);
  107. return (rt != null) ? rt : EscherRecordTypes.UNKNOWN;
  108. }
  109. }