summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/codegen/java/org/apache/fop/tools/EventProducerCollector.java15
-rw-r--r--src/documentation/content/xdocs/trunk/output.xml12
-rw-r--r--src/java/org/apache/fop/afp/DataStream.java10
-rw-r--r--src/java/org/apache/fop/afp/modca/AbstractResourceGroupContainer.java4
-rw-r--r--src/java/org/apache/fop/afp/modca/NoOperation.java21
-rw-r--r--src/java/org/apache/fop/fo/FOValidationEventProducer.xml1
-rw-r--r--src/java/org/apache/fop/render/afp/AFPDocumentHandler.java80
-rw-r--r--src/java/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java10
8 files changed, 110 insertions, 43 deletions
diff --git a/src/codegen/java/org/apache/fop/tools/EventProducerCollector.java b/src/codegen/java/org/apache/fop/tools/EventProducerCollector.java
index 4721f41df..7b103e0cd 100644
--- a/src/codegen/java/org/apache/fop/tools/EventProducerCollector.java
+++ b/src/codegen/java/org/apache/fop/tools/EventProducerCollector.java
@@ -21,7 +21,6 @@ package org.apache.fop.tools;
import java.io.File;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -47,10 +46,10 @@ import com.thoughtworks.qdox.model.Type;
class EventProducerCollector {
private static final String CLASSNAME_EVENT_PRODUCER = EventProducer.class.getName();
- private static final Map PRIMITIVE_MAP;
+ private static final Map<String, Class<?>> PRIMITIVE_MAP;
static {
- Map m = new java.util.HashMap();
+ Map <String, Class<?>> m = new java.util.HashMap<String, Class<?>>();
m.put("boolean", Boolean.class);
m.put("byte", Byte.class);
m.put("char", Character.class);
@@ -63,7 +62,7 @@ class EventProducerCollector {
}
private DocletTagFactory tagFactory;
- private List models = new ArrayList();
+ private List<EventModel> models = new java.util.ArrayList<EventModel>();
/**
* Creates a new EventProducerCollector.
@@ -139,7 +138,7 @@ class EventProducerCollector {
throws EventConventionException, ClassNotFoundException {
JavaClass clazz = method.getParentClass();
//Check EventProducer conventions
- if (!method.getReturns().isVoid()) {
+ if (!method.getReturnType().isVoid()) {
throw new EventConventionException("All methods of interface "
+ clazz.getFullyQualifiedName() + " must have return type 'void'!");
}
@@ -168,10 +167,10 @@ class EventProducerCollector {
if (params.length > 1) {
for (int j = 1, cj = params.length; j < cj; j++) {
JavaParameter p = params[j];
- Class type;
+ Class<?> type;
JavaClass pClass = p.getType().getJavaClass();
if (p.getType().isPrimitive()) {
- type = (Class)PRIMITIVE_MAP.get(pClass.getName());
+ type = PRIMITIVE_MAP.get(pClass.getName());
if (type == null) {
throw new UnsupportedOperationException(
"Primitive datatype not supported: " + pClass.getName());
@@ -197,7 +196,7 @@ class EventProducerCollector {
* Returns the event model that has been accumulated.
* @return the event model.
*/
- public List getModels() {
+ public List<EventModel> getModels() {
return this.models;
}
diff --git a/src/documentation/content/xdocs/trunk/output.xml b/src/documentation/content/xdocs/trunk/output.xml
index 226a2d96c..ea994b521 100644
--- a/src/documentation/content/xdocs/trunk/output.xml
+++ b/src/documentation/content/xdocs/trunk/output.xml
@@ -931,9 +931,15 @@ Note that the value of the encoding attribute in the example is the double-byte
</fo:simple-page-master>
</fo:layout-master-set>
]]></source>
- <p>The no-operation extension element can only occur within a simple-page-master.
- Multiple no-operation extension elements within a simple-page-master are allowed.
- The name attribute is mandatory.
+ <p>The no-operation extension element can appear as child of
+ simple-page-master (appears after "Begin Page" BPG),
+ page-sequence (appears after "Begin Named Page Group" BNG
+ and declarations (appears after "Begin Document" BDT).
+ Multiple no-operation extension elements inside the same formatting object are allowed.
+ Each NOP will appear right after the respective "Begin" field indicated above even if it
+ is specified as the last child under its parent. However, the order inside the parent
+ will be maintained.
+ The name attribute is mandatory but will not appear inside the AFP stream.
</p>
</section>
<section id="afp-invoke-medium-map">
diff --git a/src/java/org/apache/fop/afp/DataStream.java b/src/java/org/apache/fop/afp/DataStream.java
index a437c3004..2794ae932 100644
--- a/src/java/org/apache/fop/afp/DataStream.java
+++ b/src/java/org/apache/fop/afp/DataStream.java
@@ -595,7 +595,13 @@ public class DataStream {
* byte data
*/
public void createNoOperation(String content) {
- currentPage.createNoOperation(content);
+ if (currentPage != null) {
+ currentPage.createNoOperation(content);
+ } else if (currentPageGroup != null) {
+ currentPageGroup.createNoOperation(content);
+ } else {
+ document.createNoOperation(content);
+ }
}
/**
@@ -639,9 +645,9 @@ public class DataStream {
currentPageGroup.endPageGroup();
tleSequence = currentPageGroup.getTleSequence();
document.addPageGroup(currentPageGroup);
- document.writeToStream(outputStream);
currentPageGroup = null;
}
+ document.writeToStream(outputStream); //Flush objects
}
/**
diff --git a/src/java/org/apache/fop/afp/modca/AbstractResourceGroupContainer.java b/src/java/org/apache/fop/afp/modca/AbstractResourceGroupContainer.java
index 2c5e02328..f8c5a38d3 100644
--- a/src/java/org/apache/fop/afp/modca/AbstractResourceGroupContainer.java
+++ b/src/java/org/apache/fop/afp/modca/AbstractResourceGroupContainer.java
@@ -126,6 +126,7 @@ implements Streamable {
// }
/** {@inheritDoc} */
+ @Override
public void writeToStream(OutputStream os) throws IOException {
if (!started) {
writeStart(os);
@@ -140,6 +141,7 @@ implements Streamable {
}
/** {@inheritDoc} */
+ @Override
protected void writeObjects(Collection/*<AbstractAFPObject>*/ objects, OutputStream os)
throws IOException {
writeObjects(objects, os, false);
@@ -176,7 +178,7 @@ implements Streamable {
* @return true if this object can be written
*/
protected boolean canWrite(AbstractAFPObject obj) {
- if (obj instanceof AbstractPageObject) {
+ if (obj instanceof Completable) {
return ((Completable)obj).isComplete();
}
else {
diff --git a/src/java/org/apache/fop/afp/modca/NoOperation.java b/src/java/org/apache/fop/afp/modca/NoOperation.java
index cb5841346..cb6f4d60b 100644
--- a/src/java/org/apache/fop/afp/modca/NoOperation.java
+++ b/src/java/org/apache/fop/afp/modca/NoOperation.java
@@ -23,6 +23,7 @@ import java.io.IOException;
import java.io.OutputStream;
import org.apache.fop.afp.AFPConstants;
+import org.apache.fop.afp.Completable;
import org.apache.fop.afp.util.BinaryUtils;
/**
@@ -35,7 +36,7 @@ import org.apache.fop.afp.util.BinaryUtils;
* No Operation structured fields, no semantics should be attached to
* the data carried by the No Operation structured field in interchange
*/
-public class NoOperation extends AbstractAFPObject {
+public class NoOperation extends AbstractAFPObject implements Completable {
/** Up to 32759 bytes of data with no architectural definition */
private static final int MAX_DATA_LEN = 32759;
@@ -81,7 +82,7 @@ public class NoOperation extends AbstractAFPObject {
data[1] = rl1[0];
data[2] = rl1[1];
- // Structured field ID for a TLE
+ // Structured field ID for a NOP
data[3] = (byte) 0xD3;
data[4] = (byte) 0xEE;
data[5] = (byte) 0xEE;
@@ -97,4 +98,20 @@ public class NoOperation extends AbstractAFPObject {
os.write(data);
}
+ /** {@inheritDoc} */
+ public boolean isComplete() {
+ return true; //always complete
+ }
+
+ /** {@inheritDoc} */
+ public void setComplete(boolean complete) {
+ //ignore
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public String toString() {
+ return "NOP: " + content.substring(0, Math.min(64, content.length()));
+ }
+
} \ No newline at end of file
diff --git a/src/java/org/apache/fop/fo/FOValidationEventProducer.xml b/src/java/org/apache/fop/fo/FOValidationEventProducer.xml
index c3e4b6b61..509f7c1d3 100644
--- a/src/java/org/apache/fop/fo/FOValidationEventProducer.xml
+++ b/src/java/org/apache/fop/fo/FOValidationEventProducer.xml
@@ -9,6 +9,7 @@
<message key="rule.childOfSPM">The element must be a child of fo:simple-page-master.</message>
<message key="rule.childOfDeclarations">The element must be a child of fo:declarations.</message>
<message key="rule.childOfSPMorDeclarations">The element must be a child of fo:declarations or fo:simple-page-master.</message>
+ <message key="rule.childOfSPMorPSorDeclarations">The element must be a child of fo:declarations, fo:simple-page-master or fo:page-sequence.</message>
<message key="rule.childOfInstreamForeignObjectorExternalGraphic">The element must be a child of fo:instream-foreign-object or fo:external-graphic.</message>
<message key="rule.childOfPageSequence">The element must be a child of fo:page-sequence.</message>
<message key="rule.childOfPageSequenceOrSPM">The element must be a child of fo:page-sequence or fo:simple-page-master.</message>
diff --git a/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java b/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java
index c37e0c37c..87651defd 100644
--- a/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java
+++ b/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java
@@ -77,17 +77,17 @@ public class AFPDocumentHandler extends AbstractBinaryWritingIFDocumentHandler
private DataStream dataStream;
/** the map of page segments */
- private Map/*<String,PageSegmentDescriptor>*/pageSegmentMap
- = new java.util.HashMap/*<String,PageSegmentDescriptor>*/();
+ private Map<String, PageSegmentDescriptor> pageSegmentMap
+ = new java.util.HashMap<String, PageSegmentDescriptor>();
/** Medium Map referenced on previous page **/
private String lastMediumMap;
- private static final int LOC_ELSEWHERE = 0;
- private static final int LOC_FOLLOWING_PAGE_SEQUENCE = 1;
- private static final int LOC_IN_PAGE_HEADER = 2;
+ private static enum Location {
+ ELSEWHERE, IN_DOCUMENT_HEADER, FOLLOWING_PAGE_SEQUENCE, IN_PAGE_HEADER
+ }
- private int location = LOC_ELSEWHERE;
+ private Location location = Location.ELSEWHERE;
/** the shading mode for filled rectangles */
private AFPShadingMode shadingMode = AFPShadingMode.COLOR;
@@ -117,6 +117,7 @@ public class AFPDocumentHandler extends AbstractBinaryWritingIFDocumentHandler
}
/** {@inheritDoc} */
+ @Override
public void setDefaultFontInfo(FontInfo fontInfo) {
FontManager fontManager = getUserAgent().getFactory().getFontManager();
FontCollection[] fontCollections = new FontCollection[] {
@@ -152,6 +153,7 @@ public class AFPDocumentHandler extends AbstractBinaryWritingIFDocumentHandler
}
/** {@inheritDoc} */
+ @Override
public void startDocument() throws IFException {
super.startDocument();
try {
@@ -165,11 +167,23 @@ public class AFPDocumentHandler extends AbstractBinaryWritingIFDocumentHandler
}
}
+
+ /** {@inheritDoc} */
+ @Override
+ public void startDocumentHeader() throws IFException {
+ super.startDocumentHeader();
+ this.location = Location.IN_DOCUMENT_HEADER;
+ }
+
/** {@inheritDoc} */
+ @Override
public void endDocumentHeader() throws IFException {
+ super.endDocumentHeader();
+ this.location = Location.ELSEWHERE;
}
/** {@inheritDoc} */
+ @Override
public void endDocument() throws IFException {
try {
this.dataStream.endDocument();
@@ -189,7 +203,7 @@ public class AFPDocumentHandler extends AbstractBinaryWritingIFDocumentHandler
} catch (IOException ioe) {
throw new IFException("I/O error in startPageSequence()", ioe);
}
- this.location = LOC_FOLLOWING_PAGE_SEQUENCE;
+ this.location = Location.FOLLOWING_PAGE_SEQUENCE;
}
/** {@inheritDoc} */
@@ -212,7 +226,7 @@ public class AFPDocumentHandler extends AbstractBinaryWritingIFDocumentHandler
/** {@inheritDoc} */
public void startPage(int index, String name, String pageMasterName, Dimension size)
throws IFException {
- this.location = LOC_ELSEWHERE;
+ this.location = Location.ELSEWHERE;
paintingState.clear();
AffineTransform baseTransform = getBaseTransform();
@@ -232,14 +246,16 @@ public class AFPDocumentHandler extends AbstractBinaryWritingIFDocumentHandler
}
/** {@inheritDoc} */
+ @Override
public void startPageHeader() throws IFException {
super.startPageHeader();
- this.location = LOC_IN_PAGE_HEADER;
+ this.location = Location.IN_PAGE_HEADER;
}
/** {@inheritDoc} */
+ @Override
public void endPageHeader() throws IFException {
- this.location = LOC_ELSEWHERE;
+ this.location = Location.ELSEWHERE;
super.endPageHeader();
}
@@ -272,17 +288,36 @@ public class AFPDocumentHandler extends AbstractBinaryWritingIFDocumentHandler
AFPPageSetup aps = (AFPPageSetup)extension;
String element = aps.getElementName();
if (AFPElementMapping.TAG_LOGICAL_ELEMENT.equals(element)) {
- if (this.location != LOC_IN_PAGE_HEADER
- && this.location != LOC_FOLLOWING_PAGE_SEQUENCE) {
+ switch (this.location) {
+ case FOLLOWING_PAGE_SEQUENCE:
+ case IN_PAGE_HEADER:
+ String name = aps.getName();
+ String value = aps.getValue();
+ dataStream.createTagLogicalElement(name, value);
+ break;
+ default:
throw new IFException(
"TLE extension must be in the page header or between page-sequence"
+ " and the first page: " + aps, null);
}
- String name = aps.getName();
- String value = aps.getValue();
- dataStream.createTagLogicalElement(name, value);
+ } else if (AFPElementMapping.NO_OPERATION.equals(element)) {
+ switch (this.location) {
+ case IN_DOCUMENT_HEADER:
+ case FOLLOWING_PAGE_SEQUENCE:
+ case IN_PAGE_HEADER:
+ String content = aps.getContent();
+ if (content != null) {
+ dataStream.createNoOperation(content);
+ }
+ break;
+ default:
+ throw new IFException(
+ "NOP extension must be in the document header, the page header"
+ + " or between page-sequence"
+ + " and the first page: " + aps, null);
+ }
} else {
- if (this.location != LOC_IN_PAGE_HEADER) {
+ if (this.location != Location.IN_PAGE_HEADER) {
throw new IFException(
"AFP page setup extension encountered outside the page header: " + aps,
null);
@@ -294,16 +329,11 @@ public class AFPDocumentHandler extends AbstractBinaryWritingIFDocumentHandler
String source = apse.getValue();
String uri = apse.getResourceSrc();
pageSegmentMap.put(source, new PageSegmentDescriptor(name, uri));
- } else if (AFPElementMapping.NO_OPERATION.equals(element)) {
- String content = aps.getContent();
- if (content != null) {
- dataStream.createNoOperation(content);
- }
}
}
} else if (extension instanceof AFPPageOverlay) {
AFPPageOverlay ipo = (AFPPageOverlay)extension;
- if (this.location != LOC_IN_PAGE_HEADER) {
+ if (this.location != Location.IN_PAGE_HEADER) {
throw new IFException(
"AFP page overlay extension encountered outside the page header: " + ipo,
null);
@@ -313,8 +343,8 @@ public class AFPDocumentHandler extends AbstractBinaryWritingIFDocumentHandler
dataStream.createIncludePageOverlay(overlay, ipo.getX(), ipo.getY());
}
} else if (extension instanceof AFPInvokeMediumMap) {
- if (this.location != LOC_FOLLOWING_PAGE_SEQUENCE
- && this.location != LOC_IN_PAGE_HEADER) {
+ if (this.location != Location.FOLLOWING_PAGE_SEQUENCE
+ && this.location != Location.IN_PAGE_HEADER) {
throw new IFException(
"AFP IMM extension must be between page-sequence"
@@ -401,7 +431,7 @@ public class AFPDocumentHandler extends AbstractBinaryWritingIFDocumentHandler
* @return the page segment descriptor or null if there's no page segment for the given URI
*/
PageSegmentDescriptor getPageSegmentNameFor(String uri) {
- return (PageSegmentDescriptor)pageSegmentMap.get(uri);
+ return pageSegmentMap.get(uri);
}
}
diff --git a/src/java/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java b/src/java/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java
index 19f98f32a..b5b05191a 100644
--- a/src/java/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java
+++ b/src/java/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java
@@ -54,6 +54,7 @@ public class AFPPageSetupElement extends AbstractAFPExtensionObject {
}
/** {@inheritDoc} */
+ @Override
protected void startOfNode() throws FOPException {
super.startOfNode();
if (AFPElementMapping.TAG_LOGICAL_ELEMENT.equals(getLocalName())) {
@@ -63,14 +64,17 @@ public class AFPPageSetupElement extends AbstractAFPExtensionObject {
"rule.childOfPageSequenceOrSPM");
}
} else {
- if (parent.getNameId() != Constants.FO_SIMPLE_PAGE_MASTER) {
+ if (parent.getNameId() != Constants.FO_SIMPLE_PAGE_MASTER
+ && parent.getNameId() != Constants.FO_PAGE_SEQUENCE
+ && parent.getNameId() != Constants.FO_DECLARATIONS) {
invalidChildError(getLocator(), parent.getName(), getNamespaceURI(), getName(),
- "rule.childOfSPM");
+ "rule.childOfSPMorPSorDeclarations");
}
}
}
/** {@inheritDoc} */
+ @Override
protected void characters(char[] data, int start, int length,
PropertyList pList, Locator locator) throws FOPException {
StringBuffer sb = new StringBuffer();
@@ -83,6 +87,7 @@ public class AFPPageSetupElement extends AbstractAFPExtensionObject {
}
/** {@inheritDoc} */
+ @Override
public void processNode(String elementName, Locator locator,
Attributes attlist, PropertyList propertyList)
throws FOPException {
@@ -106,6 +111,7 @@ public class AFPPageSetupElement extends AbstractAFPExtensionObject {
}
/** {@inheritDoc} */
+ @Override
protected ExtensionAttachment instantiateExtensionAttachment() {
return new AFPPageSetup(getLocalName());
}