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.

FOEventRecorder.java 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  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.accessibility.fo;
  19. import java.util.ArrayList;
  20. import java.util.List;
  21. import org.apache.fop.fo.FOEventHandler;
  22. import org.apache.fop.fo.FOText;
  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. final class FOEventRecorder extends FOEventHandler {
  49. private interface Event {
  50. void replay(FOEventHandler target);
  51. }
  52. private final List<Event> events = new ArrayList<Event>();
  53. public void replay(FOEventHandler target) {
  54. for (Event event : events) {
  55. event.replay(target);
  56. }
  57. }
  58. @Override
  59. public void startPageNumber(final PageNumber pagenum) {
  60. events.add(new Event() {
  61. public void replay(FOEventHandler target) {
  62. target.startPageNumber(pagenum);
  63. }
  64. });
  65. }
  66. @Override
  67. public void endPageNumber(final PageNumber pagenum) {
  68. events.add(new Event() {
  69. public void replay(FOEventHandler target) {
  70. target.endPageNumber(pagenum);
  71. }
  72. });
  73. }
  74. @Override
  75. public void startPageNumberCitation(final PageNumberCitation pageCite) {
  76. events.add(new Event() {
  77. public void replay(FOEventHandler target) {
  78. target.startPageNumberCitation(pageCite);
  79. }
  80. });
  81. }
  82. @Override
  83. public void endPageNumberCitation(final PageNumberCitation pageCite) {
  84. events.add(new Event() {
  85. public void replay(FOEventHandler target) {
  86. target.endPageNumberCitation(pageCite);
  87. }
  88. });
  89. }
  90. @Override
  91. public void startPageNumberCitationLast(final PageNumberCitationLast pageLast) {
  92. events.add(new Event() {
  93. public void replay(FOEventHandler target) {
  94. target.startPageNumberCitationLast(pageLast);
  95. }
  96. });
  97. }
  98. @Override
  99. public void endPageNumberCitationLast(final PageNumberCitationLast pageLast) {
  100. events.add(new Event() {
  101. public void replay(FOEventHandler target) {
  102. target.endPageNumberCitationLast(pageLast);
  103. }
  104. });
  105. }
  106. @Override
  107. public void startBlock(final Block bl) {
  108. events.add(new Event() {
  109. public void replay(FOEventHandler target) {
  110. target.startBlock(bl);
  111. }
  112. });
  113. }
  114. @Override
  115. public void endBlock(final Block bl) {
  116. events.add(new Event() {
  117. public void replay(FOEventHandler target) {
  118. target.endBlock(bl);
  119. }
  120. });
  121. }
  122. @Override
  123. public void startBlockContainer(final BlockContainer blc) {
  124. events.add(new Event() {
  125. public void replay(FOEventHandler target) {
  126. target.startBlockContainer(blc);
  127. }
  128. });
  129. }
  130. @Override
  131. public void endBlockContainer(final BlockContainer blc) {
  132. events.add(new Event() {
  133. public void replay(FOEventHandler target) {
  134. target.endBlockContainer(blc);
  135. }
  136. });
  137. }
  138. @Override
  139. public void startInline(final Inline inl) {
  140. events.add(new Event() {
  141. public void replay(FOEventHandler target) {
  142. target.startInline(inl);
  143. }
  144. });
  145. }
  146. @Override
  147. public void endInline(final Inline inl) {
  148. events.add(new Event() {
  149. public void replay(FOEventHandler target) {
  150. target.endInline(inl);
  151. }
  152. });
  153. }
  154. @Override
  155. public void startTable(final Table tbl) {
  156. events.add(new Event() {
  157. public void replay(FOEventHandler target) {
  158. target.startTable(tbl);
  159. }
  160. });
  161. }
  162. @Override
  163. public void endTable(final Table tbl) {
  164. events.add(new Event() {
  165. public void replay(FOEventHandler target) {
  166. target.endTable(tbl);
  167. }
  168. });
  169. }
  170. @Override
  171. public void startColumn(final TableColumn tc) {
  172. events.add(new Event() {
  173. public void replay(FOEventHandler target) {
  174. target.startColumn(tc);
  175. }
  176. });
  177. }
  178. @Override
  179. public void endColumn(final TableColumn tc) {
  180. events.add(new Event() {
  181. public void replay(FOEventHandler target) {
  182. target.endColumn(tc);
  183. }
  184. });
  185. }
  186. @Override
  187. public void startHeader(final TableHeader header) {
  188. events.add(new Event() {
  189. public void replay(FOEventHandler target) {
  190. target.startHeader(header);
  191. }
  192. });
  193. }
  194. @Override
  195. public void endHeader(final TableHeader header) {
  196. events.add(new Event() {
  197. public void replay(FOEventHandler target) {
  198. target.endHeader(header);
  199. }
  200. });
  201. }
  202. @Override
  203. public void startFooter(final TableFooter footer) {
  204. events.add(new Event() {
  205. public void replay(FOEventHandler target) {
  206. target.startFooter(footer);
  207. }
  208. });
  209. }
  210. @Override
  211. public void endFooter(final TableFooter footer) {
  212. events.add(new Event() {
  213. public void replay(FOEventHandler target) {
  214. target.endFooter(footer);
  215. }
  216. });
  217. }
  218. @Override
  219. public void startBody(final TableBody body) {
  220. events.add(new Event() {
  221. public void replay(FOEventHandler target) {
  222. target.startBody(body);
  223. }
  224. });
  225. }
  226. @Override
  227. public void endBody(final TableBody body) {
  228. events.add(new Event() {
  229. public void replay(FOEventHandler target) {
  230. target.endBody(body);
  231. }
  232. });
  233. }
  234. @Override
  235. public void startRow(final TableRow tr) {
  236. events.add(new Event() {
  237. public void replay(FOEventHandler target) {
  238. target.startRow(tr);
  239. }
  240. });
  241. }
  242. @Override
  243. public void endRow(final TableRow tr) {
  244. events.add(new Event() {
  245. public void replay(FOEventHandler target) {
  246. target.endRow(tr);
  247. }
  248. });
  249. }
  250. @Override
  251. public void startCell(final TableCell tc) {
  252. events.add(new Event() {
  253. public void replay(FOEventHandler target) {
  254. target.startCell(tc);
  255. }
  256. });
  257. }
  258. @Override
  259. public void endCell(final TableCell tc) {
  260. events.add(new Event() {
  261. public void replay(FOEventHandler target) {
  262. target.endCell(tc);
  263. }
  264. });
  265. }
  266. @Override
  267. public void startList(final ListBlock lb) {
  268. events.add(new Event() {
  269. public void replay(FOEventHandler target) {
  270. target.startList(lb);
  271. }
  272. });
  273. }
  274. @Override
  275. public void endList(final ListBlock lb) {
  276. events.add(new Event() {
  277. public void replay(FOEventHandler target) {
  278. target.endList(lb);
  279. }
  280. });
  281. }
  282. @Override
  283. public void startListItem(final ListItem li) {
  284. events.add(new Event() {
  285. public void replay(FOEventHandler target) {
  286. target.startListItem(li);
  287. }
  288. });
  289. }
  290. @Override
  291. public void endListItem(final ListItem li) {
  292. events.add(new Event() {
  293. public void replay(FOEventHandler target) {
  294. target.endListItem(li);
  295. }
  296. });
  297. }
  298. @Override
  299. public void startListLabel(final ListItemLabel listItemLabel) {
  300. events.add(new Event() {
  301. public void replay(FOEventHandler target) {
  302. target.startListLabel(listItemLabel);
  303. }
  304. });
  305. }
  306. @Override
  307. public void endListLabel(final ListItemLabel listItemLabel) {
  308. events.add(new Event() {
  309. public void replay(FOEventHandler target) {
  310. target.endListLabel(listItemLabel);
  311. }
  312. });
  313. }
  314. @Override
  315. public void startListBody(final ListItemBody listItemBody) {
  316. events.add(new Event() {
  317. public void replay(FOEventHandler target) {
  318. target.startListBody(listItemBody);
  319. }
  320. });
  321. }
  322. @Override
  323. public void endListBody(final ListItemBody listItemBody) {
  324. events.add(new Event() {
  325. public void replay(FOEventHandler target) {
  326. target.endListBody(listItemBody);
  327. }
  328. });
  329. }
  330. @Override
  331. public void startLink(final BasicLink basicLink) {
  332. events.add(new Event() {
  333. public void replay(FOEventHandler target) {
  334. target.startLink(basicLink);
  335. }
  336. });
  337. }
  338. @Override
  339. public void endLink(final BasicLink basicLink) {
  340. events.add(new Event() {
  341. public void replay(FOEventHandler target) {
  342. target.endLink(basicLink);
  343. }
  344. });
  345. }
  346. @Override
  347. public void image(final ExternalGraphic eg) {
  348. events.add(new Event() {
  349. public void replay(FOEventHandler target) {
  350. target.image(eg);
  351. }
  352. });
  353. }
  354. @Override
  355. public void startInstreamForeignObject(final InstreamForeignObject ifo) {
  356. events.add(new Event() {
  357. public void replay(FOEventHandler target) {
  358. target.startInstreamForeignObject(ifo);
  359. }
  360. });
  361. }
  362. @Override
  363. public void endInstreamForeignObject(final InstreamForeignObject ifo) {
  364. events.add(new Event() {
  365. public void replay(FOEventHandler target) {
  366. target.endInstreamForeignObject(ifo);
  367. }
  368. });
  369. }
  370. @Override
  371. public void startFootnote(final Footnote footnote) {
  372. events.add(new Event() {
  373. public void replay(FOEventHandler target) {
  374. target.startFootnote(footnote);
  375. }
  376. });
  377. }
  378. @Override
  379. public void endFootnote(final Footnote footnote) {
  380. events.add(new Event() {
  381. public void replay(FOEventHandler target) {
  382. target.endFootnote(footnote);
  383. }
  384. });
  385. }
  386. @Override
  387. public void startFootnoteBody(final FootnoteBody body) {
  388. events.add(new Event() {
  389. public void replay(FOEventHandler target) {
  390. target.startFootnoteBody(body);
  391. }
  392. });
  393. }
  394. @Override
  395. public void endFootnoteBody(final FootnoteBody body) {
  396. events.add(new Event() {
  397. public void replay(FOEventHandler target) {
  398. target.endFootnoteBody(body);
  399. }
  400. });
  401. }
  402. @Override
  403. public void startLeader(final Leader l) {
  404. events.add(new Event() {
  405. public void replay(FOEventHandler target) {
  406. target.startLeader(l);
  407. }
  408. });
  409. }
  410. @Override
  411. public void endLeader(final Leader l) {
  412. events.add(new Event() {
  413. public void replay(FOEventHandler target) {
  414. target.endLeader(l);
  415. }
  416. });
  417. }
  418. @Override
  419. public void startWrapper(final Wrapper wrapper) {
  420. events.add(new Event() {
  421. public void replay(FOEventHandler target) {
  422. target.startWrapper(wrapper);
  423. }
  424. });
  425. }
  426. @Override
  427. public void endWrapper(final Wrapper wrapper) {
  428. events.add(new Event() {
  429. public void replay(FOEventHandler target) {
  430. target.endWrapper(wrapper);
  431. }
  432. });
  433. }
  434. @Override
  435. public void character(final Character c) {
  436. events.add(new Event() {
  437. public void replay(FOEventHandler target) {
  438. target.character(c);
  439. }
  440. });
  441. }
  442. @Override
  443. public void characters(final FOText foText) {
  444. events.add(new Event() {
  445. public void replay(FOEventHandler target) {
  446. target.characters(foText);
  447. }
  448. });
  449. }
  450. }