You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ac...@apache.org on 2008/11/27 11:37:44 UTC
svn commit: r721151 - in
/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop:
afp/ afp/fonts/ afp/modca/ render/afp/
Author: acumiskey
Date: Thu Nov 27 02:37:43 2008
New Revision: 721151
URL: http://svn.apache.org/viewvc?rev=721151&view=rev
Log:
* Text encoding is now handled by PresentationTextData and character set encoding errors are now handled by AFPEventProducer.
* Moved AFPEventProducer from org.apache.fop.render.afp package to org.apache.fop.afp package.
Added:
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPEventProducer.java (contents, props changed)
- copied, changed from r720483, xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPEventProducer.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPEventProducer.xml (with props)
Removed:
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPEventProducer.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPEventProducer.xml
Modified:
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPTextDataInfo.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/DataStream.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/fonts/AFPFontCollection.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractPageObject.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/PresentationTextData.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/PresentationTextObject.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPRenderer.java
Copied: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPEventProducer.java (from r720483, xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPEventProducer.java)
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPEventProducer.java?p2=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPEventProducer.java&p1=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPEventProducer.java&r1=720483&r2=721151&rev=721151&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPEventProducer.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPEventProducer.java Thu Nov 27 02:37:43 2008
@@ -17,7 +17,7 @@
/* $Id$ */
-package org.apache.fop.render.afp;
+package org.apache.fop.afp;
import org.apache.fop.events.EventBroadcaster;
import org.apache.fop.events.EventProducer;
@@ -55,6 +55,7 @@
/**
* Warn about using default font setup.
+ *
* @param source the event source
* @event.severity WARN
*/
@@ -62,10 +63,21 @@
/**
* Warn about a missing default "any" font configuration.
+ *
* @param source the event source
* @param style the font style
* @param weight the font weight
* @event.severity WARN
*/
void warnMissingDefaultFont(Object source, String style, int weight);
+
+ /**
+ * A character set encoding error occurred.
+ *
+ * @param source the event source
+ * @param charSetName the character set name
+ * @param encoding the encoding
+ * @event.severity ERROR
+ */
+ void characterSetEncodingError(Object source, String charSetName, String encoding);
}
Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPEventProducer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPEventProducer.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPEventProducer.java
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Thu Nov 27 02:37:43 2008
@@ -0,0 +1,2 @@
+/xmlgraphics/fop/branches/fop-0_95/src/java/org/apache/fop/render/afp/AFPEventProducer.java:684572,688085,688696
+/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPEventProducer.java:693433-698670,699739,704008-704909,705529-706135,706272-706276,706319-707083,707627,707631-708012,708192-708851,711781,718309-718502,718557-718591,718666-719110
Added: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPEventProducer.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPEventProducer.xml?rev=721151&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPEventProducer.xml (added)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPEventProducer.xml Thu Nov 27 02:37:43 2008
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<catalogue xml:lang="en">
+ <message key="org.apache.fop.afp.AFPEventProducer.warnDefaultFontSetup">No AFP fonts configured. Using default setup.</message>
+ <message key="org.apache.fop.afp.AFPEventProducer.warnMissingDefaultFont">No AFP default "any", {style}, {weight} font configured.</message>
+ <message key="org.apache.fop.afp.AFPEventProducer.characterSetEncodingError">An error occurred when attempting to encode character set {charSetName} with encoding scheme {encoding}.</message>
+</catalogue>
Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPEventProducer.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPEventProducer.xml
------------------------------------------------------------------------------
svn:keywords = Revision Id
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPTextDataInfo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPTextDataInfo.java?rev=721151&r1=721150&r2=721151&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPTextDataInfo.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPTextDataInfo.java Thu Nov 27 02:37:43 2008
@@ -26,22 +26,33 @@
*/
public class AFPTextDataInfo {
+ /** the text font reference */
private int fontReference;
+ /** the text x coordinate position */
private int x;
+ /** the text y coordinate position */
private int y;
+ /** the text color */
private Color color;
+ /** the text variable space adjustment */
private int variableSpaceCharacterIncrement;
+ /** the text inter character adjustment */
private int interCharacterAdjustment;
- private byte[] data;
-
+ /** the text orientation */
private int rotation;
+ /** the text encoding */
+ private String textEncoding;
+
+ /** the text string */
+ private String textString;
+
/**
* Returns the font reference
*
@@ -152,39 +163,57 @@
}
/**
- * Return the text data
+ * Sets the text orientation
*
- * @return the text data
+ * @param rotation the text rotation
*/
- public byte[] getData() {
- return data;
+ public void setRotation(int rotation) {
+ this.rotation = rotation;
}
/**
- * Sets the text data
+ * Returns the text rotation
*
- * @param data the text orientation
+ * @return the text rotation
*/
- public void setData(byte[] data) {
- this.data = data;
+ public int getRotation() {
+ return this.rotation;
}
/**
- * Sets the text orientation
+ * Sets the text encoding
*
- * @param rotation the text rotation
+ * @param textEncoding the text encoding
*/
- public void setRotation(int rotation) {
- this.rotation = rotation;
+ public void setEncoding(String textEncoding) {
+ this.textEncoding = textEncoding;
}
/**
- * Returns the text rotation
+ * Returns the text encoding
*
- * @return the text rotation
+ * @return the text encoding
*/
- public int getRotation() {
- return this.rotation;
+ public String getEncoding() {
+ return this.textEncoding;
+ }
+
+ /**
+ * Sets the text string
+ *
+ * @param textString the text string
+ */
+ public void setString(String textString) {
+ this.textString = textString;
+ }
+
+ /**
+ * Returns the text string
+ *
+ * @return the text string
+ */
+ public String getString() {
+ return this.textString;
}
/** {@inheritDoc} */
@@ -196,7 +225,8 @@
+ ", vsci=" + variableSpaceCharacterIncrement
+ ", ica=" + interCharacterAdjustment
+ ", orientation=" + rotation
- + ", data=" + data
+ + ", textString=" + textString
+ + ", textEncoding=" + textEncoding
+ "}";
}
}
\ No newline at end of file
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/DataStream.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/DataStream.java?rev=721151&r1=721150&r2=721151&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/DataStream.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/DataStream.java Thu Nov 27 02:37:43 2008
@@ -23,6 +23,7 @@
import java.awt.Point;
import java.io.IOException;
import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
import java.util.Iterator;
import java.util.Map;
@@ -364,8 +365,9 @@
*
* @param textDataInfo
* the afp text data
+ * @throws UnsupportedEncodingException thrown if character encoding is not supported
*/
- public void createText(AFPTextDataInfo textDataInfo) {
+ public void createText(AFPTextDataInfo textDataInfo) throws UnsupportedEncodingException {
int rotation = paintingState.getRotation();
if (rotation != 0) {
textDataInfo.setRotation(rotation);
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/fonts/AFPFontCollection.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/fonts/AFPFontCollection.java?rev=721151&r1=721150&r2=721151&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/fonts/AFPFontCollection.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/fonts/AFPFontCollection.java Thu Nov 27 02:37:43 2008
@@ -22,12 +22,12 @@
import java.util.Iterator;
import java.util.List;
+import org.apache.fop.afp.AFPEventProducer;
import org.apache.fop.events.EventBroadcaster;
import org.apache.fop.fonts.Font;
import org.apache.fop.fonts.FontCollection;
import org.apache.fop.fonts.FontInfo;
import org.apache.fop.fonts.FontTriplet;
-import org.apache.fop.render.afp.AFPEventProducer;
/**
* A base collection of AFP fonts
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractPageObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractPageObject.java?rev=721151&r1=721150&r2=721151&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractPageObject.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractPageObject.java Thu Nov 27 02:37:43 2008
@@ -21,6 +21,7 @@
import java.io.IOException;
import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
import java.util.List;
import org.apache.fop.afp.AFPLineDataInfo;
@@ -171,8 +172,9 @@
*
* @param textDataInfo
* the afp text data
+ * @throws UnsupportedEncodingException thrown if character encoding is not supported
*/
- public void createText(AFPTextDataInfo textDataInfo) {
+ public void createText(AFPTextDataInfo textDataInfo) throws UnsupportedEncodingException {
getPresentationTextObject().createTextData(textDataInfo);
}
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/PresentationTextData.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/PresentationTextData.java?rev=721151&r1=721150&r2=721151&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/PresentationTextData.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/PresentationTextData.java Thu Nov 27 02:37:43 2008
@@ -22,6 +22,7 @@
import java.awt.Color;
import java.io.IOException;
import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
import org.apache.commons.io.output.ByteArrayOutputStream;
import org.apache.fop.afp.AFPLineDataInfo;
@@ -50,49 +51,31 @@
*/
public class PresentationTextData extends AbstractAFPObject {
- /**
- * The maximum size of the presentation text data.
- */
+ /** the maximum size of the presentation text data.*/
private static final int MAX_SIZE = 8192;
- /**
- * The afp data relating to this presentation text data.
- */
+ /** the AFP data relating to this presentation text data. */
private final ByteArrayOutputStream baos = new ByteArrayOutputStream();
- /**
- * The current x coordinate.
- */
+ /** the current x coordinate. */
private int currentX = -1;
- /**
- * The current y cooridnate
- */
+ /** the current y cooridnate */
private int currentY = -1;
- /**
- * The current font
- */
+ /** the current font */
private String currentFont = "";
- /**
- * The current orientation
- */
+ /** the current orientation */
private int currentOrientation = 0;
- /**
- * The current color
- */
+ /** the current color */
private Color currentColor = new Color(0, 0, 0);
- /**
- * The current variable space increment
- */
+ /** the current variable space increment */
private int currentVariableSpaceCharacterIncrement = 0;
- /**
- * The current inter character adjustment
- */
+ /** the current inter character adjustment */
private int currentInterCharacterAdjustment = 0;
/**
@@ -115,9 +98,9 @@
0x5A, // Structured field identifier
0x00, // Record length byte 1
0x00, // Record length byte 2
- (byte) 0xD3, // PresentationTextData identifier byte 1
- (byte) 0xEE, // PresentationTextData identifier byte 2
- (byte) 0x9B, // PresentationTextData identifier byte 3
+ SF_CLASS, // PresentationTextData identifier byte 1
+ Type.DATA, // PresentationTextData identifier byte 2
+ Category.PRESENTATION_TEXT, // PresentationTextData identifier byte 3
0x00, // Flag
0x00, // Reserved
0x00, // Reserved
@@ -270,10 +253,12 @@
* @param textDataInfo
* the afp text data
* @throws MaximumSizeExceededException
- * thrown if the maximum number of text data is exceeded
+ * thrown if the maximum number of text data is exceeded
+ * @throws UnsupportedEncodingException
+ * thrown if character encoding is not supported
*/
public void createTextData(AFPTextDataInfo textDataInfo)
- throws MaximumSizeExceededException {
+ throws MaximumSizeExceededException, UnsupportedEncodingException {
ByteArrayOutputStream afpdata = new ByteArrayOutputStream();
@@ -325,7 +310,9 @@
afpdata);
// Add transparent data
- byte[] data = textDataInfo.getData();
+ String textString = textDataInfo.getString();
+ String encoding = textDataInfo.getEncoding();
+ byte[] data = textString.getBytes(encoding);
if (data.length <= TRANSPARENT_MAX_SIZE) {
addTransparentData(data, afpdata);
} else {
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/PresentationTextObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/PresentationTextObject.java?rev=721151&r1=721150&r2=721151&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/PresentationTextObject.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/PresentationTextObject.java Thu Nov 27 02:37:43 2008
@@ -21,6 +21,7 @@
import java.io.IOException;
import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
import java.util.List;
import org.apache.fop.afp.AFPLineDataInfo;
@@ -68,8 +69,9 @@
*
* @param textDataInfo
* The afp text data
+ * @throws UnsupportedEncodingException thrown if character encoding is not supported
*/
- public void createTextData(AFPTextDataInfo textDataInfo) {
+ public void createTextData(AFPTextDataInfo textDataInfo) throws UnsupportedEncodingException {
if (currentPresentationTextData == null) {
startPresentationTextData();
}
@@ -78,6 +80,9 @@
} catch (MaximumSizeExceededException msee) {
endPresentationTextData();
createTextData(textDataInfo);
+ } catch (UnsupportedEncodingException e) {
+ endPresentationTextData();
+ throw e;
}
}
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPRenderer.java?rev=721151&r1=721150&r2=721151&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPRenderer.java Thu Nov 27 02:37:43 2008
@@ -34,8 +34,8 @@
import java.util.Map;
import org.apache.fop.afp.AFPBorderPainter;
-import org.apache.fop.afp.AFPConstants;
import org.apache.fop.afp.AFPDataObjectInfo;
+import org.apache.fop.afp.AFPEventProducer;
import org.apache.fop.afp.AFPPaintingState;
import org.apache.fop.afp.AFPRectanglePainter;
import org.apache.fop.afp.AFPResourceManager;
@@ -48,6 +48,7 @@
import org.apache.fop.afp.fonts.AFPFontAttributes;
import org.apache.fop.afp.fonts.AFPFontCollection;
import org.apache.fop.afp.fonts.AFPPageFonts;
+import org.apache.fop.afp.fonts.CharacterSet;
import org.apache.fop.afp.modca.PageObject;
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
@@ -537,40 +538,34 @@
Color color = (Color) text.getTrait(Trait.COLOR);
textDataInfo.setColor(color);
- int variableSpaceCharacterIncrement = font.getWidth(' ', fontSize) / 1000
- + text.getTextWordSpaceAdjust()
- + text.getTextLetterSpaceAdjust();
+ int textWordSpaceAdjust = text.getTextWordSpaceAdjust();
+ int textLetterSpaceAdjust = text.getTextLetterSpaceAdjust();
+ int textWidth = font.getWidth(' ', fontSize) / 1000;
+ int variableSpaceCharacterIncrement
+ = textWidth + textWordSpaceAdjust + textLetterSpaceAdjust;
+
variableSpaceCharacterIncrement
= Math.round(unitConv.mpt2units(variableSpaceCharacterIncrement));
textDataInfo.setVariableSpaceCharacterIncrement(variableSpaceCharacterIncrement);
int interCharacterAdjustment
- = Math.round(unitConv.mpt2units(text.getTextLetterSpaceAdjust()));
+ = Math.round(unitConv.mpt2units(textLetterSpaceAdjust));
textDataInfo.setInterCharacterAdjustment(interCharacterAdjustment);
- // Try and get the encoding to use for the font
- String encoding = null;
- try {
- encoding = font.getCharacterSet(fontSize).getEncoding();
- } catch (Throwable ex) {
- encoding = AFPConstants.EBCIDIC_ENCODING;
- log.warn("renderText():: Error getting encoding for font '"
- + font.getFullName() + "' - using default encoding "
- + encoding);
- }
+ CharacterSet charSet = font.getCharacterSet(fontSize);
+ String encoding = charSet.getEncoding();
+ textDataInfo.setEncoding(encoding);
String textString = text.getText();
- byte[] data = null;
+ textDataInfo.setString(textString);
+
try {
- data = textString.getBytes(encoding);
- textDataInfo.setData(data);
- } catch (UnsupportedEncodingException usee) {
- log.error("renderText:: Font " + fontAttributes.getFontKey()
- + " caused UnsupportedEncodingException");
- return;
+ dataStream.createText(textDataInfo);
+ } catch (UnsupportedEncodingException e) {
+ AFPEventProducer eventProducer
+ = AFPEventProducer.Provider.get(userAgent.getEventBroadcaster());
+ eventProducer.characterSetEncodingError(this, charSet.getName(), encoding);
}
-
- dataStream.createText(textDataInfo);
// word.getOffset() = only height of text itself
// currentBlockIPPosition: 0 for beginning of line; nonzero
// where previous line area failed to take up entire allocated space
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org