您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

FOEventHandler.java 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  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. /* $Id$ */
  18. package org.apache.fop.fo;
  19. import org.xml.sax.SAXException;
  20. import org.apache.fop.apps.FOUserAgent;
  21. import org.apache.fop.fo.extensions.ExternalDocument;
  22. import org.apache.fop.fo.flow.BasicLink;
  23. import org.apache.fop.fo.flow.Block;
  24. import org.apache.fop.fo.flow.BlockContainer;
  25. import org.apache.fop.fo.flow.Character;
  26. import org.apache.fop.fo.flow.ExternalGraphic;
  27. import org.apache.fop.fo.flow.Footnote;
  28. import org.apache.fop.fo.flow.FootnoteBody;
  29. import org.apache.fop.fo.flow.Inline;
  30. import org.apache.fop.fo.flow.InstreamForeignObject;
  31. import org.apache.fop.fo.flow.Leader;
  32. import org.apache.fop.fo.flow.ListBlock;
  33. import org.apache.fop.fo.flow.ListItem;
  34. import org.apache.fop.fo.flow.PageNumber;
  35. import org.apache.fop.fo.flow.PageNumberCitation;
  36. import org.apache.fop.fo.flow.PageNumberCitationLast;
  37. import org.apache.fop.fo.flow.table.Table;
  38. import org.apache.fop.fo.flow.table.TableBody;
  39. import org.apache.fop.fo.flow.table.TableFooter;
  40. import org.apache.fop.fo.flow.table.TableHeader;
  41. import org.apache.fop.fo.flow.table.TablePart;
  42. import org.apache.fop.fo.flow.table.TableCell;
  43. import org.apache.fop.fo.flow.table.TableColumn;
  44. import org.apache.fop.fo.flow.table.TableRow;
  45. import org.apache.fop.fo.pagination.Flow;
  46. import org.apache.fop.fo.pagination.PageSequence;
  47. import org.apache.fop.fonts.FontEventAdapter;
  48. import org.apache.fop.fonts.FontInfo;
  49. /**
  50. * Abstract class defining what should be done with SAX events that map to
  51. * XSL-FO input. The events are actually captured by fo/FOTreeBuilder, passed
  52. * to the various fo Objects, which in turn, if needed, pass them to an instance
  53. * of FOEventHandler.
  54. *
  55. * Sub-classes will generally fall into one of two categories:
  56. * 1) a handler that actually builds an FO Tree from the events, or 2) a
  57. * handler that builds a structured (as opposed to formatted) document, such
  58. * as our MIF and RTF output targets.
  59. */
  60. public abstract class FOEventHandler {
  61. /**
  62. * The FOUserAgent for this process
  63. */
  64. protected FOUserAgent foUserAgent;
  65. /**
  66. * The Font information relevant for this document
  67. */
  68. protected FontInfo fontInfo;
  69. /**
  70. * Main constructor
  71. * @param foUserAgent the apps.FOUserAgent instance for this process
  72. */
  73. public FOEventHandler(FOUserAgent foUserAgent) {
  74. this.foUserAgent = foUserAgent;
  75. this.fontInfo = new FontInfo();
  76. this.fontInfo.setEventListener(new FontEventAdapter(foUserAgent.getEventBroadcaster()));
  77. }
  78. /**
  79. * Returns the User Agent object associated with this FOEventHandler.
  80. * @return the User Agent object
  81. */
  82. public FOUserAgent getUserAgent() {
  83. return foUserAgent;
  84. }
  85. /**
  86. * Retrieve the font information for this document
  87. * @return the FontInfo instance for this document
  88. */
  89. public FontInfo getFontInfo() {
  90. return this.fontInfo;
  91. }
  92. /**
  93. * This method is called to indicate the start of a new document run.
  94. * @throws SAXException In case of a problem
  95. */
  96. public void startDocument() throws SAXException {
  97. }
  98. /**
  99. * This method is called to indicate the end of a document run.
  100. * @throws SAXException In case of a problem
  101. */
  102. public void endDocument() throws SAXException {
  103. }
  104. /**
  105. *
  106. * @param pageSeq PageSequence that is starting.
  107. */
  108. public void startPageSequence(PageSequence pageSeq) {
  109. }
  110. /**
  111. * @param pageSeq PageSequence that is ending.
  112. */
  113. public void endPageSequence(PageSequence pageSeq) {
  114. }
  115. /**
  116. *
  117. * @param pagenum PageNumber that is starting.
  118. */
  119. public void startPageNumber(PageNumber pagenum) {
  120. }
  121. /**
  122. *
  123. * @param pagenum PageNumber that is ending.
  124. */
  125. public void endPageNumber(PageNumber pagenum) {
  126. }
  127. /**
  128. *
  129. * @param pageCite PageNumberCitation that is starting.
  130. */
  131. public void startPageNumberCitation(PageNumberCitation pageCite) {
  132. }
  133. /**
  134. *
  135. * @param pageCite PageNumberCitation that is ending.
  136. */
  137. public void endPageNumberCitation(PageNumberCitation pageCite) {
  138. }
  139. /**
  140. *
  141. * @param pageLast PageNumberCitationLast that is starting.
  142. */
  143. public void startPageNumberCitationLast(PageNumberCitationLast pageLast) {
  144. }
  145. /**
  146. *
  147. * @param pageLast PageNumberCitationLast that is ending.
  148. */
  149. public void endPageNumberCitationLast(PageNumberCitationLast pageLast) {
  150. }
  151. /**
  152. * This method is called to indicate the start of a new fo:flow
  153. * or fo:static-content.
  154. * This method also handles fo:static-content tags, because the
  155. * StaticContent class is derived from the Flow class.
  156. *
  157. * @param fl Flow that is starting.
  158. */
  159. public void startFlow(Flow fl) {
  160. }
  161. /**
  162. *
  163. * @param fl Flow that is ending.
  164. */
  165. public void endFlow(Flow fl) {
  166. }
  167. /**
  168. *
  169. * @param bl Block that is starting.
  170. */
  171. public void startBlock(Block bl) {
  172. }
  173. /**
  174. *
  175. * @param bl Block that is ending.
  176. */
  177. public void endBlock(Block bl) {
  178. }
  179. /**
  180. *
  181. * @param blc BlockContainer that is starting.
  182. */
  183. public void startBlockContainer(BlockContainer blc) {
  184. }
  185. /**
  186. *
  187. * @param blc BlockContainer that is ending.
  188. */
  189. public void endBlockContainer(BlockContainer blc) {
  190. }
  191. /**
  192. *
  193. * @param inl Inline that is starting.
  194. */
  195. public void startInline(Inline inl) {
  196. }
  197. /**
  198. *
  199. * @param inl Inline that is ending.
  200. */
  201. public void endInline(Inline inl) {
  202. }
  203. // Tables
  204. /**
  205. *
  206. * @param tbl Table that is starting.
  207. */
  208. public void startTable(Table tbl) {
  209. }
  210. /**
  211. *
  212. * @param tbl Table that is ending.
  213. */
  214. public void endTable(Table tbl) {
  215. }
  216. /**
  217. *
  218. * @param tc TableColumn that is starting;
  219. */
  220. public void startColumn(TableColumn tc) {
  221. }
  222. /**
  223. *
  224. * @param tc TableColumn that is ending;
  225. */
  226. public void endColumn(TableColumn tc) {
  227. }
  228. /**
  229. *
  230. * @param header TableHeader that is starting;
  231. */
  232. public void startHeader(TableHeader header) {
  233. }
  234. /**
  235. *
  236. * @param header TableHeader that is ending.
  237. */
  238. public void endHeader(TableHeader header) {
  239. }
  240. /**
  241. *
  242. * @param footer TableFooter that is starting.
  243. */
  244. public void startFooter(TableFooter footer) {
  245. }
  246. /**
  247. *
  248. * @param footer TableFooter that is ending.
  249. */
  250. public void endFooter(TableFooter footer) {
  251. }
  252. /**
  253. *
  254. * @param body TableBody that is starting.
  255. */
  256. public void startBody(TableBody body) {
  257. }
  258. /**
  259. *
  260. * @param body TableBody that is ending.
  261. */
  262. public void endBody(TableBody body) {
  263. }
  264. /**
  265. *
  266. * @param tr TableRow that is starting.
  267. */
  268. public void startRow(TableRow tr) {
  269. }
  270. /**
  271. *
  272. * @param tr TableRow that is ending.
  273. */
  274. public void endRow(TableRow tr) {
  275. }
  276. /**
  277. *
  278. * @param tc TableCell that is starting.
  279. */
  280. public void startCell(TableCell tc) {
  281. }
  282. /**
  283. *
  284. * @param tc TableCell that is ending.
  285. */
  286. public void endCell(TableCell tc) {
  287. }
  288. // Lists
  289. /**
  290. *
  291. * @param lb ListBlock that is starting.
  292. */
  293. public void startList(ListBlock lb) {
  294. }
  295. /**
  296. *
  297. * @param lb ListBlock that is ending.
  298. */
  299. public void endList(ListBlock lb) {
  300. }
  301. /**
  302. *
  303. * @param li ListItem that is starting.
  304. */
  305. public void startListItem(ListItem li) {
  306. }
  307. /**
  308. *
  309. * @param li ListItem that is ending.
  310. */
  311. public void endListItem(ListItem li) {
  312. }
  313. /**
  314. * Process start of a ListLabel.
  315. */
  316. public void startListLabel() {
  317. }
  318. /**
  319. * Process end of a ListLabel.
  320. */
  321. public void endListLabel() {
  322. }
  323. /**
  324. * Process start of a ListBody.
  325. */
  326. public void startListBody() {
  327. }
  328. /**
  329. * Process end of a ListBody.
  330. */
  331. public void endListBody() {
  332. }
  333. // Static Regions
  334. /**
  335. * Process start of a Static.
  336. */
  337. public void startStatic() {
  338. }
  339. /**
  340. * Process end of a Static.
  341. */
  342. public void endStatic() {
  343. }
  344. /**
  345. * Process start of a Markup.
  346. */
  347. public void startMarkup() {
  348. }
  349. /**
  350. * Process end of a Markup.
  351. */
  352. public void endMarkup() {
  353. }
  354. /**
  355. * Process start of a Link.
  356. * @param basicLink BasicLink that is ending
  357. */
  358. public void startLink(BasicLink basicLink) {
  359. }
  360. /**
  361. * Process end of a Link.
  362. */
  363. public void endLink() {
  364. }
  365. /**
  366. * Process an ExternalGraphic.
  367. * @param eg ExternalGraphic to process.
  368. */
  369. public void image(ExternalGraphic eg) {
  370. }
  371. /**
  372. * Process a pageRef.
  373. */
  374. public void pageRef() {
  375. }
  376. /**
  377. * Process an InstreamForeignObject.
  378. * @param ifo InstreamForeignObject to process.
  379. */
  380. public void foreignObject(InstreamForeignObject ifo) {
  381. }
  382. /**
  383. * Process the start of a footnote.
  384. * @param footnote Footnote that is starting
  385. */
  386. public void startFootnote(Footnote footnote) {
  387. }
  388. /**
  389. * Process the ending of a footnote.
  390. * @param footnote Footnote that is ending
  391. */
  392. public void endFootnote(Footnote footnote) {
  393. }
  394. /**
  395. * Process the start of a footnote body.
  396. * @param body FootnoteBody that is starting
  397. */
  398. public void startFootnoteBody(FootnoteBody body) {
  399. }
  400. /**
  401. * Process the ending of a footnote body.
  402. * @param body FootnoteBody that is ending
  403. */
  404. public void endFootnoteBody(FootnoteBody body) {
  405. }
  406. /**
  407. * Process a Leader.
  408. * @param l Leader to process.
  409. */
  410. public void leader(Leader l) {
  411. }
  412. /**
  413. * Process a Character.
  414. * @param c Character to process.
  415. */
  416. public void character(Character c) {
  417. }
  418. /**
  419. * Process character data.
  420. * @param data Array of characters to process.
  421. * @param start Offset for characters to process.
  422. * @param length Portion of array to process.
  423. */
  424. public void characters(char[] data, int start, int length) {
  425. }
  426. /**
  427. * Process the start of the external-document extension.
  428. * @param document the external-document node
  429. */
  430. public void startExternalDocument(ExternalDocument document) {
  431. }
  432. /**
  433. * Process the end of the external-document extension.
  434. * @param document the external-document node
  435. */
  436. public void endExternalDocument(ExternalDocument document) {
  437. }
  438. }