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.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. protected void startOfNode() throws FOPException {
  76. super.startOfNode();
  77. getFOEventHandler().startExternalDocument(this);
  78. }
  79. /**
  80. * @see org.apache.fop.fo.FONode#endOfNode
  81. */
  82. protected void endOfNode() throws FOPException {
  83. getFOEventHandler().endExternalDocument(this);
  84. super.endOfNode();
  85. }
  86. /**
  87. * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
  88. XSL/FOP: empty
  89. */
  90. protected void validateChildNode(Locator loc, String nsURI, String localName)
  91. throws ValidationException {
  92. invalidChildError(loc, nsURI, localName);
  93. }
  94. /**
  95. * Returns the src attribute (the URI to the embedded document).
  96. * @return the src attribute
  97. */
  98. public String getSrc() {
  99. return this.src;
  100. }
  101. /** {@inheritDoc} */
  102. public LengthRangeProperty getInlineProgressionDimension() {
  103. return inlineProgressionDimension;
  104. }
  105. /** {@inheritDoc} */
  106. public LengthRangeProperty getBlockProgressionDimension() {
  107. return blockProgressionDimension;
  108. }
  109. /** {@inheritDoc} */
  110. public Length getHeight() {
  111. return height;
  112. }
  113. /** {@inheritDoc} */
  114. public Length getWidth() {
  115. return width;
  116. }
  117. /** {@inheritDoc} */
  118. public Length getContentHeight() {
  119. return contentHeight;
  120. }
  121. /** {@inheritDoc} */
  122. public Length getContentWidth() {
  123. return contentWidth;
  124. }
  125. /** {@inheritDoc} */
  126. public int getScaling() {
  127. return scaling;
  128. }
  129. /** {@inheritDoc} */
  130. public int getOverflow() {
  131. return overflow;
  132. }
  133. /** {@inheritDoc} */
  134. public int getDisplayAlign() {
  135. return displayAlign;
  136. }
  137. /** {@inheritDoc} */
  138. public int getTextAlign() {
  139. return textAlign;
  140. }
  141. /** @see org.apache.fop.fo.FONode#getNamespaceURI() */
  142. public String getNamespaceURI() {
  143. return ExtensionElementMapping.URI;
  144. }
  145. /** @see org.apache.fop.fo.FONode#getNormalNamespacePrefix() */
  146. public String getNormalNamespacePrefix() {
  147. return "fox";
  148. }
  149. /** @see org.apache.fop.fo.FONode#getLocalName() */
  150. public String getLocalName() {
  151. return "external-document";
  152. }
  153. }