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.

FtCfSubRecord.java 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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.hssf.record;
  16. import static org.apache.poi.util.GenericRecordUtil.getEnumBitsAsString;
  17. import java.util.Map;
  18. import java.util.function.Supplier;
  19. import org.apache.poi.util.GenericRecordUtil;
  20. import org.apache.poi.util.LittleEndianInput;
  21. import org.apache.poi.util.LittleEndianOutput;
  22. import org.apache.poi.util.RecordFormatException;
  23. /**
  24. * The FtCf structure specifies the clipboard format of the picture-type Obj record containing this FtCf.
  25. */
  26. public final class FtCfSubRecord extends SubRecord {
  27. public static final short sid = 0x07;
  28. public static final short length = 0x02;
  29. /**
  30. * Specifies the format of the picture is an enhanced metafile.
  31. */
  32. public static final short METAFILE_BIT = (short)0x0002;
  33. /**
  34. * Specifies the format of the picture is a bitmap.
  35. */
  36. public static final short BITMAP_BIT = (short)0x0009;
  37. /**
  38. * Specifies the picture is in an unspecified format that is
  39. * neither and enhanced metafile nor a bitmap.
  40. */
  41. public static final short UNSPECIFIED_BIT = (short)0xFFFF;
  42. private short flags;
  43. /**
  44. * Construct a new <code>FtPioGrbitSubRecord</code> and
  45. * fill its data with the default values
  46. */
  47. public FtCfSubRecord() {}
  48. public FtCfSubRecord(FtCfSubRecord other) {
  49. super(other);
  50. flags = other.flags;
  51. }
  52. public FtCfSubRecord(LittleEndianInput in, int size) {
  53. this(in,size,-1);
  54. }
  55. FtCfSubRecord(LittleEndianInput in, int size, int cmoOt) {
  56. if (size != length) {
  57. throw new RecordFormatException("Unexpected size (" + size + ")");
  58. }
  59. flags = in.readShort();
  60. }
  61. /**
  62. * Serialize the record data into the supplied array of bytes
  63. *
  64. * @param out the stream to serialize into
  65. */
  66. public void serialize(LittleEndianOutput out) {
  67. out.writeShort(sid);
  68. out.writeShort(length);
  69. out.writeShort(flags);
  70. }
  71. protected int getDataSize() {
  72. return length;
  73. }
  74. /**
  75. * @return id of this record.
  76. */
  77. public short getSid()
  78. {
  79. return sid;
  80. }
  81. @Override
  82. public FtCfSubRecord copy() {
  83. return new FtCfSubRecord(this);
  84. }
  85. public short getFlags() {
  86. return flags;
  87. }
  88. public void setFlags(short flags) {
  89. this.flags = flags;
  90. }
  91. @Override
  92. public SubRecordTypes getGenericRecordType() {
  93. return SubRecordTypes.FT_CF;
  94. }
  95. @Override
  96. public Map<String, Supplier<?>> getGenericProperties() {
  97. return GenericRecordUtil.getGenericProperties("flags", getEnumBitsAsString(this::getFlags,
  98. new int[]{METAFILE_BIT,BITMAP_BIT,UNSPECIFIED_BIT},
  99. new String[]{"METAFILE","BITMAP","UNSPECIFIED"}));
  100. }
  101. }