diff options
author | Jeremias Maerki <jeremias@apache.org> | 2008-12-19 14:26:37 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2008-12-19 14:26:37 +0000 |
commit | e8383ed28560a67758a45f0b421021b210d6ca1f (patch) | |
tree | 0c2243e9cc93e7255b34707c5a9f260629274866 | |
parent | 34ecb4c0e098856c1249025865c05ea34b46b51e (diff) | |
parent | d928079360d10cb230640a6b2a4992f6ee87b16d (diff) | |
download | xmlgraphics-fop-e8383ed28560a67758a45f0b421021b210d6ca1f.tar.gz xmlgraphics-fop-e8383ed28560a67758a45f0b421021b210d6ca1f.zip |
Merge from Trunk revisions 724690 - 728025.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign@728031 13f79535-47bb-0310-9956-ffa450edef68
11 files changed, 93 insertions, 39 deletions
diff --git a/src/java/org/apache/fop/afp/DataStream.java b/src/java/org/apache/fop/afp/DataStream.java index 783c698ea..ea620b867 100644 --- a/src/java/org/apache/fop/afp/DataStream.java +++ b/src/java/org/apache/fop/afp/DataStream.java @@ -79,6 +79,9 @@ public class DataStream { /** The current page */ private AbstractPageObject currentPage = null; + /** Sequence number for TLE's.*/ + private int tleSequence = 0; + /** The MO:DCA interchange set in use (default to MO:DCA-P IS/2 set) */ private InterchangeSet interchangeSet = InterchangeSet.valueOf(InterchangeSet.MODCA_PRESENTATION_INTERCHANGE_SET_2); @@ -474,7 +477,7 @@ public class DataStream { for (int i = 0; i < attributes.length; i++) { String name = attributes[i].getKey(); String value = attributes[i].getValue(); - currentPage.createTagLogicalElement(name, value); + currentPage.createTagLogicalElement(name, value, tleSequence++); } } @@ -504,7 +507,7 @@ public class DataStream { if (currentPageGroup != null) { currentPageGroup.createTagLogicalElement(name, value); } else { - currentPage.createTagLogicalElement(name, value); + currentPage.createTagLogicalElement(name, value, tleSequence++); } } @@ -546,7 +549,7 @@ public class DataStream { */ public void startPageGroup() throws IOException { endPageGroup(); - this.currentPageGroup = factory.createPageGroup(); + this.currentPageGroup = factory.createPageGroup(tleSequence); } /** @@ -557,6 +560,7 @@ public class DataStream { public void endPageGroup() throws IOException { if (currentPageGroup != null) { currentPageGroup.endPageGroup(); + tleSequence = currentPageGroup.getTleSequence(); document.addPageGroup(currentPageGroup); document.writeToStream(outputStream); currentPageGroup = null; diff --git a/src/java/org/apache/fop/afp/Factory.java b/src/java/org/apache/fop/afp/Factory.java index a278a5761..9d9b83875 100644 --- a/src/java/org/apache/fop/afp/Factory.java +++ b/src/java/org/apache/fop/afp/Factory.java @@ -219,13 +219,13 @@ public class Factory { /** * Creates a new MO:DCA {@link PageGroup} - * + * @param tleSequence current start tle sequence number within stream * @return a new {@link PageGroup} */ - public PageGroup createPageGroup() { + public PageGroup createPageGroup(int tleSequence) { String name = PAGE_GROUP_NAME_PREFIX + StringUtils.lpad(String.valueOf(++pageGroupCount), '0', 5); - return new PageGroup(this, name); + return new PageGroup(this, name, tleSequence); } /** @@ -381,10 +381,11 @@ public class Factory { * * @param name name of the element * @param value value of the element + * @param tleSequence current start tle sequence number within stream* * @return a new {@link TagLogicalElement} */ - public TagLogicalElement createTagLogicalElement(String name, String value) { - TagLogicalElement tle = new TagLogicalElement(name, value); + public TagLogicalElement createTagLogicalElement(String name, String value, int tleSequence) { + TagLogicalElement tle = new TagLogicalElement(name, value, tleSequence); return tle; } diff --git a/src/java/org/apache/fop/afp/modca/AbstractAFPObject.java b/src/java/org/apache/fop/afp/modca/AbstractAFPObject.java index f1b76c447..ae1c83377 100644 --- a/src/java/org/apache/fop/afp/modca/AbstractAFPObject.java +++ b/src/java/org/apache/fop/afp/modca/AbstractAFPObject.java @@ -181,7 +181,7 @@ public abstract class AbstractAFPObject implements Streamable { public interface Type { /** Attribute */ - byte ATTRIBUTE = (byte)0x0A; + byte ATTRIBUTE = (byte)0xA0; /** Copy Count */ byte COPY_COUNT = (byte)0xA2; diff --git a/src/java/org/apache/fop/afp/modca/AbstractPageObject.java b/src/java/org/apache/fop/afp/modca/AbstractPageObject.java index 249de1339..eff879715 100644 --- a/src/java/org/apache/fop/afp/modca/AbstractPageObject.java +++ b/src/java/org/apache/fop/afp/modca/AbstractPageObject.java @@ -222,9 +222,11 @@ public abstract class AbstractPageObject extends AbstractNamedAFPObject implemen * the name of the tag * @param value * the value of the tag + * @param tleID + * unique ID within AFP stream */ - public void createTagLogicalElement(String name, String value) { - TagLogicalElement tle = new TagLogicalElement(name, value); + public void createTagLogicalElement(String name, String value, int tleID) { + TagLogicalElement tle = new TagLogicalElement(name, value, tleID); if (tagLogicalElements == null) { tagLogicalElements = new java.util.ArrayList/*<TagLogicalElement>*/(); } diff --git a/src/java/org/apache/fop/afp/modca/AbstractResourceGroupContainer.java b/src/java/org/apache/fop/afp/modca/AbstractResourceGroupContainer.java index 9dcd56277..6546fa978 100644 --- a/src/java/org/apache/fop/afp/modca/AbstractResourceGroupContainer.java +++ b/src/java/org/apache/fop/afp/modca/AbstractResourceGroupContainer.java @@ -163,6 +163,11 @@ implements Streamable { * @return true if this object can be written */ protected boolean canWrite(AbstractAFPObject obj) { - return obj instanceof AbstractPageObject && ((Completable)obj).isComplete(); + if (obj instanceof AbstractPageObject) { + return ((Completable)obj).isComplete(); + } + else { + return this.isComplete(); + } } } diff --git a/src/java/org/apache/fop/afp/modca/PageGroup.java b/src/java/org/apache/fop/afp/modca/PageGroup.java index 13be9745e..4e578718b 100644 --- a/src/java/org/apache/fop/afp/modca/PageGroup.java +++ b/src/java/org/apache/fop/afp/modca/PageGroup.java @@ -40,13 +40,20 @@ public class PageGroup extends AbstractResourceEnvironmentGroupContainer { private List tagLogicalElements = null; /** + * Sequence number for TLE's. + */ + private int tleSequence = 0; + + /** * Constructor for the PageGroup. * * @param factory the resource manager * @param name the name of the page group + * @param tleSequence current start tle sequence number within stream */ - public PageGroup(Factory factory, String name) { + public PageGroup(Factory factory, String name, int tleSequence) { super(factory, name); + this.tleSequence = tleSequence; } private List getTagLogicalElements() { @@ -65,9 +72,10 @@ public class PageGroup extends AbstractResourceEnvironmentGroupContainer { * the value of the tag */ public void createTagLogicalElement(String name, String value) { - TagLogicalElement tle = factory.createTagLogicalElement(name, value); + TagLogicalElement tle = factory.createTagLogicalElement(name, value, tleSequence); if (!getTagLogicalElements().contains(tle)) { getTagLogicalElements().add(tle); + tleSequence++; } } @@ -102,4 +110,8 @@ public class PageGroup extends AbstractResourceEnvironmentGroupContainer { public String toString() { return this.getName(); } + + public int getTleSequence() { + return tleSequence; + } }
\ No newline at end of file diff --git a/src/java/org/apache/fop/afp/modca/TagLogicalElement.java b/src/java/org/apache/fop/afp/modca/TagLogicalElement.java index 2e1fa5e07..9ccd58bfb 100644 --- a/src/java/org/apache/fop/afp/modca/TagLogicalElement.java +++ b/src/java/org/apache/fop/afp/modca/TagLogicalElement.java @@ -58,25 +58,46 @@ public class TagLogicalElement extends AbstractAFPObject { private String value = null; /** + * Sequence of TLE within document + */ + private int tleID; + + /** * Construct a tag logical element with the name and value specified. * * @param name the name of the tag logical element * @param value the value of the tag logical element + * @param tleID unique identifier for TLE within AFP stream */ - public TagLogicalElement(String name, String value) { + public TagLogicalElement(String name, String value, int tleID) { this.name = name; this.value = value; + this.tleID = tleID; } /** {@inheritDoc} */ public void writeToStream(OutputStream os) throws IOException { - byte[] data = new byte[17 + name.length() + value.length()]; + // convert name and value to ebcdic + byte[] tleByteName = null; + byte[] tleByteValue = null; + try { + tleByteName = name.getBytes(AFPConstants.EBCIDIC_ENCODING); + tleByteValue = value.getBytes(AFPConstants.EBCIDIC_ENCODING); + } catch (UnsupportedEncodingException usee) { + tleByteName = name.getBytes(); + tleByteValue = value.getBytes(); + log.warn( + "Constructor:: UnsupportedEncodingException translating the name " + + name); + } + + byte[] data = new byte[27 + tleByteName.length + tleByteValue.length]; data[0] = 0x5A; // Set the total record length byte[] rl1 - = BinaryUtils.convert(16 + name.length() + value.length(), 2); + = BinaryUtils.convert(26 + tleByteName.length + tleByteValue.length, 2); //Ignore first byte data[1] = rl1[0]; data[2] = rl1[1]; @@ -90,27 +111,15 @@ public class TagLogicalElement extends AbstractAFPObject { data[7] = 0x00; // Reserved data[8] = 0x00; // Reserved - //Use 2 triplets, attrubute name and value (the key for indexing) + //Use 2 triplets, attribute name and value (the key for indexing) - byte[] rl2 = BinaryUtils.convert(name.length() + 4, 1); + byte[] rl2 = BinaryUtils.convert(tleByteName.length + 4, 1); data[9] = rl2[0]; // length of the triplet, including this field data[10] = 0x02; //Identifies it as a FQN triplet data[11] = 0x0B; // GID format data[12] = 0x00; - byte[] tleByteName = null; - byte[] tleByteValue = null; - try { - tleByteName = name.getBytes(AFPConstants.EBCIDIC_ENCODING); - tleByteValue = value.getBytes(AFPConstants.EBCIDIC_ENCODING); - } catch (UnsupportedEncodingException usee) { - tleByteName = name.getBytes(); - tleByteValue = value.getBytes(); - log.warn( - "Constructor:: UnsupportedEncodingException translating the name " - + name); - } - + // write out TLE name int pos = 13; for (int i = 0; i < tleByteName.length; i++) { data[pos++] = tleByteName[i]; @@ -125,6 +134,18 @@ public class TagLogicalElement extends AbstractAFPObject { for (int i = 0; i < tleByteValue.length; i++) { data[pos++] = tleByteValue[i]; } + // attribute qualifier + data[pos++] = 0x10; + data[pos++] = (byte)0x80; + byte[] id = BinaryUtils.convert(tleID, 4); + for (int i = 0; i < id.length; i++) { + data[pos++] = id[i]; + } + byte[] level = BinaryUtils.convert(1, 4); + for (int i = 0; i < level.length; i++) { + data[pos++] = level[i]; + } + os.write(data); } } diff --git a/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java b/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java index 2e04f2d85..54f6170db 100644 --- a/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java +++ b/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java @@ -26,7 +26,14 @@ import java.awt.geom.Rectangle2D; import java.util.List; import java.util.Map; +import org.w3c.dom.Document; + import org.apache.batik.parser.AWTTransformProducer; + +import org.apache.xmlgraphics.image.loader.ImageSize; +import org.apache.xmlgraphics.util.QName; +import org.apache.xmlgraphics.util.UnitConv; + import org.apache.fop.area.Area; import org.apache.fop.area.Block; import org.apache.fop.area.BlockViewport; @@ -42,10 +49,6 @@ import org.apache.fop.fo.Constants; import org.apache.fop.fo.extensions.ExtensionElementMapping; import org.apache.fop.fonts.FontMetrics; import org.apache.fop.traits.BorderProps; -import org.apache.xmlgraphics.image.loader.ImageSize; -import org.apache.xmlgraphics.util.QName; -import org.apache.xmlgraphics.util.UnitConv; -import org.w3c.dom.Document; /** * Abstract base class for renderers like PDF and PostScript where many painting operations @@ -383,7 +386,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { endTextObject(); float sx1 = startx; - float sx2 = (slant[START] ? sx1 + borderWidth[AFTER] - clipw[AFTER] : sx1); + float sx2 = (slant[START] ? sx1 + borderWidth[START] - clipw[START] : sx1); float ex1 = startx + width; float ex2 = (slant[AFTER] ? ex1 - borderWidth[END] + clipw[END] : ex1); float outery = starty + height + clipw[AFTER]; diff --git a/src/java/org/apache/fop/render/afp/extensions/AFPElement.java b/src/java/org/apache/fop/render/afp/extensions/AFPElement.java index 2fdd32649..3104ced6f 100755 --- a/src/java/org/apache/fop/render/afp/extensions/AFPElement.java +++ b/src/java/org/apache/fop/render/afp/extensions/AFPElement.java @@ -53,6 +53,6 @@ public class AFPElement extends AbstractAFPExtensionObject { /** {@inheritDoc} */ protected ExtensionAttachment instantiateExtensionAttachment() { - return new AFPPageSetup(getName()); + return new AFPPageSetup(getLocalName()); } } diff --git a/src/java/org/apache/fop/render/afp/extensions/AFPPageSetup.java b/src/java/org/apache/fop/render/afp/extensions/AFPPageSetup.java index 998ce6921..d4b8e8a59 100644 --- a/src/java/org/apache/fop/render/afp/extensions/AFPPageSetup.java +++ b/src/java/org/apache/fop/render/afp/extensions/AFPPageSetup.java @@ -20,7 +20,7 @@ package org.apache.fop.render.afp.extensions; /** - * This is the pass-through value object for the PostScript extension. + * This is the pass-through value object for the AFP extension. */ public class AFPPageSetup extends AFPExtensionAttachment { diff --git a/status.xml b/status.xml index c7d030e80..6d9373a9f 100644 --- a/status.xml +++ b/status.xml @@ -53,6 +53,12 @@ <changes> <release version="FOP Trunk" date="TBD"> + <action context="Renderers" dev="JM" type="fix"> + Fixed black backgrounds occurring for transparent images in PCL output. + </action> + <action context="Renderers" dev="CB" type="fix" fixes-bug="46369"> + Fixed bug that caused AFP Renderer Extensions to be ignored. + </action> <action context="Code" dev="AD" type="fix" fixes-bug="46319"> Fixed a memory-leak in Marker.MarkerAttribute, where an instance was used both as key and value in a WeakHashMap, effectively neutralizing the benefit of using WeakReferences. Solved by extending |