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.

TopMarginRecord.java 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 java.util.Map;
  17. import java.util.function.Supplier;
  18. import org.apache.poi.util.GenericRecordUtil;
  19. import org.apache.poi.util.LittleEndianOutput;
  20. /**
  21. * Record for the top margin.
  22. */
  23. public final class TopMarginRecord extends StandardRecord implements Margin {
  24. public static final short sid = 0x28;
  25. private double field_1_margin;
  26. public TopMarginRecord() {}
  27. public TopMarginRecord(TopMarginRecord other) {
  28. super(other);
  29. field_1_margin = other.field_1_margin;
  30. }
  31. /**
  32. * @param in the RecordInputstream to read the record from
  33. */
  34. public TopMarginRecord( RecordInputStream in ) {
  35. field_1_margin = in.readDouble();
  36. }
  37. public void serialize(LittleEndianOutput out) {
  38. out.writeDouble(field_1_margin);
  39. }
  40. protected int getDataSize() {
  41. return 8;
  42. }
  43. public short getSid() { return sid; }
  44. /**
  45. * Get the margin field for the TopMargin record.
  46. */
  47. public double getMargin() { return field_1_margin; }
  48. /**
  49. * Set the margin field for the TopMargin record.
  50. */
  51. public void setMargin( double field_1_margin )
  52. { this.field_1_margin = field_1_margin; }
  53. @Override
  54. public TopMarginRecord copy() {
  55. return new TopMarginRecord(this);
  56. }
  57. @Override
  58. public HSSFRecordTypes getGenericRecordType() {
  59. return HSSFRecordTypes.TOP_MARGIN;
  60. }
  61. @Override
  62. public Map<String, Supplier<?>> getGenericProperties() {
  63. return GenericRecordUtil.getGenericProperties("magin", this::getMargin);
  64. }
  65. }