xmlgraphics-fop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerem...@apache.org
Subject svn commit: r358254 - in /xmlgraphics/fop/trunk/src/java/org/apache/fop: area/ area/inline/ layoutmgr/ render/ps/
Date Wed, 21 Dec 2005 10:21:12 GMT
Author: jeremias
Date: Wed Dec 21 02:20:56 2005
New Revision: 358254

URL: http://svn.apache.org/viewcvs?rev=358254&view=rev
Log:
Further decoupling the area tree from the FO tree.
Created a new class org.apache.fop.layoutmgr.Page that holds a reference to the generating
SimplePageMaster and the PageViewport. A deserialized area tree doesn't need a reference to
the SimplePageMaster.
Renamed PageViewportProvider to PageProvider as it now returns Page instances, not (directly)
PageViewports.

Added:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/Page.java   (with props)
Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/area/Page.java   (contents, props changed)
    xmlgraphics/fop/trunk/src/java/org/apache/fop/area/PageViewport.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java  
(contents, props changed)
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSRenderer.java

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/area/Page.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/area/Page.java?rev=358254&r1=358253&r2=358254&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/area/Page.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/area/Page.java Wed Dec 21 02:20:56 2005
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2005 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,15 +14,15 @@
  * limitations under the License.
  */
 
-/* $Id: Page.java,v 1.4 2004/02/27 17:41:26 jeremias Exp $ */
+/* $Id$ */
 
 package org.apache.fop.area;
 
 import java.awt.Rectangle;
 import java.awt.geom.Rectangle2D;
 import java.io.Serializable;
-import java.util.HashMap;
 import java.util.Iterator;
+import java.util.Map;
 
 import org.apache.fop.datatypes.FODimension;
 import org.apache.fop.datatypes.LengthBase;
@@ -54,7 +54,7 @@
     private RegionViewport regionAfter = null;
 
     // temporary map of unresolved objects used when serializing the page
-    private HashMap unresolved = null;
+    private Map unresolved = null;
 
     /** Set to true to make this page behave as if it were not empty. */
     private boolean fakeNonEmpty = false;
@@ -269,9 +269,9 @@
     /**
      * Set the unresolved references on this page for serializing.
      *
-     * @param unres the HashMap of unresolved objects
+     * @param unres the Map of unresolved objects
      */
-    public void setUnresolvedReferences(HashMap unres) {
+    public void setUnresolvedReferences(Map unres) {
         unresolved = unres;
     }
 
@@ -282,7 +282,7 @@
      *
      * @return the de-serialized HashMap of unresolved objects
      */
-    public HashMap getUnresolvedReferences() {
+    public Map getUnresolvedReferences() {
         return unresolved;
     }
 

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/area/Page.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/area/PageViewport.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/area/PageViewport.java?rev=358254&r1=358253&r2=358254&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/area/PageViewport.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/area/PageViewport.java Wed Dec 21 02:20:56
2005
@@ -46,19 +46,18 @@
 
     private Page page;
     private Rectangle2D viewArea;
-    private boolean clip = false;
+    private String simplePageMasterName;
     private String pageNumberString = null;
     private int pageIndex = -1; //-1 = undetermined
-    private SimplePageMaster spm = null;
     private boolean blank;
 
     // list of id references and the rectangle on the page
-    private Map idReferences = null;
+    //private Map idReferences = null;
 
     // this keeps a list of currently unresolved areas or extensions
     // once an idref is resolved it is removed
     // when this is empty the page can be rendered
-    private HashMap unresolvedIDRefs = new HashMap();
+    private Map unresolvedIDRefs = new java.util.HashMap();
 
     private Map pendingResolved = null;
 
@@ -69,6 +68,10 @@
     private Map markerFirstAny = null;
     private Map markerLastEnd = null;
     private Map markerLastAny = null;
+    
+    //Arbitrary attachments to the page from extensions that need to pass information
+    //down to the renderers.
+    private List extensionAttachments = null;
 
     /**
      * logging instance
@@ -82,7 +85,8 @@
      * @param blank true if this is a blank page
      */
     public PageViewport(SimplePageMaster spm, String pageStr, boolean blank) {
-        this.spm = spm;
+        this.simplePageMasterName = spm.getMasterName();
+        this.extensionAttachments = spm.getExtensionAttachments();
         this.blank = blank;
         int pageWidth = spm.getPageWidth().getValue();
         int pageHeight = spm.getPageHeight().getValue();
@@ -93,25 +97,14 @@
     }
 
     /**
-     * Create a page viewport 
-     * @param spm SimplePageMaster indicating the page and region dimensions
-     * @param pageStr the page number as string.
-     * @param p Page Reference Area
-     * @param bounds Page Viewport dimensions
+     * Copy constructor. 
+     * @param original the original PageViewport to copy from
      */
-    public PageViewport(SimplePageMaster spm, String pageStr, Page p, Rectangle2D bounds)
{
-        this.spm = spm;
-        this.pageNumberString = pageStr;
-        this.page = p;
-        this.viewArea = bounds;
-    }
-
-    /**
-     * Set if this viewport should clip.
-     * @param c true if this viewport should clip
-     */
-    public void setClip(boolean c) {
-        clip = c;
+    public PageViewport(PageViewport original) {
+        this.extensionAttachments = new java.util.ArrayList(original.extensionAttachments);
+        this.pageNumberString = original.pageNumberString;
+        this.page = (Page)original.page.clone();
+        this.viewArea = (Rectangle2D)original.viewArea.clone();
     }
 
     /**
@@ -280,11 +273,17 @@
                     Object key = iter.next();
                     if (!markerFirstStart.containsKey(key)) {
                         markerFirstStart.put(key, marks.get(key));
-                        log.trace("page " + pageNumberString + ": " + "Adding marker " +
key + " to FirstStart");
+                        if (log.isTraceEnabled()) {
+                            log.trace("page " + pageNumberString + ": " 
+                                    + "Adding marker " + key + " to FirstStart");
+                        }
                     }
                     if (!markerFirstAny.containsKey(key)) {
                         markerFirstAny.put(key, marks.get(key));
-                        log.trace("page " + pageNumberString + ": " + "Adding marker " +
key + " to FirstAny");
+                        if (log.isTraceEnabled()) {
+                            log.trace("page " + pageNumberString + ": " 
+                                    + "Adding marker " + key + " to FirstAny");
+                        }
                     }
                 }
                 if (markerLastStart == null) {
@@ -292,7 +291,10 @@
                 }
                 // last on page: replace all
                 markerLastStart.putAll(marks);
-                log.trace("page " + pageNumberString + ": " + "Adding all markers to LastStart");
+                if (log.isTraceEnabled()) {
+                    log.trace("page " + pageNumberString + ": " 
+                            + "Adding all markers to LastStart");
+                }
             } else {
                 if (markerFirstAny == null) {
                     markerFirstAny = new HashMap();
@@ -302,7 +304,10 @@
                     Object key = iter.next();
                     if (!markerFirstAny.containsKey(key)) {
                         markerFirstAny.put(key, marks.get(key));
-                        log.trace("page " + pageNumberString + ": " + "Adding marker " +
key + " to FirstAny");
+                        if (log.isTraceEnabled()) {
+                            log.trace("page " + pageNumberString + ": " 
+                                    + "Adding marker " + key + " to FirstAny");
+                        }
                     }
                 }
             }
@@ -314,14 +319,20 @@
                 }
                 // last on page: replace all
                 markerLastEnd.putAll(marks);
-                log.trace("page " + pageNumberString + ": " + "Adding all markers to LastEnd");
+                if (log.isTraceEnabled()) {
+                    log.trace("page " + pageNumberString + ": " 
+                            + "Adding all markers to LastEnd");
+                }
             }
             if (markerLastAny == null) {
                 markerLastAny = new HashMap();
             }
             // last on page: replace all
             markerLastAny.putAll(marks);
-            log.trace("page " + pageNumberString + ": " + "Adding all markers to LastAny");
+            if (log.isTraceEnabled()) {
+                log.trace("page " + pageNumberString + ": " 
+                        + "Adding all markers to LastAny");
+            }
         }
     }
 
@@ -436,11 +447,7 @@
      * @return a copy of this page and associated viewports
      */
     public Object clone() {
-        Page p = (Page)page.clone();
-        PageViewport ret = new PageViewport(spm, pageNumberString, 
-                p, (Rectangle2D)viewArea.clone());
-        ret.pageNumberString = pageNumberString;
-        return ret;
+        return new PageViewport(this);
     }
 
     /**
@@ -461,11 +468,15 @@
         sb.append(getPageNumberString());
         return sb.toString();
     }
-    /**
-     * @return Returns the spm.
-     */
-    public SimplePageMaster getSPM() {
-        return spm;
+    
+    /** @return the name of the simple-page-master that created this page */
+    public String getSimplePageMasterName() {
+        return this.simplePageMasterName;
+    }
+    
+    /** @return the list of extension attachments for this page */
+    public List getExtensionAttachments() {
+        return this.extensionAttachments;
     }
     
     /** @return True if this is a blank page. */

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java?rev=358254&r1=358253&r2=358254&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java Wed
Dec 21 02:20:56 2005
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2005 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,11 +30,14 @@
  * from an id reference.
  */
 public class UnresolvedPageNumber extends TextArea implements Resolvable {
+
     private boolean resolved = false;
     private String pageIDRef;
-    private Font font;
     private String text;
 
+    //Transient fields
+    private transient Font font;
+    
     /**
      * Create a new unresolvable page number.
      *
@@ -74,7 +77,7 @@
             removeText();
             addWord(page.getPageNumberString(), 0);
             // update ipd
-            updateIPD(getStringWidth(text));
+            updateIPD(font.getWordWidth(text));
             // set the Font object to null, as we don't need it any more
             font = null;
         }
@@ -101,15 +104,4 @@
         return true;
     }
 
-    /**
-     * @param str string to be measured
-     * @return width of the string
-     */
-    private int getStringWidth(String str) {
-        int width = 0;
-        for (int count = 0; count < str.length(); count++) {
-            width += font.getCharWidth(str.charAt(count));
-        }
-        return width;
-    }
 }

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java?rev=358254&r1=358253&r2=358254&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java Wed Dec 21
02:20:56 2005
@@ -115,12 +115,12 @@
     }
 
     /**
-     * Returns the PageViewportProvider if any. PageBreaker overrides this method because
each
+     * Returns the PageProvider if any. PageBreaker overrides this method because each
      * page may have a different available BPD which needs to be accessible to the breaking
      * algorithm.
-     * @return the applicable PageViewportProvider, or null if not applicable
+     * @return the applicable PageProvider, or null if not applicable
      */
-    protected PageSequenceLayoutManager.PageViewportProvider getPageViewportProvider() {
+    protected PageSequenceLayoutManager.PageProvider getPageProvider() {
         return null;
     }
     
@@ -222,7 +222,7 @@
                 log.debug("PLM> start of algorithm (" + this.getClass().getName() 
                         + "), flow BPD =" + flowBPD);
                 PageBreakingAlgorithm alg = new PageBreakingAlgorithm(getTopLevelLM(),
-                        getPageViewportProvider(),
+                        getPageProvider(),
                         alignment, alignmentLast, footnoteSeparatorLength,
                         isPartOverflowRecoveryActivated());
                 int iOptPageCount;

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java?rev=358254&r1=358253&r2=358254&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java Wed
Dec 21 02:20:56 2005
@@ -264,10 +264,15 @@
     }
     
     /**
-     * @see org.apache.fop.layoutmgr.PageSequenceLayoutManager#getCurrentPV
+     * @see org.apache.fop.layoutmgr.PageSequenceLayoutManager#getCurrentPage
      */
+    public Page getCurrentPage() {
+        return getPSLM().getCurrentPage();
+    }  
+    
+    /** @return the current page viewport */
     public PageViewport getCurrentPV() {
-        return getPSLM().getCurrentPV();
+        return getPSLM().getCurrentPage().getPageViewport();
     }  
     
     /**

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java?rev=358254&r1=358253&r2=358254&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java
Wed Dec 21 02:20:56 2005
@@ -35,12 +35,12 @@
     private int idealPartLen;
     
     public BalancingColumnBreakingAlgorithm(LayoutManager topLevelLM,
-            PageSequenceLayoutManager.PageViewportProvider pvProvider,
+            PageSequenceLayoutManager.PageProvider pageProvider,
             int alignment, int alignmentLast,
             MinOptMax footnoteSeparatorLength,
             boolean partOverflowRecovery,
             int columnCount) {
-        super(topLevelLM, pvProvider, alignment, alignmentLast, 
+        super(topLevelLM, pageProvider, alignment, alignmentLast, 
                 footnoteSeparatorLength, partOverflowRecovery);
         this.columnCount = columnCount;
         this.considerTooShort = true; //This is important!

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java?rev=358254&r1=358253&r2=358254&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java Wed Dec
21 02:20:56 2005
@@ -92,7 +92,7 @@
             LayoutContext childLC = new LayoutContext(0);
             childLC.setStackLimit(context.getStackLimit());
             childLC.setRefIPD(context.getRefIPD());
-            childLC.setWritingMode(getCurrentPV().getSPM().getWritingMode());
+            childLC.setWritingMode(getCurrentPage().getSimplePageMaster().getWritingMode());
             
             // get elements from curLM
             returnedList = curLM.getNextKnuthElements(childLC, alignment);

Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/Page.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/Page.java?rev=358254&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/Page.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/Page.java Wed Dec 21 02:20:56
2005
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.layoutmgr;
+
+import org.apache.fop.area.PageViewport;
+import org.apache.fop.fo.pagination.SimplePageMaster;
+
+/**
+ * This object is used by the layout engine to represent a page. It provides access to the
+ * simple-page-master that was used as a template for this page and it provides access to
the
+ * PageViewport which is the top-level area tree element. This class helps to decouple the
+ * FO tree from the area tree to make the latter easily serializable.
+ */
+public class Page {
+
+    private SimplePageMaster spm;
+    private PageViewport pageViewport;
+    
+    public Page(SimplePageMaster spm, String pageStr, boolean blank) {
+        this.spm = spm;
+        this.pageViewport = new PageViewport(spm, pageStr, blank);
+    }
+    
+    public SimplePageMaster getSimplePageMaster() {
+        return this.spm;
+    }
+    
+    public PageViewport getPageViewport() {
+        return this.pageViewport;
+    }
+    
+}

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/Page.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java?rev=358254&r1=358253&r2=358254&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java Wed
Dec 21 02:20:56 2005
@@ -31,7 +31,7 @@
 class PageBreakingAlgorithm extends BreakingAlgorithm {
 
     private LayoutManager topLevelLM;
-    private PageSequenceLayoutManager.PageViewportProvider pageViewportProvider;
+    private PageSequenceLayoutManager.PageProvider pageProvider;
     private LinkedList pageBreaks = null;
 
     private ArrayList footnotesList = null;
@@ -66,13 +66,13 @@
     private boolean storedValue = false;
 
     public PageBreakingAlgorithm(LayoutManager topLevelLM,
-                                 PageSequenceLayoutManager.PageViewportProvider pageViewportProvider,
+                                 PageSequenceLayoutManager.PageProvider pageProvider,
                                  int alignment, int alignmentLast,
                                  MinOptMax footnoteSeparatorLength,
                                  boolean partOverflowRecovery) {
         super(alignment, alignmentLast, true, partOverflowRecovery, 0);
         this.topLevelLM = topLevelLM;
-        this.pageViewportProvider = pageViewportProvider;
+        this.pageProvider = pageProvider;
         best = new BestPageRecords();
         this.footnoteSeparatorLength = (MinOptMax) footnoteSeparatorLength.clone();
         // add some stretch, to avoid a restart for every page containing footnotes
@@ -798,8 +798,8 @@
     /** @see org.apache.fop.layoutmgr.BreakingAlgorithm#getLineWidth(int) */
     protected int getLineWidth(int line) {
         int bpd;
-        if (pageViewportProvider != null) {
-            bpd = pageViewportProvider.getAvailableBPD(line);
+        if (pageProvider != null) {
+            bpd = pageProvider.getAvailableBPD(line);
         } else {
             bpd = super.getLineWidth(line);
         }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java?rev=358254&r1=358253&r2=358254&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
Wed Dec 21 02:20:56 2005
@@ -69,13 +69,13 @@
      */
     private PageSequence pageSeq;
 
-    private PageViewportProvider pvProvider;
+    private PageProvider pageProvider;
     
     /** 
-     * Current page-viewport-area being filled by
+     * Current page with page-viewport-area being filled by
      * the PSLM.
      */
-    private PageViewport curPV = null;
+    private Page curPage = null;
 
     /**
      * The FlowLayoutManager object, which processes
@@ -98,7 +98,7 @@
         super(pseq);
         this.areaTreeHandler = ath;
         this.pageSeq = pseq;
-        this.pvProvider = new PageViewportProvider(this.pageSeq);
+        this.pageProvider = new PageProvider(this.pageSeq);
     }
 
     /**
@@ -109,9 +109,9 @@
         return areaTreeHandler.getLayoutManagerMaker();
     }
 
-    /** @return the PageViewportProvider applicable to this page-sequence. */
-    public PageViewportProvider getPageViewportProvider() {
-        return this.pvProvider;
+    /** @return the PageProvider applicable to this page-sequence. */
+    public PageProvider getPageProvider() {
+        return this.pageProvider;
     }
     
     /**
@@ -135,7 +135,7 @@
         areaTreeHandler.getAreaTreeModel().startPageSequence(title);
         log.debug("Starting layout");
 
-        curPV = makeNewPage(false, false);
+        curPage = makeNewPage(false, false);
 
         addIDToPage(pageSeq.getId());
         Flow mainFlow = pageSeq.getMainFlow();
@@ -143,7 +143,7 @@
             makeFlowLayoutManager(this, mainFlow);
 
         PageBreaker breaker = new PageBreaker(this);
-        int flowBPD = (int) curPV.getBodyRegion().getRemainingBPD();
+        int flowBPD = (int)getCurrentPV().getBodyRegion().getRemainingBPD();
         breaker.doLayout(flowBPD);
         
         finishPage();
@@ -169,7 +169,7 @@
         
         /** @see org.apache.fop.layoutmgr.AbstractBreaker */
         protected void updateLayoutContext(LayoutContext context) {
-            int flowIPD = curPV.getCurrentSpan().getColumnWidth();
+            int flowIPD = getCurrentPV().getCurrentSpan().getColumnWidth();
             context.setRefIPD(flowIPD);
         }
         
@@ -177,9 +177,9 @@
             return null;  // unneeded for PSLM
         }
         
-        /** @see org.apache.fop.layoutmgr.AbstractBreaker#getPageViewportProvider() */
-        protected PageSequenceLayoutManager.PageViewportProvider getPageViewportProvider()
{
-            return pvProvider;
+        /** @see org.apache.fop.layoutmgr.AbstractBreaker#getPageProvider() */
+        protected PageSequenceLayoutManager.PageProvider getPageProvider() {
+            return pageProvider;
         }
         
         /** @see org.apache.fop.layoutmgr.AbstractBreaker */
@@ -210,8 +210,8 @@
             }
             firstPart = false;
             pageBreakHandled = true;
-            pvProvider.setStartOfNextElementList(currentPageNum, 
-                    curPV.getCurrentSpan().getCurrentFlowIndex());
+            pageProvider.setStartOfNextElementList(currentPageNum, 
+                    getCurrentPV().getCurrentSpan().getCurrentFlowIndex());
             return super.getNextBlockList(childLC, nextSequenceStartsOn, blockLists);
         }
         
@@ -280,7 +280,8 @@
         }
         
         protected int getCurrentDisplayAlign() {
-            return curPV.getSPM().getRegion(Constants.FO_REGION_BODY).getDisplayAlign();
+            return curPage.getSimplePageMaster().getRegion(
+                    Constants.FO_REGION_BODY).getDisplayAlign();
         }
         
         protected boolean hasMoreContent() {
@@ -293,7 +294,8 @@
                         "xsl-footnote-separator");
                 // create a Block area that will contain the separator areas
                 separatorArea = new Block();
-                separatorArea.setIPD(curPV.getRegionReference(Constants.FO_REGION_BODY).getIPD());
+                separatorArea.setIPD(
+                        getCurrentPV().getRegionReference(Constants.FO_REGION_BODY).getIPD());
                 // create a StaticContentLM for the footnote separator
                 footnoteSeparatorLM = (StaticContentLayoutManager)
                     getLayoutManagerMaker().makeStaticContentLayoutManager(
@@ -309,7 +311,7 @@
             if (needColumnBalancing) {
                 AbstractBreaker.log.debug("Column balancing now!!!");
                 AbstractBreaker.log.debug("===================================================");
-                int restartPoint = pvProvider.getStartingPartIndexForLastPage(partCount);
+                int restartPoint = pageProvider.getStartingPartIndexForLastPage(partCount);
                 if (restartPoint > 0) {
                     addAreas(alg, restartPoint, originalList, effectiveList);
                 }
@@ -331,13 +333,13 @@
                 }
                 pageBreakHandled = true;
                 //Update so the available BPD is reported correctly
-                pvProvider.setStartOfNextElementList(currentPageNum, 
-                        curPV.getCurrentSpan().getCurrentFlowIndex());
+                pageProvider.setStartOfNextElementList(currentPageNum, 
+                        getCurrentPV().getCurrentSpan().getCurrentFlowIndex());
 
                 //Restart last page
                 PageBreakingAlgorithm algRestart = new BalancingColumnBreakingAlgorithm(
                         getTopLevelLM(),
-                        getPageViewportProvider(),
+                        getPageProvider(),
                         alignment, Constants.EN_START, footnoteSeparatorLength,
                         isPartOverflowRecoveryActivated(),
                         getCurrentPV().getBodyRegion().getColumnCount());
@@ -367,8 +369,8 @@
         
         protected void startPart(BlockSequence list, int breakClass) {
             AbstractBreaker.log.debug("startPart() breakClass=" + breakClass);
-            if (curPV == null) {
-                throw new IllegalStateException("curPV must not be null");
+            if (curPage == null) {
+                throw new IllegalStateException("curPage must not be null");
             }
             if (!pageBreakHandled) {
                 
@@ -382,8 +384,8 @@
                     // otherwise, we may simply need a new page
                     handleBreakTrait(breakClass);
                 }
-                pvProvider.setStartOfNextElementList(currentPageNum, 
-                        curPV.getCurrentSpan().getCurrentFlowIndex());
+                pageProvider.setStartOfNextElementList(currentPageNum, 
+                        getCurrentPV().getCurrentSpan().getCurrentFlowIndex());
             }
             pageBreakHandled = false;
             // add static areas and resolve any new id areas
@@ -393,7 +395,7 @@
         
         /** @see org.apache.fop.layoutmgr.AbstractBreaker#handleEmptyContent() */
         protected void handleEmptyContent() {
-            curPV.getPage().fakeNonEmpty();
+            getCurrentPV().getPage().fakeNonEmpty();
         }
         
         protected void finishPart(PageBreakingAlgorithm alg, PageBreakPosition pbp) {
@@ -417,7 +419,7 @@
                 }
                 // set the offset from the top margin
                 Footnote parentArea = (Footnote) getCurrentPV().getBodyRegion().getFootnote();
-                int topOffset = (int) curPV.getBodyRegion().getBPD() - parentArea.getBPD();
+                int topOffset = (int) getCurrentPV().getBodyRegion().getBPD() - parentArea.getBPD();
                 if (separatorArea != null) {
                     topOffset -= separatorArea.getBPD();
                 }
@@ -441,13 +443,21 @@
     
     /**
      * Provides access to the current page.
-     * @return the current PageViewport
+     * @return the current Page
      */
-    public PageViewport getCurrentPV() {
-        return curPV;
+    public Page getCurrentPage() {
+        return curPage;
     }
 
     /**
+     * Provides access to the current page viewport.
+     * @return the current PageViewport
+     *//*
+    public PageViewport getCurrentPageViewport() {
+        return curPage.getPageViewport();
+    }*/
+
+    /**
      * Provides access to this object
      * @return this PageSequenceLayoutManager instance
      */
@@ -480,7 +490,7 @@
      */
     public void addIDToPage(String id) {
         if (id != null && id.length() > 0) {
-            areaTreeHandler.associateIDWithPageViewport(id, curPV);
+            areaTreeHandler.associateIDWithPageViewport(id, curPage.getPageViewport());
         }
     }
 
@@ -501,8 +511,8 @@
      * @param res the resolvable object that needs resolving
      */
     public void addUnresolvedArea(String id, Resolvable res) {
-        curPV.addUnresolvedIDRef(id, res);
-        areaTreeHandler.addUnresolvedIDRef(id, curPV);
+        curPage.getPageViewport().addUnresolvedIDRef(id, res);
+        areaTreeHandler.addUnresolvedIDRef(id, curPage.getPageViewport());
     }
 
     /**
@@ -529,7 +539,7 @@
         int boundary = rm.getRetrieveBoundary();               
         
         // get marker from the current markers on area tree
-        Marker mark = (Marker)curPV.getMarker(name, pos);
+        Marker mark = (Marker)getCurrentPV().getMarker(name, pos);
         if (mark == null && boundary != EN_PAGE) {
             // go back over pages until mark found
             // if document boundary then keep going
@@ -563,24 +573,25 @@
         }
     }
 
-    private PageViewport makeNewPage(boolean bIsBlank, boolean bIsLast) {
-        if (curPV != null) {
+    private Page makeNewPage(boolean bIsBlank, boolean bIsLast) {
+        if (curPage != null) {
             finishPage();
         }
 
         currentPageNum++;
 
-        curPV = pvProvider.getPageViewport(bIsBlank,
-                currentPageNum, PageViewportProvider.RELTO_PAGE_SEQUENCE);
+        curPage = pageProvider.getPage(bIsBlank,
+                currentPageNum, PageProvider.RELTO_PAGE_SEQUENCE);
 
         if (log.isDebugEnabled()) {
-            log.debug("[" + curPV.getPageNumberString() + (bIsBlank ? "*" : "") + "]");
+            log.debug("[" + curPage.getPageViewport().getPageNumberString() 
+                    + (bIsBlank ? "*" : "") + "]");
         }
-        return curPV;
+        return curPage;
     }
 
     private void layoutSideRegion(int regionID) {
-        SideRegion reg = (SideRegion)curPV.getSPM().getRegion(regionID);
+        SideRegion reg = (SideRegion)curPage.getSimplePageMaster().getRegion(regionID);
         if (reg == null) {
             return;
         }
@@ -596,7 +607,7 @@
     }
 
     private void finishPage() {
-        curPV.dumpMarkers();
+        curPage.getPageViewport().dumpMarkers();
         // Layout side regions
         layoutSideRegion(FO_REGION_BEFORE); 
         layoutSideRegion(FO_REGION_AFTER);
@@ -605,14 +616,14 @@
         
         // Try to resolve any unresolved IDs for the current page.
         // 
-        areaTreeHandler.tryIDResolution(curPV);
+        areaTreeHandler.tryIDResolution(curPage.getPageViewport());
         // Queue for ID resolution and rendering
-        areaTreeHandler.getAreaTreeModel().addPage(curPV);
+        areaTreeHandler.getAreaTreeModel().addPage(curPage.getPageViewport());
         if (log.isDebugEnabled()) {
-            log.debug("page finished: " + curPV.getPageNumberString() 
+            log.debug("page finished: " + curPage.getPageViewport().getPageNumberString()

                     + ", current num: " + currentPageNum);
         }
-        curPV = null;
+        curPage = null;
     }
     
     /**
@@ -624,26 +635,26 @@
     private void handleBreakTrait(int breakVal) {
         if (breakVal == Constants.EN_ALL) {
             //break due to span change in multi-column layout
-            curPV.createSpan(true);
+            curPage.getPageViewport().createSpan(true);
             return;
         } else if (breakVal == Constants.EN_NONE) {
-            curPV.createSpan(false);
+            curPage.getPageViewport().createSpan(false);
             return;
         } else if (breakVal == Constants.EN_COLUMN || breakVal <= 0) {
-            if (curPV.getCurrentSpan().hasMoreFlows()) {
-                curPV.getCurrentSpan().moveToNextFlow();
+            if (curPage.getPageViewport().getCurrentSpan().hasMoreFlows()) {
+                curPage.getPageViewport().getCurrentSpan().moveToNextFlow();
             } else {
-                curPV = makeNewPage(false, false);
+                curPage = makeNewPage(false, false);
             }
             return;
         }
         log.debug("handling break-before after page " + currentPageNum 
             + " breakVal=" + breakVal);
         if (needBlankPageBeforeNew(breakVal)) {
-            curPV = makeNewPage(true, false);
+            curPage = makeNewPage(true, false);
         }
         if (needNewPage(breakVal)) {
-            curPV = makeNewPage(false, false);
+            curPage = makeNewPage(false, false);
         }
     }
 
@@ -653,7 +664,7 @@
      * @param breakVal - value of break-before or break-after trait.
      */
     private boolean needBlankPageBeforeNew(int breakVal) {
-        if (breakVal == Constants.EN_PAGE || (curPV.getPage().isEmpty())) {
+        if (breakVal == Constants.EN_PAGE || (curPage.getPageViewport().getPage().isEmpty()))
{
             // any page is OK or we already have an empty page
             return false;
         } else {
@@ -671,7 +682,7 @@
      * @param breakVal - value of break-before or break-after trait.
      */
     private boolean needNewPage(int breakVal) {
-        if (curPV.getPage().isEmpty()) {
+        if (curPage.getPageViewport().getPage().isEmpty()) {
             if (breakVal == Constants.EN_PAGE) {
                 return false;
             } else if (currentPageNum % 2 == 0) { // even page
@@ -686,7 +697,7 @@
     
     
     /**
-     * <p>This class delivers PageViewport instances. It also caches them as necessary.
+     * <p>This class delivers Page instances. It also caches them as necessary.
      * </p>
      * <p>Additional functionality makes sure that surplus instances that are requested
by the
      * page breaker are properly discarded, especially in situations where hard breaks cause
@@ -694,9 +705,9 @@
      * additional pages since it doesn't know exactly until the end how many pages it really
needs.
      * </p>
      */
-    public class PageViewportProvider {
+    public class PageProvider {
         
-        private Log log = LogFactory.getLog(PageViewportProvider.class);
+        private Log log = LogFactory.getLog(PageProvider.class);
 
         /** Indices are evaluated relative to the first page in the page-sequence. */
         public static final int RELTO_PAGE_SEQUENCE = 0;
@@ -706,7 +717,7 @@
         private int startPageOfPageSequence;
         private int startPageOfCurrentElementList;
         private int startColumnOfCurrentElementList;
-        private List cachedPageViewports = new java.util.ArrayList();
+        private List cachedPages = new java.util.ArrayList();
         
         //Cache to optimize getAvailableBPD() calls
         private int lastRequestedIndex = -1;
@@ -716,7 +727,7 @@
          * Main constructor.
          * @param ps The page-sequence the provider operates on
          */
-        public PageViewportProvider(PageSequence ps) {
+        public PageProvider(PageSequence ps) {
             this.startPageOfPageSequence = ps.getStartingPageNumber();
         }
         
@@ -754,20 +765,20 @@
             int c = index;
             int pageIndex = 0;
             int colIndex = startColumnOfCurrentElementList;
-            PageViewport pv = getPageViewport(
+            Page page = getPage(
                     false, pageIndex, RELTO_CURRENT_ELEMENT_LIST);
             while (c > 0) {
                 colIndex++;
-                if (colIndex >= pv.getCurrentSpan().getColumnCount()) {
+                if (colIndex >= page.getPageViewport().getCurrentSpan().getColumnCount())
{
                     colIndex = 0;
                     pageIndex++;
-                    pv = getPageViewport(
+                    page = getPage(
                             false, pageIndex, RELTO_CURRENT_ELEMENT_LIST);
                 }
                 c--;
             }
             this.lastRequestedIndex = index;
-            this.lastReportedBPD = pv.getBodyRegion().getRemainingBPD();
+            this.lastReportedBPD = page.getPageViewport().getBodyRegion().getRemainingBPD();
             if (log.isTraceEnabled()) {
                 log.trace("getAvailableBPD(" + index + ") -> " + lastReportedBPD);
             }
@@ -785,13 +796,13 @@
             int idx = 0;
             int pageIndex = 0;
             int colIndex = startColumnOfCurrentElementList;
-            PageViewport pv = getPageViewport(
+            Page page = getPage(
                     false, pageIndex, RELTO_CURRENT_ELEMENT_LIST);
             while (idx < partCount) {
-                if ((colIndex >= pv.getCurrentSpan().getColumnCount())) {
+                if ((colIndex >= page.getPageViewport().getCurrentSpan().getColumnCount()))
{
                     colIndex = 0;
                     pageIndex++;
-                    pv = getPageViewport(
+                    page = getPage(
                             false, pageIndex, RELTO_CURRENT_ELEMENT_LIST);
                     result = idx;
                 }
@@ -802,29 +813,29 @@
         }
 
         /**
-         * Returns a PageViewport.
+         * Returns a Page.
          * @param bIsBlank true if this page is supposed to be blank.
          * @param index Index of the page (see relativeTo)
          * @param relativeTo Defines which value the index parameter should be evaluated
relative 
-         * to. (One of PageViewportProvider.RELTO_*)
-         * @return the requested PageViewport
+         * to. (One of PageProvider.RELTO_*)
+         * @return the requested Page
          */
-        public PageViewport getPageViewport(boolean bIsBlank, int index, int relativeTo)
{
+        public Page getPage(boolean bIsBlank, int index, int relativeTo) {
             if (relativeTo == RELTO_PAGE_SEQUENCE) {
-                return getPageViewport(bIsBlank, index);
+                return getPage(bIsBlank, index);
             } else if (relativeTo == RELTO_CURRENT_ELEMENT_LIST) {
                 int effIndex = startPageOfCurrentElementList + index;
                 effIndex += startPageOfPageSequence - 1;
-                return getPageViewport(bIsBlank, effIndex);
+                return getPage(bIsBlank, effIndex);
             } else {
                 throw new IllegalArgumentException(
                         "Illegal value for relativeTo: " + relativeTo);
             }
         }
         
-        private PageViewport getPageViewport(boolean bIsBlank, int index) {
+        private Page getPage(boolean bIsBlank, int index) {
             if (log.isTraceEnabled()) {
-                log.trace("getPageViewport(" + index + " " + bIsBlank);
+                log.trace("getPage(" + index + " " + bIsBlank);
             }
             int intIndex = index - startPageOfPageSequence;
             if (log.isTraceEnabled()) {
@@ -832,27 +843,27 @@
                     log.trace("blank page requested: " + index);
                 }
             }
-            while (intIndex >= cachedPageViewports.size()) {
+            while (intIndex >= cachedPages.size()) {
                 if (log.isTraceEnabled()) {
                     log.trace("Caching " + index);
                 }
-                cacheNextPageViewport(index, bIsBlank);
+                cacheNextPage(index, bIsBlank);
             }
-            PageViewport pv = (PageViewport)cachedPageViewports.get(intIndex);
-            if (pv.isBlank() != bIsBlank) {
+            Page page = (Page)cachedPages.get(intIndex);
+            if (page.getPageViewport().isBlank() != bIsBlank) {
                 log.debug("blank condition doesn't match. Replacing PageViewport.");
-                while (intIndex < cachedPageViewports.size()) {
-                    this.cachedPageViewports.remove(cachedPageViewports.size() - 1);
+                while (intIndex < cachedPages.size()) {
+                    this.cachedPages.remove(cachedPages.size() - 1);
                     if (!pageSeq.goToPreviousSimplePageMaster()) {
                         log.warn("goToPreviousSimplePageMaster() on the first page called!");
                     }
                 }
-                cacheNextPageViewport(index, bIsBlank);
+                cacheNextPage(index, bIsBlank);
             }
-            return pv;
+            return page;
         }
         
-        private void cacheNextPageViewport(int index, boolean bIsBlank) {
+        private void cacheNextPage(int index, boolean bIsBlank) {
             try {
                 String pageNumberString = pageSeq.makeFormattedPageNumber(index);
                 SimplePageMaster spm = pageSeq.getNextSimplePageMaster(
@@ -867,8 +878,8 @@
                         + spm.getMasterName() + "'.  FOP presently "
                         + "does not support this.");
                 }
-                PageViewport pv = new PageViewport(spm, pageNumberString, bIsBlank);
-                cachedPageViewports.add(pv);
+                Page page = new Page(spm, pageNumberString, bIsBlank);
+                cachedPages.add(page);
             } catch (FOPException e) {
                 //TODO Maybe improve. It'll mean to propagate this exception up several
                 //methods calls.

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSRenderer.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSRenderer.java?rev=358254&r1=358253&r2=358254&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSRenderer.java Wed Dec 21 02:20:56
2005
@@ -721,14 +721,14 @@
         }
         gen.writeDSCComment(DSCConstants.PAGE_RESOURCES, 
                 new Object[] {PSGenerator.ATEND});
-        gen.commentln("%FOPSimplePageMaster: " + page.getSPM().getMasterName());
+        gen.commentln("%FOPSimplePageMaster: " + page.getSimplePageMasterName());
         gen.writeDSCComment(DSCConstants.BEGIN_PAGE_SETUP);
         
         //Handle PSSetupCode instances on simple-page-master
-        if (page.getSPM().getExtensionAttachments().size() > 0) {
+        if (page.getExtensionAttachments().size() > 0) {
             List list = new java.util.ArrayList();
             //Extract all PSSetupCode instances from the attachment list on the s-p-m
-            Iterator i = page.getSPM().getExtensionAttachments().iterator();
+            Iterator i = page.getExtensionAttachments().iterator();
             while (i.hasNext()) {
                 ExtensionAttachment attachment = (ExtensionAttachment)i.next();
                 if (PSSetupCode.CATEGORY.equals(attachment.getCategory())) {



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org


Mime
View raw message