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.

FOElementMapping.java 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  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. // Java
  20. import java.util.HashMap;
  21. import org.apache.xmlgraphics.util.QName;
  22. import org.apache.fop.layoutmgr.BlockLevelEventProducer;
  23. /**
  24. * Element mapping class for all XSL-FO elements.
  25. */
  26. public class FOElementMapping extends ElementMapping {
  27. /** The XSL-FO namespace URI */
  28. public static final String URI = "http://www.w3.org/1999/XSL/Format";
  29. /** Standard prefix */
  30. public static final String STANDARD_PREFIX = "fo";
  31. /**
  32. * Basic constructor; inititializes the namespace URI for the fo: namespace
  33. */
  34. public FOElementMapping() {
  35. namespaceURI = URI;
  36. }
  37. /**
  38. * Initializes the collection of valid objects for the fo: namespace
  39. */
  40. protected void initialize() {
  41. if (foObjs == null) {
  42. foObjs = new HashMap<String, Maker>();
  43. // Declarations and Pagination and Layout Formatting Objects
  44. foObjs.put("root", new RootMaker());
  45. foObjs.put("declarations", new DeclarationsMaker());
  46. foObjs.put("color-profile", new ColorProfileMaker());
  47. foObjs.put("bookmark-tree", new BookmarkTreeMaker());
  48. foObjs.put("bookmark", new BookmarkMaker());
  49. foObjs.put("bookmark-title", new BookmarkTitleMaker());
  50. // foObjs.put("page-sequence-wrapper", new PageSequenceWrapperMaker());
  51. foObjs.put("page-sequence", new PageSequenceMaker());
  52. foObjs.put("layout-master-set", new LayoutMasterSetMaker());
  53. foObjs.put("page-sequence-master",
  54. new PageSequenceMasterMaker());
  55. foObjs.put("single-page-master-reference",
  56. new SinglePageMasterReferenceMaker());
  57. foObjs.put("repeatable-page-master-reference",
  58. new RepeatablePageMasterReferenceMaker());
  59. foObjs.put("repeatable-page-master-alternatives",
  60. new RepeatablePageMasterAlternativesMaker());
  61. foObjs.put("conditional-page-master-reference",
  62. new ConditionalPageMasterReferenceMaker());
  63. foObjs.put("simple-page-master",
  64. new SimplePageMasterMaker());
  65. foObjs.put("region-body", new RegionBodyMaker());
  66. foObjs.put("region-before", new RegionBeforeMaker());
  67. foObjs.put("region-after", new RegionAfterMaker());
  68. foObjs.put("region-start", new RegionStartMaker());
  69. foObjs.put("region-end", new RegionEndMaker());
  70. foObjs.put("flow", new FlowMaker());
  71. foObjs.put("static-content", new StaticContentMaker());
  72. foObjs.put("title", new TitleMaker());
  73. // Block-level Formatting Objects
  74. foObjs.put("block", new BlockMaker());
  75. foObjs.put("block-container", new BlockContainerMaker());
  76. // Inline-level Formatting Objects
  77. foObjs.put("bidi-override", new BidiOverrideMaker());
  78. foObjs.put("character",
  79. new CharacterMaker());
  80. foObjs.put("initial-property-set",
  81. new InitialPropertySetMaker());
  82. foObjs.put("external-graphic", new ExternalGraphicMaker());
  83. foObjs.put("instream-foreign-object",
  84. new InstreamForeignObjectMaker());
  85. foObjs.put("inline", new InlineMaker());
  86. foObjs.put("inline-container", new InlineContainerMaker());
  87. foObjs.put("leader", new LeaderMaker());
  88. foObjs.put("page-number", new PageNumberMaker());
  89. foObjs.put("page-number-citation",
  90. new PageNumberCitationMaker());
  91. foObjs.put("page-number-citation-last",
  92. new PageNumberCitationLastMaker());
  93. // Formatting Objects for Tables
  94. foObjs.put("table-and-caption", new TableAndCaptionMaker());
  95. foObjs.put("table", new TableMaker());
  96. foObjs.put("table-column", new TableColumnMaker());
  97. foObjs.put("table-caption", new TableCaptionMaker());
  98. foObjs.put("table-header", new TableHeaderMaker());
  99. foObjs.put("table-footer", new TableFooterMaker());
  100. foObjs.put("table-body", new TableBodyMaker());
  101. foObjs.put("table-row", new TableRowMaker());
  102. foObjs.put("table-cell", new TableCellMaker());
  103. // Formatting Objects for Lists
  104. foObjs.put("list-block", new ListBlockMaker());
  105. foObjs.put("list-item", new ListItemMaker());
  106. foObjs.put("list-item-body", new ListItemBodyMaker());
  107. foObjs.put("list-item-label", new ListItemLabelMaker());
  108. // Dynamic Effects: Link and Multi Formatting Objects
  109. foObjs.put("basic-link", new BasicLinkMaker());
  110. foObjs.put("multi-switch", new MultiSwitchMaker());
  111. foObjs.put("multi-case", new MultiCaseMaker());
  112. foObjs.put("multi-toggle", new MultiToggleMaker());
  113. foObjs.put("multi-properties", new MultiPropertiesMaker());
  114. foObjs.put("multi-property-set",
  115. new MultiPropertySetMaker());
  116. // Out-of-Line Formatting Objects
  117. foObjs.put("float",
  118. new FloatMaker());
  119. foObjs.put("footnote", new FootnoteMaker());
  120. foObjs.put("footnote-body", new FootnoteBodyMaker());
  121. // Other Formatting Objects
  122. foObjs.put("wrapper", new WrapperMaker());
  123. foObjs.put("marker", new MarkerMaker());
  124. foObjs.put("retrieve-marker", new RetrieveMarkerMaker());
  125. foObjs.put("retrieve-table-marker", new RetrieveTableMarkerMaker());
  126. // change bars
  127. foObjs.put("change-bar-begin", new ChangeBarBeginMaker());
  128. foObjs.put("change-bar-end", new ChangeBarEndMaker());
  129. }
  130. }
  131. /** {@inheritDoc} */
  132. public String getStandardPrefix() {
  133. return STANDARD_PREFIX;
  134. }
  135. /** {@inheritDoc} */
  136. public boolean isAttributeProperty(QName attributeName) {
  137. return true; //All XSL-FO attributes are to be converted to properties.
  138. }
  139. static class RootMaker extends ElementMapping.Maker {
  140. public FONode make(FONode parent) {
  141. return new org.apache.fop.fo.pagination.Root(parent);
  142. }
  143. }
  144. static class DeclarationsMaker extends ElementMapping.Maker {
  145. public FONode make(FONode parent) {
  146. return new org.apache.fop.fo.pagination.Declarations(parent);
  147. }
  148. }
  149. static class ColorProfileMaker extends ElementMapping.Maker {
  150. public FONode make(FONode parent) {
  151. return new org.apache.fop.fo.pagination.ColorProfile(parent);
  152. }
  153. }
  154. static class BookmarkTreeMaker extends ElementMapping.Maker {
  155. public FONode make(FONode parent) {
  156. return new org.apache.fop.fo.pagination.bookmarks.BookmarkTree(parent);
  157. }
  158. }
  159. static class BookmarkMaker extends ElementMapping.Maker {
  160. public FONode make(FONode parent) {
  161. return new org.apache.fop.fo.pagination.bookmarks.Bookmark(parent);
  162. }
  163. }
  164. static class BookmarkTitleMaker extends ElementMapping.Maker {
  165. public FONode make(FONode parent) {
  166. return new org.apache.fop.fo.pagination.bookmarks.BookmarkTitle(parent);
  167. }
  168. }
  169. static class PageSequenceWrapperMaker extends ElementMapping.Maker {
  170. public FONode make(FONode parent) {
  171. return new org.apache.fop.fo.pagination.PageSequenceWrapper(parent);
  172. }
  173. }
  174. static class PageSequenceMaker extends ElementMapping.Maker {
  175. public FONode make(FONode parent) {
  176. return new org.apache.fop.fo.pagination.PageSequence(parent);
  177. }
  178. }
  179. static class LayoutMasterSetMaker extends ElementMapping.Maker {
  180. public FONode make(FONode parent) {
  181. return new org.apache.fop.fo.pagination.LayoutMasterSet(parent);
  182. }
  183. }
  184. static class PageSequenceMasterMaker extends ElementMapping.Maker {
  185. public FONode make(FONode parent) {
  186. return new org.apache.fop.fo.pagination.PageSequenceMaster(parent,
  187. BlockLevelEventProducer.Provider.get(
  188. parent.getUserAgent().getEventBroadcaster()));
  189. }
  190. }
  191. static class SinglePageMasterReferenceMaker extends ElementMapping.Maker {
  192. public FONode make(FONode parent) {
  193. return new org.apache.fop.fo.pagination.SinglePageMasterReference(parent);
  194. }
  195. }
  196. static class RepeatablePageMasterReferenceMaker extends ElementMapping.Maker {
  197. public FONode make(FONode parent) {
  198. return new org.apache.fop.fo.pagination.RepeatablePageMasterReference(parent);
  199. }
  200. }
  201. static class RepeatablePageMasterAlternativesMaker extends ElementMapping.Maker {
  202. public FONode make(FONode parent) {
  203. return new org.apache.fop.fo.pagination.RepeatablePageMasterAlternatives(parent);
  204. }
  205. }
  206. static class ConditionalPageMasterReferenceMaker extends ElementMapping.Maker {
  207. public FONode make(FONode parent) {
  208. return new org.apache.fop.fo.pagination.ConditionalPageMasterReference(parent);
  209. }
  210. }
  211. static class SimplePageMasterMaker extends ElementMapping.Maker {
  212. public FONode make(FONode parent) {
  213. return new org.apache.fop.fo.pagination.SimplePageMaster(parent);
  214. }
  215. }
  216. static class RegionBodyMaker extends ElementMapping.Maker {
  217. public FONode make(FONode parent) {
  218. return new org.apache.fop.fo.pagination.RegionBody(parent);
  219. }
  220. }
  221. static class RegionBeforeMaker extends ElementMapping.Maker {
  222. public FONode make(FONode parent) {
  223. return new org.apache.fop.fo.pagination.RegionBefore(parent);
  224. }
  225. }
  226. static class RegionAfterMaker extends ElementMapping.Maker {
  227. public FONode make(FONode parent) {
  228. return new org.apache.fop.fo.pagination.RegionAfter(parent);
  229. }
  230. }
  231. static class RegionStartMaker extends ElementMapping.Maker {
  232. public FONode make(FONode parent) {
  233. return new org.apache.fop.fo.pagination.RegionStart(parent);
  234. }
  235. }
  236. static class RegionEndMaker extends ElementMapping.Maker {
  237. public FONode make(FONode parent) {
  238. return new org.apache.fop.fo.pagination.RegionEnd(parent);
  239. }
  240. }
  241. static class FlowMaker extends ElementMapping.Maker {
  242. public FONode make(FONode parent) {
  243. return new org.apache.fop.fo.pagination.Flow(parent);
  244. }
  245. }
  246. static class StaticContentMaker extends ElementMapping.Maker {
  247. public FONode make(FONode parent) {
  248. return new org.apache.fop.fo.pagination.StaticContent(parent);
  249. }
  250. }
  251. static class TitleMaker extends ElementMapping.Maker {
  252. public FONode make(FONode parent) {
  253. return new org.apache.fop.fo.pagination.Title(parent);
  254. }
  255. }
  256. static class BlockMaker extends ElementMapping.Maker {
  257. public FONode make(FONode parent) {
  258. return new org.apache.fop.fo.flow.Block(parent);
  259. }
  260. }
  261. static class BlockContainerMaker extends ElementMapping.Maker {
  262. public FONode make(FONode parent) {
  263. return new org.apache.fop.fo.flow.BlockContainer(parent);
  264. }
  265. }
  266. static class BidiOverrideMaker extends ElementMapping.Maker {
  267. public FONode make(FONode parent) {
  268. return new org.apache.fop.fo.flow.BidiOverride(parent);
  269. }
  270. }
  271. static class CharacterMaker extends ElementMapping.Maker {
  272. public FONode make(FONode parent) {
  273. return new org.apache.fop.fo.flow.Character(parent);
  274. }
  275. }
  276. static class InitialPropertySetMaker extends ElementMapping.Maker {
  277. public FONode make(FONode parent) {
  278. return new org.apache.fop.fo.flow.InitialPropertySet(parent);
  279. }
  280. }
  281. static class ExternalGraphicMaker extends ElementMapping.Maker {
  282. public FONode make(FONode parent) {
  283. return new org.apache.fop.fo.flow.ExternalGraphic(parent);
  284. }
  285. }
  286. static class InstreamForeignObjectMaker extends ElementMapping.Maker {
  287. public FONode make(FONode parent) {
  288. return new org.apache.fop.fo.flow.InstreamForeignObject(parent);
  289. }
  290. }
  291. static class InlineMaker extends ElementMapping.Maker {
  292. public FONode make(FONode parent) {
  293. return new org.apache.fop.fo.flow.Inline(parent);
  294. }
  295. }
  296. static class InlineContainerMaker extends ElementMapping.Maker {
  297. public FONode make(FONode parent) {
  298. return new org.apache.fop.fo.flow.InlineContainer(parent);
  299. }
  300. }
  301. static class LeaderMaker extends ElementMapping.Maker {
  302. public FONode make(FONode parent) {
  303. return new org.apache.fop.fo.flow.Leader(parent);
  304. }
  305. }
  306. static class PageNumberMaker extends ElementMapping.Maker {
  307. public FONode make(FONode parent) {
  308. return new org.apache.fop.fo.flow.PageNumber(parent);
  309. }
  310. }
  311. static class PageNumberCitationMaker extends ElementMapping.Maker {
  312. public FONode make(FONode parent) {
  313. return new org.apache.fop.fo.flow.PageNumberCitation(parent);
  314. }
  315. }
  316. static class PageNumberCitationLastMaker extends ElementMapping.Maker {
  317. public FONode make(FONode parent) {
  318. return new org.apache.fop.fo.flow.PageNumberCitationLast(parent);
  319. }
  320. }
  321. static class TableAndCaptionMaker extends ElementMapping.Maker {
  322. public FONode make(FONode parent) {
  323. return new org.apache.fop.fo.flow.table.TableAndCaption(parent);
  324. }
  325. }
  326. static class TableMaker extends ElementMapping.Maker {
  327. public FONode make(FONode parent) {
  328. return new org.apache.fop.fo.flow.table.Table(parent);
  329. }
  330. }
  331. static class TableColumnMaker extends ElementMapping.Maker {
  332. public FONode make(FONode parent) {
  333. return new org.apache.fop.fo.flow.table.TableColumn(parent);
  334. }
  335. }
  336. static class TableCaptionMaker extends ElementMapping.Maker {
  337. public FONode make(FONode parent) {
  338. return new org.apache.fop.fo.flow.table.TableCaption(parent);
  339. }
  340. }
  341. static class TableBodyMaker extends ElementMapping.Maker {
  342. public FONode make(FONode parent) {
  343. return new org.apache.fop.fo.flow.table.TableBody(parent);
  344. }
  345. }
  346. static class TableHeaderMaker extends ElementMapping.Maker {
  347. public FONode make(FONode parent) {
  348. return new org.apache.fop.fo.flow.table.TableHeader(parent);
  349. }
  350. }
  351. static class TableFooterMaker extends ElementMapping.Maker {
  352. public FONode make(FONode parent) {
  353. return new org.apache.fop.fo.flow.table.TableFooter(parent);
  354. }
  355. }
  356. static class TableRowMaker extends ElementMapping.Maker {
  357. public FONode make(FONode parent) {
  358. return new org.apache.fop.fo.flow.table.TableRow(parent);
  359. }
  360. }
  361. static class TableCellMaker extends ElementMapping.Maker {
  362. public FONode make(FONode parent) {
  363. return new org.apache.fop.fo.flow.table.TableCell(parent);
  364. }
  365. }
  366. static class ListBlockMaker extends ElementMapping.Maker {
  367. public FONode make(FONode parent) {
  368. return new org.apache.fop.fo.flow.ListBlock(parent);
  369. }
  370. }
  371. static class ListItemMaker extends ElementMapping.Maker {
  372. public FONode make(FONode parent) {
  373. return new org.apache.fop.fo.flow.ListItem(parent);
  374. }
  375. }
  376. static class ListItemBodyMaker extends ElementMapping.Maker {
  377. public FONode make(FONode parent) {
  378. return new org.apache.fop.fo.flow.ListItemBody(parent);
  379. }
  380. }
  381. static class ListItemLabelMaker extends ElementMapping.Maker {
  382. public FONode make(FONode parent) {
  383. return new org.apache.fop.fo.flow.ListItemLabel(parent);
  384. }
  385. }
  386. static class BasicLinkMaker extends ElementMapping.Maker {
  387. public FONode make(FONode parent) {
  388. return new org.apache.fop.fo.flow.BasicLink(parent);
  389. }
  390. }
  391. static class MultiSwitchMaker extends ElementMapping.Maker {
  392. public FONode make(FONode parent) {
  393. return new org.apache.fop.fo.flow.MultiSwitch(parent);
  394. }
  395. }
  396. static class MultiCaseMaker extends ElementMapping.Maker {
  397. public FONode make(FONode parent) {
  398. return new org.apache.fop.fo.flow.MultiCase(parent);
  399. }
  400. }
  401. static class MultiToggleMaker extends ElementMapping.Maker {
  402. public FONode make(FONode parent) {
  403. return new org.apache.fop.fo.flow.MultiToggle(parent);
  404. }
  405. }
  406. static class MultiPropertiesMaker extends ElementMapping.Maker {
  407. public FONode make(FONode parent) {
  408. return new org.apache.fop.fo.flow.MultiProperties(parent);
  409. }
  410. }
  411. static class MultiPropertySetMaker extends ElementMapping.Maker {
  412. public FONode make(FONode parent) {
  413. return new org.apache.fop.fo.flow.MultiPropertySet(parent);
  414. }
  415. }
  416. static class FloatMaker extends ElementMapping.Maker {
  417. public FONode make(FONode parent) {
  418. return new org.apache.fop.fo.flow.Float(parent);
  419. }
  420. }
  421. static class FootnoteMaker extends ElementMapping.Maker {
  422. public FONode make(FONode parent) {
  423. return new org.apache.fop.fo.flow.Footnote(parent);
  424. }
  425. }
  426. static class FootnoteBodyMaker extends ElementMapping.Maker {
  427. public FONode make(FONode parent) {
  428. return new org.apache.fop.fo.flow.FootnoteBody(parent);
  429. }
  430. }
  431. static class WrapperMaker extends ElementMapping.Maker {
  432. public FONode make(FONode parent) {
  433. return new org.apache.fop.fo.flow.Wrapper(parent);
  434. }
  435. }
  436. static class MarkerMaker extends ElementMapping.Maker {
  437. public FONode make(FONode parent) {
  438. return new org.apache.fop.fo.flow.Marker(parent);
  439. }
  440. }
  441. static class RetrieveMarkerMaker extends ElementMapping.Maker {
  442. public FONode make(FONode parent) {
  443. return new org.apache.fop.fo.flow.RetrieveMarker(parent);
  444. }
  445. }
  446. static class RetrieveTableMarkerMaker extends ElementMapping.Maker {
  447. public FONode make(FONode parent) {
  448. return new org.apache.fop.fo.flow.RetrieveTableMarker(parent);
  449. }
  450. }
  451. static class ChangeBarBeginMaker extends ElementMapping.Maker {
  452. public FONode make(FONode parent) {
  453. return new org.apache.fop.fo.flow.ChangeBarBegin(parent);
  454. }
  455. }
  456. static class ChangeBarEndMaker extends ElementMapping.Maker {
  457. public FONode make(FONode parent) {
  458. return new org.apache.fop.fo.flow.ChangeBarEnd(parent);
  459. }
  460. }
  461. }