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.

HCenterRecord.java 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. * Whether to center between horizontal margins
  22. *
  23. * @version 2.0-pre
  24. */
  25. public final class HCenterRecord extends StandardRecord {
  26. public static final short sid = 0x0083;
  27. private short field_1_hcenter;
  28. public HCenterRecord() {}
  29. public HCenterRecord(HCenterRecord other) {
  30. super(other);
  31. field_1_hcenter = other.field_1_hcenter;
  32. }
  33. public HCenterRecord(RecordInputStream in) {
  34. field_1_hcenter = in.readShort();
  35. }
  36. /**
  37. * set whether or not to horizonatally center this sheet.
  38. * @param hc center - t/f
  39. */
  40. public void setHCenter(boolean hc) {
  41. field_1_hcenter = (short)(hc ? 1 : 0);
  42. }
  43. /**
  44. * get whether or not to horizonatally center this sheet.
  45. * @return center - t/f
  46. */
  47. public boolean getHCenter()
  48. {
  49. return (field_1_hcenter == 1);
  50. }
  51. public void serialize(LittleEndianOutput out) {
  52. out.writeShort(field_1_hcenter);
  53. }
  54. protected int getDataSize() {
  55. return 2;
  56. }
  57. public short getSid()
  58. {
  59. return sid;
  60. }
  61. @Override
  62. public HCenterRecord copy() {
  63. return new HCenterRecord(this);
  64. }
  65. @Override
  66. public HSSFRecordTypes getGenericRecordType() {
  67. return HSSFRecordTypes.H_CENTER;
  68. }
  69. @Override
  70. public Map<String, Supplier<?>> getGenericProperties() {
  71. return GenericRecordUtil.getGenericProperties("hcenter", this::getHCenter);
  72. }
  73. }