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.

UserSViewBegin.java 2.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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.Arrays;
  17. import java.util.Map;
  18. import java.util.function.Supplier;
  19. import org.apache.poi.util.GenericRecordUtil;
  20. import org.apache.poi.util.LittleEndianOutput;
  21. /**
  22. * The UserSViewBegin record specifies settings for a custom view associated with the sheet.
  23. * This record also marks the start of custom view records, which save custom view settings.
  24. * Records between {@link UserSViewBegin} and {@link UserSViewEnd} contain settings for the custom view,
  25. * not settings for the sheet itself.
  26. */
  27. public final class UserSViewBegin extends StandardRecord {
  28. public static final short sid = 0x01AA;
  29. private byte[] _rawData;
  30. public UserSViewBegin(UserSViewBegin other) {
  31. super(other);
  32. _rawData = (other._rawData == null) ? null : other._rawData.clone();
  33. }
  34. public UserSViewBegin(byte[] data) {
  35. _rawData = data;
  36. }
  37. /**
  38. * construct an UserSViewBegin record. No fields are interpreted and the record will
  39. * be serialized in its original form more or less
  40. * @param in the RecordInputstream to read the record from
  41. */
  42. public UserSViewBegin(RecordInputStream in) {
  43. _rawData = in.readRemainder();
  44. }
  45. /**
  46. * spit the record out AS IS. no interpretation or identification
  47. */
  48. public void serialize(LittleEndianOutput out) {
  49. out.write(_rawData);
  50. }
  51. protected int getDataSize() {
  52. return _rawData.length;
  53. }
  54. public short getSid()
  55. {
  56. return sid;
  57. }
  58. /**
  59. * @return Globally unique identifier for the custom view
  60. */
  61. public byte[] getGuid(){
  62. return Arrays.copyOf(_rawData, 16);
  63. }
  64. @Override
  65. public UserSViewBegin copy() {
  66. return new UserSViewBegin(this);
  67. }
  68. @Override
  69. public HSSFRecordTypes getGenericRecordType() {
  70. return HSSFRecordTypes.USER_SVIEW_BEGIN;
  71. }
  72. @Override
  73. public Map<String, Supplier<?>> getGenericProperties() {
  74. return GenericRecordUtil.getGenericProperties(
  75. "guid", this::getGuid,
  76. "rawData", () -> _rawData
  77. );
  78. }
  79. }