01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
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.ElementProcessor;
21: import org.apache.cocoon.components.elementprocessor.types.NumericConverter;
22: import org.apache.cocoon.components.elementprocessor.types.NumericResult;
23:
24: import java.io.IOException;
25:
26: /**
27: * No-op implementation of ElementProcessor to handle the "Rows" tag
28: *
29: * This element has an attribute (DefaultSizePts) and is a container
30: * element
31: *
32: * @author Marc Johnson (marc_johnson27591@hotmail.com)
33: * @version CVS $Id: EPRows.java 433543 2006-08-22 06:22:54Z crossley $
34: */
35: public class EPRows extends BaseElementProcessor {
36: private NumericResult _default_size_pts;
37: private static final String _default_size_pts_attribute = "DefaultSizePts";
38:
39: // package scope so test code can see it
40: static final String DEFAULT_SIZE_PTS = "12.8";
41:
42: /**
43: * constructor
44: */
45: public EPRows() {
46: super (null);
47: _default_size_pts = null;
48: }
49:
50: /**
51: * get the default size of rows, in points
52: * @return size in points
53: * @exception IOException if the attribute is missing or malformed
54: */
55: public double getDefaultSizePts() throws IOException {
56: if (_default_size_pts == null) {
57: String value = getValue(_default_size_pts_attribute);
58:
59: if (value == null || value.trim().length() == 0) {
60: value = DEFAULT_SIZE_PTS;
61: }
62: _default_size_pts = NumericConverter.extractDouble(value);
63: }
64: return _default_size_pts.doubleValue();
65: }
66:
67: /**
68: * Override of Initialize() implementation
69: * @param attributes the array of Attribute instances; may be empty, will
70: * never be null
71: * @param parent the parent ElementProcessor; may be null
72: * @exception IOException if anything is wrong
73: */
74: public void initialize(final Attribute[] attributes,
75: final ElementProcessor parent) throws IOException {
76: super .initialize(attributes, parent);
77: getSheet().setDefaultRowHeight(getDefaultSizePts());
78: }
79: } // end public class EPRows
|