Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

FOEventHandler.java 13KB

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