1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package org.openoffice.xmerge.converter.xml.sxc.pexcel.records;
25 
26 import java.io.OutputStream;
27 import java.io.InputStream;
28 import java.io.IOException;
29 
30 
31 import org.openoffice.xmerge.util.Debug;
32 import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants;
33 
34 /**
35  * Represents a BIFF Record that describes a Boolean or Error value
36  */
37 public class BoolErrCell extends CellValue {
38 
39     private byte   bBoolErr;
40     private byte   fError;
41 
42  	/**
43 	 * Constructs a BoolErrCell from arguments
44  	 *
45 	 * @param row row number
46 	 * @param column column number
47 	 * @param ixfe font index
48 	 * @param bBoolErr Boolean value or error value
49 	 * @param fError Boolean error flag
50  	 */
BoolErrCell(int row, int column, int ixfe, int bBoolErr, int fError)51     public BoolErrCell(int row, int column, int ixfe, int bBoolErr, int fError) throws IOException {
52 
53 		setIxfe(ixfe);
54 		this.bBoolErr = (byte)bBoolErr;
55 		this.fError = (byte)fError;
56 		setRow(row);
57 		setCol(column);
58     }
59 
60 	/**
61 	 * Constructs a BoolErrCell from the <code>InputStream</code>
62  	 *
63  	 * @param	is InputStream containing a BoolErrCell
64  	 */
BoolErrCell(InputStream is)65     public BoolErrCell(InputStream is) throws IOException {
66 		read(is);
67     }
68 
69     /**
70 	 * Get the hex code for this particular <code>BIFFRecord</code>
71 	 *
72 	 * @return the hex code for <code>BoolErrCEll</code>
73 	 */
getBiffType()74     public short getBiffType() {
75         return PocketExcelConstants.BOOLERR_CELL;
76     }
77 
78     /**
79 	 * Writes a <code>BoolErrCell</code> to the specified <code>Outputstream</code>
80 	 *
81 	 * @param output the <code>OutputStream</code> to write to
82 	 */
write(OutputStream output)83     public void write(OutputStream output) throws IOException {
84 
85 		output.write(getBiffType());
86 
87 		super.write(output);
88 
89 		output.write(bBoolErr);
90 		output.write(fError);
91 
92 		Debug.log(Debug.TRACE,"Writing BoolErrCell record");
93     }
94 
95 	/**
96 	 * Reads a BoolErrCell from the <code>InputStream</code>
97  	 *
98  	 * @param	input InputStream containing a BoolErrCell
99  	 */
read(InputStream input)100     public int read(InputStream input) throws IOException {
101 
102         int numOfBytesRead = super.read(input);
103 
104         bBoolErr			= (byte) input.read();
105         fError				= (byte) input.read();
106    		numOfBytesRead += 2;
107 
108         Debug.log(Debug.TRACE, " bBoolErr : " + bBoolErr +
109                             " fError : " + fError);
110         return numOfBytesRead;
111     }
112 
113 	/**
114 	 * Gets the <code>String</code> representing the cells contents
115 	 *
116 	 * @return the <code>String</code> representing the cells contents
117 	 */
getString()118 	public String getString() throws IOException {
119         return ("Error Cell");
120 	}
121 }
122