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.

AFPIncludeFormMapElement.java 3.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 java.net.URI;
  20. import java.net.URISyntaxException;
  21. import org.xml.sax.Attributes;
  22. import org.xml.sax.Locator;
  23. import org.apache.fop.apps.FOPException;
  24. import org.apache.fop.fo.Constants;
  25. import org.apache.fop.fo.FONode;
  26. import org.apache.fop.fo.PropertyList;
  27. import org.apache.fop.fo.extensions.ExtensionAttachment;
  28. /**
  29. * This class extends the {@link org.apache.fop.fo.extensions.ExtensionObj} class.
  30. * It represents the "include-form-map" extension in the FO tree.
  31. */
  32. public class AFPIncludeFormMapElement extends AbstractAFPExtensionObject {
  33. private static final String ATT_SRC = "src";
  34. /**
  35. * Constructs an AFP object (called by Maker).
  36. *
  37. * @param parent the parent formatting object
  38. * @param name the name of the AFP element
  39. */
  40. public AFPIncludeFormMapElement(FONode parent, String name) {
  41. super(parent, name);
  42. }
  43. private AFPIncludeFormMap getFormMapAttachment() {
  44. return (AFPIncludeFormMap)getExtensionAttachment();
  45. }
  46. /** {@inheritDoc} */
  47. public void startOfNode() throws FOPException {
  48. super.startOfNode();
  49. if (parent.getNameId() != Constants.FO_DECLARATIONS) {
  50. invalidChildError(getLocator(), parent.getName(), getNamespaceURI(), getName(),
  51. "rule.childOfDeclarations");
  52. }
  53. }
  54. /** {@inheritDoc} */
  55. public void processNode(String elementName, Locator locator,
  56. Attributes attlist, PropertyList propertyList)
  57. throws FOPException {
  58. super.processNode(elementName, locator, attlist, propertyList);
  59. AFPIncludeFormMap formMap = getFormMapAttachment();
  60. String attr = attlist.getValue(ATT_SRC);
  61. if (attr != null && attr.length() > 0) {
  62. try {
  63. formMap.setSrc(new URI(attr));
  64. } catch (URISyntaxException e) {
  65. getFOValidationEventProducer().invalidPropertyValue(this,
  66. elementName, ATT_SRC, attr, null, getLocator());
  67. }
  68. } else {
  69. missingPropertyError(ATT_SRC);
  70. }
  71. }
  72. /** {@inheritDoc} */
  73. protected ExtensionAttachment instantiateExtensionAttachment() {
  74. return new AFPIncludeFormMap();
  75. }
  76. }