1 19 20 package jxl.biff.drawing; 21 22 import common.Assert; 23 import common.Logger; 24 25 29 public class DrawingData implements EscherStream 30 { 31 34 private static Logger logger = Logger.getLogger(DrawingData.class); 35 36 39 private byte[] drawingData; 40 41 44 private int numDrawings; 45 46 49 private boolean initialized; 50 51 54 private EscherRecord[] spgrChildren; 55 56 59 public DrawingData() 60 { 61 numDrawings = 0; 62 drawingData = null; 63 initialized = false; 64 } 65 66 69 private void initialize() 70 { 71 EscherRecordData er = new EscherRecordData(this,0); 72 Assert.verify(er.isContainer()); 73 74 EscherContainer dgContainer = new EscherContainer(er); 75 EscherRecord[] children = dgContainer.getChildren(); 76 77 children = dgContainer.getChildren(); 78 80 EscherContainer spgrContainer = null; 81 82 for (int i = 0 ; i < children.length && spgrContainer == null; i++) 83 { 84 EscherRecord child = children[i]; 85 if (child.getType() == EscherRecordType.SPGR_CONTAINER) 86 { 87 spgrContainer = (EscherContainer) child; 88 } 89 } 90 Assert.verify(spgrContainer != null); 91 92 spgrChildren = spgrContainer.getChildren(); 93 initialized = true; 94 } 95 96 101 public void addData(byte[] data) 102 { 103 addRawData(data); 104 numDrawings++; 105 } 106 107 112 public void addRawData(byte[] data) 113 { 114 if (drawingData == null) 115 { 116 drawingData = data; 117 return; 118 } 119 120 byte[] newArray = new byte[drawingData.length + data.length]; 122 System.arraycopy(drawingData, 0, newArray, 0, drawingData.length); 123 System.arraycopy(data, 0, newArray, drawingData.length, data.length); 124 drawingData = newArray; 125 126 initialized = false; 128 } 129 130 135 final int getNumDrawings() 136 { 137 return numDrawings; 138 } 139 140 146 EscherContainer getSpContainer(int drawingNum) 147 { 148 if (!initialized) 149 { 150 initialize(); 151 } 152 153 EscherContainer spContainer = (EscherContainer)spgrChildren[drawingNum+1]; 154 155 Assert.verify(spContainer != null); 156 157 return spContainer; 158 } 159 160 165 public byte[] getData() 166 { 167 return drawingData; 168 } 169 } 170 | Popular Tags |