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:
18: package org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements;
19:
20: import org.apache.commons.lang.StringUtils;
21: import org.apache.poi.hssf.usermodel.HSSFPrintSetup;
22:
23: import java.io.IOException;
24:
25: /**
26: * No-op implementation of ElementProcessor to handle the "paper" tag
27: *
28: * This element contains no other elements and has no attributes. Its
29: * content describes the paper to be used (e.g., A4)
30: *
31: *
32: * @author Marc Johnson (marc_johnson27591@hotmail.com)
33: * @author Victor Skladov (skladov@his.de)
34: * @version CVS $Id: EP_Paper.java 433543 2006-08-22 06:22:54Z crossley $
35: */
36: public class EP_Paper extends BaseElementProcessor {
37:
38: private String _paper;
39:
40: /**
41: * constructor
42: */
43: public EP_Paper() {
44: super (null);
45: }
46:
47: public String getPaper() {
48: if (_paper == null) {
49: _paper = StringUtils.strip(this .getData());
50: }
51: return this ._paper;
52: }
53:
54: /**
55: * Setup the paper size (Letter, Legal, Executive, A4, A5, A6, ).
56: * Default Letter
57: * @exception IOException
58: */
59:
60: public void endProcessing() throws IOException {
61: _paper = getPaper();
62: Sheet sheet = this .getSheet();
63: short paperSize = HSSFPrintSetup.LETTER_PAPERSIZE;
64: if (StringUtils.isNotEmpty(_paper)) {
65: if ("A4".equalsIgnoreCase(_paper)) {
66: paperSize = HSSFPrintSetup.A4_PAPERSIZE;
67: } else if ("A5".equalsIgnoreCase(_paper)) {
68: paperSize = HSSFPrintSetup.A5_PAPERSIZE;
69: } else if ("Legal".equalsIgnoreCase(_paper)) {
70: paperSize = HSSFPrintSetup.LEGAL_PAPERSIZE;
71: } else if ("Executive".equalsIgnoreCase(_paper)) {
72: paperSize = HSSFPrintSetup.EXECUTIVE_PAPERSIZE;
73: }
74: }
75: sheet.setPaperSize(paperSize);
76: }
77:
78: } // end public class EP_Paper
|