1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 package com.sun.star.report.pentaho.parser.rpt; 24 25 import com.sun.star.report.pentaho.OfficeNamespaces; 26 27 import org.jfree.report.expressions.FormulaFunction; 28 import org.jfree.report.structure.Element; 29 30 import org.pentaho.reporting.libraries.xmlns.parser.AbstractXmlReadHandler; 31 32 import org.xml.sax.Attributes; 33 import org.xml.sax.SAXException; 34 35 /** 36 * Handles the 'report:conditional-print-expression' element that can appear 37 * in all report elements and all root-level sections. 38 * 39 * @author Thomas Morgner 40 * @since 02.03.2007 41 */ 42 public class ConditionalPrintExpressionReadHandler 43 extends AbstractXmlReadHandler 44 { 45 46 private final Element element; 47 ConditionalPrintExpressionReadHandler(final Element element)48 public ConditionalPrintExpressionReadHandler(final Element element) 49 { 50 this.element = element; 51 } 52 startParsing(final Attributes attrs)53 protected void startParsing(final Attributes attrs) throws SAXException 54 { 55 super.startParsing(attrs); 56 final String formula = attrs.getValue(OfficeNamespaces.OOREPORT_NS, "formula"); 57 if (formula != null) 58 { 59 final FormulaFunction valueExpression = new FormulaFunction(); 60 valueExpression.setFormula(formula); 61 element.setDisplayCondition(valueExpression); 62 } 63 64 } 65 66 /** 67 * Returns the object for this element or null, if this element does not 68 * create an object. 69 * 70 * @return the object. 71 */ getObject()72 public Object getObject() 73 throws SAXException 74 { 75 return element; 76 } 77 } 78