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.

VCenterRecord.java 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 org.apache.poi.util.LittleEndianOutput;
  17. /**
  18. * Title: VCenter record<P>
  19. * Description: tells whether to center the sheet between vertical margins<P>
  20. * REFERENCE: PG 420 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P>
  21. * @author Andrew C. Oliver (acoliver at apache dot org)
  22. * @author Jason Height (jheight at chariot dot net dot au)
  23. * @version 2.0-pre
  24. */
  25. public final class VCenterRecord extends StandardRecord {
  26. public final static short sid = 0x84;
  27. private int field_1_vcenter;
  28. public VCenterRecord()
  29. {
  30. }
  31. public VCenterRecord(RecordInputStream in)
  32. {
  33. field_1_vcenter = in.readShort();
  34. }
  35. /**
  36. * set whether to center vertically or not
  37. * @param hc vcenter or not
  38. */
  39. public void setVCenter(boolean hc)
  40. {
  41. field_1_vcenter = hc ? 1 : 0;
  42. }
  43. /**
  44. * get whether to center vertically or not
  45. * @return vcenter or not
  46. */
  47. public boolean getVCenter()
  48. {
  49. return (field_1_vcenter == 1);
  50. }
  51. public String toString()
  52. {
  53. StringBuffer buffer = new StringBuffer();
  54. buffer.append("[VCENTER]\n");
  55. buffer.append(" .vcenter = ").append(getVCenter())
  56. .append("\n");
  57. buffer.append("[/VCENTER]\n");
  58. return buffer.toString();
  59. }
  60. public void serialize(LittleEndianOutput out) {
  61. out.writeShort(field_1_vcenter);
  62. }
  63. protected int getDataSize() {
  64. return 2;
  65. }
  66. public short getSid()
  67. {
  68. return sid;
  69. }
  70. public Object clone() {
  71. VCenterRecord rec = new VCenterRecord();
  72. rec.field_1_vcenter = field_1_vcenter;
  73. return rec;
  74. }
  75. }