1 16 17 package org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements; 18 19 import org.apache.cocoon.components.elementprocessor.types.Attribute; 20 import org.apache.cocoon.components.elementprocessor.types.BooleanConverter; 21 import org.apache.cocoon.components.elementprocessor.types.BooleanResult; 22 import org.apache.cocoon.components.elementprocessor.types.NumericConverter; 23 import org.apache.cocoon.components.elementprocessor.types.NumericResult; 24 import org.apache.cocoon.components.elementprocessor.types.Validator; 25 26 import java.io.IOException ; 27 28 37 public class EPRowInfo extends BaseElementProcessor { 38 39 private NumericResult _no; 41 42 private NumericResult _unit; 44 45 private NumericResult _margin_a; 47 48 private NumericResult _margin_b; 50 51 private BooleanResult _hard_size; 53 54 private BooleanResult _hidden; 56 57 private BooleanResult _collapsed; 59 60 private NumericResult _outline_level; 62 63 private NumericResult _count; 65 private static final String _no_attribute = "No"; 66 private static final String _unit_attribute = "Unit"; 67 private static final String _margin_a_attribute = "MarginA"; 68 private static final String _margin_b_attribute = "MarginB"; 69 private static final String _hard_size_attribute = "HardSize"; 70 private static final String _hidden_attribute = "Hidden"; 71 private static final String _collapsed_attribute = "Collapsed"; 72 private static final String _outline_level_attribute = "OutlineLevel"; 73 private static final String _count_attribute = "Count"; 74 private static final Validator _margin_validator = new Validator() { 75 public IOException validate(final Number number) { 76 int val = number.intValue(); 77 78 return (val >= 0 && val <= 7) ? null 79 : new IOException ("\"" + number + "\" is not a legal value"); 80 } 81 }; 82 private static final Attribute[] _implied_attributes = 83 { 84 new Attribute(_hard_size_attribute, "0"), 85 new Attribute(_hidden_attribute, "0"), 86 new Attribute(_collapsed_attribute, "0"), 87 new Attribute(_outline_level_attribute, "0"), 88 new Attribute(_count_attribute, "1")}; 89 90 93 public EPRowInfo() { 94 super(_implied_attributes); 95 _no = null; 96 _unit = null; 97 _margin_a = null; 98 _margin_b = null; 99 _hard_size = null; 100 _hidden = null; 101 _collapsed = null; 102 _outline_level = null; 103 _count = null; 104 } 105 106 110 public int getRowNo() throws IOException { 111 if (_no == null) { 112 _no = 113 NumericConverter.extractNonNegativeInteger( 114 getValue(_no_attribute)); 115 } 116 return _no.intValue(); 117 } 118 119 123 public double getPoints() throws IOException { 124 if (_unit == null) { 125 _unit = NumericConverter.extractDouble(getValue(_unit_attribute)); 126 } 127 return _unit.doubleValue(); 128 } 129 130 134 public int getLeftMargin() throws IOException { 135 if (_margin_a == null) { 136 _margin_a = 137 NumericConverter.extractInteger( 138 getValue(_margin_a_attribute), 139 _margin_validator); 140 } 141 return _margin_a.intValue(); 142 } 143 144 148 public int getRightMargin() throws IOException { 149 if (_margin_b == null) { 150 _margin_b = 151 NumericConverter.extractInteger( 152 getValue(_margin_b_attribute), 153 _margin_validator); 154 } 155 return _margin_b.intValue(); 156 } 157 158 162 public boolean getHardSize() throws IOException { 163 if (_hard_size == null) { 164 _hard_size = 165 BooleanConverter.extractBoolean(getValue(_hard_size_attribute)); 166 } 167 return _hard_size.booleanValue(); 168 } 169 170 174 public boolean getHidden() throws IOException { 175 if (_hidden == null) { 176 _hidden = 177 BooleanConverter.extractBoolean(getValue(_hidden_attribute)); 178 } 179 return _hidden.booleanValue(); 180 } 181 182 186 public boolean getCollapsed() throws IOException { 187 if (_collapsed == null) { 188 _collapsed = 189 BooleanConverter.extractBoolean(getValue(_collapsed_attribute)); 190 } 191 return _collapsed.booleanValue(); 192 } 193 194 198 public int getOutlineLevel() throws IOException { 199 if (_outline_level == null) { 200 _outline_level = NumericConverter.extractInteger( 201 getValue(_outline_level_attribute)); 202 } 203 return _outline_level.intValue(); 204 } 205 206 210 public int getRLECount() throws IOException { 211 if (_count == null) { 212 _count = 213 NumericConverter.extractInteger(getValue(_count_attribute)); 214 } 215 return _count.intValue(); 216 } 217 218 222 public void endProcessing() throws IOException { 223 int row = getRowNo(); 224 225 if (row > Short.MAX_VALUE) { 226 throw new IOException ("Illegal row value: " + row); 227 } 228 getSheet().getRow(row).setHeight(getPoints()); 229 } 230 } | Popular Tags |