aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/fo/FOElementMapping.java
blob: b087e1d9c12c8345877ada8b360cd3c600916d30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.fo;

// Java
import java.util.HashMap;

import org.apache.xmlgraphics.util.QName;

import org.apache.fop.layoutmgr.BlockLevelEventProducer;

/**
 * Element mapping class for all XSL-FO elements.
 */
public class FOElementMapping extends ElementMapping {

    /** The XSL-FO namespace URI */
    public static final String URI = "http://www.w3.org/1999/XSL/Format";

     /** Standard prefix */
    public static final String STANDARD_PREFIX = "fo";

    /**
     * Basic constructor; inititializes the namespace URI for the fo: namespace
     */
    public FOElementMapping() {
        namespaceURI = URI;
    }

    /**
     * Initializes the collection of valid objects for the fo: namespace
     */
    protected void initialize() {
        if (foObjs == null) {
            foObjs = new HashMap<String, Maker>();

            // Declarations and Pagination and Layout Formatting Objects
            foObjs.put("root", new RootMaker());
            foObjs.put("declarations", new DeclarationsMaker());
            foObjs.put("color-profile", new ColorProfileMaker());
            foObjs.put("bookmark-tree", new BookmarkTreeMaker());
            foObjs.put("bookmark", new BookmarkMaker());
            foObjs.put("bookmark-title", new BookmarkTitleMaker());
//          foObjs.put("page-sequence-wrapper", new PageSequenceWrapperMaker());
            foObjs.put("page-sequence", new PageSequenceMaker());
            foObjs.put("layout-master-set", new LayoutMasterSetMaker());
            foObjs.put("page-sequence-master",
                           new PageSequenceMasterMaker());
            foObjs.put("single-page-master-reference",
                           new SinglePageMasterReferenceMaker());
            foObjs.put("repeatable-page-master-reference",
                           new RepeatablePageMasterReferenceMaker());
            foObjs.put("repeatable-page-master-alternatives",
                           new RepeatablePageMasterAlternativesMaker());
            foObjs.put("conditional-page-master-reference",
                           new ConditionalPageMasterReferenceMaker());
            foObjs.put("simple-page-master",
                           new SimplePageMasterMaker());
            foObjs.put("region-body", new RegionBodyMaker());
            foObjs.put("region-before", new RegionBeforeMaker());
            foObjs.put("region-after", new RegionAfterMaker());
            foObjs.put("region-start", new RegionStartMaker());
            foObjs.put("region-end", new RegionEndMaker());
            foObjs.put("flow", new FlowMaker());
            foObjs.put("static-content", new StaticContentMaker());
            foObjs.put("title", new TitleMaker());

            // Block-level Formatting Objects
            foObjs.put("block", new BlockMaker());
            foObjs.put("block-container", new BlockContainerMaker());

            // Inline-level Formatting Objects
            foObjs.put("bidi-override", new BidiOverrideMaker());
            foObjs.put("character",
                           new CharacterMaker());
            foObjs.put("initial-property-set",
                           new InitialPropertySetMaker());
            foObjs.put("external-graphic", new ExternalGraphicMaker());
            foObjs.put("instream-foreign-object",
                           new InstreamForeignObjectMaker());
            foObjs.put("inline", new InlineMaker());
            foObjs.put("inline-container", new InlineContainerMaker());
            foObjs.put("leader", new LeaderMaker());
            foObjs.put("page-number", new PageNumberMaker());
            foObjs.put("page-number-citation",
                           new PageNumberCitationMaker());
            foObjs.put("page-number-citation-last",
                    new PageNumberCitationLastMaker());

            // Formatting Objects for Tables
            foObjs.put("table-and-caption", new TableAndCaptionMaker());
            foObjs.put("table", new TableMaker());
            foObjs.put("table-column", new TableColumnMaker());
            foObjs.put("table-caption", new TableCaptionMaker());
            foObjs.put("table-header", new TableHeaderMaker());
            foObjs.put("table-footer", new TableFooterMaker());
            foObjs.put("table-body", new TableBodyMaker());
            foObjs.put("table-row", new TableRowMaker());
            foObjs.put("table-cell", new TableCellMaker());

            // Formatting Objects for Lists
            foObjs.put("list-block", new ListBlockMaker());
            foObjs.put("list-item", new ListItemMaker());
            foObjs.put("list-item-body", new ListItemBodyMaker());
            foObjs.put("list-item-label", new ListItemLabelMaker());

            // Dynamic Effects: Link and Multi Formatting Objects
            foObjs.put("basic-link", new BasicLinkMaker());
            foObjs.put("multi-switch", new MultiSwitchMaker());
            foObjs.put("multi-case", new MultiCaseMaker());
            foObjs.put("multi-toggle", new MultiToggleMaker());
            foObjs.put("multi-properties", new MultiPropertiesMaker());
            foObjs.put("multi-property-set",
                           new MultiPropertySetMaker());

            // Out-of-Line Formatting Objects
            foObjs.put("float",
                           new FloatMaker());
            foObjs.put("footnote", new FootnoteMaker());
            foObjs.put("footnote-body", new FootnoteBodyMaker());

            // Other Formatting Objects
            foObjs.put("wrapper", new WrapperMaker());
            foObjs.put("marker", new MarkerMaker());
            foObjs.put("retrieve-marker", new RetrieveMarkerMaker());
            foObjs.put("retrieve-table-marker", new RetrieveTableMarkerMaker());
        }
    }

    /** {@inheritDoc} */
    public String getStandardPrefix() {
        return STANDARD_PREFIX;
    }

    /** {@inheritDoc} */
    public boolean isAttributeProperty(QName attributeName) {
        return true; //All XSL-FO attributes are to be converted to properties.
    }

    static class RootMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.pagination.Root(parent);
        }
    }

    static class DeclarationsMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.pagination.Declarations(parent);
        }
    }

    static class ColorProfileMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.pagination.ColorProfile(parent);
        }
    }

    static class BookmarkTreeMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.pagination.bookmarks.BookmarkTree(parent);
        }
    }

    static class BookmarkMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.pagination.bookmarks.Bookmark(parent);
        }
    }

    static class BookmarkTitleMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.pagination.bookmarks.BookmarkTitle(parent);
        }
    }

    static class PageSequenceWrapperMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.pagination.PageSequenceWrapper(parent);
        }
    }

    static class PageSequenceMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.pagination.PageSequence(parent);
        }
    }

    static class LayoutMasterSetMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.pagination.LayoutMasterSet(parent);
        }
    }

    static class PageSequenceMasterMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.pagination.PageSequenceMaster(parent,
                    BlockLevelEventProducer.Provider.get(
                            parent.getUserAgent().getEventBroadcaster()));
        }
    }

    static class SinglePageMasterReferenceMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.pagination.SinglePageMasterReference(parent);
        }
    }

    static class RepeatablePageMasterReferenceMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.pagination.RepeatablePageMasterReference(parent);
        }
    }

    static class RepeatablePageMasterAlternativesMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.pagination.RepeatablePageMasterAlternatives(parent);
        }
    }

    static class ConditionalPageMasterReferenceMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.pagination.ConditionalPageMasterReference(parent);
        }
    }

    static class SimplePageMasterMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.pagination.SimplePageMaster(parent);
        }
    }

    static class RegionBodyMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.pagination.RegionBody(parent);
        }
    }

    static class RegionBeforeMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.pagination.RegionBefore(parent);
        }
    }

    static class RegionAfterMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.pagination.RegionAfter(parent);
        }
    }

    static class RegionStartMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.pagination.RegionStart(parent);
        }
    }

    static class RegionEndMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.pagination.RegionEnd(parent);
        }
    }

    static class FlowMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.pagination.Flow(parent);
        }
    }

    static class StaticContentMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.pagination.StaticContent(parent);
        }
    }

    static class TitleMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.pagination.Title(parent);
        }
    }

    static class BlockMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.Block(parent);
        }
    }

    static class BlockContainerMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.BlockContainer(parent);
        }
    }

    static class BidiOverrideMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.BidiOverride(parent);
        }
    }

    static class CharacterMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.Character(parent);
        }
    }

    static class InitialPropertySetMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.InitialPropertySet(parent);
        }
    }

    static class ExternalGraphicMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.ExternalGraphic(parent);
        }
    }

    static class InstreamForeignObjectMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.InstreamForeignObject(parent);
        }
    }

    static class InlineMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.Inline(parent);
        }
    }

    static class InlineContainerMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.InlineContainer(parent);
        }
    }

    static class LeaderMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.Leader(parent);
        }
    }

    static class PageNumberMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.PageNumber(parent);
        }
    }

    static class PageNumberCitationMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.PageNumberCitation(parent);
        }
    }

    static class PageNumberCitationLastMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.PageNumberCitationLast(parent);
        }
    }

    static class TableAndCaptionMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.table.TableAndCaption(parent);
        }
    }

    static class TableMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.table.Table(parent);
        }
    }

    static class TableColumnMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.table.TableColumn(parent);
        }
    }

    static class TableCaptionMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.table.TableCaption(parent);
        }
    }

    static class TableBodyMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.table.TableBody(parent);
        }
    }

    static class TableHeaderMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.table.TableHeader(parent);
        }
    }

    static class TableFooterMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.table.TableFooter(parent);
        }
    }

    static class TableRowMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.table.TableRow(parent);
        }
    }

    static class TableCellMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.table.TableCell(parent);
        }
    }

    static class ListBlockMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.ListBlock(parent);
        }
    }

    static class ListItemMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.ListItem(parent);
        }
    }

    static class ListItemBodyMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.ListItemBody(parent);
        }
    }

    static class ListItemLabelMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.ListItemLabel(parent);
        }
    }

    static class BasicLinkMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.BasicLink(parent);
        }
    }

    static class MultiSwitchMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.MultiSwitch(parent);
        }
    }

    static class MultiCaseMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.MultiCase(parent);
        }
    }

    static class MultiToggleMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.MultiToggle(parent);
        }
    }

    static class MultiPropertiesMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.MultiProperties(parent);
        }
    }

    static class MultiPropertySetMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.MultiPropertySet(parent);
        }
    }

    static class FloatMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.Float(parent);
        }
    }

    static class FootnoteMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.Footnote(parent);
        }
    }

    static class FootnoteBodyMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.FootnoteBody(parent);
        }
    }

    static class WrapperMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.Wrapper(parent);
        }
    }

    static class MarkerMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.Marker(parent);
        }
    }

    static class RetrieveMarkerMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.RetrieveMarker(parent);
        }
    }

    static class RetrieveTableMarkerMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.RetrieveTableMarker(parent);
        }
    }
}