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.util.EndianConverter; 32 import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; 33 34 /** 35 * Represents a BIFF record defining the default column width 36 */ 37 public class DefColWidth implements BIFFRecord { 38 39 private byte[] grbit = new byte[2]; 40 private byte[] coldx = new byte[2]; 41 private byte[] ixfe = new byte[2]; 42 DefColWidth()43 public DefColWidth() { 44 grbit = new byte[] {0x00, 0x00}; 45 coldx = new byte[] {0x00, 0x09}; 46 ixfe = new byte[] {0x00, 0x00}; 47 } 48 49 /** 50 * Constructs a pocket Excel Document from the 51 * <code>InputStream</code> and assigns it the document name passed in 52 * 53 * @param is InputStream containing a Pocket Excel Data file. 54 */ DefColWidth(InputStream is)55 public DefColWidth(InputStream is) throws IOException { 56 read(is); 57 } 58 59 /** 60 * Get the hex code for this particular <code>BIFFRecord</code> 61 * 62 * @return the hex code for <code>DefColWidth</code> 63 */ getBiffType()64 public short getBiffType() { 65 return PocketExcelConstants.DEF_COL_WIDTH; 66 } 67 write(OutputStream output)68 public void write(OutputStream output) throws IOException { 69 70 output.write(getBiffType()); 71 output.write(grbit); 72 output.write(coldx); 73 output.write(ixfe); 74 75 Debug.log(Debug.TRACE, "Writing DefColWidth record"); 76 } 77 read(InputStream input)78 public int read(InputStream input) throws IOException { 79 80 int numOfBytesRead = input.read(grbit); 81 numOfBytesRead += input.read(coldx); 82 numOfBytesRead += input.read(ixfe); 83 84 Debug.log(Debug.TRACE,"\tgrbit : "+ EndianConverter.readShort(grbit) + 85 " coldx : " + EndianConverter.readShort(coldx) + 86 " ixfe : " + EndianConverter.readShort(ixfe)); 87 return 0; 88 } 89 90 } 91