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 |
|
---|
9 | http://www.apache.org/licenses/LICENSE-2.0
|
---|
10 |
|
---|
11 | Unless required by applicable law or agreed to in writing, software
|
---|
12 | distributed under the License is distributed on an "AS IS" BASIS,
|
---|
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
14 | See the License for the specific language governing permissions and
|
---|
15 | limitations under the License.
|
---|
16 | ==================================================================== */
|
---|
17 |
|
---|
18 | package org.apache.poi.hssf.record;
|
---|
19 |
|
---|
20 | import org.apache.poi.util.HexDump;
|
---|
21 | import org.apache.poi.util.LittleEndianOutput;
|
---|
22 |
|
---|
23 | /**
|
---|
24 | * Specifies the window's zoom magnification. <p/>
|
---|
25 | * If this record isn't present then the windows zoom is 100%. see p384 Excel Dev Kit
|
---|
26 | *
|
---|
27 | * @author Andrew C. Oliver (acoliver at apache.org)
|
---|
28 | */
|
---|
29 | public final class SCLRecord extends StandardRecord {
|
---|
30 | public final static short sid = 0x00A0;
|
---|
31 | private short field_1_numerator;
|
---|
32 | private short field_2_denominator;
|
---|
33 |
|
---|
34 |
|
---|
35 | public SCLRecord()
|
---|
36 | {
|
---|
37 |
|
---|
38 | }
|
---|
39 |
|
---|
40 | public SCLRecord(RecordInputStream in) // NO_UCD
|
---|
41 | {
|
---|
42 | field_1_numerator = in.readShort();
|
---|
43 | field_2_denominator = in.readShort();
|
---|
44 | }
|
---|
45 |
|
---|
46 | public String toString()
|
---|
47 | {
|
---|
48 | StringBuffer buffer = new StringBuffer();
|
---|
49 |
|
---|
50 | buffer.append("[SCL]\n");
|
---|
51 | buffer.append(" .numerator = ")
|
---|
52 | .append("0x").append(HexDump.toHex( getNumerator ()))
|
---|
53 | .append(" (").append( getNumerator() ).append(" )");
|
---|
54 | buffer.append(System.getProperty("line.separator"));
|
---|
55 | buffer.append(" .denominator = ")
|
---|
56 | .append("0x").append(HexDump.toHex( getDenominator ()))
|
---|
57 | .append(" (").append( getDenominator() ).append(" )");
|
---|
58 | buffer.append(System.getProperty("line.separator"));
|
---|
59 |
|
---|
60 | buffer.append("[/SCL]\n");
|
---|
61 | return buffer.toString();
|
---|
62 | }
|
---|
63 |
|
---|
64 | public void serialize(LittleEndianOutput out) {
|
---|
65 | out.writeShort(field_1_numerator);
|
---|
66 | out.writeShort(field_2_denominator);
|
---|
67 | }
|
---|
68 |
|
---|
69 | protected int getDataSize() {
|
---|
70 | return 2 + 2;
|
---|
71 | }
|
---|
72 |
|
---|
73 | public short getSid()
|
---|
74 | {
|
---|
75 | return sid;
|
---|
76 | }
|
---|
77 |
|
---|
78 | public Object clone() {
|
---|
79 | SCLRecord rec = new SCLRecord();
|
---|
80 |
|
---|
81 | rec.field_1_numerator = field_1_numerator;
|
---|
82 | rec.field_2_denominator = field_2_denominator;
|
---|
83 | return rec;
|
---|
84 | }
|
---|
85 |
|
---|
86 |
|
---|
87 |
|
---|
88 |
|
---|
89 | /**
|
---|
90 | * Get the numerator field for the SCL record.
|
---|
91 | */
|
---|
92 | public short getNumerator()
|
---|
93 | {
|
---|
94 | return field_1_numerator;
|
---|
95 | }
|
---|
96 |
|
---|
97 |
|
---|
98 | /**
|
---|
99 | * Get the denominator field for the SCL record.
|
---|
100 | */
|
---|
101 | public short getDenominator()
|
---|
102 | {
|
---|
103 | return field_2_denominator;
|
---|
104 | }
|
---|
105 |
|
---|
106 | }
|
---|