vmote       2003/08/26 17:36:14

  Modified:    src/java/org/apache/fop/layoutmgr PageLayoutManager.java
  Log:
  1. extract method getSimpleMasterPageToUse()
  2. clean up signature for createPage()
  
  Revision  Changes    Path
  1.7       +15 -18    xml-fop/src/java/org/apache/fop/layoutmgr/PageLayoutManager.java
  
  Index: PageLayoutManager.java
  ===================================================================
  RCS file: 
/home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/PageLayoutManager.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- PageLayoutManager.java    27 Aug 2003 00:01:14 -0000      1.6
  +++ PageLayoutManager.java    27 Aug 2003 00:36:14 -0000      1.7
  @@ -450,7 +450,7 @@
       private PageViewport makeNewPage(boolean bIsBlank, boolean bIsLast) {
           finishPage();
           try {
  -            curPage = createPage(pageSequence, pageCount, bIsBlank, isFirstPage, 
bIsLast);
  +            curPage = createPage(bIsBlank, bIsLast);
               isFirstPage = false;
           } catch (FOPException fopex) { /* ???? */
               fopex.printStackTrace();
  @@ -710,29 +710,16 @@
       }
   
       /**
  -     * Called by PageLayoutManager when it needs a new page on which to
  -     * place content. The PageSequence manages the page number (odd/even),
  -     * but the PLM tells it if the page is blank or is the last page.
  +     * Called when a new page is needed.
        *
  -     * @param pageNumber the page number to create page for
        * @param bIsBlank If true, use a master for a blank page.
  -     * @param firstPage true if this is the first page
        * @param bIsLast If true, use the master for the last page in the sequence.
        * @return the page viewport created for the page number
        * @throws FOPException if there is an error creating page
        */
  -    public PageViewport createPage(PageSequence pageSequence, int pageNumber,
  -                                   boolean bIsBlank, boolean firstPage,
  -                                   boolean bIsLast)
  +    public PageViewport createPage(boolean bIsBlank, boolean bIsLast)
                                      throws FOPException {
  -        if (pageSequence.getPageSequenceMaster() == null) {
  -            currentSimplePageMaster = pageSequence.getSimplePageMaster();
  -        } else {
  -            currentSimplePageMaster = pageSequence.getPageSequenceMaster()
  -              .getNextSimplePageMaster(((pageNumber % 2) == 1),
  -                                       firstPage,
  -                                       bIsBlank);
  -        }
  +        currentSimplePageMaster = getSimpleMasterPageToUse(bIsBlank);
           Region body = currentSimplePageMaster.getRegion(Region.BODY);
           if (!pageSequence.getMainFlow().getFlowName().equals(body.getRegionName())) 
{
             throw new FOPException("Flow '" + pageSequence.getMainFlow().getFlowName()
  @@ -740,7 +727,7 @@
                                    + currentSimplePageMaster.getMasterName() + "'");
           }
           PageMaster pageMaster = currentSimplePageMaster.getPageMaster();
  -        if ( pageMaster == null) {
  +        if (pageMaster == null) {
               createSimplePageMasterAreas(currentSimplePageMaster);
           }
           pageMaster = currentSimplePageMaster.getPageMaster();
  @@ -756,6 +743,16 @@
   
           // handle the 'force-page-count'
           //forcePage(areaTree, firstAvailPageNumber);
  +    }
  +
  +    private SimplePageMaster getSimpleMasterPageToUse(boolean bIsBlank)
  +            throws FOPException {
  +        if (pageSequence.getPageSequenceMaster() == null) {
  +            return pageSequence.getSimplePageMaster();
  +        }
  +        boolean isOddPage = ((pageCount % 2) == 1);
  +        return pageSequence.getPageSequenceMaster()
  +              .getNextSimplePageMaster(isOddPage, isFirstPage, bIsBlank);
       }
   
       public void createSimplePageMasterAreas(SimplePageMaster node) {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to