KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 /* $Id: FOEventHandler.java 429168 2006-08-06 18:23:59Z adelmelle $ */
19
20 package org.apache.fop.fo;
21
22 // Java
23
import java.util.HashSet JavaDoc;
24 import java.util.Set JavaDoc;
25 import org.xml.sax.SAXException JavaDoc;
26
27 // Apache
28
import org.apache.fop.apps.FOUserAgent;
29 import org.apache.fop.fo.flow.BasicLink;
30 import org.apache.fop.fo.flow.Block;
31 import org.apache.fop.fo.flow.BlockContainer;
32 import org.apache.fop.fo.flow.Character;
33 import org.apache.fop.fo.flow.ExternalGraphic;
34 import org.apache.fop.fo.flow.Footnote;
35 import org.apache.fop.fo.flow.FootnoteBody;
36 import org.apache.fop.fo.flow.Inline;
37 import org.apache.fop.fo.flow.InstreamForeignObject;
38 import org.apache.fop.fo.flow.Leader;
39 import org.apache.fop.fo.flow.ListBlock;
40 import org.apache.fop.fo.flow.ListItem;
41 import org.apache.fop.fo.flow.PageNumber;
42 import org.apache.fop.fo.flow.Table;
43 import org.apache.fop.fo.flow.TableBody;
44 import org.apache.fop.fo.flow.TableCell;
45 import org.apache.fop.fo.flow.TableColumn;
46 import org.apache.fop.fo.flow.TableRow;
47 import org.apache.fop.fo.pagination.Flow;
48 import org.apache.fop.fo.pagination.PageSequence;
49 import org.apache.fop.fonts.FontInfo;
50
51
52 /**
53  * Abstract class defining what should be done with SAX events that map to
54  * XSL-FO input. The events are actually captured by fo/FOTreeBuilder, passed
55  * to the various fo Objects, which in turn, if needed, pass them to an instance
56  * of FOEventHandler.
57  *
58  * Sub-classes will generally fall into one of two categories:
59  * 1) a handler that actually builds an FO Tree from the events, or 2) a
60  * handler that builds a structured (as opposed to formatted) document, such
61  * as our MIF and RTF output targets.
62  */

63 public abstract class FOEventHandler {
64     
65     /**
66      * The FOUserAgent for this process
67      */

68     protected FOUserAgent foUserAgent;
69
70     /**
71      * The Font information relevant for this document
72      */

73     protected FontInfo fontInfo;
74
75     /**
76      * The current set of id's in the FO tree.
77      * This is used so we know if the FO tree contains duplicates.
78      */

79     private Set JavaDoc idReferences = new HashSet JavaDoc();
80
81     /**
82      * The property list maker.
83      */

84     protected PropertyListMaker propertyListMaker;
85
86     /**
87      * The XMLWhitespaceHandler for this tree
88      */

89     protected XMLWhiteSpaceHandler whiteSpaceHandler = new XMLWhiteSpaceHandler();
90     
91     /**
92      * Indicates whether processing descendants of a marker
93      */

94     private boolean inMarker = false;
95     
96     /**
97      * Main constructor
98      * @param foUserAgent the apps.FOUserAgent instance for this process
99      */

100     public FOEventHandler(FOUserAgent foUserAgent) {
101         this.foUserAgent = foUserAgent;
102         this.fontInfo = new FontInfo();
103     }
104
105     /**
106      * Retuns the set of ID references.
107      * @return the ID references
108      */

109     public Set JavaDoc getIDReferences() {
110         return idReferences;
111     }
112
113     /**
114      * Returns the User Agent object associated with this FOEventHandler.
115      * @return the User Agent object
116      */

117     public FOUserAgent getUserAgent() {
118         return foUserAgent;
119     }
120
121     /**
122      * Retrieve the font information for this document
123      * @return the FontInfo instance for this document
124      */

125     public FontInfo getFontInfo() {
126         return this.fontInfo;
127     }
128
129     /**
130      * Return the propertyListMaker.
131     */

132     public PropertyListMaker getPropertyListMaker() {
133         return propertyListMaker;
134     }
135      
136     /**
137      * Set a new propertyListMaker.
138      */

139     public void setPropertyListMaker(PropertyListMaker propertyListMaker) {
140         this.propertyListMaker = propertyListMaker;
141     }
142     
143     /**
144      * Return the XMLWhiteSpaceHandler
145      * @return the whiteSpaceHandler
146      */

147     public XMLWhiteSpaceHandler getXMLWhiteSpaceHandler() {
148         return whiteSpaceHandler;
149     }
150
151     /**
152      * Switch to or from marker context
153      * (used by FOTreeBuilder when processing
154      * a marker)
155      *
156      */

157     protected void switchMarkerContext(boolean inMarker) {
158         this.inMarker = inMarker;
159     }
160     
161     /**
162      * Check whether in marker context
163      */

164     protected boolean inMarker() {
165         return this.inMarker;
166     }
167     
168     /**
169      * This method is called to indicate the start of a new document run.
170      * @throws SAXException In case of a problem
171      */

172     public void startDocument() throws SAXException JavaDoc {
173     }
174
175     /**
176      * This method is called to indicate the end of a document run.
177      * @throws SAXException In case of a problem
178      */

179     public void endDocument() throws SAXException JavaDoc {
180     }
181
182     /**
183      *
184      * @param pageSeq PageSequence that is starting.
185      */

186     public void startPageSequence(PageSequence pageSeq) {
187     }
188
189     /**
190      * @param pageSeq PageSequence that is ending.
191      */

192     public void endPageSequence(PageSequence pageSeq) {
193     }
194
195     /**
196      *
197      * @param pagenum PageNumber that is starting.
198      */

199     public void startPageNumber(PageNumber pagenum) {
200     }
201
202     /**
203      *
204      * @param pagenum PageNumber that is ending.
205      */

206     public void endPageNumber(PageNumber pagenum) {
207     }
208
209     /**
210      * This method is called to indicate the start of a new fo:flow
211      * or fo:static-content.
212      * This method also handles fo:static-content tags, because the
213      * StaticContent class is derived from the Flow class.
214      *
215      * @param fl Flow that is starting.
216      */

217     public void startFlow(Flow fl) {
218     }
219
220     /**
221      *
222      * @param fl Flow that is ending.
223      */

224     public void endFlow(Flow fl) {
225     }
226
227     /**
228      *
229      * @param bl Block that is starting.
230      */

231     public void startBlock(Block bl) {
232     }
233
234     /**
235      *
236      * @param bl Block that is ending.
237      */

238     public void endBlock(Block bl) {
239     }
240
241     /**
242     *
243     * @param blc BlockContainer that is starting.
244     */

245     public void startBlockContainer(BlockContainer blc) {
246     }
247
248     /**
249     *
250     * @param blc BlockContainer that is ending.
251     */

252     public void endBlockContainer(BlockContainer blc) {
253     }
254
255     /**
256      *
257      * @param inl Inline that is starting.
258      */

259     public void startInline(Inline inl) {
260     }
261
262     /**
263      *
264      * @param inl Inline that is ending.
265      */

266     public void endInline(Inline inl) {
267     }
268
269     // Tables
270
/**
271      *
272      * @param tbl Table that is starting.
273      */

274     public void startTable(Table tbl) {
275     }
276
277     /**
278      *
279      * @param tbl Table that is ending.
280      */

281     public void endTable(Table tbl) {
282     }
283
284     /**
285      *
286      * @param tc TableColumn that is starting;
287      */

288     public void startColumn(TableColumn tc) {
289     }
290
291     /**
292      *
293      * @param tc TableColumn that is ending;
294      */

295     public void endColumn(TableColumn tc) {
296     }
297
298     /**
299      *
300      * @param th TableBody that is starting;
301      */

302     public void startHeader(TableBody th) {
303     }
304
305     /**
306      *
307      * @param th TableBody that is ending.
308      */

309     public void endHeader(TableBody th) {
310     }
311
312     /**
313      *
314      * @param tf TableFooter that is starting.
315      */

316     public void startFooter(TableBody tf) {
317     }
318
319     /**
320      *
321      * @param tf TableFooter that is ending.
322      */

323     public void endFooter(TableBody tf) {
324     }
325
326     /**
327      *
328      * @param tb TableBody that is starting.
329      */

330     public void startBody(TableBody tb) {
331     }
332
333     /**
334      *
335      * @param tb TableBody that is ending.
336      */

337     public void endBody(TableBody tb) {
338     }
339
340     /**
341      *
342      * @param tr TableRow that is starting.
343      */

344     public void startRow(TableRow tr) {
345     }
346
347     /**
348      *
349      * @param tr TableRow that is ending.
350      */

351     public void endRow(TableRow tr) {
352     }
353
354     /**
355      *
356      * @param tc TableCell that is starting.
357      */

358     public void startCell(TableCell tc) {
359     }
360
361     /**
362      *
363      * @param tc TableCell that is ending.
364      */

365     public void endCell(TableCell tc) {
366     }
367
368
369     // Lists
370
/**
371      *
372      * @param lb ListBlock that is starting.
373      */

374     public void startList(ListBlock lb) {
375     }
376
377     /**
378      *
379      * @param lb ListBlock that is ending.
380      */

381     public void endList(ListBlock lb) {
382     }
383
384     /**
385      *
386      * @param li ListItem that is starting.
387      */

388     public void startListItem(ListItem li) {
389     }
390
391     /**
392      *
393      * @param li ListItem that is ending.
394      */

395     public void endListItem(ListItem li) {
396     }
397
398     /**
399      * Process start of a ListLabel.
400      */

401     public void startListLabel() {
402     }
403
404     /**
405      * Process end of a ListLabel.
406      */

407     public void endListLabel() {
408     }
409
410     /**
411      * Process start of a ListBody.
412      */

413     public void startListBody() {
414     }
415
416     /**
417      * Process end of a ListBody.
418      */

419     public void endListBody() {
420     }
421
422     // Static Regions
423
/**
424      * Process start of a Static.
425      */

426     public void startStatic() {
427     }
428
429     /**
430      * Process end of a Static.
431      */

432     public void endStatic() {
433     }
434
435
436     /**
437      * Process start of a Markup.
438      */

439     public void startMarkup() {
440     }
441
442     /**
443      * Process end of a Markup.
444      */

445     public void endMarkup() {
446     }
447
448     /**
449      * Process start of a Link.
450      * @param basicLink BasicLink that is ending
451      */

452     public void startLink(BasicLink basicLink) {
453     }
454
455     /**
456      * Process end of a Link.
457      */

458     public void endLink() {
459     }
460
461     /**
462      * Process an ExternalGraphic.
463      * @param eg ExternalGraphic to process.
464      */

465     public void image(ExternalGraphic eg) {
466     }
467
468     /**
469      * Process a pageRef.
470      */

471     public void pageRef() {
472     }
473
474     /**
475      * Process an InstreamForeignObject.
476      * @param ifo InstreamForeignObject to process.
477      */

478     public void foreignObject(InstreamForeignObject ifo) {
479     }
480
481     /**
482      * Process the start of a footnote.
483      * @param footnote Footnote that is starting
484      */

485     public void startFootnote(Footnote footnote) {
486     }
487     
488     /**
489      * Process the ending of a footnote.
490      * @param footnote Footnote that is ending
491      */

492     public void endFootnote(Footnote footnote) {
493     }
494
495     /**
496      * Process the start of a footnote body.
497      * @param body FootnoteBody that is starting
498      */

499     public void startFootnoteBody(FootnoteBody body) {
500     }
501     
502     /**
503      * Process the ending of a footnote body.
504      * @param body FootnoteBody that is ending
505      */

506     public void endFootnoteBody(FootnoteBody body) {
507     }
508
509     /**
510      * Process a Leader.
511      * @param l Leader to process.
512      */

513     public void leader(Leader l) {
514     }
515
516     /**
517      * Process a Character.
518      * @param c Character to process.
519      */

520     public void character(Character JavaDoc c) {
521     }
522
523     /**
524      * Process character data.
525      * @param data Array of characters to process.
526      * @param start Offset for characters to process.
527      * @param length Portion of array to process.
528      */

529     public void characters(char data[], int start, int length) {
530     }
531
532 }
533
534
Popular Tags