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.

FOEventHandler.java 13KB

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