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

Quick Search    Search Deep

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


1   package org.jfor.jfor.converter;
2   
3   import java.io.IOException;
4   import org.xml.sax.Attributes;
5   import org.jfor.jfor.rtflib.rtfdoc.*;
6   
7   /*-----------------------------------------------------------------------------
8    * jfor - Open-Source XSL-FO to RTF converter - see www.jfor.org
9    *
10   * ====================================================================
11   * jfor Apache-Style Software License.
12   * Copyright (c) 2002 by the jfor project. All rights reserved.
13   *
14   * Redistribution and use in source and binary forms, with or without
15   * modification, are permitted provided that the following conditions
16   * are met:
17   *
18   * 1. Redistributions of source code must retain the above copyright
19   * notice, this list of conditions and the following disclaimer.
20   *
21   * 2. Redistributions in binary form must reproduce the above copyright
22   * notice, this list of conditions and the following disclaimer in
23   * the documentation and/or other materials provided with the
24   * distribution.
25   *
26   * 3. The end-user documentation included with the redistribution,
27   * if any, must include the following acknowledgment:
28   * "This product includes software developed
29   * by the jfor project (http://www.jfor.org)."
30   * Alternately, this acknowledgment may appear in the software itself,
31   * if and wherever such third-party acknowledgments normally appear.
32   *
33   * 4. The name "jfor" must not be used to endorse
34   * or promote products derived from this software without prior written
35   * permission.  For written permission, please contact info@jfor.org.
36   *
37   * 5. Products derived from this software may not be called "jfor",
38   * nor may "jfor" appear in their name, without prior written
39   * permission of info@jfor.org.
40   *
41   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
42   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
43   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
44   * DISCLAIMED.  IN NO EVENT SHALL THE JFOR PROJECT OR ITS CONTRIBUTORS BE
45   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
46   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
47   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
48   * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
49   * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
50   * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
51   * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
52   * ====================================================================
53   * Contributor(s):
54   *  @author Andreas Putz a.putz@skynamics.com
55  -----------------------------------------------------------------------------*/
56  
57  /**  An IBuilder that handles fo:table-row
58   *  @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
59   */
60  
61  //------------------------------------------------------------------------------
62  // $Id: TableRowBuilder.java,v 1.6 2003/06/29 22:31:02 pherweg Exp $
63  // $Log: TableRowBuilder.java,v $
64  // Revision 1.6  2003/06/29 22:31:02  pherweg
65  // support for number-rows-spanned added
66  //
67  // Revision 1.5  2003/02/18 16:10:51  rmarra
68  // Contributions Normand Massé
69  // inheritance and other fixes
70  //
71  // Revision 1.4  2002/07/12 08:08:31  bdelacretaz
72  // License changed to jfor Apache-style license
73  //
74  // Revision 1.3  2001/09/04 14:31:27  putzi
75  // Including cell padding for tables
76  //
77  // Revision 1.2  2001/08/31 07:51:01  bdelacretaz
78  // MPL license text added + javadoc class comments corrected
79  //
80  // Revision 1.1  2001/08/29 13:27:51  bdelacretaz
81  // V0.4.1 - base package name changed to org.jfor.jfor
82  //
83  // Revision 1.1.1.1  2001/08/02 12:53:45  bdelacretaz
84  // initial SourceForge checkin of V0.1 code
85  //
86  //------------------------------------------------------------------------------
87  
88  class TableRowBuilder extends AbstractBuilder
89  {
90      TableRowBuilder(BuilderContext ctx)
91      {
92          super(ctx);
93      }
94  
95      /** called by Converter at the start of an element */
96      public void start(String rawName, Attributes atts)
97      throws IOException
98      {
99          // create an RtfTableRow in the current RtfTable
100         final RtfTable tbl = (RtfTable)m_context.getContainer(RtfTable.class,true,this);
101         // Added by Normand Masse
102         // Try to use the parents attributes
103         RtfAttributes tblAttribs = tbl.getRtfAttributes();
104         RtfAttributes tblRowAttribs = TableAttributesConverter.convertRowAttributes(atts, tblAttribs);
105         m_context.pushContainer(tbl.newTableRow( tblRowAttribs ));
106 
107         // reset column iteration index to correctly access column widths
108         m_context.getTableContext().selectFirstColumn();
109     }
110 
111     /** called by Converter at the end of an element */
112     public void end()
113     throws IOException
114     {
115         m_context.popContainer();
116         m_context.getTableContext().decreaseRowSpannings();
117     }
118 
119     /** return a TableBuilder for fo:table elements */
120     public IBuilder getBuilder(BuilderContext ctx,String rawName, Attributes atts)
121     {
122         if(rawName.equals("fo:table-row")) return new TableRowBuilder(ctx);
123         else return null;
124     }
125 }