You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FOInputHandler.java 9.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. /*
  2. * Copyright 1999-2004 The Apache Software Foundation.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /* $Id$ */
  17. package org.apache.fop.fo;
  18. // Avalon
  19. import org.apache.avalon.framework.logger.AbstractLogEnabled;
  20. // FOP
  21. import org.apache.fop.apps.FOPException;
  22. import org.apache.fop.fo.flow.BasicLink;
  23. import org.apache.fop.fo.flow.Block;
  24. import org.apache.fop.fo.flow.ExternalGraphic;
  25. import org.apache.fop.fo.flow.Footnote;
  26. import org.apache.fop.fo.flow.FootnoteBody;
  27. import org.apache.fop.fo.flow.Inline;
  28. import org.apache.fop.fo.flow.InstreamForeignObject;
  29. import org.apache.fop.fo.flow.Leader;
  30. import org.apache.fop.fo.flow.ListBlock;
  31. import org.apache.fop.fo.flow.ListItem;
  32. import org.apache.fop.fo.flow.PageNumber;
  33. import org.apache.fop.fo.flow.Table;
  34. import org.apache.fop.fo.flow.TableColumn;
  35. import org.apache.fop.fo.flow.TableBody;
  36. import org.apache.fop.fo.flow.TableCell;
  37. import org.apache.fop.fo.flow.TableRow;
  38. import org.apache.fop.fo.pagination.Flow;
  39. import org.apache.fop.fo.pagination.PageSequence;
  40. import org.xml.sax.SAXException;
  41. /**
  42. * Abstract class defining what should be done with SAX events that map to
  43. * XSL-FO input. The events are actually captured by fo/FOTreeBuilder, passed
  44. * to the various fo Objects, which in turn, if needed, pass them to an instance
  45. * of FOInputHandler.
  46. *
  47. * Sub-classes will generally fall into one of two categories:
  48. * 1) a handler that actually builds an FO Tree from the events, or 2) a
  49. * handler that builds a structured (as opposed to formatted) document, such
  50. * as our MIF and RTF output targets.
  51. */
  52. public abstract class FOInputHandler extends AbstractLogEnabled {
  53. /**
  54. * The FOTreeControl object that is controlling the FO Tree being built
  55. */
  56. public FOTreeControl foTreeControl = null;
  57. /**
  58. * Main constructor
  59. * @param foTreeControl the FOTreeControl implementation that is controlling
  60. * the FO Tree being built
  61. */
  62. public FOInputHandler(FOTreeControl foTreeControl) {
  63. this.foTreeControl = foTreeControl;
  64. }
  65. /**
  66. * Returns the FontInfo object associated with this FOInputHandler.
  67. * @return the FontInof object
  68. */
  69. public FOTreeControl getFontInfo() {
  70. return null;
  71. }
  72. /**
  73. * This method is called to indicate the start of a new document run.
  74. * @throws SAXException In case of a problem
  75. */
  76. public abstract void startDocument() throws SAXException;
  77. /**
  78. * This method is called to indicate the end of a document run.
  79. * @throws SAXException In case of a problem
  80. */
  81. public abstract void endDocument() throws SAXException;
  82. /**
  83. *
  84. * @param pageSeq PageSequence that is starting.
  85. */
  86. public abstract void startPageSequence(PageSequence pageSeq);
  87. /**
  88. *
  89. * @param pageSeq PageSequence that is ending.
  90. * @throws FOPException For errors encountered.
  91. */
  92. public abstract void endPageSequence(PageSequence pageSeq) throws FOPException;
  93. /**
  94. *
  95. * @param pagenum PageNumber that is starting.
  96. */
  97. public abstract void startPageNumber(PageNumber pagenum);
  98. /**
  99. *
  100. * @param pagenum PageNumber that is ending.
  101. */
  102. public abstract void endPageNumber(PageNumber pagenum);
  103. /**
  104. * This method is called to indicate the start of a new fo:flow or fo:static-content.
  105. * This method also handles fo:static-content tags, because the StaticContent class
  106. * is derived from the Flow class.
  107. *
  108. * @param fl Flow that is starting.
  109. */
  110. public abstract void startFlow(Flow fl);
  111. /**
  112. *
  113. * @param fl Flow that is ending.
  114. */
  115. public abstract void endFlow(Flow fl);
  116. /**
  117. *
  118. * @param bl Block that is starting.
  119. */
  120. public abstract void startBlock(Block bl);
  121. /**
  122. *
  123. * @param bl Block that is ending.
  124. */
  125. public abstract void endBlock(Block bl);
  126. /**
  127. *
  128. * @param inl Inline that is starting.
  129. */
  130. public abstract void startInline(Inline inl);
  131. /**
  132. *
  133. * @param inl Inline that is ending.
  134. */
  135. public abstract void endInline(Inline inl);
  136. // Tables
  137. /**
  138. *
  139. * @param tbl Table that is starting.
  140. */
  141. public abstract void startTable(Table tbl);
  142. /**
  143. *
  144. * @param tbl Table that is ending.
  145. */
  146. public abstract void endTable(Table tbl);
  147. /**
  148. *
  149. * @param tc TableColumn that is starting;
  150. */
  151. public abstract void startColumn(TableColumn tc);
  152. /**
  153. *
  154. * @param tc TableColumn that is ending;
  155. */
  156. public abstract void endColumn(TableColumn tc);
  157. /**
  158. *
  159. * @param th TableBody that is starting;
  160. */
  161. public abstract void startHeader(TableBody th);
  162. /**
  163. *
  164. * @param th TableBody that is ending.
  165. */
  166. public abstract void endHeader(TableBody th);
  167. /**
  168. *
  169. * @param tf TableFooter that is starting.
  170. */
  171. public abstract void startFooter(TableBody tf);
  172. /**
  173. *
  174. * @param tf TableFooter that is ending.
  175. */
  176. public abstract void endFooter(TableBody tf);
  177. /**
  178. *
  179. * @param tb TableBody that is starting.
  180. */
  181. public abstract void startBody(TableBody tb);
  182. /**
  183. *
  184. * @param tb TableBody that is ending.
  185. */
  186. public abstract void endBody(TableBody tb);
  187. /**
  188. *
  189. * @param tr TableRow that is starting.
  190. */
  191. public abstract void startRow(TableRow tr);
  192. /**
  193. *
  194. * @param tr TableRow that is ending.
  195. */
  196. public abstract void endRow(TableRow tr);
  197. /**
  198. *
  199. * @param tc TableCell that is starting.
  200. */
  201. public abstract void startCell(TableCell tc);
  202. /**
  203. *
  204. * @param tc TableCell that is ending.
  205. */
  206. public abstract void endCell(TableCell tc);
  207. // Lists
  208. /**
  209. *
  210. * @param lb ListBlock that is starting.
  211. */
  212. public abstract void startList(ListBlock lb);
  213. /**
  214. *
  215. * @param lb ListBlock that is ending.
  216. */
  217. public abstract void endList(ListBlock lb);
  218. /**
  219. *
  220. * @param li ListItem that is starting.
  221. */
  222. public abstract void startListItem(ListItem li);
  223. /**
  224. *
  225. * @param li ListItem that is ending.
  226. */
  227. public abstract void endListItem(ListItem li);
  228. /**
  229. * Process start of a ListLabel.
  230. */
  231. public abstract void startListLabel();
  232. /**
  233. * Process end of a ListLabel.
  234. */
  235. public abstract void endListLabel();
  236. /**
  237. * Process start of a ListBody.
  238. */
  239. public abstract void startListBody();
  240. /**
  241. * Process end of a ListBody.
  242. */
  243. public abstract void endListBody();
  244. // Static Regions
  245. /**
  246. * Process start of a Static.
  247. */
  248. public abstract void startStatic();
  249. /**
  250. * Process end of a Static.
  251. */
  252. public abstract void endStatic();
  253. /**
  254. * Process start of a Markup.
  255. */
  256. public abstract void startMarkup();
  257. /**
  258. * Process end of a Markup.
  259. */
  260. public abstract void endMarkup();
  261. /**
  262. * Process start of a Link.
  263. * @param basicLink BasicLink that is ending
  264. */
  265. public abstract void startLink(BasicLink basicLink);
  266. /**
  267. * Process end of a Link.
  268. */
  269. public abstract void endLink();
  270. /**
  271. * Process an ExternalGraphic.
  272. * @param eg ExternalGraphic to process.
  273. */
  274. public abstract void image(ExternalGraphic eg);
  275. /**
  276. * Process a pageRef.
  277. */
  278. public abstract void pageRef();
  279. /**
  280. * Process an InstreamForeignObject.
  281. * @param ifo InstreamForeignObject to process.
  282. */
  283. public abstract void foreignObject(InstreamForeignObject ifo);
  284. /**
  285. * Process the start of a footnote.
  286. * @param footnote Footnote that is starting
  287. */
  288. public abstract void startFootnote(Footnote footnote);
  289. /**
  290. * Process the ending of a footnote.
  291. * @param footnote Footnote that is ending
  292. */
  293. public abstract void endFootnote(Footnote footnote);
  294. /**
  295. * Process the start of a footnote body.
  296. * @param body FootnoteBody that is starting
  297. */
  298. public abstract void startFootnoteBody(FootnoteBody body);
  299. /**
  300. * Process the ending of a footnote body.
  301. * @param body FootnoteBody that is ending
  302. */
  303. public abstract void endFootnoteBody(FootnoteBody body);
  304. /**
  305. * Process a Leader.
  306. * @param l Leader to process.
  307. */
  308. public abstract void leader(Leader l);
  309. /**
  310. * Process character data.
  311. * @param data Array of characters to process.
  312. * @param start Offset for characters to process.
  313. * @param length Portion of array to process.
  314. */
  315. public abstract void characters(char data[], int start, int length);
  316. }