Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/jfor/jfor/converter/PageBuilder.java


1   package org.jfor.jfor.converter;
2   
3   import java.io.IOException;
4   import java.io.*;
5   import org.xml.sax.Attributes;
6   import org.jfor.jfor.rtflib.rtfdoc.*;
7   
8   /*-----------------------------------------------------------------------------
9    * jfor - Open-Source XSL-FO to RTF converter - see www.jfor.org
10   *
11   * ====================================================================
12   * jfor Apache-Style Software License.
13   * Copyright (c) 2002 by the jfor project. All rights reserved.
14   *
15   * Redistribution and use in source and binary forms, with or without
16   * modification, are permitted provided that the following conditions
17   * are met:
18   *
19   * 1. Redistributions of source code must retain the above copyright
20   * notice, this list of conditions and the following disclaimer.
21   *
22   * 2. Redistributions in binary form must reproduce the above copyright
23   * notice, this list of conditions and the following disclaimer in
24   * the documentation and/or other materials provided with the
25   * distribution.
26   *
27   * 3. The end-user documentation included with the redistribution,
28   * if any, must include the following acknowledgment:
29   * "This product includes software developed
30   * by the jfor project (http://www.jfor.org)."
31   * Alternately, this acknowledgment may appear in the software itself,
32   * if and wherever such third-party acknowledgments normally appear.
33   *
34   * 4. The name "jfor" must not be used to endorse
35   * or promote products derived from this software without prior written
36   * permission.  For written permission, please contact info@jfor.org.
37   *
38   * 5. Products derived from this software may not be called "jfor",
39   * nor may "jfor" appear in their name, without prior written
40   * permission of info@jfor.org.
41   *
42   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
43   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
44   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
45   * DISCLAIMED.  IN NO EVENT SHALL THE JFOR PROJECT OR ITS CONTRIBUTORS BE
46   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
47   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
48   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
49   * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
50   * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
51   * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
52   * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53   * ====================================================================
54   * Contributor(s):
55   * Christopher Scott, scottc@westinghouse.com
56   * Portions created by Christopher Scott are Coypright (C) 2001 
57   * Westinghouse Electric Company. All Rights Reserved.
58  -----------------------------------------------------------------------------*/
59  
60  /** Recognizes the simple-page-master xml:fo tag for specifying page and
61   *  and margin size.  Instantiates RtfPage through RtfPageArea.
62   *  @author Christopher Scott, scottc@westinghouse.com
63   */
64  
65  //------------------------------------------------------------------------------
66  // $Id: PageBuilder.java,v 1.2 2002/07/12 08:08:31 bdelacretaz Exp $
67  // $Log: PageBuilder.java,v $
68  // Revision 1.2  2002/07/12 08:08:31  bdelacretaz
69  // License changed to jfor Apache-style license
70  //
71  // Revision 1.1  2001/12/28 17:10:22  bdelacretaz
72  // V0.5.2 - first integration of Chris Scott's changes
73  //
74  //------------------------------------------------------------------------------
75  
76  
77  class PageBuilder extends AbstractBuilder
78  {
79    private RtfPageArea p_area;
80      PageBuilder(BuilderContext ctx)
81      {
82          super(ctx);
83          
84      }
85      
86      /** called by Converter at the start of an element */
87      public void start(String rawName, Attributes attrs)
88      throws IOException
89      {
90          final RtfFile f = m_context.getRtfFile();
91          p_area = f.getPageArea();
92          m_context.pushContainer(p_area.newPage(PageAttributesConverter.convertAttributes(attrs,m_context.log)));
93      }
94      
95      /** called by Converter at the end of an element */
96      public void end(){
97        m_context.popContainer();  
98      }
99      
100     /** this builder applies to fo:root */
101     public IBuilder getBuilder(BuilderContext ctx,String rawName, Attributes attrs)
102     {
103         if(rawName.equals("fo:layout-master-set")) return new PageBuilder(ctx);
104         else if(rawName.equals("fo:simple-page-master")) return new PageBuilder(ctx); 
105         return null;
106     }
107 }