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