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.

ExternalDocument.java 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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.extensions;
  19. import org.xml.sax.Locator;
  20. import org.apache.fop.apps.FOPException;
  21. import org.apache.fop.datatypes.Length;
  22. import org.apache.fop.fo.FONode;
  23. import org.apache.fop.fo.GraphicsProperties;
  24. import org.apache.fop.fo.PropertyList;
  25. import org.apache.fop.fo.ValidationException;
  26. import org.apache.fop.fo.pagination.AbstractPageSequence;
  27. import org.apache.fop.fo.properties.LengthRangeProperty;
  28. /**
  29. * Class for the fox:external-document extension element.
  30. */
  31. public class ExternalDocument extends AbstractPageSequence implements GraphicsProperties {
  32. // The value of properties relevant for fox:external-document
  33. private LengthRangeProperty blockProgressionDimension;
  34. private Length contentHeight;
  35. private Length contentWidth;
  36. private int displayAlign;
  37. private Length height;
  38. private LengthRangeProperty inlineProgressionDimension;
  39. private int overflow;
  40. private int scaling;
  41. private String src;
  42. private int textAlign;
  43. private Length width;
  44. // Unused but valid items, commented out for performance:
  45. // private CommonAccessibility commonAccessibility;
  46. // private CommonAural commonAural;
  47. // private String contentType;
  48. // private int scalingMethod;
  49. // End of property values
  50. /**
  51. * Constructs a ExternalDocument object (called by Maker).
  52. * @param parent the parent formatting object
  53. */
  54. public ExternalDocument(FONode parent) {
  55. super(parent);
  56. }
  57. /** {@inheritDoc} */
  58. public void bind(PropertyList pList) throws FOPException {
  59. super.bind(pList);
  60. blockProgressionDimension = pList.get(PR_BLOCK_PROGRESSION_DIMENSION).getLengthRange();
  61. contentHeight = pList.get(PR_CONTENT_HEIGHT).getLength();
  62. contentWidth = pList.get(PR_CONTENT_WIDTH).getLength();
  63. displayAlign = pList.get(PR_DISPLAY_ALIGN).getEnum();
  64. height = pList.get(PR_HEIGHT).getLength();
  65. inlineProgressionDimension = pList.get(PR_INLINE_PROGRESSION_DIMENSION).getLengthRange();
  66. overflow = pList.get(PR_OVERFLOW).getEnum();
  67. scaling = pList.get(PR_SCALING).getEnum();
  68. textAlign = pList.get(PR_TEXT_ALIGN).getEnum();
  69. width = pList.get(PR_WIDTH).getLength();
  70. src = pList.get(PR_SRC).getString();
  71. if (this.src == null || this.src.length() == 0) {
  72. missingPropertyError("src");
  73. }
  74. }
  75. /**
  76. * @throws FOPException in case of processing exception
  77. * @see org.apache.fop.fo.FONode#startOfNode()
  78. */
  79. protected void startOfNode() throws FOPException {
  80. super.startOfNode();
  81. getFOEventHandler().startExternalDocument(this);
  82. }
  83. /**
  84. * @throws FOPException in case of processing exception
  85. * @see org.apache.fop.fo.FONode#endOfNode()
  86. */
  87. protected void endOfNode() throws FOPException {
  88. getFOEventHandler().endExternalDocument(this);
  89. super.endOfNode();
  90. }
  91. /**
  92. * @param loc a locator
  93. * @param nsURI a namespace uri or null
  94. * @param localName a local name
  95. * @throws ValidationException if invalid child
  96. * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
  97. */
  98. protected void validateChildNode(Locator loc, String nsURI, String localName)
  99. throws ValidationException {
  100. invalidChildError(loc, nsURI, localName);
  101. }
  102. /**
  103. * Returns the src attribute (the URI to the embedded document).
  104. * @return the src attribute
  105. */
  106. public String getSrc() {
  107. return this.src;
  108. }
  109. /** {@inheritDoc} */
  110. public LengthRangeProperty getInlineProgressionDimension() {
  111. return inlineProgressionDimension;
  112. }
  113. /** {@inheritDoc} */
  114. public LengthRangeProperty getBlockProgressionDimension() {
  115. return blockProgressionDimension;
  116. }
  117. /** {@inheritDoc} */
  118. public Length getHeight() {
  119. return height;
  120. }
  121. /** {@inheritDoc} */
  122. public Length getWidth() {
  123. return width;
  124. }
  125. /** {@inheritDoc} */
  126. public Length getContentHeight() {
  127. return contentHeight;
  128. }
  129. /** {@inheritDoc} */
  130. public Length getContentWidth() {
  131. return contentWidth;
  132. }
  133. /** {@inheritDoc} */
  134. public int getScaling() {
  135. return scaling;
  136. }
  137. /** {@inheritDoc} */
  138. public int getOverflow() {
  139. return overflow;
  140. }
  141. /** {@inheritDoc} */
  142. public int getDisplayAlign() {
  143. return displayAlign;
  144. }
  145. /** {@inheritDoc} */
  146. public int getTextAlign() {
  147. return textAlign;
  148. }
  149. /**
  150. * @return namespace uri
  151. * @see org.apache.fop.fo.FONode#getNamespaceURI()
  152. */
  153. public String getNamespaceURI() {
  154. return ExtensionElementMapping.URI;
  155. }
  156. /**
  157. * @return namespace prefix
  158. * @see org.apache.fop.fo.FONode#getNormalNamespacePrefix()
  159. */
  160. public String getNormalNamespacePrefix() {
  161. return "fox";
  162. }
  163. /**
  164. * @return local name
  165. * @see org.apache.fop.fo.FONode#getLocalName()
  166. */
  167. public String getLocalName() {
  168. return "external-document";
  169. }
  170. }