KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > fo > StandardElementMapping


1 /*
2  * $Id: StandardElementMapping.java,v 1.26.2.4 2003/02/25 12:56:55 jeremias Exp $
3  * ============================================================================
4  * The Apache Software License, Version 1.1
5  * ============================================================================
6  *
7  * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without modifica-
10  * tion, are permitted provided that the following conditions are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright notice,
16  * this list of conditions and the following disclaimer in the documentation
17  * and/or other materials provided with the distribution.
18  *
19  * 3. The end-user documentation included with the redistribution, if any, must
20  * include the following acknowledgment: "This product includes software
21  * developed by the Apache Software Foundation (http://www.apache.org/)."
22  * Alternately, this acknowledgment may appear in the software itself, if
23  * and wherever such third-party acknowledgments normally appear.
24  *
25  * 4. The names "FOP" and "Apache Software Foundation" must not be used to
26  * endorse or promote products derived from this software without prior
27  * written permission. For written permission, please contact
28  * apache@apache.org.
29  *
30  * 5. Products derived from this software may not be called "Apache", nor may
31  * "Apache" appear in their name, without prior written permission of the
32  * Apache Software Foundation.
33  *
34  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
35  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
36  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
37  * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
38  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
39  * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
40  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
41  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
42  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
43  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44  * ============================================================================
45  *
46  * This software consists of voluntary contributions made by many individuals
47  * on behalf of the Apache Software Foundation and was originally created by
48  * James Tauber <jtauber@jtauber.com>. For more information on the Apache
49  * Software Foundation, please see <http://www.apache.org/>.
50  */

51 package org.apache.fop.fo;
52
53 import java.util.HashMap JavaDoc;
54 import java.util.Iterator JavaDoc;
55
56 import org.apache.fop.fo.properties.FOPropertyMapping;
57 import org.apache.fop.fo.flow.*;
58 import org.apache.fop.fo.pagination.*;
59
60 public class StandardElementMapping implements ElementMapping {
61     private static HashMap JavaDoc foObjs = null;
62
63     private static synchronized void setupFO() {
64
65         if(foObjs == null) {
66             foObjs = new HashMap JavaDoc();
67
68             // Declarations and Pagination and Layout Formatting Objects
69
foObjs.put("root", Root.maker());
70             foObjs.put("declarations", Declarations.maker());
71             foObjs.put("color-profile", ColorProfile.maker());
72             foObjs.put("page-sequence", PageSequence.maker());
73             foObjs.put("layout-master-set", LayoutMasterSet.maker());
74             foObjs.put("page-sequence-master",
75                            PageSequenceMaster.maker());
76             foObjs.put("single-page-master-reference",
77                            SinglePageMasterReference.maker());
78             foObjs.put("repeatable-page-master-reference",
79                            RepeatablePageMasterReference.maker());
80             foObjs.put("repeatable-page-master-alternatives",
81                            RepeatablePageMasterAlternatives.maker());
82             foObjs.put("conditional-page-master-reference",
83                            ConditionalPageMasterReference.maker());
84             foObjs.put("simple-page-master",
85                            SimplePageMaster.maker());
86             foObjs.put("region-body", RegionBody.maker());
87             foObjs.put("region-before", RegionBefore.maker());
88             foObjs.put("region-after", RegionAfter.maker());
89             foObjs.put("region-start", RegionStart.maker());
90             foObjs.put("region-end", RegionEnd.maker());
91             foObjs.put("flow", Flow.maker());
92             foObjs.put("static-content", StaticContent.maker());
93             foObjs.put("title", Title.maker());
94
95             // Block-level Formatting Objects
96
foObjs.put("block", Block.maker());
97             foObjs.put("block-container", BlockContainer.maker());
98
99             // Inline-level Formatting Objects
100
foObjs.put("bidi-override", BidiOverride.maker());
101             foObjs.put("character",
102                            org.apache.fop.fo.flow.Character.maker());
103             foObjs.put("initial-property-set",
104                            InitialPropertySet.maker());
105             foObjs.put("external-graphic", ExternalGraphic.maker());
106             foObjs.put("instream-foreign-object",
107                            InstreamForeignObject.maker());
108             foObjs.put("inline", Inline.maker());
109             foObjs.put("inline-container", InlineContainer.maker());
110             foObjs.put("leader", Leader.maker());
111             foObjs.put("page-number", PageNumber.maker());
112             foObjs.put("page-number-citation",
113                            PageNumberCitation.maker());
114
115             // Formatting Objects for Tables
116
foObjs.put("table-and-caption", TableAndCaption.maker());
117             foObjs.put("table", Table.maker());
118             foObjs.put("table-column", TableColumn.maker());
119             foObjs.put("table-caption", TableCaption.maker());
120             foObjs.put("table-header", TableHeader.maker());
121             foObjs.put("table-footer", TableFooter.maker());
122             foObjs.put("table-body", TableBody.maker());
123             foObjs.put("table-row", TableRow.maker());
124             foObjs.put("table-cell", TableCell.maker());
125
126             // Formatting Objects for Lists
127
foObjs.put("list-block", ListBlock.maker());
128             foObjs.put("list-item", ListItem.maker());
129             foObjs.put("list-item-body", ListItemBody.maker());
130             foObjs.put("list-item-label", ListItemLabel.maker());
131
132             // Dynamic Effects: Link and Multi Formatting Objects
133
foObjs.put("basic-link", BasicLink.maker());
134             foObjs.put("multi-switch", MultiSwitch.maker());
135             foObjs.put("multi-case", MultiCase.maker());
136             foObjs.put("multi-toggle", MultiToggle.maker());
137             foObjs.put("multi-properties", MultiProperties.maker());
138             foObjs.put("multi-property-set",
139                            MultiPropertySet.maker());
140
141             // Out-of-Line Formatting Objects
142
foObjs.put("float",
143                            org.apache.fop.fo.flow.Float.maker());
144             foObjs.put("footnote", Footnote.maker());
145             foObjs.put("footnote-body", FootnoteBody.maker());
146
147             // Other Formatting Objects
148
foObjs.put("wrapper", Wrapper.maker());
149             foObjs.put("marker", Marker.maker());
150             foObjs.put("retrieve-marker", RetrieveMarker.maker());
151         }
152     }
153
154     public void addToBuilder(TreeBuilder builder) {
155         setupFO();
156         String JavaDoc uri = "http://www.w3.org/1999/XSL/Format";
157         builder.addMapping(uri, foObjs);
158
159         builder.addPropertyList(uri, FOPropertyMapping.getGenericMappings());
160         /* Add any element mappings */
161         for (Iterator JavaDoc iter = FOPropertyMapping.getElementMappings().iterator();
162                 iter.hasNext(); ) {
163             String JavaDoc elem = (String JavaDoc)iter.next();
164             builder.addElementPropertyList(uri, elem,
165                                            FOPropertyMapping.getElementMapping(elem));
166         }
167     }
168 }
169
170
Popular Tags