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 15KB

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