Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

FOElementMapping.java 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. /*
  2. * $Id: FOElementMapping.java,v 1.5 2003/03/05 21:48:02 jeremias Exp $
  3. * ============================================================================
  4. * The Apache Software License, Version 1.1
  5. * ============================================================================
  6. *
  7. * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  8. *
  9. * Redistribution and use in source and binary forms, with or without modifica-
  10. * tion, are permitted provided that the following conditions are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright notice,
  13. * this list of conditions and the following disclaimer.
  14. *
  15. * 2. Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. *
  19. * 3. The end-user documentation included with the redistribution, if any, must
  20. * include the following acknowledgment: "This product includes software
  21. * developed by the Apache Software Foundation (http://www.apache.org/)."
  22. * Alternately, this acknowledgment may appear in the software itself, if
  23. * and wherever such third-party acknowledgments normally appear.
  24. *
  25. * 4. The names "FOP" and "Apache Software Foundation" must not be used to
  26. * endorse or promote products derived from this software without prior
  27. * written permission. For written permission, please contact
  28. * apache@apache.org.
  29. *
  30. * 5. Products derived from this software may not be called "Apache", nor may
  31. * "Apache" appear in their name, without prior written permission of the
  32. * Apache Software Foundation.
  33. *
  34. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  35. * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  36. * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  37. * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  38. * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
  39. * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  40. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  41. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  42. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  43. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  44. * ============================================================================
  45. *
  46. * This software consists of voluntary contributions made by many individuals
  47. * on behalf of the Apache Software Foundation and was originally created by
  48. * James Tauber <jtauber@jtauber.com>. For more information on the Apache
  49. * Software Foundation, please see <http://www.apache.org/>.
  50. */
  51. package org.apache.fop.fo;
  52. // Java
  53. import java.util.HashMap;
  54. /**
  55. * Element mapping class for all XSL-FO elements.
  56. */
  57. public class FOElementMapping implements ElementMapping {
  58. private static HashMap foObjs = null;
  59. private static synchronized void setupFO() {
  60. if (foObjs == null) {
  61. foObjs = new HashMap();
  62. // Declarations and Pagination and Layout Formatting Objects
  63. foObjs.put("root", new R());
  64. foObjs.put("declarations", new Dec());
  65. foObjs.put("color-profile", new CP());
  66. foObjs.put("page-sequence", new PS());
  67. foObjs.put("layout-master-set", new LMS());
  68. foObjs.put("page-sequence-master",
  69. new PSM());
  70. foObjs.put("single-page-master-reference",
  71. new SPMR());
  72. foObjs.put("repeatable-page-master-reference",
  73. new RPMR());
  74. foObjs.put("repeatable-page-master-alternatives",
  75. new RPMA());
  76. foObjs.put("conditional-page-master-reference",
  77. new CPMR());
  78. foObjs.put("simple-page-master",
  79. new SPM());
  80. foObjs.put("region-body", new RB());
  81. foObjs.put("region-before", new RBefore());
  82. foObjs.put("region-after", new RA());
  83. foObjs.put("region-start", new RS());
  84. foObjs.put("region-end", new RE());
  85. foObjs.put("flow", new Fl());
  86. foObjs.put("static-content", new SC());
  87. foObjs.put("title", new T());
  88. // Block-level Formatting Objects
  89. foObjs.put("block", new B());
  90. foObjs.put("block-container", new BC());
  91. // Inline-level Formatting Objects
  92. foObjs.put("bidi-override", new BO());
  93. foObjs.put("character",
  94. new Ch());
  95. foObjs.put("initial-property-set",
  96. new IPS());
  97. foObjs.put("external-graphic", new EG());
  98. foObjs.put("instream-foreign-object",
  99. new IFO());
  100. foObjs.put("inline", new In());
  101. foObjs.put("inline-container", new IC());
  102. foObjs.put("leader", new L());
  103. foObjs.put("page-number", new PN());
  104. foObjs.put("page-number-citation",
  105. new PNC());
  106. // Formatting Objects for Tables
  107. foObjs.put("table-and-caption", new TAC());
  108. foObjs.put("table", new Ta());
  109. foObjs.put("table-column", new TC());
  110. foObjs.put("table-caption", new TCaption());
  111. foObjs.put("table-header", new TB());
  112. foObjs.put("table-footer", new TB());
  113. foObjs.put("table-body", new TB());
  114. foObjs.put("table-row", new TR());
  115. foObjs.put("table-cell", new TCell());
  116. // Formatting Objects for Lists
  117. foObjs.put("list-block", new LB());
  118. foObjs.put("list-item", new LI());
  119. foObjs.put("list-item-body", new LIB());
  120. foObjs.put("list-item-label", new LIL());
  121. // Dynamic Effects: Link and Multi Formatting Objects
  122. foObjs.put("basic-link", new BL());
  123. foObjs.put("multi-switch", new MS());
  124. foObjs.put("multi-case", new MC());
  125. foObjs.put("multi-toggle", new MT());
  126. foObjs.put("multi-properties", new MP());
  127. foObjs.put("multi-property-set",
  128. new MPS());
  129. // Out-of-Line Formatting Objects
  130. foObjs.put("float",
  131. new F());
  132. foObjs.put("footnote", new Foot());
  133. foObjs.put("footnote-body", new FB());
  134. // Other Formatting Objects
  135. foObjs.put("wrapper", new W());
  136. foObjs.put("marker", new M());
  137. foObjs.put("retrieve-marker", new RM());
  138. }
  139. }
  140. /**
  141. * @see org.apache.fop.fo.ElementMapping#addToBuilder(FOTreeBuilder)
  142. */
  143. public void addToBuilder(FOTreeBuilder builder) {
  144. setupFO();
  145. String uri = "http://www.w3.org/1999/XSL/Format";
  146. builder.addMapping(uri, foObjs);
  147. }
  148. static class R extends ElementMapping.Maker {
  149. public FONode make(FONode parent) {
  150. return new org.apache.fop.fo.pagination.Root(parent);
  151. }
  152. }
  153. static class Dec extends ElementMapping.Maker {
  154. public FONode make(FONode parent) {
  155. return new Declarations(parent);
  156. }
  157. }
  158. static class CP extends ElementMapping.Maker {
  159. public FONode make(FONode parent) {
  160. return new ColorProfile(parent);
  161. }
  162. }
  163. static class PS extends ElementMapping.Maker {
  164. public FONode make(FONode parent) {
  165. return new org.apache.fop.fo.pagination.PageSequence(parent);
  166. }
  167. }
  168. static class LMS extends ElementMapping.Maker {
  169. public FONode make(FONode parent) {
  170. return new org.apache.fop.fo.pagination.LayoutMasterSet(parent);
  171. }
  172. }
  173. static class PSM extends ElementMapping.Maker {
  174. public FONode make(FONode parent) {
  175. return new org.apache.fop.fo.pagination.PageSequenceMaster(parent);
  176. }
  177. }
  178. static class SPMR extends ElementMapping.Maker {
  179. public FONode make(FONode parent) {
  180. return new org.apache.fop.fo.pagination.SinglePageMasterReference(parent);
  181. }
  182. }
  183. static class RPMR extends ElementMapping.Maker {
  184. public FONode make(FONode parent) {
  185. return new org.apache.fop.fo.pagination.RepeatablePageMasterReference(parent);
  186. }
  187. }
  188. static class RPMA extends ElementMapping.Maker {
  189. public FONode make(FONode parent) {
  190. return new org.apache.fop.fo.pagination.RepeatablePageMasterAlternatives(parent);
  191. }
  192. }
  193. static class CPMR extends ElementMapping.Maker {
  194. public FONode make(FONode parent) {
  195. return new org.apache.fop.fo.pagination.ConditionalPageMasterReference(parent);
  196. }
  197. }
  198. static class SPM extends ElementMapping.Maker {
  199. public FONode make(FONode parent) {
  200. return new org.apache.fop.fo.pagination.SimplePageMaster(parent);
  201. }
  202. }
  203. static class RB extends ElementMapping.Maker {
  204. public FONode make(FONode parent) {
  205. return new org.apache.fop.fo.pagination.RegionBody(parent);
  206. }
  207. }
  208. static class RBefore extends ElementMapping.Maker {
  209. public FONode make(FONode parent) {
  210. return new org.apache.fop.fo.pagination.RegionBefore(parent);
  211. }
  212. }
  213. static class RA extends ElementMapping.Maker {
  214. public FONode make(FONode parent) {
  215. return new org.apache.fop.fo.pagination.RegionAfter(parent);
  216. }
  217. }
  218. static class RS extends ElementMapping.Maker {
  219. public FONode make(FONode parent) {
  220. return new org.apache.fop.fo.pagination.RegionStart(parent);
  221. }
  222. }
  223. static class RE extends ElementMapping.Maker {
  224. public FONode make(FONode parent) {
  225. return new org.apache.fop.fo.pagination.RegionEnd(parent);
  226. }
  227. }
  228. static class Fl extends ElementMapping.Maker {
  229. public FONode make(FONode parent) {
  230. return new org.apache.fop.fo.flow.Flow(parent);
  231. }
  232. }
  233. static class SC extends ElementMapping.Maker {
  234. public FONode make(FONode parent) {
  235. return new org.apache.fop.fo.flow.StaticContent(parent);
  236. }
  237. }
  238. static class T extends ElementMapping.Maker {
  239. public FONode make(FONode parent) {
  240. return new Title(parent);
  241. }
  242. }
  243. static class B extends ElementMapping.Maker {
  244. public FONode make(FONode parent) {
  245. return new org.apache.fop.fo.flow.Block(parent);
  246. }
  247. }
  248. static class BC extends ElementMapping.Maker {
  249. public FONode make(FONode parent) {
  250. return new org.apache.fop.fo.flow.BlockContainer(parent);
  251. }
  252. }
  253. static class BO extends ElementMapping.Maker {
  254. public FONode make(FONode parent) {
  255. return new org.apache.fop.fo.flow.BidiOverride(parent);
  256. }
  257. }
  258. static class Ch extends ElementMapping.Maker {
  259. public FONode make(FONode parent) {
  260. return new org.apache.fop.fo.flow.Character(parent);
  261. }
  262. }
  263. static class IPS extends ElementMapping.Maker {
  264. public FONode make(FONode parent) {
  265. return new org.apache.fop.fo.flow.InitialPropertySet(parent);
  266. }
  267. }
  268. static class EG extends ElementMapping.Maker {
  269. public FONode make(FONode parent) {
  270. return new org.apache.fop.fo.flow.ExternalGraphic(parent);
  271. }
  272. }
  273. static class IFO extends ElementMapping.Maker {
  274. public FONode make(FONode parent) {
  275. return new org.apache.fop.fo.flow.InstreamForeignObject(parent);
  276. }
  277. }
  278. static class In extends ElementMapping.Maker {
  279. public FONode make(FONode parent) {
  280. return new org.apache.fop.fo.flow.Inline(parent);
  281. }
  282. }
  283. static class IC extends ElementMapping.Maker {
  284. public FONode make(FONode parent) {
  285. return new org.apache.fop.fo.flow.InlineContainer(parent);
  286. }
  287. }
  288. static class L extends ElementMapping.Maker {
  289. public FONode make(FONode parent) {
  290. return new org.apache.fop.fo.flow.Leader(parent);
  291. }
  292. }
  293. static class PN extends ElementMapping.Maker {
  294. public FONode make(FONode parent) {
  295. return new org.apache.fop.fo.flow.PageNumber(parent);
  296. }
  297. }
  298. static class PNC extends ElementMapping.Maker {
  299. public FONode make(FONode parent) {
  300. return new org.apache.fop.fo.flow.PageNumberCitation(parent);
  301. }
  302. }
  303. static class TAC extends ElementMapping.Maker {
  304. public FONode make(FONode parent) {
  305. return new org.apache.fop.fo.flow.TableAndCaption(parent);
  306. }
  307. }
  308. static class Ta extends ElementMapping.Maker {
  309. public FONode make(FONode parent) {
  310. return new org.apache.fop.fo.flow.Table(parent);
  311. }
  312. }
  313. static class TC extends ElementMapping.Maker {
  314. public FONode make(FONode parent) {
  315. return new org.apache.fop.fo.flow.TableColumn(parent);
  316. }
  317. }
  318. static class TCaption extends ElementMapping.Maker {
  319. public FONode make(FONode parent) {
  320. return new org.apache.fop.fo.flow.TableCaption(parent);
  321. }
  322. }
  323. static class TB extends ElementMapping.Maker {
  324. public FONode make(FONode parent) {
  325. return new org.apache.fop.fo.flow.TableBody(parent);
  326. }
  327. }
  328. static class TR extends ElementMapping.Maker {
  329. public FONode make(FONode parent) {
  330. return new org.apache.fop.fo.flow.TableRow(parent);
  331. }
  332. }
  333. static class TCell extends ElementMapping.Maker {
  334. public FONode make(FONode parent) {
  335. return new org.apache.fop.fo.flow.TableCell(parent);
  336. }
  337. }
  338. static class LB extends ElementMapping.Maker {
  339. public FONode make(FONode parent) {
  340. return new org.apache.fop.fo.flow.ListBlock(parent);
  341. }
  342. }
  343. static class LI extends ElementMapping.Maker {
  344. public FONode make(FONode parent) {
  345. return new org.apache.fop.fo.flow.ListItem(parent);
  346. }
  347. }
  348. static class LIB extends ElementMapping.Maker {
  349. public FONode make(FONode parent) {
  350. return new org.apache.fop.fo.flow.ListItemBody(parent);
  351. }
  352. }
  353. static class LIL extends ElementMapping.Maker {
  354. public FONode make(FONode parent) {
  355. return new org.apache.fop.fo.flow.ListItemLabel(parent);
  356. }
  357. }
  358. static class BL extends ElementMapping.Maker {
  359. public FONode make(FONode parent) {
  360. return new org.apache.fop.fo.flow.BasicLink(parent);
  361. }
  362. }
  363. static class MS extends ElementMapping.Maker {
  364. public FONode make(FONode parent) {
  365. return new org.apache.fop.fo.flow.MultiSwitch(parent);
  366. }
  367. }
  368. static class MC extends ElementMapping.Maker {
  369. public FONode make(FONode parent) {
  370. return new org.apache.fop.fo.flow.MultiCase(parent);
  371. }
  372. }
  373. static class MT extends ElementMapping.Maker {
  374. public FONode make(FONode parent) {
  375. return new org.apache.fop.fo.flow.MultiToggle(parent);
  376. }
  377. }
  378. static class MP extends ElementMapping.Maker {
  379. public FONode make(FONode parent) {
  380. return new org.apache.fop.fo.flow.MultiProperties(parent);
  381. }
  382. }
  383. static class MPS extends ElementMapping.Maker {
  384. public FONode make(FONode parent) {
  385. return new org.apache.fop.fo.flow.MultiPropertySet(parent);
  386. }
  387. }
  388. static class F extends ElementMapping.Maker {
  389. public FONode make(FONode parent) {
  390. return new org.apache.fop.fo.flow.Float(parent);
  391. }
  392. }
  393. static class Foot extends ElementMapping.Maker {
  394. public FONode make(FONode parent) {
  395. return new org.apache.fop.fo.flow.Footnote(parent);
  396. }
  397. }
  398. static class FB extends ElementMapping.Maker {
  399. public FONode make(FONode parent) {
  400. return new org.apache.fop.fo.flow.FootnoteBody(parent);
  401. }
  402. }
  403. static class W extends ElementMapping.Maker {
  404. public FONode make(FONode parent) {
  405. return new org.apache.fop.fo.flow.Wrapper(parent);
  406. }
  407. }
  408. static class M extends ElementMapping.Maker {
  409. public FONode make(FONode parent) {
  410. return new org.apache.fop.fo.flow.Marker(parent);
  411. }
  412. }
  413. static class RM extends ElementMapping.Maker {
  414. public FONode make(FONode parent) {
  415. return new org.apache.fop.fo.flow.RetrieveMarker(parent);
  416. }
  417. }
  418. }