001: /**
002: * ===========================================
003: * JFreeReport : a free Java reporting library
004: * ===========================================
005: *
006: * Project Info: http://reporting.pentaho.org/
007: *
008: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
009: *
010: * This library is free software; you can redistribute it and/or modify it under the terms
011: * of the GNU Lesser General Public License as published by the Free Software Foundation;
012: * either version 2.1 of the License, or (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
015: * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016: * See the GNU Lesser General Public License for more details.
017: *
018: * You should have received a copy of the GNU Lesser General Public License along with this
019: * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
020: * Boston, MA 02111-1307, USA.
021: *
022: * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
023: * in the United States and other countries.]
024: *
025: * ------------
026: * ApplyAutoCommitPageHeaderStep.java
027: * ------------
028: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
029: */package org.jfree.report.layout.process;
030:
031: import org.jfree.report.layout.model.LogicalPageBox;
032: import org.jfree.report.layout.model.ParagraphRenderBox;
033: import org.jfree.report.layout.model.RenderBox;
034: import org.jfree.report.layout.model.CanvasRenderBox;
035: import org.jfree.report.layout.model.BlockRenderBox;
036: import org.jfree.report.layout.model.InlineRenderBox;
037:
038: /**
039: * Marks the Page-Header as commited and as seen. Page-headers are generated on the fly and are not part of the
040: * common report-processing system. Therefore they must be printed as soon as there is some commitable content.
041: *
042: * @author Thomas Morgner
043: */
044: public class ApplyAutoCommitPageHeaderStep extends
045: IterateStructuralProcessStep {
046: private ApplyAutoCommitStep autoCommitStep;
047: private boolean hasCommitableContent;
048:
049: public ApplyAutoCommitPageHeaderStep() {
050: autoCommitStep = new ApplyAutoCommitStep();
051: }
052:
053: public boolean compute(final LogicalPageBox pageBox) {
054: hasCommitableContent = false;
055: processBoxChilds(pageBox);
056: if (hasCommitableContent) {
057: autoCommitStep.compute(pageBox.getWatermarkArea());
058: autoCommitStep.compute(pageBox.getHeaderArea());
059: return true;
060: } else {
061: return false;
062: }
063: }
064:
065: public void commitAll(final LogicalPageBox pageBox) {
066: processBoxChilds(pageBox);
067: autoCommitStep.compute(pageBox.getWatermarkArea());
068: autoCommitStep.compute(pageBox.getHeaderArea());
069: autoCommitStep.compute(pageBox.getFooterArea());
070: }
071:
072: protected void processParagraphChilds(final ParagraphRenderBox box) {
073: processBoxChilds(box);
074: }
075:
076: private boolean processBox(final RenderBox box) {
077: if (hasCommitableContent == true || box.isCommited()) {
078: hasCommitableContent = true;
079: return false;
080: }
081:
082: return true;
083: }
084:
085: protected boolean startCanvasBox(final CanvasRenderBox box) {
086: return processBox(box);
087: }
088:
089: protected boolean startBlockBox(final BlockRenderBox box) {
090: return processBox(box);
091: }
092:
093: protected boolean startInlineBox(final InlineRenderBox box) {
094: return processBox(box);
095: }
096:
097: protected boolean startOtherBox(final RenderBox box) {
098: return processBox(box);
099: }
100: }
|