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.

AFPElementMapping.java 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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.render.afp.extensions;
  19. import org.apache.fop.fo.ElementMapping;
  20. import org.apache.fop.fo.FONode;
  21. /**
  22. * AFPElementMapping object provides the ability to extract information
  23. * from the formatted object that reside in the afp namespace. This is used
  24. * for custom AFP extensions not supported by the FO schema. Examples include
  25. * adding overlays or indexing a document using the tag logical element
  26. * structured field.
  27. * <p/>
  28. */
  29. public class AFPElementMapping extends ElementMapping {
  30. /** tag logical element */
  31. public static final String TAG_LOGICAL_ELEMENT = "tag-logical-element";
  32. /** include page overlay element */
  33. public static final String INCLUDE_PAGE_OVERLAY = "include-page-overlay";
  34. /** include page segment element */
  35. public static final String INCLUDE_PAGE_SEGMENT = "include-page-segment";
  36. /** include form map element */
  37. public static final String INCLUDE_FORM_MAP = "include-form-map";
  38. /** NOP */
  39. public static final String NO_OPERATION = "no-operation";
  40. /** IMM: Invoke Medium Map (on fo:page-sequence) */
  41. public static final String INVOKE_MEDIUM_MAP = "invoke-medium-map";
  42. /**
  43. * The namespace used for AFP extensions
  44. */
  45. public static final String NAMESPACE = "http://xmlgraphics.apache.org/fop/extensions/afp";
  46. /**
  47. * The usual namespace prefix used for AFP extensions
  48. */
  49. public static final String NAMESPACE_PREFIX = "afp";
  50. /** Main constructor */
  51. public AFPElementMapping() {
  52. this.namespaceURI = NAMESPACE;
  53. }
  54. /**
  55. * Private static synchronized method to set up the element and attribute
  56. * HashMaps, this defines what elements and attributes are extracted.
  57. */
  58. protected void initialize() {
  59. if (foObjs == null) {
  60. super.foObjs = new java.util.HashMap<String, Maker>();
  61. foObjs.put(
  62. TAG_LOGICAL_ELEMENT,
  63. new AFPTagLogicalElementMaker());
  64. foObjs.put(
  65. INCLUDE_PAGE_SEGMENT,
  66. new AFPIncludePageSegmentMaker());
  67. foObjs.put(
  68. INCLUDE_PAGE_OVERLAY,
  69. new AFPIncludePageOverlayMaker());
  70. foObjs.put(
  71. INCLUDE_FORM_MAP,
  72. new AFPIncludeFormMapMaker());
  73. foObjs.put(
  74. NO_OPERATION,
  75. new AFPNoOperationMaker());
  76. foObjs.put(
  77. INVOKE_MEDIUM_MAP,
  78. new AFPInvokeMediumMapMaker());
  79. }
  80. }
  81. static class AFPIncludePageOverlayMaker extends ElementMapping.Maker {
  82. public FONode make(FONode parent) {
  83. return new AFPPageOverlayElement(parent, INCLUDE_PAGE_OVERLAY);
  84. }
  85. }
  86. static class AFPIncludePageSegmentMaker extends ElementMapping.Maker {
  87. public FONode make(FONode parent) {
  88. return new AFPPageSegmentElement(parent, INCLUDE_PAGE_SEGMENT);
  89. }
  90. }
  91. static class AFPIncludeFormMapMaker extends ElementMapping.Maker {
  92. public FONode make(FONode parent) {
  93. return new AFPIncludeFormMapElement(parent, INCLUDE_FORM_MAP);
  94. }
  95. }
  96. static class AFPTagLogicalElementMaker extends ElementMapping.Maker {
  97. public FONode make(FONode parent) {
  98. return new AFPPageSetupElement(parent, TAG_LOGICAL_ELEMENT);
  99. }
  100. }
  101. static class AFPNoOperationMaker extends ElementMapping.Maker {
  102. public FONode make(FONode parent) {
  103. return new AFPPageSetupElement(parent, NO_OPERATION);
  104. }
  105. }
  106. static class AFPInvokeMediumMapMaker extends ElementMapping.Maker {
  107. public FONode make(FONode parent) {
  108. return new AFPInvokeMediumMapElement(parent);
  109. }
  110. }
  111. }