001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements;
019:
020: import org.apache.cocoon.components.elementprocessor.types.Attribute;
021: import org.apache.cocoon.CascadingIOException;
022: import org.apache.cocoon.components.elementprocessor.ElementProcessor;
023: import org.apache.cocoon.components.elementprocessor.types.BooleanConverter;
024: import org.apache.cocoon.components.elementprocessor.types.BooleanResult;
025:
026: import java.io.IOException;
027:
028: /**
029: * No-op implementation of ElementProcessor to handle the "Sheet" tag
030: *
031: * This element contains other elements and has the following boolean
032: * attributes:
033: * <ul>
034: * <li>DisplayFormulas
035: * <li>HideZero
036: * <li>HideGrid
037: * <li>HideColHeader
038: * <li>HideRowHeader
039: * <li>DisplayOutlines
040: * <li>OutlineSymbolsBelow
041: * <li>OutlineSymbolsRight
042: * </ul>
043: *
044: * @author Marc Johnson (marc_johnson27591@hotmail.com)
045: * @author Andrew C. Oliver (acoliver2@users.sourceforge.net)
046: * @version CVS $Id: EPSheet.java 433543 2006-08-22 06:22:54Z crossley $
047: */
048: public class EPSheet extends BaseElementProcessor {
049: private Sheet _sheet;
050: private BooleanResult _display_formulas;
051: private BooleanResult _hide_zero;
052: private BooleanResult _hide_grid;
053: private BooleanResult _hide_col_header;
054: private BooleanResult _hide_row_header;
055: private BooleanResult _display_outlines;
056: private BooleanResult _outline_symbols_below;
057: private BooleanResult _outline_symbols_right;
058: private static final String _display_formulas_attribute = "DisplayFormulas";
059: private static final String _hide_zero_attribute = "HideZero";
060: private static final String _hide_grid_attribute = "HideGrid";
061: private static final String _hide_col_header_attribute = "HideColHeader";
062: private static final String _hide_row_header_attribute = "HideRowHeader";
063: private static final String _display_outlines_attribute = "DisplayOutlines";
064: private static final String _outline_symbols_below_attribute = "OutlineSymbolsBelow";
065: private static final String _outline_symbols_right_attribute = "OutlineSymbolsRight";
066:
067: /**
068: * constructor
069: */
070:
071: public EPSheet() {
072: super (null);
073: _display_formulas = null;
074: _hide_zero = null;
075: _hide_grid = null;
076: _hide_col_header = null;
077: _hide_row_header = null;
078: _display_outlines = null;
079: _outline_symbols_below = null;
080: _outline_symbols_right = null;
081: }
082:
083: /**
084: * Override of Initialize() implementation
085: * @param attributes the array of Attribute instances; may be empty, will
086: * never be null
087: * @param parent the parent ElementProcessor; may be null
088: * @exception IOException if anything is wrong
089: */
090: public void initialize(final Attribute[] attributes,
091: final ElementProcessor parent) throws IOException {
092: super .initialize(attributes, parent);
093: try {
094: _sheet = new Sheet(getWorkbook());
095: } catch (IOException e) {
096: throw e;
097: } catch (Exception e) {
098: throw new CascadingIOException(e.getMessage(), e);
099: }
100: }
101:
102: /**
103: * override of endProcessing(). Reponsible for fixing style regions with
104: * blank cells.
105: * @exception IOException
106: */
107: public void endProcessing() throws IOException {
108: _sheet.assignBlanksToRegions();
109: }
110:
111: /**
112: * override of getSheet()
113: * @return the sheet
114: */
115: protected Sheet getSheet() {
116: return _sheet;
117: }
118:
119: /**
120: * @return true if formulas should be displayed
121: * @exception IOException if attribute is missing or malformed
122: */
123: public boolean getDisplayFormulas() throws IOException {
124: if (_display_formulas == null) {
125: _display_formulas = BooleanConverter
126: .extractBoolean(getValue(_display_formulas_attribute));
127: }
128: return _display_formulas.booleanValue();
129: }
130:
131: /**
132: * @return true if zeroes should be suppressed
133: * @exception IOException if attribute is missing or malformed
134: */
135: public boolean getHideZero() throws IOException {
136: if (_hide_zero == null) {
137: _hide_zero = BooleanConverter
138: .extractBoolean(getValue(_hide_zero_attribute));
139: }
140: return _hide_zero.booleanValue();
141: }
142:
143: /**
144: * @return true if grid should be hidden
145: * @exception IOException if attribute is missing or malformed
146: */
147: public boolean getHideGrid() throws IOException {
148: if (_hide_grid == null) {
149: _hide_grid = BooleanConverter
150: .extractBoolean(getValue(_hide_grid_attribute));
151: }
152: return _hide_grid.booleanValue();
153: }
154:
155: /**
156: * @return true if column headers should be hidden
157: * @exception IOException if attribute is missing or malformed
158: */
159: public boolean getHideColHeader() throws IOException {
160: if (_hide_col_header == null) {
161: _hide_col_header = BooleanConverter
162: .extractBoolean(getValue(_hide_col_header_attribute));
163: }
164: return _hide_col_header.booleanValue();
165: }
166:
167: /**
168: * @return true if row headers should be hidden
169: * @exception IOException if attribute is missing or malformed
170: */
171: public boolean getHideRowHeader() throws IOException {
172: if (_hide_row_header == null) {
173: _hide_row_header = BooleanConverter
174: .extractBoolean(getValue(_hide_row_header_attribute));
175: }
176: return _hide_row_header.booleanValue();
177: }
178:
179: /**
180: * @return true if outlines should be displayed
181: * @exception IOException if attribute is missing or malformed
182: */
183: public boolean getDisplayOutlines() throws IOException {
184: if (_display_outlines == null) {
185: _display_outlines = BooleanConverter
186: .extractBoolean(getValue(_display_outlines_attribute));
187: }
188: return _display_outlines.booleanValue();
189: }
190:
191: /**
192: * @return true if outline symbols are below
193: * @exception IOException if attribute is missing or malformed
194: */
195: public boolean getOutlineSymbolsBelow() throws IOException {
196: if (_outline_symbols_below == null) {
197: _outline_symbols_below = BooleanConverter
198: .extractBoolean(getValue(_outline_symbols_below_attribute));
199: }
200: return _outline_symbols_below.booleanValue();
201: }
202:
203: /**
204: * @return true if outline symbols are on the right
205: * @exception IOException if attribute is missing or malformed
206: */
207: public boolean getOutlineSymbolsRight() throws IOException {
208: if (_outline_symbols_right == null) {
209: _outline_symbols_right = BooleanConverter
210: .extractBoolean(getValue(_outline_symbols_right_attribute));
211: }
212: return _outline_symbols_right.booleanValue();
213: }
214: } // end public class EPSheet
|