From 529a3492c58d2acb6ea3aa8b12beb51ab90b1aa6 Mon Sep 17 00:00:00 2001 From: Keiron Liddle Date: Thu, 18 Jul 2002 09:43:20 +0000 Subject: [PATCH] start page sequence with title git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@195004 13f79535-47bb-0310-9956-ffa450edef68 --- src/org/apache/fop/apps/LayoutHandler.java | 9 ++++++++ src/org/apache/fop/apps/StructureHandler.java | 2 +- src/org/apache/fop/fo/Title.java | 9 ++++++++ .../fop/fo/pagination/PageSequence.java | 22 ++++++++++++++----- src/org/apache/fop/mif/MIFHandler.java | 2 +- 5 files changed, 36 insertions(+), 8 deletions(-) diff --git a/src/org/apache/fop/apps/LayoutHandler.java b/src/org/apache/fop/apps/LayoutHandler.java index ba4bdc04a..d716982fe 100644 --- a/src/org/apache/fop/apps/LayoutHandler.java +++ b/src/org/apache/fop/apps/LayoutHandler.java @@ -12,6 +12,7 @@ import org.apache.fop.area.AreaTree; import org.apache.fop.area.Title; import org.apache.fop.render.Renderer; import org.apache.fop.fo.pagination.PageSequence; +import org.apache.fop.fo.pagination.LayoutMasterSet; import org.apache.avalon.framework.logger.Logger; @@ -143,6 +144,14 @@ public class LayoutHandler extends StructureHandler { //log.debug("Avg render time: " + (timeUsed / pageCount) + "ms/page"); } + public void startPageSequence(PageSequence pageSeq, org.apache.fop.fo.Title seqTitle, LayoutMasterSet lms) { + Title title = null; + if(seqTitle != null) { + title = seqTitle.getTitleArea(); + } + areaTree.startPageSequence(title); + } + /** Format the PageSequence. The PageSequence formats Pages and adds them to the AreaTree, diff --git a/src/org/apache/fop/apps/StructureHandler.java b/src/org/apache/fop/apps/StructureHandler.java index 4efbef2aa..74f858396 100644 --- a/src/org/apache/fop/apps/StructureHandler.java +++ b/src/org/apache/fop/apps/StructureHandler.java @@ -54,7 +54,7 @@ public class StructureHandler { } - public void startPageSequence(PageSequence pageSeq, LayoutMasterSet lms) { + public void startPageSequence(PageSequence pageSeq, Title seqTitle, LayoutMasterSet lms) { } diff --git a/src/org/apache/fop/fo/Title.java b/src/org/apache/fop/fo/Title.java index f099fa29f..ccbcaac83 100644 --- a/src/org/apache/fop/fo/Title.java +++ b/src/org/apache/fop/fo/Title.java @@ -23,6 +23,14 @@ public class Title extends ToBeImplementedElement { super(parent); } + public org.apache.fop.area.Title getTitleArea() { + org.apache.fop.area.Title title = + new org.apache.fop.area.Title(); + // use special layout manager to add the inline areas + // to the Title. + return title; + } + public void setup() { // Common Accessibility Properties @@ -57,3 +65,4 @@ public class Title extends ToBeImplementedElement { } } + diff --git a/src/org/apache/fop/fo/pagination/PageSequence.java b/src/org/apache/fop/fo/pagination/PageSequence.java index 2ff146c3a..e9c36a1f4 100644 --- a/src/org/apache/fop/fo/pagination/PageSequence.java +++ b/src/org/apache/fop/fo/pagination/PageSequence.java @@ -77,6 +77,9 @@ public class PageSequence extends FObj { // fo:flow per fo:page-sequence only. private boolean isFlowSet = false; + // for structure handler + private boolean sequenceStarted = false; + // // state attributes used during layout // @@ -128,7 +131,7 @@ public class PageSequence extends FObj { /** * The fo:title object for this page-sequence. */ - private FObj titleFO; + private Title titleFO; public PageSequence(FONode parent) { @@ -194,8 +197,6 @@ public class PageSequence extends FObj { // this.properties.get("country"); // this.properties.get("language"); setupID(); - - structHandler.startPageSequence(this, layoutMasterSet); } @@ -232,8 +233,11 @@ public class PageSequence extends FObj { if (childName.equals("fo:title")) { if (this._flowMap.size()>0) { log.warn("fo:title should be first in page-sequence"); + } else { + this.titleFO = (Title)child; + structHandler.startPageSequence(this, titleFO, layoutMasterSet); + sequenceStarted = true; } - this.titleFO = (FObj)child; } else if (childName.equals("fo:flow")) { if (this.mainFlow != null) { @@ -241,6 +245,10 @@ public class PageSequence extends FObj { + " per fo:page-sequence"); } else { + if(!sequenceStarted) { + structHandler.startPageSequence(this, titleFO, layoutMasterSet); + sequenceStarted = true; + } this.mainFlow = (Flow)child; addFlow(mainFlow); super.addChild(child); // For getChildren @@ -252,6 +260,10 @@ public class PageSequence extends FObj { " must precede fo:flow; ignoring"); } else { + if(!sequenceStarted) { + structHandler.startPageSequence(this, titleFO, layoutMasterSet); + sequenceStarted = true; + } addFlow((Flow)child); } } @@ -310,8 +322,6 @@ public class PageSequence extends FObj { // If no main flow, nothing to layout! if (this.mainFlow == null) return; - areaTree.startPageSequence(null); - // Initialize if already used? this.layoutMasterSet.resetPageMasters(); diff --git a/src/org/apache/fop/mif/MIFHandler.java b/src/org/apache/fop/mif/MIFHandler.java index d874c3052..2cf6bff19 100644 --- a/src/org/apache/fop/mif/MIFHandler.java +++ b/src/org/apache/fop/mif/MIFHandler.java @@ -74,7 +74,7 @@ public class MIFHandler extends StructureHandler { * This creates the pages in the MIF document that will be used * by the following flows and static areas. */ - public void startPageSequence(PageSequence pageSeq, LayoutMasterSet lms) { + public void startPageSequence(PageSequence pageSeq, Title seqTitle, LayoutMasterSet lms) { // get the layout master set // setup the pages for this sequence String name = pageSeq.getProperty("master-reference").getString(); -- 2.39.5