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 import org.openoffice.xmerge.util.Debug; 31 import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; 32 33 34 /** 35 * Represents a BIFF Record describing a number format 36 */ 37 public class NumberFormat implements BIFFRecord { 38 39 private byte cce; 40 private byte[] rgch; 41 42 /** 43 * Constructs a NumberFormat Record from the <code>InputStream</code> 44 * 45 * @param is InputStream containing the record data 46 */ NumberFormat(InputStream is)47 public NumberFormat(InputStream is) throws IOException { 48 read(is); 49 } 50 51 /** 52 * Get the hex code for this particular <code>BIFFRecord</code> 53 * 54 * @return the hex code for <code>NumberFormat</code> 55 */ getBiffType()56 public short getBiffType() { 57 return PocketExcelConstants.NUMBER_FORMAT; 58 } 59 60 /** 61 * Reads the NumberFormat from the <code>InputStream</code> Byte array 62 * containg strings are doubled in length becuse they use unicode 63 * 64 * @return the total number of bytes read 65 */ read(InputStream input)66 public int read(InputStream input) throws IOException { 67 68 cce = (byte) input.read(); 69 int numOfBytesRead = 1; 70 71 rgch = new byte[cce*2]; 72 numOfBytesRead += input.read(rgch, 0, cce*2); 73 74 Debug.log(Debug.TRACE, "\tcce : "+ cce + 75 " rgch : " + new String(rgch,"UTF-16LE")); 76 77 return numOfBytesRead; 78 } 79 write(OutputStream output)80 public void write(OutputStream output) throws IOException { 81 82 output.write(getBiffType()); 83 output.write(cce); 84 output.write(rgch); 85 86 Debug.log(Debug.TRACE,"Writing NumberFormat record"); 87 } 88 89 } 90