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 je...@apache.org on 2008/04/14 13:54:17 UTC
svn commit: r647742 [4/5] - in /xmlgraphics/fop/trunk: ./
examples/embedding/java/embedding/events/ lib/build/ src/codegen/java/
src/codegen/java/org/ src/codegen/java/org/apache/
src/codegen/java/org/apache/fop/ src/codegen/java/org/apache/fop/tools/ ...
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/Title.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/Title.java?rev=647742&r1=647741&r2=647742&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/Title.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/Title.java Mon Apr 14 04:53:29 2008
@@ -27,7 +27,7 @@
import org.apache.fop.fo.flow.InlineLevel;
/**
- * Class modelling the fo:title object.
+ * Class modeling the fo:title object.
*/
public class Title extends InlineLevel {
// The value of properties relevant for fo:title.
@@ -35,6 +35,7 @@
// End of property values
/**
+ * Creates a new title element.
* @param parent FONode that is the parent of this object
*/
public Title(FONode parent) {
@@ -46,22 +47,20 @@
XSL/FOP: (#PCDATA|%inline;)*
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
- if (!isInlineItem(nsURI, localName)) {
- invalidChildError(loc, nsURI, localName);
+ throws ValidationException {
+ if (FO_URI.equals(nsURI)) {
+ if (!isInlineItem(nsURI, localName)) {
+ invalidChildError(loc, nsURI, localName);
+ }
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public String getLocalName() {
return "title";
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public int getNameId() {
return FO_TITLE;
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/bookmarks/Bookmark.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/bookmarks/Bookmark.java?rev=647742&r1=647741&r2=647742&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/bookmarks/Bookmark.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/bookmarks/Bookmark.java Mon Apr 14 04:53:29 2008
@@ -20,10 +20,13 @@
package org.apache.fop.fo.pagination.bookmarks;
import java.util.ArrayList;
+import java.util.List;
+
import org.xml.sax.Locator;
+
import org.apache.fop.apps.FOPException;
-import org.apache.fop.fo.FObj;
import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.FObj;
import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.ValidationException;
@@ -68,10 +71,10 @@
externalDestination = null;
} else if (externalDestination.length() == 0) {
// slightly stronger than spec "should be specified"
- attributeError("Missing attribute: Either external-destination or " +
- "internal-destination must be specified.");
+ getFOValidationEventProducer().missingLinkDestination(this, getName(), locator);
} else {
- attributeWarning("external-destination property not currently supported");
+ getFOValidationEventProducer().unimplementedFeature(this, getName(),
+ "external-destination", getLocator());
}
}
@@ -80,18 +83,20 @@
XSL/FOP: (bookmark-title, bookmark*)
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
- if (FO_URI.equals(nsURI) && localName.equals("bookmark-title")) {
+ throws ValidationException {
+ if (FO_URI.equals(nsURI)) {
+ if (localName.equals("bookmark-title")) {
if (bookmarkTitle != null) {
tooManyNodesError(loc, "fo:bookmark-title");
}
- } else if (FO_URI.equals(nsURI) && localName.equals("bookmark")) {
+ } else if (localName.equals("bookmark")) {
if (bookmarkTitle == null) {
nodesOutOfOrderError(loc, "fo:bookmark-title", "fo:bookmark");
}
} else {
invalidChildError(loc, nsURI, localName);
}
+ }
}
/**
@@ -123,10 +128,18 @@
return bookmarkTitle == null ? "" : bookmarkTitle.getTitle();
}
+ /**
+ * Returns the value of the internal-destination property.
+ * @return the internal-destination
+ */
public String getInternalDestination() {
return internalDestination;
}
+ /**
+ * Returns the value of the external-destination property.
+ * @return the external-destination
+ */
public String getExternalDestination() {
return externalDestination;
}
@@ -141,7 +154,11 @@
return bShow;
}
- public ArrayList getChildBookmarks() {
+ /**
+ * Returns a list of child bookmarks.
+ * @return the list of child bookmarks
+ */
+ public List getChildBookmarks() {
return childBookmarks;
}
@@ -150,9 +167,7 @@
return "bookmark";
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public int getNameId() {
return FO_BOOKMARK;
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTitle.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTitle.java?rev=647742&r1=647741&r2=647742&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTitle.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTitle.java Mon Apr 14 04:53:29 2008
@@ -21,8 +21,8 @@
import org.xml.sax.Locator;
-import org.apache.fop.fo.FObj;
import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.FObj;
import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.ValidationException;
@@ -45,15 +45,16 @@
/**
* Add the characters to this BookmarkTitle.
- * The text data inside the BookmarkTitle xml element
+ * The text data inside the BookmarkTitle XML element
* is used for the BookmarkTitle string.
*
* @param data the character data
* @param start the start position in the data array
* @param end the end position in the character array
- * @param locator location in fo source file.
+ * @param pList the currently valid property list
+ * @param locator location in FO source file.
*/
- protected void addCharacters(char data[], int start, int end,
+ protected void addCharacters(char[] data, int start, int end,
PropertyList pList,
Locator locator) {
title += new String(data, start, end - start);
@@ -64,8 +65,10 @@
XSL/FOP: empty
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
+ throws ValidationException {
+ if (FO_URI.equals(nsURI)) {
invalidChildError(loc, nsURI, localName);
+ }
}
/**
@@ -82,9 +85,7 @@
return "bookmark-title";
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public int getNameId() {
return FO_BOOKMARK_TITLE;
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTree.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTree.java?rev=647742&r1=647741&r2=647742&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTree.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTree.java Mon Apr 14 04:53:29 2008
@@ -21,6 +21,7 @@
// Java
import java.util.ArrayList;
+import java.util.List;
import org.xml.sax.Locator;
@@ -39,15 +40,15 @@
private ArrayList bookmarks = new ArrayList();
/**
+ * Creates a new bookmark-tree element.
+ * @param parent the parent node
* @see org.apache.fop.fo.FONode#FONode(FONode)
*/
public BookmarkTree(FONode parent) {
super(parent);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
protected void addChildNode(FONode obj) {
if (obj instanceof Bookmark) {
bookmarks.add(obj);
@@ -69,14 +70,19 @@
XSL/FOP: (bookmark+)
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
- if (!(FO_URI.equals(nsURI) &&
- localName.equals("bookmark"))) {
+ throws ValidationException {
+ if (FO_URI.equals(nsURI)) {
+ if (!localName.equals("bookmark")) {
invalidChildError(loc, nsURI, localName);
+ }
}
}
- public ArrayList getBookmarks() {
+ /**
+ * Returns the root bookmarks.
+ * @return the root bookmarks
+ */
+ public List getBookmarks() {
return bookmarks;
}
@@ -85,9 +91,7 @@
return "bookmark-tree";
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public int getNameId() {
return FO_BOOKMARK_TREE;
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/XMLLangShorthandParser.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/XMLLangShorthandParser.java?rev=647742&r1=647741&r2=647742&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/XMLLangShorthandParser.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/XMLLangShorthandParser.java Mon Apr 14 04:53:29 2008
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
-/* $Id:$ */
+/* $Id$ */
package org.apache.fop.fo.properties;
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontInfo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontInfo.java?rev=647742&r1=647741&r2=647742&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontInfo.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontInfo.java Mon Apr 14 04:53:29 2008
@@ -67,6 +67,8 @@
/** Cache for Font instances. */
private Map fontInstanceCache = new java.util.HashMap();
+ private FontEventListener eventListener;
+
/**
* Main constructor
*/
@@ -78,6 +80,15 @@
}
/**
+ * Sets the font event listener that can be used to receive events about particular events
+ * in this class.
+ * @param listener the font event listener
+ */
+ public void setEventListener(FontEventListener listener) {
+ this.eventListener = listener;
+ }
+
+ /**
* Checks if the font setup is valid (At least the ultimate fallback font
* must be registered.)
* @return True if valid
@@ -158,6 +169,9 @@
public void addMetrics(String name, FontMetrics metrics) {
// add the given metrics as a font with the given name
+ if (metrics instanceof Typeface) {
+ ((Typeface)metrics).setEventListener(this.eventListener);
+ }
this.fonts.put(name, metrics);
}
@@ -364,8 +378,12 @@
}
if (!loggedFontKeys.contains(replacedKey)) {
loggedFontKeys.add(replacedKey);
- log.warn("Font '" + replacedKey + "' not found. "
- + "Substituting with '" + newKey + "'.");
+ if (this.eventListener != null) {
+ this.eventListener.fontSubstituted(this, replacedKey, newKey);
+ } else {
+ log.warn("Font '" + replacedKey + "' not found. "
+ + "Substituting with '" + newKey + "'.");
+ }
}
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/LazyFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/LazyFont.java?rev=647742&r1=647741&r2=647742&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/LazyFont.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/LazyFont.java Mon Apr 14 04:53:29 2008
@@ -141,6 +141,7 @@
throw new RuntimeException(ioex.getMessage());
}
}
+ realFont.setEventListener(this.eventListener);
isMetricsLoaded = true;
}
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/SingleByteFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/SingleByteFont.java?rev=647742&r1=647741&r2=647742&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/SingleByteFont.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/SingleByteFont.java Mon Apr 14 04:53:29 2008
@@ -117,18 +117,22 @@
}
//Give up, character is not available
- Character ch = new Character(c);
- if (warnedChars == null) {
- warnedChars = new java.util.HashSet();
- }
- if (warnedChars.size() < 8 && !warnedChars.contains(ch)) {
- warnedChars.add(ch);
- if (warnedChars.size() == 8) {
- log.warn("Many requested glyphs are not available in font " + getFontName());
- } else {
- log.warn("Glyph " + (int)c + " (0x" + Integer.toHexString(c)
- + ", " + Glyphs.charToGlyphName(c)
- + ") not available in font " + getFontName());
+ if (this.eventListener != null) {
+ this.eventListener.glyphNotAvailable(this, c, getFontName());
+ } else {
+ Character ch = new Character(c);
+ if (warnedChars == null) {
+ warnedChars = new java.util.HashSet();
+ }
+ if (warnedChars.size() < 8 && !warnedChars.contains(ch)) {
+ warnedChars.add(ch);
+ if (warnedChars.size() == 8) {
+ log.warn("Many requested glyphs are not available in font " + getFontName());
+ } else {
+ log.warn("Glyph " + (int)c + " (0x" + Integer.toHexString(c)
+ + ", " + Glyphs.charToGlyphName(c)
+ + ") not available in font " + getFontName());
+ }
}
}
return NOT_FOUND;
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/Typeface.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/Typeface.java?rev=647742&r1=647741&r2=647742&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/Typeface.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/Typeface.java Mon Apr 14 04:53:29 2008
@@ -30,6 +30,9 @@
*/
private long charMapOps = 0;
+ /** An optional event listener that receives events such as missing glyphs etc. */
+ protected FontEventListener eventListener;
+
/**
* Get the encoding of the font.
* @return the encoding
@@ -78,6 +81,15 @@
/** {@inheritDoc} */
public int getMaxAscent(int size) {
return getAscender(size);
+ }
+
+ /**
+ * Sets the font event listener that can be used to receive events about particular events
+ * in this class.
+ * @param listener the font event listener
+ */
+ public void setEventListener(FontEventListener listener) {
+ this.eventListener = listener;
}
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java?rev=647742&r1=647741&r2=647742&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java Mon Apr 14 04:53:29 2008
@@ -35,6 +35,7 @@
import org.apache.fop.fonts.EmbedFontInfo;
import org.apache.fop.fonts.Font;
import org.apache.fop.fonts.FontCache;
+import org.apache.fop.fonts.FontEventListener;
import org.apache.fop.fonts.FontLoader;
import org.apache.fop.fonts.FontResolver;
import org.apache.fop.fonts.FontTriplet;
@@ -52,6 +53,17 @@
/** logging instance */
private Log log = LogFactory.getLog(FontInfoFinder.class);
+ private FontEventListener eventListener;
+
+ /**
+ * Sets the font event listener that can be used to receive events about particular events
+ * in this class.
+ * @param listener the font event listener
+ */
+ public void setEventListener(FontEventListener listener) {
+ this.eventListener = listener;
+ }
+
/**
* Attempts to determine FontTriplets from a given CustomFont.
* It seems to be fairly accurate but will probably require some tweaking over time
@@ -180,7 +192,6 @@
// try to determine triplet information from font file
CustomFont customFont = null;
-
if (fontUrl.toExternalForm().endsWith(".ttc")) {
// Get a list of the TTC Font names
List ttcNames = null; //List<String>
@@ -193,7 +204,9 @@
FontFileReader reader = new FontFileReader(in);
ttcNames = ttf.getTTCnames(reader);
} catch (Exception e) {
- log.error(e);
+ if (this.eventListener != null) {
+ this.eventListener.fontLoadingErrorAtAutoDetection(this, fontFileURI, e);
+ }
} finally {
IOUtils.closeQuietly(in);
}
@@ -212,14 +225,16 @@
try {
ttfLoader = new TTFFontLoader(fontFileURI, fontName, resolver);
customFont = ttfLoader.getFont();
+ if (this.eventListener != null) {
+ customFont.setEventListener(this.eventListener);
+ }
} catch (Exception e) {
- //TODO Too verbose (it's an error but we don't care if some fonts can't be loaded)
- //if (log.isErrorEnabled()) {
- log.error("Unable to load font file: " + embedUrl + ". Reason: " + e.getMessage());
- //}
if (fontCache != null) {
fontCache.registerFailedFont(embedUrl, fileLastModified);
}
+ if (this.eventListener != null) {
+ this.eventListener.fontLoadingErrorAtAutoDetection(this, embedUrl, e);
+ }
continue;
}
EmbedFontInfo fi = fontInfoFromCustomFont(fontUrl, customFont, fontCache);
@@ -233,14 +248,16 @@
// The normal case
try {
customFont = FontLoader.loadFont(fontUrl, null, resolver);
+ if (this.eventListener != null) {
+ customFont.setEventListener(this.eventListener);
+ }
} catch (Exception e) {
- //TODO Too verbose (it's an error but we don't care if some fonts can't be loaded)
- //if (log.isErrorEnabled()) {
- log.error("Unable to load font file: " + embedUrl + ". Reason: " + e.getMessage());
- //}
if (fontCache != null) {
fontCache.registerFailedFont(embedUrl, fileLastModified);
}
+ if (this.eventListener != null) {
+ this.eventListener.fontLoadingErrorAtAutoDetection(this, embedUrl, e);
+ }
return null;
}
EmbedFontInfo fi = fontInfoFromCustomFont(fontUrl, customFont, fontCache);
@@ -250,7 +267,6 @@
return null;
}
}
-
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java?rev=647742&r1=647741&r2=647742&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java Mon Apr 14 04:53:29 2008
@@ -27,8 +27,11 @@
import org.apache.batik.bridge.BridgeContext;
import org.apache.batik.bridge.GVTBuilder;
+import org.apache.batik.bridge.UserAgent;
import org.apache.batik.dom.svg.SVGDOMImplementation;
import org.apache.batik.gvt.GraphicsNode;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.xmlgraphics.image.loader.Image;
import org.apache.xmlgraphics.image.loader.ImageException;
@@ -40,7 +43,7 @@
import org.apache.xmlgraphics.java2d.Graphics2DImagePainter;
import org.apache.xmlgraphics.util.UnitConv;
-import org.apache.fop.svg.SVGUserAgent;
+import org.apache.fop.svg.SimpleSVGUserAgent;
/**
* This ImageConverter converts SVG images to Java2D.
@@ -52,6 +55,9 @@
*/
public class ImageConverterSVG2G2D extends AbstractImageConverter {
+ /** logger */
+ private static Log log = LogFactory.getLog(ImageConverterSVG2G2D.class);
+
/** {@inheritDoc} */
public Image convert(Image src, Map hints) throws ImageException {
checkSourceFlavor(src);
@@ -67,9 +73,7 @@
if (ptm != null) {
pxToMillimeter = (float)UnitConv.mm2in(ptm.doubleValue());
}
- SVGUserAgent ua = new SVGUserAgent(
- pxToMillimeter,
- new AffineTransform());
+ UserAgent ua = createBatikUserAgent(pxToMillimeter);
GVTBuilder builder = new GVTBuilder();
final BridgeContext ctx = new BridgeContext(ua);
@@ -105,6 +109,25 @@
ImageGraphics2D g2dImage = new ImageGraphics2D(src.getInfo(), painter);
return g2dImage;
+ }
+
+ /**
+ * Creates a user agent for Batik. Override to provide your own user agent.
+ * @param pxToMillimeter the source resolution (in px per millimeter)
+ * @return the newly created user agent
+ */
+ protected SimpleSVGUserAgent createBatikUserAgent(float pxToMillimeter) {
+ return new SimpleSVGUserAgent(
+ pxToMillimeter,
+ new AffineTransform()) {
+
+ /** {@inheritDoc} */
+ public void displayMessage(String message) {
+ //TODO Refine and pipe through to caller
+ log.debug(message);
+ }
+
+ };
}
/** {@inheritDoc} */
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/image/loader/batik/PreloaderSVG.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/image/loader/batik/PreloaderSVG.java?rev=647742&r1=647741&r2=647742&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/image/loader/batik/PreloaderSVG.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/image/loader/batik/PreloaderSVG.java Mon Apr 14 04:53:29 2008
@@ -32,6 +32,7 @@
import org.apache.batik.bridge.BridgeContext;
import org.apache.batik.bridge.UnitProcessor;
+import org.apache.batik.bridge.UserAgent;
import org.apache.batik.dom.svg.SAXSVGDocumentFactory;
import org.apache.batik.dom.svg.SVGDOMImplementation;
import org.apache.batik.dom.svg.SVGOMDocument;
@@ -46,7 +47,7 @@
import org.apache.xmlgraphics.image.loader.util.ImageUtil;
import org.apache.xmlgraphics.util.MimeConstants;
-import org.apache.fop.svg.SVGUserAgent;
+import org.apache.fop.svg.SimpleSVGUserAgent;
import org.apache.fop.util.UnclosableInputStream;
/**
@@ -154,8 +155,15 @@
private ImageInfo createImageInfo(String uri, ImageContext context, SVGDocument doc) {
Element e = doc.getRootElement();
float pxUnitToMillimeter = 25.4f / context.getSourceResolution();
- SVGUserAgent userAg = new SVGUserAgent(pxUnitToMillimeter,
- new AffineTransform());
+ UserAgent userAg = new SimpleSVGUserAgent(pxUnitToMillimeter,
+ new AffineTransform()) {
+
+ /** {@inheritDoc} */
+ public void displayMessage(String message) {
+ log.debug(message);
+ }
+
+ };
BridgeContext ctx = new BridgeContext(userAg);
UnitProcessor.Context uctx = UnitProcessor.createContext(ctx, e);
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java?rev=647742&r1=647741&r2=647742&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java Mon Apr 14 04:53:29 2008
@@ -198,11 +198,11 @@
}
/**
- * Returns a PageBreakingLayoutListener for the PageBreakingAlgorithm to notify about layout
- * problems.
+ * Creates and returns a PageBreakingLayoutListener for the PageBreakingAlgorithm to
+ * notify about layout problems.
* @return the listener instance or null if no notifications are needed
*/
- protected PageBreakingAlgorithm.PageBreakingLayoutListener getLayoutListener() {
+ protected PageBreakingAlgorithm.PageBreakingLayoutListener createLayoutListener() {
return null;
}
@@ -320,7 +320,7 @@
log.debug("PLM> start of algorithm (" + this.getClass().getName()
+ "), flow BPD =" + flowBPD);
PageBreakingAlgorithm alg = new PageBreakingAlgorithm(getTopLevelLM(),
- getPageProvider(), getLayoutListener(),
+ getPageProvider(), createLayoutListener(),
alignment, alignmentLast, footnoteSeparatorLength,
isPartOverflowRecoveryActivated(), autoHeight, isSinglePartFavored());
int iOptPageCount;
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java?rev=647742&r1=647741&r2=647742&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java Mon Apr 14 04:53:29 2008
@@ -35,7 +35,6 @@
import org.apache.fop.area.Trait;
import org.apache.fop.datatypes.FODimension;
import org.apache.fop.datatypes.Length;
-import org.apache.fop.fo.FONode;
import org.apache.fop.fo.flow.BlockContainer;
import org.apache.fop.fo.properties.CommonAbsolutePosition;
import org.apache.fop.traits.MinOptMax;
@@ -239,11 +238,11 @@
int availableIPD = referenceIPD - getIPIndents();
if (getContentAreaIPD() > availableIPD) {
- log.warn(FONode.decorateWithContextInfo(
- "The extent in inline-progression-direction (width) of a block-container is"
- + " bigger than the available space ("
- + getContentAreaIPD() + "mpt > " + context.getRefIPD() + "mpt)",
- getBlockContainerFO()));
+ BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Provider.get(
+ getBlockContainerFO().getUserAgent().getEventBroadcaster());
+ eventProducer.objectTooWide(this, getBlockContainerFO().getName(),
+ getContentAreaIPD(), context.getRefIPD(),
+ getBlockContainerFO().getLocator());
}
MinOptMax stackLimit = new MinOptMax(relDims.bpd);
@@ -378,10 +377,12 @@
*/
if (contentOverflows) {
- log.warn("Contents overflow block-container viewport: clipping");
- if (getBlockContainerFO().getOverflow() == EN_ERROR_IF_OVERFLOW) {
- //TODO Throw layout exception
- }
+ BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Provider.get(
+ getBlockContainerFO().getUserAgent().getEventBroadcaster());
+ boolean canRecover = (getBlockContainerFO().getOverflow() != EN_ERROR_IF_OVERFLOW);
+ eventProducer.viewportOverflow(this, getBlockContainerFO().getName(),
+ breaker.getOverflowAmount(), needClip(), canRecover,
+ getBlockContainerFO().getLocator());
}
}
addKnuthElementsForBorderPaddingAfter(returnList, true);
@@ -526,10 +527,12 @@
//TODO Maybe check for page overflow when autoHeight=true
if (!autoHeight & (contentOverflows)) {
- log.warn("Contents overflow block-container viewport: clipping");
- if (getBlockContainerFO().getOverflow() == EN_ERROR_IF_OVERFLOW) {
- //TODO Throw layout exception
- }
+ BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Provider.get(
+ getBlockContainerFO().getUserAgent().getEventBroadcaster());
+ boolean canRecover = (getBlockContainerFO().getOverflow() != EN_ERROR_IF_OVERFLOW);
+ eventProducer.viewportOverflow(this, getBlockContainerFO().getName(),
+ breaker.getOverflowAmount(), needClip(), canRecover,
+ getBlockContainerFO().getLocator());
}
}
@@ -602,7 +605,18 @@
}
public boolean isOverflow() {
- return !isEmpty() && (deferredAlg.getPageBreaks().size() > 1);
+ if (isEmpty()) {
+ return false;
+ } else {
+ return (deferredAlg.getPageBreaks().size() > 1)
+ || (deferredAlg.totalWidth - deferredAlg.totalShrink)
+ > deferredAlg.getLineWidth();
+ }
+ }
+
+ public int getOverflowAmount() {
+ return (deferredAlg.totalWidth - deferredAlg.totalShrink)
+ - deferredAlg.getLineWidth();
}
protected LayoutManager getTopLevelLM() {
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java?rev=647742&r1=647741&r2=647742&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java Mon Apr 14 04:53:29 2008
@@ -201,6 +201,10 @@
if (ipd < 0) {
//5.3.4, XSL 1.0, Overconstrained Geometry
log.debug("Adjusting end-indent based on overconstrained geometry rules for " + fobj);
+ BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Provider.get(
+ getFObj().getUserAgent().getEventBroadcaster());
+ eventProducer.overconstrainedAdjustEndIndent(this,
+ getFObj().getName(), ipd, getFObj().getLocator());
endIndent += ipd;
ipd = 0;
//TODO Should we skip layout for a block that has ipd=0?
@@ -212,7 +216,7 @@
/**
* Sets the content area IPD by directly supplying the value.
* end-indent is adjusted based on overconstrained geometry rules, if necessary.
- *
+ * @param contentIPD the IPD of the content
* @return the resulting content area IPD
*/
protected int updateContentAreaIPDwithOverconstrainedAdjust(int contentIPD) {
@@ -220,6 +224,10 @@
if (ipd < 0) {
//5.3.4, XSL 1.0, Overconstrained Geometry
log.debug("Adjusting end-indent based on overconstrained geometry rules for " + fobj);
+ BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Provider.get(
+ getFObj().getUserAgent().getEventBroadcaster());
+ eventProducer.overconstrainedAdjustEndIndent(this,
+ getFObj().getName(), ipd, getFObj().getLocator());
endIndent += ipd;
}
setContentAreaIPD(contentIPD);
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/ExternalDocumentLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/ExternalDocumentLayoutManager.java?rev=647742&r1=647741&r2=647742&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/ExternalDocumentLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/ExternalDocumentLayoutManager.java Mon Apr 14 04:53:29 2008
@@ -21,6 +21,7 @@
import java.awt.Dimension;
import java.awt.Rectangle;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
@@ -46,6 +47,7 @@
import org.apache.fop.area.inline.Viewport;
import org.apache.fop.datatypes.FODimension;
import org.apache.fop.datatypes.URISpecification;
+import org.apache.fop.events.ResourceEventProducer;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.extensions.ExternalDocument;
import org.apache.fop.layoutmgr.inline.ImageLayout;
@@ -140,15 +142,26 @@
pageIndex++;
}
} catch (URISyntaxException e) {
- log.error("Error parsing or constructing URIs based on URI: " + uri);
+ getResourceEventProducer().uriError(this, uri, e,
+ getExternalDocument().getLocator());
return;
}
}
+ } catch (FileNotFoundException fnfe) {
+ getResourceEventProducer().imageNotFound(this, uri, fnfe,
+ getExternalDocument().getLocator());
} catch (IOException ioe) {
- log.error("Image not available: " + uri, ioe);
+ getResourceEventProducer().imageIOError(this, uri, ioe,
+ getExternalDocument().getLocator());
} catch (ImageException ie) {
- log.error("Error while inspecting image: " + uri + " (" + ie.getMessage() + ")");
+ getResourceEventProducer().imageError(this, uri, ie,
+ getExternalDocument().getLocator());
}
+ }
+
+ private ResourceEventProducer getResourceEventProducer() {
+ return ResourceEventProducer.Provider.get(
+ getExternalDocument().getUserAgent().getEventBroadcaster());
}
private void makePageForImage(ImageInfo info, ImageLayout layout) {
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreaker.java?rev=647742&r1=647741&r2=647742&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreaker.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreaker.java Mon Apr 14 04:53:29 2008
@@ -27,7 +27,6 @@
import org.apache.fop.area.Footnote;
import org.apache.fop.area.PageViewport;
import org.apache.fop.fo.Constants;
-import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.pagination.PageSequence;
import org.apache.fop.fo.pagination.Region;
@@ -79,27 +78,25 @@
return pslm.getPageProvider();
}
- /**
- * {@inheritDoc}
- */
- protected PageBreakingLayoutListener getLayoutListener() {
+ /** {@inheritDoc} */
+ protected PageBreakingLayoutListener createLayoutListener() {
return new PageBreakingLayoutListener() {
- public void notifyOverflow(int part, FObj obj) {
+ public void notifyOverflow(int part, int amount, FObj obj) {
Page p = pageProvider.getPage(
false, part, PageProvider.RELTO_CURRENT_ELEMENT_LIST);
RegionBody body = (RegionBody)p.getSimplePageMaster().getRegion(
Region.FO_REGION_BODY);
- String err = FONode.decorateWithContextInfo(
- "Content of the region-body on page "
- + p.getPageViewport().getPageNumberString()
- + " overflows the available area in block-progression dimension.",
- obj);
- if (body.getOverflow() == Constants.EN_ERROR_IF_OVERFLOW) {
- throw new RuntimeException(err);
- } else {
- log.warn(err);
- }
+ BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Provider.get(
+ body.getUserAgent().getEventBroadcaster());
+
+ boolean canRecover = (body.getOverflow() != Constants.EN_ERROR_IF_OVERFLOW);
+ boolean needClip = (body.getOverflow() == Constants.EN_HIDDEN
+ || body.getOverflow() == Constants.EN_ERROR_IF_OVERFLOW);
+ eventProducer.regionOverflow(this, body.getName(),
+ p.getPageViewport().getPageNumberString(),
+ amount, needClip, canRecover,
+ body.getLocator());
}
};
@@ -297,7 +294,7 @@
//Restart last page
PageBreakingAlgorithm algRestart = new PageBreakingAlgorithm(
getTopLevelLM(),
- getPageProvider(), getLayoutListener(),
+ getPageProvider(), createLayoutListener(),
alg.getAlignment(), alg.getAlignmentLast(),
footnoteSeparatorLength,
isPartOverflowRecoveryActivated(), false, false);
@@ -356,7 +353,7 @@
//Restart last page
PageBreakingAlgorithm algRestart = new BalancingColumnBreakingAlgorithm(
getTopLevelLM(),
- getPageProvider(), getLayoutListener(),
+ getPageProvider(), createLayoutListener(),
alignment, Constants.EN_START, footnoteSeparatorLength,
isPartOverflowRecoveryActivated(),
pslm.getCurrentPV().getBodyRegion().getColumnCount());
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java?rev=647742&r1=647741&r2=647742&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java Mon Apr 14 04:53:29 2008
@@ -27,7 +27,6 @@
import org.apache.commons.logging.LogFactory;
import org.apache.fop.fo.Constants;
-import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
import org.apache.fop.layoutmgr.AbstractBreaker.PageBreakPosition;
import org.apache.fop.traits.MinOptMax;
@@ -289,7 +288,7 @@
private void resetFootnotes(LinkedList elementLists) {
for (int i = 0; i < elementLists.size(); i++) {
- LinkedList removedList = (LinkedList) footnotesList.remove(footnotesList.size() - 1);
+ /*LinkedList removedList = (LinkedList)*/footnotesList.remove(footnotesList.size() - 1);
lengthList.remove(lengthList.size() - 1);
// update totalFootnotesLength
@@ -332,11 +331,13 @@
actualWidth += allFootnotes;
insertedFootnotesLength = pageNode.totalFootnotes + allFootnotes;
footnoteListIndex = footnotesList.size() - 1;
- footnoteElementIndex = ((LinkedList) footnotesList.get(footnoteListIndex)).size() - 1;
- } else if (((canDeferOldFootnotes = checkCanDeferOldFootnotes(pageNode, elementIndex))
+ footnoteElementIndex
+ = ((LinkedList) footnotesList.get(footnoteListIndex)).size() - 1;
+ } else if (((canDeferOldFootnotes
+ = checkCanDeferOldFootnotes(pageNode, elementIndex))
|| newFootnotes)
- && (footnoteSplit = getFootnoteSplit(pageNode, getLineWidth() - actualWidth,
- canDeferOldFootnotes)) > 0) {
+ && (footnoteSplit = getFootnoteSplit(pageNode,
+ getLineWidth() - actualWidth, canDeferOldFootnotes)) > 0) {
// it is allowed to break or even defer footnotes if either:
// - there are new footnotes in the last piece of content, and
// there is space to add at least a piece of the first one
@@ -356,7 +357,8 @@
actualWidth += allFootnotes;
insertedFootnotesLength = pageNode.totalFootnotes + allFootnotes;
footnoteListIndex = footnotesList.size() - 1;
- footnoteElementIndex = ((LinkedList) footnotesList.get(footnoteListIndex)).size() - 1;
+ footnoteElementIndex
+ = ((LinkedList) footnotesList.get(footnoteListIndex)).size() - 1;
}
} else {
// all footnotes have already been placed on previous pages
@@ -381,7 +383,8 @@
*/
private boolean checkCanDeferOldFootnotes(KnuthPageNode node, int contentElementIndex) {
return (noBreakBetween(node.position, contentElementIndex)
- && deferredFootnotes(node.footnoteListIndex, node.footnoteElementIndex, node.totalFootnotes));
+ && deferredFootnotes(node.footnoteListIndex,
+ node.footnoteElementIndex, node.totalFootnotes));
}
/**
@@ -455,7 +458,8 @@
* @param availableLength available space for footnotes
* @param canDeferOldFootnotes
*/
- private int getFootnoteSplit(KnuthPageNode activeNode, int availableLength, boolean canDeferOldFootnotes) {
+ private int getFootnoteSplit(KnuthPageNode activeNode, int availableLength,
+ boolean canDeferOldFootnotes) {
return getFootnoteSplit(activeNode.footnoteListIndex,
activeNode.footnoteElementIndex,
activeNode.totalFootnotes,
@@ -520,7 +524,8 @@
}
// try adding a split of the next note
- noteListIterator = ((LinkedList) footnotesList.get(listIndex)).listIterator(elementIndex);
+ noteListIterator = ((LinkedList) footnotesList.get(listIndex))
+ .listIterator(elementIndex);
int prevSplitLength = 0;
int prevIndex = -1;
@@ -754,14 +759,6 @@
}
}
- private int getPartCount() {
- if (pageBreaks == null) {
- return 0;
- } else {
- return pageBreaks.size();
- }
- }
-
public void updateData1(int total, double demerits) {
}
@@ -774,12 +771,7 @@
if (difference + bestActiveNode.availableShrink < 0) {
if (!autoHeight) {
if (layoutListener != null) {
- layoutListener.notifyOverflow(bestActiveNode.line - 1, getFObj());
- } else if (log.isWarnEnabled()) {
- log.warn(FONode.decorateWithContextInfo(
- "Part/page " + (bestActiveNode.line - 1)
- + " overflows the available area in block-progression dimension.",
- getFObj()));
+ layoutListener.notifyOverflow(bestActiveNode.line - 1, -difference, getFObj());
}
}
}
@@ -890,9 +882,10 @@
/**
* Issued when an overflow is detected
* @param part the number of the part (page) this happens on
+ * @param amount the amount by which the area overflows (in mpt)
* @param obj the root FO object where this happens
*/
- void notifyOverflow(int part, FObj obj);
+ void notifyOverflow(int part, int amount, FObj obj);
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageProvider.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageProvider.java?rev=647742&r1=647741&r2=647742&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageProvider.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageProvider.java Mon Apr 14 04:53:29 2008
@@ -23,6 +23,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.area.AreaTreeHandler;
import org.apache.fop.fo.Constants;
@@ -74,6 +75,7 @@
/**
* Main constructor.
+ * @param ath the area tree handler
* @param ps The page-sequence the provider operates on
*/
public PageProvider(AreaTreeHandler ath, PageSequence ps) {
@@ -258,10 +260,10 @@
if (!pageSeq.getMainFlow().getFlowName().equals(body.getRegionName())) {
// this is fine by the XSL Rec (fo:flow's flow-name can be mapped to
// any region), but we don't support it yet.
- throw new FOPException("Flow '" + pageSeq.getMainFlow().getFlowName()
- + "' does not map to the region-body in page-master '"
- + spm.getMasterName() + "'. FOP presently "
- + "does not support this.");
+ BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Provider.get(
+ pageSeq.getUserAgent().getEventBroadcaster());
+ eventProducer.flowNotMappingToRegionBody(this,
+ pageSeq.getMainFlow().getFlowName(), spm.getMasterName(), spm.getLocator());
}
Page page = new Page(spm, index, pageNumberString, isBlank);
//Set unique key obtained from the AreaTreeHandler
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java?rev=647742&r1=647741&r2=647742&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java Mon Apr 14 04:53:29 2008
@@ -29,10 +29,12 @@
import org.apache.fop.area.Area;
import org.apache.fop.area.Block;
import org.apache.fop.area.RegionReference;
-import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.Constants;
+import org.apache.fop.fo.FObj;
import org.apache.fop.fo.pagination.PageSequence;
import org.apache.fop.fo.pagination.SideRegion;
import org.apache.fop.fo.pagination.StaticContent;
+import org.apache.fop.layoutmgr.PageBreakingAlgorithm.PageBreakingLayoutListener;
import org.apache.fop.layoutmgr.inline.InlineLevelLayoutManager;
import org.apache.fop.layoutmgr.inline.TextLayoutManager;
import org.apache.fop.traits.MinOptMax;
@@ -240,12 +242,17 @@
breaker.doLayout(targetBPD, autoHeight);
if (breaker.isOverflow()) {
if (!autoHeight) {
- //Overflow handling
- if (regionFO.getOverflow() == EN_ERROR_IF_OVERFLOW) {
- //TODO throw layout exception
- }
- log.warn(FONode.decorateWithContextInfo(
- "static-content overflows the available area.", fobj));
+ String page = getPSLM().getCurrentPage().getPageViewport().getPageNumberString();
+
+ BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Provider.get(
+ getStaticContentFO().getUserAgent().getEventBroadcaster());
+ boolean canRecover = (regionFO.getOverflow() != EN_ERROR_IF_OVERFLOW);
+ boolean needClip = (regionFO.getOverflow() == Constants.EN_HIDDEN
+ || regionFO.getOverflow() == Constants.EN_ERROR_IF_OVERFLOW);
+ eventProducer.regionOverflow(this, regionFO.getName(),
+ page,
+ breaker.getOverflowAmount(), needClip, canRecover,
+ getStaticContentFO().getLocator());
}
}
}
@@ -262,7 +269,7 @@
private StaticContentLayoutManager lm;
private int displayAlign;
private int ipd;
- private boolean overflow = false;
+ private int overflow = 0;
public StaticContentBreaker(StaticContentLayoutManager lm, int ipd,
int displayAlign) {
@@ -288,9 +295,26 @@
}
public boolean isOverflow() {
+ return (this.overflow != 0);
+ }
+
+ public int getOverflowAmount() {
return this.overflow;
}
+ /** {@inheritDoc} */
+ protected PageBreakingLayoutListener createLayoutListener() {
+ return new PageBreakingLayoutListener() {
+
+ public void notifyOverflow(int part, int amount, FObj obj) {
+ if (StaticContentBreaker.this.overflow == 0) {
+ StaticContentBreaker.this.overflow = amount;
+ }
+ }
+
+ };
+ }
+
protected LayoutManager getTopLevelLM() {
return lm;
}
@@ -340,9 +364,6 @@
protected void doPhase3(PageBreakingAlgorithm alg, int partCount,
BlockSequence originalList, BlockSequence effectiveList) {
- if (partCount > 1) {
- overflow = true;
- }
//Rendering all parts (not just the first) at once for the case where the parts that
//overflow should be visible.
alg.removeAllPageBreaks();
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java?rev=647742&r1=647741&r2=647742&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java Mon Apr 14 04:53:29 2008
@@ -60,7 +60,6 @@
*/
private static Log log = LogFactory.getLog(ContentLayoutManager.class);
- private FOUserAgent userAgent;
private Area holder;
private int stackSize;
private LayoutManager parentLM;
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java?rev=647742&r1=647741&r2=647742&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java Mon Apr 14 04:53:29 2008
@@ -19,11 +19,15 @@
package org.apache.fop.layoutmgr.inline;
+import java.util.LinkedList;
+import java.util.List;
+
import org.apache.fop.area.Trait;
import org.apache.fop.area.inline.FilledArea;
import org.apache.fop.area.inline.InlineArea;
import org.apache.fop.area.inline.Space;
import org.apache.fop.area.inline.TextArea;
+import org.apache.fop.fo.FObj;
import org.apache.fop.fo.flow.Leader;
import org.apache.fop.fonts.Font;
import org.apache.fop.fonts.FontInfo;
@@ -41,10 +45,6 @@
import org.apache.fop.layoutmgr.TraitSetter;
import org.apache.fop.traits.MinOptMax;
-import java.util.List;
-import java.util.LinkedList;
-import org.apache.fop.fo.FObj;
-
/**
* LayoutManager for the fo:leader formatting object
*/
@@ -159,7 +159,9 @@
leaderArea = fa;
} else if (fobj.getLeaderPattern() == EN_USECONTENT) {
if (fobj.getChildNodes() == null) {
- fobj.getLogger().error("Leader use-content with no content");
+ InlineLevelEventProducer eventProducer = InlineLevelEventProducer.Provider.get(
+ getFObj().getUserAgent().getEventBroadcaster());
+ eventProducer.leaderWithoutContent(this, getFObj().getLocator());
return null;
}
@@ -339,9 +341,7 @@
return returnList;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public int getBaseLength(int lengthBase, FObj fobj) {
return getParent().getBaseLength(lengthBase, getParent().getFObj());
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java?rev=647742&r1=647741&r2=647742&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java Mon Apr 14 04:53:29 2008
@@ -34,7 +34,6 @@
import org.apache.fop.datatypes.Length;
import org.apache.fop.datatypes.Numeric;
import org.apache.fop.fo.Constants;
-import org.apache.fop.fo.FONode;
import org.apache.fop.fo.flow.Block;
import org.apache.fop.fo.properties.CommonHyphenation;
import org.apache.fop.fonts.Font;
@@ -384,11 +383,12 @@
if (log.isWarnEnabled()) {
int lack = difference + bestActiveNode.availableShrink;
if (lack < 0) {
+ InlineLevelEventProducer eventProducer
+ = InlineLevelEventProducer.Provider.get(
+ getFObj().getUserAgent().getEventBroadcaster());
+ eventProducer.lineOverflows(this, addedPositions + 1,
+ -lack, getFObj().getLocator());
String textDiff = (lack < -50000 ? "more than 50 points" : (-lack) + "mpt");
- log.warn(FONode.decorateWithContextInfo(
- "Line " + (addedPositions + 1)
- + " of a paragraph overflows the available area by "
- + textDiff + ".", getFObj()));
}
}
@@ -1430,7 +1430,9 @@
auxCount++;
}
}
- log.trace(" Word to hyphenate: " + sbChars.toString());
+ if (log.isTraceEnabled()) {
+ log.trace(" Word to hyphenate: " + sbChars.toString());
+ }
// find hyphenation points
HyphContext hc = getHyphenContext(sbChars);
// ask each LM to hyphenate its word fragment
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java?rev=647742&r1=647741&r2=647742&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java Mon Apr 14 04:53:29 2008
@@ -25,9 +25,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.fop.datatypes.PercentBaseContext;
-import org.apache.fop.datatypes.Length;
+import org.apache.fop.datatypes.Length;
+import org.apache.fop.datatypes.PercentBaseContext;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.flow.table.Table;
import org.apache.fop.fo.flow.table.TableColumn;
@@ -77,12 +77,14 @@
}
}
//Post-processing the list (looking for gaps)
+ //TODO The following block could possibly be removed
int pos = 1;
ListIterator ppIter = columns.listIterator();
while (ppIter.hasNext()) {
TableColumn col = (TableColumn)ppIter.next();
if (col == null) {
- log.error("Found a gap in the table-columns at position " + pos);
+ assert false; //Gaps are filled earlier by fo.flow.table.Table.finalizeColumns()
+ //log.error("Found a gap in the table-columns at position " + pos);
}
pos++;
}
@@ -100,7 +102,9 @@
if (index > size) {
if (index > maxColIndexReferenced) {
maxColIndexReferenced = index;
- if (!(size == 1 && getColumn(1).isImplicitColumn())) {
+ TableColumn col = getColumn(1);
+ if (!(size == 1 && col.isImplicitColumn())) {
+ assert false; //TODO Seems to be removable as this is now done in the FO tree
log.warn(FONode.decorateWithContextInfo(
"There are fewer table-columns than are needed. "
+ "Column " + index + " was accessed, but only "
@@ -193,8 +197,7 @@
if (colWidth != null) {
sumCols += colWidth.getValue(tlm);
if (colWidth instanceof TableColLength) {
- factors +=
- ((TableColLength) colWidth).getTableUnits();
+ factors += ((TableColLength) colWidth).getTableUnits();
}
}
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java?rev=647742&r1=647741&r2=647742&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java Mon Apr 14 04:53:29 2008
@@ -24,6 +24,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.flow.table.EffRow;
import org.apache.fop.fo.flow.table.GridUnit;
@@ -32,6 +33,7 @@
import org.apache.fop.fo.flow.table.TableRow;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
import org.apache.fop.fo.properties.LengthRangeProperty;
+import org.apache.fop.layoutmgr.BlockLevelEventProducer;
import org.apache.fop.layoutmgr.ElementListObserver;
import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.MinOptMaxUtil;
@@ -193,7 +195,9 @@
row.setHeight(rowHeights[rgi]);
row.setExplicitHeight(explicitRowHeight);
// TODO re-enable and improve after clarification
+ //See http://markmail.org/message/h25ycwwu7qglr4k4
// if (maxCellBPD > row.getExplicitHeight().max) {
+//old:
// log.warn(FONode.decorateWithContextInfo(
// "The contents of row " + (row.getIndex() + 1)
// + " are taller than they should be (there is a"
@@ -203,10 +207,12 @@
// + " to " + maxCellBPD + " millipoints, but the row shouldn't get"
// + " any taller than " + row.getExplicitHeight() + " millipoints.",
// row.getTableRow()));
+//new (with events):
+// BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Factory.create(
+// tableRow.getUserAgent().getEventBroadcaster());
+// eventProducer.rowTooTall(this, row.getIndex() + 1,
+// maxCellBPD, row.getExplicitHeight().max, tableRow.getLocator());
// }
- if (log.isDebugEnabled()) {
- log.debug(" height=" + rowHeights[rgi] + " explicit=" + explicitRowHeight);
- }
}
}
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java?rev=647742&r1=647741&r2=647742&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java Mon Apr 14 04:53:29 2008
@@ -26,6 +26,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.apache.fop.area.Area;
import org.apache.fop.area.Block;
import org.apache.fop.datatypes.LengthBase;
@@ -34,6 +35,7 @@
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.flow.table.Table;
import org.apache.fop.fo.flow.table.TableColumn;
+import org.apache.fop.layoutmgr.BlockLevelEventProducer;
import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
import org.apache.fop.layoutmgr.BreakElement;
import org.apache.fop.layoutmgr.ConditionalElementListener;
@@ -189,9 +191,9 @@
updateContentAreaIPDwithOverconstrainedAdjust(contentIPD);
} else {
if (!getTable().isAutoLayout()) {
- log.info("table-layout=\"fixed\" and width=\"auto\", "
- + "but auto-layout not supported "
- + "=> assuming width=\"100%\"");
+ BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Provider.get(
+ getTable().getUserAgent().getEventBroadcaster());
+ eventProducer.tableFixedAutoWidthNotSupported(this, getTable().getLocator());
}
updateContentAreaIPDwithOverconstrainedAdjust();
}
@@ -204,11 +206,11 @@
}
int availableIPD = referenceIPD - getIPIndents();
if (getContentAreaIPD() > availableIPD) {
- log.warn(FONode.decorateWithContextInfo(
- "The extent in inline-progression-direction (width) of a table is"
- + " bigger than the available space ("
- + getContentAreaIPD() + "mpt > " + context.getRefIPD() + "mpt)",
- getTable()));
+ BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Provider.get(
+ getTable().getUserAgent().getEventBroadcaster());
+ eventProducer.objectTooWide(this, getTable().getName(),
+ getContentAreaIPD(), context.getRefIPD(),
+ getTable().getLocator());
}
/* initialize unit to determine computed values
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java?rev=647742&r1=647741&r2=647742&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java Mon Apr 14 04:53:29 2008
@@ -30,12 +30,14 @@
import org.apache.batik.bridge.BridgeContext;
import org.apache.batik.bridge.GVTBuilder;
+import org.apache.batik.dom.AbstractDocument;
import org.apache.batik.dom.svg.SVGDOMImplementation;
import org.apache.batik.gvt.GraphicsNode;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+
+import org.apache.xmlgraphics.java2d.Graphics2DImagePainter;
import org.apache.fop.render.RendererContext.RendererContextWrapper;
+import org.apache.fop.svg.SVGEventProducer;
import org.apache.fop.svg.SVGUserAgent;
/**
@@ -46,9 +48,6 @@
*/
public abstract class AbstractGenericSVGHandler implements XMLHandler, RendererContextConstants {
- /** logging instance */
- private static Log log = LogFactory.getLog(AbstractGenericSVGHandler.class);
-
/** {@inheritDoc} */
public void handleXML(RendererContext context,
Document doc, String ns) throws Exception {
@@ -73,7 +72,7 @@
//Prepare
SVGUserAgent ua = new SVGUserAgent(
- context.getUserAgent().getSourcePixelUnitToMillimeter(),
+ context.getUserAgent(),
new AffineTransform());
GVTBuilder builder = new GVTBuilder();
final BridgeContext ctx = new BridgeContext(ua);
@@ -83,7 +82,9 @@
try {
root = builder.build(ctx, doc);
} catch (Exception e) {
- log.error("SVG graphic could not be built: " + e.getMessage(), e);
+ SVGEventProducer eventProducer = SVGEventProducer.Provider.get(
+ context.getUserAgent().getEventBroadcaster());
+ eventProducer.svgNotBuilt(this, e, getDocumentURI(doc));
return;
}
@@ -114,6 +115,20 @@
x, y, wrappedContext.getWidth(), wrappedContext.getHeight());
}
+ /**
+ * Gets the document URI from a Document instance if possible.
+ * @param doc the Document
+ * @return the URI or null
+ */
+ protected String getDocumentURI(Document doc) {
+ String docURI = null;
+ if (doc instanceof AbstractDocument) {
+ AbstractDocument level3Doc = (AbstractDocument)doc;
+ docURI = level3Doc.getDocumentURI();
+ }
+ return docURI;
+ }
+
/**
* Override this method to update the renderer context if it needs special settings for
* certain conditions.
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java?rev=647742&r1=647741&r2=647742&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java Mon Apr 14 04:53:29 2008
@@ -31,6 +31,7 @@
import org.apache.batik.parser.AWTTransformProducer;
import org.apache.xmlgraphics.image.loader.ImageSize;
+import org.apache.xmlgraphics.util.QName;
import org.apache.fop.area.Area;
import org.apache.fop.area.Block;
@@ -45,7 +46,6 @@
import org.apache.fop.fo.extensions.ExtensionElementMapping;
import org.apache.fop.fonts.FontMetrics;
import org.apache.fop.traits.BorderProps;
-import org.apache.fop.util.QName;
/**
* Abstract base class for renderers like PDF and PostScript where many painting operations
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractRenderer.java?rev=647742&r1=647741&r2=647742&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractRenderer.java Mon Apr 14 04:53:29 2008
@@ -67,6 +67,7 @@
import org.apache.fop.area.inline.TextArea;
import org.apache.fop.area.inline.Viewport;
import org.apache.fop.area.inline.WordArea;
+import org.apache.fop.events.ResourceEventProducer;
import org.apache.fop.fo.Constants;
import org.apache.fop.fonts.FontInfo;
@@ -113,21 +114,15 @@
private Set warnedXMLHandlers;
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public abstract void setupFontInfo(FontInfo fontInfo);
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void setUserAgent(FOUserAgent agent) {
userAgent = agent;
}
- /**
- * @return the associated <code>FOUserAgent</code>
- */
+ /** {@inheritDoc} */
public FOUserAgent getUserAgent() {
return userAgent;
}
@@ -797,10 +792,11 @@
= new XMLHandlerConfigurator(userAgent);
configurator.configure(ctx, namespace);
handler.handleXML(ctx, doc, namespace);
- } catch (Throwable t) {
+ } catch (Exception e) {
// could not handle document
- log.error("Some XML content will be ignored. "
- + "Could not render XML", t);
+ ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+ ctx.getUserAgent().getEventBroadcaster());
+ eventProducer.foreignXMLProcessingError(this, doc, namespace, e);
}
} else {
if (warnedXMLHandlers == null) {
@@ -809,8 +805,9 @@
if (!warnedXMLHandlers.contains(namespace)) {
// no handler found for document
warnedXMLHandlers.add(namespace);
- log.warn("Some XML content will be ignored. "
- + "No handler defined for XML: " + namespace);
+ ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+ ctx.getUserAgent().getEventBroadcaster());
+ eventProducer.foreignXMLNoHandler(this, doc, namespace);
}
}
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/Renderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/Renderer.java?rev=647742&r1=647741&r2=647742&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/Renderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/Renderer.java Mon Apr 14 04:53:29 2008
@@ -89,6 +89,12 @@
void setUserAgent(FOUserAgent agent);
/**
+ * Returns the associated user agent.
+ * @return the user agent
+ */
+ FOUserAgent getUserAgent();
+
+ /**
* Set up the given FontInfo.
*
* @param fontInfo The font information
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPRenderer.java?rev=647742&r1=647741&r2=647742&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPRenderer.java Mon Apr 14 04:53:29 2008
@@ -70,6 +70,7 @@
import org.apache.fop.area.inline.TextArea;
import org.apache.fop.area.inline.WordArea;
import org.apache.fop.datatypes.URISpecification;
+import org.apache.fop.events.ResourceEventProducer;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.extensions.ExtensionAttachment;
import org.apache.fop.fonts.FontInfo;
@@ -291,7 +292,9 @@
}
}
} else {
- log.warn("No AFP fonts configured - using default setup");
+ AFPEventProducer eventProducer = AFPEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.warnDefaultFontSetup(this);
}
if (this.fontInfo.fontLookup("sans-serif", "normal", 400) == null) {
CharacterSet cs = new FopCharacterSet("T1V10500", "Cp500", "CZH200 ",
@@ -909,7 +912,7 @@
RendererContext context;
context = super.createRendererContext(x, y, width, height, foreignAttributes);
context.setProperty(AFPRendererContextConstants.AFP_GRAYSCALE,
- new Boolean(!this.colorImages));
+ Boolean.valueOf(!this.colorImages));
return context;
}
@@ -1014,13 +1017,17 @@
}
} catch (ImageException ie) {
- log.error("Error while processing image: "
- + (info != null ? info.toString() : uri), ie);
+ ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.imageError(this, (info != null ? info.toString() : uri), ie, null);
} catch (FileNotFoundException fe) {
- log.error(fe.getMessage());
+ ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.imageNotFound(this, (info != null ? info.toString() : uri), fe, null);
} catch (IOException ioe) {
- log.error("I/O error while processing image: "
- + (info != null ? info.toString() : uri), ioe);
+ ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.imageIOError(this, (info != null ? info.toString() : uri), ioe, null);
}
/*
@@ -1195,7 +1202,9 @@
image.getWidth(), image.getHeight(), this.bitsPerPixel);
}
} catch (IOException ioe) {
- log.error("Error while serializing bitmap: " + ioe.getMessage(), ioe);
+ ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.imageWritingError(this, ioe);
}
}
@@ -1305,8 +1314,9 @@
} catch (Throwable ex) {
encoding = AFPConstants.EBCIDIC_ENCODING;
log.warn(
- "renderText():: Error getting encoding for font "
- + " - using default encoding "
+ "renderText():: Error getting encoding for font '"
+ + tf.getFullName()
+ + "' - using default encoding "
+ encoding);
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/PNGRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/PNGRenderer.java?rev=647742&r1=647741&r2=647742&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/PNGRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/PNGRenderer.java Mon Apr 14 04:53:29 2008
@@ -23,12 +23,12 @@
import java.io.IOException;
import java.io.OutputStream;
+import org.apache.commons.io.IOUtils;
+
import org.apache.xmlgraphics.image.writer.ImageWriter;
import org.apache.xmlgraphics.image.writer.ImageWriterParams;
import org.apache.xmlgraphics.image.writer.ImageWriterRegistry;
-import org.apache.commons.io.IOUtils;
-
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.area.PageViewport;
import org.apache.fop.render.java2d.Java2DRenderer;
@@ -74,8 +74,10 @@
OutputStream os = getCurrentOutputStream(i);
if (os == null) {
- log.warn("No filename information available."
- + " Stopping early after the first page.");
+ BitmapRendererEventProducer eventProducer
+ = BitmapRendererEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.stoppingAfterFirstPageNoFilename(this);
break;
}
try {
@@ -104,9 +106,10 @@
// Encode PNG image
ImageWriter writer = ImageWriterRegistry.getInstance().getWriterFor(getMimeType());
if (writer == null) {
- throw new IOException("Could not get an ImageWriter to produce "
- + getMimeType() + ". The most likely explanation for this is a class"
- + " loading problem.");
+ BitmapRendererEventProducer eventProducer
+ = BitmapRendererEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.noImageWriterFound(this, getMimeType());
}
if (log.isDebugEnabled()) {
log.debug("Writing image using " + writer.getClass().getName());
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java?rev=647742&r1=647741&r2=647742&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java Mon Apr 14 04:53:29 2008
@@ -129,7 +129,10 @@
// Creates writer
ImageWriter writer = ImageWriterRegistry.getInstance().getWriterFor(getMimeType());
if (writer == null) {
- throw new NullPointerException("No ImageWriter for " + getMimeType() + " available!");
+ BitmapRendererEventProducer eventProducer
+ = BitmapRendererEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.noImageWriterFound(this, getMimeType());
}
if (writer.supportsMultiImageWriter()) {
MultiImageWriter multiWriter = writer.createMultiImageWriter(outputStream);
@@ -145,8 +148,10 @@
} else {
writer.writeImage((RenderedImage) pageImagesItr.next(), outputStream, writerParams);
if (pageImagesItr.hasNext()) {
- log.error("Image encoder does not support multiple images. Only the first page"
- + " has been produced.");
+ BitmapRendererEventProducer eventProducer
+ = BitmapRendererEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.stoppingAfterFirstPageNoFilename(this);
}
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DRenderer.java?rev=647742&r1=647741&r2=647742&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DRenderer.java Mon Apr 14 04:53:29 2008
@@ -66,6 +66,7 @@
import org.apache.fop.area.inline.TextArea;
import org.apache.fop.area.inline.WordArea;
import org.apache.fop.datatypes.URISpecification;
+import org.apache.fop.events.ResourceEventProducer;
import org.apache.fop.fo.Constants;
import org.apache.fop.fonts.Font;
import org.apache.fop.fonts.FontInfo;
@@ -930,13 +931,17 @@
pos, foreignAttributes);
}
} catch (ImageException ie) {
- log.error("Error while processing image: "
- + (info != null ? info.toString() : uri), ie);
- } catch (FileNotFoundException fnfe) {
- log.error(fnfe.getMessage());
+ ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.imageError(this, (info != null ? info.toString() : uri), ie, null);
+ } catch (FileNotFoundException fe) {
+ ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.imageNotFound(this, (info != null ? info.toString() : uri), fe, null);
} catch (IOException ioe) {
- log.error("I/O error while processing image: "
- + (info != null ? info.toString() : uri), ioe);
+ ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.imageIOError(this, (info != null ? info.toString() : uri), ioe, null);
}
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java?rev=647742&r1=647741&r2=647742&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java Mon Apr 14 04:53:29 2008
@@ -23,26 +23,25 @@
import org.w3c.dom.Document;
-import org.apache.fop.render.Renderer;
-import org.apache.fop.render.XMLHandler;
-import org.apache.fop.render.RendererContext;
-import org.apache.fop.svg.SVGUserAgent;
-
-// Commons-Logging
+import org.apache.batik.bridge.BridgeContext;
+import org.apache.batik.bridge.GVTBuilder;
+import org.apache.batik.gvt.GraphicsNode;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.batik.bridge.GVTBuilder;
-import org.apache.batik.bridge.BridgeContext;
-import org.apache.batik.dom.svg.SVGDOMImplementation;
-import org.apache.batik.gvt.GraphicsNode;
+import org.apache.fop.render.AbstractGenericSVGHandler;
+import org.apache.fop.render.Renderer;
+import org.apache.fop.render.RendererContext;
+import org.apache.fop.svg.SVGEventProducer;
+import org.apache.fop.svg.SVGUserAgent;
/**
* Java2D XML handler for SVG (uses Apache Batik).
* This handler handles XML for foreign objects when rendering to Java2D.
* The properties from the Java2D renderer are subject to change.
*/
-public class Java2DSVGHandler implements XMLHandler, Java2DRendererContextConstants {
+public class Java2DSVGHandler extends AbstractGenericSVGHandler
+ implements Java2DRendererContextConstants {
/** logging instance */
private static Log log = LogFactory.getLog(Java2DSVGHandler.class);
@@ -54,16 +53,6 @@
//nop
}
- /** {@inheritDoc} */
- public void handleXML(RendererContext context,
- Document doc, String ns) throws Exception {
- Java2DInfo pdfi = getJava2DInfo(context);
-
- if (SVGDOMImplementation.SVG_NAMESPACE_URI.equals(ns)) {
- renderSVGDocument(context, doc, pdfi);
- }
- }
-
/**
* Get the pdf information from the render context.
*
@@ -106,23 +95,18 @@
}
}
- /**
- * Render the svg document.
- * @param context the renderer context
- * @param doc the svg document
- * @param info the pdf information of the current context
- */
+ /** {@inheritDoc} */
protected void renderSVGDocument(RendererContext context,
- Document doc,
- Java2DInfo info) {
+ Document doc) {
+ Java2DInfo info = getJava2DInfo(context);
+ if (log.isDebugEnabled()) {
+ log.debug("renderSVGDocument(" + context + ", " + doc + ", " + info + ")");
+ }
- log.debug("renderSVGDocument(" + context + ", " + doc + ", " + info + ")");
-
int x = info.currentXPosition;
int y = info.currentYPosition;
- float ptom = context.getUserAgent().getSourcePixelUnitToMillimeter();
- SVGUserAgent ua = new SVGUserAgent(ptom, new AffineTransform());
+ SVGUserAgent ua = new SVGUserAgent(context.getUserAgent(), new AffineTransform());
GVTBuilder builder = new GVTBuilder();
BridgeContext ctx = new BridgeContext(ua);
@@ -131,7 +115,9 @@
try {
root = builder.build(ctx, doc);
} catch (Exception e) {
- log.error("SVG graphic could not be built: " + e.getMessage(), e);
+ SVGEventProducer eventProducer = SVGEventProducer.Provider.get(
+ context.getUserAgent().getEventBroadcaster());
+ eventProducer.svgNotBuilt(this, e, getDocumentURI(doc));
return;
}
@@ -158,7 +144,9 @@
try {
root.paint(info.state.getGraph());
} catch (Exception e) {
- log.error("Error while painting SVG", e);
+ SVGEventProducer eventProducer = SVGEventProducer.Provider.get(
+ context.getUserAgent().getEventBroadcaster());
+ eventProducer.svgRenderingError(this, e, getDocumentURI(doc));
}
info.state.getGraph().setTransform(origTransform);
@@ -169,9 +157,4 @@
return (renderer instanceof Java2DRenderer);
}
-
- /** {@inheritDoc} */
- public String getNamespace() {
- return SVGDOMImplementation.SVG_NAMESPACE_URI;
- }
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLGenerator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLGenerator.java?rev=647742&r1=647741&r2=647742&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLGenerator.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLGenerator.java Mon Apr 14 04:53:29 2008
@@ -43,9 +43,11 @@
import java.util.Locale;
import org.apache.commons.io.output.ByteArrayOutputStream;
-import org.apache.fop.util.UnitConv;
+
import org.apache.xmlgraphics.image.GraphicsUtil;
+import org.apache.fop.util.UnitConv;
+
/**
* This class provides methods for generating PCL print files.
*/
@@ -355,16 +357,16 @@
if (usePCLShades
|| Color.black.equals(col)
|| Color.white.equals(col)) {
- writeCommand("*c" + formatDouble4(w / 100) + "h"
- + formatDouble4(h / 100) + "V");
+ writeCommand("*c" + formatDouble4(w / 100.0) + "h"
+ + formatDouble4(h / 100.0) + "V");
int lineshade = convertToPCLShade(col);
writeCommand("*c" + lineshade + "G");
writeCommand("*c2P"); //Shaded fill
} else {
defineGrayscalePattern(col, 32, DITHER_MATRIX_4X4);
- writeCommand("*c" + formatDouble4(w / 100) + "h"
- + formatDouble4(h / 100) + "V");
+ writeCommand("*c" + formatDouble4(w / 100.0) + "h"
+ + formatDouble4(h / 100.0) + "V");
writeCommand("*c32G");
writeCommand("*c4P"); //User-defined pattern
}
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org