From f466690aaeed2dc93360d5f5f14fede90f2f5ad2 Mon Sep 17 00:00:00 2001
From: Adrian Cumiskey
Date: Thu, 27 Mar 2008 16:16:30 +0000
Subject: Committing in preparation for trunk merge.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@641873 13f79535-47bb-0310-9956-ffa450edef68
---
.../org/apache/fop/render/ps/extensions/PSCommentAfterElement.java | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
(limited to 'src/java/org/apache/fop/render/ps/extensions/PSCommentAfterElement.java')
diff --git a/src/java/org/apache/fop/render/ps/extensions/PSCommentAfterElement.java b/src/java/org/apache/fop/render/ps/extensions/PSCommentAfterElement.java
index 306cd7bda..4bbfa0c73 100644
--- a/src/java/org/apache/fop/render/ps/extensions/PSCommentAfterElement.java
+++ b/src/java/org/apache/fop/render/ps/extensions/PSCommentAfterElement.java
@@ -27,8 +27,6 @@ import org.apache.fop.fo.extensions.ExtensionAttachment;
*/
public class PSCommentAfterElement extends AbstractPSCommentElement {
- protected static final String ELEMENT = "ps-comment-after";
-
/**
* Main constructor
* @param parent node
@@ -42,7 +40,7 @@ public class PSCommentAfterElement extends AbstractPSCommentElement {
* @see org.apache.fop.fo.FONode#getLocalName()
*/
public String getLocalName() {
- return ELEMENT;
+ return PSCommentAfter.ELEMENT;
}
/**
--
cgit v1.2.3
From 309f4e2998c676913e64070adda8dca5e3768fad Mon Sep 17 00:00:00 2001
From: Adrian Cumiskey
Date: Mon, 14 Apr 2008 13:05:52 +0000
Subject: Merged revisions 647692,647742,647745 via svnmerge from
https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk
................
r647692 | jeremias | 2008-04-14 09:25:22 +0100 (Mon, 14 Apr 2008) | 3 lines
Initialized merge tracking via "svnmerge" with revisions "1-615152" from
https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_ProcessingFeedback
................
r647742 | jeremias | 2008-04-14 12:53:29 +0100 (Mon, 14 Apr 2008) | 298 lines
Merged branch
https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_ProcessingFeedback
into Trunk.
Changes on branch:
........
r615153 | jeremias | 2008-01-25 10:07:21 +0100 (Fr, 25 Jan 2008) | 1 line
Created temporary branch for processing feedback.
........
r615155 | jeremias | 2008-01-25 10:11:59 +0100 (Fr, 25 Jan 2008) | 1 line
Initial commit of what I've built already for those who prefer code to minimalistic design docs.
........
r615278 | jeremias | 2008-01-25 18:25:00 +0100 (Fr, 25 Jan 2008) | 1 line
EventProducer interfaces now operational.
........
r615773 | jeremias | 2008-01-28 10:06:16 +0100 (Mo, 28 Jan 2008) | 1 line
No casting in client code when creating EventProducer instances.
........
r616242 | vhennebert | 2008-01-29 11:34:45 +0100 (Di, 29 Jan 2008) | 3 lines
Trick to avoid hard-coding the class name of EventProducer in the source file.
Feel free to revert if it's not ok.
........
r616900 | jeremias | 2008-01-30 21:59:31 +0100 (Mi, 30 Jan 2008) | 1 line
Generate event model XMLs in to the build directory: build/gensrc and build/test-gensrc (the latter is new and needs to be setup as source folder in your IDE!)
........
r616907 | jeremias | 2008-01-30 22:12:59 +0100 (Mi, 30 Jan 2008) | 1 line
Added an XMLResourceBundle that uses an XML file instead of a properties file to load the translations. The XML format is the same as for Cocoon's XMLResourceBundle.
........
r617097 | vhennebert | 2008-01-31 11:53:21 +0100 (Do, 31 Jan 2008) | 2 lines
Minor typo + slight improvement of Javadoc
........
r617176 | jeremias | 2008-01-31 19:14:19 +0100 (Do, 31 Jan 2008) | 5 lines
Renamed FopEvent to Event as suggested by Simon.
EventProducerCollectorTask.java now reads the EventSeverity from a doclet tag.
Added generation of EventProducer translations (including simple merging, no validation, yet)
EventFormatter introduced (only basic functionality, yet).
Added a simple EventListener implementation that uses EventFormatter to convert the events to human-readable, localized messages that are sent to the log via Commons Logging.
........
r617362 | jeremias | 2008-02-01 08:18:07 +0100 (Fr, 01 Feb 2008) | 1 line
Some remaining rename operations based on an earlier discussion.
........
r617413 | jeremias | 2008-02-01 10:46:26 +0100 (Fr, 01 Feb 2008) | 2 lines
Extracted formatting functionality into utility class AdvancedMessageFormat.java.
AdvancedMessageFormat.java now supports conditional sub-groups (delimited by []).
........
r618682 | jeremias | 2008-02-05 17:07:08 +0100 (Di, 05 Feb 2008) | 1 line
Add support for special object formatters (where toString() isn't good enough). ATM, it's hard-coded but could later be hooked into dynamic discovery if we have multiple such formatters. The SAX Locator is the only example for now.
........
r618686 | jeremias | 2008-02-05 17:12:56 +0100 (Di, 05 Feb 2008) | 3 lines
Hooked most of FONode into the new event mechanism. The FOUserAgent provides a DefaultEventBroadcaster instance.
If a producer method declares throwing an exception, the event is automatically marked FATAL and the dynamic proxy throws an exception right after notifying the listeners.
The exceptions are created through the EventExceptionManager. It currently contains only one exception factory for ValidationException. If we need more such factories it's better to register them dynamically. Right now, they're hard-coded.
........
r619313 | jeremias | 2008-02-07 10:14:15 +0100 (Do, 07 Feb 2008) | 1 line
Make sure no events are now just silently swallowed because after upgrading a user doesn't know about the event system.
........
r619314 | jeremias | 2008-02-07 10:14:46 +0100 (Do, 07 Feb 2008) | 1 line
Log what translation file is being written.
........
r619320 | jeremias | 2008-02-07 10:31:00 +0100 (Do, 07 Feb 2008) | 2 lines
FObj hooked into the event system.
Code reduction using a protected method on FONode to acquire a FOValidationEventProducer.
........
r619359 | jeremias | 2008-02-07 11:59:19 +0100 (Do, 07 Feb 2008) | 2 lines
Fop's QName now extends XGCommons' QName to initiate a transition.
Hooked PropertyList into the event mechanism.
........
r631252 | jeremias | 2008-02-26 16:24:33 +0100 (Di, 26 Feb 2008) | 1 line
Removed superfluous warning.
........
r631268 | jeremias | 2008-02-26 17:08:11 +0100 (Di, 26 Feb 2008) | 1 line
Deprecated two methods which are a problem for localization. Also helps finding additional spots to switch over to the event mechanism.
........
r633852 | jeremias | 2008-03-05 15:20:24 +0100 (Mi, 05 Mrz 2008) | 1 line
Add severity to formatting parameters.
........
r633855 | jeremias | 2008-03-05 15:21:57 +0100 (Mi, 05 Mrz 2008) | 4 lines
Added support for additional field styles:
{,if,,}
{,equals,,,}
........
r633856 | jeremias | 2008-03-05 15:24:04 +0100 (Mi, 05 Mrz 2008) | 2 lines
Javadocs and TODOs.
EventListeners can change the event severity.
........
r633857 | jeremias | 2008-03-05 15:27:08 +0100 (Mi, 05 Mrz 2008) | 4 lines
Javadocs.
Moved out event listener registration into a CompositeEventListener.
Event broadcaster uses the events effective severity, not the initial value (for the case where listeners override the initial value).
Set up a special EventBroadCaster in the FOUserAgent that filters events through a class (FOValidationEventListenerProxy) that adjusts the event severity for relaxed validation.
........
r633858 | jeremias | 2008-03-05 15:32:07 +0100 (Mi, 05 Mrz 2008) | 2 lines
Instead of always decentrally checking whether strict validation is enabled or not, this is now done in a special event listener. The event producer method caller simply indicates whether it can recover from the error condition and continue.
Started switching to event production in table FOs.
........
r634027 | jeremias | 2008-03-05 21:58:35 +0100 (Mi, 05 Mrz 2008) | 7 lines
Moved AdvancedMessageFormat into its own package.
AdvancedMessageFormat got the following added functionality:
- Alternative conditional regions [ bla {field}] -> [ bla {field1}| even more bla {field2}]
- Functions: functions get access to the parameters and they can produce an object that is then formatted ({#gatherContextInfo})
- "if" and "equals" format moved to top-level classes and added by dynamic registration.
EventFormatter now supports includes in the form {{includeName}} so you can include other entries from the resource bundle for better reuse.
Some more events in table code.
........
r634031 | jeremias | 2008-03-05 22:05:22 +0100 (Mi, 05 Mrz 2008) | 1 line
SVN Props
........
r634208 | jeremias | 2008-03-06 11:26:52 +0100 (Do, 06 Mrz 2008) | 2 lines
Improved context gathering.
Moved GatherContextInfoFunction to an inner class of FONode to reduce visibilities.
........
r634209 | jeremias | 2008-03-06 11:28:14 +0100 (Do, 06 Mrz 2008) | 1 line
Made FOPException localizable.
........
r634280 | jeremias | 2008-03-06 15:38:30 +0100 (Do, 06 Mrz 2008) | 2 lines
ExceptionFactory is now dynamically registered.
More table warnings and errors switch to events.
........
r634326 | jeremias | 2008-03-06 17:08:16 +0100 (Do, 06 Mrz 2008) | 1 line
Remaining table FOs switched to events.
........
r634328 | jeremias | 2008-03-06 17:09:21 +0100 (Do, 06 Mrz 2008) | 1 line
Deprecated FOP's QName. Mixing with Commons' variant only produces problems.
........
r634381 | jeremias | 2008-03-06 20:12:57 +0100 (Do, 06 Mrz 2008) | 2 lines
Made the "invalidChild" event fully localizable by adding a "lookup" field for the optional rule to be displayed.
And a few switches to the event system.
........
r634692 | jeremias | 2008-03-07 15:31:43 +0100 (Fr, 07 Mrz 2008) | 1 line
More FO tree stuff switched to events.
........
r634712 | jeremias | 2008-03-07 16:19:21 +0100 (Fr, 07 Mrz 2008) | 1 line
Avoid an NPE that says nothing (ex. could happen if the message template is wrong).
........
r634738 | jeremias | 2008-03-07 17:38:21 +0100 (Fr, 07 Mrz 2008) | 2 lines
Non-FO children were not properly run through validation by FOTreeBuilder.
Unified the way that non-FO elements are validated. Some FOs were already fixed. I now fixed the rest, so foreign elements can occur everywhere.
........
r637833 | jeremias | 2008-03-17 12:01:41 +0100 (Mo, 17 Mrz 2008) | 1 line
Exception while cloning for RetrieveMarker to be handled by user as suggested by Andreas.
........
r637835 | jeremias | 2008-03-17 12:03:31 +0100 (Mo, 17 Mrz 2008) | 1 line
Throw a RuntimeException of no other Exception class is specified for an event as a fallback if someone just sets the event severity to FATAL.
........
r637838 | jeremias | 2008-03-17 12:06:10 +0100 (Mo, 17 Mrz 2008) | 1 line
Throw a meaningful exception when the property name is wrong. Otherwise, there will be an ArrayIndexOutOfBoundsException.
........
r637859 | jeremias | 2008-03-17 13:35:26 +0100 (Mo, 17 Mrz 2008) | 1 line
Throw a meaningful exception when the property name is wrong. Otherwise, there will be an ArrayIndexOutOfBoundsException.
........
r637938 | jeremias | 2008-03-17 16:19:51 +0100 (Mo, 17 Mrz 2008) | 1 line
Switched pagination package to events.
........
r637947 | jeremias | 2008-03-17 16:45:16 +0100 (Mo, 17 Mrz 2008) | 1 line
Removed unlocalizable validation helper methods.
........
r637952 | jeremias | 2008-03-17 16:59:02 +0100 (Mo, 17 Mrz 2008) | 1 line
Events on FOTreeBuilder.
........
r638299 | jeremias | 2008-03-18 11:09:30 +0100 (Di, 18 Mrz 2008) | 2 lines
Added support for java.util.text's ChoiceFormat to AdvancedMessageFormat.
Reuse the regexes as constants.
........
r638302 | jeremias | 2008-03-18 11:17:06 +0100 (Di, 18 Mrz 2008) | 1 line
Events for inline-level layout managers.
........
r638774 | jeremias | 2008-03-19 11:17:36 +0100 (Mi, 19 Mrz 2008) | 1 line
Added DEBUG level.
........
r638777 | jeremias | 2008-03-19 11:23:40 +0100 (Mi, 19 Mrz 2008) | 3 lines
Generalized FOValidationEventListenerProxy into FOPEventListenerProxy, the main proxy for FOP's own event manipulation proxy. Done because of support for overflow="hidden" vs. overflow="error-if-overflow".
Switched block-level layout managers to events.
Some cleanup along the way.
........
r639222 | jeremias | 2008-03-20 10:27:34 +0100 (Do, 20 Mrz 2008) | 2 lines
Some initial work for event forwarding from Batik.
Missing errors/exceptions converted to events in PageSequenceMaster.
........
r639270 | jeremias | 2008-03-20 13:50:35 +0100 (Do, 20 Mrz 2008) | 1 line
Removed DEBUG event severity again. Promoted constrained geometry adjustment event to INFO level as per discussion.
........
r640395 | jeremias | 2008-03-24 13:39:13 +0100 (Mo, 24 Mrz 2008) | 3 lines
Moved the creation of the fallback LoggingEventListener to FOUserAgent so event before the startDocument() SAX event arrive in the log.
Dynamic discovery of event models. Renderers and extensions can register renderer-specific event models.
Switched the most important parts of the renderers to events (maybe not everything is converted).
........
r640397 | jeremias | 2008-03-24 13:43:04 +0100 (Mo, 24 Mrz 2008) | 1 line
Remaining fixcrlfs. Xalan likes to mix CRLF and LF on Windows.
........
r640398 | jeremias | 2008-03-24 13:43:54 +0100 (Mo, 24 Mrz 2008) | 1 line
Ignore namespace declarations for property handling.
........
r640463 | jeremias | 2008-03-24 17:59:52 +0100 (Mo, 24 Mrz 2008) | 2 lines
Event in area package.
Exposed getUserAgent() in Renderer interface (was already public in AbstractRenderer).
........
r642972 | jeremias | 2008-03-31 14:18:39 +0200 (Mo, 31 Mrz 2008) | 1 line
Code restructured a bit.
........
r642975 | jeremias | 2008-03-31 14:24:07 +0200 (Mo, 31 Mrz 2008) | 2 lines
Plugged fonts package into the event subsystem. Note: I did not follow the same pattern as for the rest as the font package is to be considered FOP-external, so I just added a manual adapter for the FontEventListener. This demonstrates how an external library can be integrated with the event system.
Missing warning for unknown formatting objects added. Warning is not issued by the ElementMappingRegistry anymore but by FOTreeBuilder which has access to more context information.
........
r642997 | jeremias | 2008-03-31 16:10:08 +0200 (Mo, 31 Mrz 2008) | 1 line
Added an example to demonstrate how to write your own event listener and how to deal with the exceptions thrown in the process.
........
r642998 | jeremias | 2008-03-31 16:13:40 +0200 (Mo, 31 Mrz 2008) | 1 line
Removed unused method. Event formatting should not be part of the Event class. Use EventFormatter.format(Event) instead.
........
r643066 | jeremias | 2008-03-31 19:18:54 +0200 (Mo, 31 Mrz 2008) | 1 line
First part of the event subsystem documentation (DRAFT).
........
r643784 | jeremias | 2008-04-02 10:05:33 +0200 (Mi, 02 Apr 2008) | 1 line
More documentation.
........
r643785 | jeremias | 2008-04-02 10:06:38 +0200 (Mi, 02 Apr 2008) | 1 line
Some nits.
........
r643787 | jeremias | 2008-04-02 10:24:41 +0200 (Mi, 02 Apr 2008) | 1 line
Completed javadocs
........
r643824 | jeremias | 2008-04-02 12:00:30 +0200 (Mi, 02 Apr 2008) | 1 line
Javadocs.
........
r645847 | vhennebert | 2008-04-08 12:54:16 +0200 (Di, 08 Apr 2008) | 2 lines
Minor typo fixes
........
r645848 | vhennebert | 2008-04-08 12:58:30 +0200 (Di, 08 Apr 2008) | 2 lines
Another small typo fix
........
r647678 | jeremias | 2008-04-14 09:20:26 +0200 (Mo, 14 Apr 2008) | 1 line
Renamed *EventProducer.Factory.create() to *EventProducer.Provider.get() to better reflect what the method does (instances may be cached and reused).
........
................
r647745 | jeremias | 2008-04-14 13:01:06 +0100 (Mon, 14 Apr 2008) | 1 line
svnmerge didn't work for me in this case. Remove svn merge info.
................
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@647787 13f79535-47bb-0310-9956-ffa450edef68
---
build.xml | 168 +++++--
.../java/embedding/events/ExampleEvents.java | 227 ++++++++++
.../java/embedding/events/missing-image.fo | 33 ++
lib/build/qdox-1.6.3.jar | Bin 0 -> 104078 bytes
lib/build/qdox.LICENSE.txt | 201 +++++++++
.../apache/fop/tools/EventConventionException.java | 28 ++
.../apache/fop/tools/EventProducerCollector.java | 183 ++++++++
.../fop/tools/EventProducerCollectorTask.java | 200 +++++++++
.../org/apache/fop/tools/merge-translation.xsl | 55 +++
.../org/apache/fop/tools/model2translation.xsl | 35 ++
src/documentation/content/xdocs/site.xml | 1 +
src/documentation/content/xdocs/trunk/events.xml | 422 ++++++++++++++++++
...p.events.EventExceptionManager$ExceptionFactory | 4 +
.../org.apache.fop.events.model.EventModelFactory | 7 +
...he.fop.util.text.AdvancedMessageFormat$Function | 1 +
...util.text.AdvancedMessageFormat$ObjectFormatter | 1 +
...fop.util.text.AdvancedMessageFormat$PartFactory | 6 +
src/java/org/apache/fop/apps/FOPException.java | 21 +
src/java/org/apache/fop/apps/FOUserAgent.java | 45 ++
.../org/apache/fop/area/AreaEventProducer.java | 91 ++++
src/java/org/apache/fop/area/AreaTreeHandler.java | 5 +-
src/java/org/apache/fop/area/AreaTreeObject.java | 10 +-
src/java/org/apache/fop/area/AreaTreeParser.java | 2 +-
.../apache/fop/area/CachedRenderPagesModel.java | 77 ++--
src/java/org/apache/fop/area/PageViewport.java | 16 +-
src/java/org/apache/fop/area/RenderPagesModel.java | 45 +-
.../apache/fop/events/CompositeEventListener.java | 69 +++
.../apache/fop/events/DefaultEventBroadcaster.java | 160 +++++++
src/java/org/apache/fop/events/Event.java | 150 +++++++
.../org/apache/fop/events/EventBroadcaster.java | 61 +++
.../apache/fop/events/EventExceptionManager.java | 84 ++++
src/java/org/apache/fop/events/EventFormatter.java | 196 +++++++++
src/java/org/apache/fop/events/EventFormatter.xml | 101 +++++
.../org/apache/fop/events/EventFormatter_de.xml | 23 +
src/java/org/apache/fop/events/EventListener.java | 37 ++
src/java/org/apache/fop/events/EventProducer.java | 31 ++
.../apache/fop/events/FOPEventListenerProxy.java | 73 +++
.../apache/fop/events/FOPEventModelFactory.java | 37 ++
.../apache/fop/events/LoggingEventListener.java | 92 ++++
.../fop/events/PropertyExceptionFactory.java | 47 ++
.../apache/fop/events/ResourceEventProducer.java | 136 ++++++
.../UnsupportedOperationExceptionFactory.java | 43 ++
.../fop/events/ValidationExceptionFactory.java | 51 +++
.../events/model/AbstractEventModelFactory.java | 61 +++
.../apache/fop/events/model/EventMethodModel.java | 198 +++++++++
.../org/apache/fop/events/model/EventModel.java | 135 ++++++
.../apache/fop/events/model/EventModelFactory.java | 33 ++
.../apache/fop/events/model/EventModelParser.java | 140 ++++++
.../fop/events/model/EventProducerModel.java | 105 +++++
.../org/apache/fop/events/model/EventSeverity.java | 82 ++++
src/java/org/apache/fop/fo/ElementMapping.java | 3 +-
.../org/apache/fop/fo/ElementMappingRegistry.java | 2 +-
src/java/org/apache/fop/fo/FOElementMapping.java | 2 +-
src/java/org/apache/fop/fo/FOEventHandler.java | 2 +
src/java/org/apache/fop/fo/FONode.java | 172 ++++++--
src/java/org/apache/fop/fo/FOText.java | 9 +-
src/java/org/apache/fop/fo/FOTreeBuilder.java | 67 +--
.../apache/fop/fo/FOValidationEventProducer.java | 348 +++++++++++++++
src/java/org/apache/fop/fo/FObj.java | 77 ++--
src/java/org/apache/fop/fo/PropertyList.java | 67 ++-
.../org/apache/fop/fo/expr/FromParentFunction.java | 8 +-
.../apache/fop/fo/expr/InheritedPropFunction.java | 5 +
.../fop/fo/expr/NearestSpecPropFunction.java | 5 +
.../fop/fo/extensions/ExtensionElementMapping.java | 9 +-
.../fop/fo/extensions/destination/Destination.java | 14 +-
.../apache/fop/fo/flow/AbstractListItemPart.java | 29 +-
.../fop/fo/flow/AbstractPageNumberCitation.java | 4 +-
src/java/org/apache/fop/fo/flow/BasicLink.java | 21 +-
src/java/org/apache/fop/fo/flow/BidiOverride.java | 32 +-
.../org/apache/fop/fo/flow/BlockContainer.java | 18 +-
src/java/org/apache/fop/fo/flow/Character.java | 7 +-
.../org/apache/fop/fo/flow/ExternalGraphic.java | 18 +-
src/java/org/apache/fop/fo/flow/Float.java | 7 +-
src/java/org/apache/fop/fo/flow/Footnote.java | 8 +-
src/java/org/apache/fop/fo/flow/FootnoteBody.java | 4 +-
.../org/apache/fop/fo/flow/InitialPropertySet.java | 4 +-
src/java/org/apache/fop/fo/flow/Inline.java | 33 +-
.../org/apache/fop/fo/flow/InlineContainer.java | 18 +-
.../apache/fop/fo/flow/InstreamForeignObject.java | 43 +-
src/java/org/apache/fop/fo/flow/ListBlock.java | 18 +-
src/java/org/apache/fop/fo/flow/ListItem.java | 32 +-
src/java/org/apache/fop/fo/flow/Marker.java | 13 +-
src/java/org/apache/fop/fo/flow/MultiCase.java | 3 +-
.../org/apache/fop/fo/flow/MultiProperties.java | 9 +-
.../org/apache/fop/fo/flow/MultiPropertySet.java | 7 +-
src/java/org/apache/fop/fo/flow/MultiSwitch.java | 11 +-
src/java/org/apache/fop/fo/flow/MultiToggle.java | 11 +-
src/java/org/apache/fop/fo/flow/PageNumber.java | 4 +-
.../org/apache/fop/fo/flow/RetrieveMarker.java | 31 +-
src/java/org/apache/fop/fo/flow/Wrapper.java | 25 +-
.../fop/fo/flow/table/FixedColRowGroupBuilder.java | 12 +-
src/java/org/apache/fop/fo/flow/table/Table.java | 39 +-
.../apache/fop/fo/flow/table/TableAndCaption.java | 47 +-
.../org/apache/fop/fo/flow/table/TableBody.java | 29 +-
.../org/apache/fop/fo/flow/table/TableCaption.java | 21 +-
.../org/apache/fop/fo/flow/table/TableCell.java | 28 +-
.../fop/fo/flow/table/TableCellContainer.java | 7 +-
.../org/apache/fop/fo/flow/table/TableColumn.java | 21 +-
.../fop/fo/flow/table/TableEventProducer.java | 159 +++++++
.../org/apache/fop/fo/flow/table/TableFObj.java | 29 +-
.../org/apache/fop/fo/flow/table/TableRow.java | 13 +-
.../fop/fo/pagination/AbstractPageSequence.java | 13 +-
.../org/apache/fop/fo/pagination/ColorProfile.java | 21 +-
.../pagination/ConditionalPageMasterReference.java | 16 +-
.../org/apache/fop/fo/pagination/Declarations.java | 21 +-
src/java/org/apache/fop/fo/pagination/Flow.java | 39 +-
.../apache/fop/fo/pagination/LayoutMasterSet.java | 63 +--
.../fop/fo/pagination/PageNumberGenerator.java | 6 +-
.../org/apache/fop/fo/pagination/PageSequence.java | 28 +-
.../fop/fo/pagination/PageSequenceMaster.java | 38 +-
.../fop/fo/pagination/PageSequenceWrapper.java | 19 +-
src/java/org/apache/fop/fo/pagination/Region.java | 29 +-
.../org/apache/fop/fo/pagination/RegionAfter.java | 14 +-
.../org/apache/fop/fo/pagination/RegionBA.java | 6 +-
.../org/apache/fop/fo/pagination/RegionBefore.java | 15 +-
.../org/apache/fop/fo/pagination/RegionBody.java | 24 +-
.../org/apache/fop/fo/pagination/RegionEnd.java | 18 +-
.../org/apache/fop/fo/pagination/RegionSE.java | 6 +-
.../org/apache/fop/fo/pagination/RegionStart.java | 15 +-
.../RepeatablePageMasterAlternatives.java | 43 +-
.../pagination/RepeatablePageMasterReference.java | 20 +-
src/java/org/apache/fop/fo/pagination/Root.java | 20 +-
.../org/apache/fop/fo/pagination/SideRegion.java | 6 +-
.../apache/fop/fo/pagination/SimplePageMaster.java | 130 +++---
.../fo/pagination/SinglePageMasterReference.java | 16 +-
.../apache/fop/fo/pagination/StaticContent.java | 18 +-
src/java/org/apache/fop/fo/pagination/Title.java | 19 +-
.../fop/fo/pagination/bookmarks/Bookmark.java | 37 +-
.../fop/fo/pagination/bookmarks/BookmarkTitle.java | 17 +-
.../fop/fo/pagination/bookmarks/BookmarkTree.java | 24 +-
.../org/apache/fop/fonts/FontEventAdapter.java | 82 ++++
.../org/apache/fop/fonts/FontEventListener.java | 52 +++
src/java/org/apache/fop/fonts/FontInfo.java | 22 +-
src/java/org/apache/fop/fonts/LazyFont.java | 1 +
src/java/org/apache/fop/fonts/SingleByteFont.java | 28 +-
src/java/org/apache/fop/fonts/Typeface.java | 12 +
.../fop/fonts/autodetect/FontInfoFinder.java | 38 +-
.../image/loader/batik/ImageConverterSVG2G2D.java | 31 +-
.../fop/image/loader/batik/PreloaderSVG.java | 14 +-
.../org/apache/fop/layoutmgr/AbstractBreaker.java | 8 +-
.../fop/layoutmgr/BlockContainerLayoutManager.java | 44 +-
.../fop/layoutmgr/BlockLevelEventProducer.java | 168 +++++++
.../fop/layoutmgr/BlockStackingLayoutManager.java | 10 +-
.../layoutmgr/ExternalDocumentLayoutManager.java | 19 +-
.../org/apache/fop/layoutmgr/LayoutException.java | 105 +++++
src/java/org/apache/fop/layoutmgr/PageBreaker.java | 33 +-
.../fop/layoutmgr/PageBreakingAlgorithm.java | 43 +-
.../org/apache/fop/layoutmgr/PageProvider.java | 10 +-
.../fop/layoutmgr/StaticContentLayoutManager.java | 43 +-
.../fop/layoutmgr/inline/ContentLayoutManager.java | 1 -
.../layoutmgr/inline/InlineLevelEventProducer.java | 66 +++
.../fop/layoutmgr/inline/LeaderLayoutManager.java | 16 +-
.../fop/layoutmgr/inline/LineLayoutManager.java | 14 +-
.../apache/fop/layoutmgr/table/ColumnSetup.java | 15 +-
.../fop/layoutmgr/table/RowGroupLayoutManager.java | 12 +-
.../fop/layoutmgr/table/TableLayoutManager.java | 18 +-
.../fop/render/AbstractGenericSVGHandler.java | 24 +-
.../fop/render/AbstractPathOrientedRenderer.java | 2 +-
.../org/apache/fop/render/AbstractRenderer.java | 25 +-
src/java/org/apache/fop/render/Renderer.java | 6 +
.../apache/fop/render/RendererEventProducer.java | 53 +++
.../apache/fop/render/afp/AFPEventProducer.java | 63 +++
.../org/apache/fop/render/afp/AFPEventProducer.xml | 4 +
.../org/apache/fop/render/afp/AFPRenderer.java | 30 +-
.../org/apache/fop/render/afp/AFPSVGHandler.java | 3 +-
.../render/bitmap/BitmapRendererEventProducer.java | 80 ++++
.../render/bitmap/BitmapRendererEventProducer.xml | 6 +
.../org/apache/fop/render/bitmap/PNGRenderer.java | 17 +-
.../org/apache/fop/render/bitmap/TIFFRenderer.java | 11 +-
.../apache/fop/render/java2d/Java2DRenderer.java | 17 +-
.../apache/fop/render/java2d/Java2DSVGHandler.java | 63 +--
.../apache/fop/render/pcl/PCLEventProducer.java | 66 +++
.../org/apache/fop/render/pcl/PCLEventProducer.xml | 4 +
.../org/apache/fop/render/pcl/PCLGenerator.java | 12 +-
.../org/apache/fop/render/pcl/PCLRenderer.java | 33 +-
.../apache/fop/render/pcl/PCLRendererContext.java | 3 +-
.../apache/fop/render/pdf/PDFEventProducer.java | 64 +++
.../org/apache/fop/render/pdf/PDFEventProducer.xml | 4 +
.../org/apache/fop/render/pdf/PDFRenderer.java | 100 +++--
.../org/apache/fop/render/pdf/PDFSVGHandler.java | 29 +-
.../org/apache/fop/render/ps/PSEventProducer.java | 65 +++
.../org/apache/fop/render/ps/PSEventProducer.xml | 4 +
src/java/org/apache/fop/render/ps/PSRenderer.java | 29 +-
.../org/apache/fop/render/ps/PSSVGHandler.java | 68 +--
.../org/apache/fop/render/ps/ResourceHandler.java | 8 +-
.../ps/extensions/AbstractPSCommentElement.java | 5 +-
.../ps/extensions/AbstractPSExtensionElement.java | 6 +-
.../ps/extensions/AbstractPSExtensionObject.java | 13 +-
.../ps/extensions/PSCommentAfterElement.java | 3 +
.../ps/extensions/PSCommentBeforeElement.java | 3 +
.../render/ps/extensions/PSExtensionHandler.java | 20 +-
.../ps/extensions/PSPageSetupCodeElement.java | 5 +-
.../ps/extensions/PSSetPageDeviceElement.java | 11 +-
.../render/ps/extensions/PSSetupCodeElement.java | 5 +-
.../apache/fop/render/rtf/RTFEventProducer.java | 94 ++++
.../org/apache/fop/render/rtf/RTFEventProducer.xml | 8 +
src/java/org/apache/fop/render/rtf/RTFHandler.java | 153 ++++---
.../org/apache/fop/render/xml/XMLRenderer.java | 2 +-
src/java/org/apache/fop/svg/SVGEventProducer.java | 89 ++++
src/java/org/apache/fop/svg/SVGUserAgent.java | 131 ++----
.../org/apache/fop/svg/SimpleSVGUserAgent.java | 126 ++++++
src/java/org/apache/fop/util/QName.java | 94 +---
.../org/apache/fop/util/XMLResourceBundle.java | 398 +++++++++++++++++
.../fop/util/text/AdvancedMessageFormat.java | 487 +++++++++++++++++++++
.../org/apache/fop/util/text/ChoiceFieldPart.java | 91 ++++
.../org/apache/fop/util/text/EqualsFieldPart.java | 92 ++++
.../apache/fop/util/text/GlyphNameFieldPart.java | 89 ++++
.../org/apache/fop/util/text/HexFieldPart.java | 84 ++++
src/java/org/apache/fop/util/text/IfFieldPart.java | 116 +++++
.../org/apache/fop/util/text/LocatorFormatter.java | 42 ++
.../org.apache.fop.events.model.EventModelFactory | 1 +
test/java/org/apache/fop/UtilityCodeTestSuite.java | 4 +
.../org/apache/fop/events/BasicEventTestCase.java | 95 ++++
.../fop/events/FOPTestEventModelFactory.java | 37 ++
.../org/apache/fop/events/TestEventProducer.java | 48 ++
.../fop/util/AdvancedMessageFormatTestCase.java | 183 ++++++++
.../apache/fop/util/XMLResourceBundleTestCase.java | 60 +++
.../apache/fop/util/XMLResourceBundleTestCase.xml | 5 +
.../fop/util/XMLResourceBundleTestCase_de.xml | 4 +
.../apache/fop/util/invalid-translation-file.xml | 5 +
220 files changed, 9158 insertions(+), 1624 deletions(-)
create mode 100644 examples/embedding/java/embedding/events/ExampleEvents.java
create mode 100644 examples/embedding/java/embedding/events/missing-image.fo
create mode 100644 lib/build/qdox-1.6.3.jar
create mode 100644 lib/build/qdox.LICENSE.txt
create mode 100644 src/codegen/java/org/apache/fop/tools/EventConventionException.java
create mode 100644 src/codegen/java/org/apache/fop/tools/EventProducerCollector.java
create mode 100644 src/codegen/java/org/apache/fop/tools/EventProducerCollectorTask.java
create mode 100644 src/codegen/java/org/apache/fop/tools/merge-translation.xsl
create mode 100644 src/codegen/java/org/apache/fop/tools/model2translation.xsl
create mode 100644 src/documentation/content/xdocs/trunk/events.xml
create mode 100644 src/java/META-INF/services/org.apache.fop.events.EventExceptionManager$ExceptionFactory
create mode 100644 src/java/META-INF/services/org.apache.fop.events.model.EventModelFactory
create mode 100644 src/java/META-INF/services/org.apache.fop.util.text.AdvancedMessageFormat$Function
create mode 100644 src/java/META-INF/services/org.apache.fop.util.text.AdvancedMessageFormat$ObjectFormatter
create mode 100644 src/java/META-INF/services/org.apache.fop.util.text.AdvancedMessageFormat$PartFactory
create mode 100644 src/java/org/apache/fop/area/AreaEventProducer.java
create mode 100644 src/java/org/apache/fop/events/CompositeEventListener.java
create mode 100644 src/java/org/apache/fop/events/DefaultEventBroadcaster.java
create mode 100644 src/java/org/apache/fop/events/Event.java
create mode 100644 src/java/org/apache/fop/events/EventBroadcaster.java
create mode 100644 src/java/org/apache/fop/events/EventExceptionManager.java
create mode 100644 src/java/org/apache/fop/events/EventFormatter.java
create mode 100644 src/java/org/apache/fop/events/EventFormatter.xml
create mode 100644 src/java/org/apache/fop/events/EventFormatter_de.xml
create mode 100644 src/java/org/apache/fop/events/EventListener.java
create mode 100644 src/java/org/apache/fop/events/EventProducer.java
create mode 100644 src/java/org/apache/fop/events/FOPEventListenerProxy.java
create mode 100644 src/java/org/apache/fop/events/FOPEventModelFactory.java
create mode 100644 src/java/org/apache/fop/events/LoggingEventListener.java
create mode 100644 src/java/org/apache/fop/events/PropertyExceptionFactory.java
create mode 100644 src/java/org/apache/fop/events/ResourceEventProducer.java
create mode 100644 src/java/org/apache/fop/events/UnsupportedOperationExceptionFactory.java
create mode 100644 src/java/org/apache/fop/events/ValidationExceptionFactory.java
create mode 100644 src/java/org/apache/fop/events/model/AbstractEventModelFactory.java
create mode 100644 src/java/org/apache/fop/events/model/EventMethodModel.java
create mode 100644 src/java/org/apache/fop/events/model/EventModel.java
create mode 100644 src/java/org/apache/fop/events/model/EventModelFactory.java
create mode 100644 src/java/org/apache/fop/events/model/EventModelParser.java
create mode 100644 src/java/org/apache/fop/events/model/EventProducerModel.java
create mode 100644 src/java/org/apache/fop/events/model/EventSeverity.java
create mode 100644 src/java/org/apache/fop/fo/FOValidationEventProducer.java
create mode 100644 src/java/org/apache/fop/fo/flow/table/TableEventProducer.java
create mode 100644 src/java/org/apache/fop/fonts/FontEventAdapter.java
create mode 100644 src/java/org/apache/fop/fonts/FontEventListener.java
create mode 100644 src/java/org/apache/fop/layoutmgr/BlockLevelEventProducer.java
create mode 100644 src/java/org/apache/fop/layoutmgr/LayoutException.java
create mode 100644 src/java/org/apache/fop/layoutmgr/inline/InlineLevelEventProducer.java
create mode 100644 src/java/org/apache/fop/render/RendererEventProducer.java
create mode 100644 src/java/org/apache/fop/render/afp/AFPEventProducer.java
create mode 100644 src/java/org/apache/fop/render/afp/AFPEventProducer.xml
create mode 100644 src/java/org/apache/fop/render/bitmap/BitmapRendererEventProducer.java
create mode 100644 src/java/org/apache/fop/render/bitmap/BitmapRendererEventProducer.xml
create mode 100644 src/java/org/apache/fop/render/pcl/PCLEventProducer.java
create mode 100644 src/java/org/apache/fop/render/pcl/PCLEventProducer.xml
create mode 100644 src/java/org/apache/fop/render/pdf/PDFEventProducer.java
create mode 100644 src/java/org/apache/fop/render/pdf/PDFEventProducer.xml
create mode 100644 src/java/org/apache/fop/render/ps/PSEventProducer.java
create mode 100644 src/java/org/apache/fop/render/ps/PSEventProducer.xml
create mode 100644 src/java/org/apache/fop/render/rtf/RTFEventProducer.java
create mode 100644 src/java/org/apache/fop/render/rtf/RTFEventProducer.xml
create mode 100644 src/java/org/apache/fop/svg/SVGEventProducer.java
create mode 100644 src/java/org/apache/fop/svg/SimpleSVGUserAgent.java
create mode 100644 src/java/org/apache/fop/util/XMLResourceBundle.java
create mode 100644 src/java/org/apache/fop/util/text/AdvancedMessageFormat.java
create mode 100644 src/java/org/apache/fop/util/text/ChoiceFieldPart.java
create mode 100644 src/java/org/apache/fop/util/text/EqualsFieldPart.java
create mode 100644 src/java/org/apache/fop/util/text/GlyphNameFieldPart.java
create mode 100644 src/java/org/apache/fop/util/text/HexFieldPart.java
create mode 100644 src/java/org/apache/fop/util/text/IfFieldPart.java
create mode 100644 src/java/org/apache/fop/util/text/LocatorFormatter.java
create mode 100644 test/java/META-INF/services/org.apache.fop.events.model.EventModelFactory
create mode 100644 test/java/org/apache/fop/events/BasicEventTestCase.java
create mode 100644 test/java/org/apache/fop/events/FOPTestEventModelFactory.java
create mode 100644 test/java/org/apache/fop/events/TestEventProducer.java
create mode 100644 test/java/org/apache/fop/util/AdvancedMessageFormatTestCase.java
create mode 100644 test/java/org/apache/fop/util/XMLResourceBundleTestCase.java
create mode 100644 test/java/org/apache/fop/util/XMLResourceBundleTestCase.xml
create mode 100644 test/java/org/apache/fop/util/XMLResourceBundleTestCase_de.xml
create mode 100644 test/java/org/apache/fop/util/invalid-translation-file.xml
(limited to 'src/java/org/apache/fop/render/ps/extensions/PSCommentAfterElement.java')
diff --git a/build.xml b/build.xml
index 2169003f8..5a72154f7 100644
--- a/build.xml
+++ b/build.xml
@@ -118,13 +118,15 @@ list of possible build targets.
-
-
-
-
-
+
+
+
+
+
+
+
@@ -362,7 +364,7 @@ list of possible build targets.
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -390,31 +498,22 @@ list of possible build targets.
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
+
+
-
+
@@ -452,13 +551,13 @@ list of possible build targets.
-
+
-
+
@@ -487,13 +586,13 @@ list of possible build targets.
-
+
-
+
@@ -608,14 +707,14 @@ list of possible build targets.
-
+
-
+
@@ -693,6 +792,7 @@ list of possible build targets.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/embedding/java/embedding/events/ExampleEvents.java b/examples/embedding/java/embedding/events/ExampleEvents.java
new file mode 100644
index 000000000..9c52e4ba1
--- /dev/null
+++ b/examples/embedding/java/embedding/events/ExampleEvents.java
@@ -0,0 +1,227 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package embedding.events;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.URL;
+
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.sax.SAXResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.xml.sax.SAXException;
+
+import org.apache.commons.io.IOUtils;
+
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.apps.Fop;
+import org.apache.fop.apps.FopFactory;
+import org.apache.fop.apps.MimeConstants;
+import org.apache.fop.events.Event;
+import org.apache.fop.events.EventFormatter;
+import org.apache.fop.events.EventListener;
+import org.apache.fop.events.model.EventSeverity;
+
+/**
+ * This class demonstrates how to register an event listener with FOP so you can customize
+ * FOP's error behaviour.
+ */
+public class ExampleEvents {
+
+ // configure fopFactory as desired
+ private FopFactory fopFactory = FopFactory.newInstance();
+
+ /**
+ * Converts an FO file to a PDF file using FOP
+ * @param fo the FO file
+ * @param pdf the target PDF file
+ * @throws IOException In case of an I/O problem
+ * @throws FOPException In case of a FOP problem
+ * @throws TransformerException In case of a problem with XSLT
+ */
+ public void convertFO2PDF(URL fo, File pdf)
+ throws IOException, FOPException, TransformerException {
+
+ OutputStream out = null;
+
+ try {
+ //Create the user agent for this processing run
+ FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
+
+ //Adding a simple logging listener that writes to stdout and stderr
+ foUserAgent.getEventBroadcaster().addEventListener(new SysOutEventListener());
+
+ // Add your own event listener
+ foUserAgent.getEventBroadcaster().addEventListener(new MyEventListener());
+
+ // configure foUserAgent further as desired
+
+ // Setup output stream. Note: Using BufferedOutputStream
+ // for performance reasons (helpful with FileOutputStreams).
+ out = new FileOutputStream(pdf);
+ out = new BufferedOutputStream(out);
+
+ // Construct fop with desired output format
+ Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);
+
+ // Setup JAXP using identity transformer
+ TransformerFactory factory = TransformerFactory.newInstance();
+ Transformer transformer = factory.newTransformer(); // identity transformer
+
+ // Setup input stream
+ Source src = new StreamSource(fo.toExternalForm());
+
+ // Resulting SAX events (the generated FO) must be piped through to FOP
+ Result res = new SAXResult(fop.getDefaultHandler());
+
+ // Start XSLT transformation and FOP processing
+ transformer.transform(src, res);
+
+ } finally {
+ IOUtils.closeQuietly(out);
+ }
+ }
+
+ private static class MyEventListener implements EventListener {
+
+ public void processEvent(Event event) {
+ if ("org.apache.fop.events.ResourceEventProducer.imageNotFound"
+ .equals(event.getEventID())) {
+
+ //Get the FileNotFoundException that's part of the event's parameters
+ FileNotFoundException fnfe = (FileNotFoundException)event.getParam("fnfe");
+
+ System.out.println("---=== imageNotFound Event for " + event.getParam("uri")
+ + "!!! ===---");
+ //Stop processing when an image could not be found. Otherwise, FOP would just
+ //continue without the image!
+
+ System.out.println("Throwing a RuntimeException...");
+ throw new RuntimeException(EventFormatter.format(event), fnfe);
+ } else {
+ //ignore all other events
+ }
+ }
+
+ }
+
+ /** A simple event listener that writes the events to stdout and sterr. */
+ private static class SysOutEventListener implements EventListener {
+
+ /** {@inheritDoc} */
+ public void processEvent(Event event) {
+ String msg = EventFormatter.format(event);
+ EventSeverity severity = event.getSeverity();
+ if (severity == EventSeverity.INFO) {
+ System.out.println("[INFO ] " + msg);
+ } else if (severity == EventSeverity.WARN) {
+ System.out.println("[WARN ] " + msg);
+ } else if (severity == EventSeverity.ERROR) {
+ System.err.println("[ERROR] " + msg);
+ } else if (severity == EventSeverity.FATAL) {
+ System.err.println("[FATAL] " + msg);
+ } else {
+ assert false;
+ }
+ }
+ }
+
+
+ /**
+ * This method extracts the original exception from some exception. The exception
+ * might be nested multiple levels deep.
+ * @param t the Throwable to inspect
+ * @return the original Throwable or the method parameter t if there are no nested Throwables.
+ */
+ private static Throwable getOriginalThrowable(Throwable t) {
+ if (t instanceof SAXException) {
+ SAXException saxe = (SAXException)t;
+ if (saxe.getException() != null) {
+ return getOriginalThrowable(saxe.getException());
+ } else {
+ return saxe;
+ }
+ } else {
+ if (t.getCause() != null) {
+ return getOriginalThrowable(t.getCause());
+ } else {
+ return t;
+ }
+ }
+ }
+
+ /**
+ * Main method.
+ * @param args command-line arguments
+ */
+ public static void main(String[] args) {
+ try {
+ System.out.println("FOP ExampleEvents\n");
+ System.out.println("Preparing...");
+
+ //Setup directories
+ File baseDir = new File(".");
+ File outDir = new File(baseDir, "out");
+ outDir.mkdirs();
+
+ //Setup input and output files
+ URL fo = ExampleEvents.class.getResource("missing-image.fo");
+ File pdffile = new File(outDir, "out.pdf");
+
+ System.out.println("Input: XSL-FO (" + fo.toExternalForm() + ")");
+ System.out.println("Output: PDF (" + pdffile + ")");
+ System.out.println();
+ System.out.println("Transforming...");
+
+ ExampleEvents app = new ExampleEvents();
+
+ try {
+ app.convertFO2PDF(fo, pdffile);
+ } catch (TransformerException te) {
+ //Note: We don't get the original exception here!
+ //FOP needs to embed the exception in a SAXException and the TraX transformer
+ //again wraps the SAXException in a TransformerException. Even our own
+ //RuntimeException just wraps the original FileNotFoundException.
+ //So we need to unpack to get the original exception (about three layers deep).
+ Throwable originalThrowable = getOriginalThrowable(te);
+ originalThrowable.printStackTrace(System.err);
+ System.out.println("Aborted!");
+ System.exit(-1);
+ }
+
+ System.out.println("Success!");
+ } catch (Exception e) {
+ //Some other error (shouldn't happen in this example)
+ e.printStackTrace(System.err);
+ System.exit(-1);
+ }
+ }
+
+}
diff --git a/examples/embedding/java/embedding/events/missing-image.fo b/examples/embedding/java/embedding/events/missing-image.fo
new file mode 100644
index 000000000..2c55f66ce
--- /dev/null
+++ b/examples/embedding/java/embedding/events/missing-image.fo
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ The following image is not available:
+
+
+
+
+
diff --git a/lib/build/qdox-1.6.3.jar b/lib/build/qdox-1.6.3.jar
new file mode 100644
index 000000000..3e99cb064
Binary files /dev/null and b/lib/build/qdox-1.6.3.jar differ
diff --git a/lib/build/qdox.LICENSE.txt b/lib/build/qdox.LICENSE.txt
new file mode 100644
index 000000000..3e4e3d004
--- /dev/null
+++ b/lib/build/qdox.LICENSE.txt
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
\ No newline at end of file
diff --git a/src/codegen/java/org/apache/fop/tools/EventConventionException.java b/src/codegen/java/org/apache/fop/tools/EventConventionException.java
new file mode 100644
index 000000000..675f4a0ca
--- /dev/null
+++ b/src/codegen/java/org/apache/fop/tools/EventConventionException.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.tools;
+
+public class EventConventionException extends Exception {
+
+ public EventConventionException(String message) {
+ super(message);
+ }
+
+}
diff --git a/src/codegen/java/org/apache/fop/tools/EventProducerCollector.java b/src/codegen/java/org/apache/fop/tools/EventProducerCollector.java
new file mode 100644
index 000000000..e42395ae7
--- /dev/null
+++ b/src/codegen/java/org/apache/fop/tools/EventProducerCollector.java
@@ -0,0 +1,183 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.tools;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Map;
+
+import org.apache.fop.events.EventProducer;
+import org.apache.fop.events.model.EventMethodModel;
+import org.apache.fop.events.model.EventModel;
+import org.apache.fop.events.model.EventProducerModel;
+import org.apache.fop.events.model.EventSeverity;
+
+import com.thoughtworks.qdox.JavaDocBuilder;
+import com.thoughtworks.qdox.model.DefaultDocletTagFactory;
+import com.thoughtworks.qdox.model.DocletTag;
+import com.thoughtworks.qdox.model.DocletTagFactory;
+import com.thoughtworks.qdox.model.JavaClass;
+import com.thoughtworks.qdox.model.JavaMethod;
+import com.thoughtworks.qdox.model.JavaParameter;
+import com.thoughtworks.qdox.model.Type;
+
+/**
+ * Finds EventProducer interfaces and builds the event model for them.
+ */
+public class EventProducerCollector {
+
+ private static final String CLASSNAME_EVENT_PRODUCER = EventProducer.class.getName();
+ private static final Map PRIMITIVE_MAP;
+
+ static {
+ Map m = new java.util.HashMap();
+ m.put("boolean", Boolean.class);
+ m.put("byte", Byte.class);
+ m.put("char", Character.class);
+ m.put("short", Short.class);
+ m.put("int", Integer.class);
+ m.put("long", Long.class);
+ m.put("float", Float.class);
+ m.put("double", Double.class);
+ PRIMITIVE_MAP = Collections.unmodifiableMap(m);
+ }
+
+ private DocletTagFactory tagFactory;
+ private EventModel model = new EventModel();
+
+ public EventProducerCollector() {
+ this.tagFactory = createDocletTagFactory();
+ }
+
+ protected DocletTagFactory createDocletTagFactory() {
+ return new DefaultDocletTagFactory();
+ }
+
+ public void scanFile(File src, String filename)
+ throws IOException, EventConventionException, ClassNotFoundException {
+ JavaDocBuilder builder = new JavaDocBuilder(this.tagFactory);
+ builder.addSource(src);
+ JavaClass[] classes = builder.getClasses();
+ for (int i = 0, c = classes.length; i < c; i++) {
+ JavaClass clazz = classes[i];
+ if (clazz.isInterface() && implementsInterface(clazz, CLASSNAME_EVENT_PRODUCER)) {
+ processEventProducerInterface(clazz, filename);
+ }
+ }
+ }
+
+ private boolean implementsInterface(JavaClass clazz, String intf) {
+ JavaClass[] classes = clazz.getImplementedInterfaces();
+ for (int i = 0, c = classes.length; i < c; i++) {
+ JavaClass cl = classes[i];
+ if (cl.getFullyQualifiedName().equals(intf)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Processes an EventProducer interface and creates an EventProducerModel from it.
+ * @param clazz the EventProducer interface
+ * @param javaFilename the filename of the Java source of the interface
+ * @throws EventConventionException if the event producer conventions are violated
+ * @throws ClassNotFoundException if a required class cannot be found
+ */
+ protected void processEventProducerInterface(JavaClass clazz, String javaFilename)
+ throws EventConventionException, ClassNotFoundException {
+ EventProducerModel prodMeta = new EventProducerModel(clazz.getFullyQualifiedName());
+ JavaMethod[] methods = clazz.getMethods(true);
+ for (int i = 0, c = methods.length; i < c; i++) {
+ JavaMethod method = methods[i];
+ EventMethodModel methodMeta = createMethodModel(method);
+ prodMeta.addMethod(methodMeta);
+ }
+ this.model.addProducer(prodMeta);
+ }
+
+ private EventMethodModel createMethodModel(JavaMethod method)
+ throws EventConventionException, ClassNotFoundException {
+ JavaClass clazz = method.getParentClass();
+ //Check EventProducer conventions
+ if (!method.getReturns().isVoid()) {
+ throw new EventConventionException("All methods of interface "
+ + clazz.getFullyQualifiedName() + " must have return type 'void'!");
+ }
+ String methodSig = clazz.getFullyQualifiedName() + "." + method.getCallSignature();
+ JavaParameter[] params = method.getParameters();
+ if (params.length < 1) {
+ throw new EventConventionException("The method " + methodSig
+ + " must have at least one parameter: 'Object source'!");
+ }
+ Type firstType = params[0].getType();
+ if (firstType.isPrimitive() || !"source".equals(params[0].getName())) {
+ throw new EventConventionException("The first parameter of the method " + methodSig
+ + " must be: 'Object source'!");
+ }
+
+ //build method model
+ DocletTag tag = method.getTagByName("event.severity");
+ EventSeverity severity;
+ if (tag != null) {
+ severity = EventSeverity.valueOf(tag.getValue());
+ } else {
+ severity = EventSeverity.INFO;
+ }
+ EventMethodModel methodMeta = new EventMethodModel(
+ method.getName(), severity);
+ if (params.length > 1) {
+ for (int j = 1, cj = params.length; j < cj; j++) {
+ JavaParameter p = params[j];
+ Class type;
+ JavaClass pClass = p.getType().getJavaClass();
+ if (p.getType().isPrimitive()) {
+ type = (Class)PRIMITIVE_MAP.get(pClass.getName());
+ if (type == null) {
+ throw new UnsupportedOperationException(
+ "Primitive datatype not supported: " + pClass.getName());
+ }
+ } else {
+ String className = pClass.getFullyQualifiedName();
+ type = Class.forName(className);
+ }
+ methodMeta.addParameter(type, p.getName());
+ }
+ }
+ Type[] exceptions = method.getExceptions();
+ if (exceptions != null && exceptions.length > 0) {
+ //We only use the first declared exception because that is always thrown
+ JavaClass cl = exceptions[0].getJavaClass();
+ methodMeta.setExceptionClass(cl.getFullyQualifiedName());
+ methodMeta.setSeverity(EventSeverity.FATAL); //In case it's not set in the comments
+ }
+ return methodMeta;
+ }
+
+ public EventModel getModel() {
+ return this.model;
+ }
+
+ public void saveModelToXML(File modelFile) throws IOException {
+ getModel().saveToXML(modelFile);
+ }
+
+}
diff --git a/src/codegen/java/org/apache/fop/tools/EventProducerCollectorTask.java b/src/codegen/java/org/apache/fop/tools/EventProducerCollectorTask.java
new file mode 100644
index 000000000..755e3da0b
--- /dev/null
+++ b/src/codegen/java/org/apache/fop/tools/EventProducerCollectorTask.java
@@ -0,0 +1,200 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.tools;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.URIResolver;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.sax.SAXTransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.w3c.dom.Node;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.types.FileSet;
+import org.apache.tools.ant.types.selectors.FilenameSelector;
+
+public class EventProducerCollectorTask extends Task {
+
+ private List filesets = new java.util.ArrayList();
+ private File modelFile;
+ private File translationFile;
+
+ /** {@inheritDoc} */
+ public void execute() throws BuildException {
+ try {
+ EventProducerCollector collector = new EventProducerCollector();
+ processFileSets(collector);
+ getModelFile().getParentFile().mkdirs();
+ collector.saveModelToXML(getModelFile());
+ log("Event model written to " + getModelFile());
+ if (getTranslationFile() != null) {
+ updateTranslationFile();
+ }
+ } catch (ClassNotFoundException e) {
+ throw new BuildException(e);
+ } catch (EventConventionException ece) {
+ throw new BuildException(ece);
+ } catch (IOException ioe) {
+ throw new BuildException(ioe);
+ }
+ }
+
+ private static final String MODEL2TRANSLATION = "model2translation.xsl";
+ private static final String MERGETRANSLATION = "merge-translation.xsl";
+
+ protected void updateTranslationFile() throws IOException {
+ try {
+ boolean resultExists = getTranslationFile().exists();
+ SAXTransformerFactory tFactory
+ = (SAXTransformerFactory)SAXTransformerFactory.newInstance();
+
+ //Generate fresh generated translation file as template
+ Source src = new StreamSource(getModelFile());
+ StreamSource xslt1 = new StreamSource(
+ getClass().getResourceAsStream(MODEL2TRANSLATION));
+ if (xslt1.getInputStream() == null) {
+ throw new FileNotFoundException(MODEL2TRANSLATION + " not found");
+ }
+ DOMResult domres = new DOMResult();
+ Transformer transformer = tFactory.newTransformer(xslt1);
+ transformer.transform(src, domres);
+ final Node generated = domres.getNode();
+
+ Node sourceDocument;
+ if (resultExists) {
+ //Load existing translation file into memory (because we overwrite it later)
+ src = new StreamSource(getTranslationFile());
+ domres = new DOMResult();
+ transformer = tFactory.newTransformer();
+ transformer.transform(src, domres);
+ sourceDocument = domres.getNode();
+ } else {
+ //Simply use generated as source document
+ sourceDocument = generated;
+ }
+
+ //Generate translation file (with potentially new translations)
+ src = new DOMSource(sourceDocument);
+ Result res = new StreamResult(getTranslationFile());
+ StreamSource xslt2 = new StreamSource(
+ getClass().getResourceAsStream(MERGETRANSLATION));
+ if (xslt2.getInputStream() == null) {
+ throw new FileNotFoundException(MERGETRANSLATION + " not found");
+ }
+ transformer = tFactory.newTransformer(xslt2);
+ transformer.setURIResolver(new URIResolver() {
+ public Source resolve(String href, String base) throws TransformerException {
+ if ("my:dom".equals(href)) {
+ return new DOMSource(generated);
+ }
+ return null;
+ }
+ });
+ if (resultExists) {
+ transformer.setParameter("generated-url", "my:dom");
+ }
+ transformer.transform(src, res);
+ if (resultExists) {
+ log("Translation file updated: " + getTranslationFile());
+ } else {
+ log("Translation file generated: " + getTranslationFile());
+ }
+ } catch (TransformerException te) {
+ throw new IOException(te.getMessage());
+ }
+ }
+
+ protected void processFileSets(EventProducerCollector collector)
+ throws IOException, EventConventionException, ClassNotFoundException {
+ Iterator iter = filesets.iterator();
+ while (iter.hasNext()) {
+ FileSet fs = (FileSet)iter.next();
+ DirectoryScanner ds = fs.getDirectoryScanner(getProject());
+ String[] srcFiles = ds.getIncludedFiles();
+ File directory = fs.getDir(getProject());
+ for (int i = 0, c = srcFiles.length; i < c; i++) {
+ String filename = srcFiles[i];
+ File src = new File(directory, filename);
+ collector.scanFile(src, filename);
+ }
+ }
+ }
+
+ public void addFileset(FileSet set) {
+ filesets.add(set);
+ }
+
+ public void setModelFile(File f) {
+ this.modelFile = f;
+ }
+
+ public File getModelFile() {
+ return this.modelFile;
+ }
+
+ public void setTranslationFile(File f) {
+ this.translationFile = f;
+ }
+
+ public File getTranslationFile() {
+ return this.translationFile;
+ }
+
+ public static void main(String[] args) {
+ try {
+ Project project = new Project();
+
+ EventProducerCollectorTask generator = new EventProducerCollectorTask();
+ generator.setProject(project);
+ project.setName("Test");
+ FileSet fileset = new FileSet();
+ fileset.setDir(new File("test/java"));
+
+ FilenameSelector selector = new FilenameSelector();
+ selector.setName("**/*.java");
+ fileset.add(selector);
+ generator.addFileset(fileset);
+
+ File targetDir = new File("build/codegen1");
+ targetDir.mkdirs();
+
+ generator.setModelFile(new File("D:/out.xml"));
+ generator.setTranslationFile(new File("D:/out1.xml"));
+ generator.execute();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/src/codegen/java/org/apache/fop/tools/merge-translation.xsl b/src/codegen/java/org/apache/fop/tools/merge-translation.xsl
new file mode 100644
index 000000000..d15d22fd3
--- /dev/null
+++ b/src/codegen/java/org/apache/fop/tools/merge-translation.xsl
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/codegen/java/org/apache/fop/tools/model2translation.xsl b/src/codegen/java/org/apache/fop/tools/model2translation.xsl
new file mode 100644
index 000000000..a1cf404ee
--- /dev/null
+++ b/src/codegen/java/org/apache/fop/tools/model2translation.xsl
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+ en
+
+
+
+
+
+
+ .
+
+
+
+
diff --git a/src/documentation/content/xdocs/site.xml b/src/documentation/content/xdocs/site.xml
index 18716903c..b0a3214e7 100644
--- a/src/documentation/content/xdocs/site.xml
+++ b/src/documentation/content/xdocs/site.xml
@@ -155,6 +155,7 @@
+
diff --git a/src/documentation/content/xdocs/trunk/events.xml b/src/documentation/content/xdocs/trunk/events.xml
new file mode 100644
index 000000000..d2fe5318c
--- /dev/null
+++ b/src/documentation/content/xdocs/trunk/events.xml
@@ -0,0 +1,422 @@
+
+
+
+
+
+
+ Events/Processing Feedback
+ $Revision: 634267 $
+
+
+
+ Introduction
+
+ In versions until 0.20.5, FOP used
+ Avalon-style Logging where
+ it was possible to supply a logger per processing run. During the redesign
+ the logging infrastructure was switched over to
+ Commons Logging which is (like Log4J or
+ java.util.logging) a "static" logging framework (the logger is accessed through static
+ variables). This made it very difficult in a multi-threaded system to retrieve information
+ for a single processing run.
+
+
+ With FOP's event subsystem, we'd like to close this gap again and even go further. The
+ first point is to realize that we have two kinds of "logging". Firstly, we have the logging
+ infrastructure for the (FOP) developer who needs to be able to enable finer log messages
+ for certain parts of FOP to track down a certain problem. Secondly, we have the user who
+ would like to be informed about missing images, overflowing lines or substituted fonts.
+ These messages (or events) are targeted at less technical people and may ideally be
+ localized (translated). Furthermore, tool and solution builders would like to integrate
+ FOP into their own solutions. For example, an FO editor should be able to point the user
+ to the right place where a particular problem occurred while developing a document template.
+ Finally, some integrators would like to abort processing if a resource (an image or a font)
+ has not been found, while others would simply continue. The event system allows to
+ react on these events.
+
+
+ On this page, we won't discuss logging as such. We will show how the event subsystem can
+ be used for various tasks. We'll first look at the event subsystem from the consumer side.
+ Finally, the production of events inside FOP will be discussed (this is mostly interesting
+ for FOP developers only).
+
+
+
+ The consumer side
+
+ The event subsystem is located in the org.apache.fop.events package and its
+ base is the Event class. An instance is created for each event and is sent
+ to a set of EventListener instances by the EventBroadcaster.
+ An Event contains:
+
+
+
an event ID,
+
a source object (which generated the event),
+
a severity level (Info, Warning, Error and Fatal Error) and
+
a map of named parameters.
+
+
+ The EventFormatter class can be used to translate the events into
+ human-readable, localized messages.
+
+
+ A full example of what is shown here can be found in the
+ examples/embedding/java/embedding/events directory in the FOP distribution.
+ The example can also be accessed
+ via the web.
+
+
+ Writing an EventListener
+
+ The following code sample shows a very simple EventListener. It basically just sends
+ all events to System.out (stdout) or System.err (stderr) depending on the event severity.
+
+
+
+ You can see that for every event the method processEvent of the
+ EventListener will be called. Inside this method you can do whatever
+ processing you would like including throwing a RuntimeException, if you want
+ to abort the current processing run.
+
+
+ The code above also shows how you can turn an event into a human-readable, localized
+ message that can be presented to a user. The EventFormatter class does
+ this for you. It provides additional methods if you'd like to explicitly specify
+ the locale.
+
+
+ It is possible to gather all events for a whole processing run so they can be
+ evaluated afterwards. However, care should be taken about memory consumption since
+ the events provide references to objects inside FOP which may themselves have
+ references to other objects. So holding on to these objects may mean that whole
+ object trees cannot be released!
+
+
+
+ Adding an EventListener
+
+ To register the event listener with FOP, get the EventBroadcaster which
+ is associated with the user agent (FOUserAgent) and add it there:
+
+
+
+ Please note that this is done separately for each processing run, i.e. for each
+ new user agent.
+
+
+
+ An additional listener example
+
+ Here's an additional example of an event listener:
+
+
+ By default, FOP continues processing even if an image wasn't found. If you have
+ more strict requirements and want FOP to stop if an image is not available, you can
+ do something like the following:
+
+
+
+ This throws a RuntimeException with the FileNotFoundException
+ as the cause. Further processing effectively stops in FOP. You can catch the exception
+ in your code and react as you see necessary.
+
+
+
+
+ The producer side (for FOP developers)
+
+ This section is primarily for FOP and FOP plug-in developers. It describes how to use
+ the event subsystem for producing events.
+
+
+ The event package has been designed in order to be theoretically useful for use cases
+ outside FOP. If you think this is interesting independently from FOP, please talk to
+ us.
+
+
+ Producing and sending an event
+
+ The basics are very simple. Just instantiate an Event object and fill
+ it with the necessary parameters. Then pass it to the EventBroadcaster
+ which distributes the events to the interested listeneners. Here's a code example:
+
+
+
+ The Event.paramsBuilder() is a
+ fluent interface
+ to help with the build-up of the parameters. You could just as well instantiate a
+ Map (Map<String, Object>) and fill it with values.
+
+
+
+ The EventProducer interface
+
+ To simplify event production, the event subsystem provides the EventProducer
+ interface. You can create interfaces which extend EventProducer. These
+ interfaces will contain one method per event to be generated. By contract, each event
+ method must have as its first parameter a parameter named "source" (Type Object) which
+ indicates the object that generated the event. After that come an arbitrary number of
+ parameters of any type as needed by the event.
+
+
+ The event producer interface does not need to have any implementation. The implementation
+ is produced at runtime by a dynamic proxy created by DefaultEventBroadcaster.
+ The dynamic proxy creates Event instances for each method call against
+ the event producer interface. Each parameter (except "source") is added to the event's
+ parameter map.
+
+
+ To simplify the code needed to get an instance of the event producer interface it is
+ suggested to create a public inner provider class inside the interface.
+
+
+ Here's an example of such an event producer interface:
+
+
+
+ To produce the same event as in the first example above, you'd use the following code:
+
+
+
+
+ The event model
+
+ Inside an invocation handler for a dynamic proxy, there's no information about
+ the names of each parameter. The JVM doesn't provide it. The only thing you know is
+ the interface and method name. In order to properly fill the Event's
+ parameter map we need to know the parameter names. These are retrieved from an
+ event object model. This is found in the org.apache.fop.events.model
+ package. The data for the object model is retrieved from an XML representation of the
+ event model that is loaded as a resource. The XML representation is generated using an
+ Ant task at build time (ant resourcegen). The Ant task (found in
+ src/codegen/java/org/apache/fop/tools/EventProducerCollectorTask.java)
+ scans FOP's sources for descendants of the EventProducer interface and
+ uses QDox to parse these interfaces.
+
+
+ Primarily, the QDox-based collector task records the parameters' names and types.
+ Furthermore, it extracts additional attributes embedded as Javadoc comments from
+ the methods. At the moment, the only such attribute is "@event.severity" which indicates
+ the default event severity (which can be changed by event listeners). The example event
+ producer above shows the Javadocs for an event method.
+
+
+ There's one more information that is extracted from the event producer information for
+ the event model: an optional primary exception. The first exception in the "throws"
+ declaration of an event method is noted. It is used to throw an exception from
+ the invocation handler if the event has an event severity of "FATAL" when all
+ listeners have been called (listeners can update the event severity). Please note
+ that an implementation of
+ org.apache.fop.events.EventExceptionManager$ExceptionFactory has to be
+ registered for the EventExceptionManager to be able to construct the
+ exception from an event.
+
+
+ For a given application, there can be multiple event models active at the same time.
+ In FOP, each renderer is considered to be a plug-in and provides its own specific
+ event model. The individual event models are provided through an
+ EventModelFactory. This interface is implemented for each event model
+ and registered through the service provider mechanism
+ (see the plug-ins section for details).
+
+
+
+ Event severity
+
+ Four different levels of severity for events has been defined:
+
+
+
INFO: informational only
+
WARN: a Warning
+
ERROR: an error condition from which FOP can recover. FOP will continue processing.
+
FATAL: a fatal error which causes an exception in the end and FOP will stop processing.
+
+
+ Event listeners can choose to ignore certain events based on their event severity.
+ Please note that you may recieve an event "twice" in a specific case: if there is
+ a fatal error an event is generated and sent to the listeners. After that an exception
+ is thrown with the same information and processing stops. If the fatal event is
+ shown to the user and the following exception is equally presented to the user it
+ may appear that the event is duplicated. Of course, the same information is just
+ published through two different channels.
+
+
+
+ Plug-ins to the event subsystem
+
+ The event subsystem is extensible. There are a number of extension points:
+
+
+
+ org.apache.fop.events.model.EventModelFactory: Provides
+ an event model to the event subsystem.
+
+
+ org.apache.fop.events.EventExceptionManager$ExceptionFactory:
+ Creates exceptions for events, i.e. turns an event into a specific exception.
+
+
+
+ The names in bold above are used as filenames for the service provider files that
+ are placed in the META-INF/services directory. That way, they are
+ automatically detected. This is a mechanism defined by the
+ JAR file specification.
+
+
+
+ Localization (L10n)
+
+ One goal of the event subsystem was to have localized (translated) event messages.
+ The EventFormatter class can be used to convert an event to a
+ human-readable message. Each EventProducer can provide its own XML-based
+ translation file. If there is none, a central translation file is used, called
+ "EventFormatter.xml" (found in the same directory as the EventFormatter
+ class).
+
+
+ The XML format used by the EventFormatter is the same as
+ Apache Cocoon's catalog format. Here's an example:
+
+
+
+ The example (extracted from the RTF handler's event producer) has message templates for
+ two event methods. The class used to do variable replacement in the templates is
+ org.apache.fop.util.text.AdvancedMessageFormat which is more powerful
+ than the MessageFormat classes provided by the Java class library
+ (java.util.text package).
+
+
+ "locator" is a template that is reused by the other message templates
+ by referencing it through "{{locator}}". This is some kind of include command.
+
+
+ Normal event parameters are accessed by name inside single curly braces, for example:
+ "{node}". For objects, this format just uses the toString() method to turn
+ the object into a string, unless there is an ObjectFormatter registered
+ for that type (there's an example for org.xml.sax.Locator).
+
+
+ The single curly braces pattern supports additional features. For example, it is possible
+ to do this: "{start,if,start,end}". "if" here is a special field modifier that evaluates
+ "start" as a boolean and if that is true returns the text right after the second comma
+ ("start"). Otherwise it returns the text after the third comma ("end"). The "equals"
+ modifier is similar to "if" but it takes as an additional (comma-separated) parameter
+ right after the "equals" modifier, a string that is compared to the value of the variable.
+ An example: {severity,equals,EventSeverity:FATAL,,some text} (this adds "some text" if
+ the severity is not FATAL).
+
+
+ Additional such modifiers can be added by implementing the
+ AdvancedMessageFormat$Part and AdvancedMessageFormat$PartFactory
+ interfaces.
+
+
+ Square braces can be used to specify optional template sections. The whole section will
+ be omitted if any of the variables used within are unavailable. Pipe (|) characters can
+ be used to specify alternative sub-templates (see "locator" above for an example).
+
+
+ Developers can also register a function (in the above example:
+ {#gatherContextInfo})
+ to do more complex information rendering. These functions are implementations of the
+ AdvancedMessageFormat$Function interface. Please take care that this is
+ done in a locale-independent way as there is no locale information available, yet.
+
+
+
+
+
diff --git a/src/java/META-INF/services/org.apache.fop.events.EventExceptionManager$ExceptionFactory b/src/java/META-INF/services/org.apache.fop.events.EventExceptionManager$ExceptionFactory
new file mode 100644
index 000000000..9fa7b8d04
--- /dev/null
+++ b/src/java/META-INF/services/org.apache.fop.events.EventExceptionManager$ExceptionFactory
@@ -0,0 +1,4 @@
+org.apache.fop.events.ValidationExceptionFactory
+org.apache.fop.events.PropertyExceptionFactory
+org.apache.fop.events.UnsupportedOperationExceptionFactory
+org.apache.fop.layoutmgr.LayoutException$LayoutExceptionFactory
diff --git a/src/java/META-INF/services/org.apache.fop.events.model.EventModelFactory b/src/java/META-INF/services/org.apache.fop.events.model.EventModelFactory
new file mode 100644
index 000000000..8dc13dbfd
--- /dev/null
+++ b/src/java/META-INF/services/org.apache.fop.events.model.EventModelFactory
@@ -0,0 +1,7 @@
+org.apache.fop.events.FOPEventModelFactory
+org.apache.fop.render.afp.AFPEventProducer$EventModelFactory
+org.apache.fop.render.bitmap.BitmapRendererEventProducer$EventModelFactory
+org.apache.fop.render.pcl.PCLEventProducer$EventModelFactory
+org.apache.fop.render.pdf.PDFEventProducer$EventModelFactory
+org.apache.fop.render.ps.PSEventProducer$EventModelFactory
+org.apache.fop.render.rtf.RTFEventProducer$EventModelFactory
diff --git a/src/java/META-INF/services/org.apache.fop.util.text.AdvancedMessageFormat$Function b/src/java/META-INF/services/org.apache.fop.util.text.AdvancedMessageFormat$Function
new file mode 100644
index 000000000..375130f2a
--- /dev/null
+++ b/src/java/META-INF/services/org.apache.fop.util.text.AdvancedMessageFormat$Function
@@ -0,0 +1 @@
+org.apache.fop.fo.FONode$GatherContextInfoFunction
diff --git a/src/java/META-INF/services/org.apache.fop.util.text.AdvancedMessageFormat$ObjectFormatter b/src/java/META-INF/services/org.apache.fop.util.text.AdvancedMessageFormat$ObjectFormatter
new file mode 100644
index 000000000..9e3860b31
--- /dev/null
+++ b/src/java/META-INF/services/org.apache.fop.util.text.AdvancedMessageFormat$ObjectFormatter
@@ -0,0 +1 @@
+org.apache.fop.util.text.LocatorFormatter
diff --git a/src/java/META-INF/services/org.apache.fop.util.text.AdvancedMessageFormat$PartFactory b/src/java/META-INF/services/org.apache.fop.util.text.AdvancedMessageFormat$PartFactory
new file mode 100644
index 000000000..1647fb8d5
--- /dev/null
+++ b/src/java/META-INF/services/org.apache.fop.util.text.AdvancedMessageFormat$PartFactory
@@ -0,0 +1,6 @@
+org.apache.fop.util.text.IfFieldPart$Factory
+org.apache.fop.util.text.EqualsFieldPart$Factory
+org.apache.fop.util.text.ChoiceFieldPart$Factory
+org.apache.fop.util.text.HexFieldPart$Factory
+org.apache.fop.util.text.GlyphNameFieldPart$Factory
+org.apache.fop.events.EventFormatter$LookupFieldPartFactory
diff --git a/src/java/org/apache/fop/apps/FOPException.java b/src/java/org/apache/fop/apps/FOPException.java
index 3e1c180e9..851712b09 100644
--- a/src/java/org/apache/fop/apps/FOPException.java
+++ b/src/java/org/apache/fop/apps/FOPException.java
@@ -32,6 +32,8 @@ public class FOPException extends SAXException {
private String systemId;
private int line;
private int column;
+
+ private String localizedMessage;
/**
* Constructs a new FOP exception with the specified detail message.
@@ -210,5 +212,24 @@ public class FOPException extends SAXException {
}
}
}
+
+ /**
+ * Sets the localized message for this exception.
+ * @param msg the localized message
+ */
+ public void setLocalizedMessage(String msg) {
+ this.localizedMessage = msg;
+ }
+
+ /** {@inheritDoc} */
+ public String getLocalizedMessage() {
+ if (this.localizedMessage != null) {
+ return this.localizedMessage;
+ } else {
+ return super.getLocalizedMessage();
+ }
+ }
+
+
}
diff --git a/src/java/org/apache/fop/apps/FOUserAgent.java b/src/java/org/apache/fop/apps/FOUserAgent.java
index a7405b466..307087f74 100644
--- a/src/java/org/apache/fop/apps/FOUserAgent.java
+++ b/src/java/org/apache/fop/apps/FOUserAgent.java
@@ -36,6 +36,12 @@ import org.apache.xmlgraphics.image.loader.ImageSessionContext;
import org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext;
import org.apache.fop.Version;
+import org.apache.fop.events.DefaultEventBroadcaster;
+import org.apache.fop.events.Event;
+import org.apache.fop.events.EventBroadcaster;
+import org.apache.fop.events.EventProducer;
+import org.apache.fop.events.FOPEventListenerProxy;
+import org.apache.fop.events.LoggingEventListener;
import org.apache.fop.fo.FOEventHandler;
import org.apache.fop.render.Renderer;
import org.apache.fop.render.RendererFactory;
@@ -89,6 +95,7 @@ public class FOUserAgent {
private Renderer rendererOverride = null;
private FOEventHandler foEventHandlerOverride = null;
private boolean locatorEnabled = true; // true by default (for error messages).
+ private EventBroadcaster eventBroadcaster = new FOPEventBroadcaster();
/** Producer: Metadata element for the system/software that produces
* the document. (Some renderers can store this in the document.)
@@ -530,5 +537,43 @@ public class FOUserAgent {
return locatorEnabled;
}
+ /**
+ * Returns the event broadcaster that control events sent inside a processing run. Clients
+ * can register event listeners with the event broadcaster to listen for events that occur
+ * while a document is being processed.
+ * @return the event broadcaster.
+ */
+ public EventBroadcaster getEventBroadcaster() {
+ return this.eventBroadcaster;
+ }
+
+ private class FOPEventBroadcaster extends DefaultEventBroadcaster {
+
+ private FOPEventListenerProxy rootListener;
+
+ public FOPEventBroadcaster() {
+ this.rootListener = new FOPEventListenerProxy(
+ this.listeners, FOUserAgent.this);
+ }
+
+ /** {@inheritDoc} */
+ public void broadcastEvent(Event event) {
+ rootListener.processEvent(event);
+ }
+
+ /** {@inheritDoc} */
+ protected EventProducer createProxyFor(Class clazz) {
+ if (!this.listeners.hasEventListeners()) {
+ //Backwards-compatibility: Make sure at least the LoggingEventListener is plugged
+ //in so no events are just silently swallowed.
+ addEventListener(
+ new LoggingEventListener(LogFactory.getLog(FOUserAgent.class)));
+
+ }
+ return super.createProxyFor(clazz);
+ }
+
+ }
+
}
diff --git a/src/java/org/apache/fop/area/AreaEventProducer.java b/src/java/org/apache/fop/area/AreaEventProducer.java
new file mode 100644
index 000000000..7747d2d79
--- /dev/null
+++ b/src/java/org/apache/fop/area/AreaEventProducer.java
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.area;
+
+import org.apache.fop.events.EventBroadcaster;
+import org.apache.fop.events.EventProducer;
+
+/**
+ * Event producer interface for events related to the area tree.
+ */
+public interface AreaEventProducer extends EventProducer {
+
+ /**
+ * Provider class for the event producer.
+ */
+ class Provider {
+
+ /**
+ * Returns an event producer.
+ * @param broadcaster the event broadcaster to use
+ * @return the event producer
+ */
+ public static AreaEventProducer get(EventBroadcaster broadcaster) {
+ return (AreaEventProducer)broadcaster.getEventProducerFor(
+ AreaEventProducer.class);
+ }
+ }
+
+ /**
+ * An unresolved ID reference was encountered.
+ * @param source the event source
+ * @param type the type of reference
+ * @param id the unresolved ID
+ * @event.severity WARN
+ */
+ void unresolvedIDReference(Object source, String type, String id);
+
+ /**
+ * An unresolved ID reference was encountered on a page.
+ * @param source the event source
+ * @param page the page the ID reference was found on
+ * @param id the unresolved ID
+ * @event.severity WARN
+ */
+ void unresolvedIDReferenceOnPage(Object source, String page, String id);
+
+ /**
+ * A page could not be loaded/deserialized from a file.
+ * @param source the event source
+ * @param page the page to be loaded
+ * @param e the original exception
+ * @event.severity ERROR
+ */
+ void pageLoadError(Object source, String page, Exception e);
+
+ /**
+ * A page could not be saved/serialized to a file.
+ * @param source the event source
+ * @param page the page to be serialized
+ * @param e the original exception
+ * @event.severity ERROR
+ */
+ void pageSaveError(Object source, String page, Exception e);
+
+ /**
+ * A page could not be rendered.
+ * @param source the event source
+ * @param page the page to be serialized
+ * @param e the original exception
+ * @event.severity ERROR
+ */
+ void pageRenderingError(Object source, String page, Exception e);
+
+}
diff --git a/src/java/org/apache/fop/area/AreaTreeHandler.java b/src/java/org/apache/fop/area/AreaTreeHandler.java
index 7454f4667..d3ea41554 100644
--- a/src/java/org/apache/fop/area/AreaTreeHandler.java
+++ b/src/java/org/apache/fop/area/AreaTreeHandler.java
@@ -325,8 +325,9 @@ public class AreaTreeHandler extends FOEventHandler {
if (pageVPList != null) {
res.resolveIDRef(ids[count], pageVPList);
} else {
- log.warn(odi.getName() + ": Unresolved id reference \""
- + ids[count] + "\" found.");
+ AreaEventProducer eventProducer = AreaEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.unresolvedIDReference(this, odi.getName(), ids[count]);
idTracker.addUnresolvedIDRef(ids[count], res);
}
}
diff --git a/src/java/org/apache/fop/area/AreaTreeObject.java b/src/java/org/apache/fop/area/AreaTreeObject.java
index 94250deba..1c2269a01 100644
--- a/src/java/org/apache/fop/area/AreaTreeObject.java
+++ b/src/java/org/apache/fop/area/AreaTreeObject.java
@@ -23,7 +23,7 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
-import org.apache.fop.util.QName;
+import org.apache.xmlgraphics.util.QName;
/**
* Abstract base class for all area tree objects.
@@ -53,12 +53,12 @@ public abstract class AreaTreeObject {
if (atts.size() == 0) {
return;
}
- Iterator iter = atts.keySet().iterator();
+ Iterator iter = atts.entrySet().iterator();
while (iter.hasNext()) {
- QName qName = (QName)iter.next();
- String value = (String)atts.get(qName);
+ Map.Entry entry = (Map.Entry)iter.next();
+ String value = (String)entry.getValue();
//The casting is only to ensure type safety (too bad we can't use generics, yet)
- setForeignAttribute(qName, value);
+ setForeignAttribute((QName)entry.getKey(), value);
}
}
diff --git a/src/java/org/apache/fop/area/AreaTreeParser.java b/src/java/org/apache/fop/area/AreaTreeParser.java
index fafb99ed6..19edd3d5e 100644
--- a/src/java/org/apache/fop/area/AreaTreeParser.java
+++ b/src/java/org/apache/fop/area/AreaTreeParser.java
@@ -50,6 +50,7 @@ import org.apache.commons.logging.LogFactory;
import org.apache.xmlgraphics.image.loader.ImageInfo;
import org.apache.xmlgraphics.image.loader.ImageManager;
import org.apache.xmlgraphics.image.loader.ImageSessionContext;
+import org.apache.xmlgraphics.util.QName;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.area.Trait.Background;
@@ -78,7 +79,6 @@ import org.apache.fop.util.ColorUtil;
import org.apache.fop.util.ContentHandlerFactory;
import org.apache.fop.util.ContentHandlerFactoryRegistry;
import org.apache.fop.util.DefaultErrorListener;
-import org.apache.fop.util.QName;
/**
* This is a parser for the area tree XML (intermediate format) which is used to reread an area
diff --git a/src/java/org/apache/fop/area/CachedRenderPagesModel.java b/src/java/org/apache/fop/area/CachedRenderPagesModel.java
index 363fa02d1..b34a7e8d1 100644
--- a/src/java/org/apache/fop/area/CachedRenderPagesModel.java
+++ b/src/java/org/apache/fop/area/CachedRenderPagesModel.java
@@ -19,24 +19,27 @@
package org.apache.fop.area;
-import org.apache.commons.io.IOUtils;
-import org.apache.fop.apps.FOPException;
-import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.fonts.FontInfo;
-import org.xml.sax.SAXException;
-
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Iterator;
-
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
import java.io.File;
-import java.io.FileOutputStream;
import java.io.FileInputStream;
-import java.io.ObjectOutputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
import java.io.OutputStream;
-import java.io.BufferedOutputStream;
-import java.io.BufferedInputStream;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.xml.sax.SAXException;
+
+import org.apache.commons.io.IOUtils;
+
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.events.ResourceEventProducer;
+import org.apache.fop.fonts.FontInfo;
/**
* A simple cached render pages model.
@@ -69,46 +72,39 @@ public class CachedRenderPagesModel extends RenderPagesModel {
*/
protected boolean checkPreparedPages(PageViewport newpage, boolean renderUnresolved) {
for (Iterator iter = prepared.iterator(); iter.hasNext();) {
- PageViewport p = (PageViewport)iter.next();
- if (p.isResolved() || renderUnresolved) {
- if (p != newpage) {
+ PageViewport pageViewport = (PageViewport)iter.next();
+ if (pageViewport.isResolved() || renderUnresolved) {
+ if (pageViewport != newpage) {
try {
// load page from cache
- String name = (String)pageMap.get(p);
+ String name = (String)pageMap.get(pageViewport);
File tempFile = new File(baseDir, name);
log.debug("Loading page from: " + tempFile);
ObjectInputStream in = new ObjectInputStream(
new BufferedInputStream(
new FileInputStream(tempFile)));
try {
- p.loadPage(in);
+ pageViewport.loadPage(in);
} finally {
IOUtils.closeQuietly(in);
}
if (!tempFile.delete()) {
- log.warn("Temporary file could not be deleted: " + tempFile);
+ ResourceEventProducer eventProducer
+ = ResourceEventProducer.Provider.get(
+ renderer.getUserAgent().getEventBroadcaster());
+ eventProducer.cannotDeleteTempFile(this, tempFile);
}
- pageMap.remove(p);
+ pageMap.remove(pageViewport);
} catch (Exception e) {
- log.error(e);
+ AreaEventProducer eventProducer
+ = AreaEventProducer.Provider.get(
+ renderer.getUserAgent().getEventBroadcaster());
+ eventProducer.pageLoadError(this, pageViewport.getPageNumberString(), e);
}
}
- try {
- renderer.renderPage(p);
- if (!p.isResolved()) {
- String[] idrefs = p.getIDRefs();
- for (int count = 0; count < idrefs.length; count++) {
- log.warn("Page " + p.getPageNumberString()
- + ": Unresolved id reference \"" + idrefs[count]
- + "\" found.");
- }
- }
- } catch (Exception e) {
- // use error handler to handle this FOP or IO Exception
- log.error(e);
- }
- p.clear();
+ renderPage(pageViewport);
+ pageViewport.clear();
iter.remove();
} else {
if (!renderer.supportsOutOfOrder()) {
@@ -147,8 +143,11 @@ public class CachedRenderPagesModel extends RenderPagesModel {
if (log.isDebugEnabled()) {
log.debug("Page saved to temporary file: " + tempFile);
}
- } catch (Exception e) {
- log.error(e);
+ } catch (IOException ioe) {
+ AreaEventProducer eventProducer
+ = AreaEventProducer.Provider.get(
+ renderer.getUserAgent().getEventBroadcaster());
+ eventProducer.pageSaveError(this, page.getPageNumberString(), ioe);
}
}
diff --git a/src/java/org/apache/fop/area/PageViewport.java b/src/java/org/apache/fop/area/PageViewport.java
index af557ade9..da7ef1def 100644
--- a/src/java/org/apache/fop/area/PageViewport.java
+++ b/src/java/org/apache/fop/area/PageViewport.java
@@ -21,14 +21,15 @@ package org.apache.fop.area;
import java.awt.Rectangle;
import java.awt.geom.Rectangle2D;
-import java.io.ObjectOutputStream;
+import java.io.IOException;
import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.List;
-import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import java.util.Set;
import org.apache.commons.logging.Log;
@@ -516,9 +517,9 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl
* The map of unresolved references are set on the page so that
* the resolvers can be properly serialized and reloaded.
* @param out the object output stream to write the contents
- * @throws Exception if there is a problem saving the page
+ * @throws IOException in case of an I/O error while serializing the page
*/
- public void savePage(ObjectOutputStream out) throws Exception {
+ public void savePage(ObjectOutputStream out) throws IOException {
// set the unresolved references so they are serialized
page.setUnresolvedReferences(unresolvedIDRefs);
out.writeObject(page);
@@ -531,9 +532,10 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl
* if there are any unresolved references that were resolved
* while saved they will be resolved on the page contents.
* @param in the object input stream to read the page from
- * @throws Exception if there is an error loading the page
+ * @throws ClassNotFoundException if a class was not found while loading the page
+ * @throws IOException if an I/O error occurred while loading the page
*/
- public void loadPage(ObjectInputStream in) throws Exception {
+ public void loadPage(ObjectInputStream in) throws IOException, ClassNotFoundException {
page = (Page) in.readObject();
unresolvedIDRefs = page.getUnresolvedReferences();
if (unresolvedIDRefs != null && pendingResolved != null) {
diff --git a/src/java/org/apache/fop/area/RenderPagesModel.java b/src/java/org/apache/fop/area/RenderPagesModel.java
index e080e9cbe..b21566902 100644
--- a/src/java/org/apache/fop/area/RenderPagesModel.java
+++ b/src/java/org/apache/fop/area/RenderPagesModel.java
@@ -156,23 +156,7 @@ public class RenderPagesModel extends AreaTreeModel {
&& pageViewport.getPageSequence().isFirstPage(pageViewport)) {
renderer.startPageSequence(getCurrentPageSequence());
}
- try {
- renderer.renderPage(pageViewport);
- if (!pageViewport.isResolved()) {
- String[] idrefs = pageViewport.getIDRefs();
- for (int count = 0; count < idrefs.length; count++) {
- log.warn("Page " + pageViewport.getPageNumberString()
- + ": Unresolved id reference \"" + idrefs[count]
- + "\" found.");
- }
- }
- } catch (Exception e) {
- // use error handler to handle this FOP or IO Exception
- log.error("Error while rendering page " + pageViewport.getPageIndex(), e);
- if (e instanceof RuntimeException) {
- throw (RuntimeException)e;
- }
- }
+ renderPage(pageViewport);
pageViewport.clear();
iter.remove();
} else {
@@ -185,6 +169,33 @@ public class RenderPagesModel extends AreaTreeModel {
return renderer.supportsOutOfOrder() || prepared.isEmpty();
}
+ /**
+ * Renders the given page and notified about unresolved IDs if any.
+ * @param pageViewport the page to be rendered.
+ */
+ protected void renderPage(PageViewport pageViewport) {
+ try {
+ renderer.renderPage(pageViewport);
+ if (!pageViewport.isResolved()) {
+ String[] idrefs = pageViewport.getIDRefs();
+ for (int count = 0; count < idrefs.length; count++) {
+ AreaEventProducer eventProducer = AreaEventProducer.Provider.get(
+ renderer.getUserAgent().getEventBroadcaster());
+ eventProducer.unresolvedIDReferenceOnPage(this,
+ pageViewport.getPageNumberString(), idrefs[count]);
+ }
+ }
+ } catch (Exception e) {
+ AreaEventProducer eventProducer = AreaEventProducer.Provider.get(
+ renderer.getUserAgent().getEventBroadcaster());
+ eventProducer.pageRenderingError(this,
+ pageViewport.getPageNumberString(), e);
+ if (e instanceof RuntimeException) {
+ throw (RuntimeException)e;
+ }
+ }
+ }
+
/**
* Prepare a page.
* An unresolved page can be prepared if the renderer supports
diff --git a/src/java/org/apache/fop/events/CompositeEventListener.java b/src/java/org/apache/fop/events/CompositeEventListener.java
new file mode 100644
index 000000000..a65728b71
--- /dev/null
+++ b/src/java/org/apache/fop/events/CompositeEventListener.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.events;
+
+import java.util.List;
+
+/**
+ * EventListener implementation forwards events to possibly multiple other EventListeners.
+ */
+public class CompositeEventListener implements EventListener {
+
+ private List listeners = new java.util.ArrayList();
+
+ /**
+ * Adds an event listener to the broadcaster. It is appended to the list of previously
+ * registered listeners (the order of registration defines the calling order).
+ * @param listener the listener to be added
+ */
+ public synchronized void addEventListener(EventListener listener) {
+ this.listeners.add(listener);
+ }
+
+ /**
+ * Removes an event listener from the broadcaster. If the event listener is not registered,
+ * nothing happens.
+ * @param listener the listener to be removed
+ */
+ public synchronized void removeEventListener(EventListener listener) {
+ this.listeners.remove(listener);
+ }
+
+ private synchronized int getListenerCount() {
+ return this.listeners.size();
+ }
+
+ /**
+ * Indicates whether any listeners have been registered with the broadcaster.
+ * @return true if listeners are present, false otherwise
+ */
+ public boolean hasEventListeners() {
+ return (getListenerCount() > 0);
+ }
+
+ /** {@inheritDoc} */
+ public synchronized void processEvent(Event event) {
+ for (int i = 0, c = getListenerCount(); i < c; i++) {
+ EventListener listener = (EventListener)this.listeners.get(i);
+ listener.processEvent(event);
+ }
+ }
+
+}
diff --git a/src/java/org/apache/fop/events/DefaultEventBroadcaster.java b/src/java/org/apache/fop/events/DefaultEventBroadcaster.java
new file mode 100644
index 000000000..bb1752a72
--- /dev/null
+++ b/src/java/org/apache/fop/events/DefaultEventBroadcaster.java
@@ -0,0 +1,160 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.events;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.xmlgraphics.util.Service;
+
+import org.apache.fop.events.model.EventMethodModel;
+import org.apache.fop.events.model.EventModel;
+import org.apache.fop.events.model.EventModelFactory;
+import org.apache.fop.events.model.EventProducerModel;
+import org.apache.fop.events.model.EventSeverity;
+
+/**
+ * Default implementation of the EventBroadcaster interface. It holds a list of event listeners
+ * and can provide {@link EventProducer} instances for type-safe event production.
+ */
+public class DefaultEventBroadcaster implements EventBroadcaster {
+
+ /** Holds all registered event listeners */
+ protected CompositeEventListener listeners = new CompositeEventListener();
+
+ /** {@inheritDoc} */
+ public void addEventListener(EventListener listener) {
+ this.listeners.addEventListener(listener);
+ }
+
+ /** {@inheritDoc} */
+ public void removeEventListener(EventListener listener) {
+ this.listeners.removeEventListener(listener);
+ }
+
+ /** {@inheritDoc} */
+ public boolean hasEventListeners() {
+ return this.listeners.hasEventListeners();
+ }
+
+ /** {@inheritDoc} */
+ public void broadcastEvent(Event event) {
+ this.listeners.processEvent(event);
+ }
+
+ private static List/**/ eventModels = new java.util.ArrayList();
+ private Map proxies = new java.util.HashMap();
+
+ static {
+ Iterator iter = Service.providers(EventModelFactory.class, true);
+ while (iter.hasNext()) {
+ EventModelFactory factory = (EventModelFactory)iter.next();
+ addEventModel(factory.createEventModel());
+ }
+ }
+
+ /**
+ * Adds a new {@link EventModel} to the list of registered event models.
+ * @param eventModel the event model instance
+ */
+ public static void addEventModel(EventModel eventModel) {
+ eventModels.add(eventModel);
+ }
+
+ /** {@inheritDoc} */
+ public EventProducer getEventProducerFor(Class clazz) {
+ if (!EventProducer.class.isAssignableFrom(clazz)) {
+ throw new IllegalArgumentException(
+ "Class must be an implementation of the EventProducer interface: "
+ + clazz.getName());
+ }
+ EventProducer producer;
+ producer = (EventProducer)this.proxies.get(clazz);
+ if (producer == null) {
+ producer = createProxyFor(clazz);
+ this.proxies.put(clazz, producer);
+ }
+ return producer;
+ }
+
+ private EventProducerModel getEventProducerModel(Class clazz) {
+ for (int i = 0, c = eventModels.size(); i < c; i++) {
+ EventModel eventModel = (EventModel)eventModels.get(i);
+ EventProducerModel producerModel = eventModel.getProducer(clazz);
+ if (producerModel != null) {
+ return producerModel;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Creates a dynamic proxy for the given EventProducer interface that will handle the
+ * conversion of the method call into the broadcasting of an event instance.
+ * @param clazz a descendant interface of EventProducer
+ * @return the EventProducer instance
+ */
+ protected EventProducer createProxyFor(Class clazz) {
+ final EventProducerModel producerModel = getEventProducerModel(clazz);
+ if (producerModel == null) {
+ throw new IllegalStateException("Event model doesn't contain the definition for "
+ + clazz.getName());
+ }
+ return (EventProducer)Proxy.newProxyInstance(clazz.getClassLoader(),
+ new Class[] {clazz},
+ new InvocationHandler() {
+ public Object invoke(Object proxy, Method method, Object[] args)
+ throws Throwable {
+ String methodName = method.getName();
+ EventMethodModel methodModel = producerModel.getMethod(methodName);
+ String eventID = producerModel.getInterfaceName() + "." + methodName;
+ if (methodModel == null) {
+ throw new IllegalStateException(
+ "Event model isn't consistent"
+ + " with the EventProducer interface. Please rebuild FOP!"
+ + " Affected method: "
+ + eventID);
+ }
+ Map params = new java.util.HashMap();
+ int i = 1;
+ Iterator iter = methodModel.getParameters().iterator();
+ while (iter.hasNext()) {
+ EventMethodModel.Parameter param
+ = (EventMethodModel.Parameter)iter.next();
+ params.put(param.getName(), args[i]);
+ i++;
+ }
+ Event ev = new Event(args[0], eventID, methodModel.getSeverity(), params);
+ broadcastEvent(ev);
+
+ if (ev.getSeverity() == EventSeverity.FATAL) {
+ EventExceptionManager.throwException(ev,
+ methodModel.getExceptionClass());
+ }
+ return null;
+ }
+ });
+ }
+
+}
diff --git a/src/java/org/apache/fop/events/Event.java b/src/java/org/apache/fop/events/Event.java
new file mode 100644
index 000000000..d3da1809e
--- /dev/null
+++ b/src/java/org/apache/fop/events/Event.java
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.events;
+
+import java.util.Collections;
+import java.util.EventObject;
+import java.util.Map;
+
+import org.apache.fop.events.model.EventSeverity;
+
+/**
+ * This is the default event class used by this package. Each event has a unique event identifier
+ * (a String), a severity indicator and a map of name/value pairs.
+ */
+public class Event extends EventObject {
+
+ private static final long serialVersionUID = -1310594422868258083L;
+
+ private String eventID;
+ private EventSeverity severity;
+ private Map params;
+
+ /**
+ * Creates a new Event.
+ * @param source the object that creates the event
+ * @param eventID the unique identifier of the event
+ * @param severity the severity level
+ * @param params the event parameters (a map of name/value pairs)
+ */
+ public Event(Object source, String eventID, EventSeverity severity, Map params) {
+ super(source);
+ this.eventID = eventID;
+ setSeverity(severity);
+ this.params = params;
+ }
+
+ /**
+ * Returns the event identifier.
+ * @return the event identifier
+ */
+ public String getEventID() {
+ return this.eventID;
+ }
+
+ /**
+ * Returns the event group identifier.
+ * @return the event group identifier (or null if there is no group identifier)
+ */
+ public String getEventGroupID() {
+ int pos = this.eventID.lastIndexOf('.');
+ if (pos > 0) {
+ return this.eventID.substring(0, pos);
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Returns the severity level.
+ * @return the severity level
+ */
+ public EventSeverity getSeverity() {
+ return this.severity;
+ }
+
+ /**
+ * Sets the event's severity level. This method can be used to increase or decrease the
+ * severity level in a listener.
+ * @param severity the new event severity
+ */
+ public void setSeverity(EventSeverity severity) {
+ this.severity = severity;
+ }
+
+ /**
+ * Returns a parameter.
+ * @param key the key to the parameter
+ * @return the parameter value or null if no value with this key is found
+ */
+ public Object getParam(String key) {
+ if (this.params != null) {
+ return this.params.get(key);
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Returns an unmodifiable {@link java.util.Map} with all event parameters.
+ * @return the parameter map
+ */
+ public Map getParams() {
+ return Collections.unmodifiableMap(this.params);
+ }
+
+ /**
+ * Creates and returns a fluent builder object for building up the parameter map.
+ * @return the parameter builder
+ */
+ public static ParamsBuilder paramsBuilder() {
+ return new ParamsBuilder();
+ }
+
+ /**
+ * This class is a fluent builder class for building up the parameter map.
+ */
+ public static class ParamsBuilder {
+ private Map params;
+
+ /**
+ * Adds a new parameter (a name/value pair).
+ * @param name the name of the parameter
+ * @param value the value of the parameter
+ * @return this instance
+ */
+ public ParamsBuilder param(String name, Object value) {
+ if (this.params == null) {
+ this.params = new java.util.HashMap();
+ }
+ this.params.put(name, value);
+ return this;
+ }
+
+ /**
+ * Returns the accumulated parameter map.
+ * @return the accumulated parameter map
+ */
+ public Map build() {
+ return this.params;
+ }
+ }
+
+}
diff --git a/src/java/org/apache/fop/events/EventBroadcaster.java b/src/java/org/apache/fop/events/EventBroadcaster.java
new file mode 100644
index 000000000..6c8df7375
--- /dev/null
+++ b/src/java/org/apache/fop/events/EventBroadcaster.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.events;
+
+/**
+ * The EventBroadcaster is the central relay point for events. It receives events from various
+ * parts of the application and forwards them to any registered EventListener.
+ */
+public interface EventBroadcaster {
+
+ /**
+ * Adds an event listener to the broadcaster. It is appended to the list of previously
+ * registered listeners (the order of registration defines the calling order).
+ * @param listener the listener to be added
+ */
+ void addEventListener(EventListener listener);
+
+ /**
+ * Removes an event listener from the broadcaster. If the event listener is not registered,
+ * nothing happens.
+ * @param listener the listener to be removed
+ */
+ void removeEventListener(EventListener listener);
+
+ /**
+ * Indicates whether any listeners have been registered with the broadcaster.
+ * @return true if listeners are present, false otherwise
+ */
+ boolean hasEventListeners();
+
+ /**
+ * Broadcasts an event. This method is usually called from within the observed component.
+ * @param event the event to be broadcast
+ */
+ void broadcastEvent(Event event);
+
+ /**
+ * Returns an event producer instance for the given interface class.
+ * @param clazz the Class object identifying an {@link EventProducer} interface
+ * @return the event producer instance
+ */
+ EventProducer getEventProducerFor(Class clazz);
+
+}
diff --git a/src/java/org/apache/fop/events/EventExceptionManager.java b/src/java/org/apache/fop/events/EventExceptionManager.java
new file mode 100644
index 000000000..093ae7010
--- /dev/null
+++ b/src/java/org/apache/fop/events/EventExceptionManager.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.events;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.xmlgraphics.util.Service;
+
+/**
+ * This class is reponsible for converting events into exceptions.
+ */
+public class EventExceptionManager {
+
+ private static final Map EXCEPTION_FACTORIES = new java.util.HashMap();
+
+ static {
+ Iterator iter;
+ iter = Service.providers(ExceptionFactory.class, true);
+ while (iter.hasNext()) {
+ ExceptionFactory factory = (ExceptionFactory)iter.next();
+ EXCEPTION_FACTORIES.put(factory.getExceptionClass().getName(), factory);
+ }
+ }
+
+ /**
+ * Converts an event into an exception and throws that. If the exception class is null,
+ * a {@link RuntimeException} will be thrown.
+ * @param event the event to be converted
+ * @param exceptionClass the exception class to be thrown
+ * @throws Throwable this happens always
+ */
+ public static void throwException(Event event, String exceptionClass) throws Throwable {
+ if (exceptionClass != null) {
+ ExceptionFactory factory = (ExceptionFactory)EXCEPTION_FACTORIES.get(exceptionClass);
+ if (factory != null) {
+ throw factory.createException(event);
+ } else {
+ throw new IllegalArgumentException(
+ "No such ExceptionFactory available: " + exceptionClass);
+ }
+ } else {
+ String msg = EventFormatter.format(event);
+ throw new RuntimeException(msg);
+ }
+ }
+
+ /**
+ * This interface is implementation by exception factories that can create exceptions from
+ * events.
+ */
+ public interface ExceptionFactory {
+
+ /**
+ * Creates an exception from an event.
+ * @param event the event
+ * @return the newly created exception
+ */
+ Throwable createException(Event event);
+
+ /**
+ * Returns the {@link Exception} class created by this factory.
+ * @return the exception class
+ */
+ Class getExceptionClass();
+ }
+}
diff --git a/src/java/org/apache/fop/events/EventFormatter.java b/src/java/org/apache/fop/events/EventFormatter.java
new file mode 100644
index 000000000..56964039b
--- /dev/null
+++ b/src/java/org/apache/fop/events/EventFormatter.java
@@ -0,0 +1,196 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.events;
+
+import java.util.Locale;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.fop.util.XMLResourceBundle;
+import org.apache.fop.util.text.AdvancedMessageFormat;
+import org.apache.fop.util.text.AdvancedMessageFormat.Part;
+import org.apache.fop.util.text.AdvancedMessageFormat.PartFactory;
+
+/**
+ * Converts events into human-readable, localized messages.
+ */
+public final class EventFormatter {
+
+ private static final Pattern INCLUDES_PATTERN = Pattern.compile("\\{\\{.+\\}\\}");
+
+ private static ResourceBundle defaultBundle = XMLResourceBundle.getXMLBundle(
+ EventFormatter.class.getName(), EventFormatter.class.getClassLoader());
+
+ private static Log log = LogFactory.getLog(EventFormatter.class);
+
+ private EventFormatter() {
+ //utility class
+ }
+
+ /**
+ * Formats an event using the default locale.
+ * @param event the event
+ * @return the formatted message
+ */
+ public static String format(Event event) {
+ ResourceBundle bundle = null;
+ String groupID = event.getEventGroupID();
+ if (groupID != null) {
+ try {
+ bundle = XMLResourceBundle.getXMLBundle(
+ groupID,
+ EventFormatter.class.getClassLoader());
+ } catch (MissingResourceException mre) {
+ if (log.isTraceEnabled()) {
+ log.trace("No XMLResourceBundle for " + groupID + " available.");
+ }
+ }
+ }
+ if (bundle == null) {
+ bundle = defaultBundle;
+ }
+ return format(event, bundle);
+ }
+
+ /**
+ * Formats an event using a given locale.
+ * @param event the event
+ * @param locale the locale
+ * @return the formatted message
+ */
+ public static String format(Event event, Locale locale) {
+ ResourceBundle bundle = null;
+ String groupID = event.getEventGroupID();
+ if (groupID != null) {
+ try {
+ bundle = XMLResourceBundle.getXMLBundle(
+ groupID, locale,
+ EventFormatter.class.getClassLoader());
+ } catch (MissingResourceException mre) {
+ if (log.isTraceEnabled()) {
+ log.trace("No XMLResourceBundle for " + groupID + " available.");
+ }
+ }
+ }
+ if (bundle == null) {
+ bundle = XMLResourceBundle.getXMLBundle(
+ EventFormatter.class.getName(),
+ locale,
+ EventFormatter.class.getClassLoader());
+ }
+ return format(event, bundle);
+ }
+
+ private static String format(Event event, ResourceBundle bundle) {
+ String template = bundle.getString(event.getEventID());
+ return format(event, processIncludes(template, bundle));
+ }
+
+ private static String processIncludes(String template, ResourceBundle bundle) {
+ CharSequence input = template;
+ int replacements;
+ StringBuffer sb;
+ do {
+ sb = new StringBuffer(Math.max(16, input.length()));
+ replacements = processIncludesInner(input, sb, bundle);
+ input = sb;
+ } while (replacements > 0);
+ String s = sb.toString();
+ return s;
+ }
+
+ private static int processIncludesInner(CharSequence template, StringBuffer sb,
+ ResourceBundle bundle) {
+ int replacements = 0;
+ Matcher m = INCLUDES_PATTERN.matcher(template);
+ while (m.find()) {
+ String include = m.group();
+ include = include.substring(2, include.length() - 2);
+ m.appendReplacement(sb, bundle.getString(include));
+ replacements++;
+ }
+ m.appendTail(sb);
+ return replacements;
+ }
+
+ /**
+ * Formats the event using a given pattern. The pattern needs to be compatible with
+ * {@link AdvancedMessageFormat}.
+ * @param event the event
+ * @param pattern the pattern (compatible with {@link AdvancedMessageFormat})
+ * @return the formatted message
+ */
+ public static String format(Event event, String pattern) {
+ AdvancedMessageFormat format = new AdvancedMessageFormat(pattern);
+ Map params = new java.util.HashMap(event.getParams());
+ params.put("source", event.getSource());
+ params.put("severity", event.getSeverity());
+ return format.format(params);
+ }
+
+ private static class LookupFieldPart implements Part {
+
+ private String fieldName;
+
+ public LookupFieldPart(String fieldName) {
+ this.fieldName = fieldName;
+ }
+
+ public boolean isGenerated(Map params) {
+ return getKey(params) != null;
+ }
+
+ public void write(StringBuffer sb, Map params) {
+ sb.append(defaultBundle.getString(getKey(params)));
+ }
+
+ private String getKey(Map params) {
+ return (String)params.get(fieldName);
+ }
+
+ /** {@inheritDoc} */
+ public String toString() {
+ return "{" + this.fieldName + ", lookup}";
+ }
+
+ }
+
+ /** PartFactory for lookups. */
+ public static class LookupFieldPartFactory implements PartFactory {
+
+ /** {@inheritDoc} */
+ public Part newPart(String fieldName, String values) {
+ return new LookupFieldPart(fieldName);
+ }
+
+ /** {@inheritDoc} */
+ public String getFormat() {
+ return "lookup";
+ }
+
+ }
+
+}
diff --git a/src/java/org/apache/fop/events/EventFormatter.xml b/src/java/org/apache/fop/events/EventFormatter.xml
new file mode 100644
index 000000000..f17da1161
--- /dev/null
+++ b/src/java/org/apache/fop/events/EventFormatter.xml
@@ -0,0 +1,101 @@
+
+
+
+
+ [ (See position {loc})| (See {#gatherContextInfo})| (No context info available)]
+ An fo:marker is permitted only as the descendant of an fo:flow.
+ An fo:retrieve-marker is permitted only as the descendant of an fo:static-content.
+ An fo:bidi-override that is a descendant of an fo:leader or of the fo:inline child of an fo:footnote may not have block-level children, unless it has a nearer ancestor that is an fo:inline-container.
+ An fo:inline that is a descendant of an fo:leader or fo:footnote may not have block-level children, unless it has a nearer ancestor that is an fo:inline-container.
+ The element must be a child of fo:simple-page-master.
+ The element must be a child of fo:declarations.
+ The element must be a child of fo:declarations or fo:simple-page-master.
+ For "{elementName}", only one "{offendingNode}" may be declared.{{locator}}
+ For "{elementName}", "{tooLateNode}" must be declared before "{tooEarlyNode}"!{{locator}}
+ "{offendingNode}" is not a valid child element of "{elementName}"![ {ruleViolated,lookup}]{{locator}}
+ "{elementName}" is missing child elements.[
+Required content model: {contentModel}]{{locator}}
+ Element "{elementName}" is missing required property "{propertyName}"!{{locator}}
+ Property ID "{id}" (found on "{elementName}") previously used; ID values must be unique within a document!{severity,equals,EventSeverity:FATAL,,
+Any reference to it will be considered a reference to the first occurrence in the document.}{{locator}}
+ fo:marker must be an initial child: {mcname}{{locator}}
+ fo:marker "marker-class-name" must be unique for same parent: {mcname}{{locator}}
+ Invalid property encountered on "{elementName}": {attr}{{locator}}
+ Invalid property value encountered in {propName}="{propValue}"[: {e}]{{locator}}
+ The following feature isn't implemented by Apache FOP, yet: {feature} (on {elementName}){{locator}}
+ Missing attribute on {elementName}: Either external-destination or internal-destination must be specified.{{locator}}
+ Unable to clone subtree of fo:marker (marker-class-name="{markerClassName}") for fo:retrieve-marker.{{locator}}
+ Duplicate color profile profile name: {name}{{locator}}
+ Region-name ("{regionName}") is being mapped to multiple region-classes ({defaultRegionClass1} and {defaultRegionClass2}).{{locator}}
+ The page master name ("{name}") must be unique across page-masters and page-sequence-masters.{{locator}}
+ Duplicate flow-name "{flowName}" found within {elementName}.{{locator}}
+ The flow-name "{flowName}" on {elementName} could not be mapped to a region-name in the layout-master-set.{{locator}}
+ The master-reference "{masterReference}" on {elementName} matches no simple-page-master or page-sequence-master.{{locator}}
+ The region-name "{regionName}" for {elementName} is not permitted.{{locator}}
+ Border and padding for {elementName} "{regionName}" must be '0' (See 6.4.13 in XSL 1.0).{{locator}}
+ If overflow property is set to "scroll" on {elementName}, a column-count other than "1" may not be specified.{{locator}}
+ First element must be the fo:root formatting object. Found {elementName} instead. Please make sure you're producing a valid XSL-FO document.
+ Document is empty (something might be wrong with your XSLT stylesheet).
+ Unknown formatting object "{offendingNode}" encountered (a child of {elementName}}.{{locator}}
+ Only a value of "auto" for block-progression-dimension has a well-specified behavior on fo:table. Falling back to "auto".{{locator}}
+ In collapsing border model a table does not have padding (see http://www.w3.org/TR/REC-CSS2/tables.html#collapsing-borders), but a non-zero value for padding was found. The padding will be ignored.{{locator}}
+ Either fo:table-rows or fo:table-cells may be children of an {elementName} but not both.{{locator}}
+ This table uses the collapsing border model. In order to resolve borders in an efficient way the table-footer must be known before any table-body is parsed. Either put the footer at the correct place or switch to the separate border model.{{locator}}
+ starts-row/ends-row for fo:table-cells non-applicable for children of an fo:table-row.{{locator}}
+ The column-number or number of cells in the row overflows the number of fo:table-columns specified for the table.{{locator}}
+ {propName} must be 1 or bigger, but got {actualValue}{{locator}}
+ table-layout=\"fixed\" and column-width unspecified => falling back to proportional-column-width(1){{locator}}
+ padding-* properties are not applicable to {elementName}, but a non-zero value for padding was found.{{locator}}
+ {elementName} overlaps in column {column}.
+ {breakBefore,if,break-before,break-after} ignored on {elementName} because of row spanning in progress (See XSL 1.1, {breakBefore,if,7.20.2,7.20.1}){{locator}}
+ Image not found.[ URI: {uri}.]{{locator}}
+ Image not available.[ URI: {uri}.] Reason:[ {reason}][ {e}]{{locator}}
+ I/O error while loading image.[ URI: {uri}.][ Reason: {ioe}]{{locator}}
+ The intrinsic dimensions of an instream-foreign-object could not be determined.{{locator}}
+ Error while handling URI: {uri}. Reason: {e}{{locator}}
+ Some XML content will be ignored. Could not render XML in namespace "{namespaceURI}".[ Reason: {e}]
+ Some XML content will be ignored. No handler defined for XML with namespace "{namespaceURI}".
+ Error while writing an image to the target file.[ Reason: {e}]
+ Temporary file could not be deleted: {tempFile}
+ fo:leader is set to "use-content" but has no content.{{locator}}
+ Line {line} of a paragraph overflows the available area by {overflowLength,choice,50000#{overflowLength} millipoints|50000<more than 50 points}.{{locator}}
+ The contents of table-row {row} are taller than they should be (there is a block-progression-dimension or height constraint on the indicated row). Due to its contents the row grows to {effCellBPD} millipoints, but the row shouldn't get any taller than {maxCellBPD} millipoints.{{locator}}
+ table-layout="fixed" and width="auto", but auto-layout not supported => assuming width="100%".{{locator}}
+ The extent in inline-progression-direction (width) of a {elementName} is bigger than the available space ({effIPD}mpt > {maxIPD}mpt).{{locator}}
+ Adjusting end-indent based on overconstrained geometry rules for {elementName}.{{locator}}
+ Content overflows the viewport of an {elementName} in block-progression direction by {amount} millipoints.{clip,if, Content will be clipped.}{{locator}}
+ Content overflows the viewport of the {elementName} on page {page} in block-progression direction by {amount} millipoints.{clip,if, Content will be clipped.}{{locator}}
+ Flow "{flowName}" does not map to the region-body in page-master "{masterName}". FOP presently does not support this.{{locator}}
+ Subsequences exhausted in page-sequence-master "{pageSequenceMasterName}", {canRecover,if,using previous subsequence,cannot recover}.{{locator}}
+ No subsequences in page-sequence-master "{pageSequenceMasterName}".{{locator}}
+ No simple-page-master matching "{pageMasterName}" in page-sequence-master "{pageSequenceMasterName}".{{locator}}
+ SVG error: {message}
+ SVG alert: {message}
+ SVG info: {message}
+ SVG graphic could not be built. Reason: {e}
+ SVG graphic could not be rendered. Reason: {e}
+ I/O error while writing to target file.[ Reason: {ioe}]
+ {type}: Unresolved ID reference "{id}" found.
+ Page {page}: Unresolved ID reference "{id}" found.
+ Error while deserializing page {page}.[ Reason: {e}]
+ Error while serializing page {page}.[ Reason: {e}]
+ Error while rendering page {page}.[ Reason: {e}]
+ Font "{requested}" not found. Substituting with "{effective}".
+ Unable to load font file: {fontURL}.[ Reason: {e}]
+ Glyph "{ch}" (0x{ch,hex}[, {ch,glyph-name}]) not available in font "{fontName}".
+
diff --git a/src/java/org/apache/fop/events/EventFormatter_de.xml b/src/java/org/apache/fop/events/EventFormatter_de.xml
new file mode 100644
index 000000000..c65d24f73
--- /dev/null
+++ b/src/java/org/apache/fop/events/EventFormatter_de.xml
@@ -0,0 +1,23 @@
+
+
+
+
+ [ (Siehe Position {loc})| (Siehe {#gatherContextInfo})| (Keine Kontextinformationen verfügbar)]
+ In "{elementName}" darf nur ein einziges "{offendingNode}" vorkommen!{{locator}}
+ Dem Element "{elementName}" fehlt ein verlangtes Property "{propertyName}"!{{locator}}
+
diff --git a/src/java/org/apache/fop/events/EventListener.java b/src/java/org/apache/fop/events/EventListener.java
new file mode 100644
index 000000000..f8293aed9
--- /dev/null
+++ b/src/java/org/apache/fop/events/EventListener.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.events;
+
+/**
+ * This interface is implemented by clients who want to listen for events.
+ */
+public interface EventListener extends java.util.EventListener {
+
+ /**
+ * This method is called for each event that is generated. With the event's ID it is possible
+ * to react to certain events. Events can also simply be recorded and presented to a user.
+ * It is possible to throw an (unchecked) exception if the processing needs to be aborted
+ * because some special event occured. This way the client can configure the behaviour of
+ * the observed application.
+ * @param event the event
+ */
+ void processEvent(Event event);
+
+}
diff --git a/src/java/org/apache/fop/events/EventProducer.java b/src/java/org/apache/fop/events/EventProducer.java
new file mode 100644
index 000000000..88da771a4
--- /dev/null
+++ b/src/java/org/apache/fop/events/EventProducer.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.events;
+
+/**
+ * This is a marker interface which all event producer interfaces need to extend. These interfaces
+ * must agree to the following convention:
+ *
+ *
The first parameter of each method must be: Object source
+ *
+ */
+public interface EventProducer {
+
+}
diff --git a/src/java/org/apache/fop/events/FOPEventListenerProxy.java b/src/java/org/apache/fop/events/FOPEventListenerProxy.java
new file mode 100644
index 000000000..d4c237844
--- /dev/null
+++ b/src/java/org/apache/fop/events/FOPEventListenerProxy.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.events;
+
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.events.model.EventSeverity;
+import org.apache.fop.fo.FOValidationEventProducer;
+import org.apache.fop.layoutmgr.BlockLevelEventProducer;
+
+/**
+ * EventListener proxy that inspects all events and adjusts severity levels where necessary.
+ * For validation events, it reacts on each event based on the strict validation setting in
+ * the user agent.
+ * For layout events, it reduces the default severity level if FOP signals that it can recover
+ * from the event.
+ */
+public class FOPEventListenerProxy implements EventListener {
+
+ private static final String FOVALIDATION_EVENT_ID_PREFIX
+ = FOValidationEventProducer.class.getName();
+
+ private static final String BLOCK_LEVEL_EVENT_ID_PREFIX
+ = BlockLevelEventProducer.class.getName();
+
+ private EventListener delegate;
+ private FOUserAgent userAgent;
+
+ /**
+ * Main constructor.
+ * @param delegate the event listener to delegate events to
+ * @param userAgent the FO user agent
+ */
+ public FOPEventListenerProxy(EventListener delegate, FOUserAgent userAgent) {
+ this.delegate = delegate;
+ this.userAgent = userAgent;
+ }
+
+ /** {@inheritDoc} */
+ public synchronized void processEvent(Event event) {
+ if (event.getEventID().startsWith(FOVALIDATION_EVENT_ID_PREFIX)) {
+ Boolean canRecover = (Boolean)event.getParam("canRecover");
+ if (Boolean.TRUE.equals(canRecover) && !userAgent.validateStrictly()) {
+ //Reduce severity if FOP can recover
+ event.setSeverity(EventSeverity.WARN);
+ }
+ } else if (event.getEventID().startsWith(BLOCK_LEVEL_EVENT_ID_PREFIX)) {
+ Boolean canRecover = (Boolean)event.getParam("canRecover");
+ if (Boolean.TRUE.equals(canRecover)) {
+ //Reduce severity if FOP can recover
+ event.setSeverity(EventSeverity.WARN);
+ }
+ }
+ this.delegate.processEvent(event);
+ }
+
+}
diff --git a/src/java/org/apache/fop/events/FOPEventModelFactory.java b/src/java/org/apache/fop/events/FOPEventModelFactory.java
new file mode 100644
index 000000000..5a75042fa
--- /dev/null
+++ b/src/java/org/apache/fop/events/FOPEventModelFactory.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.events;
+
+import org.apache.fop.events.model.AbstractEventModelFactory;
+import org.apache.fop.events.model.EventModel;
+
+/**
+ * Factory for FOP's main event model.
+ */
+public class FOPEventModelFactory extends AbstractEventModelFactory {
+
+ private static final String EVENT_MODEL_FILENAME = "event-model.xml";
+
+ /** {@inheritDoc} */
+ public EventModel createEventModel() {
+ return loadModel(getClass(), EVENT_MODEL_FILENAME);
+ }
+
+}
diff --git a/src/java/org/apache/fop/events/LoggingEventListener.java b/src/java/org/apache/fop/events/LoggingEventListener.java
new file mode 100644
index 000000000..9ba8ed2df
--- /dev/null
+++ b/src/java/org/apache/fop/events/LoggingEventListener.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.events;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.fop.events.model.EventSeverity;
+
+/**
+ * EventListener implementation that redirects events to Commons Logging. The events are
+ * converted to localized messages.
+ */
+public class LoggingEventListener implements EventListener {
+
+ /** Default logger instance */
+ private static Log defaultLog = LogFactory.getLog(LoggingEventListener.class);
+
+ private Log log;
+ private boolean skipFatal;
+
+ /**
+ * Creates an instance logging to the default log category of this class.
+ */
+ public LoggingEventListener() {
+ this(defaultLog);
+ }
+
+ /**
+ * Creates an instance logging to a given logger. Events with fatal severity level will be
+ * skipped.
+ * @param log the target logger
+ */
+ public LoggingEventListener(Log log) {
+ this(log, true);
+ }
+
+ /**
+ * Creates an instance logging to a given logger.
+ * @param log the target logger
+ * @param skipFatal true if events with fatal severity level should be skipped (i.e. not logged)
+ */
+ public LoggingEventListener(Log log, boolean skipFatal) {
+ this.log = log;
+ this.skipFatal = skipFatal;
+ }
+
+ /**
+ * Returns the target logger for this instance.
+ * @return the target logger
+ */
+ public Log getLog() {
+ return this.log;
+ }
+
+ /** {@inheritDoc} */
+ public void processEvent(Event event) {
+ String msg = EventFormatter.format(event);
+ EventSeverity severity = event.getSeverity();
+ if (severity == EventSeverity.INFO) {
+ log.info(msg);
+ } else if (severity == EventSeverity.WARN) {
+ log.warn(msg);
+ } else if (severity == EventSeverity.ERROR) {
+ log.error(msg);
+ } else if (severity == EventSeverity.FATAL) {
+ if (!skipFatal) {
+ log.fatal(msg);
+ }
+ } else {
+ assert false;
+ }
+ }
+
+}
diff --git a/src/java/org/apache/fop/events/PropertyExceptionFactory.java b/src/java/org/apache/fop/events/PropertyExceptionFactory.java
new file mode 100644
index 000000000..667c4a16e
--- /dev/null
+++ b/src/java/org/apache/fop/events/PropertyExceptionFactory.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.events;
+
+import java.util.Locale;
+
+import org.apache.fop.events.EventExceptionManager.ExceptionFactory;
+import org.apache.fop.fo.expr.PropertyException;
+
+/**
+ * Exception factory for {@link PropertyException}.
+ */
+public class PropertyExceptionFactory implements ExceptionFactory {
+
+ /** {@inheritDoc} */
+ public Throwable createException(Event event) {
+ String msg = EventFormatter.format(event, Locale.ENGLISH);
+ PropertyException ex = new PropertyException(msg);
+ if (!Locale.ENGLISH.equals(Locale.getDefault())) {
+ ex.setLocalizedMessage(EventFormatter.format(event));
+ }
+ return ex;
+ }
+
+ /** {@inheritDoc} */
+ public Class getExceptionClass() {
+ return PropertyException.class;
+ }
+
+}
\ No newline at end of file
diff --git a/src/java/org/apache/fop/events/ResourceEventProducer.java b/src/java/org/apache/fop/events/ResourceEventProducer.java
new file mode 100644
index 000000000..21da4f1d7
--- /dev/null
+++ b/src/java/org/apache/fop/events/ResourceEventProducer.java
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.events;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import org.w3c.dom.Document;
+
+import org.xml.sax.Locator;
+
+import org.apache.xmlgraphics.image.loader.ImageException;
+
+/**
+ * Event producer interface for resource events (missing images, fonts etc.).
+ */
+public interface ResourceEventProducer extends EventProducer {
+
+ /**
+ * Provider class for the event producer.
+ */
+ class Provider {
+
+ /**
+ * Returns an event producer.
+ * @param broadcaster the event broadcaster to use
+ * @return the requested event producer
+ */
+ public static ResourceEventProducer get(EventBroadcaster broadcaster) {
+ return (ResourceEventProducer)broadcaster.getEventProducerFor(
+ ResourceEventProducer.class);
+ }
+ }
+
+ /**
+ * Image not found.
+ * @param source the event source
+ * @param uri the original URI of the image
+ * @param fnfe the "file not found" exception
+ * @param loc the location of the error or null
+ * @event.severity ERROR
+ */
+ void imageNotFound(Object source, String uri, FileNotFoundException fnfe, Locator loc);
+
+ /**
+ * Error while processing image.
+ * @param source the event source
+ * @param uri the original URI of the image
+ * @param e the image exception
+ * @param loc the location of the error or null
+ * @event.severity ERROR
+ */
+ void imageError(Object source, String uri, ImageException e, Locator loc);
+
+ /**
+ * I/O error while loading an image.
+ * @param source the event source
+ * @param uri the original URI of the image
+ * @param ioe the I/O exception
+ * @param loc the location of the error or null
+ * @event.severity ERROR
+ */
+ void imageIOError(Object source, String uri, IOException ioe, Locator loc);
+
+ /**
+ * Error while writing/serializing an image to an output format.
+ * @param source the event source
+ * @param e the original exception
+ * @event.severity ERROR
+ */
+ void imageWritingError(Object source, Exception e);
+
+ /**
+ * Error while handling a URI.
+ * @param source the event source
+ * @param uri the original URI of the image
+ * @param e the original exception
+ * @param loc the location of the error or null
+ * @event.severity ERROR
+ */
+ void uriError(Object source, String uri, Exception e, Locator loc);
+
+ /**
+ * Intrinsic size of fo:instream-foreign-object could not be determined.
+ * @param source the event source
+ * @param loc the location of the error or null
+ * @event.severity ERROR
+ */
+ void ifoNoIntrinsicSize(Object source, Locator loc);
+
+ /**
+ * Error processing foreign XML content.
+ * @param source the event source
+ * @param doc the foreign XML
+ * @param namespaceURI the namespace URI of the foreign XML
+ * @param e the original exception
+ * @event.severity ERROR
+ */
+ void foreignXMLProcessingError(Object source, Document doc, String namespaceURI, Exception e);
+
+ /**
+ * No handler for foreign XML content.
+ * @param source the event source
+ * @param doc the foreign XML
+ * @param namespaceURI the namespace URI of the foreign XML
+ * @event.severity ERROR
+ */
+ void foreignXMLNoHandler(Object source, Document doc, String namespaceURI);
+
+ /**
+ * Cannot delete a temporary file.
+ * @param source the event source
+ * @param tempFile the temporary file
+ * @event.severity ERROR
+ */
+ void cannotDeleteTempFile(Object source, File tempFile);
+
+}
diff --git a/src/java/org/apache/fop/events/UnsupportedOperationExceptionFactory.java b/src/java/org/apache/fop/events/UnsupportedOperationExceptionFactory.java
new file mode 100644
index 000000000..06ce8dd25
--- /dev/null
+++ b/src/java/org/apache/fop/events/UnsupportedOperationExceptionFactory.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.events;
+
+import java.util.Locale;
+
+import org.apache.fop.events.EventExceptionManager.ExceptionFactory;
+
+/**
+ * Exception factory for {@link UnsupportedOperationException}.
+ */
+public class UnsupportedOperationExceptionFactory implements ExceptionFactory {
+
+ /** {@inheritDoc} */
+ public Throwable createException(Event event) {
+ String msg = EventFormatter.format(event, Locale.ENGLISH);
+ UnsupportedOperationException ex = new UnsupportedOperationException(msg);
+ return ex;
+ }
+
+ /** {@inheritDoc} */
+ public Class getExceptionClass() {
+ return UnsupportedOperationException.class;
+ }
+
+}
\ No newline at end of file
diff --git a/src/java/org/apache/fop/events/ValidationExceptionFactory.java b/src/java/org/apache/fop/events/ValidationExceptionFactory.java
new file mode 100644
index 000000000..9dba84007
--- /dev/null
+++ b/src/java/org/apache/fop/events/ValidationExceptionFactory.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.events;
+
+import java.util.Locale;
+
+import org.xml.sax.Locator;
+
+import org.apache.fop.events.EventExceptionManager.ExceptionFactory;
+import org.apache.fop.fo.ValidationException;
+
+/**
+ * Exception factory for {@link ValidationException}.
+ */
+public class ValidationExceptionFactory implements ExceptionFactory {
+
+ /** {@inheritDoc} */
+ public Throwable createException(Event event) {
+ Locator loc = (Locator)event.getParam("loc");
+ String msg = EventFormatter.format(event, Locale.ENGLISH);
+ ValidationException ex = new ValidationException(msg, loc);
+ if (!Locale.ENGLISH.equals(Locale.getDefault())) {
+ ex.setLocalizedMessage(EventFormatter.format(event));
+ }
+ return ex;
+ }
+
+ /** {@inheritDoc} */
+ public Class getExceptionClass() {
+ return ValidationException.class;
+ }
+
+
+}
\ No newline at end of file
diff --git a/src/java/org/apache/fop/events/model/AbstractEventModelFactory.java b/src/java/org/apache/fop/events/model/AbstractEventModelFactory.java
new file mode 100644
index 000000000..ee980f34e
--- /dev/null
+++ b/src/java/org/apache/fop/events/model/AbstractEventModelFactory.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.events.model;
+
+import java.io.InputStream;
+import java.util.MissingResourceException;
+
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.commons.io.IOUtils;
+
+import org.apache.fop.events.DefaultEventBroadcaster;
+
+/**
+ * This interface is used to instantiate (load, parse) event models.
+ */
+public abstract class AbstractEventModelFactory implements EventModelFactory {
+
+ /**
+ * Loads an event model and returns its instance.
+ * @param resourceBaseClass base class to use for loading resources
+ * @param resourceName the resource name pointing to the event model to be loaded
+ * @return the newly loaded event model.
+ */
+ public EventModel loadModel(Class resourceBaseClass, String resourceName) {
+ InputStream in = resourceBaseClass.getResourceAsStream(resourceName);
+ if (in == null) {
+ throw new MissingResourceException(
+ "File " + resourceName + " not found",
+ DefaultEventBroadcaster.class.getName(), "");
+ }
+ try {
+ return EventModelParser.parse(new StreamSource(in));
+ } catch (TransformerException e) {
+ throw new MissingResourceException(
+ "Error reading " + resourceName + ": " + e.getMessage(),
+ DefaultEventBroadcaster.class.getName(), "");
+ } finally {
+ IOUtils.closeQuietly(in);
+ }
+ }
+
+}
diff --git a/src/java/org/apache/fop/events/model/EventMethodModel.java b/src/java/org/apache/fop/events/model/EventMethodModel.java
new file mode 100644
index 000000000..930cda53d
--- /dev/null
+++ b/src/java/org/apache/fop/events/model/EventMethodModel.java
@@ -0,0 +1,198 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.events.model;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+
+import org.apache.xmlgraphics.util.XMLizable;
+
+/**
+ * Represents an event method. Each method in an event producer interface will result in one
+ * instance of EventMethodModel.
+ */
+public class EventMethodModel implements Serializable, XMLizable {
+
+ private static final long serialVersionUID = -7548882973341444354L;
+
+ private String methodName;
+ private EventSeverity severity;
+ private List params = new java.util.ArrayList();
+ private String exceptionClass;
+
+ /**
+ * Creates an new instance.
+ * @param methodName the event method's name
+ * @param severity the event severity
+ */
+ public EventMethodModel(String methodName, EventSeverity severity) {
+ this.methodName = methodName;
+ this.severity = severity;
+ }
+
+ /**
+ * Adds a method parameter.
+ * @param param the method parameter
+ */
+ public void addParameter(Parameter param) {
+ this.params.add(param);
+ }
+
+ /**
+ * Adds a method parameter.
+ * @param type the type of the parameter
+ * @param name the name of the parameter
+ * @return the resulting Parameter instance
+ */
+ public Parameter addParameter(Class type, String name) {
+ Parameter param = new Parameter(type, name);
+ addParameter(param);
+ return param;
+ }
+
+ /**
+ * Sets the event method name.
+ * @param name the event name
+ */
+ public void setMethodName(String name) {
+ this.methodName = name;
+ }
+
+ /**
+ * Returns the event method name
+ * @return the event name
+ */
+ public String getMethodName() {
+ return this.methodName;
+ }
+
+ /**
+ * Sets the event's severity level.
+ * @param severity the severity
+ */
+ public void setSeverity(EventSeverity severity) {
+ this.severity = severity;
+ }
+
+ /**
+ * Returns the event's severity level.
+ * @return the severity
+ */
+ public EventSeverity getSeverity() {
+ return this.severity;
+ }
+
+ /**
+ * Returns an unmodifiable list of parameters for this event method.
+ * @return the list of parameters
+ */
+ public List getParameters() {
+ return Collections.unmodifiableList(this.params);
+ }
+
+ /**
+ * Sets the primary exception class for this event method. Note: Not all event methods throw
+ * exceptions!
+ * @param exceptionClass the exception class
+ */
+ public void setExceptionClass(String exceptionClass) {
+ this.exceptionClass = exceptionClass;
+ }
+
+ /**
+ * Returns the primary exception class for this event method. This method returns null if
+ * the event is only informational or just a warning.
+ * @return the primary exception class or null
+ */
+ public String getExceptionClass() {
+ return this.exceptionClass;
+ }
+
+ /** {@inheritDoc} */
+ public void toSAX(ContentHandler handler) throws SAXException {
+ AttributesImpl atts = new AttributesImpl();
+ atts.addAttribute(null, "name", "name", "CDATA", getMethodName());
+ atts.addAttribute(null, "severity", "severity", "CDATA", getSeverity().getName());
+ if (getExceptionClass() != null) {
+ atts.addAttribute(null, "exception", "exception", "CDATA", getExceptionClass());
+ }
+ String elName = "method";
+ handler.startElement(null, elName, elName, atts);
+ Iterator iter = this.params.iterator();
+ while (iter.hasNext()) {
+ ((XMLizable)iter.next()).toSAX(handler);
+ }
+ handler.endElement(null, elName, elName);
+ }
+
+ /**
+ * Represents an event parameter.
+ */
+ public static class Parameter implements Serializable, XMLizable {
+
+ private static final long serialVersionUID = 6062500277953887099L;
+
+ private Class type;
+ private String name;
+
+ /**
+ * Creates a new event parameter.
+ * @param type the parameter type
+ * @param name the parameter name
+ */
+ public Parameter(Class type, String name) {
+ this.type = type;
+ this.name = name;
+ }
+
+ /**
+ * Returns the parameter type.
+ * @return the parameter type
+ */
+ public Class getType() {
+ return this.type;
+ }
+
+ /**
+ * Returns the parameter name.
+ * @return the parameter name
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ /** {@inheritDoc} */
+ public void toSAX(ContentHandler handler) throws SAXException {
+ AttributesImpl atts = new AttributesImpl();
+ atts.addAttribute(null, "type", "type", "CDATA", getType().getName());
+ atts.addAttribute(null, "name", "name", "CDATA", getName());
+ String elName = "parameter";
+ handler.startElement(null, elName, elName, atts);
+ handler.endElement(null, elName, elName);
+ }
+
+ }
+}
diff --git a/src/java/org/apache/fop/events/model/EventModel.java b/src/java/org/apache/fop/events/model/EventModel.java
new file mode 100644
index 000000000..61e221b3b
--- /dev/null
+++ b/src/java/org/apache/fop/events/model/EventModel.java
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.events.model;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Result;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerFactoryConfigurationError;
+import javax.xml.transform.sax.SAXTransformerFactory;
+import javax.xml.transform.sax.TransformerHandler;
+import javax.xml.transform.stream.StreamResult;
+
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+
+import org.apache.xmlgraphics.util.XMLizable;
+
+/**
+ * Represents a whole event model that supports multiple event producers.
+ */
+public class EventModel implements Serializable, XMLizable {
+
+ private static final long serialVersionUID = 7468592614934605082L;
+
+ private Map producers = new java.util.LinkedHashMap();
+
+ /**
+ * Creates a new, empty event model
+ */
+ public EventModel() {
+ }
+
+ /**
+ * Adds the model of an event producer to the event model.
+ * @param producer the event producer model
+ */
+ public void addProducer(EventProducerModel producer) {
+ this.producers.put(producer.getInterfaceName(), producer);
+ }
+
+ /**
+ * Returns an iterator over the contained event producer models.
+ * @return an iterator (Iterator<EventProducerModel>)
+ */
+ public Iterator getProducers() {
+ return this.producers.values().iterator();
+ }
+
+ /**
+ * Returns the model of an event producer with the given interface name.
+ * @param interfaceName the fully qualified name of the event producer
+ * @return the model instance for the event producer (or null if it wasn't found)
+ */
+ public EventProducerModel getProducer(String interfaceName) {
+ return (EventProducerModel)this.producers.get(interfaceName);
+ }
+
+ /**
+ * Returns the model of an event producer with the given interface.
+ * @param clazz the interface of the event producer
+ * @return the model instance for the event producer (or null if it wasn't found)
+ */
+ public EventProducerModel getProducer(Class clazz) {
+ return getProducer(clazz.getName());
+ }
+
+ /** {@inheritDoc} */
+ public void toSAX(ContentHandler handler) throws SAXException {
+ AttributesImpl atts = new AttributesImpl();
+ String elName = "event-model";
+ handler.startElement(null, elName, elName, atts);
+ Iterator iter = getProducers();
+ while (iter.hasNext()) {
+ ((XMLizable)iter.next()).toSAX(handler);
+ }
+ handler.endElement(null, elName, elName);
+ }
+
+ private void writeXMLizable(XMLizable object, File outputFile) throws IOException {
+ Result res = new StreamResult(outputFile);
+
+ try {
+ SAXTransformerFactory tFactory
+ = (SAXTransformerFactory)SAXTransformerFactory.newInstance();
+ TransformerHandler handler = tFactory.newTransformerHandler();
+ Transformer transformer = handler.getTransformer();
+ transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+ handler.setResult(res);
+ handler.startDocument();
+ object.toSAX(handler);
+ handler.endDocument();
+ } catch (TransformerConfigurationException e) {
+ throw new IOException(e.getMessage());
+ } catch (TransformerFactoryConfigurationError e) {
+ throw new IOException(e.getMessage());
+ } catch (SAXException e) {
+ throw new IOException(e.getMessage());
+ }
+ }
+
+ /**
+ * Saves this event model to an XML file.
+ * @param modelFile the target file
+ * @throws IOException if an I/O error occurs
+ */
+ public void saveToXML(File modelFile) throws IOException {
+ writeXMLizable(this, modelFile);
+ }
+
+}
diff --git a/src/java/org/apache/fop/events/model/EventModelFactory.java b/src/java/org/apache/fop/events/model/EventModelFactory.java
new file mode 100644
index 000000000..cd760501c
--- /dev/null
+++ b/src/java/org/apache/fop/events/model/EventModelFactory.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.events.model;
+
+/**
+ * This interface is used to instantiate (load, parse) event models.
+ */
+public interface EventModelFactory {
+
+ /**
+ * Creates a new EventModel instance.
+ * @return the new EventModel instance
+ */
+ EventModel createEventModel();
+
+}
diff --git a/src/java/org/apache/fop/events/model/EventModelParser.java b/src/java/org/apache/fop/events/model/EventModelParser.java
new file mode 100644
index 000000000..600e495c5
--- /dev/null
+++ b/src/java/org/apache/fop/events/model/EventModelParser.java
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.events.model;
+
+import java.util.Stack;
+
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.sax.SAXResult;
+import javax.xml.transform.sax.SAXTransformerFactory;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.fop.util.DefaultErrorListener;
+
+/**
+ * This is a parser for the event model XML.
+ */
+public class EventModelParser {
+
+ /** Logger instance */
+ protected static Log log = LogFactory.getLog(EventModelParser.class);
+
+ private static SAXTransformerFactory tFactory
+ = (SAXTransformerFactory)SAXTransformerFactory.newInstance();
+
+ /**
+ * Parses an event model file into an EventModel instance.
+ * @param src the Source instance pointing to the XML file
+ * @return the created event model structure
+ * @throws TransformerException if an error occurs while parsing the XML file
+ */
+ public static EventModel parse(Source src)
+ throws TransformerException {
+ Transformer transformer = tFactory.newTransformer();
+ transformer.setErrorListener(new DefaultErrorListener(log));
+
+ EventModel model = new EventModel();
+ SAXResult res = new SAXResult(getContentHandler(model));
+
+ transformer.transform(src, res);
+ return model;
+ }
+
+ /**
+ * Creates a new ContentHandler instance that you can send the event model XML to. The parsed
+ * content is accumulated in the model structure.
+ * @param model the EventModel
+ * @return the ContentHandler instance to receive the SAX stream from the XML file
+ */
+ public static ContentHandler getContentHandler(EventModel model) {
+ return new Handler(model);
+ }
+
+ private static class Handler extends DefaultHandler {
+
+ private EventModel model;
+ private Stack objectStack = new Stack();
+
+ public Handler(EventModel model) {
+ this.model = model;
+ }
+
+ /** {@inheritDoc} */
+ public void startElement(String uri, String localName, String qName, Attributes attributes)
+ throws SAXException {
+ try {
+ if ("event-model".equals(localName)) {
+ if (objectStack.size() > 0) {
+ throw new SAXException("event-model must be the root element");
+ }
+ objectStack.push(model);
+ } else if ("producer".equals(localName)) {
+ EventProducerModel producer = new EventProducerModel(
+ attributes.getValue("name"));
+ EventModel parent = (EventModel)objectStack.peek();
+ parent.addProducer(producer);
+ objectStack.push(producer);
+ } else if ("method".equals(localName)) {
+ EventSeverity severity = EventSeverity.valueOf(attributes.getValue("severity"));
+ String ex = attributes.getValue("exception");
+ EventMethodModel method = new EventMethodModel(
+ attributes.getValue("name"), severity);
+ if (ex != null && ex.length() > 0) {
+ method.setExceptionClass(ex);
+ }
+ EventProducerModel parent = (EventProducerModel)objectStack.peek();
+ parent.addMethod(method);
+ objectStack.push(method);
+ } else if ("parameter".equals(localName)) {
+ String className = attributes.getValue("type");
+ Class type;
+ try {
+ type = Class.forName(className);
+ } catch (ClassNotFoundException e) {
+ throw new SAXException("Could not find Class for: " + className, e);
+ }
+ String name = attributes.getValue("name");
+ EventMethodModel parent = (EventMethodModel)objectStack.peek();
+ objectStack.push(parent.addParameter(type, name));
+ } else {
+ throw new SAXException("Invalid element: " + qName);
+ }
+ } catch (ClassCastException cce) {
+ throw new SAXException("XML format error: " + qName, cce);
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void endElement(String uri, String localName, String qName) throws SAXException {
+ objectStack.pop();
+ }
+
+ }
+
+}
diff --git a/src/java/org/apache/fop/events/model/EventProducerModel.java b/src/java/org/apache/fop/events/model/EventProducerModel.java
new file mode 100644
index 000000000..938609cd9
--- /dev/null
+++ b/src/java/org/apache/fop/events/model/EventProducerModel.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.events.model;
+
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+
+import org.apache.xmlgraphics.util.XMLizable;
+
+/**
+ * Represents the model of an event producer with multiple event methods.
+ */
+public class EventProducerModel implements Serializable, XMLizable {
+
+ private static final long serialVersionUID = 122267104123721902L;
+
+ private String interfaceName;
+ private Map methods = new java.util.LinkedHashMap();
+
+ /**
+ * Creates a new instance.
+ * @param interfaceName the fully qualified interface name of the event producer
+ */
+ public EventProducerModel(String interfaceName) {
+ this.interfaceName = interfaceName;
+ }
+
+ /**
+ * Returns the fully qualified interface name of the event producer.
+ * @return the fully qualified interface name
+ */
+ public String getInterfaceName() {
+ return this.interfaceName;
+ }
+
+ /**
+ * Sets the fully qualified interface name of the event producer.
+ * @param name the fully qualified interface name
+ */
+ public void setInterfaceName(String name) {
+ this.interfaceName = name;
+ }
+
+ /**
+ * Adds a model instance of an event method.
+ * @param method the event method model
+ */
+ public void addMethod(EventMethodModel method) {
+ this.methods.put(method.getMethodName(), method);
+ }
+
+ /**
+ * Returns the model instance of an event method for the given method name.
+ * @param methodName the method name
+ * @return the model instance (or null if no method with the given name exists)
+ */
+ public EventMethodModel getMethod(String methodName) {
+ return (EventMethodModel)this.methods.get(methodName);
+ }
+
+ /**
+ * Returns an iterator over the contained event producer methods.
+ * @return an iterator (Iterator<EventMethodModel>)
+ */
+ public Iterator getMethods() {
+ return this.methods.values().iterator();
+ }
+
+ /** {@inheritDoc} */
+ public void toSAX(ContentHandler handler) throws SAXException {
+ AttributesImpl atts = new AttributesImpl();
+ atts.addAttribute(null, "name", "name", "CDATA", getInterfaceName());
+ String elName = "producer";
+ handler.startElement(null, elName, elName, atts);
+ Iterator iter = getMethods();
+ while (iter.hasNext()) {
+ ((XMLizable)iter.next()).toSAX(handler);
+ }
+ handler.endElement(null, elName, elName);
+ }
+
+
+}
diff --git a/src/java/org/apache/fop/events/model/EventSeverity.java b/src/java/org/apache/fop/events/model/EventSeverity.java
new file mode 100644
index 000000000..d37c53c1e
--- /dev/null
+++ b/src/java/org/apache/fop/events/model/EventSeverity.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.events.model;
+
+import java.io.ObjectStreamException;
+import java.io.Serializable;
+
+/** Enumeration class for event severities. */
+public final class EventSeverity implements Serializable {
+
+ private static final long serialVersionUID = 4108175215810759243L;
+
+ /** info level */
+ public static final EventSeverity INFO = new EventSeverity("INFO");
+ /** warning level */
+ public static final EventSeverity WARN = new EventSeverity("WARN");
+ /** error level */
+ public static final EventSeverity ERROR = new EventSeverity("ERROR");
+ /** fatal error */
+ public static final EventSeverity FATAL = new EventSeverity("FATAL");
+
+ private String name;
+
+ /**
+ * Constructor to add a new named item.
+ * @param name Name of the item.
+ */
+ private EventSeverity(String name) {
+ this.name = name;
+ }
+
+ /** @return the name of the enumeration */
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * Returns the enumeration/singleton object based on its name.
+ * @param name the name of the enumeration value
+ * @return the enumeration object
+ */
+ public static EventSeverity valueOf(String name) {
+ if (INFO.getName().equalsIgnoreCase(name)) {
+ return INFO;
+ } else if (WARN.getName().equalsIgnoreCase(name)) {
+ return WARN;
+ } else if (ERROR.getName().equalsIgnoreCase(name)) {
+ return ERROR;
+ } else if (FATAL.getName().equalsIgnoreCase(name)) {
+ return FATAL;
+ } else {
+ throw new IllegalArgumentException("Illegal value for enumeration: " + name);
+ }
+ }
+
+ private Object readResolve() throws ObjectStreamException {
+ return valueOf(getName());
+ }
+
+ /** {@inheritDoc} */
+ public String toString() {
+ return "EventSeverity:" + name;
+ }
+
+}
diff --git a/src/java/org/apache/fop/fo/ElementMapping.java b/src/java/org/apache/fop/fo/ElementMapping.java
index 495983750..502fb07b8 100644
--- a/src/java/org/apache/fop/fo/ElementMapping.java
+++ b/src/java/org/apache/fop/fo/ElementMapping.java
@@ -24,9 +24,10 @@ import java.util.Map;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
-import org.apache.fop.util.QName;
import org.w3c.dom.DOMImplementation;
+import org.apache.xmlgraphics.util.QName;
+
/**
* Abstract base class for Element Mappings (including FO Element Mappings)
* which provide the framework of valid elements and attibutes for a given
diff --git a/src/java/org/apache/fop/fo/ElementMappingRegistry.java b/src/java/org/apache/fop/fo/ElementMappingRegistry.java
index 2ba142203..abc4ec834 100644
--- a/src/java/org/apache/fop/fo/ElementMappingRegistry.java
+++ b/src/java/org/apache/fop/fo/ElementMappingRegistry.java
@@ -23,6 +23,7 @@ import java.util.Iterator;
import java.util.Map;
import org.w3c.dom.DOMImplementation;
+
import org.xml.sax.Locator;
import org.apache.commons.logging.Log;
@@ -144,7 +145,6 @@ public class ElementMappingRegistry {
+ "No element mapping definition found for "
+ FONode.getNodeString(namespaceURI, localName), locator);
} else {
- log.warn("Unknown formatting object " + namespaceURI + "^" + localName);
fobjMaker = new UnknownXMLObj.Maker(namespaceURI);
}
}
diff --git a/src/java/org/apache/fop/fo/FOElementMapping.java b/src/java/org/apache/fop/fo/FOElementMapping.java
index 51ec85d21..62721afeb 100644
--- a/src/java/org/apache/fop/fo/FOElementMapping.java
+++ b/src/java/org/apache/fop/fo/FOElementMapping.java
@@ -22,7 +22,7 @@ package org.apache.fop.fo;
// Java
import java.util.HashMap;
-import org.apache.fop.util.QName;
+import org.apache.xmlgraphics.util.QName;
/**
* Element mapping class for all XSL-FO elements.
diff --git a/src/java/org/apache/fop/fo/FOEventHandler.java b/src/java/org/apache/fop/fo/FOEventHandler.java
index d226cfb6c..5a9a5bb9d 100644
--- a/src/java/org/apache/fop/fo/FOEventHandler.java
+++ b/src/java/org/apache/fop/fo/FOEventHandler.java
@@ -48,6 +48,7 @@ import org.apache.fop.fo.flow.table.TableColumn;
import org.apache.fop.fo.flow.table.TableRow;
import org.apache.fop.fo.pagination.Flow;
import org.apache.fop.fo.pagination.PageSequence;
+import org.apache.fop.fonts.FontEventAdapter;
import org.apache.fop.fonts.FontInfo;
/**
@@ -101,6 +102,7 @@ public abstract class FOEventHandler {
public FOEventHandler(FOUserAgent foUserAgent) {
this.foUserAgent = foUserAgent;
this.fontInfo = new FontInfo();
+ this.fontInfo.setEventListener(new FontEventAdapter(foUserAgent.getEventBroadcaster()));
}
/**
diff --git a/src/java/org/apache/fop/fo/FONode.java b/src/java/org/apache/fop/fo/FONode.java
index f0422e414..197a2482d 100644
--- a/src/java/org/apache/fop/fo/FONode.java
+++ b/src/java/org/apache/fop/fo/FONode.java
@@ -21,6 +21,8 @@ package org.apache.fop.fo;
// Java
import java.util.ListIterator;
+import java.util.Map;
+import java.util.NoSuchElementException;
import org.xml.sax.Attributes;
import org.xml.sax.Locator;
@@ -29,6 +31,8 @@ import org.xml.sax.helpers.LocatorImpl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.xmlgraphics.util.QName;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.fo.extensions.ExtensionAttachment;
@@ -37,6 +41,7 @@ import org.apache.fop.fo.extensions.svg.SVGElementMapping;
import org.apache.fop.fo.pagination.Root;
import org.apache.fop.util.CharUtilities;
import org.apache.fop.util.ContentHandlerFactory;
+import org.apache.fop.util.text.AdvancedMessageFormat.Function;
/**
* Base class for nodes in the XML tree
@@ -143,6 +148,10 @@ public abstract class FONode implements Cloneable {
return parent.getFOEventHandler();
}
+ /**
+ * Indicates whether this node is a child of an fo:marker.
+ * @return true if this node is a child of an fo:marker
+ */
protected boolean inMarker() {
return getFOEventHandler().inMarker();
}
@@ -239,7 +248,7 @@ public abstract class FONode implements Cloneable {
* @param start starting array element to add
* @param end ending array element to add
* @param pList currently applicable PropertyList
- * @param locator location in fo source file.
+ * @param locator location in the XSL-FO source file.
* @throws FOPException if there's a problem during processing
*/
protected void addCharacters(char[] data, int start, int end,
@@ -343,54 +352,50 @@ public abstract class FONode implements Cloneable {
}
/**
- * Helper function to standardize property error exceptions
- * (e.g., not specifying either an internal- or an external-destination
- * property for an FO:link)
- * @param problem text to display that indicates the problem
- * @throws ValidationException the validation error provoked by the method call
+ * Returns an instance of the FOValidationEventProducer.
+ * @return an event producer for FO validation
*/
- protected void attributeError(String problem)
- throws ValidationException {
- throw new ValidationException(errorText(locator) + getName()
- + ", " + problem, locator);
+ protected FOValidationEventProducer getFOValidationEventProducer() {
+ return FOValidationEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
}
-
+
/**
- * Helper function to standardize attribute warnings
- * (e.g., currently unsupported properties)
- * @param problem text to display that indicates the problem
+ * Helper function to standardize "too many" error exceptions
+ * (e.g., two fo:declarations within fo:root)
+ * @param loc org.xml.sax.Locator object of the error (*not* parent node)
+ * @param nsURI namespace URI of incoming invalid node
+ * @param lName local name (i.e., no prefix) of incoming node
+ * @throws ValidationException the validation error provoked by the method call
*/
- public void attributeWarning(String problem) {
- log.warn(warningText(locator) + getName() + ", " + problem);
+ protected void tooManyNodesError(Locator loc, String nsURI, String lName)
+ throws ValidationException {
+ tooManyNodesError(loc, new QName(nsURI, lName));
}
/**
* Helper function to standardize "too many" error exceptions
* (e.g., two fo:declarations within fo:root)
* @param loc org.xml.sax.Locator object of the error (*not* parent node)
- * @param nsURI namespace URI of incoming invalid node
- * @param lName local name (i.e., no prefix) of incoming node
+ * @param offendingNode the qualified name of the offending node
* @throws ValidationException the validation error provoked by the method call
*/
- protected void tooManyNodesError(Locator loc, String nsURI, String lName)
+ protected void tooManyNodesError(Locator loc, QName offendingNode)
throws ValidationException {
- throw new ValidationException(errorText(loc) + "For " + getName()
- + ", only one " + getNodeString(nsURI, lName) + " may be declared.",
- loc);
+ getFOValidationEventProducer().tooManyNodes(this, getName(), offendingNode, loc);
}
/**
* Helper function to standardize "too many" error exceptions
* (e.g., two fo:declarations within fo:root)
- * This overrloaded method helps make the caller code better self-documenting
+ * This overloaded method helps make the caller code better self-documenting
* @param loc org.xml.sax.Locator object of the error (*not* parent node)
* @param offendingNode incoming node that would cause a duplication.
* @throws ValidationException the validation error provoked by the method call
*/
protected void tooManyNodesError(Locator loc, String offendingNode)
throws ValidationException {
- throw new ValidationException(errorText(loc) + "For " + getName()
- + ", only one " + offendingNode + " may be declared.", loc);
+ tooManyNodesError(loc, new QName(FO_URI, offendingNode));
}
/**
@@ -402,9 +407,23 @@ public abstract class FONode implements Cloneable {
* @throws ValidationException the validation error provoked by the method call
*/
protected void nodesOutOfOrderError(Locator loc, String tooLateNode,
- String tooEarlyNode) throws ValidationException {
- throw new ValidationException(errorText(loc) + "For " + getName() + ", " + tooLateNode
- + " must be declared before " + tooEarlyNode + ".", loc);
+ String tooEarlyNode) throws ValidationException {
+ nodesOutOfOrderError(loc, tooLateNode, tooEarlyNode, false);
+ }
+
+ /**
+ * Helper function to standardize "out of order" exceptions
+ * (e.g., fo:layout-master-set appearing after fo:page-sequence)
+ * @param loc org.xml.sax.Locator object of the error (*not* parent node)
+ * @param tooLateNode string name of node that should be earlier in document
+ * @param tooEarlyNode string name of node that should be later in document
+ * @param canRecover indicates whether FOP can recover from this problem and continue working
+ * @throws ValidationException the validation error provoked by the method call
+ */
+ protected void nodesOutOfOrderError(Locator loc, String tooLateNode,
+ String tooEarlyNode, boolean canRecover) throws ValidationException {
+ getFOValidationEventProducer().nodeOutOfOrder(this, getName(),
+ tooLateNode, tooEarlyNode, canRecover, loc);
}
/**
@@ -417,24 +436,24 @@ public abstract class FONode implements Cloneable {
*/
protected void invalidChildError(Locator loc, String nsURI, String lName)
throws ValidationException {
- invalidChildError(loc, nsURI, lName, null);
+ invalidChildError(loc, getName(), nsURI, lName, null);
}
/**
* Helper function to return "invalid child" exceptions with more
* complex validation rules (i.e., needing more explanation of the problem)
* @param loc org.xml.sax.Locator object of the error (*not* parent node)
+ * @param parentName the name of the parent element
* @param nsURI namespace URI of incoming invalid node
* @param lName local name (i.e., no prefix) of incoming node
- * @param ruleViolated text explanation of problem
+ * @param ruleViolated name of the rule violated (used to lookup a resource in a bundle)
* @throws ValidationException the validation error provoked by the method call
*/
- protected void invalidChildError(Locator loc, String nsURI, String lName,
+ protected void invalidChildError(Locator loc, String parentName, String nsURI, String lName,
String ruleViolated)
throws ValidationException {
- throw new ValidationException(errorText(loc) + getNodeString(nsURI, lName)
- + " is not a valid child element of " + getName()
- + ((ruleViolated != null) ? ": " + ruleViolated : "."), loc);
+ getFOValidationEventProducer().invalidChild(this, parentName,
+ new QName(nsURI, lName), ruleViolated, loc);
}
/**
@@ -446,9 +465,22 @@ public abstract class FONode implements Cloneable {
*/
protected void missingChildElementError(String contentModel)
throws ValidationException {
- throw new ValidationException(errorText(locator) + getName()
- + " is missing child elements. \nRequired Content Model: "
- + contentModel, locator);
+ getFOValidationEventProducer().missingChildElement(this, getName(),
+ contentModel, false, locator);
+ }
+
+ /**
+ * Helper function to throw an error caused by missing mandatory child elements.
+ * E.g., fo:layout-master-set not having any page-master child element.
+ * @param contentModel The XSL Content Model for the fo: object or a similar description
+ * indicating the necessary child elements.
+ * @param canRecover indicates whether FOP can recover from this problem and continue working
+ * @throws ValidationException the validation error provoked by the method call
+ */
+ protected void missingChildElementError(String contentModel, boolean canRecover)
+ throws ValidationException {
+ getFOValidationEventProducer().missingChildElement(this, getName(),
+ contentModel, canRecover, locator);
}
/**
@@ -458,8 +490,7 @@ public abstract class FONode implements Cloneable {
*/
protected void missingPropertyError(String propertyName)
throws ValidationException {
- throw new ValidationException(errorText(locator) + getName()
- + " is missing required \"" + propertyName + "\" property.", locator);
+ getFOValidationEventProducer().missingProperty(this, getName(), propertyName, locator);
}
/**
@@ -513,9 +544,10 @@ public abstract class FONode implements Cloneable {
/**
* Returns a String containing as much context information as possible about a node. Call
- * this methods only in exceptional conditions because this method may perform quite extensive
+ * this method only in exceptional conditions because this method may perform quite extensive
* information gathering inside the FO tree.
- * @return a String containing
+ * @return a String containing context information
+ * @deprecated Not localized! Should rename getContextInfoAlt() to getContextInfo() when done!
*/
public String getContextInfo() {
StringBuffer sb = new StringBuffer();
@@ -542,6 +574,54 @@ public abstract class FONode implements Cloneable {
return sb.toString();
}
+ /**
+ * Returns a String containing as some context information about a node. It does not take the
+ * locator into consideration and returns null if no useful context information can be found.
+ * Call this method only in exceptional conditions because this method may perform quite
+ * extensive information gathering inside the FO tree. All text returned by this method that
+ * is not extracted from document content needs to be locale-independent.
+ * @return a String containing context information
+ */
+ protected String getContextInfoAlt() {
+ String s = gatherContextInfo();
+ if (s != null) {
+ StringBuffer sb = new StringBuffer();
+ if (getLocalName() != null) {
+ sb.append(getName());
+ sb.append(", ");
+ }
+ sb.append("\"");
+ sb.append(s);
+ sb.append("\"");
+ return sb.toString();
+ } else {
+ return null;
+ }
+ }
+
+ /** Function for AdvancedMessageFormat to retrieve context info from an FONode. */
+ public static class GatherContextInfoFunction implements Function {
+
+ /** {@inheritDoc} */
+ public Object evaluate(Map params) {
+ Object obj = params.get("source");
+ if (obj instanceof PropertyList) {
+ PropertyList propList = (PropertyList)obj;
+ obj = propList.getFObj();
+ }
+ if (obj instanceof FONode) {
+ FONode node = (FONode)obj;
+ return node.getContextInfoAlt();
+ }
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ public Object getName() {
+ return "gatherContextInfo";
+ }
+ }
+
/**
* Gathers context information for the getContextInfo() method.
* @return the collected context information or null, if none is available
@@ -687,7 +767,7 @@ public abstract class FONode implements Cloneable {
* of child nodes
* @return the parent node
*/
- public FObj parentNode();
+ FObj parentNode();
/**
* Convenience method with return type of FONode
@@ -695,7 +775,7 @@ public abstract class FONode implements Cloneable {
* (FONode) next();)
* @return the next node (if any), as a type FONode
*/
- public FONode nextNode();
+ FONode nextNode();
/**
* Convenience method with return type of FONode
@@ -703,7 +783,7 @@ public abstract class FONode implements Cloneable {
* (FONode) previous();)
* @return the previous node (if any), as a type FONode
*/
- public FONode previousNode();
+ FONode previousNode();
/**
* Returns the first node in the list, and decreases the index,
@@ -711,7 +791,7 @@ public abstract class FONode implements Cloneable {
* @return the first node in the list
* @throws NoSuchElementException if the list is empty
*/
- public FONode firstNode();
+ FONode firstNode();
/**
* Returns the last node in the list, and advances the
@@ -720,7 +800,7 @@ public abstract class FONode implements Cloneable {
* @return the last node in the list
* @throws NoSuchElementException if the list is empty
*/
- public FONode lastNode();
+ FONode lastNode();
}
}
diff --git a/src/java/org/apache/fop/fo/FOText.java b/src/java/org/apache/fop/fo/FOText.java
index 6d1ac417f..99d37dba9 100644
--- a/src/java/org/apache/fop/fo/FOText.java
+++ b/src/java/org/apache/fop/fo/FOText.java
@@ -19,11 +19,11 @@
package org.apache.fop.fo;
-// Java
import java.awt.Color;
import java.util.NoSuchElementException;
-// FOP
+import org.xml.sax.Locator;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.datatypes.Length;
import org.apache.fop.fo.flow.Block;
@@ -34,9 +34,6 @@ import org.apache.fop.fo.properties.KeepProperty;
import org.apache.fop.fo.properties.Property;
import org.apache.fop.fo.properties.SpaceProperty;
-// SAX
-import org.xml.sax.Locator;
-
/**
* A text node (PCDATA) in the formatting object tree.
*
@@ -396,7 +393,7 @@ public class FOText extends FONode {
return ca[i];
}
default:
- log.warn("Invalid text-tranform value: " + textTransform);
+ assert false; //should never happen as the property subsystem catches that case
return ca[i];
}
}
diff --git a/src/java/org/apache/fop/fo/FOTreeBuilder.java b/src/java/org/apache/fop/fo/FOTreeBuilder.java
index d02a058fe..84abc4b8b 100644
--- a/src/java/org/apache/fop/fo/FOTreeBuilder.java
+++ b/src/java/org/apache/fop/fo/FOTreeBuilder.java
@@ -31,6 +31,8 @@ import org.xml.sax.helpers.DefaultHandler;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.xmlgraphics.util.QName;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.FormattingResults;
@@ -130,6 +132,7 @@ public class FOTreeBuilder extends DefaultHandler {
throw new IllegalStateException("FOTreeBuilder (and the Fop class) cannot be reused."
+ " Please instantiate a new instance.");
}
+
used = true;
empty = true;
rootFObj = null; // allows FOTreeBuilder to be reused
@@ -146,8 +149,10 @@ public class FOTreeBuilder extends DefaultHandler {
public void endDocument() throws SAXException {
this.delegate.endDocument();
if (this.rootFObj == null && empty) {
- throw new ValidationException(
- "Document is empty (something might be wrong with your XSLT stylesheet).");
+ FOValidationEventProducer eventProducer
+ = FOValidationEventProducer.Provider.get(
+ foEventHandler.getUserAgent().getEventBroadcaster());
+ eventProducer.emptyDocument(this);
}
rootFObj = null;
if (log.isDebugEnabled()) {
@@ -178,18 +183,6 @@ public class FOTreeBuilder extends DefaultHandler {
}
}
- /**
- * Finds the {@link Maker} used to create {@link FONode} objects of a particular type
- *
- * @param namespaceURI URI for the namespace of the element
- * @param localName name of the Element
- * @return the ElementMapping.Maker that can create an FO object for this element
- * @throws FOPException if a Maker could not be found for a bound namespace.
- */
- private Maker findFOMaker(String namespaceURI, String localName) throws FOPException {
- return elementMappingRegistry.findFOMaker(namespaceURI, localName, locator);
- }
-
/** {@inheritDoc} */
public void warning(SAXParseException e) {
log.warn(e.getLocalizedMessage());
@@ -258,22 +251,21 @@ public class FOTreeBuilder extends DefaultHandler {
if (rootFObj == null) {
empty = false;
if (!namespaceURI.equals(FOElementMapping.URI)
- || !localName.equals("root")) {
- throw new ValidationException(
- "Error: First element must be the fo:root formatting object. "
- + "Found " + FONode.getNodeString(namespaceURI, localName)
- + " instead."
- + " Please make sure you're producing a valid XSL-FO document.");
+ || !localName.equals("root")) {
+ FOValidationEventProducer eventProducer
+ = FOValidationEventProducer.Provider.get(
+ foEventHandler.getUserAgent().getEventBroadcaster());
+ eventProducer.invalidFORoot(this, FONode.getNodeString(namespaceURI, localName),
+ getEffectiveLocator());
}
} else { // check that incoming node is valid for currentFObj
- if (namespaceURI.equals(FOElementMapping.URI)
- || namespaceURI.equals(ExtensionElementMapping.URI)) {
+ if (currentFObj.getNamespaceURI().equals(FOElementMapping.URI)
+ || currentFObj.getNamespaceURI().equals(ExtensionElementMapping.URI)) {
currentFObj.validateChildNode(locator, namespaceURI, localName);
}
}
- ElementMapping.Maker fobjMaker =
- findFOMaker(namespaceURI, localName);
+ ElementMapping.Maker fobjMaker = findFOMaker(namespaceURI, localName);
try {
foNode = fobjMaker.make(currentFObj);
@@ -342,8 +334,7 @@ public class FOTreeBuilder extends DefaultHandler {
if (currentPropertyList != null
&& currentPropertyList.getFObj() == currentFObj
&& !foEventHandler.inMarker()) {
- currentPropertyList =
- currentPropertyList.getParentPropertyList();
+ currentPropertyList = currentPropertyList.getParentPropertyList();
}
if (currentFObj.getNameId() == Constants.FO_MARKER) {
@@ -373,7 +364,29 @@ public class FOTreeBuilder extends DefaultHandler {
/** {@inheritDoc} */
public void endDocument() throws SAXException {
currentFObj = null;
- }
+ }
+
+ /**
+ * Finds the {@link Maker} used to create {@link FONode} objects of a particular type
+ *
+ * @param namespaceURI URI for the namespace of the element
+ * @param localName name of the Element
+ * @return the ElementMapping.Maker that can create an FO object for this element
+ * @throws FOPException if a Maker could not be found for a bound namespace.
+ */
+ private Maker findFOMaker(String namespaceURI, String localName) throws FOPException {
+ Maker maker = elementMappingRegistry.findFOMaker(namespaceURI, localName, locator);
+ if (maker instanceof UnknownXMLObj.Maker) {
+ FOValidationEventProducer eventProducer
+ = FOValidationEventProducer.Provider.get(
+ foEventHandler.getUserAgent().getEventBroadcaster());
+ eventProducer.unknownFormattingObject(this, currentFObj.getName(),
+ new QName(namespaceURI, localName),
+ getEffectiveLocator());
+ }
+ return maker;
+ }
+
}
}
diff --git a/src/java/org/apache/fop/fo/FOValidationEventProducer.java b/src/java/org/apache/fop/fo/FOValidationEventProducer.java
new file mode 100644
index 000000000..aa7b14941
--- /dev/null
+++ b/src/java/org/apache/fop/fo/FOValidationEventProducer.java
@@ -0,0 +1,348 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.fo;
+
+import org.xml.sax.Locator;
+
+import org.apache.xmlgraphics.util.QName;
+
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.events.EventBroadcaster;
+import org.apache.fop.events.EventProducer;
+import org.apache.fop.fo.expr.PropertyException;
+
+/**
+ * Event producer interface for XSL-FO validation messages.
+ */
+public interface FOValidationEventProducer extends EventProducer {
+
+ /**
+ * Provider class for the event producer.
+ */
+ class Provider {
+
+ /**
+ * Returns an event producer.
+ * @param broadcaster the event broadcaster to use
+ * @return the event producer
+ */
+ public static FOValidationEventProducer get(EventBroadcaster broadcaster) {
+ return (FOValidationEventProducer)broadcaster.getEventProducerFor(
+ FOValidationEventProducer.class);
+ }
+ }
+
+ /**
+ * Too many child nodes.
+ * @param source the event source
+ * @param elementName the name of the context node
+ * @param offendingNode the offending node
+ * @param loc the location of the error or null
+ * @throws ValidationException the validation error provoked by the method call
+ * @event.severity FATAL
+ */
+ void tooManyNodes(Object source, String elementName, QName offendingNode,
+ Locator loc) throws ValidationException;
+
+ /**
+ * The node order is wrong.
+ * @param source the event source
+ * @param elementName the name of the context node
+ * @param tooLateNode string name of node that should be earlier in document
+ * @param tooEarlyNode string name of node that should be later in document
+ * @param canRecover indicates whether FOP can recover from this problem and continue working
+ * @param loc the location of the error or null
+ * @throws ValidationException the validation error provoked by the method call
+ */
+ void nodeOutOfOrder(Object source, String elementName,
+ String tooLateNode, String tooEarlyNode, boolean canRecover,
+ Locator loc) throws ValidationException;
+
+ /**
+ * An invalid child was encountered.
+ * @param source the event source
+ * @param elementName the name of the context node
+ * @param offendingNode the offending node
+ * @param ruleViolated the rule that was violated or null
+ * @param loc the location of the error or null
+ * @throws ValidationException the validation error provoked by the method call
+ */
+ void invalidChild(Object source, String elementName, QName offendingNode, String ruleViolated,
+ Locator loc) throws ValidationException;
+
+ /**
+ * A required child element is missing.
+ * @param source the event source
+ * @param elementName the name of the context node
+ * @param contentModel the expected content model
+ * @param canRecover indicates whether FOP can recover from this problem and continue working
+ * @param loc the location of the error or null
+ * @throws ValidationException the validation error provoked by the method call
+ * @event.severity FATAL
+ */
+ void missingChildElement(Object source, String elementName,
+ String contentModel, boolean canRecover,
+ Locator loc) throws ValidationException;
+
+ /**
+ * An element is missing a required property.
+ * @param source the event source
+ * @param elementName the name of the context node
+ * @param propertyName the name of the missing property
+ * @param loc the location of the error or null
+ * @throws ValidationException the validation error provoked by the method call
+ * @event.severity FATAL
+ */
+ void missingProperty(Object source, String elementName, String propertyName,
+ Locator loc) throws ValidationException;
+
+ /**
+ * An id was used twice in a document.
+ * @param source the event source
+ * @param elementName the name of the context node
+ * @param id the id that was reused
+ * @param canRecover indicates whether FOP can recover from this problem and continue working
+ * @param loc the location of the error or null
+ * @throws ValidationException the validation error provoked by the method call
+ * @event.severity FATAL
+ */
+ void idNotUnique(Object source, String elementName, String id, boolean canRecover,
+ Locator loc) throws ValidationException;
+
+ /**
+ * There are multiple color profiles defined with the same name.
+ * @param source the event source
+ * @param elementName the name of the context node
+ * @param name the duplicate color profile name
+ * @param loc the location of the error or null
+ * @event.severity WARN
+ */
+ void colorProfileNameNotUnique(Object source, String elementName, String name,
+ Locator loc);
+
+ /**
+ * There are multiple page masters defined with the same name.
+ * @param source the event source
+ * @param elementName the name of the context node
+ * @param name the duplicate page master name
+ * @param loc the location of the error or null
+ * @throws ValidationException the validation error provoked by the method call
+ * @event.severity FATAL
+ */
+ void masterNameNotUnique(Object source, String elementName, String name,
+ Locator loc) throws ValidationException;
+
+ /**
+ * A marker is not an initial child on a node.
+ * @param source the event source
+ * @param elementName the name of the context node
+ * @param mcname the marker class name
+ * @param loc the location of the error or null
+ * @event.severity ERROR
+ */
+ void markerNotInitialChild(Object source, String elementName, String mcname, Locator loc);
+
+ /**
+ * A marker class name is not unique within the same parent.
+ * @param source the event source
+ * @param elementName the name of the context node
+ * @param mcname the marker class name
+ * @param loc the location of the error or null
+ * @event.severity ERROR
+ */
+ void markerNotUniqueForSameParent(Object source, String elementName,
+ String mcname, Locator loc);
+
+ /**
+ * An invalid property was found.
+ * @param source the event source
+ * @param elementName the name of the context node
+ * @param attr the invalid attribute
+ * @param canRecover indicates whether FOP can recover from this problem and continue working
+ * @param loc the location of the error or null
+ * @throws ValidationException the validation error provoked by the method call
+ * @event.severity FATAL
+ */
+ void invalidProperty(Object source, String elementName, QName attr, boolean canRecover,
+ Locator loc) throws ValidationException;
+
+ /**
+ * An invalid property value was encountered.
+ * @param source the event source
+ * @param elementName the name of the context node
+ * @param propName the property name
+ * @param propValue the property value
+ * @param e the property exception caused by the invalid value
+ * @param loc the location of the error or null
+ * @event.severity ERROR
+ */
+ void invalidPropertyValue(Object source, String elementName,
+ String propName, String propValue, PropertyException e,
+ Locator loc);
+
+ /**
+ * A feature is not supported, yet.
+ * @param source the event source
+ * @param elementName the name of the context node
+ * @param feature the unsupported feature
+ * @param loc the location of the error or null
+ * @event.severity WARN
+ */
+ void unimplementedFeature(Object source, String elementName, String feature,
+ Locator loc);
+
+ /**
+ * Missing internal-/external-destination on basic-link or bookmark.
+ * @param source the event source
+ * @param elementName the name of the context node
+ * @param loc the location of the error or null
+ * @throws ValidationException the validation error provoked by the method call
+ * @event.severity FATAL
+ */
+ void missingLinkDestination(Object source, String elementName, Locator loc)
+ throws ValidationException;
+
+ /**
+ * Indicates a problem while cloning a marker (ex. due to invalid property values).
+ * @param source the event source
+ * @param markerClassName the "marker-class-name" of the marker
+ * @param fe the FOP exception that cause this problem
+ * @param loc the location of the error or null
+ * @event.severity ERROR
+ */
+ void markerCloningFailed(Object source, String markerClassName, FOPException fe, Locator loc);
+
+ /**
+ * A region name is mapped to multiple region classes.
+ * @param source the event source
+ * @param regionName the region name
+ * @param defaultRegionClass1 the first default region class
+ * @param defaultRegionClass2 the second default region class
+ * @param loc the location of the error or null
+ * @throws ValidationException the validation error provoked by the method call
+ * @event.severity FATAL
+ */
+ void regionNameMappedToMultipleRegionClasses(Object source, String regionName,
+ String defaultRegionClass1, String defaultRegionClass2, Locator loc)
+ throws ValidationException;
+
+ /**
+ * There are multiple flows with the same name.
+ * @param source the event source
+ * @param elementName the name of the context node
+ * @param flowName the flow name
+ * @param loc the location of the error or null
+ * @throws ValidationException the validation error provoked by the method call
+ * @event.severity FATAL
+ */
+ void duplicateFlowNameInPageSequence(Object source, String elementName, String flowName,
+ Locator loc) throws ValidationException;
+
+ /**
+ * A flow name could not be mapped to a region.
+ * @param source the event source
+ * @param elementName the name of the context node
+ * @param flowName the flow name
+ * @param loc the location of the error or null
+ * @throws ValidationException the validation error provoked by the method call
+ * @event.severity FATAL
+ */
+ void flowNameNotMapped(Object source, String elementName, String flowName,
+ Locator loc) throws ValidationException;
+
+ /**
+ * A page master could not be found.
+ * @param source the event source
+ * @param elementName the name of the context node
+ * @param masterReference the page master reference
+ * @param loc the location of the error or null
+ * @throws ValidationException the validation error provoked by the method call
+ * @event.severity FATAL
+ */
+ void masterNotFound(Object source, String elementName, String masterReference,
+ Locator loc) throws ValidationException;
+
+ /**
+ * An illegal region name was used.
+ * @param source the event source
+ * @param elementName the name of the context node
+ * @param regionName the region name
+ * @param loc the location of the error or null
+ * @throws ValidationException the validation error provoked by the method call
+ * @event.severity FATAL
+ */
+ void illegalRegionName(Object source, String elementName, String regionName,
+ Locator loc) throws ValidationException;
+
+ /**
+ * A non-zero border and/or padding has been encountered on a region.
+ * @param source the event source
+ * @param elementName the name of the context node
+ * @param regionName the region name
+ * @param canRecover indicates whether FOP can recover from this problem and continue working
+ * @param loc the location of the error or null
+ * @throws ValidationException the validation error provoked by the method call
+ * @event.severity FATAL
+ */
+ void nonZeroBorderPaddingOnRegion(Object source, String elementName, String regionName,
+ boolean canRecover, Locator loc) throws ValidationException;
+
+ /**
+ * If overflow property is set to "scroll", a column-count other than "1" may not be specified.
+ * @param source the event source
+ * @param elementName the name of the context node
+ * @param loc the location of the error or null
+ * @throws ValidationException the validation error provoked by the method call
+ * @event.severity FATAL
+ */
+ void columnCountErrorOnRegionBodyOverflowScroll(Object source, String elementName,
+ Locator loc) throws ValidationException;
+
+ /**
+ * fo:root must be root.
+ * @param source the event source
+ * @param elementName the name of the context node
+ * @param loc the location of the error or null
+ * @throws ValidationException the validation error provoked by the method call
+ * @event.severity FATAL
+ */
+ void invalidFORoot(Object source, String elementName,
+ Locator loc) throws ValidationException;
+
+ /**
+ * No FO document was found.
+ * @param source the event source
+ * @throws ValidationException the validation error provoked by the method call
+ * @event.severity FATAL
+ */
+ void emptyDocument(Object source) throws ValidationException;
+
+ /**
+ * An unknown/unsupported formatting object has been encountered.
+ * @param source the event source
+ * @param elementName the name of the context node
+ * @param offendingNode the offending node
+ * @param loc the location of the error or null
+ * @event.severity WARN
+ */
+ void unknownFormattingObject(Object source, String elementName,
+ QName offendingNode, Locator loc);
+
+}
diff --git a/src/java/org/apache/fop/fo/FObj.java b/src/java/org/apache/fop/fo/FObj.java
index b2587df2d..a03a351e0 100644
--- a/src/java/org/apache/fop/fo/FObj.java
+++ b/src/java/org/apache/fop/fo/FObj.java
@@ -27,13 +27,15 @@ import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+
+import org.apache.xmlgraphics.util.QName;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.extensions.ExtensionAttachment;
import org.apache.fop.fo.flow.Marker;
import org.apache.fop.fo.properties.PropertyMaker;
-import org.apache.fop.util.QName;
-import org.xml.sax.Attributes;
-import org.xml.sax.Locator;
/**
* Base class for representation of formatting objects and their processing.
@@ -171,25 +173,7 @@ public abstract class FObj extends FONode implements Constants {
if (!idrefs.contains(id)) {
idrefs.add(id);
} else {
- if (getUserAgent().validateStrictly()) {
- throw new ValidationException("Property id \"" + id
- + "\" previously used; id values must be unique"
- + " in document.", locator);
- } else {
- if (log.isWarnEnabled()) {
- StringBuffer msg = new StringBuffer();
- msg.append("Found non-unique id on ").append(getName());
- if (locator.getLineNumber() != -1) {
- msg.append(" (at ").append(locator.getLineNumber())
- .append("/").append(locator.getColumnNumber())
- .append(")");
- }
- msg.append("\nAny reference to it will be considered "
- + "a reference to the first occurrence "
- + "in the document.");
- log.warn(msg);
- }
- }
+ getFOValidationEventProducer().idNotUnique(this, getName(), id, true, locator);
}
}
}
@@ -283,16 +267,22 @@ public abstract class FObj extends FONode implements Constants {
return false;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public FONodeIterator getChildNodes() {
- if (firstChild != null) {
+ if (hasChildren()) {
return new FObjIterator(this);
}
return null;
}
+ /**
+ * Indicates whether this formatting object has children.
+ * @return true if there are children
+ */
+ public boolean hasChildren() {
+ return this.firstChild != null;
+ }
+
/**
* Return an iterator over the object's childNodes starting
* at the passed-in node (= first call to iterator.next() will
@@ -348,8 +338,8 @@ public abstract class FObj extends FONode implements Constants {
if (node instanceof FObj
|| (node instanceof FOText
&& ((FOText) node).willCreateArea())) {
- log.error(
- "fo:marker must be an initial child: " + mcname);
+ getFOValidationEventProducer().markerNotInitialChild(this, getName(),
+ mcname, locator);
return;
} else if (node instanceof FOText) {
iter.remove();
@@ -363,8 +353,8 @@ public abstract class FObj extends FONode implements Constants {
if (!markers.containsKey(mcname)) {
markers.put(mcname, marker);
} else {
- log.error("fo:marker 'marker-class-name' "
- + "must be unique for same parent: " + mcname);
+ getFOValidationEventProducer().markerNotUniqueForSameParent(this, getName(),
+ mcname, locator);
}
}
@@ -382,6 +372,33 @@ public abstract class FObj extends FONode implements Constants {
return markers;
}
+ /** {@inheritDoc} */
+ protected String getContextInfoAlt() {
+ StringBuffer sb = new StringBuffer();
+ if (getLocalName() != null) {
+ sb.append(getName());
+ sb.append(", ");
+ }
+ if (hasId()) {
+ sb.append("id=").append(getId());
+ return sb.toString();
+ }
+ String s = gatherContextInfo();
+ if (s != null) {
+ sb.append("\"");
+ if (s.length() < 32) {
+ sb.append(s);
+ } else {
+ sb.append(s.substring(0, 32));
+ sb.append("...");
+ }
+ sb.append("\"");
+ return sb.toString();
+ } else {
+ return null;
+ }
+ }
+
/** {@inheritDoc} */
protected String gatherContextInfo() {
if (getLocator() != null) {
diff --git a/src/java/org/apache/fop/fo/PropertyList.java b/src/java/org/apache/fop/fo/PropertyList.java
index 3d050efed..b6766bfe9 100644
--- a/src/java/org/apache/fop/fo/PropertyList.java
+++ b/src/java/org/apache/fop/fo/PropertyList.java
@@ -20,13 +20,13 @@
package org.apache.fop.fo;
// Java
-import java.text.MessageFormat;
-
import org.xml.sax.Attributes;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.xmlgraphics.util.QName;
+
import org.apache.fop.apps.FopFactory;
import org.apache.fop.fo.expr.PropertyException;
import org.apache.fop.fo.properties.CommonAbsolutePosition;
@@ -41,7 +41,6 @@ import org.apache.fop.fo.properties.CommonRelativePosition;
import org.apache.fop.fo.properties.CommonTextDecoration;
import org.apache.fop.fo.properties.Property;
import org.apache.fop.fo.properties.PropertyMaker;
-import org.apache.fop.util.QName;
/**
* Class containing the collection of properties for a given FObj.
@@ -150,7 +149,7 @@ public abstract class PropertyList {
* the default value.
* @param propId The Constants ID of the property whose value is desired.
* @return the Property corresponding to that name
- * @throws PropertyException ...
+ * @throws PropertyException if there is a problem evaluating the property
*/
public Property get(int propId) throws PropertyException {
return get(propId, true, true);
@@ -166,7 +165,7 @@ public abstract class PropertyList {
* value is needed
* @param bTryDefault true when the default value may be used as a last resort
* @return the property
- * @throws PropertyException ...
+ * @throws PropertyException if there is a problem evaluating the property
*/
public Property get(int propId, boolean bTryInherit,
boolean bTryDefault) throws PropertyException {
@@ -321,20 +320,18 @@ public abstract class PropertyList {
} else if (!factory.isNamespaceIgnored(attributeNS)) {
ElementMapping mapping = factory.getElementMappingRegistry().getElementMapping(
attributeNS);
+ QName attr = new QName(attributeNS, attributeName);
if (mapping != null) {
- QName attName = new QName(attributeNS, attributeName);
- if (mapping.isAttributeProperty(attName)
+ if (mapping.isAttributeProperty(attr)
&& mapping.getStandardPrefix() != null) {
convertAttributeToProperty(attributes,
- mapping.getStandardPrefix() + ":" + attName.getLocalName(),
+ mapping.getStandardPrefix() + ":" + attr.getLocalName(),
attributeValue);
} else {
- getFObj().addForeignAttribute(attName, attributeValue);
+ getFObj().addForeignAttribute(attr, attributeValue);
}
} else {
- handleInvalidProperty(
- "Error processing foreign attribute: "
- + attributeNS + "/@" + attributeName, attributeName);
+ handleInvalidProperty(attr);
}
}
}
@@ -345,11 +342,8 @@ public abstract class PropertyList {
* @param propertyName the property name to check
* @return true if the base property name and the subproperty name (if any)
* can be correctly mapped to an id
- * @throws ValidationException in case the property name
- * is invalid for the FO namespace
*/
- protected boolean isValidPropertyName(String propertyName)
- throws ValidationException {
+ protected boolean isValidPropertyName(String propertyName) {
int propId = FOPropertyMapping.getPropertyId(
findBasePropertyName(propertyName));
@@ -359,9 +353,6 @@ public abstract class PropertyList {
if (propId == -1
|| (subpropId == -1
&& findSubPropertyName(propertyName) != null)) {
- String errorMessage = MessageFormat.format(
- "Invalid property name ''{0}''.", new Object[] {propertyName});
- handleInvalidProperty(errorMessage, propertyName);
return false;
}
return true;
@@ -382,19 +373,23 @@ public abstract class PropertyList {
if (attributeValue != null) {
- if (!isValidPropertyName(attributeName)) {
- //will log an error or throw an exception
+ if (attributeName.startsWith("xmlns:")) {
+ //Ignore namespace declarations
return;
}
- FObj parentFO = fobj.findNearestAncestorFObj();
-
/* Handle "compound" properties, ex. space-before.minimum */
String basePropertyName = findBasePropertyName(attributeName);
String subPropertyName = findSubPropertyName(attributeName);
int propId = FOPropertyMapping.getPropertyId(basePropertyName);
int subpropId = FOPropertyMapping.getSubPropertyId(subPropertyName);
+
+ if (propId == -1
+ || (subpropId == -1 && subPropertyName != null)) {
+ handleInvalidProperty(new QName(null, attributeName));
+ }
+ FObj parentFO = fobj.findNearestAncestorFObj();
PropertyMaker propertyMaker = findMaker(propId);
if (propertyMaker == null) {
@@ -417,8 +412,8 @@ public abstract class PropertyList {
}
prop = propertyMaker.make(this, attributeValue, parentFO);
} else { // e.g. "leader-length.maximum"
- Property baseProperty =
- findBaseProperty(attributes, parentFO, propId,
+ Property baseProperty
+ = findBaseProperty(attributes, parentFO, propId,
basePropertyName, propertyMaker);
prop = propertyMaker.make(baseProperty, subpropId,
this, attributeValue, parentFO);
@@ -427,8 +422,8 @@ public abstract class PropertyList {
putExplicit(propId, prop);
}
} catch (PropertyException e) {
- log.error("Ignoring property: "
- + attributeName + "=\"" + attributeValue + "\" (" + e.getMessage() + ")");
+ fobj.getFOValidationEventProducer().invalidPropertyValue(this, fobj.getName(),
+ attributeName, attributeValue, e, fobj.locator);
}
}
}
@@ -465,18 +460,16 @@ public abstract class PropertyList {
}
/**
- * @param message ...
- * @param propName ...
- * @throws ValidationException ...
+ * Handles an invalid property.
+ * @param attr the invalid attribute
+ * @throws ValidationException if an exception needs to be thrown depending on the
+ * validation settings
*/
- protected void handleInvalidProperty(String message, String propName)
+ protected void handleInvalidProperty(QName attr)
throws ValidationException {
- if (!propName.startsWith("xmlns")) {
- if (fobj.getUserAgent().validateStrictly()) {
- fobj.attributeError(message);
- } else {
- log.error(message + " Property ignored.");
- }
+ if (!attr.getQName().startsWith("xmlns")) {
+ fobj.getFOValidationEventProducer().invalidProperty(this, fobj.getName(),
+ attr, true, fobj.locator);
}
}
diff --git a/src/java/org/apache/fop/fo/expr/FromParentFunction.java b/src/java/org/apache/fop/fo/expr/FromParentFunction.java
index b5a82de56..b09d3c95f 100644
--- a/src/java/org/apache/fop/fo/expr/FromParentFunction.java
+++ b/src/java/org/apache/fop/fo/expr/FromParentFunction.java
@@ -64,7 +64,13 @@ public class FromParentFunction extends FunctionBase {
* non-inherited properties too. Perhaps the result is different for
* a property line line-height which "inherits specified"???
*/
- return pInfo.getPropertyList().getFromParent(FOPropertyMapping.getPropertyId(propName));
+ int propId = FOPropertyMapping.getPropertyId(propName);
+ if (propId < 0) {
+ throw new PropertyException(
+ "Unknown property name used with inherited-property-value function: "
+ + propName);
+ }
+ return pInfo.getPropertyList().getFromParent(propId);
}
}
diff --git a/src/java/org/apache/fop/fo/expr/InheritedPropFunction.java b/src/java/org/apache/fop/fo/expr/InheritedPropFunction.java
index 3e5cadf04..e24c78caa 100644
--- a/src/java/org/apache/fop/fo/expr/InheritedPropFunction.java
+++ b/src/java/org/apache/fop/fo/expr/InheritedPropFunction.java
@@ -58,6 +58,11 @@ public class InheritedPropFunction extends FunctionBase {
}
int propId = FOPropertyMapping.getPropertyId(propName);
+ if (propId < 0) {
+ throw new PropertyException(
+ "Unknown property name used with inherited-property-value function: "
+ + propName);
+ }
return pInfo.getPropertyList().getInherited(propId);
}
diff --git a/src/java/org/apache/fop/fo/expr/NearestSpecPropFunction.java b/src/java/org/apache/fop/fo/expr/NearestSpecPropFunction.java
index 2aab5eee9..cdde96092 100644
--- a/src/java/org/apache/fop/fo/expr/NearestSpecPropFunction.java
+++ b/src/java/org/apache/fop/fo/expr/NearestSpecPropFunction.java
@@ -60,6 +60,11 @@ public class NearestSpecPropFunction extends FunctionBase {
// NOTE: special cases for shorthand property
// Should return COMPUTED VALUE
int propId = FOPropertyMapping.getPropertyId(propName);
+ if (propId < 0) {
+ throw new PropertyException(
+ "Unknown property name used with inherited-property-value function: "
+ + propName);
+ }
return pInfo.getPropertyList().getNearestSpecified(propId);
}
diff --git a/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java b/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java
index de1d019f4..fc61167b2 100644
--- a/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java
+++ b/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java
@@ -19,14 +19,15 @@
package org.apache.fop.fo.extensions;
+import java.util.HashMap;
+import java.util.Set;
+
+import org.apache.xmlgraphics.util.QName;
+
import org.apache.fop.fo.ElementMapping;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.UnknownXMLObj;
import org.apache.fop.fo.extensions.destination.Destination;
-import org.apache.fop.util.QName;
-
-import java.util.HashMap;
-import java.util.Set;
/**
* Element mapping for FOP's proprietary extension to XSL-FO.
diff --git a/src/java/org/apache/fop/fo/extensions/destination/Destination.java b/src/java/org/apache/fop/fo/extensions/destination/Destination.java
index d1e631e42..e3a2bbac4 100644
--- a/src/java/org/apache/fop/fo/extensions/destination/Destination.java
+++ b/src/java/org/apache/fop/fo/extensions/destination/Destination.java
@@ -19,15 +19,15 @@
package org.apache.fop.fo.extensions.destination;
-import org.apache.fop.fo.ValidationException;
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+
import org.apache.fop.apps.FOPException;
-import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.FONode;
-import org.apache.fop.fo.pagination.Root;
+import org.apache.fop.fo.PropertyList;
+import org.apache.fop.fo.ValidationException;
import org.apache.fop.fo.extensions.ExtensionElementMapping;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.Locator;
+import org.apache.fop.fo.pagination.Root;
/**
* Class for named destinations in PDF.
@@ -54,7 +54,7 @@ public class Destination extends FONode {
Attributes attlist, PropertyList pList) throws FOPException {
internalDestination = attlist.getValue("internal-destination");
if (internalDestination == null || internalDestination.length() == 0) {
- attributeError("Missing attribute: internal-destination must be specified.");
+ missingPropertyError("internal-destination");
}
}
diff --git a/src/java/org/apache/fop/fo/flow/AbstractListItemPart.java b/src/java/org/apache/fop/fo/flow/AbstractListItemPart.java
index 0fe6ed718..f99f9d947 100644
--- a/src/java/org/apache/fop/fo/flow/AbstractListItemPart.java
+++ b/src/java/org/apache/fop/fo/flow/AbstractListItemPart.java
@@ -62,14 +62,16 @@ public abstract class AbstractListItemPart extends FObj {
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
throws ValidationException {
- if (FO_URI.equals(nsURI) && localName.equals("marker")) {
- if (blockItemFound) {
- nodesOutOfOrderError(loc, "fo:marker", "(%block;)");
+ if (FO_URI.equals(nsURI)) {
+ if (localName.equals("marker")) {
+ if (blockItemFound) {
+ nodesOutOfOrderError(loc, "fo:marker", "(%block;)");
+ }
+ } else if (!isBlockItem(nsURI, localName)) {
+ invalidChildError(loc, nsURI, localName);
+ } else {
+ blockItemFound = true;
}
- } else if (!isBlockItem(nsURI, localName)) {
- invalidChildError(loc, nsURI, localName);
- } else {
- blockItemFound = true;
}
}
@@ -79,17 +81,8 @@ public abstract class AbstractListItemPart extends FObj {
protected void endOfNode() throws FOPException {
if (!this.blockItemFound) {
String contentModel = "marker* (%block;)+";
- if (getUserAgent().validateStrictly()) {
- missingChildElementError(contentModel);
- } else {
- StringBuffer message = new StringBuffer(
- errorText(getLocator()));
- message.append(getName())
- .append(" is missing child elements. ")
- .append("Required Content Model: ")
- .append(contentModel);
- log.warn(message.toString());
- }
+ getFOValidationEventProducer().missingChildElement(this, getName(),
+ contentModel, true, getLocator());
}
}
diff --git a/src/java/org/apache/fop/fo/flow/AbstractPageNumberCitation.java b/src/java/org/apache/fop/fo/flow/AbstractPageNumberCitation.java
index b6b827248..e9a1176d6 100644
--- a/src/java/org/apache/fop/fo/flow/AbstractPageNumberCitation.java
+++ b/src/java/org/apache/fop/fo/flow/AbstractPageNumberCitation.java
@@ -113,8 +113,10 @@ public abstract class AbstractPageNumberCitation extends FObj {
* XSL Content Model: empty
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
+ throws ValidationException {
+ if (FO_URI.equals(nsURI)) {
invalidChildError(loc, nsURI, localName);
+ }
}
/** @return the Common Font Properties. */
diff --git a/src/java/org/apache/fop/fo/flow/BasicLink.java b/src/java/org/apache/fop/fo/flow/BasicLink.java
index 61a4f8d19..b3ef48012 100644
--- a/src/java/org/apache/fop/fo/flow/BasicLink.java
+++ b/src/java/org/apache/fop/fo/flow/BasicLink.java
@@ -76,8 +76,7 @@ public class BasicLink extends Inline {
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);
}
}
@@ -102,15 +101,17 @@ public class BasicLink extends Inline {
* XSL Content Model: marker* (#PCDATA|%inline;|%block;)*
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
- if (FO_URI.equals(nsURI) && localName.equals("marker")) {
- if (blockOrInlineItemFound) {
- nodesOutOfOrderError(loc, "fo:marker", "(#PCDATA|%inline;|%block;)");
+ throws ValidationException {
+ if (FO_URI.equals(nsURI)) {
+ if (localName.equals("marker")) {
+ if (blockOrInlineItemFound) {
+ nodesOutOfOrderError(loc, "fo:marker", "(#PCDATA|%inline;|%block;)");
+ }
+ } else if (!isBlockOrInlineItem(nsURI, localName)) {
+ invalidChildError(loc, nsURI, localName);
+ } else {
+ blockOrInlineItemFound = true;
}
- } else if (!isBlockOrInlineItem(nsURI, localName)) {
- invalidChildError(loc, nsURI, localName);
- } else {
- blockOrInlineItemFound = true;
}
}
diff --git a/src/java/org/apache/fop/fo/flow/BidiOverride.java b/src/java/org/apache/fop/fo/flow/BidiOverride.java
index 2157085ad..892f4a3c5 100644
--- a/src/java/org/apache/fop/fo/flow/BidiOverride.java
+++ b/src/java/org/apache/fop/fo/flow/BidiOverride.java
@@ -19,13 +19,14 @@
package org.apache.fop.fo.flow;
+import org.xml.sax.Locator;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObjMixed;
import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.ValidationException;
import org.apache.fop.fo.properties.SpaceProperty;
-import org.xml.sax.Locator;
/**
* Class modelling the fo:bidi-override object.
@@ -96,22 +97,21 @@ public class BidiOverride extends FObjMixed {
* fo:inline-container."
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
- if (FO_URI.equals(nsURI) && localName.equals("marker")) {
- if (blockOrInlineItemFound) {
- nodesOutOfOrderError(loc, "fo:marker",
- "(#PCDATA|%inline;|%block;)");
+ throws ValidationException {
+ if (FO_URI.equals(nsURI)) {
+ if (localName.equals("marker")) {
+ if (blockOrInlineItemFound) {
+ nodesOutOfOrderError(loc, "fo:marker",
+ "(#PCDATA|%inline;|%block;)");
+ }
+ } else if (!isBlockOrInlineItem(nsURI, localName)) {
+ invalidChildError(loc, nsURI, localName);
+ } else if (!canHaveBlockLevelChildren && isBlockItem(nsURI, localName)) {
+ invalidChildError(loc, getParent().getName(), nsURI, getName(),
+ "rule.bidiOverrideContent");
+ } else {
+ blockOrInlineItemFound = true;
}
- } else if (!isBlockOrInlineItem(nsURI, localName)) {
- invalidChildError(loc, nsURI, localName);
- } else if (!canHaveBlockLevelChildren && isBlockItem(nsURI, localName)) {
- String ruleViolated = "An fo:bidi-override"
- + " that is a descendant of an fo:leader or of the fo:inline child"
- + " of an fo:footnote may not have block-level children, unless it"
- + " has a nearer ancestor that is an fo:inline-container.";
- invalidChildError(loc, nsURI, localName, ruleViolated);
- } else {
- blockOrInlineItemFound = true;
}
}
diff --git a/src/java/org/apache/fop/fo/flow/BlockContainer.java b/src/java/org/apache/fop/fo/flow/BlockContainer.java
index a71999938..f1180ac16 100644
--- a/src/java/org/apache/fop/fo/flow/BlockContainer.java
+++ b/src/java/org/apache/fop/fo/flow/BlockContainer.java
@@ -114,15 +114,17 @@ public class BlockContainer extends FObj {
* @todo - implement above restriction if possible
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
- if (FO_URI.equals(nsURI) && localName.equals("marker")) {
- if (blockItemFound) {
- nodesOutOfOrderError(loc, "fo:marker", "(%block;)");
+ throws ValidationException {
+ if (FO_URI.equals(nsURI)) {
+ if (localName.equals("marker")) {
+ if (blockItemFound) {
+ nodesOutOfOrderError(loc, "fo:marker", "(%block;)");
+ }
+ } else if (!isBlockItem(nsURI, localName)) {
+ invalidChildError(loc, nsURI, localName);
+ } else {
+ blockItemFound = true;
}
- } else if (!isBlockItem(nsURI, localName)) {
- invalidChildError(loc, nsURI, localName);
- } else {
- blockItemFound = true;
}
}
diff --git a/src/java/org/apache/fop/fo/flow/Character.java b/src/java/org/apache/fop/fo/flow/Character.java
index 022d54af7..aad4209f9 100644
--- a/src/java/org/apache/fop/fo/flow/Character.java
+++ b/src/java/org/apache/fop/fo/flow/Character.java
@@ -22,6 +22,8 @@ package org.apache.fop.fo.flow;
import java.awt.Color;
import java.util.NoSuchElementException;
+import org.xml.sax.Locator;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.datatypes.Length;
import org.apache.fop.fo.CharIterator;
@@ -35,7 +37,6 @@ import org.apache.fop.fo.properties.CommonHyphenation;
import org.apache.fop.fo.properties.CommonTextDecoration;
import org.apache.fop.fo.properties.Property;
import org.apache.fop.fo.properties.SpaceProperty;
-import org.xml.sax.Locator;
/**
* Class modelling the fo:character object.
@@ -134,8 +135,10 @@ public class Character extends FObj {
* XSL Content Model: empty
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
+ throws ValidationException {
+ if (FO_URI.equals(nsURI)) {
invalidChildError(loc, nsURI, localName);
+ }
}
/**
diff --git a/src/java/org/apache/fop/fo/flow/ExternalGraphic.java b/src/java/org/apache/fop/fo/flow/ExternalGraphic.java
index fdddf3918..07f765e52 100644
--- a/src/java/org/apache/fop/fo/flow/ExternalGraphic.java
+++ b/src/java/org/apache/fop/fo/flow/ExternalGraphic.java
@@ -32,6 +32,7 @@ import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.datatypes.Length;
import org.apache.fop.datatypes.URISpecification;
+import org.apache.fop.events.ResourceEventProducer;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.ValidationException;
@@ -78,11 +79,17 @@ public class ExternalGraphic extends AbstractGraphics {
try {
info = manager.getImageInfo(url, userAgent.getImageSessionContext());
} catch (ImageException e) {
- log.error("Image not available: " + e.getMessage());
+ ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.imageError(this, url, e, getLocator());
} catch (FileNotFoundException fnfe) {
- log.error(fnfe.getMessage());
+ ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.imageNotFound(this, url, fnfe, getLocator());
} catch (IOException ioe) {
- log.error("I/O error while loading image: " + ioe.getMessage());
+ ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.imageIOError(this, url, ioe, getLocator());
}
if (info != null) {
this.intrinsicWidth = info.getSize().getWidthMpt();
@@ -93,7 +100,6 @@ public class ExternalGraphic extends AbstractGraphics {
= FixedLength.getInstance(-baseline);
}
}
- //TODO Report to caller so he can decide to throw an exception
}
/** {@inheritDoc} */
@@ -107,8 +113,10 @@ public class ExternalGraphic extends AbstractGraphics {
* XSL Content Model: empty
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
+ throws ValidationException {
+ if (FO_URI.equals(nsURI)) {
invalidChildError(loc, nsURI, localName);
+ }
}
/** @return the "src" property */
diff --git a/src/java/org/apache/fop/fo/flow/Float.java b/src/java/org/apache/fop/fo/flow/Float.java
index 997f96c89..57d3b4ee1 100644
--- a/src/java/org/apache/fop/fo/flow/Float.java
+++ b/src/java/org/apache/fop/fo/flow/Float.java
@@ -46,7 +46,8 @@ public class Float extends FObj {
super(parent);
if (!notImplementedWarningGiven) {
- log.warn("fo:float is not yet implemented.");
+ getFOValidationEventProducer().unimplementedFeature(this, getName(),
+ getName(), getLocator());
notImplementedWarningGiven = true;
}
}
@@ -63,10 +64,12 @@ public class Float extends FObj {
* XSL Content Model: (%block;)+
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
+ throws ValidationException {
+ if (FO_URI.equals(nsURI)) {
if (!isBlockItem(nsURI, localName)) {
invalidChildError(loc, nsURI, localName);
}
+ }
}
/**
diff --git a/src/java/org/apache/fop/fo/flow/Footnote.java b/src/java/org/apache/fop/fo/flow/Footnote.java
index 95c9f25bc..c15a7e0ee 100644
--- a/src/java/org/apache/fop/fo/flow/Footnote.java
+++ b/src/java/org/apache/fop/fo/flow/Footnote.java
@@ -82,12 +82,13 @@ public class Footnote extends FObj {
* generates an absolutely positioned area.
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
- if (FO_URI.equals(nsURI) && localName.equals("inline")) {
+ throws ValidationException {
+ if (FO_URI.equals(nsURI)) {
+ if (localName.equals("inline")) {
if (footnoteCitation != null) {
tooManyNodesError(loc, "fo:inline");
}
- } else if (FO_URI.equals(nsURI) && localName.equals("footnote-body")) {
+ } else if (localName.equals("footnote-body")) {
if (footnoteCitation == null) {
nodesOutOfOrderError(loc, "fo:inline", "fo:footnote-body");
} else if (footnoteBody != null) {
@@ -96,6 +97,7 @@ public class Footnote extends FObj {
} else {
invalidChildError(loc, nsURI, localName);
}
+ }
}
/**
diff --git a/src/java/org/apache/fop/fo/flow/FootnoteBody.java b/src/java/org/apache/fop/fo/flow/FootnoteBody.java
index bb4c9b482..967d15215 100644
--- a/src/java/org/apache/fop/fo/flow/FootnoteBody.java
+++ b/src/java/org/apache/fop/fo/flow/FootnoteBody.java
@@ -73,10 +73,12 @@ public class FootnoteBody extends FObj {
* XSL Content Model: (%block;)+
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
+ throws ValidationException {
+ if (FO_URI.equals(nsURI)) {
if (!isBlockItem(nsURI, localName)) {
invalidChildError(loc, nsURI, localName);
}
+ }
}
/** {@inheritDoc} */
diff --git a/src/java/org/apache/fop/fo/flow/InitialPropertySet.java b/src/java/org/apache/fop/fo/flow/InitialPropertySet.java
index 63299978d..6d0e495b7 100644
--- a/src/java/org/apache/fop/fo/flow/InitialPropertySet.java
+++ b/src/java/org/apache/fop/fo/flow/InitialPropertySet.java
@@ -72,8 +72,10 @@ public class InitialPropertySet extends FObj {
* XSL Content Model: empty
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
+ throws ValidationException {
+ if (FO_URI.equals(nsURI)) {
invalidChildError(loc, nsURI, localName);
+ }
}
/**
diff --git a/src/java/org/apache/fop/fo/flow/Inline.java b/src/java/org/apache/fop/fo/flow/Inline.java
index 6bbd90ad1..50662d9f1 100644
--- a/src/java/org/apache/fop/fo/flow/Inline.java
+++ b/src/java/org/apache/fop/fo/flow/Inline.java
@@ -81,8 +81,8 @@ public class Inline extends InlineLevel {
int lvlInCntr = findAncestor(FO_INLINE_CONTAINER);
if (lvlLeader > 0) {
- if (lvlInCntr < 0 ||
- (lvlInCntr > 0 && lvlInCntr > lvlLeader)) {
+ if (lvlInCntr < 0
+ || (lvlInCntr > 0 && lvlInCntr > lvlLeader)) {
canHaveBlockLevelChildren = false;
}
} else if (lvlFootnote > 0) {
@@ -110,23 +110,20 @@ public class Inline extends InlineLevel {
* nearer ancestor that is an fo:inline-container." (paraphrased)
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
- if (FO_URI.equals(nsURI) && localName.equals("marker")) {
- if (blockOrInlineItemFound) {
- nodesOutOfOrderError(loc, "fo:marker",
- "(#PCDATA|%inline;|%block;)");
+ throws ValidationException {
+ if (FO_URI.equals(nsURI)) {
+ if (localName.equals("marker")) {
+ if (blockOrInlineItemFound) {
+ nodesOutOfOrderError(loc, "fo:marker",
+ "(#PCDATA|%inline;|%block;)");
+ }
+ } else if (!isBlockOrInlineItem(nsURI, localName)) {
+ invalidChildError(loc, nsURI, localName);
+ } else if (!canHaveBlockLevelChildren && isBlockItem(nsURI, localName)) {
+ invalidChildError(loc, getParent().getName(), nsURI, getName(), "rule.inlineContent");
+ } else {
+ blockOrInlineItemFound = true;
}
- } else if (!isBlockOrInlineItem(nsURI, localName)) {
- invalidChildError(loc, nsURI, localName);
- } else if (!canHaveBlockLevelChildren && isBlockItem(nsURI, localName)) {
- String ruleViolated =
- " An fo:inline that is a descendant of an fo:leader" +
- " or fo:footnote may not have block-level children," +
- " unless it has a nearer ancestor that is an" +
- " fo:inline-container.";
- invalidChildError(loc, nsURI, localName, ruleViolated);
- } else {
- blockOrInlineItemFound = true;
}
}
diff --git a/src/java/org/apache/fop/fo/flow/InlineContainer.java b/src/java/org/apache/fop/fo/flow/InlineContainer.java
index a8fb7858d..3c142afe9 100644
--- a/src/java/org/apache/fop/fo/flow/InlineContainer.java
+++ b/src/java/org/apache/fop/fo/flow/InlineContainer.java
@@ -86,15 +86,17 @@ public class InlineContainer extends FObj {
* XSL Content Model: marker* (%block;)+
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
- if (FO_URI.equals(nsURI) && localName.equals("marker")) {
- if (blockItemFound) {
- nodesOutOfOrderError(loc, "fo:marker", "(%block;)");
+ throws ValidationException {
+ if (FO_URI.equals(nsURI)) {
+ if (localName.equals("marker")) {
+ if (blockItemFound) {
+ nodesOutOfOrderError(loc, "fo:marker", "(%block;)");
+ }
+ } else if (!isBlockItem(nsURI, localName)) {
+ invalidChildError(loc, nsURI, localName);
+ } else {
+ blockItemFound = true;
}
- } else if (!isBlockItem(nsURI, localName)) {
- invalidChildError(loc, nsURI, localName);
- } else {
- blockItemFound = true;
}
}
diff --git a/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java b/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java
index 531bd657a..802f59c30 100644
--- a/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java
+++ b/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java
@@ -20,12 +20,17 @@
package org.apache.fop.fo.flow;
import java.awt.geom.Point2D;
+
+import org.xml.sax.Locator;
+
+import org.apache.xmlgraphics.util.QName;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.datatypes.Length;
+import org.apache.fop.events.ResourceEventProducer;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.ValidationException;
import org.apache.fop.fo.XMLObj;
-import org.xml.sax.Locator;
/**
* Class modelling the fo:instream-foreign-object object.
@@ -39,6 +44,7 @@ public class InstreamForeignObject extends AbstractGraphics {
//Additional value
private Point2D intrinsicDimensions;
+ private boolean instrisicSizeDetermined;
private Length intrinsicAlignmentAdjust;
@@ -68,11 +74,11 @@ public class InstreamForeignObject extends AbstractGraphics {
* XSL Content Model: one (1) non-XSL namespace child
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
+ throws ValidationException {
if (FO_URI.equals(nsURI)) {
invalidChildError(loc, nsURI, localName);
} else if (firstChild != null) {
- tooManyNodesError(loc, "child element");
+ tooManyNodesError(loc, new QName(nsURI, null, localName));
}
}
@@ -81,32 +87,28 @@ public class InstreamForeignObject extends AbstractGraphics {
return "instream-foreign-object";
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public int getNameId() {
return FO_INSTREAM_FOREIGN_OBJECT;
}
- /**
- * Preloads the image so the intrinsic size is available.
- */
+ /** Preloads the image so the intrinsic size is available. */
private void prepareIntrinsicSize() {
- if (intrinsicDimensions == null) {
+ if (!this.instrisicSizeDetermined) {
XMLObj child = (XMLObj) firstChild;
Point2D csize = new Point2D.Float(-1, -1);
intrinsicDimensions = child.getDimension(csize);
if (intrinsicDimensions == null) {
- log.error("Intrinsic dimensions of "
- + " instream-foreign-object could not be determined");
+ ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.ifoNoIntrinsicSize(this, getLocator());
}
intrinsicAlignmentAdjust = child.getIntrinsicAlignmentAdjust();
+ this.instrisicSizeDetermined = true;
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public int getIntrinsicWidth() {
prepareIntrinsicSize();
if (intrinsicDimensions != null) {
@@ -116,9 +118,7 @@ public class InstreamForeignObject extends AbstractGraphics {
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public int getIntrinsicHeight() {
prepareIntrinsicSize();
if (intrinsicDimensions != null) {
@@ -128,11 +128,8 @@ public class InstreamForeignObject extends AbstractGraphics {
}
}
- /**
- * {@inheritDoc}
- */
- public Length getIntrinsicAlignmentAdjust()
- {
+ /** {@inheritDoc} */
+ public Length getIntrinsicAlignmentAdjust() {
prepareIntrinsicSize();
return intrinsicAlignmentAdjust;
}
diff --git a/src/java/org/apache/fop/fo/flow/ListBlock.java b/src/java/org/apache/fop/fo/flow/ListBlock.java
index 86c581cc3..a196e92de 100644
--- a/src/java/org/apache/fop/fo/flow/ListBlock.java
+++ b/src/java/org/apache/fop/fo/flow/ListBlock.java
@@ -108,15 +108,17 @@ public class ListBlock extends FObj {
* XSL Content Model: marker* (list-item)+
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
- if (FO_URI.equals(nsURI) && localName.equals("marker")) {
- if (hasListItem) {
- nodesOutOfOrderError(loc, "fo:marker", "fo:list-item");
+ throws ValidationException {
+ if (FO_URI.equals(nsURI)) {
+ if (localName.equals("marker")) {
+ if (hasListItem) {
+ nodesOutOfOrderError(loc, "fo:marker", "fo:list-item");
+ }
+ } else if (localName.equals("list-item")) {
+ hasListItem = true;
+ } else {
+ invalidChildError(loc, nsURI, localName);
}
- } else if (FO_URI.equals(nsURI) && localName.equals("list-item")) {
- hasListItem = true;
- } else {
- invalidChildError(loc, nsURI, localName);
}
}
diff --git a/src/java/org/apache/fop/fo/flow/ListItem.java b/src/java/org/apache/fop/fo/flow/ListItem.java
index c09313ef6..cf0e05c56 100644
--- a/src/java/org/apache/fop/fo/flow/ListItem.java
+++ b/src/java/org/apache/fop/fo/flow/ListItem.java
@@ -98,22 +98,24 @@ public class ListItem extends FObj {
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
throws ValidationException {
- if (FO_URI.equals(nsURI) && localName.equals("marker")) {
- if (label != null) {
- nodesOutOfOrderError(loc, "fo:marker", "fo:list-item-label");
+ if (FO_URI.equals(nsURI)) {
+ if (localName.equals("marker")) {
+ if (label != null) {
+ nodesOutOfOrderError(loc, "fo:marker", "fo:list-item-label");
+ }
+ } else if (localName.equals("list-item-label")) {
+ if (label != null) {
+ tooManyNodesError(loc, "fo:list-item-label");
+ }
+ } else if (localName.equals("list-item-body")) {
+ if (label == null) {
+ nodesOutOfOrderError(loc, "fo:list-item-label", "fo:list-item-body");
+ } else if (body != null) {
+ tooManyNodesError(loc, "fo:list-item-body");
+ }
+ } else {
+ invalidChildError(loc, nsURI, localName);
}
- } else if (FO_URI.equals(nsURI) && localName.equals("list-item-label")) {
- if (label != null) {
- tooManyNodesError(loc, "fo:list-item-label");
- }
- } else if (FO_URI.equals(nsURI) && localName.equals("list-item-body")) {
- if (label == null) {
- nodesOutOfOrderError(loc, "fo:list-item-label", "fo:list-item-body");
- } else if (body != null) {
- tooManyNodesError(loc, "fo:list-item-body");
- }
- } else {
- invalidChildError(loc, nsURI, localName);
}
}
diff --git a/src/java/org/apache/fop/fo/flow/Marker.java b/src/java/org/apache/fop/fo/flow/Marker.java
index 05c9862b2..168b18180 100644
--- a/src/java/org/apache/fop/fo/flow/Marker.java
+++ b/src/java/org/apache/fop/fo/flow/Marker.java
@@ -59,9 +59,8 @@ public class Marker extends FObjMixed {
*/
public void bind(PropertyList pList) throws FOPException {
if (findAncestor(FO_FLOW) < 0) {
- invalidChildError(locator, FO_URI, "marker",
- "An fo:marker is permitted only as the descendant "
- + "of an fo:flow");
+ invalidChildError(locator, getParent().getName(), FO_URI, getName(),
+ "rule.markerDescendantOfFlow");
}
markerClassName = pList.get(PR_MARKER_CLASS_NAME).getString();
@@ -112,9 +111,11 @@ public class Marker extends FObjMixed {
* @todo implement "additional" constraint, possibly within fo:retrieve-marker
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
- if (!isBlockOrInlineItem(nsURI, localName)) {
- invalidChildError(loc, nsURI, localName);
+ throws ValidationException {
+ if (FO_URI.equals(nsURI)) {
+ if (!isBlockOrInlineItem(nsURI, localName)) {
+ invalidChildError(loc, nsURI, localName);
+ }
}
}
diff --git a/src/java/org/apache/fop/fo/flow/MultiCase.java b/src/java/org/apache/fop/fo/flow/MultiCase.java
index 42ec9d9d0..e568fba46 100644
--- a/src/java/org/apache/fop/fo/flow/MultiCase.java
+++ b/src/java/org/apache/fop/fo/flow/MultiCase.java
@@ -46,7 +46,8 @@ public class MultiCase extends FObj {
super(parent);
if (!notImplementedWarningGiven) {
- log.warn("fo:multi-case is not yet implemented.");
+ getFOValidationEventProducer().unimplementedFeature(this, getName(),
+ getName(), getLocator());
notImplementedWarningGiven = true;
}
}
diff --git a/src/java/org/apache/fop/fo/flow/MultiProperties.java b/src/java/org/apache/fop/fo/flow/MultiProperties.java
index 00cb85dc7..bd3bd893e 100644
--- a/src/java/org/apache/fop/fo/flow/MultiProperties.java
+++ b/src/java/org/apache/fop/fo/flow/MultiProperties.java
@@ -49,7 +49,8 @@ public class MultiProperties extends FObj {
super(parent);
if (!notImplementedWarningGiven) {
- log.warn("fo:multi-properties is not yet implemented.");
+ getFOValidationEventProducer().unimplementedFeature(this, getName(),
+ getName(), getLocator());
notImplementedWarningGiven = true;
}
}
@@ -69,13 +70,14 @@ public class MultiProperties extends FObj {
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
throws ValidationException {
- if (FO_URI.equals(nsURI) && localName.equals("multi-property-set")) {
+ if (FO_URI.equals(nsURI)) {
+ if (localName.equals("multi-property-set")) {
if (hasWrapper) {
nodesOutOfOrderError(loc, "fo:multi-property-set", "fo:wrapper");
} else {
hasMultiPropertySet = true;
}
- } else if (FO_URI.equals(nsURI) && localName.equals("wrapper")) {
+ } else if (localName.equals("wrapper")) {
if (hasWrapper) {
tooManyNodesError(loc, "fo:wrapper");
} else {
@@ -84,6 +86,7 @@ public class MultiProperties extends FObj {
} else {
invalidChildError(loc, nsURI, localName);
}
+ }
}
/** {@inheritDoc} */
diff --git a/src/java/org/apache/fop/fo/flow/MultiPropertySet.java b/src/java/org/apache/fop/fo/flow/MultiPropertySet.java
index 3c9c55b4f..caa31f7b9 100644
--- a/src/java/org/apache/fop/fo/flow/MultiPropertySet.java
+++ b/src/java/org/apache/fop/fo/flow/MultiPropertySet.java
@@ -45,7 +45,8 @@ public class MultiPropertySet extends FObj {
super(parent);
if (!notImplementedWarningGiven) {
- log.warn("fo:multi-property-set is not yet implemented.");
+ getFOValidationEventProducer().unimplementedFeature(this, getName(),
+ getName(), getLocator());
notImplementedWarningGiven = true;
}
}
@@ -63,8 +64,10 @@ public class MultiPropertySet extends FObj {
* XSL Content Model: empty
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
+ throws ValidationException {
+ if (FO_URI.equals(nsURI)) {
invalidChildError(loc, nsURI, localName);
+ }
}
/** {@inheritDoc} */
diff --git a/src/java/org/apache/fop/fo/flow/MultiSwitch.java b/src/java/org/apache/fop/fo/flow/MultiSwitch.java
index 7c70a7346..03f404aa3 100644
--- a/src/java/org/apache/fop/fo/flow/MultiSwitch.java
+++ b/src/java/org/apache/fop/fo/flow/MultiSwitch.java
@@ -47,7 +47,8 @@ public class MultiSwitch extends FObj {
super(parent);
if (!notImplementedWarningGiven) {
- log.warn("fo:multi-switch is not yet implemented.");
+ getFOValidationEventProducer().unimplementedFeature(this, getName(),
+ getName(), getLocator());
notImplementedWarningGiven = true;
}
}
@@ -75,9 +76,11 @@ public class MultiSwitch extends FObj {
* XSL Content Model: (multi-case+)
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
- if (!(FO_URI.equals(nsURI) && localName.equals("multi-case"))) {
- invalidChildError(loc, nsURI, localName);
+ throws ValidationException {
+ if (FO_URI.equals(nsURI)) {
+ if (!localName.equals("multi-case")) {
+ invalidChildError(loc, nsURI, localName);
+ }
}
}
diff --git a/src/java/org/apache/fop/fo/flow/MultiToggle.java b/src/java/org/apache/fop/fo/flow/MultiToggle.java
index 80b36f9f4..66442c2a7 100644
--- a/src/java/org/apache/fop/fo/flow/MultiToggle.java
+++ b/src/java/org/apache/fop/fo/flow/MultiToggle.java
@@ -47,7 +47,8 @@ public class MultiToggle extends FObj {
super(parent);
if (!notImplementedWarningGiven) {
- log.warn("fo:multi-toggle is not yet implemented.");
+ getFOValidationEventProducer().unimplementedFeature(this, getName(),
+ getName(), getLocator());
notImplementedWarningGiven = true;
}
}
@@ -65,9 +66,11 @@ public class MultiToggle extends FObj {
* XSL Content Model: (#PCDATA|%inline;|%block;)*
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
- if (!isBlockOrInlineItem(nsURI, localName)) {
- invalidChildError(loc, nsURI, localName);
+ throws ValidationException {
+ if (FO_URI.equals(nsURI)) {
+ if (!isBlockOrInlineItem(nsURI, localName)) {
+ invalidChildError(loc, nsURI, localName);
+ }
}
}
diff --git a/src/java/org/apache/fop/fo/flow/PageNumber.java b/src/java/org/apache/fop/fo/flow/PageNumber.java
index 3eca1e16e..cc51dd28a 100644
--- a/src/java/org/apache/fop/fo/flow/PageNumber.java
+++ b/src/java/org/apache/fop/fo/flow/PageNumber.java
@@ -117,8 +117,10 @@ public class PageNumber extends FObj {
* XSL Content Model: empty
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
+ throws ValidationException {
+ if (FO_URI.equals(nsURI)) {
invalidChildError(loc, nsURI, localName);
+ }
}
/** @return the Common Font Properties. */
diff --git a/src/java/org/apache/fop/fo/flow/RetrieveMarker.java b/src/java/org/apache/fop/fo/flow/RetrieveMarker.java
index 7356bc72e..ea6b6f1c5 100644
--- a/src/java/org/apache/fop/fo/flow/RetrieveMarker.java
+++ b/src/java/org/apache/fop/fo/flow/RetrieveMarker.java
@@ -21,6 +21,8 @@ package org.apache.fop.fo.flow;
import java.util.Iterator;
+import org.xml.sax.Locator;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FOText;
@@ -30,7 +32,6 @@ import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.ValidationException;
import org.apache.fop.fo.flow.table.Table;
import org.apache.fop.fo.flow.table.TableFObj;
-import org.xml.sax.Locator;
/**
* Class modelling the fo:retrieve-marker object.
@@ -48,21 +49,18 @@ public class RetrieveMarker extends FObjMixed {
/**
* Create a retrieve marker object.
- *
+ * @param parent FONode that is the parent of this object
* @see org.apache.fop.fo.FONode#FONode(FONode)
*/
public RetrieveMarker(FONode parent) {
super(parent);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void bind(PropertyList pList) throws FOPException {
if (findAncestor(FO_STATIC_CONTENT) < 0) {
- invalidChildError(locator, FO_URI, "retrieve-marker",
- "An fo:retrieve-marker is permitted only as the " +
- " descendant of an fo:static-content.");
+ invalidChildError(locator, getParent().getName(), FO_URI, getName(),
+ "rule.retrieveMarkerDescendatOfStaticContent");
}
retrieveClassName = pList.get(PR_RETRIEVE_CLASS_NAME).getString();
@@ -81,8 +79,10 @@ public class RetrieveMarker extends FObjMixed {
* XSL Content Model: empty
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
+ throws ValidationException {
+ if (FO_URI.equals(nsURI)) {
invalidChildError(loc, nsURI, localName);
+ }
}
/**
@@ -206,13 +206,12 @@ public class RetrieveMarker extends FObjMixed {
try {
cloneFromMarker(marker);
} catch (FOPException exc) {
- log.error("fo:retrieve-marker unable to clone "
- + "subtree of fo:marker (marker-class-name="
- + marker.getMarkerClassName() + ")", exc);
+ getFOValidationEventProducer().markerCloningFailed(this,
+ marker.getMarkerClassName(), exc, getLocator());
return;
}
- } else if (log.isInfoEnabled()) {
- log.info("Empty marker retrieved...");
+ } else if (log.isDebugEnabled()) {
+ log.debug("Empty marker retrieved...");
}
return;
}
@@ -222,9 +221,7 @@ public class RetrieveMarker extends FObjMixed {
return "retrieve-marker";
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public int getNameId() {
return FO_RETRIEVE_MARKER;
}
diff --git a/src/java/org/apache/fop/fo/flow/Wrapper.java b/src/java/org/apache/fop/fo/flow/Wrapper.java
index adf9b2101..87582fb47 100644
--- a/src/java/org/apache/fop/fo/flow/Wrapper.java
+++ b/src/java/org/apache/fop/fo/flow/Wrapper.java
@@ -19,12 +19,13 @@
package org.apache.fop.fo.flow;
+import org.xml.sax.Locator;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObjMixed;
import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.ValidationException;
-import org.xml.sax.Locator;
/**
* Class modelling the fo:wrapper object.
@@ -66,17 +67,19 @@ public class Wrapper extends FObjMixed {
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
throws ValidationException {
- if (FO_URI.equals(nsURI) && "marker".equals(localName)) {
- if (blockOrInlineItemFound) {
- nodesOutOfOrderError(loc, "fo:marker",
- "(#PCDATA|%inline;|%block;)");
+ if (FO_URI.equals(nsURI)) {
+ if ("marker".equals(localName)) {
+ if (blockOrInlineItemFound) {
+ nodesOutOfOrderError(loc, "fo:marker",
+ "(#PCDATA|%inline;|%block;)");
+ }
+ } else if (isBlockOrInlineItem(nsURI, localName)) {
+ //delegate validation to parent
+ FONode.validateChildNode(this.parent, loc, nsURI, localName);
+ blockOrInlineItemFound = true;
+ } else {
+ invalidChildError(loc, nsURI, localName);
}
- } else if (isBlockOrInlineItem(nsURI, localName)) {
- //delegate validation to parent
- FONode.validateChildNode(this.parent, loc, nsURI, localName);
- blockOrInlineItemFound = true;
- } else {
- invalidChildError(loc, nsURI, localName);
}
}
diff --git a/src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java b/src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java
index 28a30c6f7..0d24491d9 100644
--- a/src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java
+++ b/src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java
@@ -120,13 +120,17 @@ class FixedColRowGroupBuilder extends RowGroupBuilder {
void endTableRow() {
assert currentTableRow != null;
if (currentRowIndex > 0 && currentTableRow.getBreakBefore() != Constants.EN_AUTO) {
- currentTableRow.attributeWarning("break-before ignored because of row spanning "
- + "in progress (See XSL 1.1, 7.20.2)");
+ TableEventProducer eventProducer = TableEventProducer.Provider.get(
+ currentTableRow.getUserAgent().getEventBroadcaster());
+ eventProducer.breakIgnoredDueToRowSpanning(this, currentTableRow.getName(), true,
+ currentTableRow.getLocator());
}
if (currentRowIndex < rows.size() - 1
&& currentTableRow.getBreakAfter() != Constants.EN_AUTO) {
- currentTableRow.attributeWarning("break-after ignored because of row spanning "
- + "in progress (See XSL 1.1, 7.20.1)");
+ TableEventProducer eventProducer = TableEventProducer.Provider.get(
+ currentTableRow.getUserAgent().getEventBroadcaster());
+ eventProducer.breakIgnoredDueToRowSpanning(this, currentTableRow.getName(), false,
+ currentTableRow.getLocator());
}
for (Iterator iter = ((List) rows.get(currentRowIndex)).iterator(); iter.hasNext();) {
GridUnit gu = (GridUnit) iter.next();
diff --git a/src/java/org/apache/fop/fo/flow/table/Table.java b/src/java/org/apache/fop/fo/flow/table/Table.java
index 7d6611435..c1ef3857c 100644
--- a/src/java/org/apache/fop/fo/flow/table/Table.java
+++ b/src/java/org/apache/fop/fo/flow/table/Table.java
@@ -22,6 +22,8 @@ package org.apache.fop.fo.flow.table;
import java.util.ArrayList;
import java.util.List;
+import org.xml.sax.Locator;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.datatypes.Length;
import org.apache.fop.datatypes.ValidationPercentBaseContext;
@@ -35,7 +37,6 @@ import org.apache.fop.fo.properties.KeepProperty;
import org.apache.fop.fo.properties.LengthPairProperty;
import org.apache.fop.fo.properties.LengthRangeProperty;
import org.apache.fop.fo.properties.TableColLength;
-import org.xml.sax.Locator;
/**
* Class modelling the fo:table object.
@@ -126,20 +127,22 @@ public class Table extends TableFObj implements ColumnNumberManagerHolder {
orphanContentLimit = pList.get(PR_X_ORPHAN_CONTENT_LIMIT).getLength();
if (!blockProgressionDimension.getOptimum(null).isAuto()) {
- attributeWarning("only a value of \"auto\" for block-progression-dimension has a"
- + " well-specified behavior on fo:table. Falling back to \"auto\"");
+ TableEventProducer eventProducer = TableEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.nonAutoBPDOnTable(this, getLocator());
// Anyway, the bpd of a table is not used by the layout code
}
if (tableLayout == EN_AUTO) {
- attributeWarning("table-layout=\"auto\" is currently not supported by FOP");
+ getFOValidationEventProducer().unimplementedFeature(this, getName(),
+ "table-layout=\"auto\"", getLocator());
}
if (!isSeparateBorderModel()
&& getCommonBorderPaddingBackground().hasPadding(
ValidationPercentBaseContext.getPseudoContext())) {
//See "17.6.2 The collapsing border model" in CSS2
- attributeWarning("In collapsing border model a table does not have padding"
- + " (see http://www.w3.org/TR/REC-CSS2/tables.html#collapsing-borders)"
- + ", but a non-zero value for padding was found. The padding will be ignored.");
+ TableEventProducer eventProducer = TableEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.noTablePaddingWithCollapsingBorderModel(this, getLocator());
}
/* Store reference to the property list, so
@@ -163,7 +166,7 @@ public class Table extends TableFObj implements ColumnNumberManagerHolder {
* XSL Content Model: (marker*,table-column*,table-header?,table-footer?,table-body+)
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
+ throws ValidationException {
if (FO_URI.equals(nsURI)) {
if ("marker".equals(localName)) {
if (tableColumnFound || tableHeaderFound || tableFooterFound
@@ -193,15 +196,11 @@ public class Table extends TableFObj implements ColumnNumberManagerHolder {
} else {
tableFooterFound = true;
if (tableBodyFound) {
- if (getUserAgent().validateStrictly()) {
- nodesOutOfOrderError(loc, "fo:table-footer", "(table-body+)");
- } else if (!isSeparateBorderModel()) {
- nodesOutOfOrderError(loc, "fo:table-footer", "(table-body+)."
- + " This table uses the collapsing border"
- + " model. In order to resolve borders in an efficient way"
- + " the table-footer must be known before any table-body"
- + " is parsed. Either put the footer at the correct place"
- + " or switch to the separate border model");
+ nodesOutOfOrderError(loc, "fo:table-footer", "(table-body+)", true);
+ if (!isSeparateBorderModel()) {
+ TableEventProducer eventProducer = TableEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.footerOrderCannotRecover(this, getName(), getLocator());
}
}
}
@@ -210,8 +209,6 @@ public class Table extends TableFObj implements ColumnNumberManagerHolder {
} else {
invalidChildError(loc, nsURI, localName);
}
- } else {
- invalidChildError(loc, nsURI, localName);
}
}
@@ -225,6 +222,10 @@ public class Table extends TableFObj implements ColumnNumberManagerHolder {
"(marker*,table-column*,table-header?,table-footer?"
+ ",table-body+)");
}
+ if (!hasChildren()) {
+ getParent().removeChild(this);
+ return;
+ }
if (!inMarker()) {
rowGroupBuilder.endTable();
/* clean up */
diff --git a/src/java/org/apache/fop/fo/flow/table/TableAndCaption.java b/src/java/org/apache/fop/fo/flow/table/TableAndCaption.java
index f16931cfc..6dabf37db 100644
--- a/src/java/org/apache/fop/fo/flow/table/TableAndCaption.java
+++ b/src/java/org/apache/fop/fo/flow/table/TableAndCaption.java
@@ -62,7 +62,8 @@ public class TableAndCaption extends FObj {
super(parent);
if (!notImplementedWarningGiven) {
- log.warn("fo:table-and-caption is not yet implemented.");
+ getFOValidationEventProducer().unimplementedFeature(this, getName(),
+ "fo:table-and-caption", getLocator());
notImplementedWarningGiven = true;
}
}
@@ -83,30 +84,32 @@ public class TableAndCaption extends FObj {
* XSL Content Model: marker* table-caption? table
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
+ throws ValidationException {
- if (FO_URI.equals(nsURI) && localName.equals("marker")) {
- if (tableCaptionFound) {
- nodesOutOfOrderError(loc, "fo:marker", "fo:table-caption");
- } else if (tableFound) {
- nodesOutOfOrderError(loc, "fo:marker", "fo:table");
- }
- } else if (FO_URI.equals(nsURI) && localName.equals("table-caption")) {
- if (tableCaptionFound) {
- tooManyNodesError(loc, "fo:table-caption");
- } else if (tableFound) {
- nodesOutOfOrderError(loc, "fo:table-caption", "fo:table");
- } else {
- tableCaptionFound = true;
- }
- } else if (FO_URI.equals(nsURI) && localName.equals("table")) {
- if (tableFound) {
- tooManyNodesError(loc, "fo:table");
+ if (FO_URI.equals(nsURI)) {
+ if (localName.equals("marker")) {
+ if (tableCaptionFound) {
+ nodesOutOfOrderError(loc, "fo:marker", "fo:table-caption");
+ } else if (tableFound) {
+ nodesOutOfOrderError(loc, "fo:marker", "fo:table");
+ }
+ } else if (localName.equals("table-caption")) {
+ if (tableCaptionFound) {
+ tooManyNodesError(loc, "fo:table-caption");
+ } else if (tableFound) {
+ nodesOutOfOrderError(loc, "fo:table-caption", "fo:table");
+ } else {
+ tableCaptionFound = true;
+ }
+ } else if (localName.equals("table")) {
+ if (tableFound) {
+ tooManyNodesError(loc, "fo:table");
+ } else {
+ tableFound = true;
+ }
} else {
- tableFound = true;
+ invalidChildError(loc, nsURI, localName);
}
- } else {
- invalidChildError(loc, nsURI, localName);
}
}
diff --git a/src/java/org/apache/fop/fo/flow/table/TableBody.java b/src/java/org/apache/fop/fo/flow/table/TableBody.java
index de7bfda84..4e1673568 100644
--- a/src/java/org/apache/fop/fo/flow/table/TableBody.java
+++ b/src/java/org/apache/fop/fo/flow/table/TableBody.java
@@ -23,13 +23,14 @@ import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.ValidationException;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
-import org.xml.sax.Attributes;
-import org.xml.sax.Locator;
/**
* Class modelling the fo:table-body object.
@@ -119,13 +120,8 @@ public class TableBody extends TableCellContainer {
getFOEventHandler().endBody(this);
if (!(tableRowsFound || tableCellsFound)) {
- if (getUserAgent().validateStrictly()) {
- missingChildElementError("marker* (table-row+|table-cell+)");
- } else {
- log.error("fo:table-body must not be empty. "
- + "Expected: marker* (table-row+|table-cell+)");
- getParent().removeChild(this);
- }
+ missingChildElementError("marker* (table-row+|table-cell+)", true);
+ getParent().removeChild(this);
} else {
finishLastRowGroup();
}
@@ -167,23 +163,20 @@ public class TableBody extends TableCellContainer {
} else if (localName.equals("table-row")) {
tableRowsFound = true;
if (tableCellsFound) {
- invalidChildError(loc, nsURI, localName, "Either fo:table-rows"
- + " or fo:table-cells may be children of an " + getName()
- + " but not both");
+ TableEventProducer eventProducer = TableEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.noMixRowsAndCells(this, getName(), getLocator());
}
} else if (localName.equals("table-cell")) {
tableCellsFound = true;
if (tableRowsFound) {
- invalidChildError(loc, nsURI, localName,
- "Either fo:table-rows or fo:table-cells "
- + "may be children of an "
- + getName() + " but not both");
+ TableEventProducer eventProducer = TableEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.noMixRowsAndCells(this, getName(), getLocator());
}
} else {
invalidChildError(loc, nsURI, localName);
}
- } else {
- invalidChildError(loc, nsURI, localName);
}
}
diff --git a/src/java/org/apache/fop/fo/flow/table/TableCaption.java b/src/java/org/apache/fop/fo/flow/table/TableCaption.java
index 28174067c..416ef16ed 100644
--- a/src/java/org/apache/fop/fo/flow/table/TableCaption.java
+++ b/src/java/org/apache/fop/fo/flow/table/TableCaption.java
@@ -57,7 +57,8 @@ public class TableCaption extends FObj {
super(parent);
if (!notImplementedWarningGiven) {
- log.warn("fo:table-caption is not yet implemented.");
+ getFOValidationEventProducer().unimplementedFeature(this, getName(),
+ "fo:table-caption", getLocator());
notImplementedWarningGiven = true;
}
}
@@ -83,15 +84,17 @@ public class TableCaption extends FObj {
* XSL Content Model: marker* (%block;)
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
- if (FO_URI.equals(nsURI) && localName.equals("marker")) {
- if (blockItemFound) {
- nodesOutOfOrderError(loc, "fo:marker", "(%block;)");
+ throws ValidationException {
+ if (FO_URI.equals(nsURI)) {
+ if (localName.equals("marker")) {
+ if (blockItemFound) {
+ nodesOutOfOrderError(loc, "fo:marker", "(%block;)");
+ }
+ } else if (!isBlockItem(nsURI, localName)) {
+ invalidChildError(loc, nsURI, localName);
+ } else {
+ blockItemFound = true;
}
- } else if (!isBlockItem(nsURI, localName)) {
- invalidChildError(loc, nsURI, localName);
- } else {
- blockItemFound = true;
}
}
diff --git a/src/java/org/apache/fop/fo/flow/table/TableCell.java b/src/java/org/apache/fop/fo/flow/table/TableCell.java
index 80dbe5e2a..78e35eb52 100644
--- a/src/java/org/apache/fop/fo/flow/table/TableCell.java
+++ b/src/java/org/apache/fop/fo/flow/table/TableCell.java
@@ -102,17 +102,13 @@ public class TableCell extends TableFObj {
*/
public void endOfNode() throws FOPException {
if (!blockItemFound) {
- if (getUserAgent().validateStrictly()) {
- missingChildElementError("marker* (%block;)+");
- } else if (firstChild != null) {
- log.warn("fo:table-cell content that is not "
- + "enclosed by a fo:block will be dropped/ignored.");
- }
+ missingChildElementError("marker* (%block;)+", true);
}
if ((startsRow() || endsRow())
&& getParent().getNameId() == FO_TABLE_ROW ) {
- log.warn("starts-row/ends-row for fo:table-cells "
- + "non-applicable for children of an fo:table-row.");
+ TableEventProducer eventProducer = TableEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.startEndRowUnderTableRowWarning(this, getLocator());
}
getFOEventHandler().endCell(this);
}
@@ -123,14 +119,16 @@ public class TableCell extends TableFObj {
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
throws ValidationException {
- if (FO_URI.equals(nsURI) && localName.equals("marker")) {
- if (blockItemFound) {
- nodesOutOfOrderError(loc, "fo:marker", "(%block;)");
+ if (FO_URI.equals(nsURI)) {
+ if (localName.equals("marker")) {
+ if (blockItemFound) {
+ nodesOutOfOrderError(loc, "fo:marker", "(%block;)");
+ }
+ } else if (!isBlockItem(nsURI, localName)) {
+ invalidChildError(loc, nsURI, localName);
+ } else {
+ blockItemFound = true;
}
- } else if (!isBlockItem(nsURI, localName)) {
- invalidChildError(loc, nsURI, localName);
- } else {
- blockItemFound = true;
}
}
diff --git a/src/java/org/apache/fop/fo/flow/table/TableCellContainer.java b/src/java/org/apache/fop/fo/flow/table/TableCellContainer.java
index 7c91be351..de9f271b5 100644
--- a/src/java/org/apache/fop/fo/flow/table/TableCellContainer.java
+++ b/src/java/org/apache/fop/fo/flow/table/TableCellContainer.java
@@ -24,7 +24,6 @@ import java.util.List;
import org.apache.fop.apps.FOPException;
import org.apache.fop.datatypes.Length;
import org.apache.fop.fo.FONode;
-import org.apache.fop.fo.ValidationException;
/**
* A common class for fo:table-body and fo:table-row which both can contain fo:table-cell.
@@ -47,9 +46,9 @@ public abstract class TableCellContainer extends TableFObj implements ColumnNumb
Table t = getTable();
if (t.hasExplicitColumns()) {
if (colNumber + colSpan - 1 > t.getNumberOfColumns()) {
- throw new ValidationException(FONode.errorText(locator) + "column-number or "
- + "number of cells in the row overflows the number of fo:table-column "
- + "specified for the table.");
+ TableEventProducer eventProducer = TableEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.tooManyCells(this, getLocator());
}
} else {
t.ensureColumnNumber(colNumber + colSpan - 1);
diff --git a/src/java/org/apache/fop/fo/flow/table/TableColumn.java b/src/java/org/apache/fop/fo/flow/table/TableColumn.java
index aeb401893..e6f6b420e 100644
--- a/src/java/org/apache/fop/fo/flow/table/TableColumn.java
+++ b/src/java/org/apache/fop/fo/flow/table/TableColumn.java
@@ -82,12 +82,16 @@ public class TableColumn extends TableFObj {
super.bind(pList);
if (numberColumnsRepeated <= 0) {
- throw new PropertyException("number-columns-repeated must be 1 or bigger, "
- + "but got " + numberColumnsRepeated);
+ TableEventProducer eventProducer = TableEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.valueMustBeBiggerGtEqOne(this,
+ "number-columns-repeated", numberColumnsRepeated, getLocator());
}
if (numberColumnsSpanned <= 0) {
- throw new PropertyException("number-columns-spanned must be 1 or bigger, "
- + "but got " + numberColumnsSpanned);
+ TableEventProducer eventProducer = TableEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.valueMustBeBiggerGtEqOne(this,
+ "number-columns-spanned", numberColumnsSpanned, getLocator());
}
/* check for unspecified width and replace with default of
@@ -96,8 +100,9 @@ public class TableColumn extends TableFObj {
*/
if (columnWidth.getEnum() == EN_AUTO) {
if (!this.implicitColumn && !getTable().isAutoLayout()) {
- log.warn("table-layout=\"fixed\" and column-width unspecified "
- + "=> falling back to proportional-column-width(1)");
+ TableEventProducer eventProducer = TableEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.warnImplicitColumns(this, getLocator());
}
columnWidth = new TableColLength(1.0, this);
}
@@ -146,7 +151,9 @@ public class TableColumn extends TableFObj {
protected void validateChildNode(Locator loc,
String nsURI, String localName)
throws ValidationException {
+ if (FO_URI.equals(nsURI)) {
invalidChildError(loc, nsURI, localName);
+ }
}
/**
@@ -240,7 +247,7 @@ public class TableColumn extends TableFObj {
*
* @param propId the id for the property to retrieve
* @return the requested Property
- * @throws PropertyException
+ * @throws PropertyException if there is a problem evaluating the property
*/
public Property getProperty(int propId) throws PropertyException {
return this.pList.get(propId);
diff --git a/src/java/org/apache/fop/fo/flow/table/TableEventProducer.java b/src/java/org/apache/fop/fo/flow/table/TableEventProducer.java
new file mode 100644
index 000000000..44ddcc038
--- /dev/null
+++ b/src/java/org/apache/fop/fo/flow/table/TableEventProducer.java
@@ -0,0 +1,159 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.fo.flow.table;
+
+import org.xml.sax.Locator;
+
+import org.apache.fop.events.EventBroadcaster;
+import org.apache.fop.events.EventProducer;
+import org.apache.fop.fo.ValidationException;
+import org.apache.fop.fo.expr.PropertyException;
+
+/**
+ * Event producer interface for table-specific XSL-FO validation messages.
+ */
+public interface TableEventProducer extends EventProducer {
+
+ /** Provider class for the event producer. */
+ class Provider {
+
+ /**
+ * Returns an event producer.
+ * @param broadcaster the event broadcaster to use
+ * @return the event producer
+ */
+ public static TableEventProducer get(EventBroadcaster broadcaster) {
+ return (TableEventProducer)broadcaster.getEventProducerFor(
+ TableEventProducer.class);
+ }
+ }
+
+ /**
+ * A value other than "auto" has been specified on fo:table.
+ * @param source the event source
+ * @param loc the location of the error or null
+ * @event.severity WARN
+ */
+ void nonAutoBPDOnTable(Object source, Locator loc);
+
+ /**
+ * Padding on fo:table is ignored if the collapsing border model is active.
+ * @param source the event source
+ * @param loc the location of the error or null
+ * @event.severity WARN
+ */
+ void noTablePaddingWithCollapsingBorderModel(Object source, Locator loc);
+
+ /**
+ * No mixing of table-rows and table-cells is allowed for direct children of table-body.
+ * @param source the event source
+ * @param elementName the name of the context node
+ * @param loc the location of the error or null
+ * @throws ValidationException the validation error provoked by the method call
+ * @event.severity FATAL
+ */
+ void noMixRowsAndCells(Object source, String elementName, Locator loc)
+ throws ValidationException;
+
+ /**
+ * The table-footer was found after the table-body. FOP cannot recover with collapsed border
+ * model.
+ * @param source the event source
+ * @param elementName the name of the context node
+ * @param loc the location of the error or null
+ * @throws ValidationException the validation error provoked by the method call
+ * @event.severity FATAL
+ */
+ void footerOrderCannotRecover(Object source, String elementName, Locator loc)
+ throws ValidationException;
+
+ /**
+ * starts-row/ends-row for fo:table-cells non-applicable for children of an fo:table-row
+ * @param source the event source
+ * @param loc the location of the error or null
+ * @event.severity WARN
+ */
+ void startEndRowUnderTableRowWarning(Object source, Locator loc);
+
+ /**
+ * Column-number or number of cells in the row overflows the number of fo:table-column
+ * specified for the table.
+ * @param source the event source
+ * @param loc the location of the error or null
+ * @throws ValidationException the validation error provoked by the method call
+ * @event.severity FATAL
+ */
+ void tooManyCells(Object source, Locator loc) throws ValidationException;
+
+ /**
+ * Property value must be 1 or bigger.
+ * @param source the event source
+ * @param propName the property name
+ * @param actualValue the actual value
+ * @param loc the location of the error or null
+ * @throws PropertyException the property error provoked by the method call
+ * @event.severity FATAL
+ */
+ void valueMustBeBiggerGtEqOne(Object source, String propName,
+ int actualValue, Locator loc) throws PropertyException;
+
+ /**
+ * table-layout=\"fixed\" and column-width unspecified
+ * => falling back to proportional-column-width(1)
+ * @param source the event source
+ * @param loc the location of the error or null
+ * @event.severity WARN
+ */
+ void warnImplicitColumns(Object source, Locator loc);
+
+ /**
+ * padding-* properties are not applicable.
+ * @param source the event source
+ * @param elementName the name of the context node
+ * @param loc the location of the error or null
+ * @event.severity WARN
+ */
+ void paddingNotApplicable(Object source, String elementName, Locator loc);
+
+ /**
+ * Cell overlap.
+ * @param source the event source
+ * @param elementName the name of the context node
+ * @param column the column index of the overlapping cell
+ * @param loc the location of the error or null
+ * @throws PropertyException the property error provoked by the method call
+ * @event.severity FATAL
+ */
+ void cellOverlap(Object source, String elementName, int column,
+ Locator loc) throws PropertyException;
+
+ /**
+ * Break ignored due to row spanning.
+ * @param source the event source
+ * @param elementName the name of the context node
+ * @param breakBefore true for "break-before", false for "break-after"
+ * @param loc the location of the error or null
+ * @event.severity WARN
+ */
+ void breakIgnoredDueToRowSpanning(Object source, String elementName, boolean breakBefore,
+ Locator loc);
+
+
+}
diff --git a/src/java/org/apache/fop/fo/flow/table/TableFObj.java b/src/java/org/apache/fop/fo/flow/table/TableFObj.java
index 9618d7ff4..24528f622 100644
--- a/src/java/org/apache/fop/fo/flow/table/TableFObj.java
+++ b/src/java/org/apache/fop/fo/flow/table/TableFObj.java
@@ -58,9 +58,7 @@ public abstract class TableFObj extends FObj {
super(parent);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void bind(PropertyList pList) throws FOPException {
super.bind(pList);
borderAfterPrecedence = pList.get(PR_BORDER_AFTER_PRECEDENCE).getNumeric();
@@ -71,9 +69,9 @@ public abstract class TableFObj extends FObj {
&& getNameId() != FO_TABLE_CELL
&& getCommonBorderPaddingBackground().hasPadding(
ValidationPercentBaseContext.getPseudoContext())) {
- attributeWarning(
- "padding-* properties are not applicable to " + getName()
- + ", but a non-zero value for padding was found.");
+ TableEventProducer eventProducer = TableEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.paddingNotApplicable(this, getName(), getLocator());
}
}
@@ -156,17 +154,19 @@ public abstract class TableFObj extends FObj {
ColumnNumberManager columnIndexManager = parent.getColumnNumberManager();
int columnIndex = p.getNumeric().getValue();
if (columnIndex <= 0) {
+ /* No warning necessary as the spec clearly defines how to handle these cases.
log.warn("Specified negative or zero value for "
+ "column-number on " + fo.getName() + ": "
+ columnIndex + " forced to "
- + columnIndexManager.getCurrentColumnNumber());
+ + columnIndexManager.getCurrentColumnNumber());*/
return NumberProperty.getInstance(columnIndexManager.getCurrentColumnNumber());
} else {
double tmpIndex = p.getNumeric().getNumericValue();
if (tmpIndex - columnIndex > 0.0) {
columnIndex = (int) Math.round(tmpIndex);
+ /* No warning necessary as the spec clearly defines how to handle these cases.
log.warn("Rounding specified column-number of "
- + tmpIndex + " to " + columnIndex);
+ + tmpIndex + " to " + columnIndex);*/
p = NumberProperty.getInstance(columnIndex);
}
}
@@ -179,16 +179,9 @@ public abstract class TableFObj extends FObj {
/* if column-number is already in use by another
* cell/column => error!
*/
- StringBuffer errorMessage = new StringBuffer();
- errorMessage.append(fo.getName() + " overlaps in column ")
- .append(columnIndex + i);
- org.xml.sax.Locator loc = fo.getLocator();
- if (loc != null && loc.getLineNumber() != -1) {
- errorMessage.append(" (line #")
- .append(loc.getLineNumber()).append(", column #")
- .append(loc.getColumnNumber()).append(")");
- }
- throw new PropertyException(errorMessage.toString());
+ TableEventProducer eventProducer = TableEventProducer.Provider.get(
+ fo.getUserAgent().getEventBroadcaster());
+ eventProducer.cellOverlap(this, fo.getName(), columnIndex + 1, fo.getLocator());
}
}
diff --git a/src/java/org/apache/fop/fo/flow/table/TableRow.java b/src/java/org/apache/fop/fo/flow/table/TableRow.java
index a025f92fd..e5261614b 100644
--- a/src/java/org/apache/fop/fo/flow/table/TableRow.java
+++ b/src/java/org/apache/fop/fo/flow/table/TableRow.java
@@ -19,6 +19,9 @@
package org.apache.fop.fo.flow.table;
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.datatypes.Length;
import org.apache.fop.fo.FONode;
@@ -27,8 +30,6 @@ import org.apache.fop.fo.ValidationException;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
import org.apache.fop.fo.properties.KeepProperty;
import org.apache.fop.fo.properties.LengthRangeProperty;
-import org.xml.sax.Attributes;
-import org.xml.sax.Locator;
/**
* Class modelling the fo:table-row object.
@@ -122,9 +123,11 @@ public class TableRow extends TableCellContainer {
*/
protected void validateChildNode(Locator loc, String nsURI,
String localName)
- throws ValidationException {
- if (!(FO_URI.equals(nsURI) && localName.equals("table-cell"))) {
- invalidChildError(loc, nsURI, localName);
+ throws ValidationException {
+ if (FO_URI.equals(nsURI)) {
+ if (!localName.equals("table-cell")) {
+ invalidChildError(loc, nsURI, localName);
+ }
}
}
diff --git a/src/java/org/apache/fop/fo/pagination/AbstractPageSequence.java b/src/java/org/apache/fop/fo/pagination/AbstractPageSequence.java
index 70a09b720..578d74c4d 100644
--- a/src/java/org/apache/fop/fo/pagination/AbstractPageSequence.java
+++ b/src/java/org/apache/fop/fo/pagination/AbstractPageSequence.java
@@ -32,7 +32,9 @@ import org.apache.fop.fo.PropertyList;
public abstract class AbstractPageSequence extends FObj {
// The value of properties relevant for fo:page-sequence.
+ /** the initial-page-number value */
protected Numeric initialPageNumber;
+ /** the force-page-count value */
protected int forcePageCount;
private String format;
private int letterValue;
@@ -43,6 +45,7 @@ public abstract class AbstractPageSequence extends FObj {
private PageNumberGenerator pageNumberGenerator;
+ /** the first page number generated by the page sequence */
protected int startingPageNumber = 0;
/**
@@ -54,9 +57,7 @@ public abstract class AbstractPageSequence extends FObj {
super(parent);
}
- /**
- * @see org.apache.fop.fo.FObj#bind(PropertyList)
- */
+ /** {@inheritDoc} */
public void bind(PropertyList pList) throws FOPException {
super.bind(pList);
initialPageNumber = pList.get(PR_INITIAL_PAGE_NUMBER).getNumeric();
@@ -68,16 +69,14 @@ public abstract class AbstractPageSequence extends FObj {
referenceOrientation = pList.get(PR_REFERENCE_ORIENTATION).getNumeric();
}
- /**
- * @see org.apache.fop.fo.FONode#startOfNode()
- */
+ /** {@inheritDoc} */
protected void startOfNode() throws FOPException {
this.pageNumberGenerator = new PageNumberGenerator(
format, groupingSeparator, groupingSize, letterValue);
}
- /** @see org.apache.fop.fo.FONode#endOfNode() */
+ /** {@inheritDoc} */
protected void endOfNode() throws FOPException {
}
diff --git a/src/java/org/apache/fop/fo/pagination/ColorProfile.java b/src/java/org/apache/fop/fo/pagination/ColorProfile.java
index 9318a8896..6067b55c5 100644
--- a/src/java/org/apache/fop/fo/pagination/ColorProfile.java
+++ b/src/java/org/apache/fop/fo/pagination/ColorProfile.java
@@ -19,14 +19,14 @@
package org.apache.fop.fo.pagination;
+import org.xml.sax.Locator;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.ValidationException;
-import org.xml.sax.Locator;
-
/**
* The fo:color-profile formatting object.
* This loads the color profile when needed and resolves a requested color.
@@ -39,15 +39,15 @@ public class ColorProfile extends FObj {
// End of property values
/**
+ * Creates a new color-profile element.
+ * @param parent the parent node
* @see org.apache.fop.fo.FONode#FONode(FONode)
*/
public ColorProfile(FONode parent) {
super(parent);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void bind(PropertyList pList) throws FOPException {
src = pList.get(PR_SRC).getString();
colorProfileName = pList.get(PR_COLOR_PROFILE_NAME).getString();
@@ -59,12 +59,15 @@ public class ColorProfile extends FObj {
XSL 1.0/FOP: EMPTY (no child nodes permitted)
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
- invalidChildError(loc, nsURI, localName);
+ throws ValidationException {
+ if (FO_URI.equals(nsURI)) {
+ invalidChildError(loc, nsURI, localName);
+ }
}
/**
* Return the "color-profile-name" property.
+ * @return the color-profile-name property
*/
public String getColorProfileName() {
return colorProfileName;
@@ -75,9 +78,7 @@ public class ColorProfile extends FObj {
return "color-profile";
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public int getNameId() {
return FO_COLOR_PROFILE;
}
diff --git a/src/java/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java b/src/java/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java
index dfb4ba70b..a13808324 100644
--- a/src/java/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java
+++ b/src/java/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java
@@ -45,15 +45,15 @@ public class ConditionalPageMasterReference extends FObj {
// End of property values
/**
+ * Creates a new conditional-page-master-reference element.
+ * @param parent the parent node
* @see org.apache.fop.fo.FONode#FONode(FONode)
*/
public ConditionalPageMasterReference(FONode parent) {
super(parent);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void bind(PropertyList pList) throws FOPException {
masterReference = pList.get(PR_MASTER_REFERENCE).getString();
pagePosition = pList.get(PR_PAGE_POSITION).getEnum();
@@ -65,9 +65,7 @@ public class ConditionalPageMasterReference extends FObj {
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
protected void startOfNode() throws FOPException {
getConcreteParent().addConditionalPageMasterReference(this);
}
@@ -81,8 +79,10 @@ public class ConditionalPageMasterReference extends FObj {
* XSL Content Model: empty
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
- invalidChildError(loc, nsURI, localName);
+ throws ValidationException {
+ if (FO_URI.equals(nsURI)) {
+ invalidChildError(loc, nsURI, localName);
+ }
}
/**
diff --git a/src/java/org/apache/fop/fo/pagination/Declarations.java b/src/java/org/apache/fop/fo/pagination/Declarations.java
index 9dc282d07..3eec2897a 100644
--- a/src/java/org/apache/fop/fo/pagination/Declarations.java
+++ b/src/java/org/apache/fop/fo/pagination/Declarations.java
@@ -42,6 +42,7 @@ public class Declarations extends FObj {
private Map colorProfiles = null;
/**
+ * Creates a new declarations element.
* @param parent FONode that is the parent of this object
*/
public Declarations(FONode parent) {
@@ -49,9 +50,7 @@ public class Declarations extends FObj {
((Root) parent).setDeclarations(this);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void bind(PropertyList pList) throws FOPException {
// No properties defined for fo:declarations
}
@@ -73,6 +72,7 @@ public class Declarations extends FObj {
/**
* At the end of this element sort out the children into
* a hashmap of color profiles and a list of extension attachments.
+ * @throws FOPException if there's a problem during processing
*/
protected void endOfNode() throws FOPException {
if (firstChild != null) {
@@ -83,7 +83,8 @@ public class Declarations extends FObj {
if (!"".equals(cp.getColorProfileName())) {
addColorProfile(cp);
} else {
- log.warn("color-profile-name required for color profile");
+ getFOValidationEventProducer().missingProperty(this,
+ cp.getName(), "color-profile-name", locator);
}
} else {
log.debug("Ignoring element " + node.getName()
@@ -100,22 +101,18 @@ public class Declarations extends FObj {
}
if (colorProfiles.get(cp.getColorProfileName()) != null) {
// duplicate names
- log.warn("Duplicate fo:color-profile profile name: "
- + cp.getColorProfileName());
+ getFOValidationEventProducer().colorProfileNameNotUnique(this,
+ cp.getName(), cp.getColorProfileName(), locator);
}
colorProfiles.put(cp.getColorProfileName(), cp);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public String getLocalName() {
return "declarations";
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public int getNameId() {
return FO_DECLARATIONS;
}
diff --git a/src/java/org/apache/fop/fo/pagination/Flow.java b/src/java/org/apache/fop/fo/pagination/Flow.java
index fc5d605cc..2ee77ff0a 100644
--- a/src/java/org/apache/fop/fo/pagination/Flow.java
+++ b/src/java/org/apache/fop/fo/pagination/Flow.java
@@ -45,16 +45,12 @@ public class Flow extends FObj {
super(parent);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void bind(PropertyList pList) throws FOPException {
flowName = pList.get(PR_FLOW_NAME).getString();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
protected void startOfNode() throws FOPException {
if (flowName == null || flowName.equals("")) {
missingPropertyError("flow-name");
@@ -80,10 +76,7 @@ public class Flow extends FObj {
getFOEventHandler().startFlow(this);
}
- /**
- * Make sure content model satisfied, if so then tell the
- * FOEventHandler that we are at the end of the flow.
- */
+ /** {@inheritDoc} */
protected void endOfNode() throws FOPException {
if (!blockItemFound) {
missingChildElementError("marker* (%block;)+");
@@ -96,21 +89,21 @@ public class Flow extends FObj {
* XSL Content Model: marker* (%block;)+
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
- if (FO_URI.equals(nsURI) && localName.equals("marker")) {
- if (blockItemFound) {
- nodesOutOfOrderError(loc, "fo:marker", "(%block;)");
+ throws ValidationException {
+ if (FO_URI.equals(nsURI)) {
+ if (localName.equals("marker")) {
+ if (blockItemFound) {
+ nodesOutOfOrderError(loc, "fo:marker", "(%block;)");
+ }
+ } else if (!isBlockItem(nsURI, localName)) {
+ invalidChildError(loc, nsURI, localName);
+ } else {
+ blockItemFound = true;
}
- } else if (!isBlockItem(nsURI, localName)) {
- invalidChildError(loc, nsURI, localName);
- } else {
- blockItemFound = true;
}
}
- /**
- * @return true (Flow can generate reference areas)
- */
+ /** {@inheritDoc} */
public boolean generatesReferenceAreas() {
return true;
}
@@ -125,9 +118,7 @@ public class Flow extends FObj {
return "flow";
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public int getNameId() {
return FO_FLOW;
}
diff --git a/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java b/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java
index 54eb29744..1b57be57d 100644
--- a/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java
+++ b/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java
@@ -46,31 +46,27 @@ public class LayoutMasterSet extends FObj {
private Map pageSequenceMasters;
/**
+ * Creates a new layout-master-set element.
+ * @param parent the parent node
* @see org.apache.fop.fo.FONode#FONode(FONode)
*/
public LayoutMasterSet(FONode parent) {
super(parent);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void bind(PropertyList pList) throws FOPException {
// No properties in layout-master-set.
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
protected void startOfNode() throws FOPException {
getRoot().setLayoutMasterSet(this);
simplePageMasters = new java.util.HashMap();
pageSequenceMasters = new java.util.HashMap();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
protected void endOfNode() throws FOPException {
if (firstChild == null) {
missingChildElementError("(simple-page-master|page-sequence-master)+");
@@ -83,14 +79,12 @@ public class LayoutMasterSet extends FObj {
XSL/FOP: (simple-page-master|page-sequence-master)+
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
+ throws ValidationException {
if (FO_URI.equals(nsURI)) {
if (!localName.equals("simple-page-master")
&& !localName.equals("page-sequence-master")) {
invalidChildError(loc, nsURI, localName);
}
- } else {
- invalidChildError(loc, nsURI, localName);
}
}
@@ -104,23 +98,20 @@ public class LayoutMasterSet extends FObj {
Map allRegions = new java.util.HashMap();
for (Iterator spm = simplePageMasters.values().iterator();
spm.hasNext();) {
- SimplePageMaster simplePageMaster =
- (SimplePageMaster)spm.next();
+ SimplePageMaster simplePageMaster
+ = (SimplePageMaster)spm.next();
Map spmRegions = simplePageMaster.getRegions();
for (Iterator e = spmRegions.values().iterator();
e.hasNext();) {
Region region = (Region) e.next();
if (allRegions.containsKey(region.getRegionName())) {
- String defaultRegionName =
- (String) allRegions.get(region.getRegionName());
+ String defaultRegionName
+ = (String) allRegions.get(region.getRegionName());
if (!defaultRegionName.equals(region.getDefaultRegionName())) {
- throw new ValidationException("Region-name ("
- + region.getRegionName()
- + ") is being mapped to multiple "
- + "region-classes ("
- + defaultRegionName + " and "
- + region.getDefaultRegionName()
- + ")", locator);
+ getFOValidationEventProducer().regionNameMappedToMultipleRegionClasses(this,
+ region.getRegionName(),
+ defaultRegionName,
+ region.getDefaultRegionName(), getLocator());
}
}
allRegions.put(region.getRegionName(),
@@ -141,21 +132,16 @@ public class LayoutMasterSet extends FObj {
// check for duplication of master-name
String masterName = sPM.getMasterName();
if (existsName(masterName)) {
- throw new ValidationException("'master-name' ("
- + masterName
- + ") must be unique "
- + "across page-masters and page-sequence-masters", sPM.getLocator());
+ getFOValidationEventProducer().masterNameNotUnique(this,
+ getName(),
+ masterName, sPM.getLocator());
}
this.simplePageMasters.put(masterName, sPM);
}
private boolean existsName(String masterName) {
- if (simplePageMasters.containsKey(masterName)
- || pageSequenceMasters.containsKey(masterName)) {
- return true;
- } else {
- return false;
- }
+ return (simplePageMasters.containsKey(masterName)
+ || pageSequenceMasters.containsKey(masterName));
}
/**
@@ -181,10 +167,9 @@ public class LayoutMasterSet extends FObj {
throws ValidationException {
// check against duplication of master-name
if (existsName(masterName)) {
- throw new ValidationException("'master-name' ("
- + masterName
- + ") must be unique "
- + "across page-masters and page-sequence-masters", pSM.getLocator());
+ getFOValidationEventProducer().masterNameNotUnique(this,
+ getName(),
+ masterName, pSM.getLocator());
}
this.pageSequenceMasters.put(masterName, pSM);
}
@@ -220,9 +205,7 @@ public class LayoutMasterSet extends FObj {
return "layout-master-set";
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public int getNameId() {
return FO_LAYOUT_MASTER_SET;
}
diff --git a/src/java/org/apache/fop/fo/pagination/PageNumberGenerator.java b/src/java/org/apache/fop/fo/pagination/PageNumberGenerator.java
index 4289076ea..50620f678 100644
--- a/src/java/org/apache/fop/fo/pagination/PageNumberGenerator.java
+++ b/src/java/org/apache/fop/fo/pagination/PageNumberGenerator.java
@@ -43,7 +43,7 @@ public class PageNumberGenerator {
private int minPadding = 0; // for decimal formats
// preloaded strings of zeros
- private String zeros[] = {
+ private String[] zeros = {
"", "0", "00", "000", "0000", "00000"
};
@@ -128,10 +128,10 @@ public class PageNumberGenerator {
}
private String makeRoman(int num) {
- int arabic[] = {
+ int[] arabic = {
1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1
};
- String roman[] = {
+ String[] roman = {
"m", "cm", "d", "cd", "c", "xc", "l", "xl", "x", "ix", "v", "iv",
"i"
};
diff --git a/src/java/org/apache/fop/fo/pagination/PageSequence.java b/src/java/org/apache/fop/fo/pagination/PageSequence.java
index 91649fbc5..3d155a1da 100644
--- a/src/java/org/apache/fop/fo/pagination/PageSequence.java
+++ b/src/java/org/apache/fop/fo/pagination/PageSequence.java
@@ -78,9 +78,7 @@ public class PageSequence extends AbstractPageSequence {
super(parent);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void bind(PropertyList pList) throws FOPException {
super.bind(pList);
country = pList.get(PR_COUNTRY).getString();
@@ -93,9 +91,7 @@ public class PageSequence extends AbstractPageSequence {
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
protected void startOfNode() throws FOPException {
super.startOfNode();
flowMap = new java.util.HashMap();
@@ -105,9 +101,8 @@ public class PageSequence extends AbstractPageSequence {
this.pageSequenceMaster
= getRoot().getLayoutMasterSet().getPageSequenceMaster(masterReference);
if (this.pageSequenceMaster == null) {
- throw new ValidationException("master-reference '" + masterReference
- + "' for fo:page-sequence matches no"
- + " simple-page-master or page-sequence-master", locator);
+ getFOValidationEventProducer().masterNotFound(this, getName(),
+ masterReference, getLocator());
}
}
@@ -128,7 +123,7 @@ public class PageSequence extends AbstractPageSequence {
XSL Content Model: (title?,static-content*,flow)
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
+ throws ValidationException {
if (FO_URI.equals(nsURI)) {
if (localName.equals("title")) {
if (titleFO != null) {
@@ -149,8 +144,6 @@ public class PageSequence extends AbstractPageSequence {
} else {
invalidChildError(loc, nsURI, localName);
}
- } else {
- invalidChildError(loc, nsURI, localName);
}
}
@@ -184,18 +177,15 @@ public class PageSequence extends AbstractPageSequence {
String flowName = flow.getFlowName();
if (hasFlowName(flowName)) {
- throw new ValidationException("duplicate flow-name \""
- + flowName
- + "\" found within fo:page-sequence", flow.getLocator());
+ getFOValidationEventProducer().duplicateFlowNameInPageSequence(this, flow.getName(),
+ flowName, flow.getLocator());
}
if (!getRoot().getLayoutMasterSet().regionNameExists(flowName)
&& !flowName.equals("xsl-before-float-separator")
&& !flowName.equals("xsl-footnote-separator")) {
- throw new ValidationException("flow-name \""
- + flowName
- + "\" could not be mapped to a region-name in the"
- + " layout-master-set", flow.getLocator());
+ getFOValidationEventProducer().flowNameNotMapped(this, flow.getName(),
+ flowName, flow.getLocator());
}
}
diff --git a/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java b/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java
index 34ad299bd..4258a1139 100644
--- a/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java
+++ b/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java
@@ -29,6 +29,7 @@ import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.ValidationException;
+import org.apache.fop.layoutmgr.BlockLevelEventProducer;
/**
* The page-sequence-master formatting object.
@@ -53,6 +54,8 @@ public class PageSequenceMaster extends FObj {
// but the actual FO's are MasterReferences.
/**
+ * Creates a new page-sequence-master element.
+ * @param parent the parent node
* @see org.apache.fop.fo.FONode#FONode(FONode)
*/
public PageSequenceMaster(FONode parent) {
@@ -95,20 +98,18 @@ public class PageSequenceMaster extends FObj {
* repeatable-page-master-alternatives)+
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
+ throws ValidationException {
if (FO_URI.equals(nsURI)) {
if (!localName.equals("single-page-master-reference")
&& !localName.equals("repeatable-page-master-reference")
&& !localName.equals("repeatable-page-master-alternatives")) {
invalidChildError(loc, nsURI, localName);
}
- } else {
- invalidChildError(loc, nsURI, localName);
}
}
/**
- * Adds a new suqsequence specifier to the page sequence master.
+ * Adds a new subsequence specifier to the page sequence master.
* @param pageMasterReference the subsequence to add
*/
protected void addSubsequenceSpecifier(SubSequenceSpecifier pageMasterReference) {
@@ -199,8 +200,10 @@ public class PageSequenceMaster extends FObj {
if (currentSubSequence == null) {
currentSubSequence = getNextSubSequence();
if (currentSubSequence == null) {
- throw new FOPException("no subsequences in page-sequence-master '"
- + masterName + "'");
+ BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.missingSubsequencesInPageSequenceMaster(this,
+ masterName, getLocator());
}
}
String pageMasterName = currentSubSequence
@@ -209,14 +212,10 @@ public class PageSequenceMaster extends FObj {
while (pageMasterName == null) {
SubSequenceSpecifier nextSubSequence = getNextSubSequence();
if (nextSubSequence == null) {
- if (!canRecover) {
- throw new FOPException("subsequences exhausted in page-sequence-master '"
- + masterName
- + "', cannot recover");
- }
- log.warn("subsequences exhausted in page-sequence-master '"
- + masterName
- + "', using previous subsequence");
+ BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.pageSequenceMasterExhausted(this,
+ masterName, canRecover, getLocator());
currentSubSequence.reset();
canRecover = false;
} else {
@@ -228,9 +227,10 @@ public class PageSequenceMaster extends FObj {
SimplePageMaster pageMaster = this.layoutMasterSet
.getSimplePageMaster(pageMasterName);
if (pageMaster == null) {
- throw new FOPException("No simple-page-master matching '"
- + pageMasterName + "' in page-sequence-master '"
- + masterName + "'");
+ BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.noMatchingPageMaster(this,
+ masterName, pageMasterName, getLocator());
}
return pageMaster;
}
@@ -240,9 +240,7 @@ public class PageSequenceMaster extends FObj {
return "page-sequence-master";
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public int getNameId() {
return FO_PAGE_SEQUENCE_MASTER;
}
diff --git a/src/java/org/apache/fop/fo/pagination/PageSequenceWrapper.java b/src/java/org/apache/fop/fo/pagination/PageSequenceWrapper.java
index 94c0314a3..0b3cff276 100644
--- a/src/java/org/apache/fop/fo/pagination/PageSequenceWrapper.java
+++ b/src/java/org/apache/fop/fo/pagination/PageSequenceWrapper.java
@@ -22,8 +22,8 @@ package org.apache.fop.fo.pagination;
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;
@@ -39,15 +39,14 @@ public class PageSequenceWrapper extends FObj {
// End of property values
/**
+ * Creates a new page-sequence-wrapper element.
* @param parent FONode that is the parent of this object
*/
public PageSequenceWrapper(FONode parent) {
super(parent);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void bind(PropertyList pList) throws FOPException {
super.bind(pList);
indexClass = pList.get(PR_INDEX_CLASS).getString();
@@ -59,10 +58,12 @@ public class PageSequenceWrapper extends FObj {
XSL/FOP: (bookmark+)
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
- if (!(FO_URI.equals(nsURI) && (localName.equals("page-sequence") ||
- localName.equals("page-sequence-wrapper")))) {
+ throws ValidationException {
+ if (FO_URI.equals(nsURI)) {
+ if (!(localName.equals("page-sequence")
+ || localName.equals("page-sequence-wrapper"))) {
invalidChildError(loc, nsURI, localName);
+ }
}
}
@@ -81,9 +82,7 @@ public class PageSequenceWrapper extends FObj {
return "page-sequence-wrapper";
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public int getNameId() {
return FO_PAGE_SEQUENCE_WRAPPER;
}
diff --git a/src/java/org/apache/fop/fo/pagination/Region.java b/src/java/org/apache/fop/fo/pagination/Region.java
index 2516f90d8..ded86514b 100644
--- a/src/java/org/apache/fop/fo/pagination/Region.java
+++ b/src/java/org/apache/fop/fo/pagination/Region.java
@@ -30,7 +30,6 @@ import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.ValidationException;
-import org.apache.fop.fo.expr.PropertyException;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
/**
@@ -50,6 +49,8 @@ public abstract class Region extends FObj {
private SimplePageMaster layoutMaster;
/**
+ * Creates a new Region.
+ * @param parent the parent node
* @see org.apache.fop.fo.FONode#FONode(FONode)
*/
protected Region(FONode parent) {
@@ -57,9 +58,7 @@ public abstract class Region extends FObj {
layoutMaster = (SimplePageMaster) parent;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void bind(PropertyList pList) throws FOPException {
commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps();
// clip = pList.get(PR_CLIP);
@@ -76,18 +75,16 @@ public abstract class Region extends FObj {
// check that name is OK. Not very pretty.
if (isReserved(getRegionName())
&& !getRegionName().equals(getDefaultRegionName())) {
- throw new ValidationException("region-name '" + regionName
- + "' for " + this.getName()
- + " is not permitted.", locator);
+ getFOValidationEventProducer().illegalRegionName(this, getName(),
+ regionName, getLocator());
}
}
//TODO do we need context for getBPPaddingAndBorder() and getIPPaddingAndBorder()?
- if (getUserAgent().validateStrictly()
- && (getCommonBorderPaddingBackground().getBPPaddingAndBorder(false, null) != 0
+ if ((getCommonBorderPaddingBackground().getBPPaddingAndBorder(false, null) != 0
|| getCommonBorderPaddingBackground().getIPPaddingAndBorder(false, null) != 0)) {
- throw new PropertyException("Border and padding for region \""
- + regionName + "\" must be '0' (See 6.4.13 in XSL 1.0).");
+ getFOValidationEventProducer().nonZeroBorderPaddingOnRegion(this, getName(),
+ regionName, true, getLocator());
}
}
@@ -96,8 +93,10 @@ public abstract class Region extends FObj {
* XSL Content Model: empty
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
+ throws ValidationException {
+ if (FO_URI.equals(nsURI)) {
invalidChildError(loc, nsURI, localName);
+ }
}
/**
@@ -121,7 +120,7 @@ public abstract class Region extends FObj {
* @param name a region name to check
* @return true if the name parameter is a reserved region name
*/
- protected boolean isReserved(String name) /*throws FOPException*/ {
+ protected boolean isReserved(String name) {
return (name.equals("xsl-region-before")
|| name.equals("xsl-region-start")
|| name.equals("xsl-region-end")
@@ -130,9 +129,7 @@ public abstract class Region extends FObj {
|| name.equals("xsl-footnote-separator"));
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public boolean generatesReferenceAreas() {
return true;
}
diff --git a/src/java/org/apache/fop/fo/pagination/RegionAfter.java b/src/java/org/apache/fop/fo/pagination/RegionAfter.java
index 9459a6637..2852358b5 100644
--- a/src/java/org/apache/fop/fo/pagination/RegionAfter.java
+++ b/src/java/org/apache/fop/fo/pagination/RegionAfter.java
@@ -34,15 +34,15 @@ import org.apache.fop.datatypes.SimplePercentBaseContext;
public class RegionAfter extends RegionBA {
/**
+ * Creates a new region-after element.
+ * @param parent the parent node
* @see org.apache.fop.fo.FONode#FONode(FONode)
*/
public RegionAfter(FONode parent) {
super(parent);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public Rectangle getViewportRectangle (FODimension reldims, SimplePageMaster spm) {
/* Special rules apply to resolving extent as values are resolved relative
* to the page size and reference orientation.
@@ -82,9 +82,7 @@ public class RegionAfter extends RegionBA {
return vpRect;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
protected String getDefaultRegionName() {
return "xsl-region-after";
}
@@ -94,9 +92,7 @@ public class RegionAfter extends RegionBA {
return "region-after";
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public int getNameId() {
return FO_REGION_AFTER;
}
diff --git a/src/java/org/apache/fop/fo/pagination/RegionBA.java b/src/java/org/apache/fop/fo/pagination/RegionBA.java
index 768af2489..279164a96 100644
--- a/src/java/org/apache/fop/fo/pagination/RegionBA.java
+++ b/src/java/org/apache/fop/fo/pagination/RegionBA.java
@@ -36,15 +36,15 @@ public abstract class RegionBA extends SideRegion {
// End of property values
/**
+ * Creates a new region (before or after).
+ * @param parent the parent node
* @see org.apache.fop.fo.FONode#FONode(FONode)
*/
protected RegionBA(FONode parent) {
super(parent);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void bind(PropertyList pList) throws FOPException {
super.bind(pList);
precedence = pList.get(PR_PRECEDENCE).getEnum();
diff --git a/src/java/org/apache/fop/fo/pagination/RegionBefore.java b/src/java/org/apache/fop/fo/pagination/RegionBefore.java
index 6115d8dd8..076737252 100644
--- a/src/java/org/apache/fop/fo/pagination/RegionBefore.java
+++ b/src/java/org/apache/fop/fo/pagination/RegionBefore.java
@@ -32,23 +32,22 @@ import org.apache.fop.fo.FONode;
* The fo:region-before element.
*/
public class RegionBefore extends RegionBA {
+
/**
+ * Creates a new region-before element.
+ * @param parent the parent element
* @see org.apache.fop.fo.FONode#FONode(FONode)
*/
public RegionBefore(FONode parent) {
super(parent);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
protected String getDefaultRegionName() {
return "xsl-region-before";
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public Rectangle getViewportRectangle (FODimension reldims, SimplePageMaster spm) {
/* Special rules apply to resolving extent as values are resolved relative
* to the page size and reference orientation.
@@ -91,9 +90,7 @@ public class RegionBefore extends RegionBA {
return "region-before";
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public int getNameId() {
return FO_REGION_BEFORE;
}
diff --git a/src/java/org/apache/fop/fo/pagination/RegionBody.java b/src/java/org/apache/fop/fo/pagination/RegionBody.java
index 4de2dd1b4..9700e72fc 100644
--- a/src/java/org/apache/fop/fo/pagination/RegionBody.java
+++ b/src/java/org/apache/fop/fo/pagination/RegionBody.java
@@ -43,29 +43,29 @@ public class RegionBody extends Region {
// End of property values
/**
+ * Creates a new region-body element.
+ * @param parent the parent node
* @see org.apache.fop.fo.FONode#FONode(FONode)
*/
public RegionBody(FONode parent) {
super(parent);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void bind(PropertyList pList) throws FOPException {
super.bind(pList);
commonMarginBlock = pList.getMarginBlockProps();
columnCount = pList.get(PR_COLUMN_COUNT).getNumeric();
columnGap = pList.get(PR_COLUMN_GAP).getLength();
- if ((getColumnCount() > 1) && (getOverflow() == EN_SCROLL)) {
+ if ((getColumnCount() != 1) && (getOverflow() == EN_SCROLL)) {
/* This is an error (See XSL Rec, fo:region-body description).
* The Rec allows for acting as if "1" is chosen in
* these cases, but we will need to be able to change Numeric
* values in order to do this.
*/
- attributeError("If overflow property is set to \"scroll\","
- + " a column-count other than \"1\" may not be specified.");
+ getFOValidationEventProducer().columnCountErrorOnRegionBodyOverflowScroll(this,
+ getName(), getLocator());
}
}
@@ -93,9 +93,7 @@ public class RegionBody extends Region {
return columnGap.getValue();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public Rectangle getViewportRectangle (FODimension reldims, SimplePageMaster spm) {
/* Special rules apply to resolving margins in the page context.
* Contrary to normal margins in this case top and bottom margin
@@ -143,9 +141,7 @@ public class RegionBody extends Region {
reldims.bpd - before - after);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
protected String getDefaultRegionName() {
return "xsl-region-body";
}
@@ -155,9 +151,7 @@ public class RegionBody extends Region {
return "region-body";
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public int getNameId() {
return FO_REGION_BODY;
}
diff --git a/src/java/org/apache/fop/fo/pagination/RegionEnd.java b/src/java/org/apache/fop/fo/pagination/RegionEnd.java
index 912be9097..13f65d71a 100644
--- a/src/java/org/apache/fop/fo/pagination/RegionEnd.java
+++ b/src/java/org/apache/fop/fo/pagination/RegionEnd.java
@@ -22,26 +22,26 @@ package org.apache.fop.fo.pagination;
// Java
import java.awt.Rectangle;
-// FOP
-import org.apache.fop.fo.FONode;
import org.apache.fop.datatypes.FODimension;
import org.apache.fop.datatypes.LengthBase;
import org.apache.fop.datatypes.SimplePercentBaseContext;
+import org.apache.fop.fo.FONode;
/**
* The fo:region-end element.
*/
public class RegionEnd extends RegionSE {
+
/**
+ * Creates a new region-end element.
+ * @param parent the parent node
* @see org.apache.fop.fo.FONode#FONode(FONode)
*/
public RegionEnd(FONode parent) {
super(parent);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public Rectangle getViewportRectangle (FODimension reldims, SimplePageMaster spm) {
/* Special rules apply to resolving extent as values are resolved relative
* to the page size and reference orientation.
@@ -80,9 +80,7 @@ public class RegionEnd extends RegionSE {
return vpRect;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
protected String getDefaultRegionName() {
return "xsl-region-end";
}
@@ -92,9 +90,7 @@ public class RegionEnd extends RegionSE {
return "region-end";
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public int getNameId() {
return FO_REGION_END;
}
diff --git a/src/java/org/apache/fop/fo/pagination/RegionSE.java b/src/java/org/apache/fop/fo/pagination/RegionSE.java
index 735623352..183b44342 100644
--- a/src/java/org/apache/fop/fo/pagination/RegionSE.java
+++ b/src/java/org/apache/fop/fo/pagination/RegionSE.java
@@ -35,15 +35,15 @@ public abstract class RegionSE extends SideRegion {
// End of property values
/**
+ * Creates a new region (start or end).
+ * @param parent the parent node
* @see org.apache.fop.fo.FONode#FONode(FONode)
*/
protected RegionSE(FONode parent) {
super(parent);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void bind(PropertyList pList) throws FOPException {
super.bind(pList);
}
diff --git a/src/java/org/apache/fop/fo/pagination/RegionStart.java b/src/java/org/apache/fop/fo/pagination/RegionStart.java
index d78b19c3d..7a69cfdac 100644
--- a/src/java/org/apache/fop/fo/pagination/RegionStart.java
+++ b/src/java/org/apache/fop/fo/pagination/RegionStart.java
@@ -32,16 +32,17 @@ import org.apache.fop.datatypes.SimplePercentBaseContext;
* The fo:region-start element.
*/
public class RegionStart extends RegionSE {
+
/**
+ * Creates a new region-start element.
+ * @param parent the parent node
* @see org.apache.fop.fo.FONode#FONode(FONode)
*/
public RegionStart(FONode parent) {
super(parent);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public Rectangle getViewportRectangle (FODimension reldims, SimplePageMaster spm) {
/* Special rules apply to resolving extent as values are resolved relative
* to the page size and reference orientation.
@@ -77,9 +78,7 @@ public class RegionStart extends RegionSE {
return vpRect;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
protected String getDefaultRegionName() {
return "xsl-region-start";
}
@@ -89,9 +88,7 @@ public class RegionStart extends RegionSE {
return "region-start";
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public int getNameId() {
return FO_REGION_START;
}
diff --git a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java
index 9d2fe652c..509b81f21 100644
--- a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java
+++ b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java
@@ -52,38 +52,29 @@ public class RepeatablePageMasterAlternatives extends FObj
private boolean hasPagePositionOnly = false;
/**
+ * Creates a new repeatable-page-master-alternatives element.
+ * @param parent the parent node
* @see org.apache.fop.fo.FONode#FONode(FONode)
*/
public RepeatablePageMasterAlternatives(FONode parent) {
super(parent);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void bind(PropertyList pList) throws FOPException {
maximumRepeats = pList.get(PR_MAXIMUM_REPEATS);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
protected void startOfNode() throws FOPException {
conditionalPageMasterRefs = new java.util.ArrayList();
- if (parent.getName().equals("fo:page-sequence-master")) {
- PageSequenceMaster pageSequenceMaster = (PageSequenceMaster)parent;
- pageSequenceMaster.addSubsequenceSpecifier(this);
- } else {
- throw new ValidationException("fo:repeatable-page-master-alternatives "
- + "must be child of fo:page-sequence-master, not "
- + parent.getName(), locator);
- }
+ assert parent.getName().equals("fo:page-sequence-master"); //Validation by the parent
+ PageSequenceMaster pageSequenceMaster = (PageSequenceMaster)parent;
+ pageSequenceMaster.addSubsequenceSpecifier(this);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
protected void endOfNode() throws FOPException {
if (firstChild == null) {
missingChildElementError("(conditional-page-master-reference+)");
@@ -95,10 +86,11 @@ public class RepeatablePageMasterAlternatives extends FObj
XSL/FOP: (conditional-page-master-reference+)
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
- if (!(FO_URI.equals(nsURI)
- && localName.equals("conditional-page-master-reference"))) {
- invalidChildError(loc, nsURI, localName);
+ throws ValidationException {
+ if (FO_URI.equals(nsURI)) {
+ if (!localName.equals("conditional-page-master-reference")) {
+ invalidChildError(loc, nsURI, localName);
+ }
}
}
@@ -117,11 +109,7 @@ public class RepeatablePageMasterAlternatives extends FObj
}
}
- /**
- * Get the next matching page master from the conditional
- * page master references.
- * @see org.apache.fop.fo.pagination.SubSequenceSpecifier
- */
+ /** {@inheritDoc} */
public String getNextPageMasterName(boolean isOddPage,
boolean isFirstPage,
boolean isLastPage,
@@ -183,12 +171,11 @@ public class RepeatablePageMasterAlternatives extends FObj
}
/** {@inheritDoc} */
- /** @see org.apache.fop.fo.pagination.SubSequenceSpecifier#hasPagePositionOnly() */
public boolean hasPagePositionOnly() {
return this.hasPagePositionOnly;
}
- /** @see org.apache.fop.fo.FONode#getLocalName() */
+ /** {@inheritDoc} */
public String getLocalName() {
return "repeatable-page-master-alternatives";
}
diff --git a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java
index 172324232..87dc248c0 100644
--- a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java
+++ b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java
@@ -47,15 +47,15 @@ public class RepeatablePageMasterReference extends FObj
private int numberConsumed = 0;
/**
+ * Creates a new repeatable-page-master-reference element.
+ * @param parent the parent node
* @see org.apache.fop.fo.FONode#FONode(FONode)
*/
public RepeatablePageMasterReference(FONode parent) {
super(parent);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void bind(PropertyList pList) throws FOPException {
masterReference = pList.get(PR_MASTER_REFERENCE).getString();
maximumRepeats = pList.get(PR_MAXIMUM_REPEATS);
@@ -65,9 +65,7 @@ public class RepeatablePageMasterReference extends FObj
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
protected void startOfNode() throws FOPException {
PageSequenceMaster pageSequenceMaster = (PageSequenceMaster) parent;
@@ -83,13 +81,13 @@ public class RepeatablePageMasterReference extends FObj
* XSL Content Model: empty
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
- invalidChildError(loc, nsURI, localName);
+ throws ValidationException {
+ if (FO_URI.equals(nsURI)) {
+ invalidChildError(loc, nsURI, localName);
+ }
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public String getNextPageMasterName(boolean isOddPage,
boolean isFirstPage,
boolean isLastPage,
diff --git a/src/java/org/apache/fop/fo/pagination/Root.java b/src/java/org/apache/fop/fo/pagination/Root.java
index 6e079cf47..1cff9c3d6 100644
--- a/src/java/org/apache/fop/fo/pagination/Root.java
+++ b/src/java/org/apache/fop/fo/pagination/Root.java
@@ -25,7 +25,6 @@ import java.util.List;
import org.xml.sax.Locator;
import org.apache.fop.apps.FOPException;
-import org.apache.fop.fo.ElementMapping;
import org.apache.fop.fo.FOEventHandler;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
@@ -62,7 +61,9 @@ public class Root extends FObj {
*/
private FOEventHandler foEventHandler = null;
- /**
+ /**
+ * Creates a new root element.
+ * @param parent the parent node (must be null)
* @see org.apache.fop.fo.FONode#FONode(FONode)
*/
public Root(FONode parent) {
@@ -137,13 +138,6 @@ public class Root extends FObj {
}
- /** @inheritDoc */
- protected void validateChildNode(Locator loc, FONode child) throws ValidationException {
- if (child instanceof AbstractPageSequence) {
- pageSequenceFound = true;
- }
- }
-
/**
* Sets the FOEventHandler object that this Root is attached to
* @param foEventHandler the FOEventHandler object
@@ -291,9 +285,7 @@ public class Root extends FObj {
return bookmarkTree;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public Root getRoot() {
return this;
}
@@ -303,9 +295,7 @@ public class Root extends FObj {
return "root";
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public int getNameId() {
return FO_ROOT;
}
diff --git a/src/java/org/apache/fop/fo/pagination/SideRegion.java b/src/java/org/apache/fop/fo/pagination/SideRegion.java
index 14328aa9b..552ca871b 100644
--- a/src/java/org/apache/fop/fo/pagination/SideRegion.java
+++ b/src/java/org/apache/fop/fo/pagination/SideRegion.java
@@ -31,7 +31,11 @@ public abstract class SideRegion extends Region {
private Length extent;
- /** @see org.apache.fop.fo.FONode#FONode(FONode) */
+ /**
+ * Creates a new side region.
+ * @param parent the parent node
+ * @see org.apache.fop.fo.FONode#FONode(FONode)
+ */
protected SideRegion(FONode parent) {
super(parent);
}
diff --git a/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java b/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java
index ba1c0a6af..85a5081c8 100644
--- a/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java
+++ b/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java
@@ -63,15 +63,15 @@ public class SimplePageMaster extends FObj {
private boolean hasRegionEnd = false;
/**
+ * Creates a new simple-page-master element.
+ * @param parent the parent node
* @see org.apache.fop.fo.FONode#FONode(FONode)
*/
public SimplePageMaster(FONode parent) {
super(parent);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void bind(PropertyList pList) throws FOPException {
commonMarginBlock = pList.getMarginBlockProps();
masterName = pList.get(PR_MASTER_NAME).getString();
@@ -85,9 +85,7 @@ public class SimplePageMaster extends FObj {
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
protected void startOfNode() throws FOPException {
LayoutMasterSet layoutMasterSet = (LayoutMasterSet) parent;
@@ -101,9 +99,7 @@ public class SimplePageMaster extends FObj {
regions = new HashMap(5);
}
- /**
- * Make sure content model satisfied.
- */
+ /** {@inheritDoc} */
protected void endOfNode() throws FOPException {
if (!hasRegionBody) {
missingChildElementError(
@@ -116,72 +112,70 @@ public class SimplePageMaster extends FObj {
* XSL Content Model: (region-body,region-before?,region-after?,region-start?,region-end?)
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
- if (FO_URI.equals(nsURI) && localName.equals("region-body")) {
- if (hasRegionBody) {
- tooManyNodesError(loc, "fo:region-body");
- } else {
- hasRegionBody = true;
- }
- } else if (FO_URI.equals(nsURI) && localName.equals("region-before")) {
- if (!hasRegionBody) {
- nodesOutOfOrderError(loc, "fo:region-body", "fo:region-before");
- } else if (hasRegionBefore) {
- tooManyNodesError(loc, "fo:region-before");
- } else if (hasRegionAfter) {
- nodesOutOfOrderError(loc, "fo:region-before", "fo:region-after");
- } else if (hasRegionStart) {
- nodesOutOfOrderError(loc, "fo:region-before", "fo:region-start");
- } else if (hasRegionEnd) {
- nodesOutOfOrderError(loc, "fo:region-before", "fo:region-end");
- } else {
- hasRegionBody = true;
- }
- } else if (FO_URI.equals(nsURI) && localName.equals("region-after")) {
- if (!hasRegionBody) {
- nodesOutOfOrderError(loc, "fo:region-body", "fo:region-after");
- } else if (hasRegionAfter) {
- tooManyNodesError(loc, "fo:region-after");
- } else if (hasRegionStart) {
- nodesOutOfOrderError(loc, "fo:region-after", "fo:region-start");
- } else if (hasRegionEnd) {
- nodesOutOfOrderError(loc, "fo:region-after", "fo:region-end");
- } else {
- hasRegionAfter = true;
- }
- } else if (FO_URI.equals(nsURI) && localName.equals("region-start")) {
- if (!hasRegionBody) {
- nodesOutOfOrderError(loc, "fo:region-body", "fo:region-start");
- } else if (hasRegionStart) {
- tooManyNodesError(loc, "fo:region-start");
- } else if (hasRegionEnd) {
- nodesOutOfOrderError(loc, "fo:region-start", "fo:region-end");
- } else {
- hasRegionStart = true;
- }
- } else if (FO_URI.equals(nsURI) && localName.equals("region-end")) {
- if (!hasRegionBody) {
- nodesOutOfOrderError(loc, "fo:region-body", "fo:region-end");
- } else if (hasRegionEnd) {
- tooManyNodesError(loc, "fo:region-end");
+ throws ValidationException {
+ if (FO_URI.equals(nsURI)) {
+ if (localName.equals("region-body")) {
+ if (hasRegionBody) {
+ tooManyNodesError(loc, "fo:region-body");
+ } else {
+ hasRegionBody = true;
+ }
+ } else if (localName.equals("region-before")) {
+ if (!hasRegionBody) {
+ nodesOutOfOrderError(loc, "fo:region-body", "fo:region-before");
+ } else if (hasRegionBefore) {
+ tooManyNodesError(loc, "fo:region-before");
+ } else if (hasRegionAfter) {
+ nodesOutOfOrderError(loc, "fo:region-before", "fo:region-after");
+ } else if (hasRegionStart) {
+ nodesOutOfOrderError(loc, "fo:region-before", "fo:region-start");
+ } else if (hasRegionEnd) {
+ nodesOutOfOrderError(loc, "fo:region-before", "fo:region-end");
+ } else {
+ hasRegionBody = true;
+ }
+ } else if (localName.equals("region-after")) {
+ if (!hasRegionBody) {
+ nodesOutOfOrderError(loc, "fo:region-body", "fo:region-after");
+ } else if (hasRegionAfter) {
+ tooManyNodesError(loc, "fo:region-after");
+ } else if (hasRegionStart) {
+ nodesOutOfOrderError(loc, "fo:region-after", "fo:region-start");
+ } else if (hasRegionEnd) {
+ nodesOutOfOrderError(loc, "fo:region-after", "fo:region-end");
+ } else {
+ hasRegionAfter = true;
+ }
+ } else if (localName.equals("region-start")) {
+ if (!hasRegionBody) {
+ nodesOutOfOrderError(loc, "fo:region-body", "fo:region-start");
+ } else if (hasRegionStart) {
+ tooManyNodesError(loc, "fo:region-start");
+ } else if (hasRegionEnd) {
+ nodesOutOfOrderError(loc, "fo:region-start", "fo:region-end");
+ } else {
+ hasRegionStart = true;
+ }
+ } else if (localName.equals("region-end")) {
+ if (!hasRegionBody) {
+ nodesOutOfOrderError(loc, "fo:region-body", "fo:region-end");
+ } else if (hasRegionEnd) {
+ tooManyNodesError(loc, "fo:region-end");
+ } else {
+ hasRegionEnd = true;
+ }
} else {
- hasRegionEnd = true;
+ invalidChildError(loc, nsURI, localName);
}
- } else {
- invalidChildError(loc, nsURI, localName);
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public boolean generatesReferenceAreas() {
return true;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
protected void addChildNode(FONode child) throws FOPException {
if (child instanceof Region) {
addRegion((Region)child);
@@ -268,9 +262,7 @@ public class SimplePageMaster extends FObj {
return "simple-page-master";
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public int getNameId() {
return FO_SIMPLE_PAGE_MASTER;
}
diff --git a/src/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java b/src/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java
index 43d8e40dc..119ec409e 100644
--- a/src/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java
+++ b/src/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java
@@ -46,6 +46,8 @@ public class SinglePageMasterReference extends FObj
private int state;
/**
+ * Creates a new single-page-master-reference element.
+ * @param parent the parent node
* @see org.apache.fop.fo.FONode#FONode(FONode)
*/
public SinglePageMasterReference(FONode parent) {
@@ -53,9 +55,7 @@ public class SinglePageMasterReference extends FObj
this.state = FIRST;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void bind(PropertyList pList) throws FOPException {
masterReference = pList.get(PR_MASTER_REFERENCE).getString();
@@ -64,9 +64,7 @@ public class SinglePageMasterReference extends FObj
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
protected void startOfNode() throws FOPException {
PageSequenceMaster pageSequenceMaster = (PageSequenceMaster) parent;
pageSequenceMaster.addSubsequenceSpecifier(this);
@@ -77,8 +75,10 @@ public class SinglePageMasterReference extends FObj
* XSL Content Model: empty
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
- invalidChildError(loc, nsURI, localName);
+ throws ValidationException {
+ if (FO_URI.equals(nsURI)) {
+ invalidChildError(loc, nsURI, localName);
+ }
}
/** {@inheritDoc} */
diff --git a/src/java/org/apache/fop/fo/pagination/StaticContent.java b/src/java/org/apache/fop/fo/pagination/StaticContent.java
index 62d73e56d..184438b6f 100644
--- a/src/java/org/apache/fop/fo/pagination/StaticContent.java
+++ b/src/java/org/apache/fop/fo/pagination/StaticContent.java
@@ -27,24 +27,22 @@ import org.apache.fop.fo.FONode;
import org.apache.fop.fo.ValidationException;
/**
- * Class modelling the fo:static-content object.
+ * Class modeling the fo:static-content object.
*/
public class StaticContent extends Flow {
/**
+ * Creates a new static-content element.
* @param parent FONode that is the parent of this object
*/
public StaticContent(FONode parent) {
super(parent);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
protected void startOfNode() throws FOPException {
if (getFlowName() == null || getFlowName().equals("")) {
- throw new ValidationException("A 'flow-name' is required for "
- + getName() + ".", locator);
+ missingPropertyError("flow-name");
}
getFOEventHandler().startFlow(this);
}
@@ -66,9 +64,11 @@ public class StaticContent extends Flow {
* XSL Content Model: (%block;)+
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
- if (!isBlockItem(nsURI, localName)) {
- invalidChildError(loc, nsURI, localName);
+ throws ValidationException {
+ if (FO_URI.equals(nsURI)) {
+ if (!isBlockItem(nsURI, localName)) {
+ invalidChildError(loc, nsURI, localName);
+ }
}
}
diff --git a/src/java/org/apache/fop/fo/pagination/Title.java b/src/java/org/apache/fop/fo/pagination/Title.java
index 398424152..f6f625ea8 100644
--- a/src/java/org/apache/fop/fo/pagination/Title.java
+++ b/src/java/org/apache/fop/fo/pagination/Title.java
@@ -27,7 +27,7 @@ import org.apache.fop.fo.ValidationException;
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 @@ public class Title extends InlineLevel {
// 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 @@ public class Title extends InlineLevel {
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;
}
diff --git a/src/java/org/apache/fop/fo/pagination/bookmarks/Bookmark.java b/src/java/org/apache/fop/fo/pagination/bookmarks/Bookmark.java
index e588bb3f8..7f55ec51b 100644
--- a/src/java/org/apache/fop/fo/pagination/bookmarks/Bookmark.java
+++ b/src/java/org/apache/fop/fo/pagination/bookmarks/Bookmark.java
@@ -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 @@ public class Bookmark extends FObj {
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 @@ public class Bookmark extends FObj {
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 @@ public class Bookmark extends FObj {
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 @@ public class Bookmark extends FObj {
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 @@ public class Bookmark extends FObj {
return "bookmark";
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public int getNameId() {
return FO_BOOKMARK;
}
diff --git a/src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTitle.java b/src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTitle.java
index f31aad1cb..c7024f2aa 100644
--- a/src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTitle.java
+++ b/src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTitle.java
@@ -21,8 +21,8 @@ package org.apache.fop.fo.pagination.bookmarks;
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 @@ public class BookmarkTitle extends FObj {
/**
* 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 @@ public class BookmarkTitle extends FObj {
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 @@ public class BookmarkTitle extends FObj {
return "bookmark-title";
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public int getNameId() {
return FO_BOOKMARK_TITLE;
}
diff --git a/src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTree.java b/src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTree.java
index 6190fa22a..0f1d8a8b7 100644
--- a/src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTree.java
+++ b/src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTree.java
@@ -21,6 +21,7 @@ package org.apache.fop.fo.pagination.bookmarks;
// Java
import java.util.ArrayList;
+import java.util.List;
import org.xml.sax.Locator;
@@ -39,15 +40,15 @@ public class BookmarkTree extends FObj {
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 @@ public class BookmarkTree extends FObj {
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 @@ public class BookmarkTree extends FObj {
return "bookmark-tree";
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public int getNameId() {
return FO_BOOKMARK_TREE;
}
diff --git a/src/java/org/apache/fop/fonts/FontEventAdapter.java b/src/java/org/apache/fop/fonts/FontEventAdapter.java
new file mode 100644
index 000000000..516999f70
--- /dev/null
+++ b/src/java/org/apache/fop/fonts/FontEventAdapter.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.fonts;
+
+import java.util.Map;
+
+import org.apache.fop.events.Event;
+import org.apache.fop.events.EventBroadcaster;
+import org.apache.fop.events.model.EventSeverity;
+
+/**
+ * Event listener interface for font-related events. This interface extends FontEventListener
+ * and EventProducer for integration into FOP's event subsystem.
+ */
+public class FontEventAdapter implements FontEventListener {
+
+ private EventBroadcaster eventBroadcaster;
+
+ /**
+ * Creates a new FontEventAdapter.
+ * @param broadcaster the event broadcaster to send the generated events to
+ */
+ public FontEventAdapter(EventBroadcaster broadcaster) {
+ this.eventBroadcaster = broadcaster;
+ }
+
+ /**
+ * Returns the event group ID.
+ * @return the event group ID
+ */
+ protected String getEventGroupID() {
+ return getClass().getName();
+ }
+
+ /** {@inheritDoc} */
+ public void fontSubstituted(Object source, FontTriplet requested, FontTriplet effective) {
+ Map params = new java.util.HashMap();
+ params.put("requested", requested);
+ params.put("effective", effective);
+ Event ev = new Event(source, getEventGroupID() + ".fontSubstituted",
+ EventSeverity.WARN, params);
+ this.eventBroadcaster.broadcastEvent(ev);
+ }
+
+ /** {@inheritDoc} */
+ public void fontLoadingErrorAtAutoDetection(Object source, String fontURL, Exception e) {
+ Map params = new java.util.HashMap();
+ params.put("fontURL", fontURL);
+ params.put("e", e);
+ Event ev = new Event(source, getEventGroupID() + ".fontLoadingErrorAtAutoDetection",
+ EventSeverity.WARN, params);
+ this.eventBroadcaster.broadcastEvent(ev);
+ }
+
+ /** {@inheritDoc} */
+ public void glyphNotAvailable(Object source, char ch, String fontName) {
+ Map params = new java.util.HashMap();
+ params.put("ch", new Character(ch));
+ params.put("fontName", fontName);
+ Event ev = new Event(source, getEventGroupID() + ".glyphNotAvailable",
+ EventSeverity.WARN, params);
+ this.eventBroadcaster.broadcastEvent(ev);
+ }
+
+}
diff --git a/src/java/org/apache/fop/fonts/FontEventListener.java b/src/java/org/apache/fop/fonts/FontEventListener.java
new file mode 100644
index 000000000..512df0ac0
--- /dev/null
+++ b/src/java/org/apache/fop/fonts/FontEventListener.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.fonts;
+
+
+/**
+ * Event listener interface for font-related events.
+ */
+public interface FontEventListener {
+
+ /**
+ * Notifies about a font being substituted as the requested one isn't available.
+ * @param source the event source
+ * @param requested the requested font triplet
+ * @param effective the effective font triplet
+ */
+ void fontSubstituted(Object source, FontTriplet requested, FontTriplet effective);
+
+ /**
+ * An error occurred while loading a font for auto-detection.
+ * @param source the event source
+ * @param fontURL the font URL
+ * @param e the original exception
+ */
+ void fontLoadingErrorAtAutoDetection(Object source, String fontURL, Exception e);
+
+ /**
+ * A glyph has been requested that is not available in the font.
+ * @param source the event source
+ * @param ch the character for which the glyph isn't available
+ * @param fontName the name of the font
+ */
+ void glyphNotAvailable(Object source, char ch, String fontName);
+
+}
diff --git a/src/java/org/apache/fop/fonts/FontInfo.java b/src/java/org/apache/fop/fonts/FontInfo.java
index 218734f15..950134eb6 100644
--- a/src/java/org/apache/fop/fonts/FontInfo.java
+++ b/src/java/org/apache/fop/fonts/FontInfo.java
@@ -67,6 +67,8 @@ public class FontInfo {
/** Cache for Font instances. */
private Map fontInstanceCache = new java.util.HashMap();
+ private FontEventListener eventListener;
+
/**
* Main constructor
*/
@@ -77,6 +79,15 @@ public class FontInfo {
this.usedFonts = new java.util.HashMap();
}
+ /**
+ * 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.)
@@ -158,6 +169,9 @@ public class FontInfo {
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 @@ public class FontInfo {
}
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 + "'.");
+ }
}
}
diff --git a/src/java/org/apache/fop/fonts/LazyFont.java b/src/java/org/apache/fop/fonts/LazyFont.java
index 07b5be305..5490e13f1 100644
--- a/src/java/org/apache/fop/fonts/LazyFont.java
+++ b/src/java/org/apache/fop/fonts/LazyFont.java
@@ -141,6 +141,7 @@ public class LazyFont extends Typeface implements FontDescriptor {
throw new RuntimeException(ioex.getMessage());
}
}
+ realFont.setEventListener(this.eventListener);
isMetricsLoaded = true;
}
}
diff --git a/src/java/org/apache/fop/fonts/SingleByteFont.java b/src/java/org/apache/fop/fonts/SingleByteFont.java
index ac12b7615..0a47d52ab 100644
--- a/src/java/org/apache/fop/fonts/SingleByteFont.java
+++ b/src/java/org/apache/fop/fonts/SingleByteFont.java
@@ -117,18 +117,22 @@ public class SingleByteFont extends CustomFont {
}
//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;
diff --git a/src/java/org/apache/fop/fonts/Typeface.java b/src/java/org/apache/fop/fonts/Typeface.java
index 173d2e8a3..b6c78a3b0 100644
--- a/src/java/org/apache/fop/fonts/Typeface.java
+++ b/src/java/org/apache/fop/fonts/Typeface.java
@@ -30,6 +30,9 @@ public abstract class Typeface implements FontMetrics {
*/
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
@@ -80,5 +83,14 @@ public abstract class Typeface implements FontMetrics {
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;
+ }
+
}
diff --git a/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java b/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
index 8207eb140..b223ea7a1 100644
--- a/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
+++ b/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
@@ -35,6 +35,7 @@ import org.apache.fop.fonts.CustomFont;
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 @@ public class FontInfoFinder {
/** 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 @@ public class FontInfoFinder {
// 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
@@ -193,7 +204,9 @@ public class FontInfoFinder {
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 @@ public class FontInfoFinder {
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 @@ public class FontInfoFinder {
// 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 @@ public class FontInfoFinder {
return null;
}
}
-
}
diff --git a/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java b/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java
index 81b3b4c07..be0995d8c 100644
--- a/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java
+++ b/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java
@@ -27,8 +27,11 @@ import java.util.Map;
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.image.loader.impl.ImageXMLDOM;
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 @@ import org.apache.fop.svg.SVGUserAgent;
*/
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 @@ public class ImageConverterSVG2G2D extends AbstractImageConverter {
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);
@@ -107,6 +111,25 @@ public class ImageConverterSVG2G2D extends AbstractImageConverter {
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} */
public ImageFlavor getSourceFlavor() {
return ImageFlavor.XML_DOM;
diff --git a/src/java/org/apache/fop/image/loader/batik/PreloaderSVG.java b/src/java/org/apache/fop/image/loader/batik/PreloaderSVG.java
index e59e06b6b..20557a644 100644
--- a/src/java/org/apache/fop/image/loader/batik/PreloaderSVG.java
+++ b/src/java/org/apache/fop/image/loader/batik/PreloaderSVG.java
@@ -32,6 +32,7 @@ import org.w3c.dom.svg.SVGDocument;
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.impl.ImageXMLDOM;
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 @@ public class PreloaderSVG extends AbstractImagePreloader {
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);
diff --git a/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java b/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
index 65d537bcd..4ef0579f2 100644
--- a/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
+++ b/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
@@ -198,11 +198,11 @@ public abstract class AbstractBreaker {
}
/**
- * 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 @@ public abstract class AbstractBreaker {
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;
diff --git a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
index e8ca88c1c..f01f0e12f 100644
--- a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
@@ -35,7 +35,6 @@ import org.apache.fop.area.CTM;
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 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager
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 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager
*/
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 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager
//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 class BlockContainerLayoutManager extends BlockStackingLayoutManager
}
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() {
diff --git a/src/java/org/apache/fop/layoutmgr/BlockLevelEventProducer.java b/src/java/org/apache/fop/layoutmgr/BlockLevelEventProducer.java
new file mode 100644
index 000000000..c31a70477
--- /dev/null
+++ b/src/java/org/apache/fop/layoutmgr/BlockLevelEventProducer.java
@@ -0,0 +1,168 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.layoutmgr;
+
+import org.xml.sax.Locator;
+
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.events.EventBroadcaster;
+import org.apache.fop.events.EventProducer;
+
+/**
+ * Event producer interface for block-level layout managers.
+ */
+public interface BlockLevelEventProducer extends EventProducer {
+
+ /**
+ * Provider class for the event producer.
+ */
+ class Provider {
+
+ /**
+ * Returns an event producer.
+ * @param broadcaster the event broadcaster to use
+ * @return the event producer
+ */
+ public static BlockLevelEventProducer get(EventBroadcaster broadcaster) {
+ return (BlockLevelEventProducer)broadcaster.getEventProducerFor(
+ BlockLevelEventProducer.class);
+ }
+ }
+
+ /**
+ * The contents of a table-row are too big to fit in the constraints.
+ * @param source the event source
+ * @param row the row number
+ * @param effCellBPD the effective extent in block-progression direction of the cell
+ * @param maxCellBPD the maximum extent in block-progression direction of the cell
+ * @param loc the location of the error or null
+ * @event.severity WARN
+ */
+ void rowTooTall(Object source, int row, int effCellBPD, int maxCellBPD, Locator loc);
+
+ /**
+ * Auto-table layout is not supported, yet.
+ * @param source the event source
+ * @param loc the location of the error or null
+ * @event.severity INFO
+ */
+ void tableFixedAutoWidthNotSupported(Object source, Locator loc);
+
+ /**
+ * An formatting object is too wide.
+ * @param source the event source
+ * @param elementName the formatting object
+ * @param effIPD the effective extent in inline-progression direction of the table contents
+ * @param maxIPD the maximum extent in inline-progression direction available
+ * @param loc the location of the error or null
+ * @event.severity WARN
+ */
+ void objectTooWide(Object source, String elementName, int effIPD, int maxIPD, Locator loc);
+
+ /**
+ * An overconstrained geometry adjustment rule was triggered (5.3.4, XSL 1.0).
+ * @param source the event source
+ * @param elementName the formatting object
+ * @param amount the amount of the adjustment (in mpt)
+ * @param loc the location of the error or null
+ * @event.severity INFO
+ */
+ void overconstrainedAdjustEndIndent(Object source, String elementName, int amount, Locator loc);
+
+ /**
+ * Contents overflow a viewport.
+ * @param source the event source
+ * @param elementName the formatting object
+ * @param amount the amount by which the contents overflow (in mpt)
+ * @param clip true if the content will be clipped
+ * @param canRecover indicates whether FOP can recover from this problem and continue working
+ * @param loc the location of the error or null
+ * @throws LayoutException the layout error provoked by the method call
+ * @event.severity FATAL
+ */
+ void viewportOverflow(Object source, String elementName,
+ int amount, boolean clip, boolean canRecover,
+ Locator loc) throws LayoutException;
+
+ /**
+ * Contents overflow a region viewport.
+ * @param source the event source
+ * @param elementName the formatting object
+ * @param page the page number/name where the overflow happened
+ * @param amount the amount by which the contents overflow (in mpt)
+ * @param clip true if the content will be clipped
+ * @param canRecover indicates whether FOP can recover from this problem and continue working
+ * @param loc the location of the error or null
+ * @throws LayoutException the layout error provoked by the method call
+ * @event.severity FATAL
+ */
+ void regionOverflow(Object source, String elementName,
+ String page,
+ int amount, boolean clip, boolean canRecover,
+ Locator loc) throws LayoutException;
+
+ /**
+ * Indicates that FOP doesn't support flows that are not mapped to region-body, yet.
+ * @param source the event source
+ * @param flowName the flow name
+ * @param masterName the page master name
+ * @param loc the location of the error or null
+ * @throws UnsupportedOperationException the layout error provoked by the method call
+ * @event.severity FATAL
+ */
+ void flowNotMappingToRegionBody(Object source, String flowName, String masterName,
+ Locator loc) throws UnsupportedOperationException;
+
+ /**
+ * A page sequence master is exhausted.
+ * @param source the event source
+ * @param pageSequenceMasterName the name of the page sequence master
+ * @param canRecover indicates whether FOP can recover from this problem and continue working
+ * @param loc the location of the error or null
+ * @throws FOPException the error provoked by the method call
+ * @event.severity FATAL
+ */
+ void pageSequenceMasterExhausted(Object source, String pageSequenceMasterName,
+ boolean canRecover, Locator loc) throws FOPException;
+
+ /**
+ * No subsequences in page sequence master.
+ * @param source the event source
+ * @param pageSequenceMasterName the name of the page sequence master
+ * @param loc the location of the error or null
+ * @throws FOPException the error provoked by the method call
+ * @event.severity FATAL
+ */
+ void missingSubsequencesInPageSequenceMaster(Object source, String pageSequenceMasterName,
+ Locator loc) throws FOPException;
+
+ /**
+ * No single-page-master matching in page sequence master.
+ * @param source the event source
+ * @param pageSequenceMasterName the name of the page sequence master
+ * @param pageMasterName the name of the page master not matching
+ * @param loc the location of the error or null
+ * @throws FOPException the error provoked by the method call
+ * @event.severity FATAL
+ */
+ void noMatchingPageMaster(Object source, String pageSequenceMasterName,
+ String pageMasterName, Locator loc) throws FOPException;
+
+}
diff --git a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
index 67ed1de9f..cb6db6b01 100644
--- a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
@@ -201,6 +201,10 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
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 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
/**
* 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 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
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);
diff --git a/src/java/org/apache/fop/layoutmgr/ExternalDocumentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/ExternalDocumentLayoutManager.java
index 21856c781..086d91c31 100644
--- a/src/java/org/apache/fop/layoutmgr/ExternalDocumentLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/ExternalDocumentLayoutManager.java
@@ -21,6 +21,7 @@ package org.apache.fop.layoutmgr;
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.Image;
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,17 +142,28 @@ public class ExternalDocumentLayoutManager extends AbstractPageSequenceLayoutMan
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) {
this.imageLayout = layout;
curPage = makeNewPage(false, false);
diff --git a/src/java/org/apache/fop/layoutmgr/LayoutException.java b/src/java/org/apache/fop/layoutmgr/LayoutException.java
new file mode 100644
index 000000000..350cc758a
--- /dev/null
+++ b/src/java/org/apache/fop/layoutmgr/LayoutException.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.layoutmgr;
+
+import java.util.Locale;
+
+import org.apache.fop.events.Event;
+import org.apache.fop.events.EventFormatter;
+import org.apache.fop.events.EventExceptionManager.ExceptionFactory;
+
+/**
+ * Exception thrown by FOP if an unrecoverable layout error occurs. An example: An area overflows
+ * a viewport that has overflow="error-if-overflow".
+ *
+ * @todo Discuss if this should become a checked exception.
+ */
+public class LayoutException extends RuntimeException {
+
+ private static final long serialVersionUID = 5157080040923740433L;
+
+ private String localizedMessage;
+ private LayoutManager layoutManager;
+
+ /**
+ * Constructs a new layout exception with the specified detail message.
+ * @param message the detail message.
+ */
+ public LayoutException(String message) {
+ this(message, null);
+ }
+
+ /**
+ * Constructs a new layout exception with the specified detail message.
+ * @param message the detail message
+ * @param lm the layout manager that throws the exception
+ */
+ public LayoutException(String message, LayoutManager lm) {
+ super(message);
+ this.layoutManager = lm;
+ }
+
+ /**
+ * Sets the localized message for this exception.
+ * @param msg the localized message
+ */
+ public void setLocalizedMessage(String msg) {
+ this.localizedMessage = msg;
+ }
+
+ /** {@inheritDoc} */
+ public String getLocalizedMessage() {
+ if (this.localizedMessage != null) {
+ return this.localizedMessage;
+ } else {
+ return super.getLocalizedMessage();
+ }
+ }
+
+ /**
+ * Returns the layout manager that detected the problem.
+ * @return the layout manager (or null)
+ */
+ public LayoutManager getLayoutManager() {
+ return this.layoutManager;
+ }
+
+ /** Exception factory for {@link LayoutException}. */
+ public static class LayoutExceptionFactory implements ExceptionFactory {
+
+ /** {@inheritDoc} */
+ public Throwable createException(Event event) {
+ Object source = event.getSource();
+ LayoutManager lm = (source instanceof LayoutManager) ? (LayoutManager)source : null;
+ String msg = EventFormatter.format(event, Locale.ENGLISH);
+ LayoutException ex = new LayoutException(msg, lm);
+ if (!Locale.ENGLISH.equals(Locale.getDefault())) {
+ ex.setLocalizedMessage(EventFormatter.format(event));
+ }
+ return ex;
+ }
+
+ /** {@inheritDoc} */
+ public Class getExceptionClass() {
+ return LayoutException.class;
+ }
+
+ }
+}
diff --git a/src/java/org/apache/fop/layoutmgr/PageBreaker.java b/src/java/org/apache/fop/layoutmgr/PageBreaker.java
index 3e100cd50..d6be75758 100644
--- a/src/java/org/apache/fop/layoutmgr/PageBreaker.java
+++ b/src/java/org/apache/fop/layoutmgr/PageBreaker.java
@@ -27,7 +27,6 @@ import org.apache.fop.area.Block;
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 @@ public class PageBreaker extends AbstractBreaker {
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 @@ public class PageBreaker extends AbstractBreaker {
//Restart last page
PageBreakingAlgorithm algRestart = new PageBreakingAlgorithm(
getTopLevelLM(),
- getPageProvider(), getLayoutListener(),
+ getPageProvider(), createLayoutListener(),
alg.getAlignment(), alg.getAlignmentLast(),
footnoteSeparatorLength,
isPartOverflowRecoveryActivated(), false, false);
@@ -356,7 +353,7 @@ public class PageBreaker extends AbstractBreaker {
//Restart last page
PageBreakingAlgorithm algRestart = new BalancingColumnBreakingAlgorithm(
getTopLevelLM(),
- getPageProvider(), getLayoutListener(),
+ getPageProvider(), createLayoutListener(),
alignment, Constants.EN_START, footnoteSeparatorLength,
isPartOverflowRecoveryActivated(),
pslm.getCurrentPV().getBodyRegion().getColumnCount());
diff --git a/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java b/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
index d98d29b5c..5e3d0a887 100644
--- a/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
+++ b/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
@@ -27,7 +27,6 @@ import org.apache.commons.logging.Log;
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 @@ class PageBreakingAlgorithm extends BreakingAlgorithm {
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 @@ class PageBreakingAlgorithm extends BreakingAlgorithm {
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 @@ class PageBreakingAlgorithm extends BreakingAlgorithm {
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 @@ class PageBreakingAlgorithm extends BreakingAlgorithm {
*/
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 @@ class PageBreakingAlgorithm extends BreakingAlgorithm {
* @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 @@ class PageBreakingAlgorithm extends BreakingAlgorithm {
}
// 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 @@ class PageBreakingAlgorithm extends BreakingAlgorithm {
}
}
- private int getPartCount() {
- if (pageBreaks == null) {
- return 0;
- } else {
- return pageBreaks.size();
- }
- }
-
public void updateData1(int total, double demerits) {
}
@@ -774,12 +771,7 @@ class PageBreakingAlgorithm extends BreakingAlgorithm {
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 @@ class PageBreakingAlgorithm extends BreakingAlgorithm {
/**
* 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);
}
diff --git a/src/java/org/apache/fop/layoutmgr/PageProvider.java b/src/java/org/apache/fop/layoutmgr/PageProvider.java
index e16c3396a..037f02094 100644
--- a/src/java/org/apache/fop/layoutmgr/PageProvider.java
+++ b/src/java/org/apache/fop/layoutmgr/PageProvider.java
@@ -23,6 +23,7 @@ import java.util.List;
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 @@ public class PageProvider implements Constants {
/**
* 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 @@ public class PageProvider implements Constants {
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
diff --git a/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java
index b1e414527..763ddf58d 100644
--- a/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java
@@ -29,10 +29,12 @@ import org.apache.commons.logging.LogFactory;
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 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager {
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 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager {
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 class StaticContentLayoutManager extends BlockStackingLayoutManager {
}
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 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager {
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();
diff --git a/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java
index ff7c5b3ce..2af844c5c 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java
@@ -60,7 +60,6 @@ public class ContentLayoutManager extends AbstractBaseLayoutManager
*/
private static Log log = LogFactory.getLog(ContentLayoutManager.class);
- private FOUserAgent userAgent;
private Area holder;
private int stackSize;
private LayoutManager parentLM;
diff --git a/src/java/org/apache/fop/layoutmgr/inline/InlineLevelEventProducer.java b/src/java/org/apache/fop/layoutmgr/inline/InlineLevelEventProducer.java
new file mode 100644
index 000000000..51d2720cb
--- /dev/null
+++ b/src/java/org/apache/fop/layoutmgr/inline/InlineLevelEventProducer.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.layoutmgr.inline;
+
+import org.xml.sax.Locator;
+
+import org.apache.fop.events.EventBroadcaster;
+import org.apache.fop.events.EventProducer;
+
+/**
+ * Event producer interface for inline-level layout managers.
+ */
+public interface InlineLevelEventProducer extends EventProducer {
+
+ /**
+ * Provider class for the event producer.
+ */
+ class Provider {
+
+ /**
+ * Returns an event producer.
+ * @param broadcaster the event broadcaster to use
+ * @return the event producer
+ */
+ public static InlineLevelEventProducer get(EventBroadcaster broadcaster) {
+ return (InlineLevelEventProducer)broadcaster.getEventProducerFor(
+ InlineLevelEventProducer.class);
+ }
+ }
+
+ /**
+ * fo:leader with "use-content" but without children.
+ * @param source the event source
+ * @param loc the location of the error or null
+ * @event.severity ERROR
+ */
+ void leaderWithoutContent(Object source, Locator loc);
+
+ /**
+ * A line overflows.
+ * @param source the event source
+ * @param line the number number
+ * @param overflowLength the length by which the content overflows the available space (in mpt)
+ * @param loc the location of the error or null
+ * @event.severity WARN
+ */
+ void lineOverflows(Object source, int line, int overflowLength, Locator loc);
+
+}
diff --git a/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java
index f4bcde96f..1e7c793df 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java
@@ -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.PositionIterator;
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 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager {
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 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager {
return returnList;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public int getBaseLength(int lengthBase, FObj fobj) {
return getParent().getBaseLength(lengthBase, getParent().getFObj());
}
diff --git a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
index 9a818232c..1258fbe18 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
@@ -34,7 +34,6 @@ import org.apache.fop.area.inline.InlineArea;
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 @@ public class LineLayoutManager extends InlineStackingLayoutManager
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 @@ public class LineLayoutManager extends InlineStackingLayoutManager
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
diff --git a/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java b/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java
index 2ef2be908..bd032e610 100644
--- a/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java
+++ b/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java
@@ -25,9 +25,9 @@ import java.util.ListIterator;
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 @@ public class ColumnSetup {
}
}
//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 @@ public class ColumnSetup {
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 @@ public class ColumnSetup {
if (colWidth != null) {
sumCols += colWidth.getValue(tlm);
if (colWidth instanceof TableColLength) {
- factors +=
- ((TableColLength) colWidth).getTableUnits();
+ factors += ((TableColLength) colWidth).getTableUnits();
}
}
}
diff --git a/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java
index 9c97ca827..72e78b84f 100644
--- a/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java
@@ -24,6 +24,7 @@ import java.util.LinkedList;
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.TableColumn;
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 @@ class RowGroupLayoutManager {
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 @@ class RowGroupLayoutManager {
// + " 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);
- }
}
}
}
diff --git a/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
index d6bba5cb5..720ca5faa 100644
--- a/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
@@ -26,6 +26,7 @@ import java.util.List;
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.FONode;
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 @@ public class TableLayoutManager extends BlockStackingLayoutManager
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 @@ public class TableLayoutManager extends BlockStackingLayoutManager
}
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
diff --git a/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java b/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java
index c0c9ce88c..185aed817 100644
--- a/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java
+++ b/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java
@@ -30,12 +30,16 @@ import org.w3c.dom.Document;
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;
/**
@@ -73,7 +77,7 @@ public abstract class AbstractGenericSVGHandler implements XMLHandler, RendererC
//Prepare
SVGUserAgent ua = new SVGUserAgent(
- context.getUserAgent().getSourcePixelUnitToMillimeter(),
+ context.getUserAgent(),
new AffineTransform());
GVTBuilder builder = new GVTBuilder();
final BridgeContext ctx = new BridgeContext(ua);
@@ -83,7 +87,9 @@ public abstract class AbstractGenericSVGHandler implements XMLHandler, RendererC
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 +120,20 @@ public abstract class AbstractGenericSVGHandler implements XMLHandler, RendererC
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.
diff --git a/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java b/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java
index 9e13476f6..b38d973c5 100644
--- a/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java
+++ b/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java
@@ -31,6 +31,7 @@ import org.w3c.dom.Document;
import org.apache.batik.parser.AWTTransformProducer;
import org.apache.xmlgraphics.image.loader.ImageSize;
+import org.apache.xmlgraphics.util.QName;
import org.apache.fop.area.Area;
import org.apache.fop.area.Block;
@@ -45,7 +46,6 @@ import org.apache.fop.fo.Constants;
import org.apache.fop.fo.extensions.ExtensionElementMapping;
import org.apache.fop.fonts.FontMetrics;
import org.apache.fop.traits.BorderProps;
-import org.apache.fop.util.QName;
/**
* Abstract base class for renderers like PDF and PostScript where many painting operations
diff --git a/src/java/org/apache/fop/render/AbstractRenderer.java b/src/java/org/apache/fop/render/AbstractRenderer.java
index 32c4b33c4..ca3d007d0 100644
--- a/src/java/org/apache/fop/render/AbstractRenderer.java
+++ b/src/java/org/apache/fop/render/AbstractRenderer.java
@@ -67,6 +67,7 @@ import org.apache.fop.area.inline.SpaceArea;
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 @@ public abstract class AbstractRenderer
private Set warnedXMLHandlers;
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public abstract void setupFontInfo(FontInfo fontInfo);
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void setUserAgent(FOUserAgent agent) {
userAgent = agent;
}
- /**
- * @return the associated FOUserAgent
- */
+ /** {@inheritDoc} */
public FOUserAgent getUserAgent() {
return userAgent;
}
@@ -797,10 +792,11 @@ public abstract class AbstractRenderer
= 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 @@ public abstract class AbstractRenderer
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);
}
}
}
diff --git a/src/java/org/apache/fop/render/Renderer.java b/src/java/org/apache/fop/render/Renderer.java
index b40eec0cf..03b4582f7 100644
--- a/src/java/org/apache/fop/render/Renderer.java
+++ b/src/java/org/apache/fop/render/Renderer.java
@@ -88,6 +88,12 @@ public interface Renderer {
*/
void setUserAgent(FOUserAgent agent);
+ /**
+ * Returns the associated user agent.
+ * @return the user agent
+ */
+ FOUserAgent getUserAgent();
+
/**
* Set up the given FontInfo.
*
diff --git a/src/java/org/apache/fop/render/RendererEventProducer.java b/src/java/org/apache/fop/render/RendererEventProducer.java
new file mode 100644
index 000000000..365c8f430
--- /dev/null
+++ b/src/java/org/apache/fop/render/RendererEventProducer.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render;
+
+import java.io.IOException;
+
+import org.apache.fop.events.EventBroadcaster;
+import org.apache.fop.events.EventProducer;
+
+/**
+ * Event producer interface for rendering-specific events.
+ */
+public interface RendererEventProducer extends EventProducer {
+
+ /** Provider class for the event producer. */
+ class Provider {
+
+ /**
+ * Returns an event producer.
+ * @param broadcaster the event broadcaster to use
+ * @return the event producer
+ */
+ public static RendererEventProducer get(EventBroadcaster broadcaster) {
+ return (RendererEventProducer)broadcaster.getEventProducerFor(
+ RendererEventProducer.class);
+ }
+ }
+
+ /**
+ * I/O error while writing target file.
+ * @param source the event source
+ * @param ioe the original I/O error
+ * @event.severity ERROR
+ */
+ void ioError(Object source, IOException ioe);
+}
diff --git a/src/java/org/apache/fop/render/afp/AFPEventProducer.java b/src/java/org/apache/fop/render/afp/AFPEventProducer.java
new file mode 100644
index 000000000..615c54c32
--- /dev/null
+++ b/src/java/org/apache/fop/render/afp/AFPEventProducer.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render.afp;
+
+import org.apache.fop.events.EventBroadcaster;
+import org.apache.fop.events.EventProducer;
+import org.apache.fop.events.model.AbstractEventModelFactory;
+import org.apache.fop.events.model.EventModel;
+
+/**
+ * Event producer interface for AFP-specific events.
+ */
+public interface AFPEventProducer extends EventProducer {
+
+ /** Provider class for the event producer. */
+ class Provider {
+
+ /**
+ * Returns an event producer.
+ * @param broadcaster the event broadcaster to use
+ * @return the event producer
+ */
+ public static AFPEventProducer get(EventBroadcaster broadcaster) {
+ return (AFPEventProducer)broadcaster.getEventProducerFor(
+ AFPEventProducer.class);
+ }
+ }
+
+ /** Event model factory for AFP. */
+ public static class EventModelFactory extends AbstractEventModelFactory {
+
+ /** {@inheritDoc} */
+ public EventModel createEventModel() {
+ return loadModel(getClass(), "event-model.xml");
+ }
+
+ }
+
+ /**
+ * Warn about using default font setup.
+ * @param source the event source
+ * @event.severity WARN
+ */
+ void warnDefaultFontSetup(Object source);
+
+}
diff --git a/src/java/org/apache/fop/render/afp/AFPEventProducer.xml b/src/java/org/apache/fop/render/afp/AFPEventProducer.xml
new file mode 100644
index 000000000..8eec9b656
--- /dev/null
+++ b/src/java/org/apache/fop/render/afp/AFPEventProducer.xml
@@ -0,0 +1,4 @@
+
+
+ No AFP fonts configured. Using default setup.
+
diff --git a/src/java/org/apache/fop/render/afp/AFPRenderer.java b/src/java/org/apache/fop/render/afp/AFPRenderer.java
index e50e77830..629a7b62f 100644
--- a/src/java/org/apache/fop/render/afp/AFPRenderer.java
+++ b/src/java/org/apache/fop/render/afp/AFPRenderer.java
@@ -69,6 +69,7 @@ import org.apache.fop.area.inline.SpaceArea;
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;
@@ -295,7 +296,9 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
}
}
} 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 ",
@@ -908,7 +911,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
RendererContext context;
context = super.createRendererContext(x, y, width, height, foreignAttributes);
context.setProperty(AFPRendererContextConstants.AFP_GRAYSCALE,
- new Boolean(!this.colorImages));
+ Boolean.valueOf(!this.colorImages));
context.setProperty(AFPRendererContextConstants.AFP_FONT_INFO,
this.fontInfo);
context.setProperty(AFPRendererContextConstants.AFP_RESOLUTION,
@@ -1045,13 +1048,17 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
}
} 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);
} finally {
if (in != null) {
IOUtils.closeQuietly(in);
@@ -1217,7 +1224,9 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
//memory consumption (see PostScript output)
ImageEncodingHelper.encodeRenderedImageAsRGB(image, baout);
} catch (IOException ioe) {
- log.error("Error while serializing bitmap: " + ioe.getMessage(), ioe);
+ ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.imageWritingError(this, ioe);
return;
}
//int res = getResolution();
@@ -1363,8 +1372,9 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
} 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);
}
diff --git a/src/java/org/apache/fop/render/afp/AFPSVGHandler.java b/src/java/org/apache/fop/render/afp/AFPSVGHandler.java
index 0d3b864b0..939892648 100644
--- a/src/java/org/apache/fop/render/afp/AFPSVGHandler.java
+++ b/src/java/org/apache/fop/render/afp/AFPSVGHandler.java
@@ -113,8 +113,7 @@ public class AFPSVGHandler extends AbstractGenericSVGHandler {
if (cfg != null) {
strokeText = cfg.getChild("stroke-text", true).getValueAsBoolean(strokeText);
}
- final float uaResolution = context.getUserAgent().getSourceResolution();
- SVGUserAgent svgUserAgent = new SVGUserAgent(25.4f / uaResolution, new AffineTransform());
+ SVGUserAgent svgUserAgent = new SVGUserAgent(context.getUserAgent(), new AffineTransform());
BridgeContext ctx = new BridgeContext(svgUserAgent);
AFPTextHandler afpTextHandler = null;
diff --git a/src/java/org/apache/fop/render/bitmap/BitmapRendererEventProducer.java b/src/java/org/apache/fop/render/bitmap/BitmapRendererEventProducer.java
new file mode 100644
index 000000000..7b26d0771
--- /dev/null
+++ b/src/java/org/apache/fop/render/bitmap/BitmapRendererEventProducer.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render.bitmap;
+
+import java.io.IOException;
+
+import org.apache.fop.events.EventBroadcaster;
+import org.apache.fop.events.EventProducer;
+import org.apache.fop.events.model.AbstractEventModelFactory;
+import org.apache.fop.events.model.EventModel;
+
+/**
+ * Event producer interface for events generated by the bitmap renderers.
+ */
+public interface BitmapRendererEventProducer extends EventProducer {
+
+ /** Provider class for the event producer. */
+ class Provider {
+
+ /**
+ * Returns an event producer.
+ * @param broadcaster the event broadcaster to use
+ * @return the event producer
+ */
+ public static BitmapRendererEventProducer get(EventBroadcaster broadcaster) {
+ return (BitmapRendererEventProducer)broadcaster.getEventProducerFor(
+ BitmapRendererEventProducer.class);
+ }
+ }
+
+ /** Event model factory for this event producer. */
+ public static class EventModelFactory extends AbstractEventModelFactory {
+
+ /** {@inheritDoc} */
+ public EventModel createEventModel() {
+ return loadModel(getClass(), "event-model.xml");
+ }
+
+ }
+
+ /**
+ * No filename information available. Stopping early after the first page.
+ * @param source the event source
+ * @event.severity WARN
+ */
+ void stoppingAfterFirstPageNoFilename(Object source);
+
+ /**
+ * Image writer does not support multiple images. Only the first page has been produced.
+ * @param source the event source
+ * @event.severity WARN
+ */
+ void stoppingAfterFirstPageNoMultiWriter(Object source);
+
+ /**
+ * No ImageWriter found.
+ * @param source the event source
+ * @param mime the target MIME type
+ * @throws IOException the I/O error provoked by the method call
+ * @event.severity FATAL
+ */
+ void noImageWriterFound(Object source, String mime) throws IOException;
+}
diff --git a/src/java/org/apache/fop/render/bitmap/BitmapRendererEventProducer.xml b/src/java/org/apache/fop/render/bitmap/BitmapRendererEventProducer.xml
new file mode 100644
index 000000000..a05af3e21
--- /dev/null
+++ b/src/java/org/apache/fop/render/bitmap/BitmapRendererEventProducer.xml
@@ -0,0 +1,6 @@
+
+
+ No filename information available. Stopping early after the first page.
+ Image writer does not support multiple images. Only the first page has been produced.
+ Could not get an ImageWriter to produce "{mime}". The most likely explanation for this is a class loading problem.
+
diff --git a/src/java/org/apache/fop/render/bitmap/PNGRenderer.java b/src/java/org/apache/fop/render/bitmap/PNGRenderer.java
index bedd2c499..8613ef7b8 100644
--- a/src/java/org/apache/fop/render/bitmap/PNGRenderer.java
+++ b/src/java/org/apache/fop/render/bitmap/PNGRenderer.java
@@ -23,12 +23,12 @@ import java.awt.image.RenderedImage;
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 @@ public class PNGRenderer extends Java2DRenderer {
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 @@ public class PNGRenderer extends Java2DRenderer {
// 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());
diff --git a/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java b/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java
index 4f64e45e1..9291427d2 100644
--- a/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java
+++ b/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java
@@ -129,7 +129,10 @@ public class TIFFRenderer extends Java2DRenderer {
// 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 @@ public class TIFFRenderer extends Java2DRenderer {
} 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);
}
}
diff --git a/src/java/org/apache/fop/render/java2d/Java2DRenderer.java b/src/java/org/apache/fop/render/java2d/Java2DRenderer.java
index 583d2ad2f..0ffe3307a 100644
--- a/src/java/org/apache/fop/render/java2d/Java2DRenderer.java
+++ b/src/java/org/apache/fop/render/java2d/Java2DRenderer.java
@@ -66,6 +66,7 @@ import org.apache.fop.area.inline.SpaceArea;
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 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem
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);
}
}
diff --git a/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java b/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java
index 51b458cfe..64ac823fc 100644
--- a/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java
+++ b/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java
@@ -23,26 +23,25 @@ import java.awt.geom.AffineTransform;
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 @@ public class Java2DSVGHandler implements XMLHandler, Java2DRendererContextConsta
//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 @@ public class Java2DSVGHandler implements XMLHandler, Java2DRendererContextConsta
}
}
- /**
- * 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 @@ public class Java2DSVGHandler implements XMLHandler, Java2DRendererContextConsta
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 @@ public class Java2DSVGHandler implements XMLHandler, Java2DRendererContextConsta
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 @@ public class Java2DSVGHandler implements XMLHandler, Java2DRendererContextConsta
return (renderer instanceof Java2DRenderer);
}
-
- /** {@inheritDoc} */
- public String getNamespace() {
- return SVGDOMImplementation.SVG_NAMESPACE_URI;
- }
}
diff --git a/src/java/org/apache/fop/render/pcl/PCLEventProducer.java b/src/java/org/apache/fop/render/pcl/PCLEventProducer.java
new file mode 100644
index 000000000..3e72de293
--- /dev/null
+++ b/src/java/org/apache/fop/render/pcl/PCLEventProducer.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render.pcl;
+
+import org.apache.fop.events.EventBroadcaster;
+import org.apache.fop.events.EventProducer;
+import org.apache.fop.events.model.AbstractEventModelFactory;
+import org.apache.fop.events.model.EventModel;
+
+/**
+ * Event producer interface for events generated by the PCL renderer.
+ */
+public interface PCLEventProducer extends EventProducer {
+
+ /** Provider class for the event producer. */
+ class Provider {
+
+ /**
+ * Returns an event producer.
+ * @param broadcaster the event broadcaster to use
+ * @return the event producer
+ */
+ public static PCLEventProducer get(EventBroadcaster broadcaster) {
+ return (PCLEventProducer)broadcaster.getEventProducerFor(
+ PCLEventProducer.class);
+ }
+ }
+
+ /** Event model factory for this event producer. */
+ public static class EventModelFactory extends AbstractEventModelFactory {
+
+ /** {@inheritDoc} */
+ public EventModel createEventModel() {
+ return loadModel(getClass(), "event-model.xml");
+ }
+
+ }
+
+ /**
+ * Paper type could not be determined. Falling back to another.
+ * @param source the event source
+ * @param pageWidth the page width (in millipoints)
+ * @param pageHeight the page height (in millipoints)
+ * @param fallbackPaper the paper type that will be used instead
+ * @event.severity WARN
+ */
+ void paperTypeUnavailable(Object source, long pageWidth, long pageHeight, String fallbackPaper);
+
+}
diff --git a/src/java/org/apache/fop/render/pcl/PCLEventProducer.xml b/src/java/org/apache/fop/render/pcl/PCLEventProducer.xml
new file mode 100644
index 000000000..a3b36fd60
--- /dev/null
+++ b/src/java/org/apache/fop/render/pcl/PCLEventProducer.xml
@@ -0,0 +1,4 @@
+
+
+ Paper type ({pageWidth} x {pageHeight} mpt) could not be determined. Falling back to: {fallbackPaper}
+
diff --git a/src/java/org/apache/fop/render/pcl/PCLGenerator.java b/src/java/org/apache/fop/render/pcl/PCLGenerator.java
index 3eb8ec425..5ca9a8bf9 100644
--- a/src/java/org/apache/fop/render/pcl/PCLGenerator.java
+++ b/src/java/org/apache/fop/render/pcl/PCLGenerator.java
@@ -43,9 +43,11 @@ import java.text.DecimalFormatSymbols;
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 @@ public class PCLGenerator {
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
}
diff --git a/src/java/org/apache/fop/render/pcl/PCLRenderer.java b/src/java/org/apache/fop/render/pcl/PCLRenderer.java
index 1d606e919..b89fba9c1 100644
--- a/src/java/org/apache/fop/render/pcl/PCLRenderer.java
+++ b/src/java/org/apache/fop/render/pcl/PCLRenderer.java
@@ -58,6 +58,7 @@ import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM;
import org.apache.xmlgraphics.image.loader.util.ImageUtil;
import org.apache.xmlgraphics.java2d.GraphicContext;
import org.apache.xmlgraphics.java2d.Graphics2DImagePainter;
+import org.apache.xmlgraphics.util.QName;
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.MimeConstants;
@@ -77,6 +78,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.datatypes.URISpecification;
+import org.apache.fop.events.ResourceEventProducer;
import org.apache.fop.fo.extensions.ExtensionElementMapping;
import org.apache.fop.fonts.Font;
import org.apache.fop.fonts.FontInfo;
@@ -85,12 +87,12 @@ import org.apache.fop.render.Graphics2DAdapter;
import org.apache.fop.render.PrintRenderer;
import org.apache.fop.render.RendererContext;
import org.apache.fop.render.RendererContextConstants;
+import org.apache.fop.render.RendererEventProducer;
import org.apache.fop.render.java2d.FontMetricsMapper;
import org.apache.fop.render.java2d.FontSetup;
import org.apache.fop.render.java2d.Java2DRenderer;
import org.apache.fop.render.pcl.extensions.PCLElementMapping;
import org.apache.fop.traits.BorderProps;
-import org.apache.fop.util.QName;
import org.apache.fop.util.UnitConv;
/* Note:
@@ -208,7 +210,9 @@ public class PCLRenderer extends PrintRenderer {
*/
protected void handleIOTrouble(IOException ioe) {
if (!ioTrouble) {
- log.error("Error while writing to target file", ioe);
+ RendererEventProducer eventProducer = RendererEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.ioError(this, ioe);
ioTrouble = true;
}
}
@@ -417,11 +421,15 @@ public class PCLRenderer extends PrintRenderer {
if (this.currentPageDefinition == null) {
this.currentPageDefinition = PCLPageDefinition.getDefaultPageDefinition();
- log.warn("Paper type could not be determined. Falling back to: "
- + this.currentPageDefinition.getName());
+ PCLEventProducer eventProducer = PCLEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.paperTypeUnavailable(this, pagewidth, pageheight,
+ this.currentPageDefinition.getName());
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("page size: " + currentPageDefinition.getPhysicalPageSize());
+ log.debug("logical page: " + currentPageDefinition.getLogicalPageRect());
}
- log.debug("page size: " + currentPageDefinition.getPhysicalPageSize());
- log.debug("logical page: " + currentPageDefinition.getLogicalPageRect());
if (this.currentPageDefinition.isLandscapeFormat()) {
gen.writeCommand("&l1O"); //Orientation
} else {
@@ -1107,12 +1115,17 @@ public class PCLRenderer extends PrintRenderer {
}
} 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) {
- handleIOTrouble(ioe);
+ ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.imageIOError(this, (info != null ? info.toString() : uri), ioe, null);
}
}
diff --git a/src/java/org/apache/fop/render/pcl/PCLRendererContext.java b/src/java/org/apache/fop/render/pcl/PCLRendererContext.java
index 62d4bcaa4..422b9d51d 100644
--- a/src/java/org/apache/fop/render/pcl/PCLRendererContext.java
+++ b/src/java/org/apache/fop/render/pcl/PCLRendererContext.java
@@ -19,9 +19,10 @@
package org.apache.fop.render.pcl;
+import org.apache.xmlgraphics.util.QName;
+
import org.apache.fop.fo.extensions.ExtensionElementMapping;
import org.apache.fop.render.RendererContext;
-import org.apache.fop.util.QName;
/**
* Wrapper on the RendererContext to access the information structure for drawing
diff --git a/src/java/org/apache/fop/render/pdf/PDFEventProducer.java b/src/java/org/apache/fop/render/pdf/PDFEventProducer.java
new file mode 100644
index 000000000..f8b1bbb33
--- /dev/null
+++ b/src/java/org/apache/fop/render/pdf/PDFEventProducer.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render.pdf;
+
+import org.apache.fop.events.EventBroadcaster;
+import org.apache.fop.events.EventProducer;
+import org.apache.fop.events.model.AbstractEventModelFactory;
+import org.apache.fop.events.model.EventModel;
+
+/**
+ * Event producer interface for events generated by the PDF renderer.
+ */
+public interface PDFEventProducer extends EventProducer {
+
+ /** Provider class for the event producer. */
+ class Provider {
+
+ /**
+ * Returns an event producer.
+ * @param broadcaster the event broadcaster to use
+ * @return the event producer
+ */
+ public static PDFEventProducer get(EventBroadcaster broadcaster) {
+ return (PDFEventProducer)broadcaster.getEventProducerFor(
+ PDFEventProducer.class);
+ }
+ }
+
+ /** Event model factory for this event producer. */
+ public static class EventModelFactory extends AbstractEventModelFactory {
+
+ /** {@inheritDoc} */
+ public EventModel createEventModel() {
+ return loadModel(getClass(), "event-model.xml");
+ }
+
+ }
+
+ /**
+ * Some link targets haven't been fully resolved.
+ * @param source the event source
+ * @param count the number of unresolved links
+ * @event.severity WARN
+ */
+ void nonFullyResolvedLinkTargets(Object source, int count);
+
+}
diff --git a/src/java/org/apache/fop/render/pdf/PDFEventProducer.xml b/src/java/org/apache/fop/render/pdf/PDFEventProducer.xml
new file mode 100644
index 000000000..fd57d5099
--- /dev/null
+++ b/src/java/org/apache/fop/render/pdf/PDFEventProducer.xml
@@ -0,0 +1,4 @@
+
+
+ {count} link target{count,equals,1,,s} could not be fully resolved and now point{count,equals,1,,s} to the top of the page or {count,equals,1,is,are} dysfunctional.
+
diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderer.java b/src/java/org/apache/fop/render/pdf/PDFRenderer.java
index 55524534e..d2c8446eb 100644
--- a/src/java/org/apache/fop/render/pdf/PDFRenderer.java
+++ b/src/java/org/apache/fop/render/pdf/PDFRenderer.java
@@ -73,6 +73,7 @@ import org.apache.fop.area.inline.SpaceArea;
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.fo.extensions.xmp.XMPMetadata;
@@ -490,13 +491,10 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
PDFGoTo gt = (PDFGoTo) unfinishedGoTos.get(0);
finishIDGoTo(gt, defaultPos);
}
- boolean one = count == 1;
- String pl = one ? "" : "s";
- String ww = one ? "was" : "were";
- String ia = one ? "is" : "are";
- log.warn("" + count + " link target" + pl + " could not be fully resolved and "
- + ww + " now point to the top of the page or "
- + ia + " dysfunctional."); // dysfunctional if pageref is null
+ PDFEventProducer eventProducer = PDFEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.nonFullyResolvedLinkTargets(this, count);
+ // dysfunctional if pageref is null
}
}
@@ -555,16 +553,17 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
private void renderDestination(DestinationData dd) {
String targetID = dd.getIDRef();
- if (targetID != null && targetID.length() > 0) {
- PageViewport pv = dd.getPageViewport();
- if (pv == null) {
- log.warn("Unresolved destination item received: " + dd.getIDRef());
- }
+ if (targetID == null || targetID.length() == 0) {
+ throw new IllegalArgumentException("DestinationData must contain a ID reference");
+ }
+ PageViewport pv = dd.getPageViewport();
+ if (pv != null) {
PDFGoTo gt = getPDFGoToForID(targetID, pv.getKey());
pdfDoc.getFactory().makeDestination(
dd.getIDRef(), gt.makeReference());
} else {
- log.warn("DestinationData item with null or empty IDRef received.");
+ //Warning already issued by AreaTreeHandler (debug level is sufficient)
+ log.debug("Unresolved destination item received: " + dd.getIDRef());
}
}
@@ -584,22 +583,22 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
PDFOutline pdfOutline = null;
String targetID = bookmarkItem.getIDRef();
- if (targetID != null && targetID.length() > 0) {
- PageViewport pv = bookmarkItem.getPageViewport();
- if (pv != null) {
- String pvKey = pv.getKey();
- PDFGoTo gt = getPDFGoToForID(targetID, pvKey);
- // create outline object:
- PDFOutline parent = parentBookmarkItem != null
- ? parentBookmarkItem
- : pdfDoc.getOutlineRoot();
- pdfOutline = pdfDoc.getFactory().makeOutline(parent,
- bookmarkItem.getBookmarkTitle(), gt, bookmarkItem.showChildItems());
- } else {
- log.warn("Bookmark with IDRef \"" + targetID + "\" has a null PageViewport.");
- }
+ if (targetID == null || targetID.length() == 0) {
+ throw new IllegalArgumentException("DestinationData must contain a ID reference");
+ }
+ PageViewport pv = bookmarkItem.getPageViewport();
+ if (pv != null) {
+ String pvKey = pv.getKey();
+ PDFGoTo gt = getPDFGoToForID(targetID, pvKey);
+ // create outline object:
+ PDFOutline parent = parentBookmarkItem != null
+ ? parentBookmarkItem
+ : pdfDoc.getOutlineRoot();
+ pdfOutline = pdfDoc.getFactory().makeOutline(parent,
+ bookmarkItem.getBookmarkTitle(), gt, bookmarkItem.showChildItems());
} else {
- log.warn("Bookmark item with null or empty IDRef received.");
+ //Warning already issued by AreaTreeHandler (debug level is sufficient)
+ log.debug("Bookmark with IDRef \"" + targetID + "\" has a null PageViewport.");
}
for (int i = 0; i < bookmarkItem.getCount(); i++) {
@@ -1368,15 +1367,8 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
if (annotsAllowed) {
action = getPDFGoToForID(idRef, pvKey);
}
- } else if (pvKeyOK) {
- log.warn("Internal link trait with PageViewport key " + pvKey
- + " contains no ID reference.");
- } else if (idRefOK) {
- log.warn("Internal link trait with ID reference " + idRef
- + " contains no PageViewport key.");
} else {
- log.warn("Internal link trait received with neither PageViewport key"
- + " nor ID reference.");
+ //Warnings already issued by AreaTreeHandler
}
}
@@ -1671,7 +1663,9 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
x, y, posInt.width, posInt.height, foreignAttributes);
handler.generateImage(context, img, origin, posInt);
} catch (IOException ioe) {
- log.error("I/O error while handling image: " + info, ioe);
+ ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.imageWritingError(this, ioe);
return;
}
} else {
@@ -1680,13 +1674,17 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
+ info + " (" + img.getClass().getName() + ")");
}
} 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);
}
// output new data
@@ -1811,18 +1809,34 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
return MIME_TYPE;
}
+ /**
+ * Sets the PDF/A mode for the PDF renderer.
+ * @param mode the PDF/A mode
+ */
public void setAMode(PDFAMode mode) {
this.pdfAMode = mode;
}
+ /**
+ * Sets the PDF/X mode for the PDF renderer.
+ * @param mode the PDF/X mode
+ */
public void setXMode(PDFXMode mode) {
this.pdfXMode = mode;
}
+ /**
+ * Sets the output color profile for the PDF renderer.
+ * @param outputProfileURI the URI to the output color profile
+ */
public void setOutputProfileURI(String outputProfileURI) {
this.outputProfileURI = outputProfileURI;
}
+ /**
+ * Sets the filter map to be used by the PDF renderer.
+ * @param filterMap the filter map
+ */
public void setFilterMap(Map filterMap) {
this.filterMap = filterMap;
}
diff --git a/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java b/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java
index cbc0a8ec9..cb7c7cf89 100644
--- a/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java
+++ b/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java
@@ -36,6 +36,8 @@ import org.apache.batik.util.SVGConstants;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.xmlgraphics.util.QName;
+
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.fo.extensions.ExtensionElementMapping;
import org.apache.fop.fonts.FontInfo;
@@ -51,8 +53,8 @@ import org.apache.fop.render.RendererContextConstants;
import org.apache.fop.svg.PDFAElementBridge;
import org.apache.fop.svg.PDFBridgeContext;
import org.apache.fop.svg.PDFGraphics2D;
+import org.apache.fop.svg.SVGEventProducer;
import org.apache.fop.svg.SVGUserAgent;
-import org.apache.fop.util.QName;
/**
* PDF XML handler for SVG (uses Apache Batik).
@@ -144,8 +146,9 @@ public class PDFSVGHandler extends AbstractGenericSVGHandler
try {
super.renderSVGDocument(context, doc);
} catch (IOException ioe) {
- log.error("I/O error while rendering SVG graphic: "
- + ioe.getMessage(), ioe);
+ SVGEventProducer eventProducer = SVGEventProducer.Provider.get(
+ context.getUserAgent().getEventBroadcaster());
+ eventProducer.svgRenderingError(this, ioe, getDocumentURI(doc));
}
return;
}
@@ -153,15 +156,13 @@ public class PDFSVGHandler extends AbstractGenericSVGHandler
int yOffset = pdfInfo.currentYPosition;
FOUserAgent userAgent = context.getUserAgent();
- log.debug("Generating SVG at "
- + userAgent.getTargetResolution()
- + "dpi.");
final float deviceResolution = userAgent.getTargetResolution();
- log.debug("Generating SVG at " + deviceResolution + "dpi.");
- log.debug("Generating SVG at " + deviceResolution + "dpi.");
+ if (log.isDebugEnabled()) {
+ log.debug("Generating SVG at " + deviceResolution + "dpi.");
+ }
final float uaResolution = userAgent.getSourceResolution();
- SVGUserAgent ua = new SVGUserAgent(25.4f / uaResolution, new AffineTransform());
+ SVGUserAgent ua = new SVGUserAgent(userAgent, new AffineTransform());
//Scale for higher resolution on-the-fly images from Batik
double s = uaResolution / deviceResolution;
@@ -188,8 +189,9 @@ public class PDFSVGHandler extends AbstractGenericSVGHandler
root = builder.build(ctx, doc);
builder = null;
} 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;
}
// get the 'width' and 'height' attributes of the SVG document
@@ -261,8 +263,9 @@ public class PDFSVGHandler extends AbstractGenericSVGHandler
root.paint(graphics);
pdfInfo.currentStream.add(graphics.getString());
} catch (Exception e) {
- log.error("svg graphic could not be rendered: "
- + e.getMessage(), e);
+ SVGEventProducer eventProducer = SVGEventProducer.Provider.get(
+ context.getUserAgent().getEventBroadcaster());
+ eventProducer.svgRenderingError(this, e, getDocumentURI(doc));
}
pdfInfo.pdfState.pop();
renderer.restoreGraphicsState();
diff --git a/src/java/org/apache/fop/render/ps/PSEventProducer.java b/src/java/org/apache/fop/render/ps/PSEventProducer.java
new file mode 100644
index 000000000..451ed1cea
--- /dev/null
+++ b/src/java/org/apache/fop/render/ps/PSEventProducer.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render.ps;
+
+import org.apache.fop.events.EventBroadcaster;
+import org.apache.fop.events.EventProducer;
+import org.apache.fop.events.model.AbstractEventModelFactory;
+import org.apache.fop.events.model.EventModel;
+
+/**
+ * Event producer interface for events generated by the PostScript renderer.
+ */
+public interface PSEventProducer extends EventProducer {
+
+ /** Provider class for the event producer. */
+ class Provider {
+
+ /**
+ * Returns an event producer.
+ * @param broadcaster the event broadcaster to use
+ * @return the event producer
+ */
+ public static PSEventProducer get(EventBroadcaster broadcaster) {
+ return (PSEventProducer)broadcaster.getEventProducerFor(
+ PSEventProducer.class);
+ }
+ }
+
+ /** Event model factory for this event producer. */
+ public static class EventModelFactory extends AbstractEventModelFactory {
+
+ /** {@inheritDoc} */
+ public EventModel createEventModel() {
+ return loadModel(getClass(), "event-model.xml");
+ }
+
+ }
+
+ /**
+ * A PostScript dictionary could not be parsed.
+ * @param source the event source
+ * @param content the PostScript content
+ * @param e the original exception
+ * @event.severity ERROR
+ */
+ void postscriptDictionaryParseError(Object source, String content, Exception e);
+
+}
diff --git a/src/java/org/apache/fop/render/ps/PSEventProducer.xml b/src/java/org/apache/fop/render/ps/PSEventProducer.xml
new file mode 100644
index 000000000..a0078223a
--- /dev/null
+++ b/src/java/org/apache/fop/render/ps/PSEventProducer.xml
@@ -0,0 +1,4 @@
+
+
+ Failed to parse dictionary string. Reason: {e}, content = "{content}"
+
diff --git a/src/java/org/apache/fop/render/ps/PSRenderer.java b/src/java/org/apache/fop/render/ps/PSRenderer.java
index 7e32977e6..e4d582ba2 100644
--- a/src/java/org/apache/fop/render/ps/PSRenderer.java
+++ b/src/java/org/apache/fop/render/ps/PSRenderer.java
@@ -85,6 +85,7 @@ import org.apache.fop.area.inline.SpaceArea;
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.Font;
@@ -95,6 +96,7 @@ import org.apache.fop.render.AbstractPathOrientedRenderer;
import org.apache.fop.render.Graphics2DAdapter;
import org.apache.fop.render.ImageAdapter;
import org.apache.fop.render.RendererContext;
+import org.apache.fop.render.RendererEventProducer;
import org.apache.fop.render.ps.extensions.PSCommentAfter;
import org.apache.fop.render.ps.extensions.PSCommentBefore;
import org.apache.fop.render.ps.extensions.PSExtensionAttachment;
@@ -296,7 +298,9 @@ public class PSRenderer extends AbstractPathOrientedRenderer
*/
protected void handleIOTrouble(IOException ioe) {
if (!ioTrouble) {
- log.error("Error while writing to target file", ioe);
+ RendererEventProducer eventProducer = RendererEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.ioError(this, ioe);
ioTrouble = true;
}
}
@@ -522,12 +526,17 @@ public class PSRenderer extends AbstractPathOrientedRenderer
}
} 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) {
- handleIOTrouble(ioe);
+ ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.imageIOError(this, (info != null ? info.toString() : uri), ioe, null);
}
}
@@ -1070,8 +1079,9 @@ public class PSRenderer extends AbstractPathOrientedRenderer
try {
this.pageDeviceDictionary.putAll(PSDictionary.valueOf(content));
} catch (PSDictionaryFormatException e) {
- log.error("Failed to parse dictionary string: "
- + e.getMessage() + ", content = '" + content + "'");
+ PSEventProducer eventProducer = PSEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.postscriptDictionaryParseError(this, content, e);
}
}
} else if (attachment instanceof PSCommentBefore) {
@@ -1169,8 +1179,9 @@ public class PSRenderer extends AbstractPathOrientedRenderer
try {
pageDeviceDictionary.putAll(PSDictionary.valueOf(content));
} catch (PSDictionaryFormatException e) {
- log.error("failed to parse dictionary string: "
- + e.getMessage() + ", [" + content + "]");
+ PSEventProducer eventProducer = PSEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.postscriptDictionaryParseError(this, content, e);
}
}
}
diff --git a/src/java/org/apache/fop/render/ps/PSSVGHandler.java b/src/java/org/apache/fop/render/ps/PSSVGHandler.java
index 5cfe617c8..ebe098282 100644
--- a/src/java/org/apache/fop/render/ps/PSSVGHandler.java
+++ b/src/java/org/apache/fop/render/ps/PSSVGHandler.java
@@ -23,31 +23,24 @@ package org.apache.fop.render.ps;
import java.awt.geom.AffineTransform;
import java.io.IOException;
-// DOM
import org.w3c.dom.Document;
-import org.w3c.dom.svg.SVGDocument;
-import org.w3c.dom.svg.SVGSVGElement;
-// Batik
import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.batik.bridge.GVTBuilder;
import org.apache.batik.bridge.BridgeContext;
-import org.apache.batik.bridge.ViewBox;
-import org.apache.batik.dom.svg.SVGDOMImplementation;
+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.xmlgraphics.java2d.ps.PSGraphics2D;
+import org.apache.xmlgraphics.ps.PSGenerator;
-// FOP
import org.apache.fop.fonts.FontInfo;
+import org.apache.fop.render.AbstractGenericSVGHandler;
import org.apache.fop.render.Renderer;
-import org.apache.fop.render.XMLHandler;
import org.apache.fop.render.RendererContext;
+import org.apache.fop.svg.SVGEventProducer;
import org.apache.fop.svg.SVGUserAgent;
-import org.apache.xmlgraphics.java2d.ps.PSGraphics2D;
-import org.apache.xmlgraphics.ps.PSGenerator;
-
-// Commons-Logging
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
/**
* PostScript XML handler for SVG. Uses Apache Batik for SVG processing.
@@ -57,7 +50,8 @@ import org.apache.commons.logging.LogFactory;
*
* @version $Id$
*/
-public class PSSVGHandler implements XMLHandler, PSRendererContextConstants {
+public class PSSVGHandler extends AbstractGenericSVGHandler
+ implements PSRendererContextConstants {
/** logging instance */
private static Log log = LogFactory.getLog(PSSVGHandler.class);
@@ -68,16 +62,6 @@ public class PSSVGHandler implements XMLHandler, PSRendererContextConstants {
public PSSVGHandler() {
}
- /** {@inheritDoc} */
- public void handleXML(RendererContext context,
- Document doc, String ns) throws Exception {
- PSInfo psi = getPSInfo(context);
-
- if (SVGDOMImplementation.SVG_NAMESPACE_URI.equals(ns)) {
- renderSVGDocument(context, doc, psi);
- }
- }
-
/**
* Get the pdf information from the render context.
*
@@ -234,10 +218,10 @@ public class PSSVGHandler implements XMLHandler, PSRendererContextConstants {
* Render the svg document.
* @param context the renderer context
* @param doc the svg document
- * @param psInfo the pdf information of the current context
*/
protected void renderSVGDocument(RendererContext context,
- Document doc, PSInfo psInfo) {
+ Document doc) {
+ PSInfo psInfo = getPSInfo(context);
int xOffset = psInfo.currentXPosition;
int yOffset = psInfo.currentYPosition;
PSGenerator gen = psInfo.psGenerator;
@@ -250,9 +234,7 @@ public class PSSVGHandler implements XMLHandler, PSRendererContextConstants {
}
SVGUserAgent ua
- = new SVGUserAgent(
- context.getUserAgent().getSourcePixelUnitToMillimeter(),
- new AffineTransform());
+ = new SVGUserAgent(context.getUserAgent(), new AffineTransform());
PSGraphics2D graphics = new PSGraphics2D(strokeText, gen);
graphics.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());
@@ -273,8 +255,9 @@ public class PSSVGHandler implements XMLHandler, PSRendererContextConstants {
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;
}
// get the 'width' and 'height' attributes of the SVG document
@@ -305,10 +288,10 @@ public class PSSVGHandler implements XMLHandler, PSRendererContextConstants {
// viewBox puts it.
gen.concatMatrix(sx, 0, 0, sy, xOffset / 1000f, yOffset / 1000f);
+ /*
SVGSVGElement svg = ((SVGDocument)doc).getRootElement();
AffineTransform at = ViewBox.getPreserveAspectRatioTransform(svg,
- psInfo.getWidth() / 1000f, psInfo.getHeight() / 1000f);
- /*
+ psInfo.getWidth() / 1000f, psInfo.getHeight() / 1000f, ctx);
if (!at.isIdentity()) {
double[] vals = new double[6];
at.getMatrix(vals);
@@ -322,15 +305,17 @@ public class PSSVGHandler implements XMLHandler, PSRendererContextConstants {
try {
root.paint(graphics);
} catch (Exception e) {
- log.error("SVG graphic could not be rendered: "
- + e.getMessage(), e);
+ SVGEventProducer eventProducer = SVGEventProducer.Provider.get(
+ context.getUserAgent().getEventBroadcaster());
+ eventProducer.svgRenderingError(this, e, getDocumentURI(doc));
}
gen.restoreGraphicsState();
gen.commentln("%FOPEndSVG");
} catch (IOException ioe) {
- log.error("SVG graphic could not be rendered: "
- + ioe.getMessage(), ioe);
+ SVGEventProducer eventProducer = SVGEventProducer.Provider.get(
+ context.getUserAgent().getEventBroadcaster());
+ eventProducer.svgRenderingError(this, ioe, getDocumentURI(doc));
}
}
@@ -339,10 +324,5 @@ public class PSSVGHandler implements XMLHandler, PSRendererContextConstants {
return (renderer instanceof PSRenderer);
}
- /** {@inheritDoc} */
- public String getNamespace() {
- return SVGDOMImplementation.SVG_NAMESPACE_URI;
- }
-
}
diff --git a/src/java/org/apache/fop/render/ps/ResourceHandler.java b/src/java/org/apache/fop/render/ps/ResourceHandler.java
index 0dfb8029f..1a363c90e 100644
--- a/src/java/org/apache/fop/render/ps/ResourceHandler.java
+++ b/src/java/org/apache/fop/render/ps/ResourceHandler.java
@@ -20,8 +20,8 @@
package org.apache.fop.render.ps;
import java.awt.geom.Dimension2D;
-import java.awt.image.RenderedImage;
import java.awt.geom.Rectangle2D;
+import java.awt.image.RenderedImage;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -68,6 +68,7 @@ import org.apache.xmlgraphics.ps.dsc.events.PostScriptComment;
import org.apache.xmlgraphics.ps.dsc.tools.DSCTools;
import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.events.ResourceEventProducer;
import org.apache.fop.fonts.FontInfo;
/**
@@ -321,7 +322,10 @@ public class ResourceHandler implements DSCParserConstants, PSSupportedFlavors {
throw new UnsupportedOperationException("Unsupported image type: " + img);
}
} catch (ImageException ie) {
- throw new IOException("Error while generating form for image: " + ie.getMessage());
+ ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+ userAgent.getEventBroadcaster());
+ eventProducer.imageError(resTracker, (info != null ? info.toString() : uri),
+ ie, null);
}
}
}
diff --git a/src/java/org/apache/fop/render/ps/extensions/AbstractPSCommentElement.java b/src/java/org/apache/fop/render/ps/extensions/AbstractPSCommentElement.java
index a6e77fb13..1eb1d9d13 100644
--- a/src/java/org/apache/fop/render/ps/extensions/AbstractPSCommentElement.java
+++ b/src/java/org/apache/fop/render/ps/extensions/AbstractPSCommentElement.java
@@ -22,7 +22,6 @@ package org.apache.fop.render.ps.extensions;
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.FONode;
-import org.apache.fop.fo.ValidationException;
/**
* Base postscript commment element class
@@ -46,8 +45,8 @@ public abstract class AbstractPSCommentElement extends AbstractPSExtensionElemen
protected void startOfNode() throws FOPException {
if (parent.getNameId() != Constants.FO_DECLARATIONS
&& parent.getNameId() != Constants.FO_SIMPLE_PAGE_MASTER) {
- throw new ValidationException(getName()
- + " must be a child of fo:declarations or fo:simple-page-master.");
+ invalidChildError(getLocator(), parent.getName(), getNamespaceURI(), getName(),
+ "rule.childOfSPMorDeclarations");
}
}
diff --git a/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionElement.java b/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionElement.java
index a10bb7518..31e44d2d2 100644
--- a/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionElement.java
+++ b/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionElement.java
@@ -20,14 +20,14 @@
package org.apache.fop.render.ps.extensions;
// FOP
+import org.xml.sax.Locator;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.ValidationException;
import org.apache.fop.fo.extensions.ExtensionAttachment;
-import org.xml.sax.Locator;
-
/**
* Base class for the PostScript-specific extension elements.
*/
@@ -98,7 +98,7 @@ public abstract class AbstractPSExtensionElement extends FONode {
* @see org.apache.fop.fo.FONode#getNormalNamespacePrefix()
*/
public String getNormalNamespacePrefix() {
- return "fox";
+ return "ps";
}
/**
diff --git a/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionObject.java b/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionObject.java
index 6823d75d9..78b2f91eb 100644
--- a/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionObject.java
+++ b/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionObject.java
@@ -20,13 +20,14 @@
package org.apache.fop.render.ps.extensions;
// FOP
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.ValidationException;
import org.apache.fop.fo.extensions.ExtensionAttachment;
-import org.xml.sax.Attributes;
-import org.xml.sax.Locator;
/**
* Base class for the PostScript-specific extension elements.
@@ -36,15 +37,15 @@ public abstract class AbstractPSExtensionObject extends FONode {
private PSSetupCode setupCode = new PSSetupCode();
/**
+ * Main constructor.
+ * @param parent the parent node
* @see org.apache.fop.fo.FONode#FONode(FONode)
*/
public AbstractPSExtensionObject(FONode parent) {
super(parent);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
protected void validateChildNode(Locator loc, String nsURI, String localName)
throws ValidationException {
if (FO_URI.equals(nsURI)) {
@@ -71,7 +72,7 @@ public abstract class AbstractPSExtensionObject extends FONode {
/**{@inheritDoc} */
public String getNormalNamespacePrefix() {
- return "fox";
+ return "ps";
}
/** {@inheritDoc} */
diff --git a/src/java/org/apache/fop/render/ps/extensions/PSCommentAfterElement.java b/src/java/org/apache/fop/render/ps/extensions/PSCommentAfterElement.java
index 4bbfa0c73..d03a0220c 100644
--- a/src/java/org/apache/fop/render/ps/extensions/PSCommentAfterElement.java
+++ b/src/java/org/apache/fop/render/ps/extensions/PSCommentAfterElement.java
@@ -27,6 +27,9 @@ import org.apache.fop.fo.extensions.ExtensionAttachment;
*/
public class PSCommentAfterElement extends AbstractPSCommentElement {
+ /** the element name */
+ protected static final String ELEMENT = "ps-comment-after";
+
/**
* Main constructor
* @param parent node
diff --git a/src/java/org/apache/fop/render/ps/extensions/PSCommentBeforeElement.java b/src/java/org/apache/fop/render/ps/extensions/PSCommentBeforeElement.java
index f05e7c7fe..d74d3a194 100644
--- a/src/java/org/apache/fop/render/ps/extensions/PSCommentBeforeElement.java
+++ b/src/java/org/apache/fop/render/ps/extensions/PSCommentBeforeElement.java
@@ -27,6 +27,9 @@ import org.apache.fop.fo.extensions.ExtensionAttachment;
*/
public class PSCommentBeforeElement extends AbstractPSCommentElement {
+ /** the element name */
+ protected static final String ELEMENT = "ps-comment-before";
+
/**
* Main constructor
* @param parent parent node
diff --git a/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandler.java b/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandler.java
index 456d97430..e69500736 100644
--- a/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandler.java
+++ b/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandler.java
@@ -19,13 +19,15 @@
package org.apache.fop.render.ps.extensions;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.apache.fop.util.ContentHandlerFactory;
import org.apache.fop.util.ContentHandlerFactory.ObjectBuiltListener;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.DefaultHandler;
/**
* ContentHandler (parser) for restoring PSExtension objects from XML.
@@ -91,25 +93,19 @@ public class PSExtensionHandler extends DefaultHandler
content.append(ch, start, length);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void endDocument() throws SAXException {
if (listener != null) {
listener.notifyObjectBuilt(getObject());
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public Object getObject() {
return returnedObject;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void setObjectBuiltListener(ObjectBuiltListener listener) {
this.listener = listener;
}
diff --git a/src/java/org/apache/fop/render/ps/extensions/PSPageSetupCodeElement.java b/src/java/org/apache/fop/render/ps/extensions/PSPageSetupCodeElement.java
index ad46b9364..207c11e76 100644
--- a/src/java/org/apache/fop/render/ps/extensions/PSPageSetupCodeElement.java
+++ b/src/java/org/apache/fop/render/ps/extensions/PSPageSetupCodeElement.java
@@ -22,13 +22,13 @@ package org.apache.fop.render.ps.extensions;
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.FONode;
-import org.apache.fop.fo.ValidationException;
/**
* Extension element for fox:ps-page-setup-code.
*/
public class PSPageSetupCodeElement extends AbstractPSExtensionObject {
+ /** The element name */
protected static final String ELEMENT = "ps-page-setup-code";
/**
@@ -43,7 +43,8 @@ public class PSPageSetupCodeElement extends AbstractPSExtensionObject {
protected void startOfNode() throws FOPException {
super.startOfNode();
if (parent.getNameId() != Constants.FO_SIMPLE_PAGE_MASTER) {
- throw new ValidationException(getName() + " must be a child of fo:simple-page-master.");
+ invalidChildError(getLocator(), parent.getName(), getNamespaceURI(), getName(),
+ "rule.childOfSPM");
}
}
diff --git a/src/java/org/apache/fop/render/ps/extensions/PSSetPageDeviceElement.java b/src/java/org/apache/fop/render/ps/extensions/PSSetPageDeviceElement.java
index b512c6888..21acc8001 100644
--- a/src/java/org/apache/fop/render/ps/extensions/PSSetPageDeviceElement.java
+++ b/src/java/org/apache/fop/render/ps/extensions/PSSetPageDeviceElement.java
@@ -19,20 +19,21 @@
package org.apache.fop.render.ps.extensions;
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.PropertyList;
-import org.apache.fop.fo.ValidationException;
import org.apache.fop.fo.extensions.ExtensionAttachment;
-import org.xml.sax.Attributes;
-import org.xml.sax.Locator;
/**
* Extension element for ps:ps-setpagedevice.
*/
public class PSSetPageDeviceElement extends AbstractPSExtensionElement {
+ /** The element name */
protected static final String ELEMENT = "ps-setpagedevice";
/**
@@ -52,8 +53,8 @@ public class PSSetPageDeviceElement extends AbstractPSExtensionElement {
super.startOfNode();
if ( !((parent.getNameId() == Constants.FO_DECLARATIONS)
|| (parent.getNameId() == Constants.FO_SIMPLE_PAGE_MASTER)) ) {
- throw new ValidationException( getName()
- + " must be a child of fo:declarations or fo:simple-page-master.");
+ invalidChildError(getLocator(), parent.getName(), getNamespaceURI(), getName(),
+ "rule.childOfSPMorDeclarations");
}
}
diff --git a/src/java/org/apache/fop/render/ps/extensions/PSSetupCodeElement.java b/src/java/org/apache/fop/render/ps/extensions/PSSetupCodeElement.java
index ec7216c44..e76dfeb64 100644
--- a/src/java/org/apache/fop/render/ps/extensions/PSSetupCodeElement.java
+++ b/src/java/org/apache/fop/render/ps/extensions/PSSetupCodeElement.java
@@ -22,13 +22,13 @@ package org.apache.fop.render.ps.extensions;
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.FONode;
-import org.apache.fop.fo.ValidationException;
/**
* Extension element for fox:ps-setup-code.
*/
public class PSSetupCodeElement extends AbstractPSExtensionObject {
+ /** The element name */
protected static final String ELEMENT = "ps-setup-code";
/**
@@ -43,7 +43,8 @@ public class PSSetupCodeElement extends AbstractPSExtensionObject {
protected void startOfNode() throws FOPException {
super.startOfNode();
if (parent.getNameId() != Constants.FO_DECLARATIONS) {
- throw new ValidationException(getName() + " must be a child of fo:declarations.");
+ invalidChildError(getLocator(), parent.getName(), getNamespaceURI(), getName(),
+ "rule.childOfDeclarations");
}
}
diff --git a/src/java/org/apache/fop/render/rtf/RTFEventProducer.java b/src/java/org/apache/fop/render/rtf/RTFEventProducer.java
new file mode 100644
index 000000000..a2646af46
--- /dev/null
+++ b/src/java/org/apache/fop/render/rtf/RTFEventProducer.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render.rtf;
+
+import org.xml.sax.Locator;
+
+import org.apache.fop.events.EventBroadcaster;
+import org.apache.fop.events.EventProducer;
+import org.apache.fop.events.model.AbstractEventModelFactory;
+import org.apache.fop.events.model.EventModel;
+import org.apache.fop.fo.FONode;
+
+/**
+ * Event producer interface for events generated by the RTF renderer.
+ */
+public interface RTFEventProducer extends EventProducer {
+
+ /** Provider class for the event producer. */
+ class Provider {
+
+ /**
+ * Returns an event producer.
+ * @param broadcaster the event broadcaster to use
+ * @return the event producer
+ */
+ public static RTFEventProducer get(EventBroadcaster broadcaster) {
+ return (RTFEventProducer)broadcaster.getEventProducerFor(
+ RTFEventProducer.class);
+ }
+ }
+
+ /** Event model factory for this event producer. */
+ public static class EventModelFactory extends AbstractEventModelFactory {
+
+ /** {@inheritDoc} */
+ public EventModel createEventModel() {
+ return loadModel(getClass(), "event-model.xml");
+ }
+
+ }
+
+ /**
+ * The RTF handler only supports simple-page-masters.
+ * @param source the event source
+ * @param masterReference the reference page-master-set
+ * @param loc the location of the error or null
+ * @event.severity WARN
+ */
+ void onlySPMSupported(Object source, String masterReference, Locator loc);
+
+ /**
+ * No simple-page-master could be determined-
+ * @param source the event source
+ * @param loc the location of the error or null
+ * @event.severity WARN
+ */
+ void noSPMFound(Object source, Locator loc);
+
+ /**
+ * The RTF handler requires explicit table-columns for now.
+ * @param source the event source
+ * @param loc the location of the error or null
+ * @event.severity WARN
+ */
+ void explicitTableColumnsRequired(Object source, Locator loc);
+
+ /**
+ * The RTF handler ignored some deferred event (i.e. an unsupported element).
+ * @param source the event source
+ * @param node the FO tree node being ignored
+ * @param start true for start, false for end
+ * @param loc the location of the error or null
+ * @event.severity WARN
+ */
+ void ignoredDeferredEvent(Object source, FONode node, boolean start, Locator loc);
+
+}
diff --git a/src/java/org/apache/fop/render/rtf/RTFEventProducer.xml b/src/java/org/apache/fop/render/rtf/RTFEventProducer.xml
new file mode 100644
index 000000000..8f1f21a81
--- /dev/null
+++ b/src/java/org/apache/fop/render/rtf/RTFEventProducer.xml
@@ -0,0 +1,8 @@
+
+
+ [ (See position {loc})| (See {#gatherContextInfo})| (No context info available)]
+ Only simple-page-masters are supported on page-sequences. Using default simple-page-master from page-sequence-master "{masterReference}".{{locator}}
+ No simple-page-master could be determined.
+ No table-columns found on table. RTF output requires that all table-columns for a table are defined. Output will be incorrect.{{locator}}
+ Ignored deferred event for {node} ({start,if,start,end}).{{locator}}
+
diff --git a/src/java/org/apache/fop/render/rtf/RTFHandler.java b/src/java/org/apache/fop/render/rtf/RTFHandler.java
index d2f2c4192..88e34e17a 100644
--- a/src/java/org/apache/fop/render/rtf/RTFHandler.java
+++ b/src/java/org/apache/fop/render/rtf/RTFHandler.java
@@ -21,6 +21,7 @@ package org.apache.fop.render.rtf;
// Java
import java.awt.geom.Point2D;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -51,6 +52,7 @@ import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.datatypes.LengthBase;
import org.apache.fop.datatypes.SimplePercentBaseContext;
+import org.apache.fop.events.ResourceEventProducer;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.FOEventHandler;
import org.apache.fop.fo.FONode;
@@ -88,6 +90,7 @@ import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
import org.apache.fop.fo.properties.FixedLength;
import org.apache.fop.fonts.FontSetup;
import org.apache.fop.render.DefaultFontResolver;
+import org.apache.fop.render.RendererEventProducer;
import org.apache.fop.render.rtf.rtflib.rtfdoc.IRtfAfterContainer;
import org.apache.fop.render.rtf.rtflib.rtfdoc.IRtfBeforeContainer;
import org.apache.fop.render.rtf.rtflib.rtfdoc.IRtfListContainer;
@@ -158,6 +161,16 @@ public class RTFHandler extends FOEventHandler {
FontSetup.setup(fontInfo, null, new DefaultFontResolver(userAgent));
}
+ /**
+ * Central exception handler for I/O exceptions.
+ * @param ioe IOException to handle
+ */
+ protected void handleIOTrouble(IOException ioe) {
+ RendererEventProducer eventProducer = RendererEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.ioError(this, ioe);
+ }
+
/**
* {@inheritDoc}
*/
@@ -195,9 +208,9 @@ public class RTFHandler extends FOEventHandler {
this.pagemaster
= pageSeq.getRoot().getLayoutMasterSet().getSimplePageMaster(reference);
if (this.pagemaster == null) {
- log.warn("Only simple-page-masters are supported on page-sequences: "
- + reference);
- log.warn("Using default simple-page-master from page-sequence-master...");
+ RTFEventProducer eventProducer = RTFEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.onlySPMSupported(this, reference, pageSeq.getLocator());
PageSequenceMaster master
= pageSeq.getRoot().getLayoutMasterSet().getPageSequenceMaster(reference);
this.pagemaster = master.getNextSimplePageMaster(
@@ -218,7 +231,9 @@ public class RTFHandler extends FOEventHandler {
PageAttributesConverter.convertPageAttributes(
pagemaster));
} else {
- log.warn("No simple-page-master could be determined!");
+ RTFEventProducer eventProducer = RTFEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.noSPMFound(this, pageSeq.getLocator());
}
builderContext.pushContainer(sect);
@@ -226,9 +241,7 @@ public class RTFHandler extends FOEventHandler {
bHeaderSpecified = false;
bFooterSpecified = false;
} catch (IOException ioe) {
- // TODO could we throw Exception in all FOEventHandler events?
- log.error("startPageSequence: " + ioe.getMessage(), ioe);
- //TODO throw new FOPException(ioe);
+ handleIOTrouble(ioe);
} catch (FOPException fope) {
// TODO could we throw Exception in all FOEventHandler events?
log.error("startPageSequence: " + fope.getMessage(), fope);
@@ -338,8 +351,7 @@ public class RTFHandler extends FOEventHandler {
log.warn("A " + fl.getLocalName() + " has been skipped: " + fl.getFlowName());
}
} catch (IOException ioe) {
- log.error("startFlow: " + ioe.getMessage());
- throw new RuntimeException(ioe.getMessage());
+ handleIOTrouble(ioe);
} catch (Exception e) {
log.error("startFlow: " + e.getMessage());
throw new RuntimeException(e.getMessage());
@@ -396,9 +408,7 @@ public class RTFHandler extends FOEventHandler {
textrun.pushBlockAttributes(rtfAttr);
textrun.addBookmark(bl.getId());
} catch (IOException ioe) {
- // TODO could we throw Exception in all FOEventHandler events?
- log.error("startBlock: " + ioe.getMessage());
- throw new RuntimeException("IOException: " + ioe);
+ handleIOTrouble(ioe);
} catch (Exception e) {
log.error("startBlock: " + e.getMessage());
throw new RuntimeException("Exception: " + e);
@@ -427,8 +437,7 @@ public class RTFHandler extends FOEventHandler {
textrun.popBlockAttributes();
} catch (IOException ioe) {
- log.error("startBlock:" + ioe.getMessage());
- throw new RuntimeException(ioe.getMessage());
+ handleIOTrouble(ioe);
} catch (Exception e) {
log.error("startBlock:" + e.getMessage());
throw new RuntimeException(e.getMessage());
@@ -457,9 +466,7 @@ public class RTFHandler extends FOEventHandler {
textrun.addParagraphBreak();
textrun.pushBlockAttributes(rtfAttr);
} catch (IOException ioe) {
- // TODO could we throw Exception in all FOEventHandler events?
- log.error("startBlock: " + ioe.getMessage());
- throw new RuntimeException("IOException: " + ioe);
+ handleIOTrouble(ioe);
} catch (Exception e) {
log.error("startBlock: " + e.getMessage());
throw new RuntimeException("Exception: " + e);
@@ -486,8 +493,7 @@ public class RTFHandler extends FOEventHandler {
textrun.popBlockAttributes();
} catch (IOException ioe) {
- log.error("startBlock:" + ioe.getMessage());
- throw new RuntimeException(ioe.getMessage());
+ handleIOTrouble(ioe);
} catch (Exception e) {
log.error("startBlock:" + e.getMessage());
throw new RuntimeException(e.getMessage());
@@ -530,6 +536,8 @@ public class RTFHandler extends FOEventHandler {
table.setBorderAttributes(borderAttributes);
builderContext.pushContainer(table);
+ } catch (IOException ioe) {
+ handleIOTrouble(ioe);
} catch (Exception e) {
log.error("startTable:" + e.getMessage());
throw new RuntimeException(e.getMessage());
@@ -590,7 +598,6 @@ public class RTFHandler extends FOEventHandler {
log.error("startColumn: " + e.getMessage());
throw new RuntimeException(e.getMessage());
}
-
}
/**
@@ -649,8 +656,7 @@ public class RTFHandler extends FOEventHandler {
textrun.pushInlineAttributes(rtfAttr);
textrun.addBookmark(inl.getId());
} catch (IOException ioe) {
- log.error("startInline:" + ioe.getMessage());
- throw new RuntimeException(ioe.getMessage());
+ handleIOTrouble(ioe);
} catch (FOPException fe) {
log.error("startInline:" + fe.getMessage());
throw new RuntimeException(fe.getMessage());
@@ -677,8 +683,7 @@ public class RTFHandler extends FOEventHandler {
RtfTextrun textrun = container.getTextrun();
textrun.popInlineAttributes();
} catch (IOException ioe) {
- log.error("startInline:" + ioe.getMessage());
- throw new RuntimeException(ioe.getMessage());
+ handleIOTrouble(ioe);
} catch (Exception e) {
log.error("startInline:" + e.getMessage());
throw new RuntimeException(e.getMessage());
@@ -698,6 +703,8 @@ public class RTFHandler extends FOEventHandler {
RtfTable tbl = (RtfTable)builderContext.getContainer(RtfTable.class, true, this);
tbl.setHeaderAttribs(atts);
+ } catch (IOException ioe) {
+ handleIOTrouble(ioe);
} catch (Exception e) {
log.error("startBody: " + e.getMessage());
throw new RuntimeException(e.getMessage());
@@ -715,6 +722,8 @@ public class RTFHandler extends FOEventHandler {
try {
RtfTable tbl = (RtfTable)builderContext.getContainer(RtfTable.class, true, this);
tbl.setHeaderAttribs(null);
+ } catch (IOException ioe) {
+ handleIOTrouble(ioe);
} catch (Exception e) {
log.error("endBody: " + e.getMessage());
throw new RuntimeException(e.getMessage());
@@ -745,6 +754,8 @@ public class RTFHandler extends FOEventHandler {
// reset column iteration index to correctly access column widths
builderContext.getTableContext().selectFirstColumn();
+ } catch (IOException ioe) {
+ handleIOTrouble(ioe);
} catch (Exception e) {
log.error("startRow: " + e.getMessage());
throw new RuntimeException(e.getMessage());
@@ -778,6 +789,8 @@ public class RTFHandler extends FOEventHandler {
tctx.selectNextColumn();
}
+ } catch (IOException ioe) {
+ handleIOTrouble(ioe);
} catch (Exception e) {
log.error("endRow: " + e.getMessage());
throw new RuntimeException(e.getMessage());
@@ -870,6 +883,8 @@ public class RTFHandler extends FOEventHandler {
}
builderContext.pushContainer(cell);
+ } catch (IOException ioe) {
+ handleIOTrouble(ioe);
} catch (Exception e) {
log.error("startCell: " + e.getMessage());
throw new RuntimeException(e.getMessage());
@@ -906,8 +921,7 @@ public class RTFHandler extends FOEventHandler {
ListAttributesConverter.convertAttributes(lb));
builderContext.pushContainer(newList);
} catch (IOException ioe) {
- log.error("startList: " + ioe.getMessage());
- throw new RuntimeException(ioe.getMessage());
+ handleIOTrouble(ioe);
} catch (FOPException fe) {
log.error("startList: " + fe.getMessage());
throw new RuntimeException(fe.getMessage());
@@ -961,8 +975,7 @@ public class RTFHandler extends FOEventHandler {
builderContext.pushContainer(list.newListItem());
} catch (IOException ioe) {
- log.error("startList: " + ioe.getMessage());
- throw new RuntimeException(ioe.getMessage());
+ handleIOTrouble(ioe);
} catch (Exception e) {
log.error("startList: " + e.getMessage());
throw new RuntimeException(e.getMessage());
@@ -995,8 +1008,7 @@ public class RTFHandler extends FOEventHandler {
RtfListItemLabel label = item.new RtfListItemLabel(item);
builderContext.pushContainer(label);
} catch (IOException ioe) {
- log.error("startPageNumber:" + ioe.getMessage());
- throw new RuntimeException(ioe.getMessage());
+ handleIOTrouble(ioe);
} catch (Exception e) {
log.error("startPageNumber: " + e.getMessage());
throw new RuntimeException(e.getMessage());
@@ -1077,8 +1089,7 @@ public class RTFHandler extends FOEventHandler {
builderContext.pushContainer(link);
} catch (IOException ioe) {
- log.error("startLink:" + ioe.getMessage());
- throw new RuntimeException(ioe.getMessage());
+ handleIOTrouble(ioe);
} catch (Exception e) {
log.error("startLink: " + e.getMessage());
throw new RuntimeException(e.getMessage());
@@ -1104,21 +1115,28 @@ public class RTFHandler extends FOEventHandler {
return;
}
+ String uri = eg.getURL();
+ ImageInfo info = null;
try {
- String uri = eg.getURL();
//set image data
FOUserAgent userAgent = eg.getUserAgent();
ImageManager manager = userAgent.getFactory().getImageManager();
- ImageInfo info = manager.getImageInfo(uri, userAgent.getImageSessionContext());
- if (info == null) {
- log.error("Image could not be found: " + uri);
- return;
- }
+ info = manager.getImageInfo(uri, userAgent.getImageSessionContext());
putGraphic(eg, info);
- } catch (Exception e) {
- log.error("Error while handling an external-graphic: " + e.getMessage(), e);
+ } catch (ImageException ie) {
+ 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) {
+ ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.imageIOError(this, (info != null ? info.toString() : uri), ioe, null);
}
}
@@ -1144,6 +1162,12 @@ public class RTFHandler extends FOEventHandler {
// Set the image size to the size of the svg.
Point2D csize = new Point2D.Float(-1, -1);
Point2D intrinsicDimensions = child.getDimension(csize);
+ if (intrinsicDimensions == null) {
+ ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.ifoNoIntrinsicSize(this, child.getLocator());
+ return;
+ }
size.setSizeInMillipoints(
(int)Math.round(intrinsicDimensions.getX() * 1000),
(int)Math.round(intrinsicDimensions.getY() * 1000));
@@ -1157,8 +1181,14 @@ public class RTFHandler extends FOEventHandler {
Image converted = manager.convertImage(image, FLAVORS);
putGraphic(ifo, converted);
- } catch (Exception e) {
- log.error("Error while handling an instream-foreign-object: " + e.getMessage(), e);
+ } catch (ImageException ie) {
+ ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.imageError(this, null, ie, null);
+ } catch (IOException ioe) {
+ ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.imageIOError(this, null, ioe, null);
}
}
@@ -1183,7 +1213,9 @@ public class RTFHandler extends FOEventHandler {
putGraphic(abstractGraphic, image);
} catch (ImageException ie) {
- log.error("Error while loading/processing image: " + info.getOriginalURI(), ie);
+ ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.imageError(this, null, ie, null);
}
}
@@ -1210,8 +1242,9 @@ public class RTFHandler extends FOEventHandler {
}
if (rawData == null) {
- log.warn(FONode.decorateWithContextInfo("Image could not be embedded: "
- + image, abstractGraphic));
+ ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.imageWritingError(this, null);
return;
}
@@ -1322,9 +1355,7 @@ public class RTFHandler extends FOEventHandler {
builderContext.pushContainer(rtfFootnote);
} catch (IOException ioe) {
- // TODO could we throw Exception in all FOEventHandler events?
- log.error("startFootnote: " + ioe.getMessage());
- throw new RuntimeException("IOException: " + ioe);
+ handleIOTrouble(ioe);
} catch (Exception e) {
log.error("startFootnote: " + e.getMessage());
throw new RuntimeException("Exception: " + e);
@@ -1358,9 +1389,7 @@ public class RTFHandler extends FOEventHandler {
rtfFootnote.startBody();
} catch (IOException ioe) {
- // TODO could we throw Exception in all FOEventHandler events?
- log.error("startFootnoteBody: " + ioe.getMessage());
- throw new RuntimeException("IOException: " + ioe);
+ handleIOTrouble(ioe);
} catch (Exception e) {
log.error("startFootnoteBody: " + e.getMessage());
throw new RuntimeException("Exception: " + e);
@@ -1383,9 +1412,7 @@ public class RTFHandler extends FOEventHandler {
rtfFootnote.endBody();
} catch (IOException ioe) {
- // TODO could we throw Exception in all FOEventHandler events?
- log.error("endFootnoteBody: " + ioe.getMessage());
- throw new RuntimeException("IOException: " + ioe);
+ handleIOTrouble(ioe);
} catch (Exception e) {
log.error("endFootnoteBody: " + e.getMessage());
throw new RuntimeException("Exception: " + e);
@@ -1421,10 +1448,8 @@ public class RTFHandler extends FOEventHandler {
textrun.pushInlineAttributes(rtfAttr);
textrun.addString(new String(data, start, length - start));
textrun.popInlineAttributes();
- } catch (IOException ioe) {
- // FIXME could we throw Exception in all FOEventHandler events?
- log.error("characters: " + ioe.getMessage());
- throw new RuntimeException(ioe.getMessage());
+ } catch (IOException ioe) {
+ handleIOTrouble(ioe);
} catch (Exception e) {
log.error("characters:" + e.getMessage());
throw new RuntimeException(e.getMessage());
@@ -1452,8 +1477,7 @@ public class RTFHandler extends FOEventHandler {
RtfTextrun textrun = container.getTextrun();
textrun.addPageNumber(rtfAttr);
} catch (IOException ioe) {
- log.error("startPageNumber:" + ioe.getMessage());
- throw new RuntimeException(ioe.getMessage());
+ handleIOTrouble(ioe);
} catch (Exception e) {
log.error("startPageNumber: " + e.getMessage());
throw new RuntimeException(e.getMessage());
@@ -1611,7 +1635,9 @@ public class RTFHandler extends FOEventHandler {
endCell( (TableCell) foNode);
}
} else {
- log.warn("Ignored deferred event for " + foNode);
+ RTFEventProducer eventProducer = RTFEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.ignoredDeferredEvent(this, foNode, bStart, foNode.getLocator());
}
}
@@ -1655,8 +1681,9 @@ public class RTFHandler extends FOEventHandler {
}
} else {
//TODO Implement implicit column setup handling!
- log.warn("No table-columns found on table. RTF output requires that all"
- + " table-columns for a table are defined. Output will be incorrect.");
+ RTFEventProducer eventProducer = RTFEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.explicitTableColumnsRequired(this, table.getLocator());
}
//recurse table-header
diff --git a/src/java/org/apache/fop/render/xml/XMLRenderer.java b/src/java/org/apache/fop/render/xml/XMLRenderer.java
index 66cce0ae1..eb3c92e1b 100644
--- a/src/java/org/apache/fop/render/xml/XMLRenderer.java
+++ b/src/java/org/apache/fop/render/xml/XMLRenderer.java
@@ -41,6 +41,7 @@ import org.xml.sax.SAXException;
import org.xml.sax.ext.LexicalHandler;
import org.xml.sax.helpers.AttributesImpl;
+import org.apache.xmlgraphics.util.QName;
import org.apache.xmlgraphics.util.XMLizable;
import org.apache.fop.apps.FOPException;
@@ -90,7 +91,6 @@ import org.apache.fop.render.Renderer;
import org.apache.fop.render.RendererContext;
import org.apache.fop.render.XMLHandler;
import org.apache.fop.util.ColorUtil;
-import org.apache.fop.util.QName;
/**
* Renderer that renders areas to XML for debugging purposes.
diff --git a/src/java/org/apache/fop/svg/SVGEventProducer.java b/src/java/org/apache/fop/svg/SVGEventProducer.java
new file mode 100644
index 000000000..8894f3f58
--- /dev/null
+++ b/src/java/org/apache/fop/svg/SVGEventProducer.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.svg;
+
+import org.apache.fop.events.EventBroadcaster;
+import org.apache.fop.events.EventProducer;
+
+/**
+ * Event producer interface for SVG-related events.
+ */
+public interface SVGEventProducer extends EventProducer {
+
+ /**
+ * Provider class for the event producer.
+ */
+ class Provider {
+
+ /**
+ * Returns an event producer.
+ * @param broadcaster the event broadcaster to use
+ * @return the event producer
+ */
+ public static SVGEventProducer get(EventBroadcaster broadcaster) {
+ return (SVGEventProducer)broadcaster.getEventProducerFor(
+ SVGEventProducer.class);
+ }
+ }
+
+ /**
+ * Error during SVG processing. Either message or e must be set.
+ * @param source the event source
+ * @param message the error message (or null)
+ * @param e the exception (or null)
+ * @event.severity ERROR
+ */
+ void error(Object source, String message, Exception e);
+
+ /**
+ * Alert during SVG processing.
+ * @param source the event source
+ * @param message the error message
+ * @event.severity WARN
+ */
+ void alert(Object source, String message);
+
+ /**
+ * Info during SVG processing.
+ * @param source the event source
+ * @param message the error message
+ * @event.severity INFO
+ */
+ void info(Object source, String message);
+
+ /**
+ * SVG graphic could not be built due to an exception.
+ * @param source the event source
+ * @param e the original exception
+ * @param uri the URI of the SVG graphic
+ * @event.severity ERROR
+ */
+ void svgNotBuilt(Object source, Exception e, String uri);
+
+ /**
+ * SVG graphic could not be rendered due to an exception.
+ * @param source the event source
+ * @param e the original exception
+ * @param uri the URI of the SVG graphic
+ * @event.severity ERROR
+ */
+ void svgRenderingError(Object source, Exception e, String uri);
+
+}
diff --git a/src/java/org/apache/fop/svg/SVGUserAgent.java b/src/java/org/apache/fop/svg/SVGUserAgent.java
index 540f490de..8d7754fcb 100644
--- a/src/java/org/apache/fop/svg/SVGUserAgent.java
+++ b/src/java/org/apache/fop/svg/SVGUserAgent.java
@@ -19,49 +19,42 @@
package org.apache.fop.svg;
-import javax.xml.parsers.SAXParserFactory;
-import org.apache.batik.bridge.UserAgentAdapter;
-
-// Java
import java.awt.geom.AffineTransform;
-import java.awt.geom.Dimension2D;
-import java.awt.Dimension;
-// Commons-Logging
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.apache.fop.apps.FOUserAgent;
/**
- * The SVG user agent.
- * This is an implementation of the batik svg user agent
- * for handling errors and getting user agent values.
+ * The SVG user agent. This is an implementation of the Batik SVG user agent.
*/
-public class SVGUserAgent extends UserAgentAdapter {
- private AffineTransform currentTransform = null;
- private float pixelUnitToMillimeter = 0.0f;
+public class SVGUserAgent extends SimpleSVGUserAgent {
+
+ private SVGEventProducer eventProducer;
+ private Exception lastException;
/**
- * logging instance
+ * Creates a new SVGUserAgent.
+ * @param foUserAgent the FO user agent to associate with this SVG user agent
+ * @param at the current transform
*/
- private Log logger = LogFactory.getLog(SVGUserAgent.class);
+ public SVGUserAgent(FOUserAgent foUserAgent, AffineTransform at) {
+ super(foUserAgent.getSourcePixelUnitToMillimeter(), at);
+ this.eventProducer = SVGEventProducer.Provider.get(foUserAgent.getEventBroadcaster());
+ }
/**
* Creates a new SVGUserAgent.
- * @param pixelUnitToMM the pixel to millimeter conversion factor
- * currently in effect
- * @param at the current transform
+ * @param foUserAgent the FO user agent to associate with this SVG user agent
*/
- public SVGUserAgent(float pixelUnitToMM, AffineTransform at) {
- pixelUnitToMillimeter = pixelUnitToMM;
- currentTransform = at;
+ public SVGUserAgent(FOUserAgent foUserAgent) {
+ this(foUserAgent, new AffineTransform());
}
-
+
/**
- * Returns the logger associated with this user agent.
- * @return Logger the logger
+ * Returns the last exception sent to the {@link #displayError(Exception)} method.
+ * @return the last exception or null if no exception occurred
*/
- protected final Log getLogger() {
- return logger;
+ public Exception getLastException() {
+ return this.lastException;
}
/**
@@ -69,7 +62,7 @@ public class SVGUserAgent extends UserAgentAdapter {
* @param message the message to display
*/
public void displayError(String message) {
- logger.error(message);
+ this.eventProducer.error(this, message, null);
}
/**
@@ -77,7 +70,8 @@ public class SVGUserAgent extends UserAgentAdapter {
* @param ex the exception to display
*/
public void displayError(Exception ex) {
- logger.error("SVG Error" + ex.getMessage(), ex);
+ this.lastException = ex;
+ this.eventProducer.error(this, ex.getLocalizedMessage(), ex);
}
/**
@@ -86,7 +80,7 @@ public class SVGUserAgent extends UserAgentAdapter {
* @param message the message to display
*/
public void displayMessage(String message) {
- logger.info(message);
+ this.eventProducer.info(this, message);
}
/**
@@ -94,78 +88,7 @@ public class SVGUserAgent extends UserAgentAdapter {
* @param message the message to display
*/
public void showAlert(String message) {
- logger.warn(message);
- }
-
- /**
- * Returns a customized the pixel to mm factor.
- * @return the pixel unit to millimeter conversion factor
- */
- public float getPixelUnitToMillimeter() {
- return pixelUnitToMillimeter;
+ this.eventProducer.alert(this, message);
}
- /**
- * Returns the language settings.
- * @return the languages supported
- */
- public String getLanguages() {
- return "en"; // userLanguages;
- }
-
- /**
- * Returns the media type for this rendering.
- * @return the media for fo documents is "print"
- */
- public String getMedia() {
- return "print";
- }
-
- /**
- * Returns the user stylesheet uri.
- * @return null if no user style sheet was specified.
- */
- public String getUserStyleSheetURI() {
- return null; // userStyleSheetURI;
- }
-
- /**
- * Returns the class name of the XML parser.
- * @return the XML parser class name
- */
- public String getXMLParserClassName() {
- try {
- SAXParserFactory factory = SAXParserFactory.newInstance();
- return factory.newSAXParser().getXMLReader().getClass().getName();
- } catch (Exception e) {
- return null;
- }
- }
-
- /**
- * Is the XML parser validating.
- * @return true if the xml parser is validating
- */
- public boolean isXMLParserValidating() {
- return false;
- }
-
- /**
- * Get the transform of the svg document.
- * @return the transform
- */
- public AffineTransform getTransform() {
- return currentTransform;
- }
-
- /**
- * Get the default viewport size for an svg document.
- * This returns a default value of 100x100.
- * @return the default viewport size
- */
- public Dimension2D getViewportSize() {
- return new Dimension(100, 100);
- }
-
-}
-
+}
\ No newline at end of file
diff --git a/src/java/org/apache/fop/svg/SimpleSVGUserAgent.java b/src/java/org/apache/fop/svg/SimpleSVGUserAgent.java
new file mode 100644
index 000000000..4df1af34e
--- /dev/null
+++ b/src/java/org/apache/fop/svg/SimpleSVGUserAgent.java
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.svg;
+
+import java.awt.Dimension;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Dimension2D;
+
+import javax.xml.parsers.SAXParserFactory;
+
+import org.apache.batik.bridge.UserAgentAdapter;
+
+/**
+ * A simple SVG user agent.
+ * This is an implementation of the Batik SVG user agent. It ignores any message output sent
+ * by Batik.
+ */
+public class SimpleSVGUserAgent extends UserAgentAdapter {
+
+ private AffineTransform currentTransform = null;
+ private float pixelUnitToMillimeter = 0.0f;
+
+ /**
+ * Creates a new user agent.
+ * @param pixelUnitToMM the pixel to millimeter conversion factor currently in effect
+ * @param at the current transform
+ */
+ public SimpleSVGUserAgent(float pixelUnitToMM, AffineTransform at) {
+ pixelUnitToMillimeter = pixelUnitToMM;
+ currentTransform = at;
+ }
+
+ /**
+ * Returns a customized the pixel to mm factor.
+ * @return the pixel unit to millimeter conversion factor
+ */
+ public float getPixelUnitToMillimeter() {
+ return pixelUnitToMillimeter;
+ }
+
+ /**
+ * Returns the language settings.
+ * @return the languages supported
+ */
+ public String getLanguages() {
+ return "en"; // userLanguages;
+ }
+
+ /**
+ * Returns the media type for this rendering.
+ * @return the media for FO documents is "print"
+ */
+ public String getMedia() {
+ return "print";
+ }
+
+ /**
+ * Returns the user stylesheet URI.
+ * @return null if no user style sheet was specified.
+ */
+ public String getUserStyleSheetURI() {
+ return null; // userStyleSheetURI;
+ }
+
+ /**
+ * Returns the class name of the XML parser.
+ * @return the XML parser class name
+ */
+ public String getXMLParserClassName() {
+ try {
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ return factory.newSAXParser().getXMLReader().getClass().getName();
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ /**
+ * Is the XML parser validating.
+ * @return true if the XML parser is validating
+ */
+ public boolean isXMLParserValidating() {
+ return false;
+ }
+
+ /**
+ * Get the transform of the SVG document.
+ * @return the transform
+ */
+ public AffineTransform getTransform() {
+ return currentTransform;
+ }
+
+ /** {@inheritDoc} */
+ public void setTransform(AffineTransform at) {
+ this.currentTransform = at;
+ }
+
+ /**
+ * Get the default viewport size for an SVG document.
+ * This returns a default value of 100x100.
+ * @return the default viewport size
+ */
+ public Dimension2D getViewportSize() {
+ return new Dimension(100, 100);
+ }
+
+}
+
diff --git a/src/java/org/apache/fop/util/QName.java b/src/java/org/apache/fop/util/QName.java
index 390e29dd9..132f5b4dc 100644
--- a/src/java/org/apache/fop/util/QName.java
+++ b/src/java/org/apache/fop/util/QName.java
@@ -19,23 +19,17 @@
package org.apache.fop.util;
-import java.io.Serializable;
-
/**
* Represents a qualified name of an XML element or an XML attribute.
*
* Note: This class allows to carry a namespace prefix but it is not used in the equals() and
* hashCode() methods.
+ * @deprecated Use the XML Graphics Commons variant instead!
*/
-public class QName implements Serializable {
+public class QName extends org.apache.xmlgraphics.util.QName {
private static final long serialVersionUID = -5225376740044770690L;
- private String namespaceURI;
- private String localName;
- private String prefix;
- private int hashCode;
-
/**
* Main constructor.
* @param namespaceURI the namespace URI
@@ -43,16 +37,7 @@ public class QName implements Serializable {
* @param localName the local name
*/
public QName(String namespaceURI, String prefix, String localName) {
- if (localName == null) {
- throw new NullPointerException("Parameter localName must not be null");
- }
- if (localName.length() == 0) {
- throw new IllegalArgumentException("Parameter localName must not be empty");
- }
- this.namespaceURI = namespaceURI;
- this.prefix = prefix;
- this.localName = localName;
- this.hashCode = toHashString().hashCode();
+ super(namespaceURI, prefix, localName);
}
/**
@@ -61,78 +46,7 @@ public class QName implements Serializable {
* @param qName the qualified name
*/
public QName(String namespaceURI, String qName) {
- if (qName == null) {
- throw new NullPointerException("Parameter localName must not be null");
- }
- if (qName.length() == 0) {
- throw new IllegalArgumentException("Parameter localName must not be empty");
- }
- this.namespaceURI = namespaceURI;
- int p = qName.indexOf(':');
- if (p > 0) {
- this.prefix = qName.substring(0, p);
- this.localName = qName.substring(p + 1);
- } else {
- this.prefix = null;
- this.localName = qName;
- }
- this.hashCode = toHashString().hashCode();
+ super(namespaceURI, qName);
}
- /** @return the namespace URI */
- public String getNamespaceURI() {
- return this.namespaceURI;
- }
-
- /** @return the namespace prefix */
- public String getPrefix() {
- return this.prefix;
- }
-
- /** @return the local name */
- public String getLocalName() {
- return this.localName;
- }
-
- /** @return the fully qualified name */
- public String getQName() {
- return getPrefix() != null ? getPrefix() + ':' + getLocalName() : getLocalName();
- }
-
- /** {@inheritDoc} */
- public int hashCode() {
- return this.hashCode;
- }
-
- /** {@inheritDoc} */
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- } else if (obj == this) {
- return true;
- } else {
- if (obj instanceof QName) {
- QName other = (QName)obj;
- if ((getNamespaceURI() == null && other.getNamespaceURI() == null)
- || getNamespaceURI().equals(other.getNamespaceURI())) {
- return getLocalName().equals(other.getLocalName());
- }
- }
- }
- return false;
- }
-
- /** {@inheritDoc} */
- public String toString() {
- return prefix != null
- ? (prefix + ":" + localName)
- : toHashString();
- }
-
- private String toHashString() {
- return (namespaceURI != null
- ? ("{" + namespaceURI + "}" + localName)
- : localName);
- }
-
}
diff --git a/src/java/org/apache/fop/util/XMLResourceBundle.java b/src/java/org/apache/fop/util/XMLResourceBundle.java
new file mode 100644
index 000000000..1b320816b
--- /dev/null
+++ b/src/java/org/apache/fop/util/XMLResourceBundle.java
@@ -0,0 +1,398 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Locale;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.Properties;
+import java.util.ResourceBundle;
+import java.util.Stack;
+
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.sax.SAXResult;
+import javax.xml.transform.sax.SAXTransformerFactory;
+import javax.xml.transform.stream.StreamSource;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+import org.apache.xmlgraphics.util.QName;
+
+/**
+ * This class is a ResourceBundle that loads its contents from XML files instead of properties
+ * files (like PropertiesResourceBundle).
+ *
+ * The XML format for this resource bundle implementation is the following
+ * (the same as Apache Cocoon's XMLResourceBundle):
+ *
+ */
+public class XMLResourceBundle extends ResourceBundle {
+
+ //Note: Some code here has been copied and adapted from Apache Harmony!
+
+ private Properties resources = new Properties();
+
+ private Locale locale;
+
+ private static SAXTransformerFactory tFactory
+ = (SAXTransformerFactory)SAXTransformerFactory.newInstance();
+
+ /**
+ * Creates a resource bundle from an InputStream.
+ * @param in the stream to read from
+ * @throws IOException if an I/O error occurs
+ */
+ public XMLResourceBundle(InputStream in) throws IOException {
+ try {
+ Transformer transformer = tFactory.newTransformer();
+ StreamSource src = new StreamSource(in);
+ SAXResult res = new SAXResult(new CatalogueHandler());
+ transformer.transform(src, res);
+ } catch (TransformerException e) {
+ throw new IOException("Error while parsing XML resource bundle: " + e.getMessage());
+ }
+ }
+
+ /**
+ * Gets a resource bundle using the specified base name, default locale, and class loader.
+ * @param baseName the base name of the resource bundle, a fully qualified class name
+ * @param loader the class loader from which to load the resource bundle
+ * @return a resource bundle for the given base name and the default locale
+ * @throws MissingResourceException if no resource bundle for the specified base name can be
+ * found
+ * @see java.util.ResourceBundle#getBundle(String)
+ */
+ public static ResourceBundle getXMLBundle(String baseName, ClassLoader loader)
+ throws MissingResourceException {
+ return getXMLBundle(baseName, Locale.getDefault(), loader);
+ }
+
+ /**
+ * Gets a resource bundle using the specified base name, locale, and class loader.
+ * @param baseName the base name of the resource bundle, a fully qualified class name
+ * @param locale the locale for which a resource bundle is desired
+ * @param loader the class loader from which to load the resource bundle
+ * @return a resource bundle for the given base name and locale
+ * @throws MissingResourceException if no resource bundle for the specified base name can be
+ * found
+ * @see java.util.ResourceBundle#getBundle(String, Locale, ClassLoader)
+ */
+ public static ResourceBundle getXMLBundle(String baseName, Locale locale, ClassLoader loader)
+ throws MissingResourceException {
+ if (loader == null) {
+ throw new NullPointerException("loader must not be null");
+ }
+ if (baseName == null) {
+ throw new NullPointerException("baseName must not be null");
+ }
+
+ ResourceBundle bundle;
+ if (!locale.equals(Locale.getDefault())) {
+ bundle = handleGetXMLBundle(baseName, "_" + locale, false, loader);
+ if (bundle != null) {
+ return bundle;
+ }
+ }
+ bundle = handleGetXMLBundle(baseName, "_" + Locale.getDefault(), true, loader);
+ if (bundle != null) {
+ return bundle;
+ }
+ throw new MissingResourceException(
+ baseName + " (" + locale + ")", baseName + '_' + locale, null);
+ }
+
+ static class MissingBundle extends ResourceBundle {
+ public Enumeration getKeys() {
+ return null;
+ }
+
+ public Object handleGetObject(String name) {
+ return null;
+ }
+ }
+
+ private static final ResourceBundle MISSING = new MissingBundle();
+ private static final ResourceBundle MISSINGBASE = new MissingBundle();
+
+ private static Map cache = new java.util.WeakHashMap();
+ //
*
In order to embed a PreviewPanel in your own app, create your own renderer,
* and your own agent. In order to support reloads, you may also implement your
* own Renderable extension or the default InputHandler. Setting the Renderable
@@ -109,7 +109,7 @@ public class PreviewPanel extends JPanel {
/** The FOUserAgent associated with this panel - often shared with PreviewDialog */
protected FOUserAgent foUserAgent;
/**
- * Renderable instance that can be used to reload and re-render a document after
+ * Renderable instance that can be used to reload and re-render a document after
* modifications.
*/
protected Renderable renderable;
@@ -142,7 +142,7 @@ public class PreviewPanel extends JPanel {
*/
private ViewportScroller scroller;
-
+
/**
* Creates a new PreviewPanel instance.
* @param foUserAgent the user agent
@@ -170,7 +170,7 @@ public class PreviewPanel extends JPanel {
previewArea.setMinimumSize(new Dimension(50, 50));
add(previewArea);
}
-
+
/**
* @return the currently visible page
*/
@@ -242,12 +242,12 @@ public class PreviewPanel extends JPanel {
private int startPosX = 0;
/** Starting position of a mouse drag - Y co-ordinate */
private int startPosY = 0;
-
+
ViewportScroller(JViewport vp) {
viewport = vp;
}
- // ***** MouseMotionListener *****
+ // ***** MouseMotionListener *****
public synchronized void mouseDragged(MouseEvent e) {
if (viewport == null) {
@@ -261,7 +261,7 @@ public class PreviewPanel extends JPanel {
int viewHeight = viewport.getExtentSize().height;
int imageWidth = viewport.getViewSize().width;
int imageHeight = viewport.getViewSize().height;
-
+
Point viewPoint = viewport.getViewPosition();
int viewX = Math.max(0, Math.min(imageWidth - viewWidth, viewPoint.x - xmove));
int viewY = Math.max(0, Math.min(imageHeight - viewHeight, viewPoint.y - ymove));
diff --git a/src/java/org/apache/fop/render/awt/viewer/Renderable.java b/src/java/org/apache/fop/render/awt/viewer/Renderable.java
index 5324ff8d7..c40272220 100644
--- a/src/java/org/apache/fop/render/awt/viewer/Renderable.java
+++ b/src/java/org/apache/fop/render/awt/viewer/Renderable.java
@@ -35,5 +35,5 @@ public interface Renderable {
*/
void renderTo(FOUserAgent userAgent, String outputFormat)
throws FOPException;
-
+
}
diff --git a/src/java/org/apache/fop/render/awt/viewer/StatusListener.java b/src/java/org/apache/fop/render/awt/viewer/StatusListener.java
index 6a7cf7d9b..d145d7718 100644
--- a/src/java/org/apache/fop/render/awt/viewer/StatusListener.java
+++ b/src/java/org/apache/fop/render/awt/viewer/StatusListener.java
@@ -26,9 +26,9 @@ public interface StatusListener {
/** Called when a page has been renderered. */
void notifyPageRendered();
-
+
/** Called when the renderer has stopped. */
void notifyRendererStopped();
-
+
}
diff --git a/src/java/org/apache/fop/render/awt/viewer/Translator.java b/src/java/org/apache/fop/render/awt/viewer/Translator.java
index 6ae76be5b..df07a987f 100644
--- a/src/java/org/apache/fop/render/awt/viewer/Translator.java
+++ b/src/java/org/apache/fop/render/awt/viewer/Translator.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
*/
/* $Id$ */
-
+
package org.apache.fop.render.awt.viewer;
//Java
@@ -29,7 +29,7 @@ import java.util.Locale;
* Stanislav.Gorkhover@jCatalog.com
*/
public class Translator {
-
+
private ResourceBundle bundle;
private static String bundleBaseName = "org/apache/fop/render/awt/viewer/resources/Viewer";
diff --git a/src/java/org/apache/fop/render/bitmap/BitmapRendererEventProducer.java b/src/java/org/apache/fop/render/bitmap/BitmapRendererEventProducer.java
index 7b26d0771..6688e40ea 100644
--- a/src/java/org/apache/fop/render/bitmap/BitmapRendererEventProducer.java
+++ b/src/java/org/apache/fop/render/bitmap/BitmapRendererEventProducer.java
@@ -33,7 +33,7 @@ public interface BitmapRendererEventProducer extends EventProducer {
/** Provider class for the event producer. */
class Provider {
-
+
/**
* Returns an event producer.
* @param broadcaster the event broadcaster to use
@@ -52,23 +52,23 @@ public interface BitmapRendererEventProducer extends EventProducer {
public EventModel createEventModel() {
return loadModel(getClass(), "event-model.xml");
}
-
+
}
-
+
/**
* No filename information available. Stopping early after the first page.
* @param source the event source
* @event.severity WARN
*/
void stoppingAfterFirstPageNoFilename(Object source);
-
+
/**
* Image writer does not support multiple images. Only the first page has been produced.
* @param source the event source
* @event.severity WARN
*/
void stoppingAfterFirstPageNoMultiWriter(Object source);
-
+
/**
* No ImageWriter found.
* @param source the event source
diff --git a/src/java/org/apache/fop/render/bitmap/MultiFileRenderingUtil.java b/src/java/org/apache/fop/render/bitmap/MultiFileRenderingUtil.java
index 7c1c4ee31..1e3770542 100644
--- a/src/java/org/apache/fop/render/bitmap/MultiFileRenderingUtil.java
+++ b/src/java/org/apache/fop/render/bitmap/MultiFileRenderingUtil.java
@@ -7,7 +7,7 @@ import java.io.IOException;
import java.io.OutputStream;
/**
- * This utility class helps renderers who generate one file per page,
+ * This utility class helps renderers who generate one file per page,
* like the PNG renderer.
*/
public class MultiFileRenderingUtil {
@@ -16,10 +16,10 @@ public class MultiFileRenderingUtil {
private String filePrefix;
private String fileExtension;
-
+
/** The output directory where images are to be written */
private File outputDir;
-
+
/**
* Creates a new instance.
*
@@ -60,7 +60,7 @@ public class MultiFileRenderingUtil {
filePrefix = s.substring(0, i);
}
}
-
+
public OutputStream createOutputStream(int pageNumber) throws IOException {
if (filePrefix == null) {
return null;
@@ -71,5 +71,5 @@ public class MultiFileRenderingUtil {
return os;
}
}
-
+
}
diff --git a/src/java/org/apache/fop/render/bitmap/PNGRenderer.java b/src/java/org/apache/fop/render/bitmap/PNGRenderer.java
index 8613ef7b8..3733bf2f2 100644
--- a/src/java/org/apache/fop/render/bitmap/PNGRenderer.java
+++ b/src/java/org/apache/fop/render/bitmap/PNGRenderer.java
@@ -48,7 +48,7 @@ public class PNGRenderer extends Java2DRenderer {
/** The OutputStream for the first Image */
private OutputStream firstOutputStream;
-
+
/** Helper class for generating multiple files */
private MultiFileRenderingUtil multiFileUtil;
@@ -60,7 +60,7 @@ public class PNGRenderer extends Java2DRenderer {
/** {@inheritDoc} */
public void startRenderer(OutputStream outputStream) throws IOException {
log.info("rendering areas to PNG");
- multiFileUtil = new MultiFileRenderingUtil(PNG_FILE_EXTENSION,
+ multiFileUtil = new MultiFileRenderingUtil(PNG_FILE_EXTENSION,
getUserAgent().getOutputFile());
this.firstOutputStream = outputStream;
}
@@ -84,7 +84,7 @@ public class PNGRenderer extends Java2DRenderer {
// Do the rendering: get the image for this page
PageViewport pv = (PageViewport)pageViewportList.get(i);
RenderedImage image = (RenderedImage)getPageImage(pv);
-
+
// Encode this image
if (log.isDebugEnabled()) {
log.debug("Encoding page " + (i + 1));
@@ -102,7 +102,7 @@ public class PNGRenderer extends Java2DRenderer {
private void writeImage(OutputStream os, RenderedImage image) throws IOException {
ImageWriterParams params = new ImageWriterParams();
params.setResolution(Math.round(userAgent.getTargetResolution()));
-
+
// Encode PNG image
ImageWriter writer = ImageWriterRegistry.getInstance().getWriterFor(getMimeType());
if (writer == null) {
diff --git a/src/java/org/apache/fop/render/bitmap/PNGRendererMaker.java b/src/java/org/apache/fop/render/bitmap/PNGRendererMaker.java
index 0f4c4c4fb..7d321791a 100644
--- a/src/java/org/apache/fop/render/bitmap/PNGRendererMaker.java
+++ b/src/java/org/apache/fop/render/bitmap/PNGRendererMaker.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -32,8 +32,8 @@ import org.apache.fop.render.java2d.Java2DRendererConfigurator;
public class PNGRendererMaker extends AbstractRendererMaker {
private static final String[] MIMES = new String[] {MimeConstants.MIME_PNG};
-
-
+
+
/** {@inheritDoc} */
public Renderer makeRenderer(FOUserAgent ua) {
return new PNGRenderer();
diff --git a/src/java/org/apache/fop/render/bitmap/PNGRenderer_onthefly.java b/src/java/org/apache/fop/render/bitmap/PNGRenderer_onthefly.java
index 36dd093b2..a6a6e8dfe 100644
--- a/src/java/org/apache/fop/render/bitmap/PNGRenderer_onthefly.java
+++ b/src/java/org/apache/fop/render/bitmap/PNGRenderer_onthefly.java
@@ -96,7 +96,7 @@ public class PNGRenderer_onthefly extends Java2DRenderer {
fileSyntax = s.substring(0, i);
}
- /**
+ /**
* {@inheritDoc}
*/
public void renderPage(PageViewport pageViewport) throws IOException {
diff --git a/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java b/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java
index 9291427d2..fea831a9b 100644
--- a/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java
+++ b/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java
@@ -80,13 +80,13 @@ public class TIFFRenderer extends Java2DRenderer {
//private static final String COMPRESSION_ZLIB = "ZLib";
public static final String COMPRESSION_CCITT_T6 = "CCITT T.6"; //CCITT Group 4
public static final String COMPRESSION_CCITT_T4 = "CCITT T.4"; //CCITT Group 3
-
+
/** ImageWriter parameters */
private ImageWriterParams writerParams;
-
+
/** Image Type as parameter for the BufferedImage constructor (see BufferedImage.TYPE_*) */
private int bufferedImageType = BufferedImage.TYPE_INT_ARGB;
-
+
private OutputStream outputStream;
/** {@inheritDoc} */
@@ -160,7 +160,7 @@ public class TIFFRenderer extends Java2DRenderer {
clearViewportList();
log.debug("TIFF encoding done.");
}
-
+
/** {@inheritDoc} */
protected BufferedImage getBufferedImage(int bitmapWidth, int bitmapHeight) {
return new BufferedImage(bitmapWidth, bitmapHeight, bufferedImageType);
@@ -210,7 +210,7 @@ public class TIFFRenderer extends Java2DRenderer {
//Decorate the image with a packed sample model for encoding by the codec
SinglePixelPackedSampleModel sppsm;
sppsm = (SinglePixelPackedSampleModel)pageImage.getSampleModel();
-
+
int bands = sppsm.getNumBands();
int[] off = new int[bands];
int w = pageImage.getWidth();
@@ -220,7 +220,7 @@ public class TIFFRenderer extends Java2DRenderer {
}
SampleModel sm = new PixelInterleavedSampleModel(
DataBuffer.TYPE_BYTE, w, h, bands, w * bands, off);
-
+
RenderedImage rimg = new FormatRed(GraphicsUtil.wrap(pageImage), sm);
return rimg;
}
diff --git a/src/java/org/apache/fop/render/bitmap/TIFFRendererConfigurator.java b/src/java/org/apache/fop/render/bitmap/TIFFRendererConfigurator.java
index 71ad0b286..ff5e22ceb 100644
--- a/src/java/org/apache/fop/render/bitmap/TIFFRendererConfigurator.java
+++ b/src/java/org/apache/fop/render/bitmap/TIFFRendererConfigurator.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -28,7 +28,7 @@ import org.apache.fop.render.PrintRendererConfigurator;
import org.apache.fop.render.Renderer;
/**
- * TIFF Renderer configurator
+ * TIFF Renderer configurator
*/
public class TIFFRendererConfigurator extends PrintRendererConfigurator {
@@ -47,7 +47,7 @@ public class TIFFRendererConfigurator extends PrintRendererConfigurator {
* @throws FOPException fop exception
* {@inheritDoc}
*/
- public void configure(Renderer renderer) throws FOPException {
+ public void configure(Renderer renderer) throws FOPException {
Configuration cfg = super.getRendererConfig(renderer);
if (cfg != null) {
TIFFRenderer tiffRenderer = (TIFFRenderer)renderer;
diff --git a/src/java/org/apache/fop/render/bitmap/TIFFRendererMaker.java b/src/java/org/apache/fop/render/bitmap/TIFFRendererMaker.java
index 69463d127..e3c567995 100644
--- a/src/java/org/apache/fop/render/bitmap/TIFFRendererMaker.java
+++ b/src/java/org/apache/fop/render/bitmap/TIFFRendererMaker.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -31,7 +31,7 @@ import org.apache.fop.render.RendererConfigurator;
public class TIFFRendererMaker extends AbstractRendererMaker {
private static final String[] MIMES = new String[] {MimeConstants.MIME_TIFF};
-
+
/** {@inheritDoc} */
public Renderer makeRenderer(FOUserAgent userAgent) {
return new TIFFRenderer();
diff --git a/src/java/org/apache/fop/render/java2d/Base14FontCollection.java b/src/java/org/apache/fop/render/java2d/Base14FontCollection.java
index ca4a4bce3..29e80dc2f 100644
--- a/src/java/org/apache/fop/render/java2d/Base14FontCollection.java
+++ b/src/java/org/apache/fop/render/java2d/Base14FontCollection.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java b/src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java
index 3a773a2db..63b04da32 100644
--- a/src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java
+++ b/src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/java2d/FontMetricsMapper.java b/src/java/org/apache/fop/render/java2d/FontMetricsMapper.java
index ff246af2b..2f87b62ea 100644
--- a/src/java/org/apache/fop/render/java2d/FontMetricsMapper.java
+++ b/src/java/org/apache/fop/render/java2d/FontMetricsMapper.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -34,5 +34,5 @@ public interface FontMetricsMapper extends FontMetrics {
* @return font with the desired characteristics.
*/
java.awt.Font getFont(int size);
-
+
}
diff --git a/src/java/org/apache/fop/render/java2d/InstalledFontCollection.java b/src/java/org/apache/fop/render/java2d/InstalledFontCollection.java
index 4eac922e8..fe4e04766 100644
--- a/src/java/org/apache/fop/render/java2d/InstalledFontCollection.java
+++ b/src/java/org/apache/fop/render/java2d/InstalledFontCollection.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -61,7 +61,7 @@ public class InstalledFontCollection implements FontCollection {
/**
* Main constructor
- *
+ *
* @param graphics2D a graphics 2D
*/
public InstalledFontCollection(Graphics2D graphics2D) {
diff --git a/src/java/org/apache/fop/render/java2d/Java2DFontMetrics.java b/src/java/org/apache/fop/render/java2d/Java2DFontMetrics.java
index 64e329c62..10af3aa86 100644
--- a/src/java/org/apache/fop/render/java2d/Java2DFontMetrics.java
+++ b/src/java/org/apache/fop/render/java2d/Java2DFontMetrics.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
*/
/* $Id$ */
-
+
package org.apache.fop.render.java2d;
// Java
@@ -63,17 +63,17 @@ public class Java2DFontMetrics {
* The typical height of a small cap latter (often derived from "x", value in mpt)
*/
private int xHeight = 0;
-
+
/**
* The highest point of the font above the baseline (usually derived from "d", value in mpt)
*/
private int ascender = 0;
-
+
/**
* The lowest point of the font under the baseline (usually derived from "p", value in mpt)
*/
private int descender = 0;
-
+
/**
* Buffered font.
* f1 is bufferd for metric measurements during layout.
@@ -103,7 +103,7 @@ public class Java2DFontMetrics {
/** A LineMetrics to access high-resolution metrics information. */
private LineMetrics lineMetrics;
-
+
/**
* Temp graphics object needed to get the font metrics
*/
@@ -130,7 +130,7 @@ public class Java2DFontMetrics {
setFont(family, style, size);
return Math.round(lineMetrics.getAscent() * FONT_FACTOR);
}
-
+
/**
* Determines the font ascent of the Font described by this
* FontMetrics object
@@ -159,7 +159,7 @@ public class Java2DFontMetrics {
* Rectangle FontMetrics.getStringBounds(..) method can be called.
* The y value of the rectangle is the offset from the origin
* (baseline) apparently needed by the sample test program
- *
+ *
* xxxxx@xxxxx 2001-05-15
*/
/* I don't think this is right.
@@ -231,7 +231,7 @@ public class Java2DFontMetrics {
Rectangle2D rect = fmt.getStringBounds(ch, 0, 1, this.graphics);
return (int)Math.round(rect.getWidth() * 1000);
}
-
+
/**
* Return widths (in 1/1000ths of point size) of all
* characters
@@ -265,7 +265,7 @@ public class Java2DFontMetrics {
atts.put(TextAttribute.SIZE, new Float(size)); //size in pt
return new Font(atts);
}
-
+
/**
* Checks whether the font for which values are
* requested is the one used immediately before or
@@ -301,17 +301,17 @@ public class Java2DFontMetrics {
TextLayout layout = new TextLayout("x", f1, graphics.getFontRenderContext());
Rectangle2D rect = layout.getBounds();
xHeight = (int)Math.round(-rect.getY() * 1000);
-
+
//PostScript-compatible ascent
layout = new TextLayout("d", f1, graphics.getFontRenderContext());
rect = layout.getBounds();
ascender = (int)Math.round(-rect.getY() * 1000);
-
+
//PostScript-compatible descent
layout = new TextLayout("p", f1, graphics.getFontRenderContext());
rect = layout.getBounds();
descender = (int)Math.round((rect.getY() + rect.getHeight()) * -1000);
-
+
//Alternative way to get metrics but the ascender is again wrong for our purposes
lineMetrics = f1.getLineMetrics("", graphics.getFontRenderContext());
}
diff --git a/src/java/org/apache/fop/render/java2d/Java2DGraphics2DAdapter.java b/src/java/org/apache/fop/render/java2d/Java2DGraphics2DAdapter.java
index b29378a96..8fe93d051 100644
--- a/src/java/org/apache/fop/render/java2d/Java2DGraphics2DAdapter.java
+++ b/src/java/org/apache/fop/render/java2d/Java2DGraphics2DAdapter.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
*/
/* $Id$ */
-
+
package org.apache.fop.render.java2d;
import java.awt.Color;
@@ -40,12 +40,12 @@ public class Java2DGraphics2DAdapter extends AbstractGraphics2DAdapter {
public void paintImage(Graphics2DImagePainter painter,
RendererContext context,
int x, int y, int width, int height) throws IOException {
-
+
float fwidth = width / 1000f;
float fheight = height / 1000f;
float fx = x / 1000f;
float fy = y / 1000f;
-
+
// get the 'width' and 'height' attributes of the SVG document
Dimension dim = painter.getImageSize();
float imw = (float)dim.getWidth() / 1000f;
@@ -56,12 +56,12 @@ public class Java2DGraphics2DAdapter extends AbstractGraphics2DAdapter {
Java2DRenderer renderer = (Java2DRenderer)context.getRenderer();
Java2DGraphicsState state = renderer.state;
-
+
//Create copy and paint on that
Graphics2D g2d = (Graphics2D)state.getGraph().create();
g2d.setColor(Color.black);
g2d.setBackground(Color.black);
-
+
//TODO Clip to the image area.
// transform so that the coordinates (0,0) is from the top left
diff --git a/src/java/org/apache/fop/render/java2d/Java2DGraphicsState.java b/src/java/org/apache/fop/render/java2d/Java2DGraphicsState.java
index 31da90c95..1c5fa8427 100644
--- a/src/java/org/apache/fop/render/java2d/Java2DGraphicsState.java
+++ b/src/java/org/apache/fop/render/java2d/Java2DGraphicsState.java
@@ -73,14 +73,14 @@ public class Java2DGraphicsState {
* @param org the instance to copy
*/
public Java2DGraphicsState(Java2DGraphicsState org) {
- this.currentGraphics = (Graphics2D)org.currentGraphics.create();
+ this.currentGraphics = (Graphics2D)org.currentGraphics.create();
this.fontInfo = org.fontInfo;
this.initialTransform = org.initialTransform;
this.currentStroke = org.currentStroke;
this.currentStrokeStyle = org.currentStrokeStyle;
this.currentStrokeWidth = org.currentStrokeWidth;
}
-
+
/**
* @return the currently valid state
*/
@@ -92,7 +92,7 @@ public class Java2DGraphicsState {
public void dispose() {
this.currentGraphics.dispose();
this.currentGraphics = null;
-
+
}
/**
diff --git a/src/java/org/apache/fop/render/java2d/Java2DRendererConfigurator.java b/src/java/org/apache/fop/render/java2d/Java2DRendererConfigurator.java
index a18f71cc0..0709d4ea9 100644
--- a/src/java/org/apache/fop/render/java2d/Java2DRendererConfigurator.java
+++ b/src/java/org/apache/fop/render/java2d/Java2DRendererConfigurator.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/java2d/Java2DRendererContextConstants.java b/src/java/org/apache/fop/render/java2d/Java2DRendererContextConstants.java
index 0fd87f910..0157b7411 100644
--- a/src/java/org/apache/fop/render/java2d/Java2DRendererContextConstants.java
+++ b/src/java/org/apache/fop/render/java2d/Java2DRendererContextConstants.java
@@ -29,5 +29,5 @@ public interface Java2DRendererContextConstants extends
/** The current Java2DGraphicsState. */
String JAVA2D_STATE = "state";
-
+
}
diff --git a/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java b/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java
index 64ac823fc..12b269a44 100644
--- a/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java
+++ b/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -94,7 +94,7 @@ public class Java2DSVGHandler extends AbstractGenericSVGHandler
+ "currentYPosition = " + currentYPosition + "}";
}
}
-
+
/** {@inheritDoc} */
protected void renderSVGDocument(RendererContext context,
Document doc) {
@@ -105,12 +105,12 @@ public class Java2DSVGHandler extends AbstractGenericSVGHandler
int x = info.currentXPosition;
int y = info.currentYPosition;
-
+
SVGUserAgent ua = new SVGUserAgent(context.getUserAgent(), new AffineTransform());
-
+
GVTBuilder builder = new GVTBuilder();
BridgeContext ctx = new BridgeContext(ua);
-
+
GraphicsNode root;
try {
root = builder.build(ctx, doc);
@@ -120,20 +120,20 @@ public class Java2DSVGHandler extends AbstractGenericSVGHandler
eventProducer.svgNotBuilt(this, e, getDocumentURI(doc));
return;
}
-
+
// If no viewbox is defined in the svg file, a viewbox of 100x100 is
// assumed, as defined in SVGUserAgent.getViewportSize()
float iw = (float) ctx.getDocumentSize().getWidth() * 1000f;
float ih = (float) ctx.getDocumentSize().getHeight() * 1000f;
-
+
float w = (float) info.width;
float h = (float) info.height;
AffineTransform origTransform = info.state.getGraph().getTransform();
-
+
// correct integer roundoff
info.state.getGraph().translate(x / 1000f, y / 1000f);
-
+
//SVGSVGElement svg = ((SVGDocument) doc).getRootElement();
// Aspect ratio preserved by layout engine, not here
AffineTransform at = AffineTransform.getScaleInstance(w / iw, h / ih);
@@ -148,10 +148,10 @@ public class Java2DSVGHandler extends AbstractGenericSVGHandler
context.getUserAgent().getEventBroadcaster());
eventProducer.svgRenderingError(this, e, getDocumentURI(doc));
}
-
+
info.state.getGraph().setTransform(origTransform);
}
-
+
/** {@inheritDoc} */
public boolean supportsRenderer(Renderer renderer) {
return (renderer instanceof Java2DRenderer);
diff --git a/src/java/org/apache/fop/render/java2d/SystemFontMetricsMapper.java b/src/java/org/apache/fop/render/java2d/SystemFontMetricsMapper.java
index 19e9a4d1d..afcf088cc 100644
--- a/src/java/org/apache/fop/render/java2d/SystemFontMetricsMapper.java
+++ b/src/java/org/apache/fop/render/java2d/SystemFontMetricsMapper.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
*/
/* $Id$ */
-
+
package org.apache.fop.render.java2d;
// Java
diff --git a/src/java/org/apache/fop/render/pcl/DefaultMonochromeBitmapConverter.java b/src/java/org/apache/fop/render/pcl/DefaultMonochromeBitmapConverter.java
index 10fcfde3d..418810401 100644
--- a/src/java/org/apache/fop/render/pcl/DefaultMonochromeBitmapConverter.java
+++ b/src/java/org/apache/fop/render/pcl/DefaultMonochromeBitmapConverter.java
@@ -36,10 +36,10 @@ public class DefaultMonochromeBitmapConverter implements
public void setHint(String name, String value) {
//ignore, not supported
}
-
+
/** {@inheritDoc} */
public RenderedImage convertToMonochrome(BufferedImage img) {
- BufferedImage buf = new BufferedImage(img.getWidth(), img.getHeight(),
+ BufferedImage buf = new BufferedImage(img.getWidth(), img.getHeight(),
BufferedImage.TYPE_BYTE_BINARY);
RenderingHints hints = new RenderingHints(null);
//This hint doesn't seem to make a difference :-(
diff --git a/src/java/org/apache/fop/render/pcl/JAIMonochromeBitmapConverter.java b/src/java/org/apache/fop/render/pcl/JAIMonochromeBitmapConverter.java
index 89e54b917..e9611edac 100644
--- a/src/java/org/apache/fop/render/pcl/JAIMonochromeBitmapConverter.java
+++ b/src/java/org/apache/fop/render/pcl/JAIMonochromeBitmapConverter.java
@@ -46,20 +46,20 @@ public class JAIMonochromeBitmapConverter implements
MonochromeBitmapConverter {
private boolean isErrorDiffusion = false;
-
+
/** {@inheritDoc} */
public void setHint(String name, String value) {
if ("quality".equalsIgnoreCase(name)) {
isErrorDiffusion = "true".equalsIgnoreCase(value);
}
}
-
+
/** {@inheritDoc} */
public RenderedImage convertToMonochrome(BufferedImage img) {
if (img.getColorModel().getColorSpace().getNumComponents() != 1) {
throw new IllegalArgumentException("Source image must be a grayscale image!");
}
-
+
// Load the ParameterBlock for the dithering operation
// and set the operation name.
ParameterBlock pb = new ParameterBlock();
@@ -78,7 +78,7 @@ public class JAIMonochromeBitmapConverter implements
pb.add(colorMap);
pb.add(KernelJAI.DITHER_MASK_441);
}
-
+
//Create an image layout for a monochrome b/w image
ImageLayout layout = new ImageLayout();
byte[] map = new byte[] {(byte)0x00, (byte)0xff};
@@ -89,8 +89,8 @@ public class JAIMonochromeBitmapConverter implements
RenderingHints hints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, layout);
// Dither the image.
- PlanarImage dst = JAI.create(opName, pb, hints);
-
+ PlanarImage dst = JAI.create(opName, pb, hints);
+
//Convert it to a BufferedImage
return dst.getAsBufferedImage();
}
diff --git a/src/java/org/apache/fop/render/pcl/MonochromeBitmapConverter.java b/src/java/org/apache/fop/render/pcl/MonochromeBitmapConverter.java
index aae0b90ce..9a960f871 100644
--- a/src/java/org/apache/fop/render/pcl/MonochromeBitmapConverter.java
+++ b/src/java/org/apache/fop/render/pcl/MonochromeBitmapConverter.java
@@ -33,12 +33,12 @@ public interface MonochromeBitmapConverter {
* @param value the value
*/
void setHint(String name, String value);
-
+
/**
- * Converts a grayscale bitmap image to a monochrome (1-bit) b/w bitmap image.
+ * Converts a grayscale bitmap image to a monochrome (1-bit) b/w bitmap image.
* @param img the grayscale image
* @return the converted monochrome image
*/
RenderedImage convertToMonochrome(BufferedImage img);
-
+
}
diff --git a/src/java/org/apache/fop/render/pcl/PCLEventProducer.java b/src/java/org/apache/fop/render/pcl/PCLEventProducer.java
index 3e72de293..3e95bd4f9 100644
--- a/src/java/org/apache/fop/render/pcl/PCLEventProducer.java
+++ b/src/java/org/apache/fop/render/pcl/PCLEventProducer.java
@@ -31,7 +31,7 @@ public interface PCLEventProducer extends EventProducer {
/** Provider class for the event producer. */
class Provider {
-
+
/**
* Returns an event producer.
* @param broadcaster the event broadcaster to use
@@ -50,9 +50,9 @@ public interface PCLEventProducer extends EventProducer {
public EventModel createEventModel() {
return loadModel(getClass(), "event-model.xml");
}
-
+
}
-
+
/**
* Paper type could not be determined. Falling back to another.
* @param source the event source
@@ -62,5 +62,5 @@ public interface PCLEventProducer extends EventProducer {
* @event.severity WARN
*/
void paperTypeUnavailable(Object source, long pageWidth, long pageHeight, String fallbackPaper);
-
+
}
diff --git a/src/java/org/apache/fop/render/pcl/PCLGenerator.java b/src/java/org/apache/fop/render/pcl/PCLGenerator.java
index 6a4425012..d1b6f6578 100644
--- a/src/java/org/apache/fop/render/pcl/PCLGenerator.java
+++ b/src/java/org/apache/fop/render/pcl/PCLGenerator.java
@@ -55,24 +55,24 @@ public class PCLGenerator {
/** The ESC (escape) character */
public static final char ESC = '\033';
-
+
/** A list of all supported resolutions in PCL (values in dpi) */
public static final int[] PCL_RESOLUTIONS = new int[] {75, 100, 150, 200, 300, 600};
-
+
/** Selects a 4x4 Bayer dither matrix (17 grayscales) */
public static final int DITHER_MATRIX_4X4 = 4;
/** Selects a 8x8 Bayer dither matrix (65 grayscales) */
public static final int DITHER_MATRIX_8X8 = 8;
-
- private final DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.US);
+
+ private final DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.US);
private final DecimalFormat df2 = new DecimalFormat("0.##", symbols);
private final DecimalFormat df4 = new DecimalFormat("0.####", symbols);
-
+
private OutputStream out;
-
+
private boolean currentSourceTransparency = true;
private boolean currentPatternTransparency = true;
-
+
private int maxBitmapResolution = PCL_RESOLUTIONS[PCL_RESOLUTIONS.length - 1];
/**
@@ -80,7 +80,7 @@ public class PCLGenerator {
* to create custom dither patterns for better grayscale quality.
*/
private boolean usePCLShades = false;
-
+
/**
* Main constructor.
* @param out the OutputStream to write the PCL stream to
@@ -88,7 +88,7 @@ public class PCLGenerator {
public PCLGenerator(OutputStream out) {
this.out = out;
}
-
+
/**
* Main constructor.
* @param out the OutputStream to write the PCL stream to
@@ -108,17 +108,17 @@ public class PCLGenerator {
}
this.maxBitmapResolution = maxResolution;
}
-
+
/** @return the OutputStream that this generator writes to */
public OutputStream getOutputStream() {
return this.out;
}
-
+
/** @return the maximum resolution to encode bitmap images at */
public int getMaximumBitmapResolution() {
return this.maxBitmapResolution;
}
-
+
/**
* Writes a PCL escape command to the output stream.
* @param cmd the command (without the ESCAPE character)
@@ -128,7 +128,7 @@ public class PCLGenerator {
out.write(27); //ESC
out.write(cmd.getBytes("US-ASCII"));
}
-
+
/**
* Writes raw text (in ISO-8859-1 encoding) to the output stream.
* @param s the text
@@ -140,7 +140,7 @@ public class PCLGenerator {
/**
* Formats a double value with two decimal positions for PCL output.
- *
+ *
* @param value value to format
* @return the formatted value
*/
@@ -150,7 +150,7 @@ public class PCLGenerator {
/**
* Formats a double value with four decimal positions for PCL output.
- *
+ *
* @param value value to format
* @return the formatted value
*/
@@ -165,7 +165,7 @@ public class PCLGenerator {
public void universalEndOfLanguage() throws IOException {
writeCommand("%-12345X");
}
-
+
/**
* Resets the printer and restores the user default environment.
* @throws IOException In case of an I/O error
@@ -173,7 +173,7 @@ public class PCLGenerator {
public void resetPrinter() throws IOException {
writeCommand("E");
}
-
+
/**
* Sends the job separation command.
* @throws IOException In case of an I/O error
@@ -181,7 +181,7 @@ public class PCLGenerator {
public void separateJobs() throws IOException {
writeCommand("&l1T");
}
-
+
/**
* Sends the form feed character.
* @throws IOException In case of an I/O error
@@ -198,7 +198,7 @@ public class PCLGenerator {
public void setUnitOfMeasure(int value) throws IOException {
writeCommand("&u" + value + "D");
}
-
+
/**
* Sets the raster graphics resolution
* @param value the resolution value (units per inch)
@@ -207,7 +207,7 @@ public class PCLGenerator {
public void setRasterGraphicsResolution(int value) throws IOException {
writeCommand("*t" + value + "R");
}
-
+
/**
* Selects the page size.
* @param selector the integer representing the page size
@@ -218,7 +218,7 @@ public class PCLGenerator {
}
/**
- * Selects the paper source. The parameter is usually printer-specific. Usually, "1" is the
+ * Selects the paper source. The parameter is usually printer-specific. Usually, "1" is the
* default tray, "2" is the manual paper feed, "3" is the manual envelope feed, "4" is the
* "lower" tray and "7" is "auto-select". Consult the technical reference for your printer
* for all available values.
@@ -230,8 +230,8 @@ public class PCLGenerator {
}
/**
- * Selects the duplexing mode for the page.
- * The parameter is usually printer-specific.
+ * Selects the duplexing mode for the page.
+ * The parameter is usually printer-specific.
* "0" means Simplex,
* "1" means Duplex, Long-Edge Binding,
* "2" means Duplex, Short-Edge Binding.
@@ -249,7 +249,7 @@ public class PCLGenerator {
public void clearHorizontalMargins() throws IOException {
writeCommand("9");
}
-
+
/**
* The Top Margin command designates the number of lines between
* the top of the logical page and the top of the text area.
@@ -303,7 +303,7 @@ public class PCLGenerator {
public void pushCursorPos() throws IOException {
writeCommand("&f0S");
}
-
+
/**
* Pops the current cursor position from the stack.
* @throws IOException In case of an I/O error
@@ -311,7 +311,7 @@ public class PCLGenerator {
public void popCursorPos() throws IOException {
writeCommand("&f1S");
}
-
+
/**
* Changes the current print direction while maintaining the current cursor position.
* @param rotate the rotation angle (counterclockwise), one of 0, 90, 180 and 270.
@@ -320,10 +320,10 @@ public class PCLGenerator {
public void changePrintDirection(int rotate) throws IOException {
writeCommand("&a" + rotate + "P");
}
-
+
/**
* Enters the HP GL/2 mode.
- * @param restorePreviousHPGL2Cursor true if the previous HP GL/2 pen position should be
+ * @param restorePreviousHPGL2Cursor true if the previous HP GL/2 pen position should be
* restored, false if the current position is maintained
* @throws IOException In case of an I/O error
*/
@@ -334,7 +334,7 @@ public class PCLGenerator {
writeCommand("%1B");
}
}
-
+
/**
* Enters the PCL mode.
* @param restorePreviousPCLCursor true if the previous PCL cursor position should be restored,
@@ -348,7 +348,7 @@ public class PCLGenerator {
writeCommand("%1A");
}
}
-
+
/**
* Generate a filled rectangle at the current cursor position.
*
@@ -367,10 +367,10 @@ public class PCLGenerator {
//y += h;
}
setPatternTransparencyMode(false);
- if (usePCLShades
+ if (usePCLShades
|| Color.black.equals(col)
|| Color.white.equals(col)) {
- writeCommand("*c" + formatDouble4(w / 100.0) + "h"
+ writeCommand("*c" + formatDouble4(w / 100.0) + "h"
+ formatDouble4(h / 100.0) + "V");
int lineshade = convertToPCLShade(col);
writeCommand("*c" + lineshade + "G");
@@ -378,7 +378,7 @@ public class PCLGenerator {
} else {
defineGrayscalePattern(col, 32, DITHER_MATRIX_4X4);
- writeCommand("*c" + formatDouble4(w / 100.0) + "h"
+ writeCommand("*c" + formatDouble4(w / 100.0) + "h"
+ formatDouble4(h / 100.0) + "V");
writeCommand("*c32G");
writeCommand("*c4P"); //User-defined pattern
@@ -391,19 +391,19 @@ public class PCLGenerator {
private static final int[] BAYER_D2 = new int[] {0, 2, 3, 1};
private static final int[] BAYER_D4;
private static final int[] BAYER_D8;
-
+
static {
BAYER_D4 = deriveBayerMatrix(BAYER_D2);
BAYER_D8 = deriveBayerMatrix(BAYER_D4);
}
-
+
private static void setValueInMatrix(int[] dn, int half, int part, int idx, int value) {
int xoff = (part & 1) * half;
int yoff = (part & 2) * half * half;
int matrixIndex = yoff + ((int)(idx / half) * half * 2) + (idx % half) + xoff;
dn[matrixIndex] = value;
}
-
+
private static int[] deriveBayerMatrix(int[] d) {
int[] dn = new int[d.length * 4];
int half = (int)Math.sqrt(d.length);
@@ -414,7 +414,7 @@ public class PCLGenerator {
}
return dn;
}
-
+
/**
* Generates a user-defined pattern for a dithering pattern matching the grayscale value
* of the color given.
@@ -423,7 +423,7 @@ public class PCLGenerator {
* @param ditherMatrixSize the size of the Bayer dither matrix to use (4 or 8 supported)
* @throws IOException In case of an I/O error
*/
- public void defineGrayscalePattern(Color col, int patternID, int ditherMatrixSize)
+ public void defineGrayscalePattern(Color col, int patternID, int ditherMatrixSize)
throws IOException {
ByteArrayOutputStream baout = new ByteArrayOutputStream();
DataOutputStream data = new DataOutputStream(baout);
@@ -436,36 +436,36 @@ public class PCLGenerator {
//data.writeShort(600); //X Resolution (didn't manage to get that to work)
//data.writeShort(600); //Y Resolution
int gray255 = convertToGray(col.getRed(), col.getGreen(), col.getBlue());
-
+
byte[] pattern;
if (ditherMatrixSize == 8) {
int gray65 = gray255 * 65 / 255;
-
+
pattern = new byte[BAYER_D8.length / 8];
-
+
for (int i = 0, c = BAYER_D8.length; i < c; i++) {
boolean dot = !(BAYER_D8[i] < gray65 - 1);
if (dot) {
int byteIdx = i / 8;
- pattern[byteIdx] |= 1 << (i % 8);
+ pattern[byteIdx] |= 1 << (i % 8);
}
}
} else {
int gray17 = gray255 * 17 / 255;
-
- //Since a 4x4 pattern did not work, the 4x4 pattern is applied 4 times to an
- //8x8 pattern. Maybe this could be changed to use an 8x8 bayer dither pattern
+
+ //Since a 4x4 pattern did not work, the 4x4 pattern is applied 4 times to an
+ //8x8 pattern. Maybe this could be changed to use an 8x8 bayer dither pattern
//instead of the 4x4 one.
pattern = new byte[BAYER_D4.length / 8 * 4];
-
+
for (int i = 0, c = BAYER_D4.length; i < c; i++) {
boolean dot = !(BAYER_D4[i] < gray17 - 1);
if (dot) {
int byteIdx = i / 4;
- pattern[byteIdx] |= 1 << (i % 4);
- pattern[byteIdx] |= 1 << ((i % 4) + 4);
- pattern[byteIdx + 4] |= 1 << (i % 4);
- pattern[byteIdx + 4] |= 1 << ((i % 4) + 4);
+ pattern[byteIdx] |= 1 << (i % 4);
+ pattern[byteIdx] |= 1 << ((i % 4) + 4);
+ pattern[byteIdx + 4] |= 1 << (i % 4);
+ pattern[byteIdx + 4] |= 1 << ((i % 4) + 4);
}
}
}
@@ -525,7 +525,7 @@ public class PCLGenerator {
public final int convertToGray(int r, int g, int b) {
return (r * 30 + g * 59 + b * 11) / 100;
}
-
+
/**
* Convert a Color value to a PCL shade value (0-100).
* @param col the color
@@ -535,7 +535,7 @@ public class PCLGenerator {
float gray = convertToGray(col.getRed(), col.getGreen(), col.getBlue()) / 255f;
return (int)(100 - (gray * 100f));
}
-
+
/**
* Selects the current grayscale color (the given color is converted to grayscales).
* @param col the color
@@ -555,7 +555,7 @@ public class PCLGenerator {
}
}
}
-
+
/**
* Select the current pattern
* @param patternID the pattern ID (*c#G command)
@@ -583,7 +583,7 @@ public class PCLGenerator {
return false;
}
}
-
+
/**
* Indicates whether an image is a grayscale image.
* @param img the image
@@ -592,7 +592,7 @@ public class PCLGenerator {
public static boolean isGrayscaleImage(RenderedImage img) {
return (img.getColorModel().getColorSpace().getNumComponents() == 1);
}
-
+
private MonochromeBitmapConverter createMonochromeBitmapConverter() {
MonochromeBitmapConverter converter = null;
try {
@@ -621,7 +621,7 @@ public class PCLGenerator {
private int calculatePCLResolution(int resolution) {
return calculatePCLResolution(resolution, false);
}
-
+
/**
* Calculates the ideal PCL resolution for a given resolution.
* @param resolution the input resolution
@@ -653,35 +653,35 @@ public class PCLGenerator {
}
return PCL_RESOLUTIONS[choice];
}
-
+
private boolean isValidPCLResolution(int resolution) {
return resolution == calculatePCLResolution(resolution);
}
-
- private Dimension getAdjustedDimension(Dimension orgDim, double orgResolution,
+
+ private Dimension getAdjustedDimension(Dimension orgDim, double orgResolution,
int pclResolution) {
if (orgResolution == pclResolution) {
return orgDim;
} else {
Dimension result = new Dimension();
- result.width = (int)Math.round((double)orgDim.width * pclResolution / orgResolution);
- result.height = (int)Math.round((double)orgDim.height * pclResolution / orgResolution);
+ result.width = (int)Math.round((double)orgDim.width * pclResolution / orgResolution);
+ result.height = (int)Math.round((double)orgDim.height * pclResolution / orgResolution);
return result;
}
}
-
+
//Threshold table to convert an alpha channel (8-bit) into a clip mask (1-bit)
private static final byte[] THRESHOLD_TABLE = new byte[256];
static { // Initialize the arrays
for (int i = 0; i < 256; i++) {
THRESHOLD_TABLE[i] = (byte) ((i < 240) ? 255 : 0);
}
- }
-
+ }
+
private RenderedImage getMask(RenderedImage img, Dimension targetDim) {
- ColorModel cm = img.getColorModel();
+ ColorModel cm = img.getColorModel();
if (cm.hasAlpha()) {
- BufferedImage alpha = new BufferedImage(img.getWidth(), img.getHeight(),
+ BufferedImage alpha = new BufferedImage(img.getWidth(), img.getHeight(),
BufferedImage.TYPE_BYTE_GRAY);
Raster raster = img.getData();
GraphicsUtil.copyBand(raster, cm.getNumColorComponents(), alpha.getRaster(), 0);
@@ -700,7 +700,7 @@ public class PCLGenerator {
targetDim.width, targetDim.height, 1, 1, null);
mask = new BufferedImage(colorModel, wraster, false, null);
}
-
+
Graphics2D g2d = mask.createGraphics();
try {
AffineTransform at = new AffineTransform();
@@ -732,7 +732,7 @@ public class PCLGenerator {
* @param sourceTransparency true if the background should not be erased
* @throws IOException In case of an I/O error
*/
- public void paintBitmap(RenderedImage img, Dimension targetDim, boolean sourceTransparency)
+ public void paintBitmap(RenderedImage img, Dimension targetDim, boolean sourceTransparency)
throws IOException {
double targetResolution = img.getWidth() / UnitConv.mpt2in(targetDim.width);
int resolution = (int)Math.round(targetResolution);
@@ -745,7 +745,7 @@ public class PCLGenerator {
if (!monochrome) {
//Transparency mask disabled. Doesn't work reliably
final boolean transparencyDisabled = true;
- RenderedImage mask = (transparencyDisabled ? null : getMask(img, effDim));
+ RenderedImage mask = (transparencyDisabled ? null : getMask(img, effDim));
if (mask != null) {
pushCursorPos();
selectCurrentPattern(0, 1); //Solid white
@@ -753,11 +753,11 @@ public class PCLGenerator {
paintMonochromeBitmap(mask, effResolution);
popCursorPos();
}
-
+
BufferedImage src = null;
if (img instanceof BufferedImage && !scaled) {
if (!isGrayscaleImage(img) || img.getColorModel().hasAlpha()) {
- src = new BufferedImage(effDim.width, effDim.height,
+ src = new BufferedImage(effDim.width, effDim.height,
BufferedImage.TYPE_BYTE_GRAY);
ColorConvertOp op = new ColorConvertOp(
ColorSpace.getInstance(ColorSpace.CS_GRAY), null);
@@ -767,7 +767,7 @@ public class PCLGenerator {
}
}
if (src == null) {
- src = new BufferedImage(effDim.width, effDim.height,
+ src = new BufferedImage(effDim.width, effDim.height,
BufferedImage.TYPE_BYTE_GRAY);
Graphics2D g2d = src.createGraphics();
try {
@@ -784,7 +784,7 @@ public class PCLGenerator {
converter.setHint("quality", "false");
BufferedImage buf = (BufferedImage)converter.convertToMonochrome(src);
-
+
RenderedImage red = buf;
selectCurrentPattern(0, 0); //Solid black
setTransparencyMode(sourceTransparency || mask != null, true);
@@ -793,7 +793,7 @@ public class PCLGenerator {
//TODO untested!
RenderedImage effImg = img;
if (scaled) {
- BufferedImage buf = new BufferedImage(effDim.width, effDim.height,
+ BufferedImage buf = new BufferedImage(effDim.width, effDim.height,
BufferedImage.TYPE_BYTE_BINARY);
Graphics2D g2d = buf.createGraphics();
try {
@@ -831,7 +831,7 @@ public class PCLGenerator {
if (!monochrome) {
throw new IllegalArgumentException("img must be a monochrome image");
}
-
+
int x = 0;
int y = 0;
int imgw = img.getWidth();
@@ -856,7 +856,7 @@ public class PCLGenerator {
if ((sample == 0)) {
ib |= (1 << (7 - (x % 8)));
}
-
+
//RLE encoding
if ((x % 8) == 7 || ((x + 1) == imgw)) {
if (rlewidth < bytewidth) {
diff --git a/src/java/org/apache/fop/render/pcl/PCLGraphics2D.java b/src/java/org/apache/fop/render/pcl/PCLGraphics2D.java
index ef777e20a..3eef38b6b 100644
--- a/src/java/org/apache/fop/render/pcl/PCLGraphics2D.java
+++ b/src/java/org/apache/fop/render/pcl/PCLGraphics2D.java
@@ -54,10 +54,10 @@ public class PCLGraphics2D extends AbstractGraphics2D {
/** The PCL generator */
protected PCLGenerator gen;
-
+
private boolean failOnUnsupportedFeature = true;
private boolean clippingDisabled = false;
-
+
/**
* Create a new PCLGraphics2D.
* @param gen the PCL Generator to paint with
@@ -103,7 +103,7 @@ public class PCLGraphics2D extends AbstractGraphics2D {
public void setClippingDisabled(boolean value) {
this.clippingDisabled = value;
}
-
+
/**
* Central handler for IOExceptions for this class.
* @param ioe IOException to handle
@@ -124,7 +124,7 @@ public class PCLGraphics2D extends AbstractGraphics2D {
throw new UnsupportedOperationException(msg);
}
}
-
+
/** {@inheritDoc} */
public GraphicsConfiguration getDeviceConfiguration() {
return GraphicsEnvironment.getLocalGraphicsEnvironment().
@@ -142,7 +142,7 @@ public class PCLGraphics2D extends AbstractGraphics2D {
float[] da = bs.getDashArray();
if (da != null) {
-
+
gen.writeText("UL1,");
int len = Math.min(20, da.length);
float patternLen = 0.0f;
@@ -161,7 +161,7 @@ public class PCLGraphics2D extends AbstractGraphics2D {
}
if (len == 1) {
gen.writeText("," + gen.formatDouble2(da[0] * 100 / patternLen ));
-
+
}
gen.writeText(";");
/* TODO Dash phase NYI
@@ -209,7 +209,7 @@ public class PCLGraphics2D extends AbstractGraphics2D {
float ml = bs.getMiterLimit();
gen.writeText(",3" + gen.formatDouble4(ml));
-
+
float lw = bs.getLineWidth();
Point2D ptSrc = new Point2D.Double(lw, 0);
//Pen widths are set as absolute metric values (WU0;)
@@ -217,7 +217,7 @@ public class PCLGraphics2D extends AbstractGraphics2D {
double transDist = UnitConv.pt2mm(ptDest.distance(0, 0));
//System.out.println("--" + ptDest.distance(0, 0) + " " + transDist);
gen.writeText(";PW" + gen.formatDouble4(transDist) + ";");
-
+
} else {
handleUnsupportedFeature("Unsupported Stroke: " + stroke.getClass().getName());
}
@@ -246,7 +246,7 @@ public class PCLGraphics2D extends AbstractGraphics2D {
//gen.writeText("IW;");
} else {
handleUnsupportedFeature("Clipping is not supported. Shape: " + imclip);
- /* This is an attempt to clip using the "InputWindow" (IW) but this only allows to
+ /* This is an attempt to clip using the "InputWindow" (IW) but this only allows to
* clip a rectangular area. Force falling back to bitmap mode for now.
Rectangle2D bounds = imclip.getBounds2D();
Point2D p1 = new Point2D.Double(bounds.getX(), bounds.getY());
@@ -266,16 +266,16 @@ public class PCLGraphics2D extends AbstractGraphics2D {
public void draw(Shape s) {
try {
AffineTransform trans = getTransform();
-
+
Shape imclip = getClip();
writeClip(imclip);
-
+
if (!Color.black.equals(getColor())) {
//TODO PCL 5 doesn't support colored pens, PCL5c has a pen color (PC) command
handleUnsupportedFeature("Only black is supported as stroke color: " + getColor());
}
applyStroke(getStroke());
-
+
PathIterator iter = s.getPathIterator(trans);
processPathIteratorStroke(iter);
writeClip(null);
@@ -290,7 +290,7 @@ public class PCLGraphics2D extends AbstractGraphics2D {
AffineTransform trans = getTransform();
Shape imclip = getClip();
writeClip(imclip);
-
+
applyPaint(getPaint());
PathIterator iter = s.getPathIterator(trans);
@@ -371,7 +371,7 @@ public class PCLGraphics2D extends AbstractGraphics2D {
sb.append("\n");
gen.writeText(sb.toString());
}
-
+
/**
* Processes a path iterator generating the nexessary painting operations.
* @param iter PathIterator to process
@@ -440,7 +440,7 @@ public class PCLGraphics2D extends AbstractGraphics2D {
sb.append("\n");
gen.writeText(sb.toString());
}
-
+
private void fillPolygon(int windingRule, StringBuffer sb) {
int fillMethod = (windingRule == PathIterator.WIND_EVEN_ODD ? 0 : 1);
sb.append("FP").append(fillMethod).append(";");
@@ -461,16 +461,16 @@ public class PCLGraphics2D extends AbstractGraphics2D {
sb.append(",").append(gen.formatDouble4(y3)).append(";");
}
- private void quadraticBezierAbsolute(double originX, double originY,
+ private void quadraticBezierAbsolute(double originX, double originY,
double x1, double y1, double x2, double y2, StringBuffer sb) {
//Quadratic Bezier curve can be mapped to a normal bezier curve
//See http://pfaedit.sourceforge.net/bezier.html
double nx1 = originX + (2.0 / 3.0) * (x1 - originX);
double ny1 = originY + (2.0 / 3.0) * (y1 - originY);
-
+
double nx2 = nx1 + (1.0 / 3.0) * (x2 - originX);
double ny2 = ny1 + (1.0 / 3.0) * (y2 - originY);
-
+
bezierAbsolute(nx1, ny1, nx2, ny2, x2, y2, sb);
}
@@ -554,7 +554,7 @@ public class PCLGraphics2D extends AbstractGraphics2D {
at.transform(p1, p1);
pclContext.getTransform().transform(p1, p1);
gen.setCursorPos(p1.getX(), p1.getY());
- gen.paintBitmap(buf, 72);
+ gen.paintBitmap(buf, 72);
gen.enterHPGL2Mode(false);
} catch (IOException ioe) {
handleIOException(ioe);
@@ -596,7 +596,7 @@ public class PCLGraphics2D extends AbstractGraphics2D {
return new BufferedImage(size.width, size.height,
BufferedImage.TYPE_BYTE_GRAY);
}
-
+
/** {@inheritDoc} */
public java.awt.FontMetrics getFontMetrics(java.awt.Font f) {
return fmg.getFontMetrics(f);
diff --git a/src/java/org/apache/fop/render/pcl/PCLGraphics2DAdapter.java b/src/java/org/apache/fop/render/pcl/PCLGraphics2DAdapter.java
index 06a4d37a0..3878a84fb 100644
--- a/src/java/org/apache/fop/render/pcl/PCLGraphics2DAdapter.java
+++ b/src/java/org/apache/fop/render/pcl/PCLGraphics2DAdapter.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
*/
/* $Id$ */
-
+
package org.apache.fop.render.pcl;
import java.awt.Dimension;
@@ -49,15 +49,15 @@ public class PCLGraphics2DAdapter extends AbstractGraphics2DAdapter {
*/
public PCLGraphics2DAdapter() {
}
-
+
/** {@inheritDoc} */
- public void paintImage(Graphics2DImagePainter painter,
+ public void paintImage(Graphics2DImagePainter painter,
RendererContext context,
int x, int y, int width, int height) throws IOException {
PCLRendererContext pclContext = PCLRendererContext.wrapRendererContext(context);
PCLRenderer pcl = (PCLRenderer)context.getRenderer();
PCLGenerator gen = pcl.gen;
-
+
// get the 'width' and 'height' attributes of the image/document
Dimension dim = painter.getImageSize();
float imw = (float)dim.getWidth();
@@ -80,11 +80,11 @@ public class PCLGraphics2DAdapter extends AbstractGraphics2DAdapter {
graphics.setClippingDisabled(pclContext.isClippingDisabled());
Rectangle2D area = new Rectangle2D.Double(0.0, 0.0, imw, imh);
painter.paint(graphics, area);
-
+
//If we arrive here, the graphic is natively paintable, so write the graphic
pcl.saveGraphicsState();
pcl.setCursorPos(x, y);
- gen.writeCommand("*c" + gen.formatDouble4(width / 100f) + "x"
+ gen.writeCommand("*c" + gen.formatDouble4(width / 100f) + "x"
+ gen.formatDouble4(height / 100f) + "Y");
gen.writeCommand("*c0T");
gen.enterHPGL2Mode(false);
@@ -92,7 +92,7 @@ public class PCLGraphics2DAdapter extends AbstractGraphics2DAdapter {
gen.writeText("SP1;");
//One Plotter unit is 0.025mm!
double scale = imw / UnitConv.mm2pt(imw * 0.025);
- gen.writeText("SC0," + gen.formatDouble4(scale)
+ gen.writeText("SC0," + gen.formatDouble4(scale)
+ ",0,-" + gen.formatDouble4(scale) + ",2;");
gen.writeText("IR0,100,0,100;");
gen.writeText("PU;PA0,0;\n");
@@ -104,11 +104,11 @@ public class PCLGraphics2DAdapter extends AbstractGraphics2DAdapter {
painted = true;
} catch (UnsupportedOperationException uoe) {
log.debug(
- "Cannot paint graphic natively. Falling back to bitmap painting. Reason: "
+ "Cannot paint graphic natively. Falling back to bitmap painting. Reason: "
+ uoe.getMessage());
}
}
-
+
if (!painted) {
//Fallback solution: Paint to a BufferedImage
int resolution = (int)Math.round(context.getUserAgent().getTargetResolution());
diff --git a/src/java/org/apache/fop/render/pcl/PCLPageDefinition.java b/src/java/org/apache/fop/render/pcl/PCLPageDefinition.java
index ebff61f0f..e8c8814ab 100644
--- a/src/java/org/apache/fop/render/pcl/PCLPageDefinition.java
+++ b/src/java/org/apache/fop/render/pcl/PCLPageDefinition.java
@@ -33,17 +33,17 @@ public class PCLPageDefinition {
private static List pageDefinitions;
private static PCLPageDefinition defaultPageDefinition;
-
+
private String name;
private int selector;
private Dimension physicalPageSize;
private Rectangle logicalPageRect;
private boolean landscape;
-
+
static {
createPageDefinitions();
}
-
+
/**
* Main constructor
* @param name the name of the page definition
@@ -52,7 +52,7 @@ public class PCLPageDefinition {
* @param logicalPageRect the rectangle defining the logical page
* @param landscape true if it is a landscape format
*/
- public PCLPageDefinition(String name, int selector, Dimension physicalPageSize,
+ public PCLPageDefinition(String name, int selector, Dimension physicalPageSize,
Rectangle logicalPageRect, boolean landscape) {
this.name = name;
this.selector = selector;
@@ -60,17 +60,17 @@ public class PCLPageDefinition {
this.logicalPageRect = logicalPageRect;
this.landscape = landscape;
}
-
+
/** @return the name of the page definition */
public String getName() {
return this.name;
}
-
+
/** @return the selector used by the &l#A command (page size) */
public int getSelector() {
return this.selector;
}
-
+
/** @return true if it is a landscape format */
public boolean isLandscapeFormat() {
return this.landscape;
@@ -80,17 +80,17 @@ public class PCLPageDefinition {
public Dimension getPhysicalPageSize() {
return this.physicalPageSize;
}
-
+
/** @return the rectangle defining the logical page */
public Rectangle getLogicalPageRect() {
return this.logicalPageRect;
}
-
+
private boolean matches(long width, long height, int errorMargin) {
- return (Math.abs(this.physicalPageSize.width - width) < errorMargin)
+ return (Math.abs(this.physicalPageSize.width - width) < errorMargin)
&& (Math.abs(this.physicalPageSize.height - height) < errorMargin);
}
-
+
/** {@inheritDoc} */
public String toString() {
return getName();
@@ -113,12 +113,12 @@ public class PCLPageDefinition {
}
return null;
}
-
+
/** @return the default page definition (letter) */
public static PCLPageDefinition getDefaultPageDefinition() {
return defaultPageDefinition;
}
-
+
/**
* Converts an offset values for logical pages to millipoints. The values are given as pixels
* in a 300dpi environment.
@@ -128,34 +128,34 @@ public class PCLPageDefinition {
private static int convert300dpiDotsToMpt(int offset) {
return (int)Math.round(((double)offset) * 72000 / 300);
}
-
+
private static Dimension createPhysicalPageSizeInch(float width, float height) {
return new Dimension(
- (int)Math.round(UnitConv.in2mpt(width)),
+ (int)Math.round(UnitConv.in2mpt(width)),
(int)Math.round(UnitConv.in2mpt(height)));
}
-
+
private static Dimension createPhysicalPageSizeMm(float width, float height) {
return new Dimension(
- (int)Math.round(UnitConv.mm2mpt(width)),
+ (int)Math.round(UnitConv.mm2mpt(width)),
(int)Math.round(UnitConv.mm2mpt(height)));
}
-
+
private static Rectangle createLogicalPageRect(int x, int y, int width, int height) {
- return new Rectangle(convert300dpiDotsToMpt(x), convert300dpiDotsToMpt(y),
+ return new Rectangle(convert300dpiDotsToMpt(x), convert300dpiDotsToMpt(y),
convert300dpiDotsToMpt(width), convert300dpiDotsToMpt(height));
}
-
+
private static void createPageDefinitions() {
pageDefinitions = new java.util.ArrayList();
pageDefinitions.add(new PCLPageDefinition("Letter", 2,
createPhysicalPageSizeInch(8.5f, 11),
createLogicalPageRect(75, 0, 2400, 3300), false));
- defaultPageDefinition = new PCLPageDefinition("Legal", 3,
+ defaultPageDefinition = new PCLPageDefinition("Legal", 3,
createPhysicalPageSizeInch(8.5f, 14),
createLogicalPageRect(75, 0, 2400, 4200), false);
pageDefinitions.add(defaultPageDefinition);
- pageDefinitions.add(new PCLPageDefinition("Executive", 1,
+ pageDefinitions.add(new PCLPageDefinition("Executive", 1,
createPhysicalPageSizeInch(7.25f, 10.5f),
createLogicalPageRect(75, 0, 2025, 3150), false));
pageDefinitions.add(new PCLPageDefinition("Ledger", 6,
@@ -164,19 +164,19 @@ public class PCLPageDefinition {
pageDefinitions.add(new PCLPageDefinition("A4", 26,
createPhysicalPageSizeMm(210, 297),
createLogicalPageRect(71, 0, 2338, 3507), false));
- pageDefinitions.add(new PCLPageDefinition("A3", 27,
+ pageDefinitions.add(new PCLPageDefinition("A3", 27,
createPhysicalPageSizeMm(297, 420),
createLogicalPageRect(71, 0, 3365, 4960), false));
//TODO Add envelope definitions
-
+
pageDefinitions.add(new PCLPageDefinition("LetterL", 2,
createPhysicalPageSizeInch(11, 8.5f),
createLogicalPageRect(60, 0, 3180, 2550), true));
pageDefinitions.add(new PCLPageDefinition("LegalL", 3,
createPhysicalPageSizeInch(14, 8.5f),
createLogicalPageRect(60, 0, 4080, 2550), true));
- pageDefinitions.add(new PCLPageDefinition("ExecutiveL", 1,
+ pageDefinitions.add(new PCLPageDefinition("ExecutiveL", 1,
createPhysicalPageSizeInch(10.5f, 7.25f),
createLogicalPageRect(60, 0, 3030, 2175), true));
pageDefinitions.add(new PCLPageDefinition("LedgerL", 6,
@@ -189,5 +189,5 @@ public class PCLPageDefinition {
createPhysicalPageSizeMm(420, 297),
createLogicalPageRect(59, 0, 4842, 3507), true));
}
-
+
}
diff --git a/src/java/org/apache/fop/render/pcl/PCLRendererConfigurator.java b/src/java/org/apache/fop/render/pcl/PCLRendererConfigurator.java
index b9c772dcb..6d57825cd 100644
--- a/src/java/org/apache/fop/render/pcl/PCLRendererConfigurator.java
+++ b/src/java/org/apache/fop/render/pcl/PCLRendererConfigurator.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -27,10 +27,10 @@ import org.apache.fop.render.PrintRendererConfigurator;
import org.apache.fop.render.Renderer;
/**
- * PCL Renderer configurator
+ * PCL Renderer configurator
*/
public class PCLRendererConfigurator extends PrintRendererConfigurator {
-
+
/**
* Default constructor
* @param userAgent user agent
@@ -41,7 +41,7 @@ public class PCLRendererConfigurator extends PrintRendererConfigurator {
/**
* Configure the PCL renderer.
- *
+ *
* @param renderer PCL renderer
* @throws FOPException fop exception
*/
@@ -49,7 +49,7 @@ public class PCLRendererConfigurator extends PrintRendererConfigurator {
Configuration cfg = super.getRendererConfig(renderer);
if (cfg != null) {
PCLRenderer pclRenderer = (PCLRenderer)renderer;
-
+
String rendering = cfg.getChild("rendering").getValue(null);
if ("quality".equalsIgnoreCase(rendering)) {
pclRenderer.setQualityBeforeSpeed(true);
@@ -57,10 +57,10 @@ public class PCLRendererConfigurator extends PrintRendererConfigurator {
pclRenderer.setQualityBeforeSpeed(false);
} else if (rendering != null) {
throw new FOPException(
- "Valid values for 'rendering' are 'quality' and 'speed'. Value found: "
+ "Valid values for 'rendering' are 'quality' and 'speed'. Value found: "
+ rendering);
}
-
+
String textRendering = cfg.getChild("text-rendering").getValue(null);
if ("bitmap".equalsIgnoreCase(textRendering)) {
pclRenderer.setAllTextAsBitmaps(true);
@@ -68,10 +68,10 @@ public class PCLRendererConfigurator extends PrintRendererConfigurator {
pclRenderer.setAllTextAsBitmaps(false);
} else if (textRendering != null) {
throw new FOPException(
- "Valid values for 'text-rendering' are 'auto' and 'bitmap'. Value found: "
+ "Valid values for 'text-rendering' are 'auto' and 'bitmap'. Value found: "
+ textRendering);
}
-
+
pclRenderer.setPJLDisabled(cfg.getChild("disable-pjl").getValueAsBoolean(false));
}
super.configure(renderer);
diff --git a/src/java/org/apache/fop/render/pcl/PCLRendererContext.java b/src/java/org/apache/fop/render/pcl/PCLRendererContext.java
index 422b9d51d..aa6271fe5 100644
--- a/src/java/org/apache/fop/render/pcl/PCLRendererContext.java
+++ b/src/java/org/apache/fop/render/pcl/PCLRendererContext.java
@@ -25,7 +25,7 @@ import org.apache.fop.fo.extensions.ExtensionElementMapping;
import org.apache.fop.render.RendererContext;
/**
- * Wrapper on the RendererContext to access the information structure for drawing
+ * Wrapper on the RendererContext to access the information structure for drawing
* the XML document.
*/
public class PCLRendererContext extends RendererContext.RendererContextWrapper {
@@ -48,18 +48,18 @@ public class PCLRendererContext extends RendererContext.RendererContextWrapper {
public PCLRendererContext(RendererContext context) {
super(context);
}
-
+
/** @return true if the SVG image should be rendered as a bitmap */
public boolean paintAsBitmap() {
QName qName = new QName(ExtensionElementMapping.URI, null, "conversion-mode");
- return getForeignAttributes() != null
+ return getForeignAttributes() != null
&& "bitmap".equalsIgnoreCase((String)getForeignAttributes().get(qName));
}
-
+
/** @return true if clipping is disabled inside the PCLGraphics2D. */
public boolean isClippingDisabled() {
QName qName = new QName(ExtensionElementMapping.URI, null, "disable-clipping");
- return getForeignAttributes() != null
+ return getForeignAttributes() != null
&& "true".equalsIgnoreCase((String)getForeignAttributes().get(qName));
}
@@ -69,10 +69,10 @@ public class PCLRendererContext extends RendererContext.RendererContextWrapper {
*/
public boolean isSourceTransparency() {
QName qName = new QName(ExtensionElementMapping.URI, null, "source-transparency");
- return getForeignAttributes() != null
+ return getForeignAttributes() != null
&& "true".equalsIgnoreCase((String)getForeignAttributes().get(qName));
}
-
+
/**
* Indicates whether an RGB canvas should be used rather than one with grayscales.
* This can be used to work around limitations of Apache Batik if you get error while
@@ -82,8 +82,8 @@ public class PCLRendererContext extends RendererContext.RendererContextWrapper {
public boolean isColorCanvas() {
QName qName = new QName(ExtensionElementMapping.URI, null, "color-canvas");
Boolean prop = (Boolean)context.getProperty(PCLRendererContextConstants.PCL_COLOR_CANVAS);
- return Boolean.TRUE.equals(prop)
- || (getForeignAttributes() != null
+ return Boolean.TRUE.equals(prop)
+ || (getForeignAttributes() != null
&& "true".equalsIgnoreCase((String)getForeignAttributes().get(qName)));
}
diff --git a/src/java/org/apache/fop/render/pcl/PCLRendererMaker.java b/src/java/org/apache/fop/render/pcl/PCLRendererMaker.java
index f18446506..a7651a6ac 100644
--- a/src/java/org/apache/fop/render/pcl/PCLRendererMaker.java
+++ b/src/java/org/apache/fop/render/pcl/PCLRendererMaker.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -34,7 +34,7 @@ public class PCLRendererMaker extends AbstractRendererMaker {
MimeConstants.MIME_PCL,
MimeConstants.MIME_PCL_ALT
};
-
+
/**{@inheritDoc} */
public Renderer makeRenderer(FOUserAgent userAgent) {
return new PCLRenderer();
diff --git a/src/java/org/apache/fop/render/pcl/PCLSVGHandler.java b/src/java/org/apache/fop/render/pcl/PCLSVGHandler.java
index a016c692f..fb2389758 100644
--- a/src/java/org/apache/fop/render/pcl/PCLSVGHandler.java
+++ b/src/java/org/apache/fop/render/pcl/PCLSVGHandler.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -36,13 +36,13 @@ public class PCLSVGHandler extends AbstractGenericSVGHandler {
public boolean supportsRenderer(Renderer renderer) {
return (renderer instanceof PCLRenderer);
}
-
+
/** {@inheritDoc} */
protected void updateRendererContext(RendererContext context) {
//Work around a problem in Batik: Gradients cannot be done in ColorSpace.CS_GRAY
context.setProperty(PCLRendererContextConstants.PCL_COLOR_CANVAS,
Boolean.TRUE);
}
-
+
}
diff --git a/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java b/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java
index caf8928ac..cbaac4e55 100644
--- a/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java
+++ b/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -48,7 +48,7 @@ public abstract class AbstractImageAdapter implements PDFImage {
private String key;
/** the image */
protected Image image;
-
+
private PDFICCStream pdfICCStream = null;
/**
@@ -77,7 +77,7 @@ public abstract class AbstractImageAdapter implements PDFImage {
protected ColorSpace getImageColorSpace() {
return image.getColorSpace();
}
-
+
/** {@inheritDoc} */
public void setup(PDFDocument doc) {
@@ -88,7 +88,7 @@ public abstract class AbstractImageAdapter implements PDFImage {
}
if (doc.getProfile().getPDFAMode().isPDFA1LevelB()) {
if (pdfCS != null
- && pdfCS.getColorSpace() != PDFDeviceColorSpace.DEVICE_RGB
+ && pdfCS.getColorSpace() != PDFDeviceColorSpace.DEVICE_RGB
&& pdfCS.getColorSpace() != PDFDeviceColorSpace.DEVICE_GRAY
&& prof == null) {
//See PDF/A-1, ISO 19005:1:2005(E), 6.2.3.3
@@ -107,7 +107,7 @@ public abstract class AbstractImageAdapter implements PDFImage {
protected ICC_Profile getEffectiveICCProfile() {
return image.getICCProfile();
}
-
+
private static PDFICCStream setupColorProfile(PDFDocument doc,
ICC_Profile prof, PDFDeviceColorSpace pdfCS) {
boolean defaultsRGB = ColorProfileUtil.isDefaultsRGB(prof);
@@ -154,32 +154,32 @@ public abstract class AbstractImageAdapter implements PDFImage {
public boolean isTransparent() {
return false;
}
-
+
/** {@inheritDoc} */
public PDFColor getTransparentColor() {
return null;
}
-
+
/** {@inheritDoc} */
public String getMask() {
return null;
}
-
+
/** {@inheritDoc} */
public String getSoftMask() {
return null;
}
-
+
/** {@inheritDoc} */
public PDFReference getSoftMaskReference() {
return null;
}
-
+
/** {@inheritDoc} */
public boolean isInverted() {
return false;
}
-
+
/** {@inheritDoc} */
public boolean isPS() {
return false;
@@ -194,7 +194,7 @@ public abstract class AbstractImageAdapter implements PDFImage {
public void populateXObjectDictionary(PDFDictionary dict) {
//nop
}
-
+
/**
* Converts a ColorSpace object to a PDFColorSpace object.
* @param cs ColorSpace instance
diff --git a/src/java/org/apache/fop/render/pdf/CTMHelper.java b/src/java/org/apache/fop/render/pdf/CTMHelper.java
index e2d29f768..ced025ea3 100644
--- a/src/java/org/apache/fop/render/pdf/CTMHelper.java
+++ b/src/java/org/apache/fop/render/pdf/CTMHelper.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
*/
/* $Id$ */
-
+
package org.apache.fop.render.pdf;
import java.awt.geom.AffineTransform;
@@ -37,7 +37,7 @@ public final class CTMHelper {
*
Converts the sourceMatrix to a string for use in the PDFRenderer cm operations.
diff --git a/src/java/org/apache/fop/render/pdf/ImageRawCCITTFaxAdapter.java b/src/java/org/apache/fop/render/pdf/ImageRawCCITTFaxAdapter.java
index b80e2c03e..f158f6a14 100644
--- a/src/java/org/apache/fop/render/pdf/ImageRawCCITTFaxAdapter.java
+++ b/src/java/org/apache/fop/render/pdf/ImageRawCCITTFaxAdapter.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -55,7 +55,7 @@ public class ImageRawCCITTFaxAdapter extends AbstractImageAdapter {
public ImageRawCCITTFax getImage() {
return ((ImageRawCCITTFax)this.image);
}
-
+
/** {@inheritDoc} */
public void setup(PDFDocument doc) {
pdfFilter = new CCFFilter();
@@ -95,7 +95,7 @@ public class ImageRawCCITTFaxAdapter extends AbstractImageAdapter {
public PDFFilter getPDFFilter() {
return pdfFilter;
}
-
+
/** {@inheritDoc} */
public void outputContents(OutputStream out) throws IOException {
getImage().writeTo(out);
diff --git a/src/java/org/apache/fop/render/pdf/ImageRawJPEGAdapter.java b/src/java/org/apache/fop/render/pdf/ImageRawJPEGAdapter.java
index 1e505daed..a60c9e92c 100644
--- a/src/java/org/apache/fop/render/pdf/ImageRawJPEGAdapter.java
+++ b/src/java/org/apache/fop/render/pdf/ImageRawJPEGAdapter.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -64,7 +64,7 @@ public class ImageRawJPEGAdapter extends AbstractImageAdapter {
public ImageRawJPEG getImage() {
return ((ImageRawJPEG)this.image);
}
-
+
/** {@inheritDoc} */
public void setup(PDFDocument doc) {
pdfFilter = new DCTFilter();
@@ -88,12 +88,12 @@ public class ImageRawJPEGAdapter extends AbstractImageAdapter {
public boolean isInverted() {
return getImage().isInverted();
}
-
+
/** {@inheritDoc} */
public PDFFilter getPDFFilter() {
return pdfFilter;
}
-
+
/** {@inheritDoc} */
public void outputContents(OutputStream out) throws IOException {
InputStream in = getImage().createInputStream();
@@ -101,7 +101,7 @@ public class ImageRawJPEGAdapter extends AbstractImageAdapter {
try {
JPEGFile jpeg = new JPEGFile(in);
DataInput din = jpeg.getDataInput();
-
+
//Copy the whole JPEG file except:
// - the ICC profile
//TODO Thumbnails could safely be skipped, too.
@@ -149,7 +149,7 @@ public class ImageRawJPEGAdapter extends AbstractImageAdapter {
default:
out.write(0xFF);
out.write(segID);
-
+
reclen = jpeg.readSegmentLength();
//write short
out.write((reclen >>> 8) & 0xFF);
diff --git a/src/java/org/apache/fop/render/pdf/ImageRenderedAdapter.java b/src/java/org/apache/fop/render/pdf/ImageRenderedAdapter.java
index 62e83da81..e8988244f 100644
--- a/src/java/org/apache/fop/render/pdf/ImageRenderedAdapter.java
+++ b/src/java/org/apache/fop/render/pdf/ImageRenderedAdapter.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -52,7 +52,7 @@ public class ImageRenderedAdapter extends AbstractImageAdapter {
private static Log log = LogFactory.getLog(ImageRenderedAdapter.class);
private ImageEncodingHelper encodingHelper;
-
+
private PDFFilter pdfFilter = null;
private String maskRef;
private PDFReference softMask;
@@ -74,11 +74,11 @@ public class ImageRenderedAdapter extends AbstractImageAdapter {
public ImageRendered getImage() {
return ((ImageRendered)this.image);
}
-
+
private ColorModel getEffectiveColorModel() {
return encodingHelper.getEncodedColorModel();
}
-
+
/** {@inheritDoc} */
protected ColorSpace getImageColorSpace() {
return getEffectiveColorModel().getColorSpace();
@@ -90,14 +90,14 @@ public class ImageRenderedAdapter extends AbstractImageAdapter {
ColorModel cm = getEffectiveColorModel();
super.setup(doc);
-
+
//Handle transparency mask if applicable
- ColorModel orgcm = ri.getColorModel();
+ ColorModel orgcm = ri.getColorModel();
if (orgcm.hasAlpha() && orgcm.getTransparency() == ColorModel.TRANSLUCENT) {
doc.getProfile().verifyTransparencyAllowed(image.getInfo().getOriginalURI());
//TODO Implement code to combine image with background color if transparency is not
//allowed (need BufferedImage support for that)
-
+
AlphaRasterImage alphaImage = new AlphaRasterImage("Mask:" + getKey(), ri);
this.softMask = doc.addImage(null, alphaImage).makeReference();
}
@@ -130,7 +130,7 @@ public class ImageRenderedAdapter extends AbstractImageAdapter {
}
return (getImage().getTransparentColor() != null);
}
-
+
private static Integer getIndexOfFirstTransparentColorInPalette(RenderedImage image) {
ColorModel cm = image.getColorModel();
if (cm instanceof IndexColorModel) {
@@ -180,19 +180,19 @@ public class ImageRenderedAdapter extends AbstractImageAdapter {
public PDFReference getSoftMaskReference() {
return softMask;
}
-
+
/** {@inheritDoc} */
public PDFFilter getPDFFilter() {
return pdfFilter;
}
-
+
/** {@inheritDoc} */
public void outputContents(OutputStream out) throws IOException {
encodingHelper.encode(out);
}
private static final int MAX_HIVAL = 255;
-
+
/** {@inheritDoc} */
public void populateXObjectDictionary(PDFDictionary dict) {
ColorModel cm = getEffectiveColorModel();
@@ -200,11 +200,11 @@ public class ImageRenderedAdapter extends AbstractImageAdapter {
IndexColorModel icm = (IndexColorModel)cm;
PDFArray indexed = new PDFArray(dict);
indexed.add(new PDFName("Indexed"));
-
+
if (icm.getColorSpace().getType() != ColorSpace.TYPE_RGB) {
log.warn("Indexed color space is not using RGB as base color space."
+ " The image may not be handled correctly."
- + " Base color space: " + icm.getColorSpace()
+ + " Base color space: " + icm.getColorSpace()
+ " Image: " + image.getInfo());
}
indexed.add(new PDFName(toPDFColorSpace(icm.getColorSpace()).getName()));
@@ -229,7 +229,7 @@ public class ImageRenderedAdapter extends AbstractImageAdapter {
dict.put("ColorSpace", indexed);
dict.put("BitsPerComponent", icm.getPixelSize());
-
+
Integer index = getIndexOfFirstTransparentColorInPalette(getImage().getRenderedImage());
if (index != null) {
PDFArray mask = new PDFArray(dict);
@@ -239,7 +239,7 @@ public class ImageRenderedAdapter extends AbstractImageAdapter {
}
}
}
-
+
/** {@inheritDoc} */
public String getFilterHint() {
return PDFFilterList.IMAGE_FILTER;
diff --git a/src/java/org/apache/fop/render/pdf/PDFEventProducer.java b/src/java/org/apache/fop/render/pdf/PDFEventProducer.java
index f8b1bbb33..2c3be9736 100644
--- a/src/java/org/apache/fop/render/pdf/PDFEventProducer.java
+++ b/src/java/org/apache/fop/render/pdf/PDFEventProducer.java
@@ -31,7 +31,7 @@ public interface PDFEventProducer extends EventProducer {
/** Provider class for the event producer. */
class Provider {
-
+
/**
* Returns an event producer.
* @param broadcaster the event broadcaster to use
@@ -50,9 +50,9 @@ public interface PDFEventProducer extends EventProducer {
public EventModel createEventModel() {
return loadModel(getClass(), "event-model.xml");
}
-
+
}
-
+
/**
* Some link targets haven't been fully resolved.
* @param source the event source
@@ -60,5 +60,5 @@ public interface PDFEventProducer extends EventProducer {
* @event.severity WARN
*/
void nonFullyResolvedLinkTargets(Object source, int count);
-
+
}
diff --git a/src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java b/src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java
index c47b944d0..b61ebc346 100644
--- a/src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java
+++ b/src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
*/
/* $Id$ */
-
+
package org.apache.fop.render.pdf;
import java.awt.Color;
@@ -49,18 +49,18 @@ public class PDFGraphics2DAdapter extends AbstractGraphics2DAdapter {
public PDFGraphics2DAdapter(PDFRenderer renderer) {
this.renderer = renderer;
}
-
+
/** {@inheritDoc} */
public void paintImage(Graphics2DImagePainter painter,
RendererContext context,
int x, int y, int width, int height) throws IOException {
-
+
PDFSVGHandler.PDFInfo pdfInfo = PDFSVGHandler.getPDFInfo(context);
float fwidth = width / 1000f;
float fheight = height / 1000f;
float fx = x / 1000f;
float fy = y / 1000f;
-
+
// get the 'width' and 'height' attributes of the SVG document
Dimension dim = painter.getImageSize();
float imw = (float)dim.getWidth() / 1000f;
@@ -72,7 +72,7 @@ public class PDFGraphics2DAdapter extends AbstractGraphics2DAdapter {
renderer.saveGraphicsState();
renderer.setColor(Color.black, false, null);
renderer.setColor(Color.black, true, null);
-
+
//TODO Clip to the image area.
// transform so that the coordinates (0,0) is from the top left
@@ -86,13 +86,13 @@ public class PDFGraphics2DAdapter extends AbstractGraphics2DAdapter {
if (pdfInfo.pdfContext == null) {
pdfInfo.pdfContext = pdfInfo.pdfPage;
}
- PDFGraphics2D graphics = new PDFGraphics2D(textAsShapes,
+ PDFGraphics2D graphics = new PDFGraphics2D(textAsShapes,
pdfInfo.fi, pdfInfo.pdfDoc,
pdfInfo.pdfContext, pdfInfo.pdfPage.referencePDF(),
pdfInfo.currentFontName,
pdfInfo.currentFontSize);
graphics.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());
-
+
AffineTransform transform = new AffineTransform();
transform.translate(fx, fy);
pdfInfo.pdfState.concatenate(transform);
@@ -105,7 +105,7 @@ public class PDFGraphics2DAdapter extends AbstractGraphics2DAdapter {
RendererContextWrapper ctx = RendererContext.wrapRendererContext(context);
BufferedImage bi = paintToBufferedImage(painter, ctx, resolution, false, false);
- float scale = PDFRenderer.NORMAL_PDF_RESOLUTION
+ float scale = PDFRenderer.NORMAL_PDF_RESOLUTION
/ context.getUserAgent().getTargetResolution();
graphics.drawImage(bi, new AffineTransform(scale, 0, 0, scale, 0, 0), null);
} else {
@@ -121,9 +121,9 @@ public class PDFGraphics2DAdapter extends AbstractGraphics2DAdapter {
/** {@inheritDoc} */
protected void setRenderingHintsForBufferedImage(Graphics2D g2d) {
super.setRenderingHintsForBufferedImage(g2d);
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
- g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
+ g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
}
diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandler.java b/src/java/org/apache/fop/render/pdf/PDFImageHandler.java
index d62dcbc5b..f93ee5a97 100644
--- a/src/java/org/apache/fop/render/pdf/PDFImageHandler.java
+++ b/src/java/org/apache/fop/render/pdf/PDFImageHandler.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -41,19 +41,19 @@ public interface PDFImageHandler {
* @return a positive integer (>0) indicating the priority
*/
int getPriority();
-
+
/**
* Returns the {@link ImageFlavor}s supported by this instance
* @return the supported image flavors
*/
ImageFlavor[] getSupportedImageFlavors();
-
+
/**
* Returns the {@link Image} subclass supported by this instance.
* @return the Image type
*/
Class getSupportedImageClass();
-
+
/**
* Generates the PDF objects for the given {@link Image} instance. If the handler generates
* an XObject, it shall return it or otherwise return null. A generated XObject shall be
@@ -66,7 +66,7 @@ public interface PDFImageHandler {
* @return the generated XObject or null if no XObject was generated
* @throws IOException if an I/O error occurs
*/
- PDFXObject generateImage(RendererContext context, Image image,
+ PDFXObject generateImage(RendererContext context, Image image,
Point origin, Rectangle pos) throws IOException;
-
+
}
diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandlerGraphics2D.java b/src/java/org/apache/fop/render/pdf/PDFImageHandlerGraphics2D.java
index f1825297e..a58fe5922 100644
--- a/src/java/org/apache/fop/render/pdf/PDFImageHandlerGraphics2D.java
+++ b/src/java/org/apache/fop/render/pdf/PDFImageHandlerGraphics2D.java
@@ -38,9 +38,9 @@ public class PDFImageHandlerGraphics2D implements PDFImageHandler {
private static final ImageFlavor[] FLAVORS = new ImageFlavor[] {
ImageFlavor.GRAPHICS2D,
};
-
+
/** {@inheritDoc} */
- public PDFXObject generateImage(RendererContext context, Image image,
+ public PDFXObject generateImage(RendererContext context, Image image,
Point origin, Rectangle pos)
throws IOException {
PDFRenderer renderer = (PDFRenderer)context.getRenderer();
diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawCCITTFax.java b/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawCCITTFax.java
index 65142878a..9f56ebfea 100644
--- a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawCCITTFax.java
+++ b/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawCCITTFax.java
@@ -41,9 +41,9 @@ public class PDFImageHandlerRawCCITTFax implements PDFImageHandler {
private static final ImageFlavor[] FLAVORS = new ImageFlavor[] {
ImageFlavor.RAW_CCITTFAX,
};
-
+
/** {@inheritDoc} */
- public PDFXObject generateImage(RendererContext context, Image image,
+ public PDFXObject generateImage(RendererContext context, Image image,
Point origin, Rectangle pos)
throws IOException {
PDFRenderer renderer = (PDFRenderer)context.getRenderer();
@@ -52,7 +52,7 @@ public class PDFImageHandlerRawCCITTFax implements PDFImageHandler {
PDFRendererContextConstants.PDF_DOCUMENT);
PDFResourceContext resContext = (PDFResourceContext)context.getProperty(
PDFRendererContextConstants.PDF_CONTEXT);
-
+
PDFImage pdfimage = new ImageRawCCITTFaxAdapter(ccitt, image.getInfo().getOriginalURI());
PDFXObject xobj = pdfDoc.addImage(resContext, pdfimage);
@@ -61,7 +61,7 @@ public class PDFImageHandlerRawCCITTFax implements PDFImageHandler {
float w = (float)pos.getWidth() / 1000f;
float h = (float)pos.getHeight() / 1000f;
renderer.placeImage(x, y, w, h, xobj);
-
+
return xobj;
}
diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawJPEG.java b/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawJPEG.java
index 58c9f1f53..f971a49ae 100644
--- a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawJPEG.java
+++ b/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawJPEG.java
@@ -41,9 +41,9 @@ public class PDFImageHandlerRawJPEG implements PDFImageHandler {
private static final ImageFlavor[] FLAVORS = new ImageFlavor[] {
ImageFlavor.RAW_JPEG,
};
-
+
/** {@inheritDoc} */
- public PDFXObject generateImage(RendererContext context, Image image,
+ public PDFXObject generateImage(RendererContext context, Image image,
Point origin, Rectangle pos)
throws IOException {
PDFRenderer renderer = (PDFRenderer)context.getRenderer();
@@ -52,7 +52,7 @@ public class PDFImageHandlerRawJPEG implements PDFImageHandler {
PDFRendererContextConstants.PDF_DOCUMENT);
PDFResourceContext resContext = (PDFResourceContext)context.getProperty(
PDFRendererContextConstants.PDF_CONTEXT);
-
+
PDFImage pdfimage = new ImageRawJPEGAdapter(jpeg, image.getInfo().getOriginalURI());
PDFXObject xobj = pdfDoc.addImage(resContext, pdfimage);
@@ -61,7 +61,7 @@ public class PDFImageHandlerRawJPEG implements PDFImageHandler {
float w = (float)pos.getWidth() / 1000f;
float h = (float)pos.getHeight() / 1000f;
renderer.placeImage(x, y, w, h, xobj);
-
+
return xobj;
}
diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRegistry.java b/src/java/org/apache/fop/render/pdf/PDFImageHandlerRegistry.java
index 536fc19b0..b664a0a24 100644
--- a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRegistry.java
+++ b/src/java/org/apache/fop/render/pdf/PDFImageHandlerRegistry.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -41,7 +41,7 @@ public class PDFImageHandlerRegistry {
/** the logger */
private static Log log = LogFactory.getLog(PDFImageHandlerRegistry.class);
-
+
private static final Comparator HANDLER_COMPARATOR = new Comparator() {
public int compare(Object o1, Object o2) {
PDFImageHandler h1 = (PDFImageHandler)o1;
@@ -54,19 +54,19 @@ public class PDFImageHandlerRegistry {
private Map handlers = new java.util.HashMap();
/** List containing the same handlers as above but ordered by priority */
private List handlerList = new java.util.LinkedList();
-
+
/** Sorted Set of registered handlers */
private ImageFlavor[] supportedFlavors = new ImageFlavor[0];
private int handlerRegistrations;
private int lastSync;
-
+
/**
* Default constructor.
*/
public PDFImageHandlerRegistry() {
discoverHandlers();
}
-
+
/**
* Add an PDFImageHandler. The handler itself is inspected to find out what it supports.
* @param classname the fully qualified class name
@@ -87,11 +87,11 @@ public class PDFImageHandlerRegistry {
+ classname);
} catch (ClassCastException e) {
throw new IllegalArgumentException(classname
- + " is not an "
+ + " is not an "
+ PDFImageHandler.class.getName());
}
}
-
+
/**
* Add an image handler. The handler itself is inspected to find out what it supports.
* @param handler the PDFImageHandler instance
@@ -99,7 +99,7 @@ public class PDFImageHandlerRegistry {
public synchronized void addHandler(PDFImageHandler handler) {
Class imageClass = handler.getSupportedImageClass();
this.handlers.put(imageClass, handler);
-
+
//Sorted insert
ListIterator iter = this.handlerList.listIterator();
while (iter.hasNext()) {
@@ -112,7 +112,7 @@ public class PDFImageHandlerRegistry {
iter.add(handler);
this.handlerRegistrations++;
}
-
+
/**
* Returns an PDFImageHandler which handles an specific image type given the MIME type
* of the image.
@@ -143,7 +143,7 @@ public class PDFImageHandlerRegistry {
}
/**
- * Returns the ordered array of supported image flavors.
+ * Returns the ordered array of supported image flavors.
* @return the array of image flavors
*/
public synchronized ImageFlavor[] getSupportedFlavors() {
@@ -162,7 +162,7 @@ public class PDFImageHandlerRegistry {
}
return this.supportedFlavors;
}
-
+
/**
* Discovers PDFImageHandler implementations through the classpath and dynamically
* registers them.
@@ -175,7 +175,7 @@ public class PDFImageHandlerRegistry {
PDFImageHandler handler = (PDFImageHandler)providers.next();
try {
if (log.isDebugEnabled()) {
- log.debug("Dynamically adding PDFImageHandler: "
+ log.debug("Dynamically adding PDFImageHandler: "
+ handler.getClass().getName());
}
addHandler(handler);
diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRenderedImage.java b/src/java/org/apache/fop/render/pdf/PDFImageHandlerRenderedImage.java
index 628883b9f..783cb225c 100644
--- a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRenderedImage.java
+++ b/src/java/org/apache/fop/render/pdf/PDFImageHandlerRenderedImage.java
@@ -40,11 +40,11 @@ public class PDFImageHandlerRenderedImage implements PDFImageHandler {
private static final ImageFlavor[] FLAVORS = new ImageFlavor[] {
ImageFlavor.BUFFERED_IMAGE,
- ImageFlavor.RENDERED_IMAGE
+ ImageFlavor.RENDERED_IMAGE
};
-
+
/** {@inheritDoc} */
- public PDFXObject generateImage(RendererContext context, Image image,
+ public PDFXObject generateImage(RendererContext context, Image image,
Point origin, Rectangle pos)
throws IOException {
PDFRenderer renderer = (PDFRenderer)context.getRenderer();
@@ -53,7 +53,7 @@ public class PDFImageHandlerRenderedImage implements PDFImageHandler {
PDFRendererContextConstants.PDF_DOCUMENT);
PDFResourceContext resContext = (PDFResourceContext)context.getProperty(
PDFRendererContextConstants.PDF_CONTEXT);
-
+
PDFImage pdfimage = new ImageRenderedAdapter(imageRend, image.getInfo().getOriginalURI());
PDFXObject xobj = pdfDoc.addImage(resContext, pdfimage);
@@ -62,7 +62,7 @@ public class PDFImageHandlerRenderedImage implements PDFImageHandler {
float w = (float)pos.getWidth() / 1000f;
float h = (float)pos.getHeight() / 1000f;
renderer.placeImage(x, y, w, h, xobj);
-
+
return xobj;
}
diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandlerXML.java b/src/java/org/apache/fop/render/pdf/PDFImageHandlerXML.java
index ba47cce69..d111e733f 100644
--- a/src/java/org/apache/fop/render/pdf/PDFImageHandlerXML.java
+++ b/src/java/org/apache/fop/render/pdf/PDFImageHandlerXML.java
@@ -41,9 +41,9 @@ public class PDFImageHandlerXML implements PDFImageHandler {
private static final ImageFlavor[] FLAVORS = new ImageFlavor[] {
ImageFlavor.XML_DOM,
};
-
+
/** {@inheritDoc} */
- public PDFXObject generateImage(RendererContext context, Image image,
+ public PDFXObject generateImage(RendererContext context, Image image,
Point origin, Rectangle pos)
throws IOException {
PDFRenderer renderer = (PDFRenderer)context.getRenderer();
diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderer.java b/src/java/org/apache/fop/render/pdf/PDFRenderer.java
index c3e4a9657..27caf86b4 100644
--- a/src/java/org/apache/fop/render/pdf/PDFRenderer.java
+++ b/src/java/org/apache/fop/render/pdf/PDFRenderer.java
@@ -122,7 +122,7 @@ import org.apache.fop.util.ColorProfileUtil;
* Renderer that renders areas to PDF.
*/
public class PDFRenderer extends AbstractPathOrientedRenderer {
-
+
/**
* The mime type for pdf
*/
@@ -130,7 +130,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
/** Normal PDF resolution (72dpi) */
public static final int NORMAL_PDF_RESOLUTION = 72;
-
+
/** PDF encryption parameter: all parameters as object, datatype: PDFEncryptionParams */
public static final String ENCRYPTION_PARAMS = "encryption-params";
/** PDF encryption parameter: user password, datatype: String */
@@ -159,7 +159,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
/** Controls whether comments are written to the PDF stream. */
protected static final boolean WRITE_COMMENTS = true;
-
+
/**
* the PDF Document being created
*/
@@ -167,10 +167,10 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
/** the PDF/A mode (Default: disabled) */
protected PDFAMode pdfAMode = PDFAMode.DISABLED;
-
+
/** the PDF/X mode (Default: disabled) */
protected PDFXMode pdfXMode = PDFXMode.DISABLED;
-
+
/**
* Map of pages using the PageViewport as the key
* this is used for prepared pages that cannot be immediately
@@ -246,10 +246,10 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
protected PDFICCBasedColorSpace sRGBColorSpace;
/** controls whether the sRGB color space should be installed */
protected boolean disableSRGBColorSpace = false;
-
+
/** Optional URI to an output profile to be used. */
- protected String outputProfileURI;
-
+ protected String outputProfileURI;
+
/** drawing state */
protected PDFState currentState = null;
@@ -263,7 +263,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
/** Image handler registry */
private PDFImageHandlerRegistry imageHandlerRegistry = new PDFImageHandlerRegistry();
-
+
/**
* create the PDF renderer
*/
@@ -279,13 +279,13 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
throw new IllegalArgumentException("Boolean or \"true\" or \"false\" expected.");
}
}
-
+
/**
* {@inheritDoc}
*/
public void setUserAgent(FOUserAgent agent) {
super.setUserAgent(agent);
- PDFEncryptionParams params
+ PDFEncryptionParams params
= (PDFEncryptionParams)agent.getRendererOptions().get(ENCRYPTION_PARAMS);
if (params != null) {
this.encryptionParams = params; //overwrite if available
@@ -381,7 +381,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
}
if (pdfXMode != PDFXMode.DISABLED) {
log.debug(pdfXMode + " is active.");
- log.warn("Note: " + pdfXMode
+ log.warn("Note: " + pdfXMode
+ " support is work-in-progress and not fully implemented, yet!");
addPDFXOutputIntent();
}
@@ -389,7 +389,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
log.debug("PDF/A is active. Conformance Level: " + pdfAMode);
addPDFA1OutputIntent();
}
-
+
}
private void addsRGBColorSpace() throws IOException {
@@ -409,7 +409,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
this.sRGBColorSpace = PDFICCBasedColorSpace.setupsRGBAsDefaultRGBColorSpace(pdfDoc);
}
}
-
+
private void addDefaultOutputProfile() throws IOException {
if (this.outputProfile != null) {
return;
@@ -438,7 +438,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
outputProfile = sRGBColorSpace.getICCStream();
}
}
-
+
/**
* Adds an OutputIntent to the PDF as mandated by PDF/A-1 when uncalibrated color spaces
* are used (which is true if we use DeviceRGB to represent sRGB colors).
@@ -446,7 +446,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
*/
private void addPDFA1OutputIntent() throws IOException {
addDefaultOutputProfile();
-
+
String desc = ColorProfileUtil.getICCProfileDescription(this.outputProfile.getICCProfile());
PDFOutputIntent outputIntent = pdfDoc.getFactory().makeOutputIntent();
outputIntent.setSubtype(PDFOutputIntent.GTS_PDFA1);
@@ -463,7 +463,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
*/
private void addPDFXOutputIntent() throws IOException {
addDefaultOutputProfile();
-
+
String desc = ColorProfileUtil.getICCProfileDescription(this.outputProfile.getICCProfile());
int deviceClass = this.outputProfile.getICCProfile().getProfileClass();
if (deviceClass != ICC_Profile.CLASS_OUTPUT) {
@@ -627,7 +627,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
return new PDFGraphics2DAdapter(this);
}
- /**
+ /**
* writes out a comment.
* @param text text for the comment
*/
@@ -738,7 +738,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
page.getPageIndex());
pageReferences.put(page.getKey(), currentPage.referencePDF());
pvReferences.put(page.getKey(), page);
-
+
//Produce page labels
PDFPageLabels pageLabels = this.pdfDoc.getRoot().getPageLabels();
if (pageLabels == null) {
@@ -746,14 +746,14 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
pageLabels = this.pdfDoc.getFactory().makePageLabels();
this.pdfDoc.getRoot().setPageLabels(pageLabels);
}
- PDFNumsArray nums = pageLabels.getNums();
+ PDFNumsArray nums = pageLabels.getNums();
PDFDictionary dict = new PDFDictionary(nums);
dict.put("P", page.getPageNumberString());
//TODO If the sequence of generated page numbers were inspected, this could be
//expressed in a more space-efficient way
nums.put(page.getPageIndex(), dict);
}
-
+
/**
* This method creates a pdf stream for the current page
* uses it as the contents of a new page. The page is written
@@ -789,7 +789,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
pageHeight / 1000f);
currentState.concatenate(basicPageTransform);
currentStream.add(CTMHelper.toPDFString(basicPageTransform, false) + " cm\n");
-
+
super.renderPage(page);
this.pdfDoc.registerObject(currentStream);
@@ -811,9 +811,9 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
new AffineTransform(CTMHelper.toPDFArray(ctm)));
if (clippingRect != null) {
- clipRect((float)clippingRect.getX() / 1000f,
- (float)clippingRect.getY() / 1000f,
- (float)clippingRect.getWidth() / 1000f,
+ clipRect((float)clippingRect.getX() / 1000f,
+ (float)clippingRect.getY() / 1000f,
+ (float)clippingRect.getWidth() / 1000f,
(float)clippingRect.getHeight() / 1000f);
}
// multiply with current CTM
@@ -832,7 +832,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
currentStream.add(CTMHelper.toPDFString(at, false) + " cm\n");
}
}
-
+
/**
* Formats a float value (normally coordinates) as Strings.
* @param value the value
@@ -841,9 +841,9 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
protected static String format(float value) {
return PDFNumber.doubleOut(value);
}
-
+
/** {@inheritDoc} */
- protected void drawBorderLine(float x1, float y1, float x2, float y2,
+ protected void drawBorderLine(float x1, float y1, float x2, float y2,
boolean horz, boolean startOrBefore, int style, Color col) {
float w = x2 - x1;
float h = y2 - y1;
@@ -853,7 +853,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
return;
}
switch (style) {
- case Constants.EN_DASHED:
+ case Constants.EN_DASHED:
setColor(col, false, null);
if (horz) {
float unit = Math.abs(2 * h);
@@ -865,7 +865,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
currentStream.add("[" + format(unit) + "] 0 d ");
currentStream.add(format(h) + " w\n");
float ym = y1 + (h / 2);
- currentStream.add(format(x1) + " " + format(ym) + " m "
+ currentStream.add(format(x1) + " " + format(ym) + " m "
+ format(x2) + " " + format(ym) + " l S\n");
} else {
float unit = Math.abs(2 * w);
@@ -877,7 +877,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
currentStream.add("[" + format(unit) + "] 0 d ");
currentStream.add(format(w) + " w\n");
float xm = x1 + (w / 2);
- currentStream.add(format(xm) + " " + format(y1) + " m "
+ currentStream.add(format(xm) + " " + format(y1) + " m "
+ format(xm) + " " + format(y2) + " l S\n");
}
break;
@@ -894,7 +894,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
currentStream.add("[0 " + format(unit) + "] 0 d ");
currentStream.add(format(h) + " w\n");
float ym = y1 + (h / 2);
- currentStream.add(format(x1) + " " + format(ym) + " m "
+ currentStream.add(format(x1) + " " + format(ym) + " m "
+ format(x2) + " " + format(ym) + " l S\n");
} else {
float unit = Math.abs(2 * w);
@@ -906,7 +906,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
currentStream.add("[0 " + format(unit) + " ] 0 d ");
currentStream.add(format(w) + " w\n");
float xm = x1 + (w / 2);
- currentStream.add(format(xm) + " " + format(y1) + " m "
+ currentStream.add(format(xm) + " " + format(y1) + " m "
+ format(xm) + " " + format(y2) + " l S\n");
}
break;
@@ -918,18 +918,18 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
currentStream.add(format(h3) + " w\n");
float ym1 = y1 + (h3 / 2);
float ym2 = ym1 + h3 + h3;
- currentStream.add(format(x1) + " " + format(ym1) + " m "
+ currentStream.add(format(x1) + " " + format(ym1) + " m "
+ format(x2) + " " + format(ym1) + " l S\n");
- currentStream.add(format(x1) + " " + format(ym2) + " m "
+ currentStream.add(format(x1) + " " + format(ym2) + " m "
+ format(x2) + " " + format(ym2) + " l S\n");
} else {
float w3 = w / 3;
currentStream.add(format(w3) + " w\n");
float xm1 = x1 + (w3 / 2);
float xm2 = xm1 + w3 + w3;
- currentStream.add(format(xm1) + " " + format(y1) + " m "
+ currentStream.add(format(xm1) + " " + format(y1) + " m "
+ format(xm1) + " " + format(y2) + " l S\n");
- currentStream.add(format(xm2) + " " + format(y1) + " m "
+ currentStream.add(format(xm2) + " " + format(y1) + " m "
+ format(xm2) + " " + format(y2) + " l S\n");
}
break;
@@ -945,13 +945,13 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
currentStream.add(format(h3) + " w\n");
float ym1 = y1 + (h3 / 2);
setColor(uppercol, false, null);
- currentStream.add(format(x1) + " " + format(ym1) + " m "
+ currentStream.add(format(x1) + " " + format(ym1) + " m "
+ format(x2) + " " + format(ym1) + " l S\n");
setColor(col, false, null);
- currentStream.add(format(x1) + " " + format(ym1 + h3) + " m "
+ currentStream.add(format(x1) + " " + format(ym1 + h3) + " m "
+ format(x2) + " " + format(ym1 + h3) + " l S\n");
setColor(lowercol, false, null);
- currentStream.add(format(x1) + " " + format(ym1 + h3 + h3) + " m "
+ currentStream.add(format(x1) + " " + format(ym1 + h3 + h3) + " m "
+ format(x2) + " " + format(ym1 + h3 + h3) + " l S\n");
} else {
Color leftcol = lightenColor(col, -colFactor);
@@ -960,13 +960,13 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
currentStream.add(format(w3) + " w\n");
float xm1 = x1 + (w3 / 2);
setColor(leftcol, false, null);
- currentStream.add(format(xm1) + " " + format(y1) + " m "
+ currentStream.add(format(xm1) + " " + format(y1) + " m "
+ format(xm1) + " " + format(y2) + " l S\n");
setColor(col, false, null);
- currentStream.add(format(xm1 + w3) + " " + format(y1) + " m "
+ currentStream.add(format(xm1 + w3) + " " + format(y1) + " m "
+ format(xm1 + w3) + " " + format(y2) + " l S\n");
setColor(rightcol, false, null);
- currentStream.add(format(xm1 + w3 + w3) + " " + format(y1) + " m "
+ currentStream.add(format(xm1 + w3 + w3) + " " + format(y1) + " m "
+ format(xm1 + w3 + w3) + " " + format(y2) + " l S\n");
}
break;
@@ -982,14 +982,14 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
currentStream.add(format(h) + " w\n");
float ym1 = y1 + (h / 2);
setColor(c, false, null);
- currentStream.add(format(x1) + " " + format(ym1) + " m "
+ currentStream.add(format(x1) + " " + format(ym1) + " m "
+ format(x2) + " " + format(ym1) + " l S\n");
} else {
c = lightenColor(c, (startOrBefore ? 1 : -1) * colFactor);
currentStream.add(format(w) + " w\n");
float xm1 = x1 + (w / 2);
setColor(c, false, null);
- currentStream.add(format(xm1) + " " + format(y1) + " m "
+ currentStream.add(format(xm1) + " " + format(y1) + " m "
+ format(xm1) + " " + format(y2) + " l S\n");
}
break;
@@ -1002,17 +1002,17 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
if (horz) {
currentStream.add(format(h) + " w\n");
float ym = y1 + (h / 2);
- currentStream.add(format(x1) + " " + format(ym) + " m "
+ currentStream.add(format(x1) + " " + format(ym) + " m "
+ format(x2) + " " + format(ym) + " l S\n");
} else {
currentStream.add(format(w) + " w\n");
float xm = x1 + (w / 2);
- currentStream.add(format(xm) + " " + format(y1) + " m "
+ currentStream.add(format(xm) + " " + format(y1) + " m "
+ format(xm) + " " + format(y2) + " l S\n");
}
}
}
-
+
/**
* Sets the current line width in points.
* @param width line width in points
@@ -1023,10 +1023,10 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
currentStream.add(format(width) + " w\n");
}
}
-
+
/** {@inheritDoc} */
protected void clipRect(float x, float y, float width, float height) {
- currentStream.add(format(x) + " " + format(y) + " "
+ currentStream.add(format(x) + " " + format(y) + " "
+ format(width) + " " + format(height) + " re ");
clip();
}
@@ -1040,42 +1040,42 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
}
/**
- * Moves the current point to (x, y), omitting any connecting line segment.
+ * Moves the current point to (x, y), omitting any connecting line segment.
* @param x x coordinate
* @param y y coordinate
*/
protected void moveTo(float x, float y) {
currentStream.add(format(x) + " " + format(y) + " m ");
}
-
+
/**
- * Appends a straight line segment from the current point to (x, y). The
- * new current point is (x, y).
+ * Appends a straight line segment from the current point to (x, y). The
+ * new current point is (x, y).
* @param x x coordinate
* @param y y coordinate
*/
protected void lineTo(float x, float y) {
currentStream.add(format(x) + " " + format(y) + " l ");
}
-
+
/**
- * Closes the current subpath by appending a straight line segment from
+ * Closes the current subpath by appending a straight line segment from
* the current point to the starting point of the subpath.
*/
protected void closePath() {
currentStream.add("h ");
}
- /**
- * {@inheritDoc}
+ /**
+ * {@inheritDoc}
*/
protected void fillRect(float x, float y, float width, float height) {
if (width > 0 && height > 0) {
- currentStream.add(format(x) + " " + format(y) + " "
+ currentStream.add(format(x) + " " + format(y) + " "
+ format(width) + " " + format(height) + " re f\n");
}
}
-
+
/**
* Draw a line.
*
@@ -1131,7 +1131,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
}
/**
- * Returns area's id if it is the first area in the document with that id
+ * Returns area's id if it is the first area in the document with that id
* (i.e. if the area qualifies as a link target).
* Otherwise, or if the area has no id, null is returned.
*
@@ -1216,7 +1216,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
* @param pdfPageRef the PDF page reference string
* @param relativeIPP the *relative* IP position in millipoints
* @param relativeBPP the *relative* BP position in millipoints
- * @param tf the transformation to apply once the relative positions have been
+ * @param tf the transformation to apply once the relative positions have been
* converted to points
*/
protected void saveAbsolutePosition(String id, String pdfPageRef,
@@ -1258,13 +1258,13 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
* @param relativeBPP the *relative* BP position in millipoints
*/
protected void saveAbsolutePosition(String id, int relativeIPP, int relativeBPP) {
- saveAbsolutePosition(id, currentPageRef,
+ saveAbsolutePosition(id, currentPageRef,
relativeIPP, relativeBPP, currentState.getTransform());
}
/**
- * If the given block area is a possible link target, its id + absolute position will
- * be saved. The saved position is only correct if this function is called at the very
+ * If the given block area is a possible link target, its id + absolute position will
+ * be saved. The saved position is only correct if this function is called at the very
* start of renderBlock!
*
* @param block the block area in question
@@ -1392,7 +1392,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
// warn if link trait found but not allowed, else create link
if (linkTraitFound) {
if (!annotsAllowed) {
- log.warn("Skipping annotation for a link due to PDF profile: "
+ log.warn("Skipping annotation for a link due to PDF profile: "
+ pdfDoc.getProfile());
} else if (action != null) {
PDFLink pdfLink = factory.makeLink(ipRect, action);
@@ -1408,23 +1408,23 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
}
return tf;
}
-
+
/** {@inheritDoc} */
public void renderText(TextArea text) {
renderInlineAreaBackAndBorders(text);
Color ct = (Color) text.getTrait(Trait.COLOR);
updateColor(ct, true);
-
+
beginTextObject();
String fontName = getInternalFontNameForArea(text);
int size = ((Integer) text.getTrait(Trait.FONT_SIZE)).intValue();
-
+
// This assumes that *all* CIDFonts use a /ToUnicode mapping
Typeface tf = getTypeface(fontName);
-
+
textutil.updateTf(fontName, size / 1000f, tf.isMultiByte());
-
+
// word.getOffset() = only height of text itself
// currentBlockIPPosition: 0 for beginning of line; nonzero
@@ -1437,7 +1437,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
super.renderText(text);
textutil.writeTJ();
-
+
renderTextDecoration(tf, size, text, bl, rx);
}
@@ -1446,7 +1446,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
Font font = getFontFromArea(word.getParentArea());
String s = word.getWord();
- escapeText(s, word.getLetterAdjustArray(),
+ escapeText(s, word.getLetterAdjustArray(),
font, (AbstractTextArea)word.getParentArea());
super.renderWord(word);
@@ -1456,7 +1456,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
public void renderSpace(SpaceArea space) {
Font font = getFontFromArea(space.getParentArea());
String s = space.getSpace();
-
+
AbstractTextArea textArea = (AbstractTextArea)space.getParentArea();
escapeText(s, null, font, textArea);
@@ -1485,7 +1485,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
Font font, AbstractTextArea parentArea) {
escapeText(s, 0, s.length(), letterAdjust, font, parentArea);
}
-
+
/**
* Escapes text according to PDF rules.
* @param s Text to escape
@@ -1507,7 +1507,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
}
int l = s.length();
-
+
for (int i = start; i < end; i++) {
char orgChar = s.charAt(i);
char ch;
@@ -1553,7 +1553,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
/**
* Establishes a new foreground or fill color. In contrast to updateColor
* this method does not check the PDFState for optimization possibilities.
- * @param col the color to apply
+ * @param col the color to apply
* @param fill true to set the fill color, false for the foreground color
* @param pdf StringBuffer to write the PDF code to, if null, the code is
* written to the current stream.
@@ -1567,7 +1567,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
currentStream.add(color.getColorSpaceOut(fill));
}
}
-
+
/**
* Establishes a new foreground or fill color.
* @param col the color to apply (null skips this operation)
@@ -1595,7 +1595,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
protected void updateColor(Color col, boolean fill) {
updateColor(col, fill, null);
}
-
+
/** {@inheritDoc} */
public void renderImage(Image image, Rectangle2D pos) {
endTextObject();
@@ -1618,7 +1618,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
protected void putImage(String uri, Rectangle2D pos) {
putImage(uri, pos, null);
}
-
+
/**
* Adds a PDF XObject (a bitmap or form) to the PDF that will later be referenced.
* @param uri URL of the bitmap
@@ -1650,11 +1650,11 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
try {
ImageSessionContext sessionContext = getUserAgent().getImageSessionContext();
info = manager.getImageInfo(uri, sessionContext);
-
+
Map hints = ImageUtil.getDefaultHints(sessionContext);
org.apache.xmlgraphics.image.loader.Image img = manager.getImage(
info, imageHandlerRegistry.getSupportedFlavors(), hints, sessionContext);
-
+
//First check for a dynamically registered handler
PDFImageHandler handler = imageHandlerRegistry.getHandler(img.getClass());
if (handler != null) {
@@ -1712,13 +1712,13 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
currentStream.add(format(w) + " 0 0 "
+ format(-h) + " "
+ format(currentIPPosition / 1000f + x) + " "
- + format(currentBPPosition / 1000f + h + y)
+ + format(currentBPPosition / 1000f + h + y)
+ " cm\n" + xobj.getName() + " Do\n");
restoreGraphicsState();
}
/** {@inheritDoc} */
- protected RendererContext createRendererContext(int x, int y, int width, int height,
+ protected RendererContext createRendererContext(int x, int y, int width, int height,
Map foreignAttributes) {
RendererContext context = super.createRendererContext(
x, y, width, height, foreignAttributes);
@@ -1749,7 +1749,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
int style = area.getRuleStyle();
float startx = (currentIPPosition + area.getBorderAndPaddingWidthStart()) / 1000f;
float starty = (currentBPPosition + area.getOffset()) / 1000f;
- float endx = (currentIPPosition + area.getBorderAndPaddingWidthStart()
+ float endx = (currentIPPosition + area.getBorderAndPaddingWidthStart()
+ area.getIPD()) / 1000f;
float ruleThickness = area.getRuleThickness() / 1000f;
Color col = (Color)area.getTrait(Trait.COLOR);
@@ -1758,7 +1758,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
case EN_SOLID:
case EN_DASHED:
case EN_DOUBLE:
- drawBorderLine(startx, starty, endx, starty + ruleThickness,
+ drawBorderLine(startx, starty, endx, starty + ruleThickness,
true, true, style, col);
break;
case EN_DOTTED:
@@ -1766,7 +1766,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
//This displaces the dots to the right by half a dot's width
//TODO There's room for improvement here
currentStream.add("1 0 0 1 " + format(ruleThickness / 2) + " 0 cm\n");
- drawBorderLine(startx, starty, endx, starty + ruleThickness,
+ drawBorderLine(startx, starty, endx, starty + ruleThickness,
true, true, style, col);
break;
case EN_GROOVE:
@@ -1811,7 +1811,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
public String getMimeType() {
return MIME_TYPE;
}
-
+
/**
* Sets the PDF/A mode for the PDF renderer.
* @param mode the PDF/A mode
@@ -1825,7 +1825,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
* @param mode the PDF/X mode
*/
public void setXMode(PDFXMode mode) {
- this.pdfXMode = mode;
+ this.pdfXMode = mode;
}
/**
@@ -1846,7 +1846,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
/**
* Sets the encryption parameters used by the PDF renderer.
- * @param encryptionParams the encryption parameters
+ * @param encryptionParams the encryption parameters
*/
public void setEncryptionParams(PDFEncryptionParams encryptionParams) {
this.encryptionParams = encryptionParams;
diff --git a/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java b/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java
index 826f610c8..8d1042f7f 100644
--- a/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java
+++ b/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -36,7 +36,7 @@ import org.apache.fop.render.Renderer;
import org.apache.fop.util.LogUtil;
/**
- * PDF renderer configurator
+ * PDF renderer configurator
*/
public class PDFRendererConfigurator extends PrintRendererConfigurator {
@@ -70,9 +70,9 @@ public class PDFRendererConfigurator extends PrintRendererConfigurator {
} catch (ConfigurationException e) {
LogUtil.handleException(log, e, false);
}
-
+
super.configure(renderer);
-
+
String s = cfg.getChild(PDFRenderer.PDF_A_MODE, true).getValue(null);
if (s != null) {
pdfRenderer.setAMode(PDFAMode.valueOf(s));
@@ -143,7 +143,7 @@ public class PDFRendererConfigurator extends PrintRendererConfigurator {
* @return Map the newly built filter map
* @throws ConfigurationException if a filter list is defined twice
*/
- public static Map buildFilterMapFromConfiguration(Configuration cfg)
+ public static Map buildFilterMapFromConfiguration(Configuration cfg)
throws ConfigurationException {
Map filterMap = new java.util.HashMap();
Configuration[] filterLists = cfg.getChildren("filterList");
@@ -156,11 +156,11 @@ public class PDFRendererConfigurator extends PrintRendererConfigurator {
String name = filt[j].getValue();
filterList.add(name);
}
-
+
if (type == null) {
type = PDFFilterList.DEFAULT_FILTER;
}
-
+
if (!filterList.isEmpty() && log.isDebugEnabled()) {
StringBuffer debug = new StringBuffer("Adding PDF filter");
if (filterList.size() != 1) {
@@ -175,13 +175,13 @@ public class PDFRendererConfigurator extends PrintRendererConfigurator {
}
log.debug(debug.toString());
}
-
+
if (filterMap.get(type) != null) {
- throw new ConfigurationException("A filterList of type '"
+ throw new ConfigurationException("A filterList of type '"
+ type + "' has already been defined");
}
filterMap.put(type, filterList);
}
- return filterMap;
+ return filterMap;
}
}
diff --git a/src/java/org/apache/fop/render/pdf/PDFRendererContextConstants.java b/src/java/org/apache/fop/render/pdf/PDFRendererContextConstants.java
index d3efa9667..de51aabc7 100644
--- a/src/java/org/apache/fop/render/pdf/PDFRendererContextConstants.java
+++ b/src/java/org/apache/fop/render/pdf/PDFRendererContextConstants.java
@@ -49,5 +49,5 @@ public interface PDFRendererContextConstants extends RendererContextConstants {
/** The current pdf font size. */
String PDF_FONT_SIZE = "fontSize";
-
+
}
diff --git a/src/java/org/apache/fop/render/pdf/PDFRendererMaker.java b/src/java/org/apache/fop/render/pdf/PDFRendererMaker.java
index 98fd7b5db..fb65c9d74 100644
--- a/src/java/org/apache/fop/render/pdf/PDFRendererMaker.java
+++ b/src/java/org/apache/fop/render/pdf/PDFRendererMaker.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -31,7 +31,7 @@ import org.apache.fop.render.RendererConfigurator;
public class PDFRendererMaker extends AbstractRendererMaker {
private static final String[] MIMES = new String[] {MimeConstants.MIME_PDF};
-
+
/** {@inheritDoc} */
public Renderer makeRenderer(FOUserAgent userAgent) {
return new PDFRenderer();
@@ -41,7 +41,7 @@ public class PDFRendererMaker extends AbstractRendererMaker {
public RendererConfigurator getConfigurator(FOUserAgent userAgent) {
return new PDFRendererConfigurator(userAgent);
}
-
+
/** {@inheritDoc} */
public boolean needsOutputStream() {
return true;
diff --git a/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java b/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java
index 73b50e323..e31628160 100644
--- a/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java
+++ b/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -62,7 +62,7 @@ import org.apache.fop.svg.SVGUserAgent;
* It renders SVG to the PDF document using the PDFGraphics2D.
* The properties from the PDF renderer are subject to change.
*/
-public class PDFSVGHandler extends AbstractGenericSVGHandler
+public class PDFSVGHandler extends AbstractGenericSVGHandler
implements PDFRendererContextConstants {
/** logging instance */
@@ -93,7 +93,7 @@ public class PDFSVGHandler extends AbstractGenericSVGHandler
Map foreign = (Map)context.getProperty(RendererContextConstants.FOREIGN_ATTRIBUTES);
QName qName = new QName(ExtensionElementMapping.URI, null, "conversion-mode");
- if (foreign != null
+ if (foreign != null
&& "bitmap".equalsIgnoreCase((String)foreign.get(qName))) {
pdfi.paintAsBitmap = true;
}
@@ -156,12 +156,12 @@ public class PDFSVGHandler extends AbstractGenericSVGHandler
int xOffset = pdfInfo.currentXPosition;
int yOffset = pdfInfo.currentYPosition;
- FOUserAgent userAgent = context.getUserAgent();
+ FOUserAgent userAgent = context.getUserAgent();
final float deviceResolution = userAgent.getTargetResolution();
if (log.isDebugEnabled()) {
log.debug("Generating SVG at " + deviceResolution + "dpi.");
}
-
+
final float uaResolution = userAgent.getSourceResolution();
SVGUserAgent ua = new SVGUserAgent(userAgent, new AffineTransform());
@@ -169,22 +169,22 @@ public class PDFSVGHandler extends AbstractGenericSVGHandler
double s = uaResolution / deviceResolution;
AffineTransform resolutionScaling = new AffineTransform();
resolutionScaling.scale(s, s);
-
+
GVTBuilder builder = new GVTBuilder();
-
+
//Controls whether text painted by Batik is generated using text or path operations
boolean strokeText = false;
Configuration cfg = pdfInfo.cfg;
if (cfg != null) {
strokeText = cfg.getChild("stroke-text", true).getValueAsBoolean(strokeText);
}
-
- BridgeContext ctx = new PDFBridgeContext(ua,
+
+ BridgeContext ctx = new PDFBridgeContext(ua,
(strokeText ? null : pdfInfo.fi),
userAgent.getFactory().getImageManager(),
userAgent.getImageSessionContext(),
new AffineTransform());
-
+
GraphicsNode root;
try {
root = builder.build(ctx, doc);
@@ -211,7 +211,7 @@ public class PDFSVGHandler extends AbstractGenericSVGHandler
AffineTransform imageTransform = new AffineTransform();
imageTransform.concatenate(scaling);
imageTransform.concatenate(resolutionScaling);
-
+
/*
* Clip to the svg area.
* Note: To have the svg overlay (under) a text area then use
@@ -232,27 +232,27 @@ public class PDFSVGHandler extends AbstractGenericSVGHandler
if (pdfInfo.pdfContext == null) {
pdfInfo.pdfContext = pdfInfo.pdfPage;
}
- PDFGraphics2D graphics = new PDFGraphics2D(true, pdfInfo.fi,
+ PDFGraphics2D graphics = new PDFGraphics2D(true, pdfInfo.fi,
pdfInfo.pdfDoc,
pdfInfo.pdfContext, pdfInfo.pdfPage.referencePDF(),
pdfInfo.currentFontName, pdfInfo.currentFontSize);
graphics.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());
if (!resolutionScaling.isIdentity()) {
- pdfInfo.currentStream.add("%resolution scaling for " + uaResolution
+ pdfInfo.currentStream.add("%resolution scaling for " + uaResolution
+ " -> " + deviceResolution + "\n");
pdfInfo.currentStream.add(
CTMHelper.toPDFString(resolutionScaling, false) + " cm\n");
graphics.scale(1 / s, 1 / s);
}
-
+
pdfInfo.currentStream.add("%SVG start\n");
//Save state and update coordinate system for the SVG image
pdfInfo.pdfState.push();
pdfInfo.pdfState.concatenate(imageTransform);
- //Now that we have the complete transformation matrix for the image, we can update the
+ //Now that we have the complete transformation matrix for the image, we can update the
//transformation matrix for the AElementBridge.
PDFAElementBridge aBridge = (PDFAElementBridge)ctx.getBridge(
SVGDOMImplementation.SVG_NAMESPACE_URI, SVGConstants.SVG_A_TAG);
@@ -272,7 +272,7 @@ public class PDFSVGHandler extends AbstractGenericSVGHandler
renderer.restoreGraphicsState();
pdfInfo.currentStream.add("%SVG end\n");
}
-
+
/** {@inheritDoc} */
public boolean supportsRenderer(Renderer renderer) {
return (renderer instanceof PDFRenderer);
diff --git a/src/java/org/apache/fop/render/print/PageableRenderer.java b/src/java/org/apache/fop/render/print/PageableRenderer.java
index 947708cef..01a60646b 100644
--- a/src/java/org/apache/fop/render/print/PageableRenderer.java
+++ b/src/java/org/apache/fop/render/print/PageableRenderer.java
@@ -57,8 +57,8 @@ public class PageableRenderer extends Java2DRenderer implements Pageable {
* datatype: a positive Integer
*/
public static final String END_PAGE = "end-page";
-
-
+
+
/** first valid page number (1-based) */
protected int startNumber = 0;
/** last valid page number (1-based) */
@@ -68,17 +68,17 @@ public class PageableRenderer extends Java2DRenderer implements Pageable {
protected PagesMode mode = PagesMode.ALL;
private PageFilter pageFilter;
-
+
/**
* Creates a new PageableRenderer.
*/
public PageableRenderer() {
}
-
+
/** {@inheritDoc} */
public void setUserAgent(FOUserAgent agent) {
super.setUserAgent(agent);
-
+
Map rendererOptions = agent.getRendererOptions();
processOptions(rendererOptions);
this.pageFilter = new DefaultPageFilter();
@@ -97,7 +97,7 @@ public class PageableRenderer extends Java2DRenderer implements Pageable {
+ " must be an 'all', 'even', 'odd' or a PagesMode instance.");
}
}
-
+
o = rendererOptions.get(PageableRenderer.START_PAGE);
if (o != null) {
this.startNumber = getPositiveInteger(o);
@@ -132,7 +132,7 @@ public class PageableRenderer extends Java2DRenderer implements Pageable {
"Value must be a positive integer");
}
}
-
+
/** {@inheritDoc} */
public void stopRenderer() throws IOException {
super.stopRenderer();
@@ -149,13 +149,13 @@ public class PageableRenderer extends Java2DRenderer implements Pageable {
super.rememberPage(pageViewport);
}
}
-
+
private interface PageFilter {
boolean isValid(PageViewport page);
}
private class DefaultPageFilter implements PageFilter {
-
+
public boolean isValid(PageViewport page) {
int pageNum = page.getPageIndex() + 1;
assert pageNum >= 0;
@@ -171,7 +171,7 @@ public class PageableRenderer extends Java2DRenderer implements Pageable {
return true;
}
}
-
+
/** {@inheritDoc} */
public PageFormat getPageFormat(int pageIndex)
throws IndexOutOfBoundsException {
@@ -179,15 +179,15 @@ public class PageableRenderer extends Java2DRenderer implements Pageable {
if (pageIndex >= getNumberOfPages()) {
return null;
}
-
+
PageFormat pageFormat = new PageFormat();
-
+
Paper paper = new Paper();
-
+
Rectangle2D dim = getPageViewport(pageIndex).getViewArea();
double width = dim.getWidth();
double height = dim.getHeight();
-
+
// if the width is greater than the height assume landscape mode
// and swap the width and height values in the paper format
if (width > height) {
diff --git a/src/java/org/apache/fop/render/print/PagesMode.java b/src/java/org/apache/fop/render/print/PagesMode.java
index 6879aa68d..cf8bade1d 100644
--- a/src/java/org/apache/fop/render/print/PagesMode.java
+++ b/src/java/org/apache/fop/render/print/PagesMode.java
@@ -28,7 +28,7 @@ public final class PagesMode {
public static final PagesMode EVEN = new PagesMode("even");
/** the odd pages mode */
public static final PagesMode ODD = new PagesMode("odd");
-
+
private String name;
/**
@@ -43,7 +43,7 @@ public final class PagesMode {
public String getName() {
return this.name;
}
-
+
/**
* Returns a PagesMode instance by name.
* @param name the name of the pages mode
@@ -60,10 +60,10 @@ public final class PagesMode {
throw new IllegalArgumentException("Invalid value for PagesMode: " + name);
}
}
-
+
/** {@inheritDoc} */
public String toString() {
return "PagesMode:" + name;
}
-
+
}
diff --git a/src/java/org/apache/fop/render/print/PrintRenderer.java b/src/java/org/apache/fop/render/print/PrintRenderer.java
index 888776ecb..2eb2b07a2 100644
--- a/src/java/org/apache/fop/render/print/PrintRenderer.java
+++ b/src/java/org/apache/fop/render/print/PrintRenderer.java
@@ -39,14 +39,14 @@ public class PrintRenderer extends PageableRenderer {
* datatype: java.awt.print.PrinterJob
*/
public static final String PRINTER_JOB = "printerjob";
-
+
/**
* Printing parameter: the number of copies of the document to be printed,
* datatype: a positive Integer
*/
public static final String COPIES = "copies";
-
-
+
+
private int copies = 1;
private PrinterJob printerJob;
@@ -57,7 +57,7 @@ public class PrintRenderer extends PageableRenderer {
*/
public PrintRenderer() {
}
-
+
/**
* Creates a new PrintRenderer and allows you to pass in a specific PrinterJob instance
* that this renderer should work with.
@@ -69,7 +69,7 @@ public class PrintRenderer extends PageableRenderer {
this.printerJob = printerJob;
printerJob.setPageable(this);
}
-
+
private void initializePrinterJob() {
if (this.printerJob == null) {
printerJob = PrinterJob.getPrinterJob();
@@ -88,9 +88,9 @@ public class PrintRenderer extends PageableRenderer {
/** {@inheritDoc} */
public void setUserAgent(FOUserAgent agent) {
super.setUserAgent(agent);
-
+
Map rendererOptions = agent.getRendererOptions();
-
+
Object printerJobO = rendererOptions.get(PrintRenderer.PRINTER_JOB);
if (printerJobO != null) {
if (!(printerJobO instanceof PrinterJob)) {
@@ -118,7 +118,7 @@ public class PrintRenderer extends PageableRenderer {
public int getEndNumber() {
return endNumber;
}
-
+
/**
* Sets the number of the last page to be printed.
* @param end The ending page number
@@ -126,12 +126,12 @@ public class PrintRenderer extends PageableRenderer {
public void setEndPage(int end) {
this.endNumber = end;
}
-
+
/** @return the starting page number */
public int getStartPage() {
return startNumber;
}
-
+
/**
* Sets the number of the first page to be printed.
* @param start The starting page number
@@ -139,7 +139,7 @@ public class PrintRenderer extends PageableRenderer {
public void setStartPage(int start) {
this.startNumber = start;
}
-
+
/** {@inheritDoc} */
public void stopRenderer() throws IOException {
super.stopRenderer();
diff --git a/src/java/org/apache/fop/render/print/PrintRendererMaker.java b/src/java/org/apache/fop/render/print/PrintRendererMaker.java
index 2390567ef..21eb4717a 100644
--- a/src/java/org/apache/fop/render/print/PrintRendererMaker.java
+++ b/src/java/org/apache/fop/render/print/PrintRendererMaker.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -32,7 +32,7 @@ import org.apache.fop.render.RendererConfigurator;
public class PrintRendererMaker extends AbstractRendererMaker {
private static final String[] MIMES = new String[] {MimeConstants.MIME_FOP_PRINT};
-
+
/**{@inheritDoc} */
public Renderer makeRenderer(FOUserAgent userAgent) {
return new PrintRenderer();
diff --git a/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java b/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java
index aa0fc88b9..b8ff8ef3f 100644
--- a/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java
+++ b/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/ps/EPSTranscoder.java b/src/java/org/apache/fop/render/ps/EPSTranscoder.java
index c34772196..38e700a57 100644
--- a/src/java/org/apache/fop/render/ps/EPSTranscoder.java
+++ b/src/java/org/apache/fop/render/ps/EPSTranscoder.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
*/
/* $Id$ */
-
+
package org.apache.fop.render.ps;
import org.apache.xmlgraphics.java2d.ps.AbstractPSDocumentGraphics2D;
diff --git a/src/java/org/apache/fop/render/ps/ImageEncoderCCITTFax.java b/src/java/org/apache/fop/render/ps/ImageEncoderCCITTFax.java
index d5b2d2a23..e315b1433 100644
--- a/src/java/org/apache/fop/render/ps/ImageEncoderCCITTFax.java
+++ b/src/java/org/apache/fop/render/ps/ImageEncoderCCITTFax.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -31,7 +31,7 @@ import org.apache.xmlgraphics.ps.PSDictionary;
* ImageEncoder implementation for CCITT encoded images.
*/
public class ImageEncoderCCITTFax implements ImageEncoder {
-
+
private final ImageRawCCITTFax ccitt;
/**
@@ -66,7 +66,7 @@ public class ImageEncoderCCITTFax implements ImageEncoder {
throw new IllegalStateException(
"Invalid compression scheme: " + compression);
}
-
+
return dict.toString() + " /CCITTFaxDecode";
}
}
\ No newline at end of file
diff --git a/src/java/org/apache/fop/render/ps/ImageEncoderJPEG.java b/src/java/org/apache/fop/render/ps/ImageEncoderJPEG.java
index ef4b9f16c..9baed2a8e 100644
--- a/src/java/org/apache/fop/render/ps/ImageEncoderJPEG.java
+++ b/src/java/org/apache/fop/render/ps/ImageEncoderJPEG.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/ps/PSEventProducer.java b/src/java/org/apache/fop/render/ps/PSEventProducer.java
index 451ed1cea..c7c621e78 100644
--- a/src/java/org/apache/fop/render/ps/PSEventProducer.java
+++ b/src/java/org/apache/fop/render/ps/PSEventProducer.java
@@ -31,7 +31,7 @@ public interface PSEventProducer extends EventProducer {
/** Provider class for the event producer. */
class Provider {
-
+
/**
* Returns an event producer.
* @param broadcaster the event broadcaster to use
@@ -50,9 +50,9 @@ public interface PSEventProducer extends EventProducer {
public EventModel createEventModel() {
return loadModel(getClass(), "event-model.xml");
}
-
+
}
-
+
/**
* A PostScript dictionary could not be parsed.
* @param source the event source
@@ -61,5 +61,5 @@ public interface PSEventProducer extends EventProducer {
* @event.severity ERROR
*/
void postscriptDictionaryParseError(Object source, String content, Exception e);
-
+
}
diff --git a/src/java/org/apache/fop/render/ps/PSFontUtils.java b/src/java/org/apache/fop/render/ps/PSFontUtils.java
index 63b12c5c8..6bb1f294b 100644
--- a/src/java/org/apache/fop/render/ps/PSFontUtils.java
+++ b/src/java/org/apache/fop/render/ps/PSFontUtils.java
@@ -55,7 +55,7 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils {
/** logging instance */
protected static Log log = LogFactory.getLog(PSFontUtils.class);
-
+
/**
* Generates the PostScript code for the font dictionary.
* @param gen PostScript generator to use for output
@@ -63,11 +63,11 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils {
* @return a Map of PSResource instances representing all defined fonts (key: font key)
* @throws IOException in case of an I/O problem
*/
- public static Map writeFontDict(PSGenerator gen, FontInfo fontInfo)
+ public static Map writeFontDict(PSGenerator gen, FontInfo fontInfo)
throws IOException {
return writeFontDict(gen, fontInfo, fontInfo.getFonts());
}
-
+
/**
* Generates the PostScript code for the font dictionary.
* @param gen PostScript generator to use for output
@@ -76,7 +76,7 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils {
* @return a Map of PSResource instances representing all defined fonts (key: font key)
* @throws IOException in case of an I/O problem
*/
- public static Map writeFontDict(PSGenerator gen, FontInfo fontInfo, Map fonts)
+ public static Map writeFontDict(PSGenerator gen, FontInfo fontInfo, Map fonts)
throws IOException {
gen.commentln("%FOPBeginFontDict");
@@ -88,7 +88,7 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils {
PSResource fontRes = new PSResource(PSResource.TYPE_FONT, tf.getFontName());
fontResources.put(key, fontRes);
embedFont(gen, tf, fontRes);
-
+
if (tf instanceof SingleByteFont) {
SingleByteFont sbf = (SingleByteFont)tf;
for (int i = 0, c = sbf.getAdditionalEncodingCount(); i < c; i++) {
@@ -108,12 +108,12 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils {
private static void reencodeFonts(PSGenerator gen, Map fonts) throws IOException {
ResourceTracker tracker = gen.getResourceTracker();
-
+
if (!tracker.isResourceSupplied(WINANSI_ENCODING_RESOURCE)) {
defineWinAnsiEncoding(gen);
}
gen.commentln("%FOPBeginFontReencode");
-
+
//Rewrite font encodings
Iterator iter = fonts.keySet().iterator();
while (iter.hasNext()) {
@@ -133,7 +133,7 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils {
//ignore (no encoding redefinition)
} else {
if (tf instanceof Base14Font) {
- //Our Base 14 fonts don't use the default encoding
+ //Our Base 14 fonts don't use the default encoding
redefineFontEncoding(gen, tf.getFontName(), tf.getEncodingName());
}
}
@@ -149,7 +149,7 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils {
if (tf == null) {
//This is to avoid an NPE if a malconfigured font is in the configuration but not
//used in the document. If it were used, we wouldn't get this far.
- String fallbackKey = fontInfo.getInternalFontKey(Font.DEFAULT_FONT);
+ String fallbackKey = fontInfo.getInternalFontKey(Font.DEFAULT_FONT);
tf = (Typeface)fonts.get(fallbackKey);
}
return tf;
@@ -162,7 +162,7 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils {
* @param fontRes the PSResource associated with the font
* @throws IOException In case of an I/O error
*/
- public static void embedFont(PSGenerator gen, Typeface tf, PSResource fontRes)
+ public static void embedFont(PSGenerator gen, Typeface tf, PSResource fontRes)
throws IOException {
boolean embeddedFont = false;
if (FontType.TYPE1 == tf.getFontType()) {
@@ -171,7 +171,7 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils {
if (isEmbeddable(cf)) {
InputStream in = getInputStreamOnFont(gen, cf);
if (in != null) {
- gen.writeDSCComment(DSCConstants.BEGIN_RESOURCE,
+ gen.writeDSCComment(DSCConstants.BEGIN_RESOURCE,
fontRes);
embedType1Font(gen, in);
gen.writeDSCComment(DSCConstants.END_RESOURCE);
@@ -193,8 +193,8 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils {
private static boolean isEmbeddable(CustomFont font) {
return font.isEmbeddable();
}
-
- private static InputStream getInputStreamOnFont(PSGenerator gen, CustomFont font)
+
+ private static InputStream getInputStreamOnFont(PSGenerator gen, CustomFont font)
throws IOException {
if (isEmbeddable(font)) {
Source source = font.getEmbedFileSource();
@@ -239,7 +239,7 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils {
* @param fonts the set of fonts to work with
* @return a Map of PSResource instances representing all defined fonts (key: font key)
*/
- public static Map determineSuppliedFonts(ResourceTracker resTracker,
+ public static Map determineSuppliedFonts(ResourceTracker resTracker,
FontInfo fontInfo, Map fonts) {
Map fontResources = new java.util.HashMap();
Iterator iter = fonts.keySet().iterator();
@@ -337,5 +337,5 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils {
gen.getResourceTracker().registerSuppliedResource(res);
return res;
}
-
+
}
diff --git a/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java b/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java
index 717153b3b..c17fe9e56 100644
--- a/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java
+++ b/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
*/
/* $Id$ */
-
+
package org.apache.fop.render.ps;
import java.awt.Dimension;
@@ -47,7 +47,7 @@ public class PSGraphics2DAdapter extends AbstractGraphics2DAdapter {
public PSGraphics2DAdapter(PSRenderer renderer) {
this(renderer.gen, true);
}
-
+
/**
* Constructor for use without a PSRenderer instance.
* @param gen the PostScript generator
@@ -57,16 +57,16 @@ public class PSGraphics2DAdapter extends AbstractGraphics2DAdapter {
this.gen = gen;
this.clip = clip;
}
-
+
/** {@inheritDoc} */
- public void paintImage(Graphics2DImagePainter painter,
+ public void paintImage(Graphics2DImagePainter painter,
RendererContext context,
int x, int y, int width, int height) throws IOException {
float fwidth = width / 1000f;
float fheight = height / 1000f;
float fx = x / 1000f;
float fy = y / 1000f;
-
+
// get the 'width' and 'height' attributes of the SVG document
Dimension dim = painter.getImageSize();
float imw = (float)dim.getWidth() / 1000f;
@@ -83,7 +83,7 @@ public class PSGraphics2DAdapter extends AbstractGraphics2DAdapter {
gen.defineRect(fx, fy, fwidth, fheight);
gen.writeln("clip");
}
-
+
// transform so that the coordinates (0,0) is from the top left
// and positive is down and to the right. (0,0) is where the
// viewBox puts it.
diff --git a/src/java/org/apache/fop/render/ps/PSImageFormResource.java b/src/java/org/apache/fop/render/ps/PSImageFormResource.java
index b00e2201d..11c3205e6 100644
--- a/src/java/org/apache/fop/render/ps/PSImageFormResource.java
+++ b/src/java/org/apache/fop/render/ps/PSImageFormResource.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -28,7 +28,7 @@ import org.apache.xmlgraphics.ps.PSResource;
public class PSImageFormResource extends PSResource {
private String uri;
-
+
/**
* Create a new Form Resource.
* @param id An ID for the form
@@ -37,7 +37,7 @@ public class PSImageFormResource extends PSResource {
public PSImageFormResource(int id, String uri) {
this("FOPForm:" + Integer.toString(id), uri);
}
-
+
/**
/**
* Create a new Form Resource.
@@ -48,7 +48,7 @@ public class PSImageFormResource extends PSResource {
super(PSResource.TYPE_FORM, name);
this.uri = uri;
}
-
+
/**
* Returns the image URI.
* @return the image URI
@@ -56,5 +56,5 @@ public class PSImageFormResource extends PSResource {
public String getImageURI() {
return this.uri;
}
-
+
}
diff --git a/src/java/org/apache/fop/render/ps/PSImageUtils.java b/src/java/org/apache/fop/render/ps/PSImageUtils.java
index 27eb736d8..7a011fbec 100644
--- a/src/java/org/apache/fop/render/ps/PSImageUtils.java
+++ b/src/java/org/apache/fop/render/ps/PSImageUtils.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
*/
/* $Id$ */
-
+
package org.apache.fop.render.ps;
/**
diff --git a/src/java/org/apache/fop/render/ps/PSRenderer.java b/src/java/org/apache/fop/render/ps/PSRenderer.java
index f84f46bf9..9f8cdc771 100644
--- a/src/java/org/apache/fop/render/ps/PSRenderer.java
+++ b/src/java/org/apache/fop/render/ps/PSRenderer.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -121,7 +121,7 @@ import org.apache.fop.util.CharUtilities;
*
* This renderer inserts FOP-specific comments into the PostScript stream which
* may help certain users to do certain types of post-processing of the output.
- * These comments all start with "%FOP".
+ * These comments all start with "%FOP".
*
* @author Apache FOP Development Team
* @version $Id$
@@ -150,7 +150,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer
private OutputStream outputStream;
/** the temporary file in case of two-pass processing */
private File tempFile;
-
+
/** The PostScript generator used to output the PostScript */
protected PSGenerator gen;
/** Determines whether the PS file is generated in two passes to minimize file size */
@@ -181,13 +181,13 @@ public class PSRenderer extends AbstractPathOrientedRenderer
/** Is used to determine the document's bounding box */
private Rectangle2D documentBoundingBox;
-
+
/** This is a collection holding all document header comments */
private Collection headerComments;
/** This is a collection holding all document footer comments */
private Collection footerComments;
-
+
/** {@inheritDoc} */
public void setUserAgent(FOUserAgent agent) {
super.setUserAgent(agent);
@@ -215,7 +215,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer
throw new IllegalArgumentException("Boolean or \"true\" or \"false\" expected.");
}
}
-
+
private int intValueOf(Object obj) {
if (obj instanceof Integer) {
return ((Integer)obj).intValue();
@@ -225,11 +225,11 @@ public class PSRenderer extends AbstractPathOrientedRenderer
throw new IllegalArgumentException("Integer or String with a number expected.");
}
}
-
+
/**
* Sets the landscape mode for this renderer.
* @param value false will normally generate a "pseudo-portrait" page, true will rotate
- * a "wider-than-long" page by 90 degrees.
+ * a "wider-than-long" page by 90 degrees.
*/
public void setAutoRotateLandscape(boolean value) {
this.autoRotateLandscape = value;
@@ -251,7 +251,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer
throw new IllegalArgumentException("Only language levels 2 or 3 are allowed/supported");
}
}
-
+
/**
* Return the PostScript language level that the renderer produces.
* @return the language level
@@ -259,12 +259,12 @@ public class PSRenderer extends AbstractPathOrientedRenderer
public int getLanguageLevel() {
return this.languageLevel;
}
-
+
/**
* Sets the resource optimization mode. If set to true, the renderer does two passes to
* only embed the necessary resources in the PostScript file. This is slower, but produces
* smaller files.
- * @param value true to enable the resource optimization
+ * @param value true to enable the resource optimization
*/
public void setOptimizeResources(boolean value) {
this.twoPassGeneration = value;
@@ -335,7 +335,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer
protected void clip() {
writeln("clip newpath");
}
-
+
/** {@inheritDoc} */
protected void clipRect(float x, float y, float width, float height) {
try {
@@ -350,27 +350,27 @@ public class PSRenderer extends AbstractPathOrientedRenderer
protected void moveTo(float x, float y) {
writeln(gen.formatDouble(x) + " " + gen.formatDouble(y) + " M");
}
-
+
/**
- * Moves the current point by (x, y) relative to the current position,
- * omitting any connecting line segment.
+ * Moves the current point by (x, y) relative to the current position,
+ * omitting any connecting line segment.
* @param x x coordinate
* @param y y coordinate
*/
protected void rmoveTo(float x, float y) {
writeln(gen.formatDouble(x) + " " + gen.formatDouble(y) + " RM");
}
-
+
/** {@inheritDoc} */
protected void lineTo(float x, float y) {
writeln(gen.formatDouble(x) + " " + gen.formatDouble(y) + " lineto");
}
-
+
/** {@inheritDoc} */
protected void closePath() {
writeln("cp");
}
-
+
/** {@inheritDoc} */
protected void fillRect(float x, float y, float width, float height) {
if (width != 0 && height != 0) {
@@ -400,7 +400,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer
protected boolean isImageInlined(String uri) {
return !isOptimizeResources() || uri == null || "".equals(uri);
}
-
+
/**
* Indicates whether an image should be inlined or added as a PostScript form.
* @param info the ImageInfo object of the image
@@ -410,7 +410,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer
if (isImageInlined(info.getOriginalURI())) {
return true;
}
-
+
if (!isOptimizeResources()) {
throw new IllegalStateException("Must not get here if form support is enabled");
}
@@ -423,7 +423,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer
info, inlineFlavors);
ImageProviderPipeline inlineChoice = manager.choosePipeline(inlineCandidates);
ImageFlavor inlineFlavor = (inlineChoice != null ? inlineChoice.getTargetFlavor() : null);
-
+
//Investigate choice for form mode
ImageFlavor[] formFlavors = getFormFlavors();
ImageProviderPipeline[] formCandidates
@@ -431,11 +431,11 @@ public class PSRenderer extends AbstractPathOrientedRenderer
info, formFlavors);
ImageProviderPipeline formChoice = manager.choosePipeline(formCandidates);
ImageFlavor formFlavor = (formChoice != null ? formChoice.getTargetFlavor() : null);
-
+
//Inline if form is not supported or if a better choice is available with inline mode
return formFlavor == null || !formFlavor.equals(inlineFlavor);
}
-
+
/** {@inheritDoc} */
protected void drawImage(String uri, Rectangle2D pos, Map foreignAttributes) {
endTextObject();
@@ -445,7 +445,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer
if (log.isDebugEnabled()) {
log.debug("Handling image: " + uri);
}
-
+
ImageManager manager = getUserAgent().getFactory().getImageManager();
ImageInfo info = null;
try {
@@ -453,7 +453,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer
info = manager.getImageInfo(uri, sessionContext);
int width = (int)pos.getWidth();
int height = (int)pos.getHeight();
-
+
//millipoints --> points for PostScript
float ptx = x / 1000f;
float pty = y / 1000f;
@@ -468,7 +468,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer
Map hints = ImageUtil.getDefaultHints(sessionContext);
org.apache.xmlgraphics.image.loader.Image img = manager.getImage(
info, getInlineFlavors(), hints, sessionContext);
-
+
//...and embed as inline image
if (img instanceof ImageGraphics2D) {
ImageGraphics2D imageG2D = (ImageGraphics2D)img;
@@ -488,7 +488,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer
final ImageRawStream raw = (ImageRawStream)img;
if (raw instanceof ImageRawEPS) {
ImageRawEPS eps = (ImageRawEPS)raw;
- Rectangle2D bbox = eps.getBoundingBox();
+ Rectangle2D bbox = eps.getBoundingBox();
InputStream in = raw.createInputStream();
try {
PSImageUtils.renderEPS(in, uri,
@@ -525,9 +525,9 @@ public class PSRenderer extends AbstractPathOrientedRenderer
log.debug("Image " + info + " is embedded as a form later");
}
//Don't load image at this time, just put a form placeholder in the stream
- PSResource form = getFormForImage(uri);
+ PSResource form = getFormForImage(uri);
Rectangle2D targetRect = new Rectangle2D.Double(ptx, pty, ptw, pth);
- PSImageUtils.paintForm(form, info.getSize().getDimensionPt(), targetRect, gen);
+ PSImageUtils.paintForm(form, info.getSize().getDimensionPt(), targetRect, gen);
}
} catch (ImageException ie) {
@@ -586,7 +586,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer
}
/** {@inheritDoc} */
- public void paintImage(RenderedImage image, RendererContext context,
+ public void paintImage(RenderedImage image, RendererContext context,
int x, int y, int width, int height) throws IOException {
float fx = (float)x / 1000f;
x += currentIPPosition / 1000f;
@@ -606,12 +606,12 @@ public class PSRenderer extends AbstractPathOrientedRenderer
* @param endy the y end position
*/
private void drawLine(float startx, float starty, float endx, float endy) {
- writeln(gen.formatDouble(startx) + " "
- + gen.formatDouble(starty) + " M "
- + gen.formatDouble(endx) + " "
+ writeln(gen.formatDouble(startx) + " "
+ + gen.formatDouble(starty) + " M "
+ + gen.formatDouble(endx) + " "
+ gen.formatDouble(endy) + " lineto stroke newpath");
}
-
+
/** Saves the graphics state of the rendering engine. */
public void saveGraphicsState() {
endTextObject();
@@ -673,7 +673,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer
handleIOTrouble(ioe);
}
}
-
+
private String getPostScriptNameForFontKey(String key) {
int pos = key.indexOf('_');
String postFix = null;
@@ -695,7 +695,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer
return tf.getFontName() + postFix;
}
}
-
+
/**
* Returns the PSResource for the given font key.
* @param key the font key ("F*")
@@ -706,7 +706,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer
if (this.fontResources != null) {
res = (PSResource)this.fontResources.get(key);
} else {
- this.fontResources = new java.util.HashMap();
+ this.fontResources = new java.util.HashMap();
}
if (res == null) {
res = new PSResource(PSResource.TYPE_FONT, getPostScriptNameForFontKey(key));
@@ -714,7 +714,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer
}
return res;
}
-
+
/**
* Changes the currently used font.
* @param key key of the font ("F*")
@@ -742,15 +742,15 @@ public class PSRenderer extends AbstractPathOrientedRenderer
|| area.hasTrait(Trait.BORDER_AFTER)
|| area.hasTrait(Trait.BORDER_START)
|| area.hasTrait(Trait.BORDER_END)) {
- comment("%FOPBeginBackgroundAndBorder: "
+ comment("%FOPBeginBackgroundAndBorder: "
+ startx + " " + starty + " " + width + " " + height);
super.drawBackAndBorders(area, startx, starty, width, height);
- comment("%FOPEndBackgroundAndBorder");
+ comment("%FOPEndBackgroundAndBorder");
}
}
-
+
/** {@inheritDoc} */
- protected void drawBorderLine(float x1, float y1, float x2, float y2,
+ protected void drawBorderLine(float x1, float y1, float x2, float y2,
boolean horz, boolean startOrBefore, int style, Color col) {
try {
float w = x2 - x1;
@@ -760,7 +760,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer
return;
}
switch (style) {
- case Constants.EN_DASHED:
+ case Constants.EN_DASHED:
useColor(col);
if (horz) {
float unit = Math.abs(2 * h);
@@ -902,14 +902,14 @@ public class PSRenderer extends AbstractPathOrientedRenderer
handleIOTrouble(ioe);
}
}
-
+
/** {@inheritDoc} */
public void startRenderer(OutputStream outputStream)
throws IOException {
log.debug("Rendering areas to PostScript...");
this.outputStream = outputStream;
- OutputStream out;
+ OutputStream out;
if (isOptimizeResources()) {
this.tempFile = File.createTempFile("fop", null);
out = new java.io.FileOutputStream(this.tempFile);
@@ -917,7 +917,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer
} else {
out = this.outputStream;
}
-
+
//Setup for PostScript generation
this.gen = new PSGenerator(out) {
/** Need to subclass PSGenerator to have better URI resolution */
@@ -944,7 +944,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer
gen.writeDSCComment(DSCConstants.BBOX, DSCConstants.ATEND);
gen.writeDSCComment(DSCConstants.HIRES_BBOX, DSCConstants.ATEND);
this.documentBoundingBox = new Rectangle2D.Double();
- gen.writeDSCComment(DSCConstants.DOCUMENT_SUPPLIED_RESOURCES,
+ gen.writeDSCComment(DSCConstants.DOCUMENT_SUPPLIED_RESOURCES,
new Object[] {DSCConstants.ATEND});
if (headerComments != null) {
for (Iterator iter = headerComments.iterator(); iter.hasNext();) {
@@ -988,7 +988,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer
PSResource res = (PSResource)this.fontResources.get(key);
gen.notifyResourceUsage(res);
}*/
-
+
//Write trailer
gen.writeDSCComment(DSCConstants.TRAILER);
if (footerComments != null) {
@@ -1016,7 +1016,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer
pageDeviceDictionary.clear();
}
}
-
+
/**
* Used for two-pass production. This will rewrite the PostScript file from the temporary
* file while adding all needed resources.
@@ -1030,7 +1030,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer
in = new java.io.BufferedInputStream(in);
try {
try {
- ResourceHandler.process(this.userAgent, in, this.outputStream,
+ ResourceHandler.process(this.userAgent, in, this.outputStream,
this.fontInfo, resTracker, this.formResources,
this.currentPageNumber, this.documentBoundingBox);
this.outputStream.flush();
@@ -1100,7 +1100,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer
}
super.processOffDocumentItem(oDI);
}
-
+
/**
* Formats and writes a List of PSSetupCode instances to the output stream.
* @param setupCodeList a List of PSSetupCode instances
@@ -1111,8 +1111,8 @@ public class PSRenderer extends AbstractPathOrientedRenderer
Iterator i = setupCodeList.iterator();
while (i.hasNext()) {
PSSetupCode setupCode = (PSSetupCode)i.next();
- gen.commentln("%FOPBegin" + type + ": ("
- + (setupCode.getName() != null ? setupCode.getName() : "")
+ gen.commentln("%FOPBegin" + type + ": ("
+ + (setupCode.getName() != null ? setupCode.getName() : "")
+ ")");
LineNumberReader reader = new LineNumberReader(
new java.io.StringReader(setupCode.getContent()));
@@ -1137,9 +1137,9 @@ public class PSRenderer extends AbstractPathOrientedRenderer
if (this.currentPageNumber == 0) {
writeHeader();
}
-
+
this.currentPageNumber++;
-
+
gen.getResourceTracker().notifyStartNewPage();
gen.getResourceTracker().notifyResourceUsageOnPage(PSProcSets.STD_PROCSET);
gen.writeDSCComment(DSCConstants.PAGE, new Object[]
@@ -1159,7 +1159,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer
pageSizes.add(new Long(Math.round(pageHeight)));
}
pageDeviceDictionary.put("/PageSize", pageSizes);
-
+
if (page.hasExtensionAttachments()) {
for (Iterator iter = page.getExtensionAttachments().iterator();
iter.hasNext();) {
@@ -1245,7 +1245,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer
if (safeSetPageDevice) {
content += " SSPD";
} else {
- content += " setpagedevice";
+ content += " setpagedevice";
}
writeEnclosedExtensionAttachment(new PSSetPageDevice(content));
}
@@ -1256,8 +1256,8 @@ public class PSRenderer extends AbstractPathOrientedRenderer
}
concatMatrix(1, 0, 0, -1, 0, pageHeight);
- gen.writeDSCComment(DSCConstants.END_PAGE_SETUP);
-
+ gen.writeDSCComment(DSCConstants.END_PAGE_SETUP);
+
//Process page
super.renderPage(page);
@@ -1287,7 +1287,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer
comment("%FOPEndRegionViewport");
}
}
-
+
/** Indicates the beginning of a text object. */
protected void beginTextObject() {
if (!inTextMode) {
@@ -1327,16 +1327,16 @@ public class PSRenderer extends AbstractPathOrientedRenderer
handleIOTrouble(ioe);
}
}
-
+
beginTextObject();
- writeln("1 0 0 -1 " + gen.formatDouble(rx / 1000f)
+ writeln("1 0 0 -1 " + gen.formatDouble(rx / 1000f)
+ " " + gen.formatDouble(bl / 1000f) + " Tm");
-
+
super.renderText(area); //Updates IPD
renderTextDecoration(tf, fontsize, area, bl, rx);
}
-
+
/** {@inheritDoc} */
protected void renderWord(WordArea word) {
renderText((TextArea)word.getParentArea(), word.getWord(), word.getLetterAdjustArray());
@@ -1349,9 +1349,9 @@ public class PSRenderer extends AbstractPathOrientedRenderer
String s = space.getSpace();
char sp = s.charAt(0);
Font font = getFontFromArea(textArea);
-
- int tws = (space.isAdjustable()
- ? ((TextArea) space.getParentArea()).getTextWordSpaceAdjust()
+
+ int tws = (space.isAdjustable()
+ ? ((TextArea) space.getParentArea()).getTextWordSpaceAdjust()
+ 2 * textArea.getTextLetterSpaceAdjust()
: 0);
@@ -1366,7 +1366,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer
}
return tf;
}
-
+
private void renderText(AbstractTextArea area, String text, int[] letterAdjust) {
String fontkey = getInternalFontNameForArea(area);
int fontSize = area.getTraitAsInteger(Trait.FONT_SIZE);
@@ -1411,8 +1411,8 @@ public class PSRenderer extends AbstractPathOrientedRenderer
int initialSize = text.length();
initialSize += initialSize / 2;
StringBuffer sb = new StringBuffer(initialSize);
- if (letterAdjust == null
- && area.getTextLetterSpaceAdjust() == 0
+ if (letterAdjust == null
+ && area.getTextLetterSpaceAdjust() == 0
&& area.getTextWordSpaceAdjust() == 0) {
sb.append("(");
for (int i = start; i < end; i++) {
@@ -1437,7 +1437,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer
}
int cw = tf.getWidth(mapped, fontsize) / 1000;
int ladj = (letterAdjust != null && i < end - 1 ? letterAdjust[i + 1] : 0);
- int tls = (i < end - 1 ? area.getTextLetterSpaceAdjust() : 0);
+ int tls = (i < end - 1 ? area.getTextLetterSpaceAdjust() : 0);
offsets[i - start] = cw + ladj + tls + wordSpace;
PSGenerator.escapeChar(codepoint, sb);
}
@@ -1479,7 +1479,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer
return null;
}
}
-
+
/** {@inheritDoc} */
protected void restoreStateStackAfterBreakOut(List breakOutList) {
try {
@@ -1496,16 +1496,16 @@ public class PSRenderer extends AbstractPathOrientedRenderer
handleIOTrouble(ioe);
}
}
-
+
/**
- * {@inheritDoc}
+ * {@inheritDoc}
*/
protected void startVParea(CTM ctm, Rectangle2D clippingRect) {
saveGraphicsState();
if (clippingRect != null) {
- clipRect((float)clippingRect.getX() / 1000f,
- (float)clippingRect.getY() / 1000f,
- (float)clippingRect.getWidth() / 1000f,
+ clipRect((float)clippingRect.getX() / 1000f,
+ (float)clippingRect.getY() / 1000f,
+ (float)clippingRect.getWidth() / 1000f,
(float)clippingRect.getHeight() / 1000f);
}
// multiply with current CTM
@@ -1528,12 +1528,12 @@ public class PSRenderer extends AbstractPathOrientedRenderer
super.renderBlockViewport(bv, children);
comment("%FOPEndBlockViewport");
}
-
+
/** {@inheritDoc} */
protected void renderInlineParent(InlineParent ip) {
super.renderInlineParent(ip);
}
-
+
/**
* {@inheritDoc}
*/
@@ -1545,7 +1545,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer
int style = area.getRuleStyle();
float startx = (currentIPPosition + area.getBorderAndPaddingWidthStart()) / 1000f;
float starty = (currentBPPosition + area.getOffset()) / 1000f;
- float endx = (currentIPPosition + area.getBorderAndPaddingWidthStart()
+ float endx = (currentIPPosition + area.getBorderAndPaddingWidthStart()
+ area.getIPD()) / 1000f;
float ruleThickness = area.getRuleThickness() / 1000f;
Color col = (Color)area.getTrait(Trait.COLOR);
@@ -1555,7 +1555,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer
case EN_SOLID:
case EN_DASHED:
case EN_DOUBLE:
- drawBorderLine(startx, starty, endx, starty + ruleThickness,
+ drawBorderLine(startx, starty, endx, starty + ruleThickness,
true, true, style, col);
break;
case EN_DOTTED:
@@ -1563,13 +1563,13 @@ public class PSRenderer extends AbstractPathOrientedRenderer
//This displaces the dots to the right by half a dot's width
//TODO There's room for improvement here
gen.concatMatrix(1, 0, 0, 1, ruleThickness / 2, 0);
- drawBorderLine(startx, starty, endx, starty + ruleThickness,
+ drawBorderLine(startx, starty, endx, starty + ruleThickness,
true, true, style, col);
break;
case EN_GROOVE:
case EN_RIDGE:
float half = area.getRuleThickness() / 2000f;
-
+
gen.useColor(lightenColor(col, 0.6f));
moveTo(startx, starty);
lineTo(endx, starty);
@@ -1606,7 +1606,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}
*/
public void renderImage(Image image, Rectangle2D pos) {
drawImage(image.getURL(), pos);
@@ -1615,7 +1615,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer
/**
* {@inheritDoc}
*/
- protected RendererContext createRendererContext(int x, int y, int width, int height,
+ protected RendererContext createRendererContext(int x, int y, int width, int height,
Map foreignAttributes) {
RendererContext context = super.createRendererContext(
x, y, width, height, foreignAttributes);
@@ -1631,7 +1631,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer
/**
* Formats and writes a PSExtensionAttachment to the output stream.
- *
+ *
* @param attachment an PSExtensionAttachment instance
*/
private void writeEnclosedExtensionAttachment(PSExtensionAttachment attachment)
@@ -1661,7 +1661,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer
/**
* Formats and writes a Collection of PSExtensionAttachment instances to
* the output stream.
- *
+ *
* @param attachmentCollection
* a Collection of PSExtensionAttachment instances
*/
@@ -1677,15 +1677,15 @@ public class PSRenderer extends AbstractPathOrientedRenderer
iter.remove();
}
}
-
+
/**
* Sets whether or not the safe set page device macro should be used
* (as opposed to directly invoking setpagedevice) when setting the
* postscript page device.
- *
+ *
* This option is a useful option when you want to guard against the possibility
- * of invalid/unsupported postscript key/values being placed in the page device.
- *
+ * of invalid/unsupported postscript key/values being placed in the page device.
+ *
* @param safeSetPageDevice setting to false and the renderer will make a
* standard "setpagedevice" call, setting to true will make a safe set page
* device macro call (default is false).
@@ -1701,14 +1701,14 @@ public class PSRenderer extends AbstractPathOrientedRenderer
* It can cause problems (unwanted PostScript subsystem initgraphics/erasepage calls)
* on some printers when the pagedevice is set. If this causes problems on a
* particular implementation then use this setting with a 'false' value to try and
- * minimize the number of setpagedevice calls in the postscript document output.
+ * minimize the number of setpagedevice calls in the postscript document output.
*
* Set this value to false if you experience unwanted blank pages in your
* postscript output.
* @param dscCompliant boolean value (default is true)
*/
public void setDSCCompliant(boolean dscCompliant) {
- this.dscCompliant = dscCompliant;
+ this.dscCompliant = dscCompliant;
}
}
diff --git a/src/java/org/apache/fop/render/ps/PSRendererConfigurator.java b/src/java/org/apache/fop/render/ps/PSRendererConfigurator.java
index 3ce9751b5..867888ea5 100644
--- a/src/java/org/apache/fop/render/ps/PSRendererConfigurator.java
+++ b/src/java/org/apache/fop/render/ps/PSRendererConfigurator.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -27,7 +27,7 @@ import org.apache.fop.render.Renderer;
import org.apache.xmlgraphics.ps.PSGenerator;
/**
- * Postscript renderer config
+ * Postscript renderer config
*/
public class PSRendererConfigurator extends PrintRendererConfigurator {
@@ -50,7 +50,7 @@ public class PSRendererConfigurator extends PrintRendererConfigurator {
super.configure(renderer);
PSRenderer psRenderer = (PSRenderer)renderer;
-
+
psRenderer.setAutoRotateLandscape(
cfg.getChild("auto-rotate-landscape").getValueAsBoolean(false));
Configuration child;
diff --git a/src/java/org/apache/fop/render/ps/PSRendererContextConstants.java b/src/java/org/apache/fop/render/ps/PSRendererContextConstants.java
index f5a5cc89f..433f2ce7c 100644
--- a/src/java/org/apache/fop/render/ps/PSRendererContextConstants.java
+++ b/src/java/org/apache/fop/render/ps/PSRendererContextConstants.java
@@ -32,5 +32,5 @@ public interface PSRendererContextConstants extends RendererContextConstants {
/** The font information for the PostScript renderer. */
public static final String PS_FONT_INFO = "psFontInfo";
-
+
}
diff --git a/src/java/org/apache/fop/render/ps/PSRendererMaker.java b/src/java/org/apache/fop/render/ps/PSRendererMaker.java
index 657a65f70..8c64f2806 100644
--- a/src/java/org/apache/fop/render/ps/PSRendererMaker.java
+++ b/src/java/org/apache/fop/render/ps/PSRendererMaker.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -31,7 +31,7 @@ import org.apache.fop.render.RendererConfigurator;
public class PSRendererMaker extends AbstractRendererMaker {
private static final String[] MIMES = new String[] {MimeConstants.MIME_POSTSCRIPT};
-
+
/** {@inheritDoc} */
public Renderer makeRenderer(FOUserAgent userAgent) {
return new PSRenderer();
diff --git a/src/java/org/apache/fop/render/ps/PSSVGHandler.java b/src/java/org/apache/fop/render/ps/PSSVGHandler.java
index ebe098282..1d293fa71 100644
--- a/src/java/org/apache/fop/render/ps/PSSVGHandler.java
+++ b/src/java/org/apache/fop/render/ps/PSSVGHandler.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -246,7 +246,7 @@ public class PSSVGHandler extends AbstractGenericSVGHandler
nativeTextHandler = new NativeTextHandler(graphics, psInfo.getFontInfo());
graphics.setCustomTextHandler(nativeTextHandler);
PSTextPainter textPainter = new PSTextPainter(nativeTextHandler);
- ctx.setTextPainter(textPainter);
+ ctx.setTextPainter(textPainter);
PSTextElementBridge tBridge = new PSTextElementBridge(textPainter);
ctx.putBridge(tBridge);
}
@@ -279,10 +279,10 @@ public class PSSVGHandler extends AbstractGenericSVGHandler
* an fo:block-container
*/
gen.writeln("newpath");
- gen.defineRect(xOffset / 1000f, yOffset / 1000f,
+ gen.defineRect(xOffset / 1000f, yOffset / 1000f,
psInfo.getWidth() / 1000f, psInfo.getHeight() / 1000f);
gen.writeln("clip");
-
+
// transform so that the coordinates (0,0) is from the top left
// and positive is down and to the right. (0,0) is where the
// viewBox puts it.
@@ -323,6 +323,6 @@ public class PSSVGHandler extends AbstractGenericSVGHandler
public boolean supportsRenderer(Renderer renderer) {
return (renderer instanceof PSRenderer);
}
-
+
}
diff --git a/src/java/org/apache/fop/render/ps/PSSupportedFlavors.java b/src/java/org/apache/fop/render/ps/PSSupportedFlavors.java
index 8ccfa8e26..b5c42c99e 100644
--- a/src/java/org/apache/fop/render/ps/PSSupportedFlavors.java
+++ b/src/java/org/apache/fop/render/ps/PSSupportedFlavors.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
*/
/* $Id$ */
-
+
package org.apache.fop.render.ps;
import org.apache.xmlgraphics.image.loader.ImageFlavor;
@@ -31,8 +31,8 @@ public interface PSSupportedFlavors {
{ImageFlavor.RAW_EPS,
ImageFlavor.RAW_CCITTFAX,
ImageFlavor.GRAPHICS2D,
- ImageFlavor.BUFFERED_IMAGE,
- ImageFlavor.RENDERED_IMAGE,
+ ImageFlavor.BUFFERED_IMAGE,
+ ImageFlavor.RENDERED_IMAGE,
ImageFlavor.XML_DOM};
/** The flavors supported inline with PostScript level 3 and higher. */
@@ -41,17 +41,17 @@ public interface PSSupportedFlavors {
ImageFlavor.RAW_JPEG,
ImageFlavor.RAW_CCITTFAX,
ImageFlavor.GRAPHICS2D,
- ImageFlavor.BUFFERED_IMAGE,
- ImageFlavor.RENDERED_IMAGE,
+ ImageFlavor.BUFFERED_IMAGE,
+ ImageFlavor.RENDERED_IMAGE,
ImageFlavor.XML_DOM};
-
+
/** The flavors supported as forms with PostScript level 2. */
ImageFlavor[] LEVEL_2_FLAVORS_FORM = new ImageFlavor[]
{//ImageFlavor.RAW_EPS,
ImageFlavor.RAW_CCITTFAX,
ImageFlavor.GRAPHICS2D,
- ImageFlavor.BUFFERED_IMAGE,
- ImageFlavor.RENDERED_IMAGE/*,
+ ImageFlavor.BUFFERED_IMAGE,
+ ImageFlavor.RENDERED_IMAGE/*,
ImageFlavor.XML_DOM*/};
/** The flavors supported as forms with PostScript level 3 or higher. */
@@ -60,8 +60,8 @@ public interface PSSupportedFlavors {
ImageFlavor.RAW_JPEG,
ImageFlavor.RAW_CCITTFAX,
ImageFlavor.GRAPHICS2D,
- ImageFlavor.BUFFERED_IMAGE,
- ImageFlavor.RENDERED_IMAGE/*,
+ ImageFlavor.BUFFERED_IMAGE,
+ ImageFlavor.RENDERED_IMAGE/*,
ImageFlavor.XML_DOM*/};
-
+
}
diff --git a/src/java/org/apache/fop/render/ps/PSTextElementBridge.java b/src/java/org/apache/fop/render/ps/PSTextElementBridge.java
index 0f41ca525..ab0c2d723 100644
--- a/src/java/org/apache/fop/render/ps/PSTextElementBridge.java
+++ b/src/java/org/apache/fop/render/ps/PSTextElementBridge.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -36,7 +36,7 @@ import org.w3c.dom.Node;
* @version $Id$
*/
public class PSTextElementBridge extends SVGTextElementBridge {
-
+
private PSTextPainter textPainter;
/**
diff --git a/src/java/org/apache/fop/render/ps/PSTextPainter.java b/src/java/org/apache/fop/render/ps/PSTextPainter.java
index 08cea6517..31cb4b605 100644
--- a/src/java/org/apache/fop/render/ps/PSTextPainter.java
+++ b/src/java/org/apache/fop/render/ps/PSTextPainter.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -70,10 +70,10 @@ import org.apache.fop.fonts.FontTriplet;
* @version $Id$
*/
public class PSTextPainter implements TextPainter {
-
+
/** the logger for this class */
protected Log log = LogFactory.getLog(PSTextPainter.class);
-
+
private NativeTextHandler nativeTextHandler;
private FontInfo fontInfo;
@@ -81,7 +81,7 @@ public class PSTextPainter implements TextPainter {
* Use the stroking text painter to get the bounds and shape.
* Also used as a fallback to draw the string with strokes.
*/
- protected static final TextPainter
+ protected static final TextPainter
PROXY_PAINTER = StrokingTextPainter.getInstance();
/**
@@ -102,19 +102,19 @@ public class PSTextPainter implements TextPainter {
public void paint(TextNode node, Graphics2D g2d) {
String txt = node.getText();
Point2D loc = node.getLocation();
-
+
if (hasUnsupportedAttributes(node)) {
PROXY_PAINTER.paint(node, g2d);
} else {
paintTextRuns(node.getTextRuns(), g2d, loc);
}
}
-
-
+
+
private boolean hasUnsupportedAttributes(TextNode node) {
Iterator i = node.getTextRuns().iterator();
while (i.hasNext()) {
- StrokingTextPainter.TextRun
+ StrokingTextPainter.TextRun
run = (StrokingTextPainter.TextRun)i.next();
AttributedCharacterIterator aci = run.getACI();
boolean hasUnsupported = hasUnsupportedAttributes(aci);
@@ -127,17 +127,17 @@ public class PSTextPainter implements TextPainter {
private boolean hasUnsupportedAttributes(AttributedCharacterIterator aci) {
boolean hasunsupported = false;
-
+
String text = getText(aci);
Font font = makeFont(aci);
if (hasUnsupportedGlyphs(text, font)) {
log.trace("-> Unsupported glyphs found");
hasunsupported = true;
}
-
+
TextPaintInfo tpi = (TextPaintInfo) aci.getAttribute(
GVTAttributedCharacterIterator.TextAttribute.PAINT_INFO);
- if ((tpi != null)
+ if ((tpi != null)
&& ((tpi.strokeStroke != null && tpi.strokePaint != null)
|| (tpi.strikethroughStroke != null)
|| (tpi.underlineStroke != null)
@@ -169,7 +169,7 @@ public class PSTextPainter implements TextPainter {
log.trace("-> word spacing found");
hasunsupported = true;
}
-
+
Object lengthAdjust = aci.getAttribute(
GVTAttributedCharacterIterator.TextAttribute.LENGTH_ADJUST);
if (lengthAdjust != null) {
@@ -179,7 +179,7 @@ public class PSTextPainter implements TextPainter {
Object writeMod = aci.getAttribute(
GVTAttributedCharacterIterator.TextAttribute.WRITING_MODE);
- if (writeMod != null
+ if (writeMod != null
&& !GVTAttributedCharacterIterator.TextAttribute.WRITING_MODE_LTR.equals(
writeMod)) {
log.trace("-> Unsupported writing modes found");
@@ -193,7 +193,7 @@ public class PSTextPainter implements TextPainter {
log.trace("-> vertical orientation found");
hasunsupported = true;
}
-
+
Object rcDel = aci.getAttribute(
GVTAttributedCharacterIterator.TextAttribute.TEXT_COMPOUND_DELIMITER);
//Batik 1.6 returns null here which makes it impossible to determine whether this can
@@ -202,7 +202,7 @@ public class PSTextPainter implements TextPainter {
log.trace("-> spans found");
hasunsupported = true; //Filter spans
}
-
+
if (hasunsupported) {
log.trace("Unsupported attributes found in ACI, using StrokingTextPainter");
}
@@ -219,7 +219,7 @@ public class PSTextPainter implements TextPainter {
Point2D currentloc = loc;
Iterator i = textRuns.iterator();
while (i.hasNext()) {
- StrokingTextPainter.TextRun
+ StrokingTextPainter.TextRun
run = (StrokingTextPainter.TextRun)i.next();
currentloc = paintTextRun(run, g2d, currentloc);
}
@@ -251,7 +251,7 @@ public class PSTextPainter implements TextPainter {
}
/**
- * Paint an ACI on a Graphics2D at a given location. The method has to
+ * Paint an ACI on a Graphics2D at a given location. The method has to
* update the location after painting.
* @param aci ACI to paint
* @param g2d Graphics2D to paint on
@@ -260,18 +260,18 @@ public class PSTextPainter implements TextPainter {
*/
protected Point2D paintACI(AttributedCharacterIterator aci, Graphics2D g2d, Point2D loc) {
//ACIUtils.dumpAttrs(aci);
-
+
aci.first();
updateLocationFromACI(aci, loc);
TextPaintInfo tpi = (TextPaintInfo) aci.getAttribute(
GVTAttributedCharacterIterator.TextAttribute.PAINT_INFO);
-
+
if (tpi == null) {
return loc;
}
-
+
TextNode.Anchor anchor = (TextNode.Anchor)aci.getAttribute(
GVTAttributedCharacterIterator.TextAttribute.ANCHOR_TYPE);
@@ -315,7 +315,7 @@ public class PSTextPainter implements TextPainter {
default: //nop
}
}
-
+
drawPrimitiveString(g2d, loc, font, txt, tx);
loc.setLocation(loc.getX() + (double)advance, loc.getY());
return loc;
@@ -354,25 +354,25 @@ public class PSTextPainter implements TextPainter {
}
if (ypos != null) {
loc.setLocation(loc.getX(), ypos.doubleValue());
- }
+ }
if (dxpos != null) {
loc.setLocation(loc.getX() + dxpos.doubleValue(), loc.getY());
- }
+ }
if (dypos != null) {
loc.setLocation(loc.getX(), loc.getY() + dypos.doubleValue());
- }
+ }
}
private String getStyle(AttributedCharacterIterator aci) {
Float posture = (Float)aci.getAttribute(TextAttribute.POSTURE);
return ((posture != null) && (posture.floatValue() > 0.0))
- ? "italic"
+ ? "italic"
: "normal";
}
private int getWeight(AttributedCharacterIterator aci) {
Float taWeight = (Float)aci.getAttribute(TextAttribute.WEIGHT);
- return ((taWeight != null) && (taWeight.floatValue() > 1.0))
+ return ((taWeight != null) && (taWeight.floatValue() > 1.0))
? Font.WEIGHT_BOLD
: Font.WEIGHT_NORMAL;
}
@@ -479,8 +479,8 @@ public class PSTextPainter implements TextPainter {
* @return the bounds of the text
*/
public Rectangle2D getBounds2D(TextNode node) {
- /* (todo) getBounds2D() is too slow
- * because it uses the StrokingTextPainter. We should implement this
+ /* (todo) getBounds2D() is too slow
+ * because it uses the StrokingTextPainter. We should implement this
* method ourselves. */
return PROXY_PAINTER.getBounds2D(node);
}
diff --git a/src/java/org/apache/fop/render/ps/PSTranscoder.java b/src/java/org/apache/fop/render/ps/PSTranscoder.java
index fd252b447..3585ab2f8 100644
--- a/src/java/org/apache/fop/render/ps/PSTranscoder.java
+++ b/src/java/org/apache/fop/render/ps/PSTranscoder.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/ps/ResourceHandler.java b/src/java/org/apache/fop/render/ps/ResourceHandler.java
index 1a363c90e..bdd305164 100644
--- a/src/java/org/apache/fop/render/ps/ResourceHandler.java
+++ b/src/java/org/apache/fop/render/ps/ResourceHandler.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -94,18 +94,18 @@ public class ResourceHandler implements DSCParserConstants, PSSupportedFlavors {
* @throws DSCException If there's an error in the DSC structure of the PS file
* @throws IOException In case of an I/O error
*/
- public static void process(FOUserAgent userAgent, InputStream in, OutputStream out,
+ public static void process(FOUserAgent userAgent, InputStream in, OutputStream out,
FontInfo fontInfo, ResourceTracker resTracker, Map formResources,
int pageCount, Rectangle2D documentBoundingBox)
throws DSCException, IOException {
DSCParser parser = new DSCParser(in);
PSGenerator gen = new PSGenerator(out);
parser.setNestedDocumentHandler(new DefaultNestedDocumentHandler(gen));
-
+
//Skip DSC header
DSCHeaderComment header = DSCTools.checkAndSkipDSC30Header(parser);
header.generate(gen);
-
+
parser.setFilter(new DSCFilter() {
private final Set filtered = new java.util.HashSet();
{
@@ -141,15 +141,15 @@ public class ResourceHandler implements DSCParserConstants, PSSupportedFlavors {
PSFontUtils.determineSuppliedFonts(resTracker, fontInfo, fontInfo.getUsedFonts());
registerSuppliedForms(resTracker, formResources);
-
+
//Supplied Resources
- DSCCommentDocumentSuppliedResources supplied
+ DSCCommentDocumentSuppliedResources supplied
= new DSCCommentDocumentSuppliedResources(
resTracker.getDocumentSuppliedResources());
supplied.generate(gen);
-
+
//Needed Resources
- DSCCommentDocumentNeededResources needed
+ DSCCommentDocumentNeededResources needed
= new DSCCommentDocumentNeededResources(
resTracker.getDocumentNeededResources());
needed.generate(gen);
@@ -167,7 +167,7 @@ public class ResourceHandler implements DSCParserConstants, PSSupportedFlavors {
}
event.generate(gen);
}
-
+
//Skip to the FOPFontSetup
PostScriptComment fontSetupPlaceholder = parser.nextPSComment("FOPFontSetup", gen);
if (fontSetupPlaceholder == null) {
@@ -181,7 +181,7 @@ public class ResourceHandler implements DSCParserConstants, PSSupportedFlavors {
if (pageOrTrailer == null) {
throw new DSCException("Page expected, but none found");
}
-
+
//Process individual pages (and skip as necessary)
while (true) {
DSCCommentPage page = (DSCCommentPage)pageOrTrailer;
@@ -194,7 +194,7 @@ public class ResourceHandler implements DSCParserConstants, PSSupportedFlavors {
break;
}
}
-
+
//Write the rest
while (parser.hasNext()) {
DSCEvent event = parser.nextEvent();
@@ -218,7 +218,7 @@ public class ResourceHandler implements DSCParserConstants, PSSupportedFlavors {
}
}
- private static void generateForms(ResourceTracker resTracker, FOUserAgent userAgent,
+ private static void generateForms(ResourceTracker resTracker, FOUserAgent userAgent,
Map formResources, PSGenerator gen) throws IOException {
if (formResources == null) {
return;
@@ -227,13 +227,13 @@ public class ResourceHandler implements DSCParserConstants, PSSupportedFlavors {
while (iter.hasNext()) {
PSImageFormResource form = (PSImageFormResource)iter.next();
final String uri = form.getImageURI();
-
+
ImageManager manager = userAgent.getFactory().getImageManager();
ImageInfo info = null;
try {
ImageSessionContext sessionContext = userAgent.getImageSessionContext();
info = manager.getImageInfo(uri, sessionContext);
-
+
ImageFlavor[] flavors;
if (gen.getPSLevel() >= 3) {
flavors = LEVEL_3_FLAVORS_FORM;
@@ -243,7 +243,7 @@ public class ResourceHandler implements DSCParserConstants, PSSupportedFlavors {
Map hints = ImageUtil.getDefaultHints(sessionContext);
org.apache.xmlgraphics.image.loader.Image img = manager.getImage(
info, flavors, hints, sessionContext);
-
+
String imageDescription = info.getMimeType() + " " + info.getOriginalURI();
final Dimension2D dimensionsPt = info.getSize().getDimensionPt();
final Dimension2D dimensionsMpt = info.getSize().getDimensionMpt();
@@ -261,12 +261,12 @@ public class ResourceHandler implements DSCParserConstants, PSSupportedFlavors {
PSGraphics2DAdapter adapter = new PSGraphics2DAdapter(gen, false);
adapter.paintImage(imageG2D.getGraphics2DImagePainter(),
null,
- 0, 0,
+ 0, 0,
(int)Math.round(dimensionsMpt.getWidth()),
(int)Math.round(dimensionsMpt.getHeight()));
gen.writeln("EndEPSF");
}
-
+
};
formGen.generate(gen);
} else if (img instanceof ImageRendered) {
@@ -349,9 +349,9 @@ public class ResourceHandler implements DSCParserConstants, PSSupportedFlavors {
gen.writeln("1 0 lineto");
gen.writeln("stroke");
}
-
+
};
return formGen;
}
-
+
}
diff --git a/src/java/org/apache/fop/render/ps/extensions/AbstractPSCommentElement.java b/src/java/org/apache/fop/render/ps/extensions/AbstractPSCommentElement.java
index 1eb1d9d13..a8bab26b6 100644
--- a/src/java/org/apache/fop/render/ps/extensions/AbstractPSCommentElement.java
+++ b/src/java/org/apache/fop/render/ps/extensions/AbstractPSCommentElement.java
@@ -30,17 +30,17 @@ public abstract class AbstractPSCommentElement extends AbstractPSExtensionElemen
/**
* Default constructor
- *
+ *
* @param parent parent of this node
* @see org.apache.fop.fo.FONode#FONode(FONode)
*/
public AbstractPSCommentElement(FONode parent) {
super(parent);
- }
-
+ }
+
/**
* @throws FOPException if there's a problem during processing
- * @see org.apache.fop.fo.FONode#startOfNode()
+ * @see org.apache.fop.fo.FONode#startOfNode()
*/
protected void startOfNode() throws FOPException {
if (parent.getNameId() != Constants.FO_DECLARATIONS
diff --git a/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionElement.java b/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionElement.java
index 31e44d2d2..14865a8c9 100644
--- a/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionElement.java
+++ b/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionElement.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
*/
/* $Id$ */
-
+
package org.apache.fop.render.ps.extensions;
// FOP
@@ -37,10 +37,10 @@ public abstract class AbstractPSExtensionElement extends FONode {
* extension attachment
*/
protected PSExtensionAttachment attachment;
-
+
/**
* Default constructor
- *
+ *
* @param parent parent of this node
* @see org.apache.fop.fo.FONode#FONode(FONode)
*/
@@ -50,14 +50,14 @@ public abstract class AbstractPSExtensionElement extends FONode {
/**
* Blocks XSL FO's from having non-FO parents.
- *
+ *
* @param loc location in the FO source file
* @param nsURI namespace of incoming node
* @param localName (e.g. "table" for "fo:table")
* @throws ValidationException if incoming node not valid for parent
* @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
*/
- protected void validateChildNode(Locator loc, String nsURI, String localName)
+ protected void validateChildNode(Locator loc, String nsURI, String localName)
throws ValidationException {
if (FO_URI.equals(nsURI)) {
invalidChildError(loc, nsURI, localName);
@@ -69,7 +69,7 @@ public abstract class AbstractPSExtensionElement extends FONode {
* @param data array of characters containing text to be added
* @param start starting array element to add
* @param length of data array to add
- * @param pList currently applicable PropertyList
+ * @param pList currently applicable PropertyList
* @param locator location in fo source file.
* @see org.apache.fop.fo.FONode#addCharacters(char[], int, int, PropertyList, Locator)
*/
@@ -92,7 +92,7 @@ public abstract class AbstractPSExtensionElement extends FONode {
public String getNamespaceURI() {
return PSExtensionElementMapping.NAMESPACE;
}
-
+
/**
* @return a String representation of this object
* @see org.apache.fop.fo.FONode#getNormalNamespacePrefix()
@@ -112,7 +112,7 @@ public abstract class AbstractPSExtensionElement extends FONode {
missingChildElementError("#PCDATA");
}
}
-
+
/**
* @return the extension attachment if one is created by the extension element, null otherwise.
* @see org.apache.fop.fo.FONode#getExtensionAttachment()
@@ -123,7 +123,7 @@ public abstract class AbstractPSExtensionElement extends FONode {
}
return this.attachment;
}
-
+
/**
* Instantiates extension attachment object
* @return extension attachment
diff --git a/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionObject.java b/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionObject.java
index 78b2f91eb..92108b551 100644
--- a/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionObject.java
+++ b/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionObject.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
*/
/* $Id$ */
-
+
package org.apache.fop.render.ps.extensions;
// FOP
@@ -35,7 +35,7 @@ import org.apache.fop.fo.extensions.ExtensionAttachment;
public abstract class AbstractPSExtensionObject extends FONode {
private PSSetupCode setupCode = new PSSetupCode();
-
+
/**
* Main constructor.
* @param parent the parent node
@@ -46,7 +46,7 @@ public abstract class AbstractPSExtensionObject extends FONode {
}
/** {@inheritDoc} */
- protected void validateChildNode(Locator loc, String nsURI, String localName)
+ protected void validateChildNode(Locator loc, String nsURI, String localName)
throws ValidationException {
if (FO_URI.equals(nsURI)) {
invalidChildError(loc, nsURI, localName);
@@ -69,14 +69,14 @@ public abstract class AbstractPSExtensionObject extends FONode {
public String getNamespaceURI() {
return PSExtensionElementMapping.NAMESPACE;
}
-
+
/**{@inheritDoc} */
public String getNormalNamespacePrefix() {
return "ps";
}
/** {@inheritDoc} */
- public void processNode(String elementName, Locator locator,
+ public void processNode(String elementName, Locator locator,
Attributes attlist, PropertyList propertyList)
throws FOPException {
String name = attlist.getValue("name");
@@ -88,12 +88,12 @@ public abstract class AbstractPSExtensionObject extends FONode {
/** {@inheritDoc} */
protected void endOfNode() throws FOPException {
super.endOfNode();
- String s = setupCode.getContent();
+ String s = setupCode.getContent();
if (s == null || s.length() == 0) {
missingChildElementError("#PCDATA");
}
}
-
+
/** {@inheritDoc} */
public ExtensionAttachment getExtensionAttachment() {
return this.setupCode;
diff --git a/src/java/org/apache/fop/render/ps/extensions/PSCommentAfterElement.java b/src/java/org/apache/fop/render/ps/extensions/PSCommentAfterElement.java
index d03a0220c..eb0f4d833 100644
--- a/src/java/org/apache/fop/render/ps/extensions/PSCommentAfterElement.java
+++ b/src/java/org/apache/fop/render/ps/extensions/PSCommentAfterElement.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -39,7 +39,7 @@ public class PSCommentAfterElement extends AbstractPSCommentElement {
}
/**
- * @return local name
+ * @return local name
* @see org.apache.fop.fo.FONode#getLocalName()
*/
public String getLocalName() {
diff --git a/src/java/org/apache/fop/render/ps/extensions/PSCommentBeforeElement.java b/src/java/org/apache/fop/render/ps/extensions/PSCommentBeforeElement.java
index d74d3a194..951e685b3 100644
--- a/src/java/org/apache/fop/render/ps/extensions/PSCommentBeforeElement.java
+++ b/src/java/org/apache/fop/render/ps/extensions/PSCommentBeforeElement.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -51,5 +51,5 @@ public class PSCommentBeforeElement extends AbstractPSCommentElement {
*/
protected ExtensionAttachment instantiateExtensionAttachment() {
return new PSCommentBefore();
- }
+ }
}
diff --git a/src/java/org/apache/fop/render/ps/extensions/PSExtensionAttachment.java b/src/java/org/apache/fop/render/ps/extensions/PSExtensionAttachment.java
index 9da2b0911..efee86aa8 100644
--- a/src/java/org/apache/fop/render/ps/extensions/PSExtensionAttachment.java
+++ b/src/java/org/apache/fop/render/ps/extensions/PSExtensionAttachment.java
@@ -31,7 +31,7 @@ import org.apache.fop.fo.extensions.ExtensionAttachment;
* This is the pass-through value object for the PostScript extension.
*/
public abstract class PSExtensionAttachment implements ExtensionAttachment, XMLizable {
-
+
/** extension node content */
protected String content;
@@ -59,12 +59,12 @@ public abstract class PSExtensionAttachment implements ExtensionAttachment, XMLi
public String getCategory() {
return CATEGORY;
}
-
+
/** @return the content */
public String getContent() {
return content;
}
-
+
/**
* Sets the content for the setup code object.
* @param content The content to set.
@@ -72,10 +72,10 @@ public abstract class PSExtensionAttachment implements ExtensionAttachment, XMLi
public void setContent(String content) {
this.content = content;
}
-
+
/**
* Generates SAX events representing the object's state.
- *
+ *
* @param handler ContentHandler instance to send the SAX events to
* @throws SAXException if there's a problem generating the SAX events
* @see org.apache.xmlgraphics.util.XMLizable#toSAX(org.xml.sax.ContentHandler)
@@ -96,7 +96,7 @@ public abstract class PSExtensionAttachment implements ExtensionAttachment, XMLi
String className = getClass().getName();
return className.substring(className.lastIndexOf('.') + 3);
}
-
+
/**
* @return a string representation of this object
* @see java.lang.Object#toString()
diff --git a/src/java/org/apache/fop/render/ps/extensions/PSExtensionElementMapping.java b/src/java/org/apache/fop/render/ps/extensions/PSExtensionElementMapping.java
index b23ff54da..2044385a8 100644
--- a/src/java/org/apache/fop/render/ps/extensions/PSExtensionElementMapping.java
+++ b/src/java/org/apache/fop/render/ps/extensions/PSExtensionElementMapping.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
*/
/* $Id$ */
-
+
package org.apache.fop.render.ps.extensions;
import org.apache.fop.fo.FONode;
@@ -28,7 +28,7 @@ import org.apache.fop.fo.ElementMapping;
public class PSExtensionElementMapping extends ElementMapping {
/** Namespace for the extension */
- public static final String NAMESPACE = "http://xmlgraphics.apache.org/fop/postscript";
+ public static final String NAMESPACE = "http://xmlgraphics.apache.org/fop/postscript";
/** Main constructor */
public PSExtensionElementMapping() {
@@ -64,7 +64,7 @@ public class PSExtensionElementMapping extends ElementMapping {
return new PSSetPageDeviceElement(parent);
}
}
-
+
static class PSCommentBeforeMaker extends ElementMapping.Maker {
public FONode make(FONode parent) {
return new PSCommentBeforeElement(parent);
diff --git a/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandler.java b/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandler.java
index e69500736..dee918f19 100644
--- a/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandler.java
+++ b/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandler.java
@@ -32,7 +32,7 @@ import org.apache.fop.util.ContentHandlerFactory.ObjectBuiltListener;
/**
* ContentHandler (parser) for restoring PSExtension objects from XML.
*/
-public class PSExtensionHandler extends DefaultHandler
+public class PSExtensionHandler extends DefaultHandler
implements ContentHandlerFactory.ObjectSource {
/** Logger instance */
@@ -40,12 +40,12 @@ public class PSExtensionHandler extends DefaultHandler
private StringBuffer content = new StringBuffer();
private Attributes lastAttributes;
-
+
private PSExtensionAttachment returnedObject;
private ObjectBuiltListener listener;
-
+
/** {@inheritDoc} */
- public void startElement(String uri, String localName, String qName, Attributes attributes)
+ public void startElement(String uri, String localName, String qName, Attributes attributes)
throws SAXException {
boolean handled = false;
if (PSExtensionAttachment.CATEGORY.equals(uri)) {
@@ -61,10 +61,10 @@ public class PSExtensionHandler extends DefaultHandler
}
if (!handled) {
if (PSExtensionAttachment.CATEGORY.equals(uri)) {
- throw new SAXException("Unhandled element " + localName
+ throw new SAXException("Unhandled element " + localName
+ " in namespace: " + uri);
} else {
- log.warn("Unhandled element " + localName
+ log.warn("Unhandled element " + localName
+ " in namespace: " + uri);
}
}
@@ -78,13 +78,13 @@ public class PSExtensionHandler extends DefaultHandler
this.returnedObject = new PSSetupCode(name, content.toString());
} else if (PSSetPageDevice.ELEMENT.equals(localName)) {
String name = lastAttributes.getValue("name");
- this.returnedObject = new PSSetPageDevice(name, content.toString());
+ this.returnedObject = new PSSetPageDevice(name, content.toString());
} else if (PSCommentBefore.ELEMENT.equals(localName)) {
- this.returnedObject = new PSCommentBefore(content.toString());
+ this.returnedObject = new PSCommentBefore(content.toString());
} else if (PSCommentAfter.ELEMENT.equals(localName)) {
this.returnedObject = new PSCommentAfter(content.toString());
}
- }
+ }
content.setLength(0); //Reset text buffer (see characters())
}
diff --git a/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandlerFactory.java b/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandlerFactory.java
index 655c96260..d94e236f7 100644
--- a/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandlerFactory.java
+++ b/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandlerFactory.java
@@ -28,7 +28,7 @@ import org.xml.sax.ContentHandler;
public class PSExtensionHandlerFactory implements ContentHandlerFactory {
private static final String[] NAMESPACES = new String[] {PSSetupCode.CATEGORY};
-
+
/** {@inheritDoc} */
public String[] getSupportedNamespaces() {
return NAMESPACES;
diff --git a/src/java/org/apache/fop/render/ps/extensions/PSPageSetupCodeElement.java b/src/java/org/apache/fop/render/ps/extensions/PSPageSetupCodeElement.java
index 207c11e76..686667c3d 100644
--- a/src/java/org/apache/fop/render/ps/extensions/PSPageSetupCodeElement.java
+++ b/src/java/org/apache/fop/render/ps/extensions/PSPageSetupCodeElement.java
@@ -24,13 +24,13 @@ import org.apache.fop.fo.Constants;
import org.apache.fop.fo.FONode;
/**
- * Extension element for fox:ps-page-setup-code.
+ * Extension element for fox:ps-page-setup-code.
*/
public class PSPageSetupCodeElement extends AbstractPSExtensionObject {
/** The element name */
protected static final String ELEMENT = "ps-page-setup-code";
-
+
/**
* Main constructor
* @param parent parent FO node
@@ -47,7 +47,7 @@ public class PSPageSetupCodeElement extends AbstractPSExtensionObject {
"rule.childOfSPM");
}
}
-
+
/** {@inheritDoc} */
public String getLocalName() {
return ELEMENT;
diff --git a/src/java/org/apache/fop/render/ps/extensions/PSSetPageDevice.java b/src/java/org/apache/fop/render/ps/extensions/PSSetPageDevice.java
index 28ea3c24c..8bdb2adc0 100644
--- a/src/java/org/apache/fop/render/ps/extensions/PSSetPageDevice.java
+++ b/src/java/org/apache/fop/render/ps/extensions/PSSetPageDevice.java
@@ -62,12 +62,12 @@ public class PSSetPageDevice extends PSExtensionAttachment {
*/
public PSSetPageDevice() {
}
-
+
/** @return the name */
public String getName() {
return name;
}
-
+
/**
* Sets the name of the setup code object.
* @param name The name to set.
@@ -77,7 +77,7 @@ public class PSSetPageDevice extends PSExtensionAttachment {
}
/**
- * @return a string representation of this object
+ * @return a string representation of this object
* @see java.lang.Object#toString()
*/
public String toString() {
diff --git a/src/java/org/apache/fop/render/ps/extensions/PSSetPageDeviceElement.java b/src/java/org/apache/fop/render/ps/extensions/PSSetPageDeviceElement.java
index 21acc8001..6cdd1c60c 100644
--- a/src/java/org/apache/fop/render/ps/extensions/PSSetPageDeviceElement.java
+++ b/src/java/org/apache/fop/render/ps/extensions/PSSetPageDeviceElement.java
@@ -29,7 +29,7 @@ import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.extensions.ExtensionAttachment;
/**
- * Extension element for ps:ps-setpagedevice.
+ * Extension element for ps:ps-setpagedevice.
*/
public class PSSetPageDeviceElement extends AbstractPSExtensionElement {
@@ -69,7 +69,7 @@ public class PSSetPageDeviceElement extends AbstractPSExtensionElement {
* @throws FOPException if there's a problem during processing
* @see org.apache.fop.fo.FONode#processNode
*/
- public void processNode(String elementName, Locator locator,
+ public void processNode(String elementName, Locator locator,
Attributes attlist, PropertyList propertyList)
throws FOPException {
String name = attlist.getValue("name");
@@ -79,7 +79,7 @@ public class PSSetPageDeviceElement extends AbstractPSExtensionElement {
}
/**
- * @return local name
+ * @return local name
* @see org.apache.fop.fo.FONode#getLocalName() */
public String getLocalName() {
return ELEMENT;
diff --git a/src/java/org/apache/fop/render/ps/extensions/PSSetupCode.java b/src/java/org/apache/fop/render/ps/extensions/PSSetupCode.java
index eb3ed0e39..e2236629c 100644
--- a/src/java/org/apache/fop/render/ps/extensions/PSSetupCode.java
+++ b/src/java/org/apache/fop/render/ps/extensions/PSSetupCode.java
@@ -31,7 +31,7 @@ public class PSSetupCode extends PSExtensionAttachment {
* element name
*/
protected static final String ELEMENT = "ps-setup-code";
-
+
private static final String ATT_NAME = "name";
/**
@@ -44,7 +44,7 @@ public class PSSetupCode extends PSExtensionAttachment {
*/
public PSSetupCode() {
}
-
+
/**
* Default constructor.
* @param name the name of the setup code object, may be null
@@ -54,12 +54,12 @@ public class PSSetupCode extends PSExtensionAttachment {
super(content);
this.name = name;
}
-
+
/** @return the name */
public String getName() {
return name;
}
-
+
/**
* Sets the name of the setup code object.
* @param name The name to set.
@@ -72,7 +72,7 @@ public class PSSetupCode extends PSExtensionAttachment {
public String getCategory() {
return CATEGORY;
}
-
+
/** {@inheritDoc} */
public String toString() {
return "PSSetupCode(name=" + getName() + ", content='" + getContent() + "')";
@@ -85,7 +85,7 @@ public class PSSetupCode extends PSExtensionAttachment {
protected String getElement() {
return ELEMENT;
}
-
+
/** {@inheritDoc} */
public void toSAX(ContentHandler handler) throws SAXException {
AttributesImpl atts = new AttributesImpl();
diff --git a/src/java/org/apache/fop/render/ps/extensions/PSSetupCodeElement.java b/src/java/org/apache/fop/render/ps/extensions/PSSetupCodeElement.java
index e76dfeb64..4ac0af2b7 100644
--- a/src/java/org/apache/fop/render/ps/extensions/PSSetupCodeElement.java
+++ b/src/java/org/apache/fop/render/ps/extensions/PSSetupCodeElement.java
@@ -24,13 +24,13 @@ import org.apache.fop.fo.Constants;
import org.apache.fop.fo.FONode;
/**
- * Extension element for fox:ps-setup-code.
+ * Extension element for fox:ps-setup-code.
*/
public class PSSetupCodeElement extends AbstractPSExtensionObject {
/** The element name */
protected static final String ELEMENT = "ps-setup-code";
-
+
/**
* Main constructor
* @param parent parent FO node
@@ -38,7 +38,7 @@ public class PSSetupCodeElement extends AbstractPSExtensionObject {
public PSSetupCodeElement(FONode parent) {
super(parent);
}
-
+
/** {@inheritDoc} */
protected void startOfNode() throws FOPException {
super.startOfNode();
@@ -47,10 +47,10 @@ public class PSSetupCodeElement extends AbstractPSExtensionObject {
"rule.childOfDeclarations");
}
}
-
+
/** {@inheritDoc} */
public String getLocalName() {
return ELEMENT;
}
-
+
}
diff --git a/src/java/org/apache/fop/render/rtf/BorderAttributesConverter.java b/src/java/org/apache/fop/render/rtf/BorderAttributesConverter.java
index 5d6a7f64e..216802c8f 100644
--- a/src/java/org/apache/fop/render/rtf/BorderAttributesConverter.java
+++ b/src/java/org/apache/fop/render/rtf/BorderAttributesConverter.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -42,12 +42,12 @@ public final class BorderAttributesConverter {
*/
private BorderAttributesConverter() {
}
-
+
/**
- * Create a border control word in attributes, with border properties
+ * Create a border control word in attributes, with border properties
* as specified in color, style and width.
* @param border The CommonBorderPaddingBackground object.
- * @param side The START, END, BEFORE, AFTER enum from CommonBorderPaddingBackground.
+ * @param side The START, END, BEFORE, AFTER enum from CommonBorderPaddingBackground.
* @param attributes The attributes list to set the border control word.
* @param controlWord The border control word.
*/
@@ -61,18 +61,18 @@ public final class BorderAttributesConverter {
//division by 50 to convert millipoints to twips
attrs.set(IBorderAttributes.BORDER_WIDTH, border.getBorderWidth(side, false) / 50);
attributes.set(controlWord, attrs);
- //Don't set BORDER_SPACE, because it makes the table look quite broken:
+ //Don't set BORDER_SPACE, because it makes the table look quite broken:
//vertical and horizontal borders don't meet at corners.
//attrs.setTwips(IBorderAttributes.BORDER_SPACE, border.getPadding(side, false, null));
//attributes.set(controlWord, attrs);
} else {
// Here padding specified, but corresponding border is not available
-
+
// Padding in millipoints
double paddingPt = border.getPadding(side, false, null) / 1000.0;
// Padding in twips
int padding = (int) Math.round(paddingPt * FoUnitsConverter.POINT_TO_TWIPS);
-
+
// Add padding to corresponding space (space-before or space-after)
// if side == START or END, do nothing
if (side == CommonBorderPaddingBackground.BEFORE) {
diff --git a/src/java/org/apache/fop/render/rtf/FOPRtfAttributes.java b/src/java/org/apache/fop/render/rtf/FOPRtfAttributes.java
index 20100fb7d..0cfa3e0fe 100755
--- a/src/java/org/apache/fop/render/rtf/FOPRtfAttributes.java
+++ b/src/java/org/apache/fop/render/rtf/FOPRtfAttributes.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -28,7 +28,7 @@ import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfColorTable;
/**
- * A RtfAttributes subclass that adds some helper set methods.
+ * A RtfAttributes subclass that adds some helper set methods.
*/
public class FOPRtfAttributes extends RtfAttributes {
@@ -83,16 +83,16 @@ public class FOPRtfAttributes extends RtfAttributes {
}
private static class DummyPercentBaseContext implements PercentBaseContext {
-
+
static DummyPercentBaseContext singleton = new DummyPercentBaseContext();
-
+
private DummyPercentBaseContext() {
// noop
}
-
+
public int getBaseLength(int lengthBase, FObj fo) {
return 0;
}
}
-
+
}
diff --git a/src/java/org/apache/fop/render/rtf/FoUnitsConverter.java b/src/java/org/apache/fop/render/rtf/FoUnitsConverter.java
index fa95b8502..caf11323f 100644
--- a/src/java/org/apache/fop/render/rtf/FoUnitsConverter.java
+++ b/src/java/org/apache/fop/render/rtf/FoUnitsConverter.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/ListAttributesConverter.java b/src/java/org/apache/fop/render/rtf/ListAttributesConverter.java
index 4131b814d..e778c902b 100644
--- a/src/java/org/apache/fop/render/rtf/ListAttributesConverter.java
+++ b/src/java/org/apache/fop/render/rtf/ListAttributesConverter.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -38,13 +38,13 @@ import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfText;
* Provides methods to convert list attributes to RtfAttributes.
*/
public final class ListAttributesConverter {
-
+
/**
* Constructor is private, because it's just a utility class.
*/
private ListAttributesConverter() {
}
-
+
/**
* Reads an FO object's properties and adds returns them as RtfAttributes.
* @param fobj FO object
@@ -53,12 +53,12 @@ public final class ListAttributesConverter {
*/
static RtfAttributes convertAttributes(ListBlock fobj)
throws FOPException {
-
+
FOPRtfAttributes attrib = new FOPRtfAttributes();
-
+
attrib.setTwips(RtfListTable.LIST_INDENT, fobj.getCommonMarginBlock().startIndent);
attrib.setTwips(RtfText.LEFT_INDENT_BODY, fobj.getCommonMarginBlock().endIndent);
-
+
/*
* set list table defaults
*/
@@ -67,7 +67,7 @@ public final class ListAttributesConverter {
attrib.set(RtfListTable.LIST, "simple");
//set following char as tab
attrib.set(RtfListTable.LIST_FOLLOWING_CHAR, 0);
-
+
return attrib;
}
}
\ No newline at end of file
diff --git a/src/java/org/apache/fop/render/rtf/PageAttributesConverter.java b/src/java/org/apache/fop/render/rtf/PageAttributesConverter.java
index 50355e145..c7f97ef4f 100644
--- a/src/java/org/apache/fop/render/rtf/PageAttributesConverter.java
+++ b/src/java/org/apache/fop/render/rtf/PageAttributesConverter.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -46,19 +46,19 @@ final class PageAttributesConverter {
*/
private PageAttributesConverter() {
}
-
+
/** convert xsl:fo attributes to RTF text attributes */
static RtfAttributes convertPageAttributes(SimplePageMaster pagemaster) {
FOPRtfAttributes attrib = new FOPRtfAttributes();
-
+
try {
RegionBA before = (RegionBA) pagemaster.getRegion(Constants.FO_REGION_BEFORE);
RegionBody body = (RegionBody) pagemaster.getRegion(Constants.FO_REGION_BODY);
RegionBA after = (RegionBA) pagemaster.getRegion(Constants.FO_REGION_AFTER);
-
+
attrib.setTwips(RtfPage.PAGE_WIDTH, pagemaster.getPageWidth());
attrib.setTwips(RtfPage.PAGE_HEIGHT, pagemaster.getPageHeight());
-
+
Object widthRaw = attrib.getValue(RtfPage.PAGE_WIDTH);
Object heightRaw = attrib.getValue(RtfPage.PAGE_HEIGHT);
if ((widthRaw instanceof Integer) && (heightRaw instanceof Integer)
@@ -84,7 +84,7 @@ final class PageAttributesConverter {
bodyLeft = (Length) NumericOp.addition(pageLeft, bodyMargin.marginLeft);
bodyRight = (Length) NumericOp.addition(pageRight, bodyMargin.marginRight);
}
-
+
attrib.setTwips(RtfPage.MARGIN_TOP, bodyTop);
attrib.setTwips(RtfPage.MARGIN_BOTTOM, bodyBottom);
attrib.setTwips(RtfPage.MARGIN_LEFT, bodyLeft);
@@ -104,7 +104,7 @@ final class PageAttributesConverter {
}
attrib.setTwips(RtfPage.FOOTERY, beforeTop);
} catch (Exception e) {
- log.error("Exception in convertPageAttributes: "
+ log.error("Exception in convertPageAttributes: "
+ e.getMessage() + "- page attributes ignored");
attrib = new FOPRtfAttributes();
}
diff --git a/src/java/org/apache/fop/render/rtf/RTFEventProducer.java b/src/java/org/apache/fop/render/rtf/RTFEventProducer.java
index a2646af46..69058501f 100644
--- a/src/java/org/apache/fop/render/rtf/RTFEventProducer.java
+++ b/src/java/org/apache/fop/render/rtf/RTFEventProducer.java
@@ -34,7 +34,7 @@ public interface RTFEventProducer extends EventProducer {
/** Provider class for the event producer. */
class Provider {
-
+
/**
* Returns an event producer.
* @param broadcaster the event broadcaster to use
@@ -53,9 +53,9 @@ public interface RTFEventProducer extends EventProducer {
public EventModel createEventModel() {
return loadModel(getClass(), "event-model.xml");
}
-
+
}
-
+
/**
* The RTF handler only supports simple-page-masters.
* @param source the event source
@@ -64,7 +64,7 @@ public interface RTFEventProducer extends EventProducer {
* @event.severity WARN
*/
void onlySPMSupported(Object source, String masterReference, Locator loc);
-
+
/**
* No simple-page-master could be determined-
* @param source the event source
@@ -72,7 +72,7 @@ public interface RTFEventProducer extends EventProducer {
* @event.severity WARN
*/
void noSPMFound(Object source, Locator loc);
-
+
/**
* The RTF handler requires explicit table-columns for now.
* @param source the event source
@@ -80,7 +80,7 @@ public interface RTFEventProducer extends EventProducer {
* @event.severity WARN
*/
void explicitTableColumnsRequired(Object source, Locator loc);
-
+
/**
* The RTF handler ignored some deferred event (i.e. an unsupported element).
* @param source the event source
@@ -90,5 +90,5 @@ public interface RTFEventProducer extends EventProducer {
* @event.severity WARN
*/
void ignoredDeferredEvent(Object source, FONode node, boolean start, Locator loc);
-
+
}
diff --git a/src/java/org/apache/fop/render/rtf/RTFFOEventHandlerMaker.java b/src/java/org/apache/fop/render/rtf/RTFFOEventHandlerMaker.java
index a15d206ee..afcfbf702 100644
--- a/src/java/org/apache/fop/render/rtf/RTFFOEventHandlerMaker.java
+++ b/src/java/org/apache/fop/render/rtf/RTFFOEventHandlerMaker.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -35,8 +35,8 @@ public class RTFFOEventHandlerMaker extends AbstractFOEventHandlerMaker {
MimeConstants.MIME_RTF,
MimeConstants.MIME_RTF_ALT1,
MimeConstants.MIME_RTF_ALT2};
-
-
+
+
/**
* {@inheritDoc}
* @param ua FOUserAgent
diff --git a/src/java/org/apache/fop/render/rtf/RTFHandler.java b/src/java/org/apache/fop/render/rtf/RTFHandler.java
index 6171e68b4..1adba9e2b 100644
--- a/src/java/org/apache/fop/render/rtf/RTFHandler.java
+++ b/src/java/org/apache/fop/render/rtf/RTFHandler.java
@@ -213,7 +213,7 @@ public class RTFHandler extends FOEventHandler {
RTFEventProducer eventProducer = RTFEventProducer.Provider.get(
getUserAgent().getEventBroadcaster());
eventProducer.onlySPMSupported(this, reference, pageSeq.getLocator());
- PageSequenceMaster master
+ PageSequenceMaster master
= pageSeq.getRoot().getLayoutMasterSet().getPageSequenceMaster(reference);
this.pagemaster = master.getNextSimplePageMaster(
false, false, false, false, false);
@@ -306,7 +306,7 @@ public class RTFHandler extends FOEventHandler {
contAfter.newAfter(attr);
}
handled = true;
- } else if (regionBefore != null
+ } else if (regionBefore != null
&& fl.getFlowName().equals(regionBefore.getRegionName())) {
bHeaderSpecified = true;
bPrevHeaderSpecified = true;
@@ -325,7 +325,7 @@ public class RTFHandler extends FOEventHandler {
RtfBefore before = c.newBefore(beforeAttributes);
builderContext.pushContainer(before);
handled = true;
- } else if (regionAfter != null
+ } else if (regionAfter != null
&& fl.getFlowName().equals(regionAfter.getRegionName())) {
bFooterSpecified = true;
bPrevFooterSpecified = true;
@@ -371,10 +371,10 @@ public class RTFHandler extends FOEventHandler {
Region regionAfter = pagemaster.getRegion(Constants.FO_REGION_AFTER);
if (fl.getFlowName().equals(regionBody.getRegionName())) {
//just do nothing
- } else if (regionBefore != null
+ } else if (regionBefore != null
&& fl.getFlowName().equals(regionBefore.getRegionName())) {
builderContext.popContainer();
- } else if (regionAfter != null
+ } else if (regionAfter != null
&& fl.getFlowName().equals(regionAfter.getRegionName())) {
builderContext.popContainer();
}
@@ -514,15 +514,15 @@ public class RTFHandler extends FOEventHandler {
final IRtfTableContainer tc
= (IRtfTableContainer)builderContext.getContainer(
IRtfTableContainer.class, true, null);
-
+
RtfAttributes atts
= TableAttributesConverter.convertTableAttributes(tbl);
-
+
RtfTable table = tc.newTable(atts, tableContext);
-
+
CommonBorderPaddingBackground border = tbl.getCommonBorderPaddingBackground();
RtfAttributes borderAttributes = new RtfAttributes();
-
+
BorderAttributesConverter.makeBorder(border, CommonBorderPaddingBackground.BEFORE,
borderAttributes, ITableAttributes.CELL_BORDER_TOP);
BorderAttributesConverter.makeBorder(border, CommonBorderPaddingBackground.AFTER,
@@ -531,9 +531,9 @@ public class RTFHandler extends FOEventHandler {
borderAttributes, ITableAttributes.CELL_BORDER_LEFT);
BorderAttributesConverter.makeBorder(border, CommonBorderPaddingBackground.END,
borderAttributes, ITableAttributes.CELL_BORDER_RIGHT);
-
+
table.setBorderAttributes(borderAttributes);
-
+
builderContext.pushContainer(table);
} catch (IOException ioe) {
handleIOTrouble(ioe);
@@ -576,16 +576,16 @@ public class RTFHandler extends FOEventHandler {
* rest of the document will be rendered. Usage of the
* TableLayoutManager is not welcome due to design reasons and
* it also does not provide the correct values.
- * TODO: Make proportional-column-width working for rtf output
+ * TODO: Make proportional-column-width working for rtf output
*/
SimplePercentBaseContext context
= new SimplePercentBaseContext(null,
LengthBase.TABLE_UNITS,
100000);
-
+
Integer iWidth
= new Integer(tc.getColumnWidth().getValue(context) / 1000);
-
+
String strWidth = iWidth.toString() + FixedLength.POINT;
Float width = new Float(
FoUnitsConverter.getInstance().convertToTwips(strWidth));
@@ -708,7 +708,7 @@ public class RTFHandler extends FOEventHandler {
} catch (Exception e) {
log.error("startPart: " + e.getMessage());
throw new RuntimeException(e.getMessage());
- }
+ }
}
private void endPart(TablePart tb) {
@@ -724,10 +724,10 @@ public class RTFHandler extends FOEventHandler {
} catch (Exception e) {
log.error("endPart: " + e.getMessage());
throw new RuntimeException(e.getMessage());
- }
+ }
}
-
+
/**
* {@inheritDoc}
*/
@@ -735,7 +735,7 @@ public class RTFHandler extends FOEventHandler {
startPart(body);
}
-
+
/**
* {@inheritDoc}
*/
@@ -782,7 +782,7 @@ public class RTFHandler extends FOEventHandler {
if (bDefer) {
return;
}
-
+
try {
TableContext tctx = builderContext.getTableContext();
final RtfTableRow row = (RtfTableRow)builderContext.getContainer(RtfTableRow.class,
@@ -795,11 +795,11 @@ public class RTFHandler extends FOEventHandler {
RtfTableCell vCell = row.newTableCellMergedVertically(
(int)tctx.getColumnWidth(),
tctx.getColumnRowSpanningAttrs());
-
+
if (!tctx.getFirstSpanningCol()) {
vCell.setHMerge(RtfTableCell.MERGE_WITH_PREVIOUS);
}
-
+
tctx.selectNextColumn();
}
} catch (IOException ioe) {
@@ -837,11 +837,11 @@ public class RTFHandler extends FOEventHandler {
RtfTableCell vCell = row.newTableCellMergedVertically(
(int)tctx.getColumnWidth(),
tctx.getColumnRowSpanningAttrs());
-
+
if (!tctx.getFirstSpanningCol()) {
vCell.setHMerge(RtfTableCell.MERGE_WITH_PREVIOUS);
}
-
+
tctx.selectNextColumn();
}
@@ -851,14 +851,14 @@ public class RTFHandler extends FOEventHandler {
// create an RtfTableCell in the current RtfTableRow
RtfAttributes atts = TableAttributesConverter.convertCellAttributes(tc);
RtfTableCell cell = row.newTableCell((int)width, atts);
-
+
//process number-rows-spanned attribute
if (numberRowsSpanned > 1) {
// Start vertical merge
cell.setVMerge(RtfTableCell.MERGE_START);
// set the number of rows spanned
- tctx.setCurrentColumnRowSpanning(new Integer(numberRowsSpanned),
+ tctx.setCurrentColumnRowSpanning(new Integer(numberRowsSpanned),
cell.getRtfAttributes());
} else {
tctx.setCurrentColumnRowSpanning(
@@ -870,23 +870,23 @@ public class RTFHandler extends FOEventHandler {
// Get the number of columns spanned
RtfTable table = row.getTable();
tctx.setCurrentFirstSpanningCol(true);
-
+
// We widthdraw one cell because the first cell is already created
// (it's the current cell) !
for (int i = 0; i < numberColumnsSpanned - 1; ++i) {
tctx.selectNextColumn();
-
+
tctx.setCurrentFirstSpanningCol(false);
RtfTableCell hCell = row.newTableCellMergedHorizontally(
0, null);
-
+
if (numberRowsSpanned > 1) {
// Start vertical merge
hCell.setVMerge(RtfTableCell.MERGE_START);
// set the number of rows spanned
tctx.setCurrentColumnRowSpanning(
- new Integer(numberRowsSpanned),
+ new Integer(numberRowsSpanned),
cell.getRtfAttributes());
} else {
tctx.setCurrentColumnRowSpanning(
@@ -894,7 +894,7 @@ public class RTFHandler extends FOEventHandler {
}
}
}
-
+
builderContext.pushContainer(cell);
} catch (IOException ioe) {
handleIOTrouble(ioe);
@@ -962,12 +962,12 @@ public class RTFHandler extends FOEventHandler {
if (bDefer) {
return;
}
-
+
// create an RtfListItem in the current RtfList
try {
RtfList list = (RtfList)builderContext.getContainer(
RtfList.class, true, this);
-
+
/**
* If the current list already contains a list item, then close the
* list and open a new one, so every single list item gets its own
@@ -981,11 +981,11 @@ public class RTFHandler extends FOEventHandler {
this.endList((ListBlock) li.getParent());
this.startList((ListBlock) li.getParent());
this.startListBody();
-
+
list = (RtfList)builderContext.getContainer(
RtfList.class, true, this);
- }
-
+ }
+
builderContext.pushContainer(list.newListItem());
} catch (IOException ioe) {
handleIOTrouble(ioe);
@@ -1136,7 +1136,7 @@ public class RTFHandler extends FOEventHandler {
FOUserAgent userAgent = eg.getUserAgent();
ImageManager manager = userAgent.getFactory().getImageManager();
info = manager.getImageInfo(uri, userAgent.getImageSessionContext());
-
+
putGraphic(eg, info);
} catch (ImageException ie) {
ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
@@ -1160,18 +1160,18 @@ public class RTFHandler extends FOEventHandler {
if (bDefer) {
return;
}
-
+
try {
XMLObj child = (XMLObj) ifo.getChildXMLObj();
Document doc = child.getDOMDocument();
String ns = child.getNamespaceURI();
-
+
ImageInfo info = new ImageInfo(null, null);
// Set the resolution to that of the FOUserAgent
FOUserAgent ua = ifo.getUserAgent();
ImageSize size = new ImageSize();
size.setResolution(ua.getSourceResolution());
-
+
// Set the image size to the size of the svg.
Point2D csize = new Point2D.Float(-1, -1);
Point2D intrinsicDimensions = child.getDimension(csize);
@@ -1188,12 +1188,12 @@ public class RTFHandler extends FOEventHandler {
info.setSize(size);
ImageXMLDOM image = new ImageXMLDOM(info, doc, ns);
-
+
FOUserAgent userAgent = ifo.getUserAgent();
ImageManager manager = userAgent.getFactory().getImageManager();
Image converted = manager.convertImage(image, FLAVORS);
putGraphic(ifo, converted);
-
+
} catch (ImageException ie) {
ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
getUserAgent().getEventBroadcaster());
@@ -1208,14 +1208,14 @@ public class RTFHandler extends FOEventHandler {
private static final ImageFlavor[] FLAVORS = new ImageFlavor[] {
ImageFlavor.RAW_EMF, ImageFlavor.RAW_PNG, ImageFlavor.RAW_JPEG
};
-
+
/**
* Puts a graphic/image into the generated RTF file.
* @param abstractGraphic the graphic (external-graphic or instream-foreign-object)
* @param info the image info object
* @throws IOException In case of an I/O error
*/
- private void putGraphic(AbstractGraphics abstractGraphic, ImageInfo info)
+ private void putGraphic(AbstractGraphics abstractGraphic, ImageInfo info)
throws IOException {
try {
FOUserAgent userAgent = abstractGraphic.getUserAgent();
@@ -1231,17 +1231,17 @@ public class RTFHandler extends FOEventHandler {
eventProducer.imageError(this, null, ie, null);
}
}
-
+
/**
* Puts a graphic/image into the generated RTF file.
* @param abstractGraphic the graphic (external-graphic or instream-foreign-object)
* @param image the image
* @throws IOException In case of an I/O error
*/
- private void putGraphic(AbstractGraphics abstractGraphic, Image image)
+ private void putGraphic(AbstractGraphics abstractGraphic, Image image)
throws IOException {
byte[] rawData = null;
-
+
ImageInfo info = image.getInfo();
if (image instanceof ImageRawStream) {
@@ -1266,7 +1266,7 @@ public class RTFHandler extends FOEventHandler {
IRtfTextrunContainer.class, true, this);
final RtfExternalGraphic rtfGraphic = c.getTextrun().newImage();
-
+
//set URL
if (info.getOriginalURI() != null) {
rtfGraphic.setURL(info.getOriginalURI());
@@ -1341,7 +1341,7 @@ public class RTFHandler extends FOEventHandler {
}
}
}
-
+
/**
* {@inheritDoc}
*/
diff --git a/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java b/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java
index a28d91d36..764c2c93e 100644
--- a/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java
+++ b/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -64,7 +64,7 @@ public final class TableAttributesConverter {
//////////////////////////////////////////////////
/**
* Converts table-only attributes to rtf attributes.
- *
+ *
* @param attrs Given attributes
* @param defaultAttributes Default rtf attributes
*
@@ -75,14 +75,14 @@ public final class TableAttributesConverter {
static RtfAttributes convertTableAttributes(Table fobj)
throws FOPException {
FOPRtfAttributes attrib = new FOPRtfAttributes();
- attrib.setTwips(ITableAttributes.ATTR_ROW_LEFT_INDENT,
+ attrib.setTwips(ITableAttributes.ATTR_ROW_LEFT_INDENT,
fobj.getCommonMarginBlock().marginLeft);
return attrib;
}
/**
* Converts table-only attributes to rtf attributes.
- *
+ *
* @param attrs Given attributes
* @param defaultAttributes Default rtf attributes
*
@@ -109,7 +109,7 @@ public final class TableAttributesConverter {
//Property p;
//RtfColorTable colorTable = RtfColorTable.getInstance();
-
+
FOPRtfAttributes attrib = new FOPRtfAttributes();
//boolean isBorderPresent = false;
@@ -121,7 +121,7 @@ public final class TableAttributesConverter {
//If there is no background-color specified for the cell,
//then try to read it from table-row or table-header.
CommonBorderPaddingBackground brd = null;
-
+
if (fobj.getParent() instanceof TableRow) {
TableRow parentRow = (TableRow)fobj.getParent();
brd = parentRow.getCommonBorderPaddingBackground();
@@ -131,20 +131,20 @@ public final class TableAttributesConverter {
brd = parentHeader.getCommonBorderPaddingBackground();
color = brd.backgroundColor;
}
-
+
if (color == null
- && fobj.getParent() != null
- && fobj.getParent().getParent() != null
+ && fobj.getParent() != null
+ && fobj.getParent().getParent() != null
&& fobj.getParent().getParent().getParent() instanceof Table) {
Table table = (Table)fobj.getParent().getParent().getParent();
brd = table.getCommonBorderPaddingBackground();
color = brd.backgroundColor;
}
-
-
+
+
}
- if ((color != null)
+ if ((color != null)
&& (color.getAlpha() != 0
|| color.getRed() != 0
|| color.getGreen() != 0
@@ -198,13 +198,13 @@ public final class TableAttributesConverter {
attrib.setTwips(ITableAttributes.ATTR_CELL_PADDING_BOTTOM, padding);
attrib.set(ITableAttributes.ATTR_CELL_U_PADDING_BOTTOM, 3 /*=twips*/);
}
-
+
int n = fobj.getNumberColumnsSpanned();
// Column spanning :
if (n > 1) {
attrib.set(ITableAttributes.COLUMN_SPAN, n);
}
-
+
switch (fobj.getDisplayAlign()) {
case Constants.EN_BEFORE:
attrib.set(ITableAttributes.ATTR_CELL_VERT_ALIGN_TOP);
@@ -328,7 +328,7 @@ public final class TableAttributesConverter {
isBorderPresent = true;
}
- //Currently there is only one border width supported in each cell.
+ //Currently there is only one border width supported in each cell.
p = fobj.getProperty(Constants.PR_BORDER_LEFT_WIDTH);
if(p == null) {
p = fobj.getProperty(Constants.PR_BORDER_RIGHT_WIDTH);
diff --git a/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java b/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java
index d40c6a826..792193b15 100644
--- a/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java
+++ b/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -52,13 +52,13 @@ import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfText;
* @author rmarra
*/
final class TextAttributesConverter {
-
+
/**
* Constructor is private, because it's just a utility class.
*/
private TextAttributesConverter() {
}
-
+
/**
* Converts all known text FO properties to RtfAttributes
* @param props list of FO properites, which are to be converted
@@ -106,7 +106,7 @@ final class TextAttributesConverter {
attrBaseLineShift(fobj.getBaseLineShift(), attrib);
return attrib;
}
-
+
/**
* Converts all character related FO properties to RtfAttributes.
* @param fobj FObj whose properties are to be converted
@@ -150,7 +150,7 @@ final class TextAttributesConverter {
} else {
rtfAttr.set("b", 0);
}
-
+
if (font.getFontStyle() == Constants.EN_ITALIC) {
rtfAttr.set(RtfText.ATTR_ITALIC, 1);
} else {
@@ -176,20 +176,20 @@ final class TextAttributesConverter {
- private static void attrTextDecoration(CommonTextDecoration textDecoration,
+ private static void attrTextDecoration(CommonTextDecoration textDecoration,
RtfAttributes rtfAttr) {
if (textDecoration == null) {
rtfAttr.set(RtfText.ATTR_UNDERLINE, 0);
rtfAttr.set(RtfText.ATTR_STRIKETHROUGH, 0);
return;
}
-
+
if (textDecoration.hasUnderline()) {
rtfAttr.set(RtfText.ATTR_UNDERLINE, 1);
} else {
rtfAttr.set(RtfText.ATTR_UNDERLINE, 0);
}
-
+
if (textDecoration.hasLineThrough()) {
rtfAttr.set(RtfText.ATTR_STRIKETHROUGH, 1);
} else {
@@ -198,9 +198,9 @@ final class TextAttributesConverter {
}
private static void attrBlockMargin(CommonMarginBlock cmb, FOPRtfAttributes rtfAttr) {
- rtfAttr.setTwips(RtfText.SPACE_BEFORE,
+ rtfAttr.setTwips(RtfText.SPACE_BEFORE,
cmb.spaceBefore.getOptimum(null).getLength());
- rtfAttr.setTwips(RtfText.SPACE_AFTER,
+ rtfAttr.setTwips(RtfText.SPACE_AFTER,
cmb.spaceAfter.getOptimum(null).getLength());
rtfAttr.setTwips(RtfText.LEFT_INDENT_BODY, cmb.startIndent);
rtfAttr.setTwips(RtfText.RIGHT_INDENT_BODY, cmb.endIndent);
@@ -283,20 +283,20 @@ final class TextAttributesConverter {
CommonBorderPaddingBackground commonBorderPaddingBackground = null;
if (node instanceof Block) {
Block block = (Block) node;
- commonBorderPaddingBackground = block.getCommonBorderPaddingBackground();
- } else if (node instanceof BlockContainer) {
+ commonBorderPaddingBackground = block.getCommonBorderPaddingBackground();
+ } else if (node instanceof BlockContainer) {
BlockContainer container = (BlockContainer) node;
commonBorderPaddingBackground = container.getCommonBorderPaddingBackground();
- }
+ }
- if (commonBorderPaddingBackground != null
+ if (commonBorderPaddingBackground != null
&& commonBorderPaddingBackground.hasBorder()) {
return true;
}
node = node.getParent();
}
- return false;
+ return false;
}
/** Adds inline border information from bpb to rtrAttr. */
@@ -313,7 +313,7 @@ final class TextAttributesConverter {
* @param bl the Block object the properties are read from
* @param rtfAttr the RtfAttributes object the attributes are written to
*/
- private static void attrBackgroundColor(CommonBorderPaddingBackground bpb,
+ private static void attrBackgroundColor(CommonBorderPaddingBackground bpb,
RtfAttributes rtfAttr) {
Color fopValue = bpb.backgroundColor;
int rtfColor = 0;
@@ -334,11 +334,11 @@ final class TextAttributesConverter {
rtfAttr.set(RtfText.ATTR_BACKGROUND_COLOR, rtfColor);
}
-
+
private static void attrBaseLineShift(Length baselineShift, RtfAttributes rtfAttr) {
-
+
int s = baselineShift.getEnum();
-
+
if (s == Constants.EN_SUPER) {
rtfAttr.set(RtfText.ATTR_SUPERSCRIPT);
} else if (s == Constants.EN_SUB) {
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/exceptions/RtfException.java b/src/java/org/apache/fop/render/rtf/rtflib/exceptions/RtfException.java
index d1fd0192e..71bc9ed88 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/exceptions/RtfException.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/exceptions/RtfException.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/exceptions/RtfStructureException.java b/src/java/org/apache/fop/render/rtf/rtflib/exceptions/RtfStructureException.java
index f3502b4aa..7b8a22df2 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/exceptions/RtfStructureException.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/exceptions/RtfStructureException.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IBorderAttributes.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IBorderAttributes.java
index 0e9820994..5b3153b15 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IBorderAttributes.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IBorderAttributes.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfAfterContainer.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfAfterContainer.java
index 6afba3ba1..2fff24afa 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfAfterContainer.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfAfterContainer.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfBeforeContainer.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfBeforeContainer.java
index 7966010b6..87beb24d8 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfBeforeContainer.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfBeforeContainer.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfBookmarkContainer.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfBookmarkContainer.java
index afbbba04b..957ce62f6 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfBookmarkContainer.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfBookmarkContainer.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfExternalGraphicContainer.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfExternalGraphicContainer.java
index 568c33996..14486d8d1 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfExternalGraphicContainer.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfExternalGraphicContainer.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfHyperLinkContainer.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfHyperLinkContainer.java
index 9bc096e7a..194d25653 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfHyperLinkContainer.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfHyperLinkContainer.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfJforCmdContainer.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfJforCmdContainer.java
index d341f80fe..743b10e85 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfJforCmdContainer.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfJforCmdContainer.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfListContainer.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfListContainer.java
index 7e2936ea8..890e00760 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfListContainer.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfListContainer.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfOptions.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfOptions.java
index e620ff996..2083f9b6e 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfOptions.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfOptions.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfPageBreakContainer.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfPageBreakContainer.java
index 6c49e7c08..d30bbb173 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfPageBreakContainer.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfPageBreakContainer.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfPageContainer.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfPageContainer.java
index a7cca6dcf..299ff2169 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfPageContainer.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfPageContainer.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfPageNumberCitationContainer.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfPageNumberCitationContainer.java
index 16f4a4af3..dba341700 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfPageNumberCitationContainer.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfPageNumberCitationContainer.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfPageNumberContainer.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfPageNumberContainer.java
index 1aa5820fb..77832cac2 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfPageNumberContainer.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfPageNumberContainer.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfParagraphContainer.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfParagraphContainer.java
index f2c9b0aa6..f940d9dec 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfParagraphContainer.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfParagraphContainer.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfParagraphKeepTogetherContainer.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfParagraphKeepTogetherContainer.java
index 74a50b8b5..c2b78e8a8 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfParagraphKeepTogetherContainer.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfParagraphKeepTogetherContainer.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfTableContainer.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfTableContainer.java
index a61edf803..afa62807f 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfTableContainer.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfTableContainer.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfTextContainer.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfTextContainer.java
index 1545df320..0522cdf10 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfTextContainer.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfTextContainer.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfTextrunContainer.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfTextrunContainer.java
index 58ca07196..528c05e70 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfTextrunContainer.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IRtfTextrunContainer.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -31,7 +31,7 @@ import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTextrun;
*/
public interface IRtfTextrunContainer {
-
+
/**
* Returns the current RtfTextrun object.
* Opens a new one if necessary.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/ITableAttributes.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/ITableAttributes.java
index e96fbbe30..87f7fe520 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/ITableAttributes.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/ITableAttributes.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -45,13 +45,13 @@ public interface ITableAttributes {
/** half the space between the cells of a table row in twips */
String ATTR_RTF_15_TRGAPH = "trgaph";
-
+
/**
* Position of the leftmost edge of the table with respect to the
* left edge of its column
*/
String ATTR_ROW_LEFT_INDENT = "trleft";
-
+
/** table row header */
String ATTR_HEADER = "trhdr";
@@ -140,7 +140,7 @@ public interface ITableAttributes {
//Table row attributes
/** row attribute, keep-together */
String ROW_KEEP_TOGETHER = "trkeep";
-
+
/** Height of a table row in twips */
String ROW_HEIGHT = "trrh";
@@ -206,5 +206,5 @@ public interface ITableAttributes {
*/
String[] CELL_VERT_ALIGN = {
ATTR_CELL_VERT_ALIGN_TOP, ATTR_CELL_VERT_ALIGN_CENTER, ATTR_CELL_VERT_ALIGN_BOTTOM};
-
+
}
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/ITableColumnsInfo.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/ITableColumnsInfo.java
index d94563c69..dc0e559cc 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/ITableColumnsInfo.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/ITableColumnsInfo.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -50,9 +50,9 @@ public interface ITableColumnsInfo {
/** @return number of columns */
int getNumberOfColumns();
-
+
/**
- *
+ *
* @return true, if it's the first of multiple spanning columns
*/
boolean getFirstSpanningCol();
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IrtfTemplateContainer.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IrtfTemplateContainer.java
index 5a8b6a5b9..a02825b3c 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IrtfTemplateContainer.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/IrtfTemplateContainer.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/ParagraphKeeptogetherContext.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/ParagraphKeeptogetherContext.java
index 79171cb47..aec0237e5 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/ParagraphKeeptogetherContext.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/ParagraphKeeptogetherContext.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAfter.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAfter.java
index 75abb5fbb..078439306 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAfter.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAfter.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAfterBeforeBase.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAfterBeforeBase.java
index f71075d96..5fbde8d3e 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAfterBeforeBase.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAfterBeforeBase.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -123,7 +123,7 @@ implements IRtfParagraphContainer, IRtfExternalGraphicContainer, IRtfTableContai
table = new RtfTable(this, writer, tc);
return table;
}
-
+
public RtfTextrun getTextrun()
throws IOException {
return RtfTextrun.getTextrun(this, writer, null);
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAttributes.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAttributes.java
index 92d6a5655..2eb95b587 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAttributes.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAttributes.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -215,17 +215,17 @@ implements java.lang.Cloneable {
xslAttributes = new org.xml.sax.helpers.AttributesImpl(pAttribs);
}
}
-
+
/**
* Add integer value addValue to attribute with name name.
- * If there is no such setted attribute, then value of this attribure is equal to
+ * If there is no such setted attribute, then value of this attribure is equal to
* addValue.
* @param addValue the increment of value
* @param name the name of attribute
*/
public void addIntegerValue(int addValue, String name) {
Integer value = (Integer) getValue(name);
- int v = (value != null) ? value.intValue() : 0;
+ int v = (value != null) ? value.intValue() : 0;
set(name, v + addValue);
}
}
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfBefore.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfBefore.java
index c48d50ec9..0828be238 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfBefore.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfBefore.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfBookmark.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfBookmark.java
index 23883f672..f691c211c 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfBookmark.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfBookmark.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfBookmarkContainerImpl.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfBookmarkContainerImpl.java
index 986e79c0c..3eee4cd71 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfBookmarkContainerImpl.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfBookmarkContainerImpl.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfColorTable.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfColorTable.java
index 641202c99..8df7bd7b2 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfColorTable.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfColorTable.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -158,7 +158,7 @@ public final class RtfColorTable {
//The color currently does not exist, so add it to the table.
//First add it, then read the size as index (to return it).
//So the first added color gets index 1. That is OK, because
- //index 0 is reserved for auto-colored.
+ //index 0 is reserved for auto-colored.
addColor (identifier);
retVal = colorTable.size ();
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfContainer.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfContainer.java
index a3db213c4..5a6b1d6ed 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfContainer.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfContainer.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfDocumentArea.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfDocumentArea.java
index 3e37ec9d7..6204e2ac2 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfDocumentArea.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfDocumentArea.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfElement.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfElement.java
index 3e64a0f7d..3f1e2f7e1 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfElement.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfElement.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -97,7 +97,7 @@ public abstract class RtfElement {
public void newLine() throws IOException {
writer.write("\n");
}
-
+
/**
* Write an RTF control word to our Writer
* @param word RTF control word to write
@@ -224,7 +224,7 @@ public abstract class RtfElement {
writeControlWord(cw);
writeAttributes((RtfAttributes) value, null);
return;
- }
+ }
writeControlWord(cw);
}
@@ -246,7 +246,7 @@ public abstract class RtfElement {
writeControlWord(cw);
writeAttributes((RtfAttributes) value, null);
return;
- }
+ }
writeControlWordNS(cw);
}
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java
index 932198676..182894ea5 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -65,7 +65,7 @@ public class RtfExternalGraphic extends RtfElement {
super(reason);
}
}
-
+
//////////////////////////////////////////////////
// Supported Formats
//////////////////////////////////////////////////
@@ -83,7 +83,7 @@ public class RtfExternalGraphic extends RtfElement {
public static boolean isFormat(byte[] data) {
return false;
}
-
+
/**
* Convert image data if necessary - for example when format is not supported by rtf.
*
@@ -93,7 +93,7 @@ public class RtfExternalGraphic extends RtfElement {
public FormatBase convert(FormatBase format, byte[] data) {
return format;
}
-
+
/**
* Determine image file format.
*
@@ -118,7 +118,7 @@ public class RtfExternalGraphic extends RtfElement {
return null;
}
}
-
+
/**
* Get image type.
*
@@ -127,7 +127,7 @@ public class RtfExternalGraphic extends RtfElement {
public int getType() {
return ImageConstants.I_NOT_SUPPORTED;
}
-
+
/**
* Get rtf tag.
*
@@ -137,7 +137,7 @@ public class RtfExternalGraphic extends RtfElement {
return "";
}
}
-
+
private static class FormatGIF extends FormatBase {
public static boolean isFormat(byte[] data) {
// Indentifier "GIF8" on position 0
@@ -145,12 +145,12 @@ public class RtfExternalGraphic extends RtfElement {
return ImageUtil.compareHexValues(pattern, data, 0, true);
}
-
+
public int getType() {
return ImageConstants.I_GIF;
}
}
-
+
private static class FormatEMF extends FormatBase {
public static boolean isFormat(byte[] data) {
// No offical Indentifier known
@@ -158,28 +158,28 @@ public class RtfExternalGraphic extends RtfElement {
return ImageUtil.compareHexValues(pattern, data, 0, true);
}
-
+
public int getType() {
return ImageConstants.I_EMF;
}
-
+
public String getRtfTag() {
return "emfblip";
}
}
-
+
private static class FormatBMP extends FormatBase {
public static boolean isFormat(byte[] data) {
byte [] pattern = new byte [] {(byte) 0x42, (byte) 0x4D};
return ImageUtil.compareHexValues(pattern, data, 0, true);
}
-
+
public int getType() {
return ImageConstants.I_BMP;
}
}
-
+
private static class FormatJPG extends FormatBase {
public static boolean isFormat(byte[] data) {
// Indentifier "0xFFD8" on position 0
@@ -187,16 +187,16 @@ public class RtfExternalGraphic extends RtfElement {
return ImageUtil.compareHexValues(pattern, data, 0, true);
}
-
+
public int getType() {
return ImageConstants.I_JPG;
}
-
+
public String getRtfTag() {
return "jpegblip";
}
}
-
+
private static class FormatPNG extends FormatBase {
public static boolean isFormat(byte[] data) {
// Indentifier "PNG" on position 1
@@ -204,16 +204,16 @@ public class RtfExternalGraphic extends RtfElement {
return ImageUtil.compareHexValues(pattern, data, 1, true);
}
-
+
public int getType() {
return ImageConstants.I_PNG;
}
-
+
public String getRtfTag() {
return "pngblip";
}
}
-
+
//////////////////////////////////////////////////
// @@ Members
//////////////////////////////////////////////////
@@ -370,7 +370,7 @@ public class RtfExternalGraphic extends RtfElement {
throw new ExternalGraphicException("The attribute 'src' of "
+ " has a invalid value: '"
+ url + "' (" + e + ")");
- }
+ }
}
if (imagedata == null) {
@@ -383,8 +383,8 @@ public class RtfExternalGraphic extends RtfElement {
if (imageformat != null) {
imageformat = imageformat.convert(imageformat, imagedata);
}
-
- if (imageformat == null
+
+ if (imageformat == null
|| imageformat.getType() == ImageConstants.I_NOT_SUPPORTED
|| "".equals(imageformat.getRtfTag())) {
throw new ExternalGraphicException("The tag "
@@ -465,17 +465,17 @@ public class RtfExternalGraphic extends RtfElement {
}
} else if (imageformat.getType() == ImageConstants.I_EMF) {
int i = 0;
-
+
i = ImageUtil.getIntFromByteArray(imagedata, 151, 4, false);
if (i != 0 ) {
- width = i;
+ width = i;
}
-
+
i = ImageUtil.getIntFromByteArray(imagedata, 155, 4, false);
if (i != 0 ) {
height = i;
}
-
+
}
}
@@ -557,7 +557,7 @@ public class RtfExternalGraphic extends RtfElement {
this.scaleUniform = true;
}
}
-
+
/**
* Sets the binary imagedata of the image.
*
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExtraRowSet.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExtraRowSet.java
index 73f5cfa37..631f2d901 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExtraRowSet.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExtraRowSet.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFile.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFile.java
index fa0728533..d5eaa304d 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFile.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFile.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -109,7 +109,7 @@ extends RtfContainer {
return listTable;
}
-
+
/**
* Get the list table.
* @return the RtfListTable
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFontManager.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFontManager.java
index 26c95e200..06dbaccd5 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFontManager.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFontManager.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -169,7 +169,7 @@ public final class RtfFontManager {
private String getFontKey(String family) {
return family.toLowerCase();
}
-
+
/**
* Adds a font to the table.
*
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFontTable.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFontTable.java
index 33a8169f8..c64f27377 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFontTable.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFontTable.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFootnote.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFootnote.java
index d91a63c0e..f3b2ebf72 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFootnote.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFootnote.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -49,7 +49,7 @@ public class RtfFootnote extends RtfContainer
if (bBody) {
RtfTextrun textrun = RtfTextrun.getTextrun(body, writer, null);
textrun.setSuppressLastPar(true);
-
+
return textrun;
} else {
return textrunInline;
@@ -62,16 +62,16 @@ public class RtfFootnote extends RtfContainer
*/
protected void writeRtfContent() throws IOException {
textrunInline.writeRtfContent();
-
+
writeGroupMark(true);
writeControlWord("footnote");
- writeControlWord("ftnalt");
-
+ writeControlWord("ftnalt");
+
body.writeRtfContent();
-
+
writeGroupMark(false);
}
-
+
public RtfList newList(RtfAttributes attrs) throws IOException {
if (list != null) {
list.close();
@@ -81,11 +81,11 @@ public class RtfFootnote extends RtfContainer
return list;
}
-
+
public void startBody() {
bBody = true;
}
-
+
public void endBody() {
bBody = false;
}
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfGenerator.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfGenerator.java
index 8e07ae86a..1dd00c66d 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfGenerator.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfGenerator.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -31,7 +31,7 @@ public class RtfGenerator extends RtfElement {
public RtfGenerator(RtfHeader h, Writer w) throws IOException {
super(h, w);
}
-
+
/**
* {@inheritDoc}
*/
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfHeader.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfHeader.java
index 7e75e97f5..2554cad38 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfHeader.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfHeader.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -60,7 +60,7 @@ class RtfHeader extends RtfContainer {
RtfTemplate.getInstance().writeTemplate(this);
RtfStyleSheetTable.getInstance().writeStyleSheet(this);
writeFootnoteProperties();
-
+
}
/** write user properties if any */
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfHyperLink.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfHyperLink.java
index 4924e6829..cd80c6993 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfHyperLink.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfHyperLink.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -70,7 +70,7 @@ implements IRtfTextContainer,
super ((RtfContainer) parent, writer, attr);
new RtfText (this, writer, str, attr);
}
-
+
public RtfHyperLink (RtfTextrun parent, Writer writer, RtfAttributes attr)
throws IOException {
super ((RtfContainer) parent, writer, attr);
@@ -216,7 +216,7 @@ implements IRtfTextContainer,
public boolean isEmpty () {
return false;
}
-
+
public RtfTextrun getTextrun()
throws IOException {
RtfTextrun textrun = RtfTextrun.getTextrun(this, writer, null);
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfJforCmd.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfJforCmd.java
index d018e52a0..d7b77f633 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfJforCmd.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfJforCmd.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfLineBreak.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfLineBreak.java
index cce3d8697..4073302ce 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfLineBreak.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfLineBreak.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfList.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfList.java
index a559c4c61..f44199bee 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfList.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfList.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -60,7 +60,7 @@ public class RtfList extends RtfContainer {
// find out if we are nested in a table
hasTableParent = this.getParentOfClass(RtfTable.class) != null;
-
+
this.setRtfListStyle(new RtfListStyleBullet());
}
@@ -84,7 +84,7 @@ public class RtfList extends RtfContainer {
public Integer getListId() {
return listId;
}
-
+
/**
* Returns the Id of the list template.
* @return Id of the list template
@@ -92,7 +92,7 @@ public class RtfList extends RtfContainer {
public Integer getListTemplateId() {
return listTemplateId;
}
-
+
/**
* Change list style
* @param ls ListStyle to set
@@ -108,7 +108,7 @@ public class RtfList extends RtfContainer {
public RtfListStyle getRtfListStyle() {
return defaultListStyle;
}
-
+
/**
* Returns true, if the list has a parent table.
* @return true, if the list has a parent table
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfListItem.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfListItem.java
index 3638dc11f..14b4b486f 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfListItem.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfListItem.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -45,7 +45,7 @@ public class RtfListItem extends RtfContainer
private RtfListStyle listStyle;
private int number = 0;
- /**
+ /**
* special RtfParagraph that writes list item setup code before its content
*/
private class RtfListItemParagraph extends RtfParagraph {
@@ -61,21 +61,21 @@ public class RtfListItem extends RtfContainer
}
}
- /**
+ /**
* special RtfTextrun that is used as list item label
*/
public class RtfListItemLabel extends RtfTextrun implements IRtfTextrunContainer {
-
+
private RtfListItem rtfListItem;
-
+
/**
* Constructs the RtfListItemLabel
* @param item The RtfListItem the label belongs to
* @throws IOException Thrown when an IO-problem occurs
*/
public RtfListItemLabel(RtfListItem item) throws IOException {
- super(null, item.writer, null);
-
+ super(null, item.writer, null);
+
rtfListItem = item;
}
@@ -88,14 +88,14 @@ public class RtfListItem extends RtfContainer
public RtfTextrun getTextrun() throws IOException {
return this;
}
-
+
/**
* Sets the content of the list item label.
* @param s Content of the list item label.
* @throws IOException Thrown when an IO-problem occurs
*/
public void addString(String s) throws IOException {
-
+
final String label = s.trim();
if (label.length() > 0 && Character.isDigit(label.charAt(0))) {
rtfListItem.setRtfListStyle(new RtfListStyleNumber());
@@ -151,7 +151,7 @@ public class RtfListItem extends RtfContainer
textrun.setRtfListItem(this);
return textrun;
}
-
+
/**
* Start a new list after closing current paragraph, list and table
* @param attrs attributes of new RftList object
@@ -162,22 +162,22 @@ public class RtfListItem extends RtfContainer
RtfList list = new RtfList(this, writer, attrs);
return list;
}
-
+
/**
* Overridden to setup the list: start a group with appropriate attributes
* @throws IOException for I/O problems
*/
protected void writeRtfPrefix() throws IOException {
-
+
// pard causes word97 (and sometimes 2000 too) to crash if the list is nested in a table
if (!parentList.getHasTableParent()) {
writeControlWord("pard");
}
- writeOneAttribute(RtfText.LEFT_INDENT_FIRST,
+ writeOneAttribute(RtfText.LEFT_INDENT_FIRST,
"360"); //attrib.getValue(RtfListTable.LIST_INDENT));
-
- writeOneAttribute(RtfText.LEFT_INDENT_BODY,
+
+ writeOneAttribute(RtfText.LEFT_INDENT_BODY,
attrib.getValue(RtfText.LEFT_INDENT_BODY));
// group for list setup info
@@ -191,7 +191,7 @@ public class RtfListItem extends RtfContainer
writeGroupMark(false);
writeOneAttribute(RtfListTable.LIST_NUMBER, new Integer(number));
}
-
+
/**
* End the list group
* @throws IOException for I/O problems
@@ -202,20 +202,20 @@ public class RtfListItem extends RtfContainer
/* reset paragraph defaults to make sure list ends
* but pard causes word97 (and sometimes 2000 too) to crash if the list
* is nested in a table
- */
+ */
if (!parentList.getHasTableParent()) {
writeControlWord("pard");
}
-
+
}
-
+
/**
* Change list style
* @param ls ListStyle to set
*/
public void setRtfListStyle(RtfListStyle ls) {
listStyle = ls;
-
+
listStyle.setRtfListItem(this);
number = getRtfFile().getListTable().addRtfListStyle(ls);
}
@@ -223,7 +223,7 @@ public class RtfListItem extends RtfContainer
/**
* Get list style
* @return ListSytle of the List
- */
+ */
public RtfListStyle getRtfListStyle() {
if (listStyle == null) {
return parentList.getRtfListStyle();
@@ -231,7 +231,7 @@ public class RtfListItem extends RtfContainer
return listStyle;
}
}
-
+
/**
* Get the parent list.
* @return the parent list
@@ -239,7 +239,7 @@ public class RtfListItem extends RtfContainer
public RtfList getParentList() {
return parentList;
}
-
+
/**
* Returns the list number
* @return list number
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfListStyle.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfListStyle.java
index 7ae121c3f..e0f85ee88 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfListStyle.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfListStyle.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -37,7 +37,7 @@ import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfElement;
*/
public class RtfListStyle {
private RtfListItem rtfListItem;
-
+
/**
* Sets the RtfListItem this style belongs to.
* @param item RtfListItem this style belongs to
@@ -45,7 +45,7 @@ public class RtfListStyle {
public void setRtfListItem(RtfListItem item) {
rtfListItem = item;
}
-
+
/**
* Gets the RtfListItem this style belongs to.
* @return RtfListItem this style belongs to
@@ -83,7 +83,7 @@ public class RtfListStyle {
* Gets called when the list table has to be written.
* @param element RtfElement in whose context is to be written
* @throws IOException Thrown when an IO-problem occurs.
- */
+ */
public void writeLevelGroup(RtfElement element)
throws IOException {
}
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfListStyleBullet.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfListStyleBullet.java
index 15ffc9163..958f359a1 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfListStyleBullet.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfListStyleBullet.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -36,7 +36,7 @@ import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfElement;
* Class to handle bullet list style.
*/
public class RtfListStyleBullet extends RtfListStyle {
-
+
/**
* Gets called before a RtfListItem has to be written.
* @param item RtfListItem whose prefix has to be written
@@ -73,7 +73,7 @@ public class RtfListStyleBullet extends RtfListStyle {
/**
* Gets called when the list table has to be written.
- *
+ *
* @param element RtfElement in whose context is to be written
* {@inheritDoc}
* @throws IOException Thrown when an IO-problem occurs
@@ -83,12 +83,12 @@ public class RtfListStyleBullet extends RtfListStyle {
element.writeGroupMark(true);
element.writeOneAttributeNS(RtfListTable.LIST_TEXT_FORM, "\\'01\\'b7");
element.writeGroupMark(false);
-
+
element.writeGroupMark(true);
element.writeOneAttributeNS(RtfListTable.LIST_NUM_POSITION, null);
element.writeGroupMark(false);
-
+
element.attrib.set(RtfListTable.LIST_FONT_TYPE, 2);
}
-
+
}
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfListStyleNumber.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfListStyleNumber.java
index 926614f8a..6d35fee95 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfListStyleNumber.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfListStyleNumber.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -36,7 +36,7 @@ import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfElement;
* Class to handle number list style.
*/
public class RtfListStyleNumber extends RtfListStyle {
-
+
/**
* Gets called before a RtfListItem has to be written.
* @param item RtfListItem whose prefix has to be written
@@ -54,10 +54,10 @@ public class RtfListStyleNumber extends RtfListStyle {
item.attrib.getValue(RtfListTable.LIST_INDENT));
item.writeControlWord("pntxta.");
}
-
+
/**
* Gets called before a paragraph, which is contained by a RtfListItem has to be written.
- *
+ *
* @param element RtfElement in whose context is to be written
* {@inheritDoc}
* @throws IOException Thrown when an IO-problem occurs
@@ -71,10 +71,10 @@ public class RtfListStyleNumber extends RtfListStyle {
element.writeControlWord("tab");
element.writeGroupMark(false);
}
-
+
/**
* Gets called when the list table has to be written.
- *
+ *
* @param element RtfElement in whose context is to be written
* {@inheritDoc}
* @throws IOException Thrown when an IO-problem occurs
@@ -84,17 +84,17 @@ public class RtfListStyleNumber extends RtfListStyle {
element.writeOneAttributeNS(
RtfListTable.LIST_START_AT, new Integer(1));
element.attrib.set(RtfListTable.LIST_NUMBER_TYPE, 0);
-
+
element.writeGroupMark(true);
element.writeOneAttributeNS(
RtfListTable.LIST_TEXT_FORM, "\\'03\\\'00. ;");
element.writeGroupMark(false);
-
+
element.writeGroupMark(true);
element.writeOneAttributeNS(
RtfListTable.LIST_NUM_POSITION, "\\'01;");
element.writeGroupMark(false);
-
+
element.writeOneAttribute(RtfListTable.LIST_FONT_TYPE, new Integer(0));
}
}
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfListStyleText.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfListStyleText.java
index 48c987d2d..8eb993e0d 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfListStyleText.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfListStyleText.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -37,15 +37,15 @@ import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfElement;
*/
public class RtfListStyleText extends RtfListStyle {
private String text;
-
+
/**
* Constructs a RtfListStyleText object.
* @param s Text to be displayed
*/
public RtfListStyleText(String s) {
- text = s;
+ text = s;
}
-
+
/**
* Gets called before a RtfListItem has to be written.
* @param item RtfListItem whose prefix has to be written
@@ -68,10 +68,10 @@ public class RtfListStyleText extends RtfListStyle {
RtfStringConverter.getInstance().writeRtfString(item.writer, text);
item.writeGroupMark(false);
}
-
+
/**
* Gets called before a paragraph, which is contained by a RtfListItem has to be written.
- *
+ *
* @param element RtfElement in whose context is to be written
* {@inheritDoc}
* @throws IOException Thrown when an IO-problem occurs
@@ -82,10 +82,10 @@ public class RtfListStyleText extends RtfListStyle {
element.writeControlWord("pntext");
element.writeGroupMark(false);
}
-
+
/**
* Gets called when the list table has to be written.
- *
+ *
* @param element RtfElement in whose context is to be written
* {@inheritDoc}
* @throws IOException Thrown when an IO-problem occurs
@@ -94,7 +94,7 @@ public class RtfListStyleText extends RtfListStyle {
throws IOException {
element.attrib.set(RtfListTable.LIST_NUMBER_TYPE, 23);
element.writeGroupMark(true);
-
+
String sCount;
if (text.length() < 10) {
sCount = "0" + String.valueOf(text.length());
@@ -105,14 +105,14 @@ public class RtfListStyleText extends RtfListStyle {
}
}
element.writeOneAttributeNS(
- RtfListTable.LIST_TEXT_FORM, "\\'" + sCount
+ RtfListTable.LIST_TEXT_FORM, "\\'" + sCount
+ RtfStringConverter.getInstance().escape(text));
element.writeGroupMark(false);
-
+
element.writeGroupMark(true);
element.writeOneAttributeNS(RtfListTable.LIST_NUM_POSITION, null);
element.writeGroupMark(false);
-
+
element.attrib.set(RtfListTable.LIST_FONT_TYPE, 2);
}
}
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfListTable.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfListTable.java
index 2f4988a20..aeb9618f4 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfListTable.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfListTable.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -119,7 +119,7 @@ public class RtfListTable extends RtfContainer {
}
lists.add(list);
-
+
return lists.size();
}
@@ -140,7 +140,7 @@ public class RtfListTable extends RtfContainer {
newLine();
}
writeGroupMark(false);
-
+
newLine();
//write '\listoveridetable'
writeGroupMark(true);
@@ -149,11 +149,11 @@ public class RtfListTable extends RtfContainer {
newLine();
for (Iterator it = styles.iterator(); it.hasNext();) {
final RtfListStyle style = (RtfListStyle)it.next();
-
+
writeGroupMark(true);
writeStarControlWordNS(LIST_OVR);
writeGroupMark(true);
-
+
writeOneAttributeNS(LIST_ID, style.getRtfList().getListId().toString());
writeOneAttributeNS(LIST_OVR_COUNT, new Integer(0));
writeOneAttributeNS(LIST_NUMBER, new Integer(z++));
@@ -162,7 +162,7 @@ public class RtfListTable extends RtfContainer {
writeGroupMark(false);
newLine();
}
-
+
writeGroupMark(false);
newLine();
}
@@ -176,7 +176,7 @@ public class RtfListTable extends RtfContainer {
public boolean isEmpty() {
return false;
}
-
+
private void writeListTableEntry(RtfList list)
throws IOException {
//write list-specific attributes
@@ -184,29 +184,29 @@ public class RtfListTable extends RtfContainer {
writeControlWordNS(LIST);
writeOneAttributeNS(LIST_TEMPLATE_ID, list.getListTemplateId().toString());
writeOneAttributeNS(LIST, attrib.getValue(LIST));
-
+
// write level-specific attributes
writeGroupMark(true);
writeControlWordNS(LIST_LEVEL);
-
+
writeOneAttributeNS(LIST_JUSTIFICATION, attrib.getValue(LIST_JUSTIFICATION));
writeOneAttributeNS(LIST_FOLLOWING_CHAR, attrib.getValue(LIST_FOLLOWING_CHAR));
writeOneAttributeNS(LIST_SPACE, new Integer(0));
writeOneAttributeNS(LIST_INDENT, attrib.getValue(LIST_INDENT));
-
+
RtfListItem item = (RtfListItem)list.getChildren().get(0);
if (item != null) {
item.getRtfListStyle().writeLevelGroup(this);
}
-
+
writeGroupMark(false);
-
+
writeGroupMark(true);
writeControlWordNS(LIST_NAME);
writeGroupMark(false);
-
+
writeOneAttributeNS(LIST_ID, list.getListId().toString());
-
+
writeGroupMark(false);
}
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfNull.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfNull.java
index 6f8b6afc3..4e6e08291 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfNull.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfNull.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfOptions.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfOptions.java
index 788eef147..54cdb802a 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfOptions.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfOptions.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPage.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPage.java
index bd2e9e62d..fb2df3fac 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPage.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPage.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -55,7 +55,7 @@ extends RtfContainer {
public static final String MARGIN_LEFT = "margl";
/** constant for right margin */
public static final String MARGIN_RIGHT = "margr";
-
+
/** constant for header position */
public static final String HEADERY = "headery";
/** constant for footer position */
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPageArea.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPageArea.java
index 488a49a30..851dc6c87 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPageArea.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPageArea.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPageBreak.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPageBreak.java
index 7335e8a81..b570842c2 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPageBreak.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPageBreak.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPageNumber.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPageNumber.java
index 7a9641ee8..235b3f8e1 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPageNumber.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPageNumber.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPageNumberCitation.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPageNumberCitation.java
index c7f455c70..92ba2bb7f 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPageNumberCitation.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPageNumberCitation.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -78,8 +78,8 @@ public class RtfPageNumberCitation extends RtfContainer {
// Build page reference field
String pageRef = RTF_FIELD_PAGEREF_MODEL;
final int insertionIndex = pageRef.indexOf("}");
- pageRef = pageRef.substring(0, insertionIndex)
- + "\"" + id
+ pageRef = pageRef.substring(0, insertionIndex)
+ + "\"" + id
+ "\"" + " "
+ pageRef.substring(insertionIndex, pageRef.length());
id = null;
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfParagraph.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfParagraph.java
index 8cf71d68e..ffc37a667 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfParagraph.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfParagraph.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfParagraphKeepTogether.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfParagraphKeepTogether.java
index 1fa6166d9..e27ab6460 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfParagraphKeepTogether.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfParagraphKeepTogether.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfSection.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfSection.java
index 88c7e599b..4b7f8f677 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfSection.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfSection.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -231,7 +231,7 @@ implements
closeCurrentExternalGraphic();
closeCurrentBefore();
}
-
+
/**
* Returns the current RtfTextrun.
* @return Current RtfTextrun
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfSpaceManager.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfSpaceManager.java
index 2983f9ca7..da55e54b0 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfSpaceManager.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfSpaceManager.java
@@ -23,8 +23,8 @@ import java.util.Iterator;
import java.util.LinkedList;
/**
- * This class is responsible for saving space-before/space-after attributes
- * history and adding spacing to established candidates (i.e. attributes) or
+ * This class is responsible for saving space-before/space-after attributes
+ * history and adding spacing to established candidates (i.e. attributes) or
* accumulation spacing in case of candidate absence.
*/
public class RtfSpaceManager {
@@ -41,7 +41,7 @@ public class RtfSpaceManager {
* property.
*/
private int accumulatedSpace = 0;
-
+
/**
* Construct a newly allocated RtfSpaceManager object.
*/
@@ -49,8 +49,8 @@ public class RtfSpaceManager {
}
/**
- * Iterates block-level stack (i.e. all open blocks) and stops updating
- * candidate for adding space-before/space-after attribute in case of
+ * Iterates block-level stack (i.e. all open blocks) and stops updating
+ * candidate for adding space-before/space-after attribute in case of
* candidate presence.
*/
public void stopUpdatingSpaceBefore() {
@@ -61,10 +61,10 @@ public class RtfSpaceManager {
}
}
}
-
+
/**
* Set attributes as candidate for space attributes inheritance.
- *
+ *
* @param attrs attributes to set
*/
public void setCandidate(RtfAttributes attrs) {
@@ -74,24 +74,24 @@ public class RtfSpaceManager {
splitter.setSpaceAfterCandidate(attrs);
}
}
-
+
/**
- * Builds RtfSpaceSplitter on attrs and adds it to the
+ * Builds RtfSpaceSplitter on attrs and adds it to the
* block-level stack.
- *
+ *
* @param attrs RtfAttribute to add
* @return instance of RtfSpaceSplitter
*/
public RtfSpaceSplitter pushRtfSpaceSplitter(RtfAttributes attrs) {
RtfSpaceSplitter splitter;
splitter = new RtfSpaceSplitter(attrs, accumulatedSpace);
- // set accumulatedSpace to 0, because now accumulatedSpace used
+ // set accumulatedSpace to 0, because now accumulatedSpace used
// in splitter
accumulatedSpace = 0;
blockAttributes.addLast(splitter);
return splitter;
}
-
+
/**
* Removes RtfSpaceSplitter from top of block-level stack.
*/
@@ -105,7 +105,7 @@ public class RtfSpaceManager {
/**
* Pushes inline attributes to inline-level stack.
- *
+ *
* @param attrs attributes to add
*/
public void pushInlineAttributes(RtfAttributes attrs) {
@@ -123,7 +123,7 @@ public class RtfSpaceManager {
/**
* Peeks at inline-level attribute stack.
- *
+ *
* @return RtfAttributes from top of inline-level stack
*/
public RtfAttributes getLastInlineAttribute() {
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfSpaceSplitter.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfSpaceSplitter.java
index 19db4dc6a..689a2753f 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfSpaceSplitter.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfSpaceSplitter.java
@@ -45,7 +45,7 @@ public class RtfSpaceSplitter {
/**
* Create RtfSpaceSplitter with given RtfAttributes.
- *
+ *
* @param attrs RtfAttributes for splitting
* @param previousSpace integer, representing accumulated spacing
*/
@@ -62,7 +62,7 @@ public class RtfSpaceSplitter {
/**
* Remove attributes with name key from
* commonAttributes and return it as int.
- *
+ *
* @param key attributes name to extract
* @return integer, representing value of extracted attributes
*/
@@ -86,10 +86,10 @@ public class RtfSpaceSplitter {
return spaceBefore;
}
- /**
+ /**
* Sets a candidate for space-before property.
- *
- * @param candidate instance of RtfAttributes, considered as
+ *
+ * @param candidate instance of RtfAttributes, considered as
* a candidate for space-before adding
*/
public void setSpaceBeforeCandidate(RtfAttributes candidate) {
@@ -98,10 +98,10 @@ public class RtfSpaceSplitter {
}
}
- /**
+ /**
* Sets a candidate for space-after property.
- *
- * @param candidate instance of RtfAttributes, considered as
+ *
+ * @param candidate instance of RtfAttributes, considered as
* a candidate for space-after adding
*/
public void setSpaceAfterCandidate(RtfAttributes candidate) {
@@ -117,19 +117,19 @@ public class RtfSpaceSplitter {
public boolean isAfterCadidateSet() {
return spaceAfterCandidate != null;
}
-
+
/**
* Stops updating candidates for space-before attribute.
*/
public void stopUpdatingSpaceBefore() {
updatingSpaceBefore = false;
- }
+ }
/**
* Adds corresponding attributes to their candidates.
- *
- * @return integer, representing value of space-before/space-after
- * attributes, that can't be added anywhere (i.e. these attributes
+ *
+ * @return integer, representing value of space-before/space-after
+ * attributes, that can't be added anywhere (i.e. these attributes
* hasn't their candidates)
*/
public int flush() {
@@ -144,7 +144,7 @@ public class RtfSpaceSplitter {
if (!isAfterCadidateSet()) {
accumulatingSpace += spaceAfter;
} else {
- spaceAfterCandidate.addIntegerValue(spaceAfter,
+ spaceAfterCandidate.addIntegerValue(spaceAfter,
RtfText.SPACE_AFTER);
}
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfString.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfString.java
index a9b531ca3..c7cc6d36f 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfString.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfString.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -36,21 +36,21 @@ import java.io.Writer;
public class RtfString extends RtfElement {
private String text = "";
-
+
RtfString(RtfContainer parent, Writer w, String s)
throws IOException {
super(parent, w);
-
+
text = s;
}
-
+
/**
* @return true if this element would generate no "useful" RTF content
*/
public boolean isEmpty() {
return text.trim().equals("");
}
-
+
/**
* write RTF code of all our children
* @throws IOException for I/O problems
@@ -58,11 +58,11 @@ public class RtfString extends RtfElement {
protected void writeRtfContent() throws IOException {
RtfStringConverter.getInstance().writeRtfString(writer, text);
}
-
+
public String getText() {
return text;
}
-
+
public void setText(String s) {
text = s;
}
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfStringConverter.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfStringConverter.java
index 04275fd72..40460bb4d 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfStringConverter.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfStringConverter.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -132,5 +132,5 @@ public class RtfStringConverter {
}
return sb.toString();
}
-
+
}
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfStyleSheetTable.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfStyleSheetTable.java
index fdbe94cfc..b838fb8a4 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfStyleSheetTable.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfStyleSheetTable.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTable.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTable.java
index b8bb4b032..eda5644a2 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTable.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTable.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -110,16 +110,16 @@ public class RtfTable extends RtfContainer {
writeControlWordNS("pard");
}
- writeGroupMark(true);
+ writeGroupMark(true);
}
-
+
/**
* Overridden to write RTF suffix code, what comes after our children
* @throws IOException for I/O problems
*/
protected void writeRtfSuffix() throws IOException {
writeGroupMark(false);
-
+
if (isNestedTable()) {
getRow().writeRowAndCellsDefintions();
}
@@ -154,7 +154,7 @@ public class RtfTable extends RtfContainer {
}
/**
- *
+ *
* @return RtfAttributes of Header
*/
public RtfAttributes getHeaderAttribs() {
@@ -173,7 +173,7 @@ public class RtfTable extends RtfContainer {
return super.getRtfAttributes();
}
-
+
/** @return true if the the table is a nested table */
public boolean isNestedTable() {
if (isNestedTable == null) {
@@ -194,9 +194,9 @@ public class RtfTable extends RtfContainer {
return false;
}
-
+
/**
- *
+ *
* @return Parent row table (for nested tables only)
*/
public RtfTableRow getRow() {
@@ -209,7 +209,7 @@ public class RtfTable extends RtfContainer {
e = e.parent;
}
- return null;
+ return null;
}
/**
@@ -219,7 +219,7 @@ public class RtfTable extends RtfContainer {
public void setBorderAttributes(RtfAttributes attributes) {
borderAttributes = attributes;
}
-
+
/**
* Returns the RtfAttributes for the borders of the table.
* @return Border attributes of the table.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableCell.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableCell.java
index 1ba590f22..740ea36e5 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableCell.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableCell.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -100,7 +100,7 @@ public class RtfTableCell
if (attrs == null) {
attrs = new RtfAttributes();
}
-
+
attrs.set("intbl");
paragraph = new RtfParagraph(this, writer, attrs);
@@ -192,13 +192,13 @@ public class RtfTableCell
* table (Word2000 seems to do the same).
* Cause of this, dont't write horizontally merged cells.
* They just exist as placeholders in TableContext class,
- * and are never written to RTF file.
+ * and are never written to RTF file.
*/
// horizontal cell merge codes
if (hMerge == MERGE_WITH_PREVIOUS) {
return offset;
}
-
+
newLine();
this.widthOffset = offset;
@@ -225,13 +225,13 @@ public class RtfTableCell
if (attrib.getValue("number-columns-spanned") != null) {
// Get the number of columns spanned
int nbMergedCells = ((Integer)attrib.getValue("number-columns-spanned")).intValue();
-
+
RtfTable tab = getRow().getTable();
-
+
// Get the context of the current table in order to get the width of each column
ITableColumnsInfo tableColumnsInfo
= tab.getITableColumnsInfo();
-
+
tableColumnsInfo.selectFirstColumn();
// Reach the column index in table context corresponding to the current column cell
@@ -273,7 +273,7 @@ public class RtfTableCell
return xPos;
}
-
+
/**
* Overriden to avoid writing any it's a merged cell.
* @throws IOException for I/O problems
@@ -283,7 +283,7 @@ public class RtfTableCell
if (hMerge == MERGE_WITH_PREVIOUS) {
return;
}
-
+
super.writeRtfContent();
}
@@ -297,7 +297,7 @@ public class RtfTableCell
if (hMerge == MERGE_WITH_PREVIOUS) {
return;
}
-
+
super.writeRtfPrefix();
}
@@ -310,7 +310,7 @@ public class RtfTableCell
if (hMerge == MERGE_WITH_PREVIOUS) {
return;
}
-
+
if (getRow().getTable().isNestedTable()) {
//nested table
writeControlWordNS("nestcell");
@@ -330,19 +330,19 @@ public class RtfTableCell
writeControlWord("qr");
} else {
RtfElement lastChild = null;
-
+
if (getChildren().size() > 0) {
lastChild = (RtfElement) getChildren().get(getChildren().size() - 1);
}
-
-
+
+
if (lastChild != null
&& lastChild instanceof RtfTextrun) {
- //Don't write \ql in order to allow for example a right aligned paragraph
+ //Don't write \ql in order to allow for example a right aligned paragraph
//in a not right aligned table-cell to write its \qr.
} else {
writeControlWord("ql");
- }
+ }
}
if (!containsText()) {
@@ -497,7 +497,7 @@ public class RtfTableCell
}
return result;
}
-
+
/**
* Returns the current RtfTextrun object.
* Opens a new one if necessary.
@@ -506,20 +506,20 @@ public class RtfTableCell
*/
public RtfTextrun getTextrun() throws IOException {
RtfAttributes attrs = new RtfAttributes();
-
+
if (!getRow().getTable().isNestedTable()) {
attrs.set("intbl");
}
-
+
RtfTextrun textrun = RtfTextrun.getTextrun(this, writer, attrs);
//Suppress the very last \par, because the closing \cell applies the
- //paragraph attributes.
- textrun.setSuppressLastPar(true);
-
+ //paragraph attributes.
+ textrun.setSuppressLastPar(true);
+
return textrun;
}
-
+
/**
* Get the parent row.
* @return The parent row.
@@ -534,6 +534,6 @@ public class RtfTableCell
e = e.parent;
}
- return null;
+ return null;
}
}
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java
index 2182f94ec..fe936e3f5 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -145,15 +145,15 @@ public class RtfTableRow extends RtfContainer implements ITableAttributes {
// now children can write themselves, we have the correct RTF prefix code
super.writeRtfContent();
}
-
+
/**
- *
+ *
* @throws IOException In case of a IO-problem
*/
public void writeRowAndCellsDefintions() throws IOException {
// render the row and cells definitions
writeControlWord("trowd");
-
+
if (!getTable().isNestedTable()) {
writeControlWord("itap0");
}
@@ -181,24 +181,24 @@ public class RtfTableRow extends RtfContainer implements ITableAttributes {
// write X positions of our cells
int xPos = 0;
-
+
final Object leftIndent = attrib.getValue(ITableAttributes.ATTR_ROW_LEFT_INDENT);
if (leftIndent != null) {
xPos = ((Integer)leftIndent).intValue();
}
-
+
RtfAttributes tableBorderAttributes = getTable().getBorderAttributes();
-
+
int index = 0;
for (Iterator it = getChildren().iterator(); it.hasNext();) {
final RtfElement e = (RtfElement)it.next();
if (e instanceof RtfTableCell) {
-
+
RtfTableCell rtfcell = (RtfTableCell)e;
-
+
// Adjust the cell's display attributes so the table's/row's borders
// are drawn properly.
-
+
if (tableBorderAttributes != null) {
// get border attributes from table
if (index == 0) {
@@ -233,7 +233,7 @@ public class RtfTableRow extends RtfContainer implements ITableAttributes {
}
}
}
-
+
// get border attributes from row
if (index == 0) {
if (!rtfcell.getRtfAttributes().isSet(ITableAttributes.CELL_BORDER_LEFT)) {
@@ -268,7 +268,7 @@ public class RtfTableRow extends RtfContainer implements ITableAttributes {
}
index++; // Added by Boris POUDEROUS on 2002/07/02
}
-
+
newLine();
}
@@ -366,9 +366,9 @@ public class RtfTableRow extends RtfContainer implements ITableAttributes {
public boolean isHighestCell(int cellId) {
return (highestCell == cellId) ? true : false;
}
-
+
/**
- *
+ *
* @return Parent table of the row.
*/
public RtfTable getTable() {
@@ -381,6 +381,6 @@ public class RtfTableRow extends RtfContainer implements ITableAttributes {
e = e.parent;
}
- return null;
+ return null;
}
}
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTemplate.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTemplate.java
index fa4cf3978..a02d6db8f 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTemplate.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTemplate.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfText.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfText.java
index 3dc2e59e0..b176e1ee2 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfText.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfText.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -79,7 +79,7 @@ public class RtfText extends RtfElement {
/** RtfText attributes: paragraph shading attributes */
/** Constant for the shading of the paragraph */
public static final String SHADING = "shading";
- /** Constant for the document's color tableshading of the paragraph */
+ /** Constant for the document's color tableshading of the paragraph */
public static final String SHADING_FRONT_COLOR = "cfpat";
/** Constant for the 100% shading of the paragraph */
public static final int FULL_SHADING = 10000;
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java
index 05a97ffd4..e0703d7ba 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -29,33 +29,33 @@ import java.util.ListIterator;
// FOP
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfExternalGraphic;
-/**
- * Class which contains a linear text run. It has methods to add attributes,
+/**
+ * Class which contains a linear text run. It has methods to add attributes,
* text, paragraph breaks....
* @author Peter Herweg, pherweg@web.de
*/
public class RtfTextrun extends RtfContainer {
private boolean bSuppressLastPar = false;
private RtfListItem rtfListItem;
-
+
/** Manager for handling space-* property. */
private RtfSpaceManager rtfSpaceManager = new RtfSpaceManager();
-
+
/** Class which represents the opening of a RTF group mark.*/
private class RtfOpenGroupMark extends RtfElement {
-
+
RtfOpenGroupMark(RtfContainer parent, Writer w, RtfAttributes attr)
throws IOException {
super(parent, w, attr);
}
-
+
/**
* @return true if this element would generate no "useful" RTF content
*/
public boolean isEmpty() {
return false;
}
-
+
/**
* write RTF code of all our children
* @throws IOException for I/O problems
@@ -65,22 +65,22 @@ public class RtfTextrun extends RtfContainer {
writeAttributes(getRtfAttributes(), null);
}
}
-
+
/** Class which represents the closing of a RTF group mark.*/
private class RtfCloseGroupMark extends RtfElement {
-
+
RtfCloseGroupMark(RtfContainer parent, Writer w)
throws IOException {
super(parent, w);
}
-
+
/**
* @return true if this element would generate no "useful" RTF content
*/
public boolean isEmpty() {
return false;
}
-
+
/**
* write RTF code of all our children
* @throws IOException for I/O problems
@@ -92,19 +92,19 @@ public class RtfTextrun extends RtfContainer {
/** Class which represents a paragraph break.*/
private class RtfParagraphBreak extends RtfElement {
-
+
RtfParagraphBreak(RtfContainer parent, Writer w)
throws IOException {
super(parent, w);
}
-
+
/**
* @return true if this element would generate no "useful" RTF content
*/
public boolean isEmpty() {
return false;
}
-
+
/**
* write RTF code of all our children
* @throws IOException for I/O problems
@@ -113,16 +113,16 @@ public class RtfTextrun extends RtfContainer {
writeControlWord("par");
}
}
-
+
/** Create an RTF container as a child of given container */
RtfTextrun(RtfContainer parent, Writer w, RtfAttributes attrs) throws IOException {
super(parent, w, attrs);
}
-
-
+
+
/**
* Adds instance of OpenGroupMark as a child with attributes.
- *
+ *
* @param attrs attributes to add
* @throws IOException for I/O problems
*/
@@ -132,17 +132,17 @@ public class RtfTextrun extends RtfContainer {
/**
* Adds instance of CloseGroupMark as a child.
- *
+ *
* @throws IOException for I/O problems
*/
private void addCloseGroupMark() throws IOException {
RtfCloseGroupMark r = new RtfCloseGroupMark(this, writer);
}
-
+
/**
- * Pushes block attributes, notifies all opened blocks about pushing block
+ * Pushes block attributes, notifies all opened blocks about pushing block
* attributes, adds OpenGroupMark as a child.
- *
+ *
* @param attrs the block attributes to push
* @throws IOException for I/O problems
*/
@@ -151,11 +151,11 @@ public class RtfTextrun extends RtfContainer {
RtfSpaceSplitter splitter = rtfSpaceManager.pushRtfSpaceSplitter(attrs);
addOpenGroupMark(splitter.getCommonAttributes());
}
-
+
/**
- * Pops block attributes, notifies all opened blocks about pushing block
+ * Pops block attributes, notifies all opened blocks about pushing block
* attributes, adds CloseGroupMark as a child.
- *
+ *
* @throws IOException for I/O problems
*/
public void popBlockAttributes() throws IOException {
@@ -166,7 +166,7 @@ public class RtfTextrun extends RtfContainer {
/**
* Pushes inline attributes.
- *
+ *
* @param attrs the inline attributes to push
* @throws IOException for I/O problems
*/
@@ -177,17 +177,17 @@ public class RtfTextrun extends RtfContainer {
/**
* Pop inline attributes.
- *
+ *
* @throws IOException for I/O problems
*/
public void popInlineAttributes() throws IOException {
rtfSpaceManager.popInlineAttributes();
addCloseGroupMark();
}
-
+
/**
* Add string to children list.
- *
+ *
* @param s string to add
* @throws IOException for I/O problems
*/
@@ -202,20 +202,20 @@ public class RtfTextrun extends RtfContainer {
RtfString r = new RtfString(this, writer, s);
rtfSpaceManager.popRtfSpaceSplitter();
}
-
+
/**
* Inserts a footnote.
- *
+ *
* @return inserted footnote
* @throws IOException for I/O problems
*/
public RtfFootnote addFootnote() throws IOException {
return new RtfFootnote(this, writer);
}
-
+
/**
* Inserts paragraph break before all close group marks.
- *
+ *
* @throws IOException for I/O problems
*/
public void addParagraphBreak() throws IOException {
@@ -241,7 +241,7 @@ public class RtfTextrun extends RtfContainer {
}
}
}
-
+
/**
* Inserts a page number.
* @param attr Attributes for the page number to insert.
@@ -250,7 +250,7 @@ public class RtfTextrun extends RtfContainer {
public void addPageNumber(RtfAttributes attr) throws IOException {
RtfPageNumber r = new RtfPageNumber(this, writer, attr);
}
-
+
/**
* Inserts a hyperlink.
* @param attr Attributes for the hyperlink to insert.
@@ -260,7 +260,7 @@ public class RtfTextrun extends RtfContainer {
public RtfHyperLink addHyperlink(RtfAttributes attr) throws IOException {
return new RtfHyperLink(this, writer, attr);
}
-
+
/**
* Inserts a bookmark.
* @param id Id for the inserted bookmark
@@ -294,7 +294,7 @@ public class RtfTextrun extends RtfContainer {
throws IOException {
List list = container.getChildren();
-
+
if (list.size() == 0) {
//add a new RtfTextrun
RtfTextrun textrun = new RtfTextrun(container, writer, attrs);
@@ -302,7 +302,7 @@ public class RtfTextrun extends RtfContainer {
return textrun;
}
-
+
Object obj = list.get(list.size() - 1);
if (obj instanceof RtfTextrun) {
@@ -313,18 +313,18 @@ public class RtfTextrun extends RtfContainer {
//add a new RtfTextrun as the last child
RtfTextrun textrun = new RtfTextrun(container, writer, attrs);
list.add(textrun);
-
+
return textrun;
}
-
+
/**
* specify, if the last paragraph control word (\par) should be suppressed.
* @param bSuppress true, if the last \par should be suppressed
- */
+ */
public void setSuppressLastPar(boolean bSuppress) {
bSuppressLastPar = bSuppress;
}
-
+
/**
* write RTF code of all our children
* @throws IOException for I/O problems
@@ -336,7 +336,7 @@ public class RtfTextrun extends RtfContainer {
* 2. To write the children
* Maybe this can be done more efficient.
*/
-
+
boolean bHasTableCellParent =
this.getParentOfClass(RtfTableCell.class) != null;
RtfAttributes attrBlockLevel = new RtfAttributes();
@@ -349,7 +349,7 @@ public class RtfTextrun extends RtfContainer {
break;
}
}
-
+
//get last RtfParagraphBreak, which is not followed by any visible child
RtfParagraphBreak lastParagraphBreak = null;
if (bLast) {
@@ -366,10 +366,10 @@ public class RtfTextrun extends RtfContainer {
}
}
}
-
+
//may contain for example \intbl
writeAttributes(attrib, null);
-
+
if (rtfListItem != null) {
rtfListItem.getRtfListStyle().writeParagraphPrefix(this);
}
@@ -384,8 +384,8 @@ public class RtfTextrun extends RtfContainer {
if (bHasTableCellParent) {
attrBlockLevel.set(e.getRtfAttributes());
}
-
-
+
+
/**
* -Write RtfParagraphBreak only, if the previous visible child
* was't also a RtfParagraphBreak.
@@ -396,21 +396,21 @@ public class RtfTextrun extends RtfContainer {
*/
boolean bHide = false;
bHide = bRtfParagraphBreak;
- bHide = bHide
- && (bPrevPar
- || bFirst
- || (bSuppressLastPar && bLast && lastParagraphBreak != null
+ bHide = bHide
+ && (bPrevPar
+ || bFirst
+ || (bSuppressLastPar && bLast && lastParagraphBreak != null
&& e == lastParagraphBreak));
-
+
if (!bHide) {
newLine();
- e.writeRtf();
-
+ e.writeRtf();
+
if (rtfListItem != null && e instanceof RtfParagraphBreak) {
rtfListItem.getRtfListStyle().writeParagraphPrefix(this);
}
}
-
+
if (e instanceof RtfParagraphBreak) {
bPrevPar = true;
} else if (e instanceof RtfCloseGroupMark) {
@@ -422,26 +422,26 @@ public class RtfTextrun extends RtfContainer {
bFirst = bFirst && e.isEmpty();
}
} //for (Iterator it = ...)
-
+
//
if (bHasTableCellParent) {
writeAttributes(attrBlockLevel, null);
}
-
+
}
-
+
/**
* Set the parent list-item of the textrun.
- *
+ *
* @param listItem parent list-item of the textrun
*/
public void setRtfListItem(RtfListItem listItem) {
rtfListItem = listItem;
}
-
+
/**
- * Gets the parent list-item of the textrun.
- *
+ * Gets the parent list-item of the textrun.
+ *
* @return parent list-item of the textrun
*/
public RtfListItem getRtfListItem() {
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/WhitespaceCollapser.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/WhitespaceCollapser.java
index c690a287b..339434b69 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/WhitespaceCollapser.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/WhitespaceCollapser.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -63,7 +63,7 @@ class WhitespaceCollapser {
txt.setText(newString);
}
}
-
+
/** process one RtfString from our container */
private void processString(RtfString txt) {
final String newString = processString(txt.getText());
@@ -71,7 +71,7 @@ class WhitespaceCollapser {
txt.setText(newString);
}
}
-
+
/** process one String */
private String processString(String txt) {
final String orig = txt;
@@ -80,7 +80,7 @@ class WhitespaceCollapser {
// to collapse multiple spaces into one
if (orig == null) {
return null;
- } else if (orig.length() > 0) {
+ } else if (orig.length() > 0) {
final boolean allSpaces = orig.trim().length() == 0;
final boolean endSpace = allSpaces
|| Character.isWhitespace(orig.charAt(orig.length() - 1));
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/tools/BuilderContext.java b/src/java/org/apache/fop/render/rtf/rtflib/tools/BuilderContext.java
index 7e9b59c20..430231792 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/tools/BuilderContext.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/tools/BuilderContext.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/tools/ImageConstants.java b/src/java/org/apache/fop/render/rtf/rtflib/tools/ImageConstants.java
index 274ad53f5..859472709 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/tools/ImageConstants.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/tools/ImageConstants.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/tools/ImageUtil.java b/src/java/org/apache/fop/render/rtf/rtflib/tools/ImageUtil.java
index 93bb991e8..c5e3cb191 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/tools/ImageUtil.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/tools/ImageUtil.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -67,7 +67,7 @@ public class ImageUtil {
} else {
//for example "600.0pt" has to be exited,
//when the dot is reached.
- break;
+ break;
}
}
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/tools/TableContext.java b/src/java/org/apache/fop/render/rtf/rtflib/tools/TableContext.java
index 826be58e7..96d65ad12 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/tools/TableContext.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/tools/TableContext.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -60,7 +60,7 @@ public class TableContext implements ITableColumnsInfo {
* as a number-rows-spanned attribute has been found.
*/
private final List colRowSpanningAttrs = new java.util.ArrayList();
-
+
/**
* This ArrayList contains one element for each column in the table.
* value == true means, it's the first of multiple spanned columns
@@ -71,7 +71,7 @@ public class TableContext implements ITableColumnsInfo {
private boolean bNextRowBelongsToHeader = false;
/**
- *
+ *
* @param value Specifies, if next row belongs to header
*/
public void setNextRowBelongsToHeader(boolean value) {
@@ -79,7 +79,7 @@ public class TableContext implements ITableColumnsInfo {
}
/**
- *
+ *
* @return true, if next row belongs to header
*/
public boolean getNextRowBelongsToHeader() {
@@ -87,7 +87,7 @@ public class TableContext implements ITableColumnsInfo {
}
/**
- *
+ *
* @param ctx BuilderContext
*/
public TableContext(BuilderContext ctx) {
@@ -95,7 +95,7 @@ public class TableContext implements ITableColumnsInfo {
}
/**
- * Adds a column and sets its width.
+ * Adds a column and sets its width.
* @param width Width of next column
*/
public void setNextColumnWidth(Float width) {
@@ -103,7 +103,7 @@ public class TableContext implements ITableColumnsInfo {
}
/**
- *
+ *
* @return RtfAttributes of current row-spanning cell
*/
public RtfAttributes getColumnRowSpanningAttrs() {
@@ -111,15 +111,15 @@ public class TableContext implements ITableColumnsInfo {
}
/**
- *
+ *
* @return Number of currently spanned rows
*/
public Integer getColumnRowSpanningNumber() {
return (Integer)colRowSpanningNumber.get(colIndex);
}
-
+
/**
- *
+ *
* @return true, if it's the first of multiple spanning columns
*/
public boolean getFirstSpanningCol() {
@@ -128,7 +128,7 @@ public class TableContext implements ITableColumnsInfo {
}
/**
- *
+ *
* @param iRowSpanning number of rows to span
* @param attrs RtfAttributes of row-spanning cell
*/
@@ -145,7 +145,7 @@ public class TableContext implements ITableColumnsInfo {
}
/**
- *
+ *
* @param iRowSpanning number of rows to span in next column
* @param attrs RtfAttributes of row-spanning cell
*/
@@ -154,10 +154,10 @@ public class TableContext implements ITableColumnsInfo {
colRowSpanningNumber.add(iRowSpanning);
colRowSpanningAttrs.add(colIndex, attrs);
}
-
+
/**
- *
- * @param bFirstSpanningCol specifies, if it's the first of
+ *
+ * @param bFirstSpanningCol specifies, if it's the first of
* multiple spanned columns
*/
public void setCurrentFirstSpanningCol(
@@ -174,8 +174,8 @@ public class TableContext implements ITableColumnsInfo {
}
/**
- *
- * @param bFirstSpanningCol specifies, if it's the first of
+ *
+ * @param bFirstSpanningCol specifies, if it's the first of
* multiple spanned columns
*/
public void setNextFirstSpanningCol(
@@ -234,7 +234,7 @@ public class TableContext implements ITableColumnsInfo {
if (colIndex < 0) {
throw new IllegalStateException("colIndex must not be negative!");
} else if (colIndex >= getNumberOfColumns()) {
- log.warn("Column width for column " + (colIndex + 1) + " is not defined, using "
+ log.warn("Column width for column " + (colIndex + 1) + " is not defined, using "
+ INVALID_COLUMN_WIDTH);
while (colIndex >= getNumberOfColumns()) {
setNextColumnWidth(new Float(INVALID_COLUMN_WIDTH));
@@ -250,9 +250,9 @@ public class TableContext implements ITableColumnsInfo {
public void setColumnIndex(int index) {
colIndex = index;
}
-
+
/**
- * @return Index of current column
+ * @return Index of current column
*/
public int getColumnIndex() {
return colIndex;
diff --git a/src/java/org/apache/fop/render/txt/Helper.java b/src/java/org/apache/fop/render/txt/Helper.java
index f2bd14914..1bdf86f0f 100644
--- a/src/java/org/apache/fop/render/txt/Helper.java
+++ b/src/java/org/apache/fop/render/txt/Helper.java
@@ -30,9 +30,9 @@ public final class Helper {
private Helper() { }
/**
- * Returns nearest integer to x, divisible by
- * quantum.
- *
+ * Returns nearest integer to x, divisible by
+ * quantum.
+ *
* @param x integer for quantization
* @param quantum integer, representing quantization
* @return computed nearest integer
@@ -44,9 +44,9 @@ public final class Helper {
}
/**
- * Returns minimal possible integer, greater or equal than
+ * Returns minimal possible integer, greater or equal than
* x, divisible by quantum.
- *
+ *
* @param x integer for quantization
* @param quantum integer, representing quantization
* @return computed nearest integer
@@ -59,7 +59,7 @@ public final class Helper {
/**
* Returns maximum possible integer, less or equal than
* oldValue, divisible by quantum.
- *
+ *
* @param x integer for quantization
* @param quantum integer, representing quantization
* @return computed nearest integer
@@ -71,9 +71,9 @@ public final class Helper {
/**
* Returns the closest integer to x/y fraction.
- * It's possible to consider this methos as a analog of Math.round(x/y),
+ * It's possible to consider this methos as a analog of Math.round(x/y),
* without having deal with non-integer.
- *
+ *
* @param x integer, fraction numerator
* @param y integer, fraction denominator
* @return the value of the fraction rounded to the nearest
@@ -84,31 +84,31 @@ public final class Helper {
}
/**
- * Returns the smallest integer that is greater than or equal to the
+ * Returns the smallest integer that is greater than or equal to the
* x/y fraction.
- * It's possible to consider this function as a analog of Math.ceil(x/y),
+ * It's possible to consider this function as a analog of Math.ceil(x/y),
* without having deal with non-integer.
- *
+ *
* @param x integer, fraction numerator
* @param y integer, fraction denominator
- * @return the smallest integer that is greater than or equal to
+ * @return the smallest integer that is greater than or equal to
* x/y fraction
* @see java.lang.Math#ceil(double)
*/
public static int ceilPosition(int x, int y) {
return ceil(x, y) / y;
}
-
-
+
+
/**
* Returns the largest integer that is less than or equal to the
* argument and is equal to x/y fraction.
- * It's possible to consider this function as a analog of Math.floor(x/y),
+ * It's possible to consider this function as a analog of Math.floor(x/y),
* without having deal with non-integer.
- *
+ *
* @param x integer, fraction numerator
* @param y integer, fraction denominator
- * @return the largest integer that is less than or equal to
+ * @return the largest integer that is less than or equal to
* the argument and is equal to x/y fraction
* @see java.lang.Math#floor(double)
*/
diff --git a/src/java/org/apache/fop/render/txt/TXTRenderer.java b/src/java/org/apache/fop/render/txt/TXTRenderer.java
index b6d09d769..52c6912d4 100644
--- a/src/java/org/apache/fop/render/txt/TXTRenderer.java
+++ b/src/java/org/apache/fop/render/txt/TXTRenderer.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
*/
/* $Id$ */
-
+
package org.apache.fop.render.txt;
import java.awt.Color;
@@ -40,17 +40,17 @@ import org.apache.fop.render.txt.border.BorderManager;
/**
* Renderer that renders areas to plain text.
- *
+ *
* @author Art Welch
* @author Mark Lillywhite (to use
* the new Renderer interface)
*/
public class TXTRenderer extends AbstractPathOrientedRenderer {
-
+
private static final char LIGHT_SHADE = '\u2591';
-
+
private static final char MEDIUM_SHADE = '\u2592';
-
+
private static final char DARK_SHADE = '\u2593';
private static final char FULL_BLOCK = '\u2588';
@@ -95,7 +95,7 @@ public class TXTRenderer extends AbstractPathOrientedRenderer {
/** Manager for storing border's information. */
private BorderManager bm;
-
+
/** Char for current filling. */
private char fillChar;
@@ -103,7 +103,7 @@ public class TXTRenderer extends AbstractPathOrientedRenderer {
private TXTState currentState = new TXTState();
private String encoding;
-
+
/**
* Constructs a newly allocated TXTRenderer object.
*/
@@ -114,7 +114,7 @@ public class TXTRenderer extends AbstractPathOrientedRenderer {
public String getMimeType() {
return "text/plain";
}
-
+
/**
* Sets the encoding of the target file.
* @param encoding the encoding, null to select the default encoding (UTF-8)
@@ -125,7 +125,7 @@ public class TXTRenderer extends AbstractPathOrientedRenderer {
/**
* Indicates if point (x, y) lay inside currentPage.
- *
+ *
* @param x x coordinate
* @param y y coordinate
* @return true if point lay inside page
@@ -136,7 +136,7 @@ public class TXTRenderer extends AbstractPathOrientedRenderer {
/**
* Add char to text buffer.
- *
+ *
* @param x x coordinate
* @param y y coordinate
* @param ch char to add
@@ -149,7 +149,7 @@ public class TXTRenderer extends AbstractPathOrientedRenderer {
/**
* Add char to text or background buffer.
- *
+ *
* @param x x coordinate
* @param y x coordinate
* @param ch char to add
@@ -168,7 +168,7 @@ public class TXTRenderer extends AbstractPathOrientedRenderer {
/**
* Adds string to text buffer (charData).
* Chars of string map in turn.
- *
+ *
* @param row x coordinate
* @param col y coordinate
* @param s string to add
@@ -181,7 +181,7 @@ public class TXTRenderer extends AbstractPathOrientedRenderer {
/**
* Render TextArea to Text.
- *
+ *
* @param area inline area to render
*/
protected void renderText(TextArea area) {
@@ -211,7 +211,7 @@ public class TXTRenderer extends AbstractPathOrientedRenderer {
pageWidth = Helper.ceilPosition((int) width, CHAR_WIDTH);
pageHeight = Helper.ceilPosition((int) height, CHAR_HEIGHT);
-
+
// init buffers
charData = new StringBuffer[pageHeight];
decoData = new StringBuffer[pageHeight];
@@ -229,8 +229,8 @@ public class TXTRenderer extends AbstractPathOrientedRenderer {
}
/**
- * Projects current page borders (i.e.bm) to buffer for
- * background and images (i.e.decoData).
+ * Projects current page borders (i.e.bm) to buffer for
+ * background and images (i.e.decoData).
*/
private void flushBorderToBuffer() {
for (int x = 0; x < pageWidth; x++) {
@@ -363,14 +363,14 @@ public class TXTRenderer extends AbstractPathOrientedRenderer {
}
/**
- * Does nothing.
+ * Does nothing.
* {@inheritDoc}
*/
protected void moveTo(float x, float y) {
}
/**
- * Does nothing.
+ * Does nothing.
* {@inheritDoc}
*/
protected void lineTo(float x, float y) {
@@ -384,16 +384,16 @@ public class TXTRenderer extends AbstractPathOrientedRenderer {
}
/**
- * Fills rectangle startX, startY, width, height with char
+ * Fills rectangle startX, startY, width, height with char
* charToFill.
- *
+ *
* @param startX x-coordinate of upper left point
* @param startY y-coordinate of upper left point
* @param width width of rectangle
* @param height height of rectangle
- * @param charToFill filling char
+ * @param charToFill filling char
*/
- private void fillRect(int startX, int startY, int width, int height,
+ private void fillRect(int startX, int startY, int width, int height,
char charToFill) {
for (int x = startX; x < startX + width; x++) {
for (int y = startY; y < startY + height; y++) {
@@ -401,7 +401,7 @@ public class TXTRenderer extends AbstractPathOrientedRenderer {
}
}
}
-
+
/**
* Fills a rectangular area with the current filling char.
* {@inheritDoc}
@@ -410,7 +410,7 @@ public class TXTRenderer extends AbstractPathOrientedRenderer {
fillRect(bm.getStartX(), bm.getStartY(), bm.getWidth(), bm.getHeight(),
fillChar);
}
-
+
/**
* Changes current filling char.
* {@inheritDoc}
@@ -423,11 +423,11 @@ public class TXTRenderer extends AbstractPathOrientedRenderer {
// TODO: This fillShase is catually the luminance component of the color
// transformed to the YUV (YPrBb) Colorspace. It should use standard
// Java methods for its conversion instead of the formula given here.
- double fillShade = 0.30f / 255f * col.getRed()
- + 0.59f / 255f * col.getGreen()
+ double fillShade = 0.30f / 255f * col.getRed()
+ + 0.59f / 255f * col.getGreen()
+ 0.11f / 255f * col.getBlue();
fillShade = 1 - fillShade;
-
+
if (fillShade > 0.8f) {
fillChar = FULL_BLOCK;
} else if (fillShade > 0.6f) {
@@ -445,10 +445,10 @@ public class TXTRenderer extends AbstractPathOrientedRenderer {
protected void drawImage(String url, Rectangle2D pos, Map foreignAttributes) {
//No images are painted here
}
-
+
/**
* Fills image rectangle with a IMAGE_CHAR.
- *
+ *
* @param image the base image
* @param pos the position of the image
*/
@@ -457,17 +457,17 @@ public class TXTRenderer extends AbstractPathOrientedRenderer {
int y1 = Helper.ceilPosition(currentBPPosition, CHAR_HEIGHT);
int width = Helper.ceilPosition((int) pos.getWidth(), CHAR_WIDTH);
int height = Helper.ceilPosition((int) pos.getHeight(), CHAR_HEIGHT);
-
+
fillRect(x1, y1, width, height, IMAGE_CHAR);
}
-
+
/**
* Returns the closest integer to the multiplication of a number and 1000.
- *
- * @param x the value of the argument, multiplied by
+ *
+ * @param x the value of the argument, multiplied by
* 1000 and rounded
- * @return the value of the argument multiplied by
+ * @return the value of the argument multiplied by
* 1000 and rounded to the nearest integer
*/
protected int toMilli(float x) {
@@ -476,11 +476,11 @@ public class TXTRenderer extends AbstractPathOrientedRenderer {
/**
* Adds one element of border.
- *
+ *
* @param x x coordinate
* @param y y coordinate
* @param style integer, representing border style
- * @param type integer, representing border element type
+ * @param type integer, representing border element type
*/
private void addBitOfBorder(int x, int y, int style, int type) {
Point point = currentState.transformPoint(x, y);
@@ -542,7 +542,7 @@ public class TXTRenderer extends AbstractPathOrientedRenderer {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}
*/
protected void drawBackAndBorders(Area area, float startx, float starty,
float width, float height) {
@@ -567,10 +567,10 @@ public class TXTRenderer extends AbstractPathOrientedRenderer {
protected void endVParea() {
currentState.pop();
}
-
+
/** {@inheritDoc} */
protected void concatenateTransformationMatrix(AffineTransform at) {
currentState.push(new CTM(ptToMpt(at)));
}
-
+
}
diff --git a/src/java/org/apache/fop/render/txt/TXTRendererConfigurator.java b/src/java/org/apache/fop/render/txt/TXTRendererConfigurator.java
index 0ca509b66..f2c47735f 100644
--- a/src/java/org/apache/fop/render/txt/TXTRendererConfigurator.java
+++ b/src/java/org/apache/fop/render/txt/TXTRendererConfigurator.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -26,7 +26,7 @@ import org.apache.fop.render.PrintRendererConfigurator;
import org.apache.fop.render.Renderer;
/**
- * TXT Renderer configurator
+ * TXT Renderer configurator
*/
public class TXTRendererConfigurator extends PrintRendererConfigurator {
diff --git a/src/java/org/apache/fop/render/txt/TXTRendererMaker.java b/src/java/org/apache/fop/render/txt/TXTRendererMaker.java
index 24e24ea87..0db369ef2 100644
--- a/src/java/org/apache/fop/render/txt/TXTRendererMaker.java
+++ b/src/java/org/apache/fop/render/txt/TXTRendererMaker.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -31,7 +31,7 @@ import org.apache.fop.render.RendererConfigurator;
public class TXTRendererMaker extends AbstractRendererMaker {
private static final String[] MIMES = new String[] {MimeConstants.MIME_PLAIN_TEXT};
-
+
/**{@inheritDoc} */
public Renderer makeRenderer(FOUserAgent userAgent) {
return new TXTRenderer();
diff --git a/src/java/org/apache/fop/render/txt/TXTState.java b/src/java/org/apache/fop/render/txt/TXTState.java
index 172b5eb9c..09abc2515 100644
--- a/src/java/org/apache/fop/render/txt/TXTState.java
+++ b/src/java/org/apache/fop/render/txt/TXTState.java
@@ -27,7 +27,7 @@ import java.util.LinkedList;
import org.apache.fop.area.CTM;
/**
- * This keeps information about the current state when writing to txt, i.e.
+ * This keeps information about the current state when writing to txt, i.e.
* manages coordinate transformation matrices for getting absolute coordinates.
*/
public class TXTState {
@@ -36,7 +36,7 @@ public class TXTState {
private LinkedList stackCTM = new LinkedList();
/**
- * Current result coordinate transformation matrix. It's product of
+ * Current result coordinate transformation matrix. It's product of
* all matrices in order, saved in stackCTM.
*/
private CTM resultCTM = new CTM();
@@ -48,9 +48,9 @@ public class TXTState {
}
/**
- * Updates result coordinate transformation matrix
+ * Updates result coordinate transformation matrix
* (i.e. resultCTM), multipliing it by given matrix.
- *
+ *
* @param ctm CTM
*/
private void updateResultCTM(CTM ctm) {
@@ -68,9 +68,9 @@ public class TXTState {
}
/**
- * Push the current coordinate transformation matrix onto the stack and
+ * Push the current coordinate transformation matrix onto the stack and
* reevaluate resultCTM.
- *
+ *
* @param ctm instance of CTM
*/
public void push(CTM ctm) {
@@ -86,11 +86,11 @@ public class TXTState {
stackCTM.removeLast();
calcResultCTM();
}
-
+
/**
- * Modifies coordinate transformation matrix in such a way, so
+ * Modifies coordinate transformation matrix in such a way, so
* x-shift and y-shift will be transformed in text positions.
- *
+ *
* @param ctm CTM to modify
* @return instance of CTM
*/
@@ -100,13 +100,13 @@ public class TXTState {
da[4] = Helper.roundPosition((int) da[4], TXTRenderer.CHAR_WIDTH);
// refine y-shift
da[5] = Helper.roundPosition((int) da[5], TXTRenderer.CHAR_HEIGHT);
-
+
return new CTM(da[0], da[1], da[2], da[3], da[4], da[5]);
}
/**
* Transforms point using ctm.
- *
+ *
* @param p Point
* @param ctm CTM
* @return transformed Point
@@ -120,7 +120,7 @@ public class TXTState {
/**
* Transforms point (x, y) using resultCTM.
- *
+ *
* @param x x-coordinate
* @param y y-coordinate
* @return transformed Point
diff --git a/src/java/org/apache/fop/render/txt/TXTStream.java b/src/java/org/apache/fop/render/txt/TXTStream.java
index 57797eb86..49e36be3a 100644
--- a/src/java/org/apache/fop/render/txt/TXTStream.java
+++ b/src/java/org/apache/fop/render/txt/TXTStream.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
*/
/* $Id$ */
-
+
package org.apache.fop.render.txt;
import java.io.IOException;
@@ -26,9 +26,9 @@ import java.io.OutputStream;
* Helper class for text streams.
*/
public class TXTStream {
-
+
private static final String DEFAULT_ENCODING = "UTF-8";
-
+
private OutputStream out = null;
private boolean doOutput = true;
private String encoding = DEFAULT_ENCODING;
@@ -65,7 +65,7 @@ public class TXTStream {
public void setDoOutput(boolean doout) {
doOutput = doout;
}
-
+
/**
* Set the encoding for the text stream.
* @param encoding the encoding, if null, "UTF-8" is chosen as default
diff --git a/src/java/org/apache/fop/render/txt/border/AbstractBorderElement.java b/src/java/org/apache/fop/render/txt/border/AbstractBorderElement.java
index 80f8dc01c..cd79594c1 100644
--- a/src/java/org/apache/fop/render/txt/border/AbstractBorderElement.java
+++ b/src/java/org/apache/fop/render/txt/border/AbstractBorderElement.java
@@ -33,25 +33,25 @@ import org.apache.fop.render.txt.TXTState;
public abstract class AbstractBorderElement implements Constants {
/**
- * Constant for a line segment, directing from a center of symbol up
+ * Constant for a line segment, directing from a center of symbol up
* the the symbol boundary.
*/
public static final int UP = 0;
/**
- * Constant for a line segment, directing from a center of symbol right
+ * Constant for a line segment, directing from a center of symbol right
* the the symbol boundary.
*/
public static final int RIGHT = 1;
/**
- * Constant for a line segment, directing from a center of symbol down
+ * Constant for a line segment, directing from a center of symbol down
* the the symbol boundary.
*/
public static final int DOWN = 2;
/**
- * Constant for a line segment, directing from a center of symbol left
+ * Constant for a line segment, directing from a center of symbol left
* the the symbol boundary.
*/
public static final int LEFT = 3;
@@ -63,7 +63,7 @@ public abstract class AbstractBorderElement implements Constants {
protected int[] data = {0, 0, 0, 0};
/**
- * Initializes a newly created AbstractBorderElement object
+ * Initializes a newly created AbstractBorderElement object
* so that it represents an empty border element.
*/
public AbstractBorderElement() {
@@ -71,9 +71,9 @@ public abstract class AbstractBorderElement implements Constants {
/**
* Constructs a newly allocated AbstractBorderElement object.
- * Fills array data using binary representation of
+ * Fills array data using binary representation of
* type.
- *
+ *
* @param type binary representation of type gives data
*/
public AbstractBorderElement(int type) {
@@ -84,7 +84,7 @@ public abstract class AbstractBorderElement implements Constants {
/**
* Returns value of side's element of data.
- *
+ *
* @param side integer, representing side
* @return value of side's element
*/
@@ -94,7 +94,7 @@ public abstract class AbstractBorderElement implements Constants {
/**
* Sets a value for data[side].
- *
+ *
* @param side integer, representing side
* @param value a new value for data[side]
*/
diff --git a/src/java/org/apache/fop/render/txt/border/BorderManager.java b/src/java/org/apache/fop/render/txt/border/BorderManager.java
index 4a470a37f..0af243ec6 100644
--- a/src/java/org/apache/fop/render/txt/border/BorderManager.java
+++ b/src/java/org/apache/fop/render/txt/border/BorderManager.java
@@ -32,7 +32,7 @@ public class BorderManager {
/** Width of current processed border. */
private int width;
-
+
/** Height of current processed border. */
private int height;
@@ -46,9 +46,9 @@ public class BorderManager {
private TXTState state;
/**
- * Constructs BorderManger, using pageWidth and
+ * Constructs BorderManger, using pageWidth and
* pageHeight for creating borderInfo.
- *
+ *
* @param pageWidth page width
* @param pageHeight page height
* @param state TXTState
@@ -60,12 +60,12 @@ public class BorderManager {
/**
* Adds border element to borderInfo.
- *
+ *
* @param x x-coordinate
* @param y y-coordinate
* @param style border-style
- * @param type border element type, binary representation of wich gives
- * information about availability or absence of corresponding side.
+ * @param type border element type, binary representation of wich gives
+ * information about availability or absence of corresponding side.
*/
public void addBorderElement(int x, int y, int style, int type) {
AbstractBorderElement be = null;
@@ -91,9 +91,9 @@ public class BorderManager {
/**
* @param x x-coordinate
* @param y y-coordinate
- * @return if border element at point (x,y) is available, returns instance
- * of Character, created on char, given by corresponding border element,
- * otherwise returns null.
+ * @return if border element at point (x,y) is available, returns instance
+ * of Character, created on char, given by corresponding border element,
+ * otherwise returns null.
*/
public Character getCharacter(int x, int y) {
Character c = null;
@@ -109,7 +109,7 @@ public class BorderManager {
public int getWidth() {
return width;
}
-
+
/**
* Sets width of current processed border.
* @param width width of border
@@ -117,7 +117,7 @@ public class BorderManager {
public void setWidth(int width) {
this.width = width;
}
-
+
/**
* @return height of current processed border.
*/
diff --git a/src/java/org/apache/fop/render/txt/border/DashedBorderElement.java b/src/java/org/apache/fop/render/txt/border/DashedBorderElement.java
index d91179845..7c806e6ce 100644
--- a/src/java/org/apache/fop/render/txt/border/DashedBorderElement.java
+++ b/src/java/org/apache/fop/render/txt/border/DashedBorderElement.java
@@ -25,39 +25,39 @@ import java.util.Arrays;
* This class is responsible for managing of dashed border elements.
*/
public class DashedBorderElement extends AbstractBorderElement {
-
+
private static final char DASH_HORIZONTAL = '-';
private static final char DASH_VERTICAL = '|';
-
+
private static final char UNDEFINED = '?';
-
+
private static final int UP2 = 1;
-
+
private static final int RIGHT2 = 2;
-
+
private static final int DOWN2 = 4;
-
+
private static final int LEFT2 = 8;
-
+
private static char[] map = new char[20];
-
+
static {
Arrays.fill(map, UNDEFINED);
map[0] = ' ';
map[UP2] = DASH_VERTICAL;
map[DOWN2] = DASH_VERTICAL;
map[UP2 + DOWN2] = DASH_VERTICAL;
-
+
map[LEFT2] = DASH_HORIZONTAL;
map[RIGHT2] = DASH_HORIZONTAL;
map[LEFT2 + RIGHT2] = DASH_HORIZONTAL;
}
-
+
/**
* Constructs a newly allocated DashedBorderElement object.
* Fills data using superclass constructor.
- *
+ *
* @param type binary representation of type gives data
*/
public DashedBorderElement(int type) {
@@ -66,8 +66,8 @@ public class DashedBorderElement extends AbstractBorderElement {
/**
* Merges dashed border element with instance of solid and double border
- * element, returns instance of SolidAndDoubleBorderElement.
- *
+ * element, returns instance of SolidAndDoubleBorderElement.
+ *
* @param sdb instance of SolidAndDoubleBorderElement to merge
* @return merged border element
*/
@@ -76,13 +76,13 @@ public class DashedBorderElement extends AbstractBorderElement {
for (int i = 0; i < 4; i++) {
e.setData(i, Math.max(data[i], sdb.getData(i)));
}
- return e;
+ return e;
}
/**
- * Merges dashed border element with dashed border element and returns
- * instance of DashedBorderElement.
- *
+ * Merges dashed border element with dashed border element and returns
+ * instance of DashedBorderElement.
+ *
* @param dbe instance of DashedBorderElement to merge
* @return merged border element
*/
@@ -92,11 +92,11 @@ public class DashedBorderElement extends AbstractBorderElement {
}
return this;
}
-
+
/**
- * Converts dashed border element to
+ * Converts dashed border element to
* SolidAndDoubleBorderElement.
- *
+ *
* @return converted instance of SolidAndDoubleBorderElement
*/
private AbstractBorderElement toSolidAndDouble() {
@@ -104,7 +104,7 @@ public class DashedBorderElement extends AbstractBorderElement {
for (int i = 0; i < 4; i++) {
e.setData(i, data[i]);
}
- return e;
+ return e;
}
/**
@@ -124,7 +124,7 @@ public class DashedBorderElement extends AbstractBorderElement {
return abe;
}
- /**
+ /**
* {@inheritDoc}
*/
public char convert2Char() {
diff --git a/src/java/org/apache/fop/render/txt/border/DottedBorderElement.java b/src/java/org/apache/fop/render/txt/border/DottedBorderElement.java
index e5930fcb3..3e1700f1a 100644
--- a/src/java/org/apache/fop/render/txt/border/DottedBorderElement.java
+++ b/src/java/org/apache/fop/render/txt/border/DottedBorderElement.java
@@ -23,13 +23,13 @@ package org.apache.fop.render.txt.border;
* This class is responsible for managing of dotted border elements.
*/
public class DottedBorderElement extends AbstractBorderElement {
-
+
private static final char MIDDLE_DOT = '\u00B7';
/**
* Merges dotted border element with another border element. Here merging
* is quite simple: returning this without any comparing.
- *
+ *
* @param e instance of AbstractBorderElement
* @return instance of DottedBorderElement
*/
diff --git a/src/java/org/apache/fop/render/txt/border/SolidAndDoubleBorderElement.java b/src/java/org/apache/fop/render/txt/border/SolidAndDoubleBorderElement.java
index b14ecabe7..7defc64c6 100644
--- a/src/java/org/apache/fop/render/txt/border/SolidAndDoubleBorderElement.java
+++ b/src/java/org/apache/fop/render/txt/border/SolidAndDoubleBorderElement.java
@@ -47,67 +47,67 @@ public class SolidAndDoubleBorderElement extends AbstractBorderElement {
private static final char LIGHT_UP_AND_HORIZONTAL = '\u2534';
private static final char LIGHT_VERTICAL_AND_HORIZONTAL = '\u253C';
-
+
private static final char DOUBLE_HORIZONTAL = '\u2550';
private static final char DOUBLE_VERTICAL = '\u2551';
-
- private static final char DOUBLE_DOWN_AND_RIGHT = '\u2554';
+
+ private static final char DOUBLE_DOWN_AND_RIGHT = '\u2554';
private static final char DOUBLE_DOWN_AND_LEFT = '\u2557';
private static final char DOUBLE_UP_AND_RIGHT = '\u255A';
private static final char DOUBLE_UP_AND_LEFT = '\u255D';
-
+
private static final char DOUBLE_VERTICAL_AND_RIGHT = '\u2560';
-
+
private static final char DOUBLE_VERTICAL_AND_LEFT = '\u2563';
-
+
private static final char DOUBLE_DOWN_AND_HORIZONTAL = '\u2566';
-
+
private static final char DOUBLE_UP_AND_HORIZONTAL = '\u2569';
-
+
private static final char DOUBLE_VERTICAL_AND_HORIZONTAL = '\u256C';
-
+
private static final char DOWN_SINGLE_AND_RIGHT_DOUBLE = '\u2552';
-
+
private static final char DOWN_DOUBLE_AND_RIGHT_SINGLE = '\u2553';
private static final char DOWN_SINGLE_AND_LEFT_DOUBLE = '\u2555';
private static final char DOWN_DOUBLE_AND_LEFT_SINGLE = '\u2556';
-
+
private static final char UP_SINGLE_AND_RIGHT_DOUBLE = '\u2558';
-
+
private static final char UP_DOUBLE_AND_RIGHT_SINGLE = '\u2559';
-
+
private static final char UP_SINGLE_AND_LEFT_DOUBLE = '\u255B';
-
+
private static final char UP_DOUBLE_AND_LEFT_SINGLE = '\u255C';
-
+
private static final char VERTICAL_SINGLE_AND_RIGHT_DOUBLE = '\u255E';
-
+
private static final char VERTICAL_DOUBLE_AND_RIGHT_SINGLE = '\u255F';
-
+
private static final char VERTICAL_SINGLE_AND_LEFT_DOUBLE = '\u2561';
-
+
private static final char VERTICAL_DOUBLE_AND_LEFT_SINGLE = '\u2562';
-
+
private static final char DOWN_SINGLE_AND_HORIZONTAL_DOUBLE = '\u2564';
-
+
private static final char DOWN_DOUBLE_AND_HORIZONTAL_SINGLE = '\u2565';
-
+
private static final char UP_SINGLE_AND_HORIZONTAL_DOUBLE = '\u2567';
-
+
private static final char UP_DOUBLE_AND_HORIZONTAL_SINGLE = '\u2568';
-
+
private static final char VERTICAL_SINGLE_AND_HORIZONTAL_DOUBLE = '\u256A';
-
+
private static final char VERTICAL_DOUBLE_AND_HORIZONTAL_SINGLE = '\u256B';
-
+
private static final char UNDEFINED = '?';
-
+
private static final int UP3 = 1;
private static final int DOWN3 = 3;
@@ -174,19 +174,19 @@ public class SolidAndDoubleBorderElement extends AbstractBorderElement {
}
/**
- * Initializes a newly created SolidAndDoubleBorderElement
+ * Initializes a newly created SolidAndDoubleBorderElement
* object so that it represents an empty border element.
*/
public SolidAndDoubleBorderElement() {
}
/**
- * Constructs a newly allocated SolidAndDoubleBorderElement
- * object. Fills data using binary representation of
- * type. If border style is EN_DOUBLE, multiplies
- * data[side] by 2 for every side to distinguish EN_SOLID and
+ * Constructs a newly allocated SolidAndDoubleBorderElement
+ * object. Fills data using binary representation of
+ * type. If border style is EN_DOUBLE, multiplies
+ * data[side] by 2 for every side to distinguish EN_SOLID and
* EN_DOUBLE.
- *
+ *
* @param style integer, representing border style.
* @param type binary representation of type gives data
*/
@@ -198,7 +198,7 @@ public class SolidAndDoubleBorderElement extends AbstractBorderElement {
}
}
}
-
+
/**
* Merges with sde.
* @param sde instance of SolidAndDoubleBorderElement
@@ -232,10 +232,10 @@ public class SolidAndDoubleBorderElement extends AbstractBorderElement {
}
return abe;
}
-
+
/**
* Maps to char.
- * @return resulting mapping char
+ * @return resulting mapping char
*/
private char map2Char() {
int key = 0;
diff --git a/src/java/org/apache/fop/render/xml/AbstractXMLRenderer.java b/src/java/org/apache/fop/render/xml/AbstractXMLRenderer.java
index 7aa22e080..4f62155a3 100644
--- a/src/java/org/apache/fop/render/xml/AbstractXMLRenderer.java
+++ b/src/java/org/apache/fop/render/xml/AbstractXMLRenderer.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -88,7 +88,7 @@ public abstract class AbstractXMLRenderer extends PrintRenderer {
* @param comment the comment
*/
protected void comment(String comment) {
- if (handler instanceof LexicalHandler) {
+ if (handler instanceof LexicalHandler) {
try {
((LexicalHandler) handler).comment(comment.toCharArray(), 0, comment.length());
} catch (SAXException saxe) {
@@ -96,7 +96,7 @@ public abstract class AbstractXMLRenderer extends PrintRenderer {
}
}
}
-
+
/**
* Starts a new element (without attributes).
* @param tagName tag name of the element
@@ -158,7 +158,7 @@ public abstract class AbstractXMLRenderer extends PrintRenderer {
* @param value value of the attribute
*/
protected void addAttribute(QName name, String value) {
- atts.addAttribute(name.getNamespaceURI(), name.getLocalName(), name.getQName(),
+ atts.addAttribute(name.getNamespaceURI(), name.getLocalName(), name.getQName(),
CDATA, value);
}
@@ -175,7 +175,7 @@ public abstract class AbstractXMLRenderer extends PrintRenderer {
return "" + (int) rect.getX() + " " + (int) rect.getY() + " "
+ (int) rect.getWidth() + " " + (int) rect.getHeight();
}
-
+
/**
* Adds a new attribute to the protected member variable "atts".
* @param name name of the attribute
@@ -259,7 +259,7 @@ public abstract class AbstractXMLRenderer extends PrintRenderer {
* @param attachments a list of extension attachments
*/
protected abstract void handleExtensionAttachments(List attachments);
-
+
/**
* Renders a bookmark tree
* @param odi the bookmark data
diff --git a/src/java/org/apache/fop/render/xml/XMLRenderer.java b/src/java/org/apache/fop/render/xml/XMLRenderer.java
index aec067b91..38db7abdf 100644
--- a/src/java/org/apache/fop/render/xml/XMLRenderer.java
+++ b/src/java/org/apache/fop/render/xml/XMLRenderer.java
@@ -92,7 +92,7 @@ import org.apache.fop.util.ColorUtil;
* Renderer that renders areas to XML for debugging purposes.
* This creates an xml that contains the information of the area
* tree. It does not output any state or derived information.
- * The output can be used to build a new area tree which can be
+ * The output can be used to build a new area tree which can be
* rendered to any renderer.
*/
public class XMLRenderer extends AbstractXMLRenderer {
@@ -148,7 +148,7 @@ public class XMLRenderer extends AbstractXMLRenderer {
public void setCompactFormat(boolean compact) {
this.compactFormat = compact;
}
-
+
private boolean isDetailedFormat() {
return !this.compactFormat;
}
@@ -243,7 +243,7 @@ public class XMLRenderer extends AbstractXMLRenderer {
}
}
}
-
+
transferForeignObjects(area);
}
@@ -261,7 +261,7 @@ public class XMLRenderer extends AbstractXMLRenderer {
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry)iter.next();
String qn = "xmlns:" + (String)entry.getKey();
- atts.addAttribute("", (String)entry.getKey(), qn,
+ atts.addAttribute("", (String)entry.getKey(), qn,
CDATA, (String)entry.getValue());
}
}
@@ -606,7 +606,7 @@ public class XMLRenderer extends AbstractXMLRenderer {
renderBlocks(block, children);
}
}
-
+
/** {@inheritDoc} */
protected void renderBlock(Block block) {
atts.clear();
@@ -779,7 +779,7 @@ public class XMLRenderer extends AbstractXMLRenderer {
protected void renderWord(WordArea word) {
atts.clear();
addAttribute("offset", word.getOffset());
- int[] letterAdjust = word.getLetterAdjustArray();
+ int[] letterAdjust = word.getLetterAdjustArray();
if (letterAdjust != null) {
StringBuffer sb = new StringBuffer(64);
boolean nonZeroFound = false;
diff --git a/src/java/org/apache/fop/render/xml/XMLRendererMaker.java b/src/java/org/apache/fop/render/xml/XMLRendererMaker.java
index 5aa0deb2b..8526daa2a 100644
--- a/src/java/org/apache/fop/render/xml/XMLRendererMaker.java
+++ b/src/java/org/apache/fop/render/xml/XMLRendererMaker.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -32,7 +32,7 @@ import org.apache.fop.render.RendererConfigurator;
public class XMLRendererMaker extends AbstractRendererMaker {
private static final String[] MIMES = new String[] {MimeConstants.MIME_FOP_AREA_TREE};
-
+
/**{@inheritDoc} */
public Renderer makeRenderer(FOUserAgent userAgent) {
return new XMLRenderer();
diff --git a/src/java/org/apache/fop/servlet/FopPrintServlet.java b/src/java/org/apache/fop/servlet/FopPrintServlet.java
index f99468743..d446dff54 100644
--- a/src/java/org/apache/fop/servlet/FopPrintServlet.java
+++ b/src/java/org/apache/fop/servlet/FopPrintServlet.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -53,31 +53,31 @@ import org.apache.fop.apps.MimeConstants;
*
* Example URL: http://servername/fop/servlet/FopPrintServlet?xml=data.xml&xsl=format.xsl
*
- * Note: This servlet is derived from FopServlet. Most methods are inherited from the
+ * Note: This servlet is derived from FopServlet. Most methods are inherited from the
* superclass. Only the differences to the base class are necessary.
- *
+ *
* @author Apache FOP Development Team
* @version $Id$
*/
public class FopPrintServlet extends FopServlet {
/**
- * {@inheritDoc}
+ * {@inheritDoc}
*/
protected void render(Source src, Transformer transformer, HttpServletResponse response)
throws FOPException, TransformerException, IOException {
FOUserAgent foUserAgent = getFOUserAgent();
-
+
//Setup FOP
Fop fop = fopFactory.newFop(MimeConstants.MIME_FOP_PRINT, foUserAgent);
-
+
//Make sure the XSL transformation's result is piped through to FOP
Result res = new SAXResult(fop.getDefaultHandler());
-
+
//Start the transformation and rendering process
transformer.transform(src, res);
-
+
//Return the result
reportOK(response);
}
diff --git a/src/java/org/apache/fop/servlet/FopServlet.java b/src/java/org/apache/fop/servlet/FopServlet.java
index 173e622dd..9b2326032 100644
--- a/src/java/org/apache/fop/servlet/FopServlet.java
+++ b/src/java/org/apache/fop/servlet/FopServlet.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -85,7 +85,7 @@ public class FopServlet extends HttpServlet {
/** The FopFactory used to create Fop instances */
protected FopFactory fopFactory = null;
/** URIResolver for use by this servlet */
- protected URIResolver uriResolver;
+ protected URIResolver uriResolver;
/**
* {@inheritDoc}
@@ -101,7 +101,7 @@ public class FopServlet extends HttpServlet {
this.fopFactory.setURIResolver(this.uriResolver);
configureFopFactory();
}
-
+
/**
* This method is called right after the FopFactory is instantiated and can be overridden
* by subclasses to perform additional configuration.
@@ -111,7 +111,7 @@ public class FopServlet extends HttpServlet {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}
*/
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException {
@@ -163,7 +163,7 @@ public class FopServlet extends HttpServlet {
response.getOutputStream().write(content);
response.getOutputStream().flush();
}
-
+
/**
* Renders an XSL-FO file into a PDF file. The PDF is written to a byte
* array that is returned as the method's result.
@@ -252,7 +252,7 @@ public class FopServlet extends HttpServlet {
//Return the result
sendPDF(out.toByteArray(), response);
}
-
+
/** @return a new FOUserAgent for FOP */
protected FOUserAgent getFOUserAgent() {
FOUserAgent userAgent = fopFactory.newFOUserAgent();
diff --git a/src/java/org/apache/fop/servlet/ServletContextURIResolver.java b/src/java/org/apache/fop/servlet/ServletContextURIResolver.java
index 48bd2d6cb..413dac76d 100644
--- a/src/java/org/apache/fop/servlet/ServletContextURIResolver.java
+++ b/src/java/org/apache/fop/servlet/ServletContextURIResolver.java
@@ -37,9 +37,9 @@ public class ServletContextURIResolver implements URIResolver {
/** The protocol name for the servlet context URIs. */
public static final String SERVLET_CONTEXT_PROTOCOL = "servlet-context:";
-
+
private ServletContext servletContext;
-
+
/**
* Main constructor
* @param servletContext the servlet context to access the resources through
@@ -47,14 +47,14 @@ public class ServletContextURIResolver implements URIResolver {
public ServletContextURIResolver(ServletContext servletContext) {
this.servletContext = servletContext;
}
-
+
/** {@inheritDoc} */
public Source resolve(String href, String base) throws TransformerException {
if (href.startsWith(SERVLET_CONTEXT_PROTOCOL)) {
return resolveServletContextURI(href.substring(SERVLET_CONTEXT_PROTOCOL.length()));
} else {
- if (base != null
- && base.startsWith(SERVLET_CONTEXT_PROTOCOL)
+ if (base != null
+ && base.startsWith(SERVLET_CONTEXT_PROTOCOL)
&& (href.indexOf(':') < 0)) {
String abs = base + href;
return resolveServletContextURI(
diff --git a/src/java/org/apache/fop/svg/ACIUtils.java b/src/java/org/apache/fop/svg/ACIUtils.java
index 984b63f25..91dfb85ca 100644
--- a/src/java/org/apache/fop/svg/ACIUtils.java
+++ b/src/java/org/apache/fop/svg/ACIUtils.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -44,7 +44,7 @@ public final class ACIUtils {
Map.Entry entry = (Map.Entry)i.next();
if (entry.getValue() != null) {
System.out.println(entry.getKey() + ": " + entry.getValue());
- }
+ }
}
int start = aci.getBeginIndex();
System.out.print("AttrRuns: ");
@@ -54,7 +54,7 @@ public final class ACIUtils {
aci.setIndex(end);
if (start == end) {
break;
- }
+ }
start = end;
}
System.out.println("");
diff --git a/src/java/org/apache/fop/svg/AbstractFOPTranscoder.java b/src/java/org/apache/fop/svg/AbstractFOPTranscoder.java
index b7cee29ef..83cfa8021 100644
--- a/src/java/org/apache/fop/svg/AbstractFOPTranscoder.java
+++ b/src/java/org/apache/fop/svg/AbstractFOPTranscoder.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
*/
/* $Id$ */
-
+
package org.apache.fop.svg;
import org.apache.batik.bridge.UserAgent;
@@ -40,7 +40,7 @@ import org.xml.sax.EntityResolver;
public abstract class AbstractFOPTranscoder extends SVGAbstractTranscoder {
/**
- * The key to specify whether to stroke text instead of using text
+ * The key to specify whether to stroke text instead of using text
* operations.
*/
public static final TranscodingHints.Key KEY_STROKE_TEXT = new BooleanKey();
@@ -69,7 +69,7 @@ public abstract class AbstractFOPTranscoder extends SVGAbstractTranscoder {
hints.put(KEY_DOM_IMPLEMENTATION,
SVGDOMImplementation.getDOMImplementation());
}
-
+
/**
* Creates and returns the default user agent for this transcoder. Override
* this method if you need non-default behaviour.
@@ -78,7 +78,7 @@ public abstract class AbstractFOPTranscoder extends SVGAbstractTranscoder {
protected UserAgent createUserAgent() {
return new FOPTranscoderUserAgent();
}
-
+
/**
* @param logger
*/
@@ -93,9 +93,9 @@ public abstract class AbstractFOPTranscoder extends SVGAbstractTranscoder {
public void setEntityResolver(EntityResolver resolver) {
this.resolver = resolver;
}
-
+
/**
- * Returns the logger associated with this transcoder. It returns a
+ * Returns the logger associated with this transcoder. It returns a
* SimpleLog if no logger has been explicitly set.
* @return Logger the logger for the transcoder.
*/
@@ -106,7 +106,7 @@ public abstract class AbstractFOPTranscoder extends SVGAbstractTranscoder {
}
return this.logger;
}
-
+
/**
* Creates a DocumentFactory that is used to create an SVG DOM
* tree. The specified DOM Implementation is ignored and the Batik
@@ -118,7 +118,7 @@ public abstract class AbstractFOPTranscoder extends SVGAbstractTranscoder {
*/
protected DocumentFactory createDocumentFactory(DOMImplementation domImpl,
String parserClassname) {
- final FOPSAXSVGDocumentFactory factory
+ final FOPSAXSVGDocumentFactory factory
= new FOPSAXSVGDocumentFactory(parserClassname);
if (this.resolver != null) {
factory.setAdditionalEntityResolver(this.resolver);
@@ -141,18 +141,18 @@ public abstract class AbstractFOPTranscoder extends SVGAbstractTranscoder {
}
return stroke;
}
-
+
// --------------------------------------------------------------------
// FOP's default error handler (for transcoders)
// --------------------------------------------------------------------
/**
* This is the default transcoder error handler for FOP. It logs error
- * to an Commons Logger instead of to System.out. The remaining behaviour
+ * to an Commons Logger instead of to System.out. The remaining behaviour
* is the same as Batik's DefaultErrorHandler.
- */
+ */
protected class FOPErrorHandler implements ErrorHandler {
-
+
/**
* {@inheritDoc}
*/
@@ -244,5 +244,5 @@ public abstract class AbstractFOPTranscoder extends SVGAbstractTranscoder {
}
}
-
+
}
diff --git a/src/java/org/apache/fop/svg/FOPSAXSVGDocumentFactory.java b/src/java/org/apache/fop/svg/FOPSAXSVGDocumentFactory.java
index e265613fa..720795cb2 100644
--- a/src/java/org/apache/fop/svg/FOPSAXSVGDocumentFactory.java
+++ b/src/java/org/apache/fop/svg/FOPSAXSVGDocumentFactory.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
*/
/* $Id$ */
-
+
package org.apache.fop.svg;
import java.io.IOException;
@@ -41,7 +41,7 @@ public class FOPSAXSVGDocumentFactory extends SAXSVGDocumentFactory {
public FOPSAXSVGDocumentFactory(String parser) {
super(parser);
}
-
+
/**
* Sets an additional entity resolver. It will be used before the default
* entity resolving.
@@ -50,9 +50,9 @@ public class FOPSAXSVGDocumentFactory extends SAXSVGDocumentFactory {
public void setAdditionalEntityResolver(EntityResolver resolver) {
this.additionalResolver = resolver;
}
-
+
/**
- * {@inheritDoc}
+ * {@inheritDoc}
*/
public InputSource resolveEntity(String publicId, String systemId)
throws SAXException {
diff --git a/src/java/org/apache/fop/svg/GraphicsConfiguration.java b/src/java/org/apache/fop/svg/GraphicsConfiguration.java
index a92baed27..ca3b3363c 100644
--- a/src/java/org/apache/fop/svg/GraphicsConfiguration.java
+++ b/src/java/org/apache/fop/svg/GraphicsConfiguration.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
*/
/* $Id$ */
-
+
package org.apache.fop.svg;
@@ -27,8 +27,8 @@ import java.awt.image.VolatileImage;
* compilation errors.
* The version for JDK 1.4 needs to add an override for the abstract
* createCompatibleVolatileImage() method. It can't be overidden
- * for JDK 1.3 because there is no VolatileImage there.
- *
+ * for JDK 1.3 because there is no VolatileImage there.
+ *
*/
abstract public class GraphicsConfiguration extends java.awt.GraphicsConfiguration {
diff --git a/src/java/org/apache/fop/svg/PDFAElementBridge.java b/src/java/org/apache/fop/svg/PDFAElementBridge.java
index e9bb8a955..9ab360f39 100644
--- a/src/java/org/apache/fop/svg/PDFAElementBridge.java
+++ b/src/java/org/apache/fop/svg/PDFAElementBridge.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
*/
/* $Id$ */
-
+
package org.apache.fop.svg;
import java.awt.geom.AffineTransform;
@@ -55,7 +55,7 @@ public class PDFAElementBridge extends AbstractGraphicsNodeBridge {
public AffineTransform getCurrentTransform() {
return this.transform;
}
-
+
/**
* Returns 'a'.
* @return the name of this node
diff --git a/src/java/org/apache/fop/svg/PDFANode.java b/src/java/org/apache/fop/svg/PDFANode.java
index 84c8b9e42..a2d1d354c 100644
--- a/src/java/org/apache/fop/svg/PDFANode.java
+++ b/src/java/org/apache/fop/svg/PDFANode.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
*/
/* $Id$ */
-
+
package org.apache.fop.svg;
import org.apache.batik.gvt.CompositeGraphicsNode;
@@ -102,7 +102,7 @@ public class PDFANode extends CompositeGraphicsNode {
}
}
} catch (Exception e) {
- //TODO Move this to setDestination() and throw an IllegalArgumentException
+ //TODO Move this to setDestination() and throw an IllegalArgumentException
e.printStackTrace();
}
Rectangle2D destRect = new Rectangle2D.Float(x, y, width, height);
diff --git a/src/java/org/apache/fop/svg/PDFBatikFlowTextElementBridge.java b/src/java/org/apache/fop/svg/PDFBatikFlowTextElementBridge.java
index 748e216a7..d167f5de4 100644
--- a/src/java/org/apache/fop/svg/PDFBatikFlowTextElementBridge.java
+++ b/src/java/org/apache/fop/svg/PDFBatikFlowTextElementBridge.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -32,7 +32,7 @@ import org.apache.fop.fonts.FontInfo;
public class PDFBatikFlowTextElementBridge extends BatikFlowTextElementBridge {
private PDFTextPainter textPainter;
-
+
/**
* Main Constructor.
* @param fontInfo the font directory
@@ -40,7 +40,7 @@ public class PDFBatikFlowTextElementBridge extends BatikFlowTextElementBridge {
public PDFBatikFlowTextElementBridge(FontInfo fontInfo) {
this.textPainter = new PDFFlowExtTextPainter(fontInfo);
}
-
+
/** {@inheritDoc} */
protected GraphicsNode instantiateGraphicsNode() {
GraphicsNode node = super.instantiateGraphicsNode();
@@ -58,5 +58,5 @@ public class PDFBatikFlowTextElementBridge extends BatikFlowTextElementBridge {
public TextPainter getTextPainter() {
return this.textPainter;
}
-
+
}
diff --git a/src/java/org/apache/fop/svg/PDFBridgeContext.java b/src/java/org/apache/fop/svg/PDFBridgeContext.java
index 9f235b6a9..fdf83784f 100644
--- a/src/java/org/apache/fop/svg/PDFBridgeContext.java
+++ b/src/java/org/apache/fop/svg/PDFBridgeContext.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -36,7 +36,7 @@ import org.apache.fop.fonts.FontInfo;
* BridgeContext which registers the custom bridges for PDF output.
*/
public class PDFBridgeContext extends BridgeContext {
-
+
/** The font list. */
private final FontInfo fontInfo;
@@ -44,7 +44,7 @@ public class PDFBridgeContext extends BridgeContext {
private final ImageSessionContext imageSessionContext;
private AffineTransform linkTransform;
-
+
/**
* Constructs a new bridge context.
* @param userAgent the user agent
@@ -75,8 +75,8 @@ public class PDFBridgeContext extends BridgeContext {
* @param linkTransform AffineTransform to properly place links,
* may be null
*/
- public PDFBridgeContext(UserAgent userAgent,
- FontInfo fontInfo,
+ public PDFBridgeContext(UserAgent userAgent,
+ FontInfo fontInfo,
ImageManager imageManager,
ImageSessionContext imageSessionContext,
AffineTransform linkTransform) {
@@ -115,12 +115,12 @@ public class PDFBridgeContext extends BridgeContext {
public ImageSessionContext getImageSessionContext() {
return this.imageSessionContext;
}
-
+
private void putPDFElementBridgeConditional(String className, String testFor) {
try {
Class.forName(testFor);
//if we get here the test class is available
-
+
Class clazz = Class.forName(className);
Constructor constructor = clazz.getConstructor(new Class[] {FontInfo.class});
putBridge((Bridge)constructor.newInstance(new Object[] {fontInfo}));
@@ -128,7 +128,7 @@ public class PDFBridgeContext extends BridgeContext {
//simply ignore (bridges instantiated over this method are optional)
}
}
-
+
/** {@inheritDoc} */
public void registerSVGBridges() {
super.registerSVGBridges();
@@ -136,7 +136,7 @@ public class PDFBridgeContext extends BridgeContext {
if (fontInfo != null) {
PDFTextElementBridge textElementBridge = new PDFTextElementBridge(fontInfo);
putBridge(textElementBridge);
-
+
//Batik flow text extension (may not always be available)
//putBridge(new PDFBatikFlowTextElementBridge(fontInfo);
putPDFElementBridgeConditional(
@@ -148,7 +148,7 @@ public class PDFBridgeContext extends BridgeContext {
putPDFElementBridgeConditional(
"org.apache.fop.svg.PDFSVG12TextElementBridge",
"org.apache.batik.bridge.svg12.SVG12TextElementBridge");
-
+
//putBridge(new PDFSVGFlowRootElementBridge(fontInfo));
putPDFElementBridgeConditional(
"org.apache.fop.svg.PDFSVGFlowRootElementBridge",
diff --git a/src/java/org/apache/fop/svg/PDFContext.java b/src/java/org/apache/fop/svg/PDFContext.java
index 494d47636..b7eec7b73 100644
--- a/src/java/org/apache/fop/svg/PDFContext.java
+++ b/src/java/org/apache/fop/svg/PDFContext.java
@@ -31,7 +31,7 @@ public class PDFContext {
/** number of pages generated */
private int pagecount;
-
+
/** @return true if a page is set up for painting. */
public boolean isPagePending() {
return this.currentPage != null;
diff --git a/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java b/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java
index 5bdfe8c8d..dd13df1c4 100644
--- a/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java
+++ b/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java b/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java
index cda1478bb..2d1c9279c 100644
--- a/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java
+++ b/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/svg/PDFFlowExtTextPainter.java b/src/java/org/apache/fop/svg/PDFFlowExtTextPainter.java
index 0e8f47cfe..1c85a2899 100644
--- a/src/java/org/apache/fop/svg/PDFFlowExtTextPainter.java
+++ b/src/java/org/apache/fop/svg/PDFFlowExtTextPainter.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -45,5 +45,5 @@ public class PDFFlowExtTextPainter extends PDFTextPainter {
FlowExtTextPainter delegate = (FlowExtTextPainter)FlowExtTextPainter.getInstance();
return delegate.getTextRuns(node, aci);
}
-
+
}
diff --git a/src/java/org/apache/fop/svg/PDFFlowTextPainter.java b/src/java/org/apache/fop/svg/PDFFlowTextPainter.java
index eeef40da1..5b307ce83 100644
--- a/src/java/org/apache/fop/svg/PDFFlowTextPainter.java
+++ b/src/java/org/apache/fop/svg/PDFFlowTextPainter.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -30,7 +30,7 @@ import org.apache.fop.fonts.FontInfo;
* Text Painter for SVG 1.2 (flow) text.
*/
public class PDFFlowTextPainter extends PDFTextPainter {
-
+
/**
* Main constructor
* @param fontInfo the font directory
@@ -45,5 +45,5 @@ public class PDFFlowTextPainter extends PDFTextPainter {
FlowTextPainter delegate = (FlowTextPainter)FlowTextPainter.getInstance();
return delegate.getTextRuns(node, aci);
}
-
+
}
diff --git a/src/java/org/apache/fop/svg/PDFGraphics2D.java b/src/java/org/apache/fop/svg/PDFGraphics2D.java
index 4d1ee6a6d..ca2245a12 100644
--- a/src/java/org/apache/fop/svg/PDFGraphics2D.java
+++ b/src/java/org/apache/fop/svg/PDFGraphics2D.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/svg/PDFGraphicsConfiguration.java b/src/java/org/apache/fop/svg/PDFGraphicsConfiguration.java
index 20c2c5c89..83a431d5e 100644
--- a/src/java/org/apache/fop/svg/PDFGraphicsConfiguration.java
+++ b/src/java/org/apache/fop/svg/PDFGraphicsConfiguration.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
*/
/* $Id$ */
-
+
package org.apache.fop.svg;
import java.awt.Rectangle;
diff --git a/src/java/org/apache/fop/svg/PDFGraphicsDevice.java b/src/java/org/apache/fop/svg/PDFGraphicsDevice.java
index 763bc7bb4..5da2d50ee 100644
--- a/src/java/org/apache/fop/svg/PDFGraphicsDevice.java
+++ b/src/java/org/apache/fop/svg/PDFGraphicsDevice.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
*/
/* $Id$ */
-
+
package org.apache.fop.svg;
import java.awt.GraphicsDevice;
diff --git a/src/java/org/apache/fop/svg/PDFImageElementBridge.java b/src/java/org/apache/fop/svg/PDFImageElementBridge.java
index 0513c78bb..7eb89d2b1 100644
--- a/src/java/org/apache/fop/svg/PDFImageElementBridge.java
+++ b/src/java/org/apache/fop/svg/PDFImageElementBridge.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
*/
/* $Id$ */
-
+
package org.apache.fop.svg;
import java.awt.Graphics2D;
@@ -72,13 +72,13 @@ public class PDFImageElementBridge extends SVGImageElementBridge {
protected GraphicsNode createImageGraphicsNode
(BridgeContext ctx, Element imageElement, ParsedURL purl) {
PDFBridgeContext pdfCtx = (PDFBridgeContext)ctx;
-
+
ImageManager manager = pdfCtx.getImageManager();
ImageSessionContext sessionContext = pdfCtx.getImageSessionContext();
try {
ImageInfo info = manager.getImageInfo(purl.toString(), sessionContext);
Image image = manager.getImage(info, supportedFlavors, sessionContext);
-
+
//TODO color profile overrides aren't handled, yet!
//ICCColorSpaceExt colorspaceOverride = extractColorSpace(e, ctx);
AbstractGraphicsNode specializedNode = null;
@@ -104,7 +104,7 @@ public class PDFImageElementBridge extends SVGImageElementBridge {
ctx.getUserAgent().displayError(
new ImageException("Cannot convert an image to a usable format: " + purl));
}
-
+
Rectangle2D imgBounds = getImageBounds(ctx, imageElement);
Rectangle2D bounds = specializedNode.getPrimitiveBounds();
float [] vb = new float[4];
@@ -113,14 +113,14 @@ public class PDFImageElementBridge extends SVGImageElementBridge {
vb[2] = (float) bounds.getWidth(); // width
vb[3] = (float) bounds.getHeight(); // height
- // handles the 'preserveAspectRatio', 'overflow' and 'clip'
+ // handles the 'preserveAspectRatio', 'overflow' and 'clip'
// and sets the appropriate AffineTransform to the image node
initializeViewport(ctx, imageElement, specializedNode, vb, imgBounds);
return specializedNode;
} catch (Exception e) {
ctx.getUserAgent().displayError(e);
}
-
+
return superCreateGraphicsNode(ctx, imageElement, purl);
}
@@ -144,13 +144,13 @@ public class PDFImageElementBridge extends SVGImageElementBridge {
* the PDFGraphics2D.
*/
public class LoaderImageNode extends AbstractGraphicsNode {
-
+
private Image image;
private BridgeContext ctx;
private Element imageElement;
private ParsedURL purl;
private GraphicsNode origGraphicsNode = null;
-
+
/**
* Create a new image node for drawing natively handled images
* into PDF graphics.
@@ -159,7 +159,7 @@ public class PDFImageElementBridge extends SVGImageElementBridge {
* @param imageElement the SVG image element
* @param purl the URL to the image
*/
- public LoaderImageNode(Image image, BridgeContext ctx,
+ public LoaderImageNode(Image image, BridgeContext ctx,
Element imageElement, ParsedURL purl) {
this.image = image;
this.ctx = ctx;
@@ -191,7 +191,7 @@ public class PDFImageElementBridge extends SVGImageElementBridge {
if (origGraphicsNode == null) {
// Haven't constructed baseclass Graphics Node,
// so do so now.
- origGraphicsNode
+ origGraphicsNode
= PDFImageElementBridge.this.superCreateGraphicsNode
(ctx, imageElement, purl);
}
@@ -223,9 +223,9 @@ public class PDFImageElementBridge extends SVGImageElementBridge {
* A node that holds a Graphics2D image.
*/
public class Graphics2DNode extends AbstractGraphicsNode {
-
+
private ImageGraphics2D image;
-
+
/**
* Create a new Graphics2D node.
* @param g2d the Graphics2D image
diff --git a/src/java/org/apache/fop/svg/PDFSVGFlowRootElementBridge.java b/src/java/org/apache/fop/svg/PDFSVGFlowRootElementBridge.java
index ec6996389..d313e6cc4 100644
--- a/src/java/org/apache/fop/svg/PDFSVGFlowRootElementBridge.java
+++ b/src/java/org/apache/fop/svg/PDFSVGFlowRootElementBridge.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -32,7 +32,7 @@ import org.apache.fop.fonts.FontInfo;
public class PDFSVGFlowRootElementBridge extends SVGFlowRootElementBridge {
private PDFTextPainter textPainter;
-
+
/**
* Main Constructor.
* @param fontInfo the font directory
@@ -40,7 +40,7 @@ public class PDFSVGFlowRootElementBridge extends SVGFlowRootElementBridge {
public PDFSVGFlowRootElementBridge(FontInfo fontInfo) {
this.textPainter = new PDFFlowTextPainter(fontInfo);
}
-
+
/** {@inheritDoc} */
protected GraphicsNode instantiateGraphicsNode() {
GraphicsNode node = super.instantiateGraphicsNode();
@@ -58,5 +58,5 @@ public class PDFSVGFlowRootElementBridge extends SVGFlowRootElementBridge {
public TextPainter getTextPainter() {
return this.textPainter;
}
-
+
}
diff --git a/src/java/org/apache/fop/svg/PDFTextElementBridge.java b/src/java/org/apache/fop/svg/PDFTextElementBridge.java
index 47e794dda..4c11aa97e 100644
--- a/src/java/org/apache/fop/svg/PDFTextElementBridge.java
+++ b/src/java/org/apache/fop/svg/PDFTextElementBridge.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -35,7 +35,7 @@ import org.w3c.dom.Element;
* @author Keiron Liddle
*/
public class PDFTextElementBridge extends SVGTextElementBridge {
-
+
private PDFTextPainter pdfTextPainter;
/**
diff --git a/src/java/org/apache/fop/svg/PDFTextPainter.java b/src/java/org/apache/fop/svg/PDFTextPainter.java
index 754b0794b..d8123c4fb 100644
--- a/src/java/org/apache/fop/svg/PDFTextPainter.java
+++ b/src/java/org/apache/fop/svg/PDFTextPainter.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -62,7 +62,7 @@ import org.apache.fop.util.CharUtilities;
public class PDFTextPainter extends StrokingTextPainter {
private static final boolean DEBUG = false;
-
+
private boolean strokeText = false;
private FontInfo fontInfo;
@@ -102,7 +102,7 @@ public class PDFTextPainter extends StrokingTextPainter {
if ((tpi != null) && (tpi.composite != null)) {
g2d.setComposite(tpi.composite);
}
-
+
//------------------------------------
TextSpanLayout layout = textRun.getLayout();
if (DEBUG) {
@@ -110,7 +110,7 @@ public class PDFTextPainter extends StrokingTextPainter {
System.out.println("================================================");
System.out.println("New text run:");
System.out.println("char count: " + charCount);
- System.out.println("range: "
+ System.out.println("range: "
+ runaci.getBeginIndex() + " - " + runaci.getEndIndex());
System.out.println("glyph count: " + layout.getGlyphCount()); //=getNumGlyphs()
}
@@ -125,26 +125,26 @@ public class PDFTextPainter extends StrokingTextPainter {
System.out.println("Text: " + chars);
pdf.currentStream.write("%Text: " + chars + "\n");
}
-
+
GeneralPath debugShapes = null;
if (DEBUG) {
debugShapes = new GeneralPath();
}
-
+
Font[] fonts = findFonts(runaci);
if (fonts == null || fonts.length == 0) {
//Draw using Java2D
textRun.getLayout().draw(g2d);
continue;
}
-
+
textUtil.saveGraphicsState();
textUtil.concatMatrix(g2d.getTransform());
Shape imclip = g2d.getClip();
pdf.writeClip(imclip);
-
+
applyColorAndPaint(tpi, pdf);
-
+
textUtil.beginTextObject();
textUtil.setFonts(fonts);
textUtil.setTextRenderingMode(tpi.fillPaint != null, tpi.strokePaint != null, false);
@@ -158,7 +158,7 @@ public class PDFTextPainter extends StrokingTextPainter {
boolean visibleChar = gv.isGlyphVisible(index)
|| (CharUtilities.isAnySpace(ch) && !CharUtilities.isZeroWidthSpace(ch));
if (DEBUG) {
- System.out.println("glyph " + index
+ System.out.println("glyph " + index
+ " -> " + layout.getGlyphIndex(index) + " => " + ch);
if (CharUtilities.isAnySpace(ch) && ch != 32) {
System.out.println("Space found: " + Integer.toHexString(ch));
@@ -198,9 +198,9 @@ public class PDFTextPainter extends StrokingTextPainter {
localTransform.concatenate(glyphTransform);
}
localTransform.scale(1, -1);
-
- boolean yPosChanged = (prevPos == null
- || prevPos.getY() != p.getY()
+
+ boolean yPosChanged = (prevPos == null
+ || prevPos.getY() != p.getY()
|| glyphTransform != null);
if (yPosChanged) {
if (index > 0) {
@@ -218,7 +218,7 @@ public class PDFTextPainter extends StrokingTextPainter {
textUtil.adjustGlyphTJ(adjust * 1000);
}
if (DEBUG) {
- System.out.println("==> x diff: " + xdiff + ", " + effxdiff
+ System.out.println("==> x diff: " + xdiff + ", " + effxdiff
+ ", charWidth: " + cw);
}
}
@@ -231,7 +231,7 @@ public class PDFTextPainter extends StrokingTextPainter {
}
char paintChar = (CharUtilities.isAnySpace(ch) ? ' ' : ch);
textUtil.writeTJChar(paintChar);
-
+
//Update last position
prevPos = p;
prevVisibleCharWidth = textUtil.getCurrentFont().getCharWidth(chars.charAt(index));
@@ -268,7 +268,7 @@ public class PDFTextPainter extends StrokingTextPainter {
}
pdf.applyAlpha(fillAlpha, PDFGraphics2D.OPAQUE);
}
-
+
private Font[] findFonts(AttributedCharacterIterator aci) {
List fonts = new java.util.ArrayList();
List gvtFonts = (List) aci.getAttribute(
@@ -343,5 +343,5 @@ public class PDFTextPainter extends StrokingTextPainter {
}
return (Font[])fonts.toArray(new Font[fonts.size()]);
}
-
+
}
\ No newline at end of file
diff --git a/src/java/org/apache/fop/svg/PDFTextUtil.java b/src/java/org/apache/fop/svg/PDFTextUtil.java
index f3c7f31a2..9ba7cd049 100644
--- a/src/java/org/apache/fop/svg/PDFTextUtil.java
+++ b/src/java/org/apache/fop/svg/PDFTextUtil.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -32,7 +32,7 @@ public abstract class PDFTextUtil extends org.apache.fop.pdf.PDFTextUtil {
private FontInfo fontInfo;
private Font[] fonts;
private Font font;
-
+
/**
* Main constructor.
* @param fontInfo the font catalog
@@ -41,13 +41,13 @@ public abstract class PDFTextUtil extends org.apache.fop.pdf.PDFTextUtil {
super();
this.fontInfo = fontInfo;
}
-
+
/** {@inheritDoc} */
protected void initValues() {
super.initValues();
this.font = null;
}
-
+
/**
* Sets the current fonts for the text object. For every character, the suitable font will
* be selected.
@@ -56,7 +56,7 @@ public abstract class PDFTextUtil extends org.apache.fop.pdf.PDFTextUtil {
public void setFonts(Font[] fonts) {
this.fonts = fonts;
}
-
+
/**
* Sets the current font for the text object.
* @param font the new font
@@ -64,7 +64,7 @@ public abstract class PDFTextUtil extends org.apache.fop.pdf.PDFTextUtil {
public void setFont(Font font) {
setFonts(new Font[] {font});
}
-
+
/**
* Returns the current font in use.
* @return the current font or null if no font is currently active.
@@ -72,7 +72,7 @@ public abstract class PDFTextUtil extends org.apache.fop.pdf.PDFTextUtil {
public Font getCurrentFont() {
return this.font;
}
-
+
/**
* Sets the current font.
* @param f the new font to use
@@ -80,7 +80,7 @@ public abstract class PDFTextUtil extends org.apache.fop.pdf.PDFTextUtil {
public void setCurrentFont(Font f) {
this.font = f;
}
-
+
/**
* Determines whether the font with the given name is a multi-byte font.
* @param name the name of the font
@@ -114,7 +114,7 @@ public abstract class PDFTextUtil extends org.apache.fop.pdf.PDFTextUtil {
}
return fonts[0]; //TODO Maybe fall back to painting with shapes
}
-
+
/**
* Writes a char to the "TJ-Buffer".
* @param ch the unmapped character
diff --git a/src/java/org/apache/fop/svg/PDFTranscoder.java b/src/java/org/apache/fop/svg/PDFTranscoder.java
index 281df1b1d..333cd5e4c 100644
--- a/src/java/org/apache/fop/svg/PDFTranscoder.java
+++ b/src/java/org/apache/fop/svg/PDFTranscoder.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -78,7 +78,7 @@ import org.apache.fop.fonts.FontInfo;
* KEY_USER_STYLESHEET_URI to fix the URI of a user
* stylesheet, and KEY_PIXEL_TO_MM to specify the pixel to
* millimeter conversion factor.
- *
+ *
*
KEY_AUTO_FONTS to disable the auto-detection of fonts installed in the system.
* The PDF Transcoder cannot use AWT's font subsystem and that's why the fonts have to be
* configured differently. By default, font auto-detection is enabled to match the behaviour
@@ -93,25 +93,25 @@ public class PDFTranscoder extends AbstractFOPTranscoder
/**
* The key is used to specify the resolution for on-the-fly images generated
- * due to complex effects like gradients and filters.
+ * due to complex effects like gradients and filters.
*/
public static final TranscodingHints.Key KEY_DEVICE_RESOLUTION = new FloatKey();
/**
* The key is used to specify whether the available fonts should be automatically
* detected. The alternative is to configure the transcoder manually using a configuration
- * file.
+ * file.
*/
public static final TranscodingHints.Key KEY_AUTO_FONTS = new BooleanKey();
private Configuration cfg = null;
-
+
/** Graphics2D instance that is used to paint to */
protected PDFDocumentGraphics2D graphics = null;
private ImageManager imageManager;
private ImageSessionContext imageSessionContext;
-
+
/**
* Constructs a new PDFTranscoder.
*/
@@ -132,7 +132,7 @@ public class PDFTranscoder extends AbstractFOPTranscoder
}
};
}
-
+
/** {@inheritDoc} */
public void configure(Configuration cfg) throws ConfigurationException {
this.cfg = cfg;
@@ -147,21 +147,21 @@ public class PDFTranscoder extends AbstractFOPTranscoder
* @exception TranscoderException if an error occured while transcoding
*/
protected void transcode(Document document, String uri,
- TranscoderOutput output)
+ TranscoderOutput output)
throws TranscoderException {
graphics = new PDFDocumentGraphics2D(isTextStroked());
- graphics.getPDFDocument().getInfo().setProducer("Apache FOP Version "
- + Version.getVersion()
+ graphics.getPDFDocument().getInfo().setProducer("Apache FOP Version "
+ + Version.getVersion()
+ ": PDF Transcoder for Batik");
if (hints.containsKey(KEY_DEVICE_RESOLUTION)) {
graphics.setDeviceDPI(((Float)hints.get(KEY_DEVICE_RESOLUTION)).floatValue());
}
-
+
setupImageInfrastructure(uri);
-
+
try {
- Configuration effCfg = this.cfg;
+ Configuration effCfg = this.cfg;
if (effCfg == null) {
//By default, enable font auto-detection if no cfg is given
boolean autoFonts = true;
@@ -177,7 +177,7 @@ public class PDFTranscoder extends AbstractFOPTranscoder
effCfg = c;
}
}
-
+
if (effCfg != null) {
PDFDocumentGraphics2DConfigurator configurator
= new PDFDocumentGraphics2DConfigurator();
@@ -195,14 +195,14 @@ public class PDFTranscoder extends AbstractFOPTranscoder
if (getLogger().isTraceEnabled()) {
getLogger().trace("document size: " + width + " x " + height);
}
-
+
// prepare the image to be painted
- UnitProcessor.Context uctx = UnitProcessor.createContext(ctx,
+ UnitProcessor.Context uctx = UnitProcessor.createContext(ctx,
document.getDocumentElement());
- float widthInPt = UnitProcessor.userSpaceToSVG(width, SVGLength.SVG_LENGTHTYPE_PT,
+ float widthInPt = UnitProcessor.userSpaceToSVG(width, SVGLength.SVG_LENGTHTYPE_PT,
UnitProcessor.HORIZONTAL_LENGTH, uctx);
int w = (int)(widthInPt + 0.5);
- float heightInPt = UnitProcessor.userSpaceToSVG(height, SVGLength.SVG_LENGTHTYPE_PT,
+ float heightInPt = UnitProcessor.userSpaceToSVG(height, SVGLength.SVG_LENGTHTYPE_PT,
UnitProcessor.HORIZONTAL_LENGTH, uctx);
int h = (int)(heightInPt + 0.5);
if (getLogger().isTraceEnabled()) {
@@ -271,7 +271,7 @@ public class PDFTranscoder extends AbstractFOPTranscoder
return null;
}
}
-
+
};
}
@@ -291,5 +291,5 @@ public class PDFTranscoder extends AbstractFOPTranscoder
this.imageManager, this.imageSessionContext);
return ctx;
}
-
+
}
diff --git a/src/java/org/apache/fop/svg/SVGEventProducer.java b/src/java/org/apache/fop/svg/SVGEventProducer.java
index 8894f3f58..27d7da215 100644
--- a/src/java/org/apache/fop/svg/SVGEventProducer.java
+++ b/src/java/org/apache/fop/svg/SVGEventProducer.java
@@ -31,7 +31,7 @@ public interface SVGEventProducer extends EventProducer {
* Provider class for the event producer.
*/
class Provider {
-
+
/**
* Returns an event producer.
* @param broadcaster the event broadcaster to use
@@ -51,7 +51,7 @@ public interface SVGEventProducer extends EventProducer {
* @event.severity ERROR
*/
void error(Object source, String message, Exception e);
-
+
/**
* Alert during SVG processing.
* @param source the event source
@@ -59,7 +59,7 @@ public interface SVGEventProducer extends EventProducer {
* @event.severity WARN
*/
void alert(Object source, String message);
-
+
/**
* Info during SVG processing.
* @param source the event source
@@ -67,7 +67,7 @@ public interface SVGEventProducer extends EventProducer {
* @event.severity INFO
*/
void info(Object source, String message);
-
+
/**
* SVG graphic could not be built due to an exception.
* @param source the event source
@@ -76,7 +76,7 @@ public interface SVGEventProducer extends EventProducer {
* @event.severity ERROR
*/
void svgNotBuilt(Object source, Exception e, String uri);
-
+
/**
* SVG graphic could not be rendered due to an exception.
* @param source the event source
@@ -85,5 +85,5 @@ public interface SVGEventProducer extends EventProducer {
* @event.severity ERROR
*/
void svgRenderingError(Object source, Exception e, String uri);
-
+
}
diff --git a/src/java/org/apache/fop/svg/SVGUserAgent.java b/src/java/org/apache/fop/svg/SVGUserAgent.java
index 8d7754fcb..65a581776 100644
--- a/src/java/org/apache/fop/svg/SVGUserAgent.java
+++ b/src/java/org/apache/fop/svg/SVGUserAgent.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
*/
/* $Id$ */
-
+
package org.apache.fop.svg;
import java.awt.geom.AffineTransform;
@@ -27,7 +27,7 @@ import org.apache.fop.apps.FOUserAgent;
* The SVG user agent. This is an implementation of the Batik SVG user agent.
*/
public class SVGUserAgent extends SimpleSVGUserAgent {
-
+
private SVGEventProducer eventProducer;
private Exception lastException;
@@ -48,7 +48,7 @@ public class SVGUserAgent extends SimpleSVGUserAgent {
public SVGUserAgent(FOUserAgent foUserAgent) {
this(foUserAgent, new AffineTransform());
}
-
+
/**
* Returns the last exception sent to the {@link #displayError(Exception)} method.
* @return the last exception or null if no exception occurred
diff --git a/src/java/org/apache/fop/svg/SVGUtilities.java b/src/java/org/apache/fop/svg/SVGUtilities.java
index 1ea11465b..cb07ab1f1 100644
--- a/src/java/org/apache/fop/svg/SVGUtilities.java
+++ b/src/java/org/apache/fop/svg/SVGUtilities.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/java/org/apache/fop/svg/SimpleSVGUserAgent.java b/src/java/org/apache/fop/svg/SimpleSVGUserAgent.java
index 4df1af34e..2b27945a4 100644
--- a/src/java/org/apache/fop/svg/SimpleSVGUserAgent.java
+++ b/src/java/org/apache/fop/svg/SimpleSVGUserAgent.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
*/
/* $Id$ */
-
+
package org.apache.fop.svg;
import java.awt.Dimension;
@@ -33,7 +33,7 @@ import org.apache.batik.bridge.UserAgentAdapter;
* by Batik.
*/
public class SimpleSVGUserAgent extends UserAgentAdapter {
-
+
private AffineTransform currentTransform = null;
private float pixelUnitToMillimeter = 0.0f;
@@ -46,7 +46,7 @@ public class SimpleSVGUserAgent extends UserAgentAdapter {
pixelUnitToMillimeter = pixelUnitToMM;
currentTransform = at;
}
-
+
/**
* Returns a customized the pixel to mm factor.
* @return the pixel unit to millimeter conversion factor
diff --git a/src/java/org/apache/fop/text/linebreak/LineBreakStatus.java b/src/java/org/apache/fop/text/linebreak/LineBreakStatus.java
index 94e018c75..15f3434d9 100644
--- a/src/java/org/apache/fop/text/linebreak/LineBreakStatus.java
+++ b/src/java/org/apache/fop/text/linebreak/LineBreakStatus.java
@@ -1,13 +1,13 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -48,8 +48,8 @@ public class LineBreakStatus {
public LineBreakStatus() {
reset();
}
-
-
+
+
/**
* Reset the status.
* This method will reset the status to the initial state. It is meant
@@ -63,44 +63,44 @@ public class LineBreakStatus {
/**
* Check whether a line break may happen according to the rules described in
* the Unicode Line Breaking Algorithm.
- * The function returns the line breaking status of the point before the given character.
- * The algorithm is the table-driven algorithm, as described in
+ * The function returns the line breaking status of the point before the given character.
+ * The algorithm is the table-driven algorithm, as described in
*
* Unicode Technical Report #14.
* The pair table is taken from {@link LineBreakUtils}.
- *
+ *
* TODO: Better handling for AI, SA, SG and XX line break classes.
- *
+ *
* @param c the character to check
* @return the break action to be taken
- * one of: {@link #DIRECT_BREAK},
- * {@link #INDIRECT_BREAK},
- * {@link #COMBINING_INDIRECT_BREAK},
+ * one of: {@link #DIRECT_BREAK},
+ * {@link #INDIRECT_BREAK},
+ * {@link #COMBINING_INDIRECT_BREAK},
* {@link #COMBINING_PROHIBITED_BREAK},
* {@link #PROHIBITED_BREAK},
* {@link #EXPLICIT_BREAK}
*/
public byte nextChar(char c) {
-
+
byte currentClass = LineBreakUtils.getLineBreakProperty(c);
-
+
/* Initial conversions */
switch (currentClass) {
case LineBreakUtils.LINE_BREAK_PROPERTY_AI:
case LineBreakUtils.LINE_BREAK_PROPERTY_SG:
case LineBreakUtils.LINE_BREAK_PROPERTY_XX:
- // LB 1: Resolve AI, ... SG and XX into other line breaking classes
+ // LB 1: Resolve AI, ... SG and XX into other line breaking classes
// depending on criteria outside the scope of this algorithm.
- // In the absence of such criteria, it is recommended that
+ // In the absence of such criteria, it is recommended that
// classes AI, ... SG and XX be resolved to AL
currentClass = LineBreakUtils.LINE_BREAK_PROPERTY_AL;
break;
-
+
case LineBreakUtils.LINE_BREAK_PROPERTY_SA:
- // LB 1: Resolve ... SA ... into other line breaking classes
+ // LB 1: Resolve ... SA ... into other line breaking classes
// depending on criteria outside the scope of this algorithm.
- // In the absence of such criteria, it is recommended that
- // ... SA be resolved to AL, except that characters of
+ // In the absence of such criteria, it is recommended that
+ // ... SA be resolved to AL, except that characters of
// class SA that have General_Category Mn or Mc be resolved to CM
switch (Character.getType(c)) {
case Character.COMBINING_SPACING_MARK: //General_Category "Mc"
@@ -110,11 +110,11 @@ public class LineBreakStatus {
default:
currentClass = LineBreakUtils.LINE_BREAK_PROPERTY_AL;
}
-
+
default:
//nop
}
-
+
/* Check 1: First character or initial character after a reset/mandatory break? */
switch (leftClass) {
case -1:
@@ -126,7 +126,7 @@ public class LineBreakStatus {
}
// LB 2: Never break at the start of text
return PROHIBITED_BREAK;
-
+
case LineBreakUtils.LINE_BREAK_PROPERTY_BK:
case LineBreakUtils.LINE_BREAK_PROPERTY_LF:
case LineBreakUtils.LINE_BREAK_PROPERTY_NL:
@@ -136,9 +136,9 @@ public class LineBreakStatus {
reset();
leftClass = currentClass;
return EXPLICIT_BREAK;
-
+
case LineBreakUtils.LINE_BREAK_PROPERTY_CR:
- //first character after a carriage return:
+ //first character after a carriage return:
// LB 5: Treat CR followed by LF, as well as CR ... as hard line breaks
// If current is LF, then fall through to Check 2 (see below),
// and the hard break will be signaled for the character after LF (see above)
@@ -147,11 +147,11 @@ public class LineBreakStatus {
leftClass = currentClass;
return EXPLICIT_BREAK;
}
-
+
default:
//nop
}
-
+
/* Check 2: current is a mandatory break or space? */
switch (currentClass) {
case LineBreakUtils.LINE_BREAK_PROPERTY_BK:
@@ -161,17 +161,17 @@ public class LineBreakStatus {
// LB 6: Do not break before a hard break
leftClass = currentClass;
return PROHIBITED_BREAK;
-
+
case LineBreakUtils.LINE_BREAK_PROPERTY_SP:
// LB 7: Do not break before spaces ...
// Zero-width spaces are in the pair-table (see below)
hadSpace = true;
return PROHIBITED_BREAK;
-
+
default:
//nop
}
-
+
/* Normal treatment, if the first two checks did not return */
boolean savedHadSpace = hadSpace;
hadSpace = false;
@@ -181,7 +181,7 @@ public class LineBreakStatus {
case DIRECT_BREAK:
leftClass = currentClass;
return breakAction;
-
+
case INDIRECT_BREAK:
leftClass = currentClass;
if (savedHadSpace) {
@@ -189,7 +189,7 @@ public class LineBreakStatus {
} else {
return PROHIBITED_BREAK;
}
-
+
case COMBINING_INDIRECT_BREAK:
if (savedHadSpace) {
leftClass = currentClass;
@@ -197,19 +197,19 @@ public class LineBreakStatus {
} else {
return PROHIBITED_BREAK;
}
-
+
case COMBINING_PROHIBITED_BREAK:
if (savedHadSpace) {
leftClass = currentClass;
}
return COMBINING_PROHIBITED_BREAK;
-
+
default:
assert false;
return breakAction;
}
}
-
+
/**
* for debugging only
*/
diff --git a/src/java/org/apache/fop/text/linebreak/LineBreakUtils.java b/src/java/org/apache/fop/text/linebreak/LineBreakUtils.java
index 5e84e1004..49557a6c9 100644
--- a/src/java/org/apache/fop/text/linebreak/LineBreakUtils.java
+++ b/src/java/org/apache/fop/text/linebreak/LineBreakUtils.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,10 +19,10 @@
package org.apache.fop.text.linebreak;
-/*
- * !!! THIS IS A GENERATED FILE !!!
+/*
+ * !!! THIS IS A GENERATED FILE !!!
* If updates to the source are needed, then:
- * - apply the necessary modifications to
+ * - apply the necessary modifications to
* 'src/codegen/unicode/java/org/apache/fop/text/linebreak/GenerateLineBreakUtils.java'
* - run 'ant codegen-unicode', which will generate a new LineBreakUtils.java
* in 'src/java/org/apache/fop/text/linebreak'
@@ -45,41 +45,41 @@ public final class LineBreakUtils {
public static final byte EXPLICIT_BREAK = 5;
private static final byte PAIR_TABLE[][] = {
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 1, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 1, 4, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 0, 4, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 0, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 1, 1, 1, 1, 0, 0, 4, 2, 0, 4, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 1, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 0, 4, 1, 0, 1, 1, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 1, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 1, 4, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 1, 1, 1, 1, 0, 0, 4, 2, 0, 4, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 0, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 1, 4, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 0, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 1, 4, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 0, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 0, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 1, 4, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 0, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 1, 4, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 1, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 0, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 1, 1, 1, 0, 1, 4, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 0, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 1, 4, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 0, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 1, 4, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 1, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 1, 4, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 4, 4, 4, 4, 0, 0, 4, 3, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 4, 4, 4, 4, 4, 4, 0, 0, 0, 4, 4, 0, 4},
- {0, 1, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 1, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 1, 1, 1, 1, 0, 4, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 1, 1, 1, 1, 0, 0, 4, 2, 0, 4, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 0, 0, 1, 1, 4, 1, 1, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 1, 1, 1, 1, 0, 0, 4, 2, 0, 4, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 1, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 1, 4, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 0, 4, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 0, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 1, 1, 1, 1, 0, 0, 4, 2, 0, 4, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 1, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 0, 4, 1, 0, 1, 1, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 1, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 1, 4, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 1, 1, 1, 1, 0, 0, 4, 2, 0, 4, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 0, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 1, 4, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 0, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 1, 4, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 0, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 0, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 1, 4, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 0, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 1, 4, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 1, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 0, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 1, 1, 1, 0, 1, 4, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 0, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 1, 4, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 0, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 1, 4, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 1, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 1, 4, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 4, 4, 4, 4, 0, 0, 4, 3, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 4, 4, 4, 4, 4, 4, 0, 0, 0, 4, 4, 0, 4},
+ {0, 1, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 1, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 1, 1, 1, 1, 0, 4, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 1, 1, 1, 1, 0, 0, 4, 2, 0, 4, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 0, 0, 1, 1, 4, 1, 1, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 1, 1, 1, 1, 0, 0, 4, 2, 0, 4, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4}};
private static byte lineBreakProperties[][] = new byte[512][];
@@ -680,8 +680,8 @@ public final class LineBreakUtils {
/** Linebreak property constant */
public static final byte LINE_BREAK_PROPERTY_ZW = 36;
- private static String lineBreakPropertyShortNames[] = {"AI", "AL", "B2", "BA", "BB", "BK", "CB", "CL", "CM", "CR", "EX",
- "GL", "H2", "H3", "HY", "ID", "IN", "IS", "JL", "JT", "JV", "LF", "NL", "NS", "NU", "OP", "PO", "PR", "QU", "SA", "SG", "SP",
+ private static String lineBreakPropertyShortNames[] = {"AI", "AL", "B2", "BA", "BB", "BK", "CB", "CL", "CM", "CR", "EX",
+ "GL", "H2", "H3", "HY", "ID", "IN", "IS", "JL", "JT", "JV", "LF", "NL", "NS", "NU", "OP", "PO", "PR", "QU", "SA", "SG", "SP",
"SY", "WJ", "XX", "ZW"};
private static String lineBreakPropertyLongNames[] = {"Ambiguous","Alphabetic","Break_Both","Break_After","Break_Before",
@@ -691,7 +691,7 @@ public final class LineBreakUtils {
"Surrogate","Space","Break_Symbols","Word_Joiner","Unknown","ZWSpace"};
/**
- * Return the short name for the linebreak property corresponding
+ * Return the short name for the linebreak property corresponding
* to the given symbolic constant.
*
* @param i the numeric value of the linebreak property
@@ -706,7 +706,7 @@ public final class LineBreakUtils {
}
/**
- * Return the long name for the linebreak property corresponding
+ * Return the long name for the linebreak property corresponding
* to the given symbolic constant.
*
* @param i the numeric value of the linebreak property
@@ -731,7 +731,7 @@ public final class LineBreakUtils {
}
/**
- * Return the break class constant for the given pair of linebreak
+ * Return the break class constant for the given pair of linebreak
* property constants.
*
* @param lineBreakPropertyBefore the linebreak property for the first character
diff --git a/src/java/org/apache/fop/tools/TestConverter.java b/src/java/org/apache/fop/tools/TestConverter.java
index 5cbd3c095..0c6e09bd0 100644
--- a/src/java/org/apache/fop/tools/TestConverter.java
+++ b/src/java/org/apache/fop/tools/TestConverter.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
*/
/* $Id$ */
-
+
package org.apache.fop.tools;
import java.io.File;
@@ -48,10 +48,10 @@ import org.apache.commons.logging.impl.SimpleLog;
* pdf rendering.
*/
public class TestConverter {
-
+
// configure fopFactory as desired
private FopFactory fopFactory = FopFactory.newInstance();
-
+
private boolean failOnly = false;
private String outputFormat = MimeConstants.MIME_FOP_AREA_TREE;
private File destdir;
@@ -126,7 +126,7 @@ public class TestConverter {
}
/**
- * Controls whether to process only the tests which are specified as fail
+ * Controls whether to process only the tests which are specified as fail
* in the test results.
* @param fail True if only fail tests should be processed
*/
@@ -262,7 +262,7 @@ public class TestConverter {
if (xslNode != null) {
xsl = xslNode.getNodeValue();
}
- logger.debug("converting xml:" + xml + " and xsl:"
+ logger.debug("converting xml:" + xml + " and xsl:"
+ xsl + " to area tree");
String res = xml;
@@ -299,7 +299,7 @@ public class TestConverter {
if (outname.endsWith(".xml") || outname.endsWith(".pdf")) {
outname = outname.substring(0, outname.length() - 4);
}
- File outputFile = new File(destdir,
+ File outputFile = new File(destdir,
outname + makeResultExtension());
outputFile.getParentFile().mkdirs();
diff --git a/src/java/org/apache/fop/tools/anttasks/FileCompare.java b/src/java/org/apache/fop/tools/anttasks/FileCompare.java
index 5deaa7da2..d9b64226a 100644
--- a/src/java/org/apache/fop/tools/anttasks/FileCompare.java
+++ b/src/java/org/apache/fop/tools/anttasks/FileCompare.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
*/
/* $Id$ */
-
+
package org.apache.fop.tools.anttasks;
import java.util.Date;
@@ -37,7 +37,7 @@ import java.text.DateFormat;
*/
public class FileCompare {
-
+
private String referenceDirectory, testDirectory;
private String[] filenameList;
private String filenames;
diff --git a/src/java/org/apache/fop/tools/anttasks/RunTest.java b/src/java/org/apache/fop/tools/anttasks/RunTest.java
index 2bc13e8b2..1e1a959ed 100644
--- a/src/java/org/apache/fop/tools/anttasks/RunTest.java
+++ b/src/java/org/apache/fop/tools/anttasks/RunTest.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
*/
/* $Id$ */
-
+
package org.apache.fop.tools.anttasks;
// Ant
@@ -42,7 +42,7 @@ import java.util.Map;
* to run the tests and check the results.
*/
public class RunTest extends Task {
-
+
private String basedir;
private String testsuite = "";
private String referenceJar = "";
@@ -218,7 +218,7 @@ public class RunTest extends Task {
}
/**
- * Return a list of URL's with the specified URL first and followed
+ * Return a list of URL's with the specified URL first and followed
* by all the jar files from lib/.
* @return a list of urls to the runtime jar files.
*/
diff --git a/src/java/org/apache/fop/tools/anttasks/SerializeHyphPattern.java b/src/java/org/apache/fop/tools/anttasks/SerializeHyphPattern.java
index 0aefb8422..778c39f9a 100644
--- a/src/java/org/apache/fop/tools/anttasks/SerializeHyphPattern.java
+++ b/src/java/org/apache/fop/tools/anttasks/SerializeHyphPattern.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
*/
/* $Id$ */
-
+
package org.apache.fop.tools.anttasks;
// Java
diff --git a/src/java/org/apache/fop/traits/BlockProps.java b/src/java/org/apache/fop/traits/BlockProps.java
index 27417d897..370a97982 100644
--- a/src/java/org/apache/fop/traits/BlockProps.java
+++ b/src/java/org/apache/fop/traits/BlockProps.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
*/
/* $Id$ */
-
+
package org.apache.fop.traits;
import org.apache.fop.datatypes.Length;
@@ -26,7 +26,7 @@ import org.apache.fop.datatypes.Length;
* Public "structure" allows direct member access.
*/
public class BlockProps {
-
+
public Length firstIndent; // text-indent
public int lastIndent; // last-line-indent
public int textAlign;
diff --git a/src/java/org/apache/fop/traits/BorderProps.java b/src/java/org/apache/fop/traits/BorderProps.java
index d00bdb09d..20e362674 100644
--- a/src/java/org/apache/fop/traits/BorderProps.java
+++ b/src/java/org/apache/fop/traits/BorderProps.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
*/
/* $Id$ */
-
+
package org.apache.fop.traits;
import java.awt.Color;
@@ -33,14 +33,14 @@ import org.apache.fop.util.ColorUtil;
* Class to store border trait propties for the area tree.
*/
public class BorderProps implements Serializable {
-
+
/** Separate border model */
public static final int SEPARATE = 0;
/** Collapsing border model, for borders inside a table */
public static final int COLLAPSE_INNER = 1;
/** Collapsing border model, for borders at the table's outer border */
public static final int COLLAPSE_OUTER = 2;
-
+
/** Border style (one of EN_*) */
public int style; // Enum for border style
/** Border color */
@@ -86,7 +86,7 @@ public class BorderProps implements Serializable {
return 0;
}
}
-
+
private String getStyleString() {
switch (style) {
case Constants.EN_NONE: return "none";
@@ -102,7 +102,7 @@ public class BorderProps implements Serializable {
default: throw new IllegalStateException("Illegal border style: " + style);
}
}
-
+
private static int getConstantForStyle(String style) {
if ("none".equalsIgnoreCase(style)) {
return Constants.EN_NONE;
@@ -128,7 +128,7 @@ public class BorderProps implements Serializable {
throw new IllegalStateException("Illegal border style: " + style);
}
}
-
+
/** {@inheritDoc} */
public int hashCode() {
return toString().hashCode();
@@ -144,7 +144,7 @@ public class BorderProps implements Serializable {
if (obj instanceof BorderProps) {
BorderProps other = (BorderProps)obj;
return (style == other.style)
- && color.equals(other.color)
+ && color.equals(other.color)
&& width == other.width
&& mode == other.mode;
}
@@ -153,7 +153,7 @@ public class BorderProps implements Serializable {
}
/**
- * Returns a BorderProps represtation of a string of the format as written by
+ * Returns a BorderProps represtation of a string of the format as written by
* BorderProps.toString().
* @param foUserAgent FOP user agent caching ICC profiles
* @param s the string
@@ -180,8 +180,8 @@ public class BorderProps implements Serializable {
c = ColorUtil.parseColorString(foUserAgent, color);
} catch (PropertyException e) {
throw new IllegalArgumentException(e.getMessage());
- }
-
+ }
+
return new BorderProps(style, width, c, mode);
} else {
throw new IllegalArgumentException("BorderProps must be surrounded by parentheses");
diff --git a/src/java/org/apache/fop/traits/InlineProps.java b/src/java/org/apache/fop/traits/InlineProps.java
index 735ebc0ca..06ca2553d 100644
--- a/src/java/org/apache/fop/traits/InlineProps.java
+++ b/src/java/org/apache/fop/traits/InlineProps.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
*/
/* $Id$ */
-
+
package org.apache.fop.traits;
/**
diff --git a/src/java/org/apache/fop/traits/LayoutProps.java b/src/java/org/apache/fop/traits/LayoutProps.java
index f93470720..eff218b37 100644
--- a/src/java/org/apache/fop/traits/LayoutProps.java
+++ b/src/java/org/apache/fop/traits/LayoutProps.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
*/
/* $Id$ */
-
+
package org.apache.fop.traits;
import org.apache.fop.datatypes.KeepValue;
diff --git a/src/java/org/apache/fop/traits/MinOptMax.java b/src/java/org/apache/fop/traits/MinOptMax.java
index 33d10a8a5..a4719f896 100644
--- a/src/java/org/apache/fop/traits/MinOptMax.java
+++ b/src/java/org/apache/fop/traits/MinOptMax.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
*/
/* $Id$ */
-
+
package org.apache.fop.traits;
/**
@@ -163,7 +163,7 @@ public class MinOptMax implements java.io.Serializable, Cloneable {
opt -= op.opt;
max -= op.min;
}
-
+
/** @return true if this instance represents a zero-width length (min=opt=max=0) */
public boolean isNonZero() {
return (min != 0 || max != 0);
@@ -173,7 +173,7 @@ public class MinOptMax implements java.io.Serializable, Cloneable {
public boolean isElastic() {
return (min != opt || opt != max);
}
-
+
/** {@inheritDoc} */
public String toString() {
StringBuffer sb = new StringBuffer();
diff --git a/src/java/org/apache/fop/traits/SpaceVal.java b/src/java/org/apache/fop/traits/SpaceVal.java
index 0dae92193..e2ac6fb1c 100644
--- a/src/java/org/apache/fop/traits/SpaceVal.java
+++ b/src/java/org/apache/fop/traits/SpaceVal.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
*/
/* $Id$ */
-
+
package org.apache.fop.traits;
import org.apache.fop.datatypes.PercentBaseContext;
@@ -30,7 +30,7 @@ import org.apache.fop.fonts.Font;
* Length values resolved. See section 4.3 in the specs.
*/
public class SpaceVal {
-
+
private final MinOptMax space;
private final boolean bConditional;
private final boolean bForcing;
@@ -45,7 +45,7 @@ public class SpaceVal {
space = new MinOptMax(spaceprop.getMinimum(context).getLength().getValue(context),
spaceprop.getOptimum(context).getLength().getValue(context),
spaceprop.getMaximum(context).getLength().getValue(context));
- bConditional =
+ bConditional =
(spaceprop.getConditionality().getEnum() == Constants.EN_DISCARD);
Property precProp = spaceprop.getPrecedence();
if (precProp.getNumber() != null) {
@@ -72,8 +72,8 @@ public class SpaceVal {
this.iPrecedence = iPrecedence;
}
- static public SpaceVal makeWordSpacing(Property wordSpacing,
- SpaceVal letterSpacing,
+ static public SpaceVal makeWordSpacing(Property wordSpacing,
+ SpaceVal letterSpacing,
Font fs) {
if (wordSpacing.getEnum() == Constants.EN_NORMAL) {
// give word spaces the possibility to shrink by a third,
@@ -87,7 +87,7 @@ public class SpaceVal {
true, true, 0);
} else {
return new SpaceVal(wordSpacing.getSpace(), null);
- }
+ }
}
static public SpaceVal makeLetterSpacing(Property letterSpacing) {
diff --git a/src/java/org/apache/fop/util/BreakUtil.java b/src/java/org/apache/fop/util/BreakUtil.java
index c0528464d..0e419016e 100644
--- a/src/java/org/apache/fop/util/BreakUtil.java
+++ b/src/java/org/apache/fop/util/BreakUtil.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -44,7 +44,7 @@ public final class BreakUtil {
* Compares the given break classes and return the one that wins. even-page and
* odd-page win over page, which wins over column, which wins over auto. If even-page
* and odd-page are compared to each other, which one will be returned is undefined.
- *
+ *
* @param break1 a break class, one of {@link Constants#EN_AUTO},
* {@link Constants#EN_COLUMN}, {@link Constants#EN_PAGE},
* {@link Constants#EN_EVEN_PAGE}, {@link Constants#EN_ODD_PAGE}
diff --git a/src/java/org/apache/fop/util/CMYKColorSpace.java b/src/java/org/apache/fop/util/CMYKColorSpace.java
index 26de8aa97..593c65cea 100644
--- a/src/java/org/apache/fop/util/CMYKColorSpace.java
+++ b/src/java/org/apache/fop/util/CMYKColorSpace.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
*/
/* $Id$ */
-
+
package org.apache.fop.util;
import java.awt.color.ColorSpace;
diff --git a/src/java/org/apache/fop/util/CharUtilities.java b/src/java/org/apache/fop/util/CharUtilities.java
index eb56cd331..7786552ff 100644
--- a/src/java/org/apache/fop/util/CharUtilities.java
+++ b/src/java/org/apache/fop/util/CharUtilities.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -89,7 +89,7 @@ public class CharUtilities {
/** Unicode value indicating the the character is "not a character". */
public static final char NOT_A_CHARACTER = '\uFFFF';
-
+
/**
* Utility class: Constructor prevents instantiating when subclassed.
*/
@@ -147,7 +147,7 @@ public class CharUtilities {
* @return true if the character has a fixed-width
*/
public static boolean isFixedWidthSpace(char c) {
- return (c >= '\u2000' && c <= '\u200B')
+ return (c >= '\u2000' && c <= '\u200B')
|| c == '\u3000';
// c == '\u2000' // en quad
// c == '\u2001' // em quad
@@ -191,7 +191,7 @@ public class CharUtilities {
(c == '\u0020' // normal space
|| c == NBSPACE); // no-break space
}
-
+
/**
* Determines if the character represents any kind of space.
* @param c character to check
@@ -200,7 +200,7 @@ public class CharUtilities {
public static boolean isAnySpace(char c) {
return (isBreakableSpace(c) || isNonBreakableSpace(c));
}
-
+
/**
* Indicates whether a character is classified as "Alphabetic" by the Unicode standard.
* @param ch the character
diff --git a/src/java/org/apache/fop/util/CloseBlockerOutputStream.java b/src/java/org/apache/fop/util/CloseBlockerOutputStream.java
index c0db8c8b7..eae1cc09d 100644
--- a/src/java/org/apache/fop/util/CloseBlockerOutputStream.java
+++ b/src/java/org/apache/fop/util/CloseBlockerOutputStream.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
*/
/* $Id$ */
-
+
package org.apache.fop.util;
import java.io.IOException;
diff --git a/src/java/org/apache/fop/util/ColorExt.java b/src/java/org/apache/fop/util/ColorExt.java
index bd2c95a33..d2e73d227 100644
--- a/src/java/org/apache/fop/util/ColorExt.java
+++ b/src/java/org/apache/fop/util/ColorExt.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -36,11 +36,11 @@ public final class ColorExt extends Color {
private float rgbReplacementRed;
private float rgbReplacementGreen;
private float rgbReplacementBlue;
-
+
private String iccProfileName;
private String iccProfileSrc;
private ColorSpace colorSpace;
-
+
private float[] colorValues;
/*
@@ -59,7 +59,7 @@ public final class ColorExt extends Color {
/**
* Create ColorExt object backup up FO's rgb-icc color function
- *
+ *
* @param redReplacement
* Red part of RGB replacement color that will be used when ICC
* profile can not be loaded
@@ -95,7 +95,7 @@ public final class ColorExt extends Color {
/**
* Create ColorExt object backing up SVG's icc-color function.
- *
+ *
* @param red
* Red value resulting from the conversion from the user provided
* (icc) color values to the batik (rgb) color space
@@ -134,7 +134,7 @@ public final class ColorExt extends Color {
/**
* Get ICC profile name
- *
+ *
* @return ICC profile name
*/
public String getIccProfileName() {
@@ -143,7 +143,7 @@ public final class ColorExt extends Color {
/**
* Get ICC profile source
- *
+ *
* @return ICC profile source
*/
public String getIccProfileSrc() {
diff --git a/src/java/org/apache/fop/util/ColorProfileUtil.java b/src/java/org/apache/fop/util/ColorProfileUtil.java
index 6a849a031..f234dde66 100644
--- a/src/java/org/apache/fop/util/ColorProfileUtil.java
+++ b/src/java/org/apache/fop/util/ColorProfileUtil.java
@@ -49,7 +49,7 @@ public class ColorProfileUtil {
}
}
}
-
+
/**
* Indicates whether a given color profile is identical to the default sRGB profile
* provided by the Java class library.
@@ -64,5 +64,5 @@ public class ColorProfileUtil {
}
return profile == sRGBProfile;
}
-
+
}
diff --git a/src/java/org/apache/fop/util/ColorSpaceCache.java b/src/java/org/apache/fop/util/ColorSpaceCache.java
index 92dcf8d55..7b3f409e0 100644
--- a/src/java/org/apache/fop/util/ColorSpaceCache.java
+++ b/src/java/org/apache/fop/util/ColorSpaceCache.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -49,19 +49,19 @@ public class ColorSpaceCache {
public ColorSpaceCache(URIResolver resolver) {
this.resolver = resolver;
}
-
+
/**
* Create (if needed) and return an ICC ColorSpace instance.
- *
+ *
* The ICC profile source is taken from the src attribute of the color-profile FO element.
* If the ICC ColorSpace is not yet in the cache a new one is created and stored in the cache.
- *
- * The FOP URI resolver is used to try and locate the ICC file.
+ *
+ * The FOP URI resolver is used to try and locate the ICC file.
* If that fails null is returned.
- *
+ *
* @param base a base URI to resolve relative URIs
* @param iccProfileSrc ICC Profile source to return a ColorSpace for
- * @return ICC ColorSpace object or null if ColorSpace could not be created
+ * @return ICC ColorSpace object or null if ColorSpace could not be created
*/
public ColorSpace get(String base, String iccProfileSrc) {
ColorSpace colorSpace = null;
@@ -80,7 +80,7 @@ public class ColorSpaceCache {
// TODO - Would it make sense to fall back on VM ICC
// resolution
// Problem is the cache might be more difficult to maintain
- //
+ //
// FOP URI resolver did not find ICC profile - perhaps the
// Java VM can find it?
// iccProfile = ICC_Profile.getInstance(iccProfileSrc);
@@ -106,5 +106,5 @@ public class ColorSpaceCache {
+ iccProfileSrc);
}
return colorSpace;
- }
+ }
}
diff --git a/src/java/org/apache/fop/util/ColorUtil.java b/src/java/org/apache/fop/util/ColorUtil.java
index fbfc68c36..b85b0c017 100644
--- a/src/java/org/apache/fop/util/ColorUtil.java
+++ b/src/java/org/apache/fop/util/ColorUtil.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -39,21 +39,21 @@ import org.apache.fop.fo.expr.PropertyException;
public final class ColorUtil {
/**
- *
+ *
* keeps all the predefined and parsed colors.
*
* This map is used to predefine given colors, as well as speeding up
* parsing of already parsed colors.
*/
private static Map colorMap = null;
-
+
/** Logger instance */
protected static Log log = LogFactory.getLog(ColorUtil.class);
-
+
static {
initializeColorMap();
}
-
+
/**
* Private constructor since this is an utility class.
*/
@@ -77,8 +77,8 @@ public final class ColorUtil {
*
*
- *
- * @param foUserAgent FOUserAgent object
+ *
+ * @param foUserAgent FOUserAgent object
* @param value
* the string to parse.
* @return a Color representing the string if possible
@@ -86,7 +86,7 @@ public final class ColorUtil {
* if the string is not parsable or does not follow any of the
* given formats.
*/
- public static Color parseColorString(FOUserAgent foUserAgent, String value)
+ public static Color parseColorString(FOUserAgent foUserAgent, String value)
throws PropertyException {
if (value == null) {
return null;
@@ -111,11 +111,11 @@ public final class ColorUtil {
} else if (value.startsWith("cmyk")) {
parsedColor = parseAsCMYK(value);
}
-
+
if (parsedColor == null) {
throw new PropertyException("Unknown Color: " + value);
}
-
+
colorMap.put(value, parsedColor);
}
@@ -127,7 +127,7 @@ public final class ColorUtil {
/**
* Tries to parse a color given with the system-color() function.
- *
+ *
* @param value
* the complete line
* @return a color if possible
@@ -149,7 +149,7 @@ public final class ColorUtil {
/**
* Tries to parse the standard java.awt.Color toString output.
- *
+ *
* @param value
* the complete line
* @return a color if possible
@@ -170,11 +170,11 @@ public final class ColorUtil {
throw new PropertyException(
"Invalid number of arguments for a java.awt.Color: " + value);
}
-
+
red = Float.parseFloat(args[0].trim().substring(2)) / 255f;
green = Float.parseFloat(args[1].trim().substring(2)) / 255f;
blue = Float.parseFloat(args[2].trim().substring(2)) / 255f;
- if ((red < 0.0 || red > 1.0)
+ if ((red < 0.0 || red > 1.0)
|| (green < 0.0 || green > 1.0)
|| (blue < 0.0 || blue > 1.0)) {
throw new PropertyException("Color values out of range");
@@ -193,7 +193,7 @@ public final class ColorUtil {
/**
* Parse a color given with the rgb() function.
- *
+ *
* @param value
* the complete line
* @return a color if possible
@@ -234,7 +234,7 @@ public final class ColorUtil {
} else {
blue = Float.parseFloat(str) / 255f;
}
- if ((red < 0.0 || red > 1.0)
+ if ((red < 0.0 || red > 1.0)
|| (green < 0.0 || green > 1.0)
|| (blue < 0.0 || blue > 1.0)) {
throw new PropertyException("Color values out of range");
@@ -256,7 +256,7 @@ public final class ColorUtil {
/**
* parse a color given in the #.... format.
- *
+ *
* @param value
* the complete line
* @return a color if possible
@@ -297,19 +297,19 @@ public final class ColorUtil {
/**
* Parse a color specified using the fop-rgb-icc() function.
- *
+ *
* @param value the function call
* @return a color if possible
* @throws PropertyException if the format is wrong.
*/
- private static Color parseAsFopRgbIcc(FOUserAgent foUserAgent, String value)
+ private static Color parseAsFopRgbIcc(FOUserAgent foUserAgent, String value)
throws PropertyException {
Color parsedColor;
int poss = value.indexOf("(");
int pose = value.indexOf(")");
if (poss != -1 && pose != -1) {
String[] args = value.substring(poss + 1, pose).split(",");
-
+
try {
if (args.length < 5) {
throw new PropertyException("Too few arguments for rgb-icc() function");
@@ -339,27 +339,27 @@ public final class ColorUtil {
ColorSpace colorSpace = (foUserAgent != null
? foUserAgent.getFactory().getColorSpace(
foUserAgent.getBaseURL(), iccProfileSrc) : null);
-
+
float red = 0, green = 0, blue = 0;
red = Float.parseFloat(args[0].trim());
green = Float.parseFloat(args[1].trim());
blue = Float.parseFloat(args[2].trim());
/* Verify rgb replacement arguments */
- if ((red < 0 || red > 1)
- || (green < 0 || green > 1)
+ if ((red < 0 || red > 1)
+ || (green < 0 || green > 1)
|| (blue < 0 || blue > 1)) {
throw new PropertyException("Color values out of range. "
+ "Fallback RGB arguments to fop-rgb-icc() must be [0..1]");
}
if (colorSpace != null) {
- // ColorSpace available - create ColorExt (keeps track of replacement rgb
+ // ColorSpace available - create ColorExt (keeps track of replacement rgb
// values for possible later colorTOsRGBString call
- parsedColor = ColorExt.createFromFoRgbIcc(red, green, blue,
+ parsedColor = ColorExt.createFromFoRgbIcc(red, green, blue,
iccProfileName, iccProfileSrc, colorSpace, iccComponents);
} else {
// ICC profile could not be loaded - use rgb replacement values */
- log.warn("Color profile '" + iccProfileSrc
+ log.warn("Color profile '" + iccProfileSrc
+ "' not found. Using rgb replacement values.");
parsedColor = new Color(Math.round(red * 255),
Math.round(green * 255), Math.round(blue * 255));
@@ -380,7 +380,7 @@ public final class ColorUtil {
/**
* Parse a color given with the cmyk() function.
- *
+ *
* @param value
* the complete line
* @return a color if possible
@@ -428,8 +428,8 @@ public final class ColorUtil {
} else {
black = Float.parseFloat(str);
}
-
- if ((cyan < 0.0 || cyan > 1.0)
+
+ if ((cyan < 0.0 || cyan > 1.0)
|| (magenta < 0.0 || magenta > 1.0)
|| (yellow < 0.0 || yellow > 1.0)
|| (black < 0.0 || black > 1.0)) {
@@ -439,7 +439,7 @@ public final class ColorUtil {
float[] cmyk = new float[] {cyan, magenta, yellow, black};
CMYKColorSpace cmykCs = CMYKColorSpace.getInstance();
float[] rgb = cmykCs.toRGB(cmyk);
- parsedColor = ColorExt.createFromFoRgbIcc(rgb[0], rgb[1], rgb[2],
+ parsedColor = ColorExt.createFromFoRgbIcc(rgb[0], rgb[1], rgb[2],
null, "#CMYK", cmykCs, cmyk);
} catch (PropertyException pe) {
throw pe;
@@ -452,13 +452,13 @@ public final class ColorUtil {
}
return parsedColor;
}
-
+
/**
* Creates a re-parsable string representation of the given color.
*
* First, the color will be converted into the sRGB colorspace. It will then
* be printed as #rrggbb, or as #rrrggbbaa if an alpha value is present.
- *
+ *
* @param color
* the color to represent.
* @return a re-parsable string representadion.
diff --git a/src/java/org/apache/fop/util/CommandLineLogger.java b/src/java/org/apache/fop/util/CommandLineLogger.java
index beb82ab03..0da112e5c 100644
--- a/src/java/org/apache/fop/util/CommandLineLogger.java
+++ b/src/java/org/apache/fop/util/CommandLineLogger.java
@@ -4,9 +4,9 @@
/* The ASF licenses this file to You under the Apache License, Version 2.0
/* (the "License"); you may not use this file except in compliance with
/* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -40,17 +40,17 @@ public class CommandLineLogger implements Log {
private int logLevel;
private String logName;
-
+
/**
- * Construct the logger with a default log level taken from the LogFactory
- * attribute "level".
+ * Construct the logger with a default log level taken from the LogFactory
+ * attribute "level".
* @param logName the logger name.
*/
public CommandLineLogger(String logName) {
this.logName = logName;
setLogLevel((String) LogFactory.getFactory().getAttribute("level"));
}
-
+
/**
* Set a log level for the logger.
* @param level the log level
@@ -72,7 +72,7 @@ public class CommandLineLogger implements Log {
logLevel = LOG_LEVEL_INFO;
}
}
-
+
/**
* {@inheritDoc}
*/
@@ -93,7 +93,7 @@ public class CommandLineLogger implements Log {
public final boolean isInfoEnabled() {
return logLevel <= LOG_LEVEL_INFO;
}
-
+
/**
* {@inheritDoc}
*/
@@ -114,7 +114,7 @@ public class CommandLineLogger implements Log {
public final boolean isFatalEnabled() {
return logLevel <= LOG_LEVEL_FATAL;
}
-
+
/**
* {@inheritDoc}
*/
@@ -222,7 +222,7 @@ public class CommandLineLogger implements Log {
log(LOG_LEVEL_FATAL, message, t);
}
}
-
+
/**
* Do the actual logging.
* This method assembles the message and prints it to
diff --git a/src/java/org/apache/fop/util/ContentHandlerFactory.java b/src/java/org/apache/fop/util/ContentHandlerFactory.java
index 30ab2374a..7eca0bf95 100644
--- a/src/java/org/apache/fop/util/ContentHandlerFactory.java
+++ b/src/java/org/apache/fop/util/ContentHandlerFactory.java
@@ -34,43 +34,43 @@ public interface ContentHandlerFactory {
* @return an array of supported namespaces.
*/
String[] getSupportedNamespaces();
-
+
/**
* @return a new ContentHandler to handle a SAX stream
* @throws SAXException if there's an error while preparing the ContentHandler
*/
ContentHandler createContentHandler() throws SAXException;
-
+
/**
* Interface that ContentHandler implementations that parse Java objects from XML can implement
* to return these objects.
*/
public interface ObjectSource {
-
+
/**
* @return the object parsed from the SAX stream (call valid after parsing)
*/
Object getObject();
-
+
/**
* Set a listener which gets notified when the object is fully built.
* @param listener the listener which gets notified
*/
void setObjectBuiltListener(ObjectBuiltListener listener);
}
-
+
/**
* EventListener interface for objects which want to get notified when ContentHandler
* implementing the ObjectSource interface has finished parsing.
*/
public interface ObjectBuiltListener extends EventListener {
-
+
/**
* Notifies the listener when the object is fully built.
* @param obj the newly built object
*/
void notifyObjectBuilt(Object obj);
-
+
}
-
+
}
diff --git a/src/java/org/apache/fop/util/ContentHandlerFactoryRegistry.java b/src/java/org/apache/fop/util/ContentHandlerFactoryRegistry.java
index 3d8ef8296..ceedf9f12 100644
--- a/src/java/org/apache/fop/util/ContentHandlerFactoryRegistry.java
+++ b/src/java/org/apache/fop/util/ContentHandlerFactoryRegistry.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -36,24 +36,24 @@ public class ContentHandlerFactoryRegistry {
/** the logger */
private static Log log = LogFactory.getLog(ContentHandlerFactoryRegistry.class);
-
+
/** Map from namespace URIs to ContentHandlerFactories */
private Map factories = new java.util.HashMap();
-
+
/**
* Default constructor.
*/
public ContentHandlerFactoryRegistry() {
discover();
}
-
+
/**
* Add an XML handler. The handler itself is inspected to find out what it supports.
* @param classname the fully qualified class name
*/
public void addContentHandlerFactory(String classname) {
try {
- ContentHandlerFactory factory
+ ContentHandlerFactory factory
= (ContentHandlerFactory)Class.forName(classname).newInstance();
addContentHandlerFactory(factory);
} catch (ClassNotFoundException e) {
@@ -67,11 +67,11 @@ public class ContentHandlerFactoryRegistry {
+ classname);
} catch (ClassCastException e) {
throw new IllegalArgumentException(classname
- + " is not an "
+ + " is not an "
+ ContentHandlerFactory.class.getName());
}
}
-
+
/**
* Add an ContentHandlerFactory. The instance is inspected to find out what it supports.
* @param factory the ContentHandlerFactory instance
@@ -82,7 +82,7 @@ public class ContentHandlerFactoryRegistry {
factories.put(ns[i], factory);
}
}
-
+
/**
* Retrieves a ContentHandlerFactory instance of a given namespace URI.
* @param namespaceURI the namespace to be handled.
@@ -92,7 +92,7 @@ public class ContentHandlerFactoryRegistry {
ContentHandlerFactory factory = (ContentHandlerFactory)factories.get(namespaceURI);
return factory;
}
-
+
/**
* Discovers ContentHandlerFactory implementations through the classpath and dynamically
* registers them.
@@ -105,7 +105,7 @@ public class ContentHandlerFactoryRegistry {
ContentHandlerFactory factory = (ContentHandlerFactory)providers.next();
try {
if (log.isDebugEnabled()) {
- log.debug("Dynamically adding ContentHandlerFactory: "
+ log.debug("Dynamically adding ContentHandlerFactory: "
+ factory.getClass().getName());
}
addContentHandlerFactory(factory);
diff --git a/src/java/org/apache/fop/util/ConversionUtils.java b/src/java/org/apache/fop/util/ConversionUtils.java
index e2d93fbd3..82d06ba32 100644
--- a/src/java/org/apache/fop/util/ConversionUtils.java
+++ b/src/java/org/apache/fop/util/ConversionUtils.java
@@ -5,7 +5,7 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
-
+
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@@ -27,84 +27,84 @@ public final class ConversionUtils {
* Converts the given base String into
* an array of int, splitting the base along the
* given separator pattern.
- * Note: this method assumes the input is a string containing
+ * Note: this method assumes the input is a string containing
* only decimal integers, signed or unsigned, that are parsable
* by java.lang.Integer.parseInt(String). If this
* is not the case, the resulting NumberFormatException
* will have to be handled by the caller.
- *
+ *
* @param baseString the base string
* @param separatorPattern the pattern separating the integer values
* (if this is null, the baseString is parsed as one
- * integer value)
+ * integer value)
* @return an array of int whose size is equal to the number
* values in the input string; null if this number
* is equal to zero.
*/
public static int[] toIntArray(String baseString, String separatorPattern) {
-
+
if (baseString == null || "".equals(baseString)) {
return null;
}
-
+
if (separatorPattern == null || "".equals(separatorPattern)) {
return new int[] { Integer.parseInt(baseString) };
}
-
+
String[] values = baseString.split(separatorPattern);
int numValues = values.length;
if (numValues == 0) {
return null;
}
-
+
int[] returnArray = new int[numValues];
for (int i = 0; i < numValues; ++i) {
returnArray[i] = Integer.parseInt(values[i]);
}
return returnArray;
-
+
}
/**
* Converts the given base String into
* an array of double, splitting the base along the
* given separator pattern.
- * Note: this method assumes the input is a string containing
+ * Note: this method assumes the input is a string containing
* only decimal doubles, signed or unsigned, that are parsable
* by java.lang.Double.parseDouble(String). If this
* is not the case, the resulting NumberFormatException
* will have to be handled by the caller.
- *
+ *
* @param baseString the base string
* @param separatorPattern the pattern separating the integer values
* (if this is null, the baseString is parsed as one
- * double value)
+ * double value)
* @return an array of double whose size is equal to the number
* values in the input string; null if this number
* is equal to zero.
*/
public static double[] toDoubleArray(String baseString, String separatorPattern) {
-
+
if (baseString == null || "".equals(baseString)) {
return null;
}
-
+
if (separatorPattern == null || "".equals(separatorPattern)) {
return new double[] { Double.parseDouble(baseString) };
}
-
+
String[] values = baseString.split(separatorPattern);
int numValues = values.length;
if (numValues == 0) {
return null;
}
-
+
double[] returnArray = new double[numValues];
for (int i = 0; i < numValues; ++i) {
returnArray[i] = Double.parseDouble(values[i]);
}
return returnArray;
-
+
}
-
+
}
diff --git a/src/java/org/apache/fop/util/DOM2SAX.java b/src/java/org/apache/fop/util/DOM2SAX.java
index 15f371b45..04096e053 100644
--- a/src/java/org/apache/fop/util/DOM2SAX.java
+++ b/src/java/org/apache/fop/util/DOM2SAX.java
@@ -35,7 +35,7 @@ import org.xml.sax.helpers.AttributesImpl;
/**
* Helper class that produces a SAX stream from a DOM Document.
*
- * Part of the code here copied and adapted from Apache Xalan-J,
+ * Part of the code here copied and adapted from Apache Xalan-J,
* src/org/apache/xalan/xsltc/trax/DOM2SAX.java
*/
public class DOM2SAX {
@@ -45,9 +45,9 @@ public class DOM2SAX {
private ContentHandler contentHandler;
private LexicalHandler lexicalHandler;
-
+
private Map prefixes = new java.util.HashMap();
-
+
/**
* Main constructor
* @param handler the ContentHandler to send SAX events to
@@ -58,7 +58,7 @@ public class DOM2SAX {
this.lexicalHandler = (LexicalHandler)handler;
}
}
-
+
/**
* Writes the given document using the given ContentHandler.
* @param doc DOM document
@@ -143,7 +143,7 @@ public class DOM2SAX {
* @param node node to serialize
* @throws SAXException In case of a problem while writing XML
*/
- private void writeNode(Node node)
+ private void writeNode(Node node)
throws SAXException {
if (node == null) {
return;
@@ -284,5 +284,5 @@ public class DOM2SAX {
}
}
-
+
}
diff --git a/src/java/org/apache/fop/util/DOMBuilderContentHandlerFactory.java b/src/java/org/apache/fop/util/DOMBuilderContentHandlerFactory.java
index 5ad127021..6117c436d 100644
--- a/src/java/org/apache/fop/util/DOMBuilderContentHandlerFactory.java
+++ b/src/java/org/apache/fop/util/DOMBuilderContentHandlerFactory.java
@@ -35,23 +35,23 @@ import org.xml.sax.SAXException;
*/
public class DOMBuilderContentHandlerFactory implements ContentHandlerFactory {
- private static SAXTransformerFactory tFactory
+ private static SAXTransformerFactory tFactory
= (SAXTransformerFactory)SAXTransformerFactory.newInstance();
private String namespaceURI;
private DOMImplementation domImplementation;
-
+
/**
* Main Constructor
- * @param namespaceURI the main namespace URI for the DOM to be parsed
+ * @param namespaceURI the main namespace URI for the DOM to be parsed
* @param domImplementation the DOMImplementation to use for build the DOM
*/
- public DOMBuilderContentHandlerFactory(String namespaceURI,
+ public DOMBuilderContentHandlerFactory(String namespaceURI,
DOMImplementation domImplementation) {
this.namespaceURI = namespaceURI;
this.domImplementation = domImplementation;
}
-
+
/** {@inheritDoc} */
public String[] getSupportedNamespaces() {
return new String[] {namespaceURI};
@@ -61,13 +61,13 @@ public class DOMBuilderContentHandlerFactory implements ContentHandlerFactory {
public ContentHandler createContentHandler() throws SAXException {
return new Handler();
}
-
+
private class Handler extends DelegatingContentHandler
implements ContentHandlerFactory.ObjectSource {
-
+
private Document doc;
private ObjectBuiltListener obListener;
-
+
public Handler() throws SAXException {
super();
}
@@ -75,7 +75,7 @@ public class DOMBuilderContentHandlerFactory implements ContentHandlerFactory {
public Document getDocument() {
return this.doc;
}
-
+
/**
* {@inheritDoc}
*/
@@ -89,7 +89,7 @@ public class DOMBuilderContentHandlerFactory implements ContentHandlerFactory {
public void setObjectBuiltListener(ObjectBuiltListener listener) {
this.obListener = listener;
}
-
+
/**
* {@inheritDoc}
*/
@@ -103,7 +103,7 @@ public class DOMBuilderContentHandlerFactory implements ContentHandlerFactory {
/**
* {@inheritDoc}
*/
- public void startElement(String uri, String localName, String qName, Attributes atts)
+ public void startElement(String uri, String localName, String qName, Attributes atts)
throws SAXException {
if (doc == null) {
TransformerHandler handler;
diff --git a/src/java/org/apache/fop/util/DataURIResolver.java b/src/java/org/apache/fop/util/DataURIResolver.java
index 699659f7e..89db6dc9d 100644
--- a/src/java/org/apache/fop/util/DataURIResolver.java
+++ b/src/java/org/apache/fop/util/DataURIResolver.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -31,7 +31,7 @@ import org.apache.xmlgraphics.util.io.Base64DecodeStream;
/**
* Resolves data URLs (described in RFC 2397) returning its data as a StreamSource.
- *
+ *
* @see javax.xml.transform.URIResolver
* @see RFC 2397
*/
@@ -51,7 +51,7 @@ public class DataURIResolver implements URIResolver {
/**
* Parses inline data URIs as generated by MS Word's XML export and FO
* stylesheet.
- *
+ *
* @see RFC 2397
*/
private Source parseDataURI(String href) {
diff --git a/src/java/org/apache/fop/util/DataURLUtil.java b/src/java/org/apache/fop/util/DataURLUtil.java
index 03236dd45..d8f7f17bf 100644
--- a/src/java/org/apache/fop/util/DataURLUtil.java
+++ b/src/java/org/apache/fop/util/DataURLUtil.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -44,7 +44,7 @@ public class DataURLUtil {
writeDataURL(in, mediatype, writer);
return writer.toString();
}
-
+
/**
* Generates a data URL and writes it to a Writer.
* @param in the InputStream to read the data from
diff --git a/src/java/org/apache/fop/util/DefaultErrorListener.java b/src/java/org/apache/fop/util/DefaultErrorListener.java
index 3717d3192..1d17b86fd 100644
--- a/src/java/org/apache/fop/util/DefaultErrorListener.java
+++ b/src/java/org/apache/fop/util/DefaultErrorListener.java
@@ -31,7 +31,7 @@ import org.apache.commons.logging.Log;
public class DefaultErrorListener implements ErrorListener {
private Log log;
-
+
/**
* Main constructor
* @param log the log instance to send log events to
@@ -39,7 +39,7 @@ public class DefaultErrorListener implements ErrorListener {
public DefaultErrorListener(Log log) {
this.log = log;
}
-
+
/**
* {@inheritDoc}
*/
diff --git a/src/java/org/apache/fop/util/DelegatingContentHandler.java b/src/java/org/apache/fop/util/DelegatingContentHandler.java
index 0b371483f..0db1105ce 100644
--- a/src/java/org/apache/fop/util/DelegatingContentHandler.java
+++ b/src/java/org/apache/fop/util/DelegatingContentHandler.java
@@ -38,9 +38,9 @@ import org.xml.sax.ext.LexicalHandler;
*
* The ContentHandler is the only instance that is required. All others (DTDHandler,
* EntityResolver, LexicalHandler and ErrorHandler) may be ignored.
- *
+ *
*/
-public class DelegatingContentHandler
+public class DelegatingContentHandler
implements EntityResolver, DTDHandler, ContentHandler, LexicalHandler, ErrorHandler {
private ContentHandler delegate;
@@ -48,7 +48,7 @@ public class DelegatingContentHandler
private DTDHandler dtdHandler;
private LexicalHandler lexicalHandler;
private ErrorHandler errorHandler;
-
+
/**
* Main constructor.
*/
@@ -62,7 +62,7 @@ public class DelegatingContentHandler
public ContentHandler getDelegateContentHandler() {
return this.delegate;
}
-
+
/**
* Sets the delegate ContentHandler that all events are forwarded to.
* @param handler the delegate instance
@@ -70,7 +70,7 @@ public class DelegatingContentHandler
public void setDelegateContentHandler(ContentHandler handler) {
this.delegate = handler;
}
-
+
/**
* Sets the delegate EntityResolver.
* @param resolver the delegate instance
@@ -78,7 +78,7 @@ public class DelegatingContentHandler
public void setDelegateEntityResolver(EntityResolver resolver) {
this.entityResolver = resolver;
}
-
+
/**
* Sets the delegate DTDHandler.
* @param handler the delegate instance
@@ -86,7 +86,7 @@ public class DelegatingContentHandler
public void setDelegateDTDHandler(DTDHandler handler) {
this.dtdHandler = handler;
}
-
+
/**
* Sets the delegate LexicalHandler.
* @param handler the delegate instance
@@ -94,7 +94,7 @@ public class DelegatingContentHandler
public void setDelegateLexicalHandler(LexicalHandler handler) {
this.lexicalHandler = handler;
}
-
+
/**
* Sets the delegate ErrorHandler.
* @param handler the delegate instance
@@ -102,9 +102,9 @@ public class DelegatingContentHandler
public void setDelegateErrorHandler(ErrorHandler handler) {
this.errorHandler = handler;
}
-
+
// ==== EntityResolver
-
+
/**
* {@inheritDoc}
*/
@@ -130,7 +130,7 @@ public class DelegatingContentHandler
/**
* {@inheritDoc}
*/
- public void unparsedEntityDecl(String name, String publicId, String systemId,
+ public void unparsedEntityDecl(String name, String publicId, String systemId,
String notationName) throws SAXException {
if (dtdHandler != null) {
dtdHandler.unparsedEntityDecl(name, publicId, systemId, notationName);
@@ -138,7 +138,7 @@ public class DelegatingContentHandler
}
// ==== ContentHandler
-
+
/**
* {@inheritDoc}
*/
@@ -177,7 +177,7 @@ public class DelegatingContentHandler
/**
* {@inheritDoc}
*/
- public void startElement(String uri, String localName, String qName,
+ public void startElement(String uri, String localName, String qName,
Attributes atts) throws SAXException {
delegate.startElement(uri, localName, qName, atts);
}
@@ -218,7 +218,7 @@ public class DelegatingContentHandler
}
// ==== LexicalHandler
-
+
/**
* {@inheritDoc}
*/
@@ -226,7 +226,7 @@ public class DelegatingContentHandler
if (lexicalHandler != null) {
lexicalHandler.startDTD(name, publicId, systemId);
}
-
+
}
/**
@@ -275,14 +275,14 @@ public class DelegatingContentHandler
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}
*/
public void comment(char[] ch, int start, int length) throws SAXException {
if (lexicalHandler != null) {
lexicalHandler.comment(ch, start, length);
}
}
-
+
// ==== ErrorHandler
/**
diff --git a/src/java/org/apache/fop/util/ListUtil.java b/src/java/org/apache/fop/util/ListUtil.java
index a6b8d490c..d97457510 100644
--- a/src/java/org/apache/fop/util/ListUtil.java
+++ b/src/java/org/apache/fop/util/ListUtil.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,7 +23,7 @@ import java.util.List;
/**
* Provides helper functions for {@link java.util.List}.
- *
+ *
*/
public final class ListUtil {
@@ -33,7 +33,7 @@ public final class ListUtil {
/**
* Retrieve the last element from a list.
- *
+ *
* @param list
* The list to work on
* @return last element
@@ -44,7 +44,7 @@ public final class ListUtil {
/**
* Retrieve and remove the last element from a list.
- *
+ *
* @param list
* The list to work on
* @return previous last element
diff --git a/src/java/org/apache/fop/util/LogUtil.java b/src/java/org/apache/fop/util/LogUtil.java
index e33397fcb..23f275644 100644
--- a/src/java/org/apache/fop/util/LogUtil.java
+++ b/src/java/org/apache/fop/util/LogUtil.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,7 +23,7 @@ import org.apache.commons.logging.Log;
import org.apache.fop.apps.FOPException;
/**
- * Convenience Logging utility methods used in FOP
+ * Convenience Logging utility methods used in FOP
*/
public class LogUtil {
diff --git a/src/java/org/apache/fop/util/QName.java b/src/java/org/apache/fop/util/QName.java
index 132f5b4dc..1b0708a89 100644
--- a/src/java/org/apache/fop/util/QName.java
+++ b/src/java/org/apache/fop/util/QName.java
@@ -22,14 +22,14 @@ package org.apache.fop.util;
/**
* Represents a qualified name of an XML element or an XML attribute.
*
- * Note: This class allows to carry a namespace prefix but it is not used in the equals() and
+ * Note: This class allows to carry a namespace prefix but it is not used in the equals() and
* hashCode() methods.
* @deprecated Use the XML Graphics Commons variant instead!
*/
public class QName extends org.apache.xmlgraphics.util.QName {
private static final long serialVersionUID = -5225376740044770690L;
-
+
/**
* Main constructor.
* @param namespaceURI the namespace URI
@@ -39,7 +39,7 @@ public class QName extends org.apache.xmlgraphics.util.QName {
public QName(String namespaceURI, String prefix, String localName) {
super(namespaceURI, prefix, localName);
}
-
+
/**
* Main constructor.
* @param namespaceURI the namespace URI
@@ -48,5 +48,5 @@ public class QName extends org.apache.xmlgraphics.util.QName {
public QName(String namespaceURI, String qName) {
super(namespaceURI, qName);
}
-
+
}
diff --git a/src/java/org/apache/fop/util/UnclosableInputStream.java b/src/java/org/apache/fop/util/UnclosableInputStream.java
index 0384a62ff..7d06a5ac7 100644
--- a/src/java/org/apache/fop/util/UnclosableInputStream.java
+++ b/src/java/org/apache/fop/util/UnclosableInputStream.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -29,7 +29,7 @@ public class UnclosableInputStream extends FilterInputStream {
/**
* Default constructor.
- *
+ *
* @param in the Stream to filter.
*/
public UnclosableInputStream(InputStream in) {
diff --git a/src/java/org/apache/fop/util/UnitConv.java b/src/java/org/apache/fop/util/UnitConv.java
index cd3276b9f..8bf7274eb 100644
--- a/src/java/org/apache/fop/util/UnitConv.java
+++ b/src/java/org/apache/fop/util/UnitConv.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -26,13 +26,13 @@ public final class UnitConv {
/** conversion factory from millimeters to inches. */
public static final float IN2MM = 25.4f;
-
+
/** conversion factory from centimeters to inches. */
public static final float IN2CM = 2.54f;
-
+
/** conversion factory from inches to points. */
public static final int IN2PT = 72;
-
+
/**
* Converts millimeters (mm) to points (pt)
* @param mm the value in mm
@@ -59,7 +59,7 @@ public final class UnitConv {
public static double pt2mm(double pt) {
return pt * IN2MM / IN2PT;
}
-
+
/**
* Converts millimeters (mm) to inches (in)
* @param mm the value in mm
@@ -68,7 +68,7 @@ public final class UnitConv {
public static double mm2in(double mm) {
return mm / IN2MM;
}
-
+
/**
* Converts inches (in) to millimeters (mm)
* @param in the value in inches
@@ -77,7 +77,7 @@ public final class UnitConv {
public static double in2mm(double in) {
return in * IN2MM;
}
-
+
/**
* Converts inches (in) to millipoints (mpt)
* @param in the value in inches
@@ -86,7 +86,7 @@ public final class UnitConv {
public static double in2mpt(double in) {
return in * IN2PT * 1000;
}
-
+
/**
* Converts inches (in) to points (pt)
* @param in the value in inches
@@ -95,16 +95,16 @@ public final class UnitConv {
public static double in2pt(double in) {
return in * IN2PT;
}
-
+
/**
- * Converts millipoints (mpt) to inches (in)
+ * Converts millipoints (mpt) to inches (in)
* @param mpt the value in mpt
* @return the value in inches
*/
public static double mpt2in(double mpt) {
return mpt / IN2PT / 1000;
}
-
+
/**
* Converts millimeters (mm) to pixels (px)
* @param mm the value in mm
diff --git a/src/java/org/apache/fop/util/WriterOutputStream.java b/src/java/org/apache/fop/util/WriterOutputStream.java
index d399b60dc..fb6875498 100644
--- a/src/java/org/apache/fop/util/WriterOutputStream.java
+++ b/src/java/org/apache/fop/util/WriterOutputStream.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -24,7 +24,7 @@ import java.io.OutputStream;
import java.io.Writer;
/**
- * An OutputStream wrapper for a Writer.
+ * An OutputStream wrapper for a Writer.
*/
public class WriterOutputStream extends OutputStream {
diff --git a/src/java/org/apache/fop/util/XMLResourceBundle.java b/src/java/org/apache/fop/util/XMLResourceBundle.java
index 1b320816b..268ce1eed 100644
--- a/src/java/org/apache/fop/util/XMLResourceBundle.java
+++ b/src/java/org/apache/fop/util/XMLResourceBundle.java
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
@@ -61,12 +61,12 @@ import org.apache.xmlgraphics.util.QName;
public class XMLResourceBundle extends ResourceBundle {
//Note: Some code here has been copied and adapted from Apache Harmony!
-
+
private Properties resources = new Properties();
private Locale locale;
-
- private static SAXTransformerFactory tFactory
+
+ private static SAXTransformerFactory tFactory
= (SAXTransformerFactory)SAXTransformerFactory.newInstance();
/**
@@ -84,7 +84,7 @@ public class XMLResourceBundle extends ResourceBundle {
throw new IOException("Error while parsing XML resource bundle: " + e.getMessage());
}
}
-
+
/**
* Gets a resource bundle using the specified base name, default locale, and class loader.
* @param baseName the base name of the resource bundle, a fully qualified class name
@@ -98,7 +98,7 @@ public class XMLResourceBundle extends ResourceBundle {
throws MissingResourceException {
return getXMLBundle(baseName, Locale.getDefault(), loader);
}
-
+
/**
* Gets a resource bundle using the specified base name, locale, and class loader.
* @param baseName the base name of the resource bundle, a fully qualified class name
@@ -117,7 +117,7 @@ public class XMLResourceBundle extends ResourceBundle {
if (baseName == null) {
throw new NullPointerException("baseName must not be null");
}
-
+
ResourceBundle bundle;
if (!locale.equals(Locale.getDefault())) {
bundle = handleGetXMLBundle(baseName, "_" + locale, false, loader);
@@ -145,10 +145,10 @@ public class XMLResourceBundle extends ResourceBundle {
private static final ResourceBundle MISSING = new MissingBundle();
private static final ResourceBundle MISSINGBASE = new MissingBundle();
-
+
private static Map cache = new java.util.WeakHashMap();
//