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: +

+
    +
  1. INFO: informational only
  2. +
  3. WARN: a Warning
  4. +
  5. ERROR: an error condition from which FOP can recover. FOP will continue processing.
  6. +
  7. FATAL: a fatal error which causes an exception in the end and FOP will stop processing.
  8. +
+

+ 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: +

+ + + + [ (See position {loc})| (See {#gatherContextInfo})| (No context info available)] + + + 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}} + + +]]> +

+ 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): + *

+ * <catalogue xml:lang="en">
+ *   <message key="key1">Message <br/> Value 1</message>
+ *   <message key="key2">Message <br/> Value 1</message>
+ *   ...
+ * </catalogue>
+ * 
+ */ +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(); + //> + + private static ResourceBundle handleGetXMLBundle(String base, String locale, + boolean loadBase, final ClassLoader loader) { + XMLResourceBundle bundle = null; + String bundleName = base + locale; + Object cacheKey = loader != null ? (Object) loader : (Object) "null"; + Hashtable loaderCache; // + synchronized (cache) { + loaderCache = (Hashtable)cache.get(cacheKey); + if (loaderCache == null) { + loaderCache = new Hashtable(); + cache.put(cacheKey, loaderCache); + } + } + ResourceBundle result = (ResourceBundle)loaderCache.get(bundleName); + if (result != null) { + if (result == MISSINGBASE) { + return null; + } + if (result == MISSING) { + if (!loadBase) { + return null; + } + String extension = strip(locale); + if (extension == null) { + return null; + } + return handleGetXMLBundle(base, extension, loadBase, loader); + } + return result; + } + + final String fileName = bundleName.replace('.', '/') + ".xml"; + InputStream stream = (InputStream)AccessController + .doPrivileged(new PrivilegedAction() { + public Object run() { + return loader == null + ? ClassLoader.getSystemResourceAsStream(fileName) + : loader.getResourceAsStream(fileName); + } + }); + if (stream != null) { + try { + try { + bundle = new XMLResourceBundle(stream); + } finally { + stream.close(); + } + bundle.setLocale(locale); + } catch (IOException e) { + throw new MissingResourceException(e.getMessage(), base, null); + } + } + + String extension = strip(locale); + if (bundle != null) { + if (extension != null) { + ResourceBundle parent = handleGetXMLBundle(base, extension, true, + loader); + if (parent != null) { + bundle.setParent(parent); + } + } + loaderCache.put(bundleName, bundle); + return bundle; + } + + if (extension != null) { + ResourceBundle fallback = handleGetXMLBundle(base, extension, loadBase, loader); + if (fallback != null) { + loaderCache.put(bundleName, fallback); + return fallback; + } + } + loaderCache.put(bundleName, loadBase ? MISSINGBASE : MISSING); + return null; + } + + private void setLocale(String name) { + String language = "", country = "", variant = ""; + if (name.length() > 1) { + int nextIndex = name.indexOf('_', 1); + if (nextIndex == -1) { + nextIndex = name.length(); + } + language = name.substring(1, nextIndex); + if (nextIndex + 1 < name.length()) { + int index = nextIndex; + nextIndex = name.indexOf('_', nextIndex + 1); + if (nextIndex == -1) { + nextIndex = name.length(); + } + country = name.substring(index + 1, nextIndex); + if (nextIndex + 1 < name.length()) { + variant = name.substring(nextIndex + 1, name.length()); + } + } + } + this.locale = new Locale(language, country, variant); + } + + private static String strip(String name) { + int index = name.lastIndexOf('_'); + if (index != -1) { + return name.substring(0, index); + } + return null; + } + + private Enumeration getLocalKeys() { + return (Enumeration)resources.propertyNames(); + } + + /** {@inheritDoc} */ + public Locale getLocale() { + return this.locale; + } + + /** {@inheritDoc} */ + public Enumeration getKeys() { + if (parent == null) { + return getLocalKeys(); + } + return new Enumeration() { + private Enumeration local = getLocalKeys(); + private Enumeration pEnum = parent.getKeys(); + + private Object nextElement; + + private boolean findNext() { + if (nextElement != null) { + return true; + } + while (pEnum.hasMoreElements()) { + Object next = pEnum.nextElement(); + if (!resources.containsKey(next)) { + nextElement = next; + return true; + } + } + return false; + } + + public boolean hasMoreElements() { + if (local.hasMoreElements()) { + return true; + } + return findNext(); + } + + public Object nextElement() { + if (local.hasMoreElements()) { + return local.nextElement(); + } + if (findNext()) { + Object result = nextElement; + nextElement = null; + return result; + } + // Cause an exception + return pEnum.nextElement(); + } + }; + } + + /** {@inheritDoc} */ + protected Object handleGetObject(String key) { + if (key == null) { + throw new NullPointerException("key must not be null"); + } + return resources.get(key); + } + + /** {@inheritDoc} */ + public String toString() { + return "XMLResourceBundle: " + getLocale(); + } + + private class CatalogueHandler extends DefaultHandler { + + private static final String CATALOGUE = "catalogue"; + private static final String MESSAGE = "message"; + + private StringBuffer valueBuffer = new StringBuffer(); + private Stack elementStack = new Stack(); + private String currentKey = null; + + private boolean isOwnNamespace(String uri) { + return ("".equals(uri)); + } + + private QName getParentElementName() { + return (QName)elementStack.peek(); + } + + /** {@inheritDoc} */ + public void startElement(String uri, String localName, String qName, + Attributes atts) throws SAXException { + super.startElement(uri, localName, qName, atts); + QName elementName = new QName(uri, qName); + if (isOwnNamespace(uri)) { + if (CATALOGUE.equals(localName)) { + //nop + } else if (MESSAGE.equals(localName)) { + if (!CATALOGUE.equals(getParentElementName().getLocalName())) { + throw new SAXException(MESSAGE + " must be a child of " + CATALOGUE); + } + this.currentKey = atts.getValue("key"); + } else { + throw new SAXException("Invalid element name: " + elementName); + } + } else { + //ignore + } + this.valueBuffer.setLength(0); + elementStack.push(elementName); + } + + /** {@inheritDoc} */ + public void endElement(String uri, String localName, String qName) throws SAXException { + super.endElement(uri, localName, qName); + elementStack.pop(); + if (isOwnNamespace(uri)) { + if (CATALOGUE.equals(localName)) { + //nop + } else if (MESSAGE.equals(localName)) { + if (this.currentKey == null) { + throw new SAXException( + "current key is null (attribute 'key' might be mistyped)"); + } + resources.put(this.currentKey, this.valueBuffer.toString()); + this.currentKey = null; + } + } else { + //ignore + } + this.valueBuffer.setLength(0); + } + + /** {@inheritDoc} */ + public void characters(char[] ch, int start, int length) throws SAXException { + super.characters(ch, start, length); + valueBuffer.append(ch, start, length); + } + + } + +} diff --git a/src/java/org/apache/fop/util/text/AdvancedMessageFormat.java b/src/java/org/apache/fop/util/text/AdvancedMessageFormat.java new file mode 100644 index 000000000..a2169156a --- /dev/null +++ b/src/java/org/apache/fop/util/text/AdvancedMessageFormat.java @@ -0,0 +1,487 @@ +/* + * 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.text; + +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.regex.Pattern; + +import org.apache.xmlgraphics.util.Service; + + +/** + * Formats messages based on a template and with a set of named parameters. This is similar to + * {@link java.util.MessageFormat} but uses named parameters and supports conditional sub-groups. + *

+ * Example: + *

+ *

Missing field "{fieldName}"[ at location: {location}]!

+ *
    + *
  • Curly brackets ("{}") are used for fields.
  • + *
  • Square brackets ("[]") are used to delimit conditional sub-groups. A sub-group is + * conditional when all fields inside the sub-group have a null value. In the case, everything + * between the brackets is skipped.
  • + *
+ */ +public class AdvancedMessageFormat { + + /** Regex that matches "," but not "\," (escaped comma) */ + static final Pattern COMMA_SEPARATOR_REGEX = Pattern.compile("(? 0) { + parent.addChild(new TextPart(sb.toString())); + sb.setLength(0); + } + i++; + int nesting = 1; + while (i < len) { + ch = pattern.charAt(i); + if (ch == '{') { + nesting++; + } else if (ch == '}') { + nesting--; + if (nesting == 0) { + i++; + break; + } + } + sb.append(ch); + i++; + } + parent.addChild(parseField(sb.toString())); + sb.setLength(0); + break; + case ']': + i++; + break loop; //Current composite is finished + case '[': + if (sb.length() > 0) { + parent.addChild(new TextPart(sb.toString())); + sb.setLength(0); + } + i++; + CompositePart composite = new CompositePart(true); + parent.addChild(composite); + i += parseInnerPattern(pattern, composite, sb, i); + break; + case '|': + if (sb.length() > 0) { + parent.addChild(new TextPart(sb.toString())); + sb.setLength(0); + } + parent.newSection(); + i++; + break; + case '\\': + if (i < len - 1) { + i++; + ch = pattern.charAt(i); + } + //no break here! Must be right before "default" section + default: + sb.append(ch); + i++; + } + } + if (sb.length() > 0) { + parent.addChild(new TextPart(sb.toString())); + sb.setLength(0); + } + return i - start; + } + + private Part parseField(String field) { + String[] parts = COMMA_SEPARATOR_REGEX.split(field, 3); + String fieldName = parts[0]; + if (parts.length == 1) { + if (fieldName.startsWith("#")) { + return new FunctionPart(fieldName.substring(1)); + } else { + return new SimpleFieldPart(fieldName); + } + } else { + String format = parts[1]; + PartFactory factory = (PartFactory)PART_FACTORIES.get(format); + if (factory == null) { + throw new IllegalArgumentException( + "No PartFactory available under the name: " + format); + } + if (parts.length == 2) { + return factory.newPart(fieldName, null); + } else { + return factory.newPart(fieldName, parts[2]); + } + } + } + + private static Function getFunction(String functionName) { + return (Function)FUNCTIONS.get(functionName); + } + + /** + * Formats a message with the given parameters. + * @param params a Map of named parameters (Contents: ) + * @return the formatted message + */ + public String format(Map params) { + StringBuffer sb = new StringBuffer(); + format(params, sb); + return sb.toString(); + } + + /** + * Formats a message with the given parameters. + * @param params a Map of named parameters (Contents: ) + * @param target the target StringBuffer to write the formatted message to + */ + public void format(Map params, StringBuffer target) { + rootPart.write(target, params); + } + + /** + * Represents a message template part. This interface is implemented by various variants of + * the single curly braces pattern ({field}, {field,if,yes,no} etc.). + */ + public interface Part { + + /** + * Writes the formatted part to a string buffer. + * @param sb the target string buffer + * @param params the parameters to work with + */ + void write(StringBuffer sb, Map params); + + /** + * Indicates whether there is any content that is generated by this message part. + * @param params the parameters to work with + * @return true if the part has content + */ + boolean isGenerated(Map params); + } + + /** + * Implementations of this interface parse a field part and return message parts. + */ + public interface PartFactory { + + /** + * Creates a new part by parsing the values parameter to configure the part. + * @param fieldName the field name + * @param values the unparsed parameter values + * @return the new message part + */ + Part newPart(String fieldName, String values); + + /** + * Returns the name of the message part format. + * @return the name of the message part format + */ + String getFormat(); + } + + /** + * Implementations of this interface format certain objects to strings. + */ + public interface ObjectFormatter { + + /** + * Formats an object to a string and writes the result to a string buffer. + * @param sb the target string buffer + * @param obj the object to be formatted + */ + void format(StringBuffer sb, Object obj); + + /** + * Indicates whether a given object is supported. + * @param obj the object + * @return true if the object is supported by the formatter + */ + boolean supportsObject(Object obj); + } + + /** + * Implementations of this interface do some computation based on the message parameters + * given to it. Note: at the moment, this has to be done in a local-independent way since + * there is no locale information. + */ + public interface Function { + + /** + * Executes the function. + * @param params the message parameters + * @return the function result + */ + Object evaluate(Map params); + + /** + * Returns the name of the function. + * @return the name of the function + */ + Object getName(); + } + + private static class TextPart implements Part { + + private String text; + + public TextPart(String text) { + this.text = text; + } + + public void write(StringBuffer sb, Map params) { + sb.append(text); + } + + public boolean isGenerated(Map params) { + return true; + } + + /** {@inheritDoc} */ + public String toString() { + return this.text; + } + } + + private static class SimpleFieldPart implements Part { + + private String fieldName; + + public SimpleFieldPart(String fieldName) { + this.fieldName = fieldName; + } + + public void write(StringBuffer sb, Map params) { + if (!params.containsKey(fieldName)) { + throw new IllegalArgumentException( + "Message pattern contains unsupported field name: " + fieldName); + } + Object obj = params.get(fieldName); + formatObject(obj, sb); + } + + public boolean isGenerated(Map params) { + Object obj = params.get(fieldName); + return obj != null; + } + + /** {@inheritDoc} */ + public String toString() { + return "{" + this.fieldName + "}"; + } + } + + /** + * Formats an object to a string and writes the result to a string buffer. This method + * usually uses the object's toString() method unless there is an + * {@link ObjectFormatter} that supports the object. {@link ObjectFormatter}s are registered + * through the service provider mechanism defined by the JAR specification. + * @param obj the object to be formatted + * @param target the target string buffer + */ + public static void formatObject(Object obj, StringBuffer target) { + if (obj instanceof String) { + target.append(obj); + } else { + boolean handled = false; + Iterator iter = OBJECT_FORMATTERS.iterator(); + while (iter.hasNext()) { + ObjectFormatter formatter = (ObjectFormatter)iter.next(); + if (formatter.supportsObject(obj)) { + formatter.format(target, obj); + handled = true; + break; + } + } + if (!handled) { + target.append(String.valueOf(obj)); + } + } + } + + private static class FunctionPart implements Part { + + private Function function; + + public FunctionPart(String functionName) { + this.function = getFunction(functionName); + if (this.function == null) { + throw new IllegalArgumentException("Unknown function: " + functionName); + } + } + + public void write(StringBuffer sb, Map params) { + Object obj = this.function.evaluate(params); + formatObject(obj, sb); + } + + public boolean isGenerated(Map params) { + Object obj = this.function.evaluate(params); + return obj != null; + } + + /** {@inheritDoc} */ + public String toString() { + return "{#" + this.function.getName() + "}"; + } + } + + private static class CompositePart implements Part { + + protected List parts = new java.util.ArrayList(); + private boolean conditional; + private boolean hasSections = false; + + public CompositePart(boolean conditional) { + this.conditional = conditional; + } + + private CompositePart(List parts) { + this.parts.addAll(parts); + this.conditional = true; + } + + public void addChild(Part part) { + if (part == null) { + throw new NullPointerException("part must not be null"); + } + if (hasSections) { + CompositePart composite = (CompositePart)this.parts.get(this.parts.size() - 1); + composite.addChild(part); + } else { + this.parts.add(part); + } + } + + public void newSection() { + if (!hasSections) { + List p = this.parts; + //Dropping into a different mode... + this.parts = new java.util.ArrayList(); + this.parts.add(new CompositePart(p)); + hasSections = true; + } + this.parts.add(new CompositePart(true)); + } + + public void write(StringBuffer sb, Map params) { + if (hasSections) { + Iterator iter = this.parts.iterator(); + while (iter.hasNext()) { + CompositePart part = (CompositePart)iter.next(); + if (part.isGenerated(params)) { + part.write(sb, params); + break; + } + } + } else { + if (isGenerated(params)) { + Iterator iter = this.parts.iterator(); + while (iter.hasNext()) { + Part part = (Part)iter.next(); + part.write(sb, params); + } + } + } + } + + public boolean isGenerated(Map params) { + if (hasSections) { + Iterator iter = this.parts.iterator(); + while (iter.hasNext()) { + Part part = (Part)iter.next(); + if (part.isGenerated(params)) { + return true; + } + } + return false; + } else { + if (conditional) { + Iterator iter = this.parts.iterator(); + while (iter.hasNext()) { + Part part = (Part)iter.next(); + if (!part.isGenerated(params)) { + return false; + } + } + } + return true; + } + } + + /** {@inheritDoc} */ + public String toString() { + return this.parts.toString(); + } + } + + + static String unescapeComma(String string) { + return string.replaceAll("\\\\,", ","); + } +} diff --git a/src/java/org/apache/fop/util/text/ChoiceFieldPart.java b/src/java/org/apache/fop/util/text/ChoiceFieldPart.java new file mode 100644 index 000000000..df457a02b --- /dev/null +++ b/src/java/org/apache/fop/util/text/ChoiceFieldPart.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.util.text; + +import java.text.ChoiceFormat; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.fop.util.text.AdvancedMessageFormat.Part; +import org.apache.fop.util.text.AdvancedMessageFormat.PartFactory; + +/** + * Defines a "choice" field part that works like {@link ChoiceFormat}. + */ +public class ChoiceFieldPart implements Part { + + private static final Pattern VARIABLE_REGEX = Pattern.compile("\\{([^\\}]+)\\}"); + + private String fieldName; + private ChoiceFormat choiceFormat; + + /** + * Creates a new choice part. + * @param fieldName the field name to work on + * @param choicesPattern the choices pattern (as used by {@link ChoiceFormat}) + */ + public ChoiceFieldPart(String fieldName, String choicesPattern) { + this.fieldName = fieldName; + this.choiceFormat = new ChoiceFormat(choicesPattern); + } + + /** {@inheritDoc} */ + public boolean isGenerated(Map params) { + Object obj = params.get(fieldName); + return obj != null; + } + + /** {@inheritDoc} */ + public void write(StringBuffer sb, Map params) { + Object obj = params.get(fieldName); + Number num = (Number)obj; + String result = this.choiceFormat.format(num.doubleValue()); + Matcher m = VARIABLE_REGEX.matcher(result); + if (m.find()) { + //Resolve inner variables + AdvancedMessageFormat f = new AdvancedMessageFormat(result); + f.format(params, sb); + } else { + sb.append(result); + } + } + + /** {@inheritDoc} */ + public String toString() { + return "{" + this.fieldName + ",choice, ....}"; + } + + /** Factory for ChoiceFieldPart. */ + public static class Factory implements PartFactory { + + /** {@inheritDoc} */ + public Part newPart(String fieldName, String values) { + return new ChoiceFieldPart(fieldName, values); + } + + /** {@inheritDoc} */ + public String getFormat() { + return "choice"; + } + + } + +} \ No newline at end of file diff --git a/src/java/org/apache/fop/util/text/EqualsFieldPart.java b/src/java/org/apache/fop/util/text/EqualsFieldPart.java new file mode 100644 index 000000000..2114b0d00 --- /dev/null +++ b/src/java/org/apache/fop/util/text/EqualsFieldPart.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.util.text; + +import java.util.Map; + +import org.apache.fop.util.text.AdvancedMessageFormat.Part; +import org.apache.fop.util.text.AdvancedMessageFormat.PartFactory; + +/** + * Defines an "equals" field part that can compare a field's string value against another string. + * It returns either of two possible values attached as additional part parameters. Example: + * {field,equals,new,This is new!,This is old!} + */ +public class EqualsFieldPart extends IfFieldPart { + + private String equalsValue; + + /** + * Creates a new "equals" field part. + * @param fieldName the field name + * @param values the unparsed parameter values + */ + public EqualsFieldPart(String fieldName, String values) { + super(fieldName, values); + } + + /** {@inheritDoc} */ + protected void parseValues(String values) { + String[] parts = AdvancedMessageFormat.COMMA_SEPARATOR_REGEX.split(values, 3); + this.equalsValue = parts[0]; + if (parts.length == 1) { + throw new IllegalArgumentException( + "'equals' format must have at least 2 parameters"); + } + if (parts.length == 3) { + ifValue = AdvancedMessageFormat.unescapeComma(parts[1]); + elseValue = AdvancedMessageFormat.unescapeComma(parts[2]); + } else { + ifValue = AdvancedMessageFormat.unescapeComma(parts[1]); + } + } + + /** {@inheritDoc} */ + protected boolean isTrue(Map params) { + Object obj = params.get(fieldName); + if (obj != null) { + return String.valueOf(obj).equals(this.equalsValue); + } else { + return false; + } + } + + /** {@inheritDoc} */ + public String toString() { + return "{" + this.fieldName + ", equals " + this.equalsValue + "}"; + } + + /** + * Part factory for "equals". + */ + public static class Factory implements PartFactory { + + /** {@inheritDoc} */ + public Part newPart(String fieldName, String values) { + return new EqualsFieldPart(fieldName, values); + } + + /** {@inheritDoc} */ + public String getFormat() { + return "equals"; + } + + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/util/text/GlyphNameFieldPart.java b/src/java/org/apache/fop/util/text/GlyphNameFieldPart.java new file mode 100644 index 000000000..5d78cdfad --- /dev/null +++ b/src/java/org/apache/fop/util/text/GlyphNameFieldPart.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.util.text; + +import java.util.Map; + +import org.apache.xmlgraphics.fonts.Glyphs; + +import org.apache.fop.util.text.AdvancedMessageFormat.Part; +import org.apache.fop.util.text.AdvancedMessageFormat.PartFactory; + +/** + * Function formatting a character to a glyph name. + */ +public class GlyphNameFieldPart implements Part { + + private String fieldName; + + /** + * Creates a new glyph name field part + * @param fieldName the field name + */ + public GlyphNameFieldPart(String fieldName) { + this.fieldName = fieldName; + } + + /** {@inheritDoc} */ + public boolean isGenerated(Map params) { + Object obj = params.get(fieldName); + return obj != null && getGlyphName(obj).length() > 0; + } + + private String getGlyphName(Object obj) { + if (obj instanceof Character) { + return Glyphs.charToGlyphName(((Character)obj).charValue()); + } else { + throw new IllegalArgumentException( + "Value for glyph name part must be a Character but was: " + + obj.getClass().getName()); + } + } + + /** {@inheritDoc} */ + public void write(StringBuffer sb, Map params) { + if (!params.containsKey(fieldName)) { + throw new IllegalArgumentException( + "Message pattern contains unsupported field name: " + fieldName); + } + Object obj = params.get(fieldName); + sb.append(getGlyphName(obj)); + } + + /** {@inheritDoc} */ + public String toString() { + return "{" + this.fieldName + ",glyph-name}"; + } + + /** Factory for {@link GlyphNameFieldPart}. */ + public static class Factory implements PartFactory { + + /** {@inheritDoc} */ + public Part newPart(String fieldName, String values) { + return new GlyphNameFieldPart(fieldName); + } + + /** {@inheritDoc} */ + public String getFormat() { + return "glyph-name"; + } + + } +} diff --git a/src/java/org/apache/fop/util/text/HexFieldPart.java b/src/java/org/apache/fop/util/text/HexFieldPart.java new file mode 100644 index 000000000..19f47f3d7 --- /dev/null +++ b/src/java/org/apache/fop/util/text/HexFieldPart.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.util.text; + +import java.util.Map; + +import org.apache.fop.util.text.AdvancedMessageFormat.Part; +import org.apache.fop.util.text.AdvancedMessageFormat.PartFactory; + +/** + * Function formatting a number or character to a hex value. + */ +public class HexFieldPart implements Part { + + private String fieldName; + + /** + * Creates a new hex field part + * @param fieldName the field name + */ + public HexFieldPart(String fieldName) { + this.fieldName = fieldName; + } + + /** {@inheritDoc} */ + public boolean isGenerated(Map params) { + Object obj = params.get(fieldName); + return obj != null; + } + + /** {@inheritDoc} */ + public void write(StringBuffer sb, Map params) { + if (!params.containsKey(fieldName)) { + throw new IllegalArgumentException( + "Message pattern contains unsupported field name: " + fieldName); + } + Object obj = params.get(fieldName); + if (obj instanceof Character) { + sb.append(Integer.toHexString(((Character)obj).charValue())); + } else if (obj instanceof Number) { + sb.append(Integer.toHexString(((Number)obj).intValue())); + } else { + throw new IllegalArgumentException("Incompatible value for hex field part: " + + obj.getClass().getName()); + } + } + + /** {@inheritDoc} */ + public String toString() { + return "{" + this.fieldName + ",hex}"; + } + + /** Factory for {@link HexFieldPart}. */ + public static class Factory implements PartFactory { + + /** {@inheritDoc} */ + public Part newPart(String fieldName, String values) { + return new HexFieldPart(fieldName); + } + + /** {@inheritDoc} */ + public String getFormat() { + return "hex"; + } + + } +} diff --git a/src/java/org/apache/fop/util/text/IfFieldPart.java b/src/java/org/apache/fop/util/text/IfFieldPart.java new file mode 100644 index 000000000..31cd8f36c --- /dev/null +++ b/src/java/org/apache/fop/util/text/IfFieldPart.java @@ -0,0 +1,116 @@ +/* + * 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.text; + +import java.util.Map; + +import org.apache.fop.util.text.AdvancedMessageFormat.Part; +import org.apache.fop.util.text.AdvancedMessageFormat.PartFactory; + +/** + * Defines an "if" field part that checks if field's value is true or false. + * It returns either of two possible values attached as additional part parameters. Example: + * {field,if,Yes,No} + */ +public class IfFieldPart implements Part { + + /** the field name for the part */ + protected String fieldName; + /** the value being returned if the field is true */ + protected String ifValue; + /** the value being returned if the field is false */ + protected String elseValue; + + /** + * Creates a new "if" field part. + * @param fieldName the field name + * @param values the unparsed parameter values + */ + public IfFieldPart(String fieldName, String values) { + this.fieldName = fieldName; + parseValues(values); + } + + /** + * Parses the parameter values + * @param values the unparsed parameter values + */ + protected void parseValues(String values) { + String[] parts = AdvancedMessageFormat.COMMA_SEPARATOR_REGEX.split(values, 2); + if (parts.length == 2) { + ifValue = AdvancedMessageFormat.unescapeComma(parts[0]); + elseValue = AdvancedMessageFormat.unescapeComma(parts[1]); + } else { + ifValue = AdvancedMessageFormat.unescapeComma(values); + } + } + + /** {@inheritDoc} */ + public void write(StringBuffer sb, Map params) { + boolean isTrue = isTrue(params); + if (isTrue) { + sb.append(ifValue); + } else if (elseValue != null) { + sb.append(elseValue); + } + } + + /** + * Indicates whether the field's value is true. If the field is not a boolen, it is true + * if the field is not null. + * @param params the message parameters + * @return true the field's value as boolean + */ + protected boolean isTrue(Map params) { + Object obj = params.get(fieldName); + if (obj instanceof Boolean) { + return ((Boolean)obj).booleanValue(); + } else { + return (obj != null); + } + } + + /** {@inheritDoc} */ + public boolean isGenerated(Map params) { + return isTrue(params) || (elseValue != null); + } + + /** {@inheritDoc} */ + public String toString() { + return "{" + this.fieldName + ", if...}"; + } + + /** + * Part factory for "if". + */ + public static class Factory implements PartFactory { + + /** {@inheritDoc} */ + public Part newPart(String fieldName, String values) { + return new IfFieldPart(fieldName, values); + } + + /** {@inheritDoc} */ + public String getFormat() { + return "if"; + } + + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/util/text/LocatorFormatter.java b/src/java/org/apache/fop/util/text/LocatorFormatter.java new file mode 100644 index 000000000..d9532c66d --- /dev/null +++ b/src/java/org/apache/fop/util/text/LocatorFormatter.java @@ -0,0 +1,42 @@ +/* + * 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.text; + +import org.xml.sax.Locator; + +import org.apache.fop.util.text.AdvancedMessageFormat.ObjectFormatter; + +/** + * Object formatter for the SAX Locator object. + */ +public class LocatorFormatter implements ObjectFormatter { + + /** {@inheritDoc} */ + public void format(StringBuffer sb, Object obj) { + Locator loc = (Locator)obj; + sb.append(loc.getLineNumber()).append(":").append(loc.getColumnNumber()); + } + + /** {@inheritDoc} */ + public boolean supportsObject(Object obj) { + return obj instanceof Locator; + } + +} \ No newline at end of file diff --git a/test/java/META-INF/services/org.apache.fop.events.model.EventModelFactory b/test/java/META-INF/services/org.apache.fop.events.model.EventModelFactory new file mode 100644 index 000000000..a40d5658a --- /dev/null +++ b/test/java/META-INF/services/org.apache.fop.events.model.EventModelFactory @@ -0,0 +1 @@ +org.apache.fop.events.FOPTestEventModelFactory \ No newline at end of file diff --git a/test/java/org/apache/fop/UtilityCodeTestSuite.java b/test/java/org/apache/fop/UtilityCodeTestSuite.java index 86a3469ce..d2577c251 100644 --- a/test/java/org/apache/fop/UtilityCodeTestSuite.java +++ b/test/java/org/apache/fop/UtilityCodeTestSuite.java @@ -23,12 +23,14 @@ import junit.framework.Test; import junit.framework.TestSuite; import org.apache.fop.pdf.PDFObjectTestCase; +import org.apache.fop.events.BasicEventTestCase; import org.apache.fop.traits.BorderPropsTestCase; import org.apache.fop.util.DataURIResolverTestCase; import org.apache.fop.util.ElementListUtilsTestCase; import org.apache.fop.util.PDFNumberTestCase; import org.apache.fop.util.ColorUtilTestCase; import org.apache.fop.util.UnitConvTestCase; +import org.apache.fop.util.XMLResourceBundleTestCase; /** * Test suite for FOP's utility classes. @@ -50,6 +52,8 @@ public class UtilityCodeTestSuite { suite.addTest(new TestSuite(BorderPropsTestCase.class)); suite.addTest(new TestSuite(ElementListUtilsTestCase.class)); suite.addTest(new TestSuite(DataURIResolverTestCase.class)); + suite.addTest(new TestSuite(BasicEventTestCase.class)); + suite.addTest(new TestSuite(XMLResourceBundleTestCase.class)); //$JUnit-END$ return suite; } diff --git a/test/java/org/apache/fop/events/BasicEventTestCase.java b/test/java/org/apache/fop/events/BasicEventTestCase.java new file mode 100644 index 000000000..d365ca0ec --- /dev/null +++ b/test/java/org/apache/fop/events/BasicEventTestCase.java @@ -0,0 +1,95 @@ +/* + * 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 junit.framework.TestCase; + +import org.apache.fop.events.model.EventSeverity; + +public class BasicEventTestCase extends TestCase { + + public void testBasics() throws Exception { + + MyEventListener listener = new MyEventListener(); + + EventBroadcaster broadcaster = new DefaultEventBroadcaster(); + broadcaster.addEventListener(listener); + assertTrue(broadcaster.hasEventListeners()); + + Event ev = new Event(this, "123", EventSeverity.INFO, + Event.paramsBuilder() + .param("reason", "I'm tired") + .param("blah", new Integer(23)) + .build()); + broadcaster.broadcastEvent(ev); + + ev = listener.event; + assertNotNull(ev); + assertEquals("123", listener.event.getEventID()); + assertEquals(EventSeverity.INFO, listener.event.getSeverity()); + assertEquals("I'm tired", ev.getParam("reason")); + assertEquals(new Integer(23), ev.getParam("blah")); + + broadcaster.removeEventListener(listener); + assertFalse(broadcaster.hasEventListeners()); + + //Just check that there are no NPEs + broadcaster.broadcastEvent(ev); + } + + public void testEventProducer() throws Exception { + MyEventListener listener = new MyEventListener(); + + EventBroadcaster broadcaster = new DefaultEventBroadcaster(); + broadcaster.addEventListener(listener); + assertTrue(broadcaster.hasEventListeners()); + + + TestEventProducer producer = TestEventProducer.Provider.get(broadcaster); + producer.complain(this, "I'm tired", 23); + + Event ev = listener.event; + assertNotNull(ev); + assertEquals("org.apache.fop.events.TestEventProducer.complain", + listener.event.getEventID()); + assertEquals(EventSeverity.WARN, listener.event.getSeverity()); + assertEquals("I'm tired", ev.getParam("reason")); + assertEquals(new Integer(23), ev.getParam("blah")); + + broadcaster.removeEventListener(listener); + assertFalse(broadcaster.hasEventListeners()); + + //Just check that there are no NPEs + broadcaster.broadcastEvent(ev); + } + + private class MyEventListener implements EventListener { + + private Event event; + + public void processEvent(Event event) { + if (this.event != null) { + fail("Multiple events received"); + } + this.event = event; + } + } + +} diff --git a/test/java/org/apache/fop/events/FOPTestEventModelFactory.java b/test/java/org/apache/fop/events/FOPTestEventModelFactory.java new file mode 100644 index 000000000..796a9cfb5 --- /dev/null +++ b/test/java/org/apache/fop/events/FOPTestEventModelFactory.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 test event model. + */ +public class FOPTestEventModelFactory extends AbstractEventModelFactory { + + private static final String EVENT_MODEL_FILENAME = "test-event-model.xml"; + + /** {@inheritDoc} */ + public EventModel createEventModel() { + return loadModel(getClass(), EVENT_MODEL_FILENAME); + } + +} diff --git a/test/java/org/apache/fop/events/TestEventProducer.java b/test/java/org/apache/fop/events/TestEventProducer.java new file mode 100644 index 000000000..7dfba75ba --- /dev/null +++ b/test/java/org/apache/fop/events/TestEventProducer.java @@ -0,0 +1,48 @@ +/* + * 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; + +public interface TestEventProducer extends EventProducer { + + /** + * Complain about something. + * @param source the event source + * @param reason the reason for the complaint + * @param blah the complaint + * @event.severity WARN + */ + void complain(Object source, String reason, int blah); + + /** + * Express joy about something. + * @param source the event source + * @param what the cause for the joy + * @event.severity INFO + */ + void enjoy(Object source, String what); + + public class Provider { + + public static TestEventProducer get(EventBroadcaster broadcaster) { + return (TestEventProducer)broadcaster.getEventProducerFor(TestEventProducer.class); + } + } + +} diff --git a/test/java/org/apache/fop/util/AdvancedMessageFormatTestCase.java b/test/java/org/apache/fop/util/AdvancedMessageFormatTestCase.java new file mode 100644 index 000000000..c0e003573 --- /dev/null +++ b/test/java/org/apache/fop/util/AdvancedMessageFormatTestCase.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.util; + +import java.util.Map; + +import junit.framework.TestCase; + +import org.xml.sax.helpers.LocatorImpl; + +import org.apache.fop.events.model.EventSeverity; +import org.apache.fop.util.text.AdvancedMessageFormat; + +/** + * Tests for EventFormatter. + */ +public class AdvancedMessageFormatTestCase extends TestCase { + + public void testFormatting() throws Exception { + String msg; + AdvancedMessageFormat format; + + String pattern + = "Element \"{elementName}\" is missing[ required property \"{propertyName}\"]!"; + format = new AdvancedMessageFormat(pattern); + + Map params = new java.util.HashMap(); + params.put("node", new Object()); + params.put("elementName", "fo:external-graphic"); + params.put("propertyName", "src"); + + msg = format.format(params); + assertEquals("Element \"fo:external-graphic\" is missing required property \"src\"!", msg); + + params.remove("propertyName"); + msg = format.format(params); + assertEquals("Element \"fo:external-graphic\" is missing!", msg); + + pattern + = "Testing \\{escaped \\[characters\\], now a normal field {elementName}!"; + format = new AdvancedMessageFormat(pattern); + msg = format.format(params); + assertEquals("Testing {escaped [characters], now a normal field fo:external-graphic!", msg); + + pattern = "Multi-conditional: [case1: {var1}|case2: {var2}|case3: {var3}]"; + format = new AdvancedMessageFormat(pattern); + + params = new java.util.HashMap(); + msg = format.format(params); + assertEquals("Multi-conditional: ", msg); + + params.put("var3", "value3"); + msg = format.format(params); + assertEquals("Multi-conditional: case3: value3", msg); + params.put("var1", "value1"); + msg = format.format(params); + assertEquals("Multi-conditional: case1: value1", msg); + } + + public void testObjectFormatting() throws Exception { + String msg; + AdvancedMessageFormat format; + + String pattern + = "Here's a Locator: {locator}"; + format = new AdvancedMessageFormat(pattern); + + Map params = new java.util.HashMap(); + LocatorImpl loc = new LocatorImpl(); + loc.setColumnNumber(7); + loc.setLineNumber(12); + params.put("locator", loc); + + msg = format.format(params); + assertEquals("Here\'s a Locator: 12:7", msg); + } + + public void testIfFormatting() throws Exception { + String msg; + AdvancedMessageFormat format; + + format = new AdvancedMessageFormat("You are{isBad,if, not} nice!"); + + Map params = new java.util.HashMap(); + + params.put("isBad", Boolean.FALSE); + msg = format.format(params); + assertEquals("You are nice!", msg); + + params.put("isBad", Boolean.TRUE); + msg = format.format(params); + assertEquals("You are not nice!", msg); + + format = new AdvancedMessageFormat("You are{isGood,if, very, not so} nice!"); + + params = new java.util.HashMap(); + + msg = format.format(params); //isGood is missing + assertEquals("You are not so nice!", msg); + + params.put("isGood", Boolean.FALSE); + msg = format.format(params); + assertEquals("You are not so nice!", msg); + + params.put("isGood", Boolean.TRUE); + msg = format.format(params); + assertEquals("You are very nice!", msg); + + format = new AdvancedMessageFormat("You are{isGood,if, very\\, very} nice!"); + + params = new java.util.HashMap(); + + msg = format.format(params); //isGood is missing + assertEquals("You are nice!", msg); + + params.put("isGood", Boolean.FALSE); + msg = format.format(params); + assertEquals("You are nice!", msg); + + params.put("isGood", Boolean.TRUE); + msg = format.format(params); + assertEquals("You are very, very nice!", msg); + } + + public void testEqualsFormatting() throws Exception { + String msg; + AdvancedMessageFormat format; + + format = new AdvancedMessageFormat( + "Error{severity,equals,EventSeverity:FATAL,,\nSome explanation!}"); + + Map params = new java.util.HashMap(); + + params.put("severity", EventSeverity.FATAL); + msg = format.format(params); + assertEquals("Error", msg); + + params.put("severity", EventSeverity.WARN); + msg = format.format(params); + assertEquals("Error\nSome explanation!", msg); + } + + public void testChoiceFormatting() throws Exception { + String msg; + AdvancedMessageFormat format; + + format = new AdvancedMessageFormat( + "You have {amount,choice,0#nothing|0<{amount} bucks|100 + + Hello World! + Untranslatable + \ No newline at end of file diff --git a/test/java/org/apache/fop/util/XMLResourceBundleTestCase_de.xml b/test/java/org/apache/fop/util/XMLResourceBundleTestCase_de.xml new file mode 100644 index 000000000..44cf5a5b4 --- /dev/null +++ b/test/java/org/apache/fop/util/XMLResourceBundleTestCase_de.xml @@ -0,0 +1,4 @@ + + + Hallo Welt! + \ No newline at end of file diff --git a/test/java/org/apache/fop/util/invalid-translation-file.xml b/test/java/org/apache/fop/util/invalid-translation-file.xml new file mode 100644 index 000000000..09306b7cc --- /dev/null +++ b/test/java/org/apache/fop/util/invalid-translation-file.xml @@ -0,0 +1,5 @@ + + + Hello World! + blah + \ No newline at end of file -- cgit v1.2.3 From d058e870151a49af34ec1e7204edd0ffc64aaefc Mon Sep 17 00:00:00 2001 From: Vincent Hennebert Date: Fri, 25 Jul 2008 10:55:49 +0000 Subject: Merged revisions 679052-679352 via svnmerge from https://svn.eu.apache.org/repos/asf/xmlgraphics/fop/trunk ........ r679060 | acumiskey | 2008-07-23 11:39:11 +0100 (Wed, 23 Jul 2008) | 2 lines My bad.. copy paste error I introduced which broke forrest. ........ r679164 | jeremias | 2008-07-23 20:33:24 +0100 (Wed, 23 Jul 2008) | 1 line Only update the generated files if any source file is newer than the generated ones. ........ r679326 | vhennebert | 2008-07-24 10:35:34 +0100 (Thu, 24 Jul 2008) | 2 lines Fed up with all those trailing whitespaces. Let's remove them all (once... and for all?) ........ git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@679758 13f79535-47bb-0310-9956-ffa450edef68 --- .../embedding/java/embedding/ExampleAWTViewer.java | 6 +- .../embedding/java/embedding/ExampleDOM2PDF.java | 42 ++-- .../java/embedding/ExampleFO2JPSPrint.java | 28 +-- .../java/embedding/ExampleFO2OldStylePrint.java | 22 +- .../embedding/java/embedding/ExampleFO2PDF.java | 32 +-- .../embedding/ExampleFO2PDFUsingSAXParser.java | 20 +- .../embedding/java/embedding/ExampleFO2RTF.java | 28 +-- .../embedding/java/embedding/ExampleObj2PDF.java | 20 +- .../embedding/java/embedding/ExampleObj2XML.java | 22 +- .../embedding/java/embedding/ExampleSVG2PDF.java | 22 +- .../embedding/java/embedding/ExampleXML2FO.java | 20 +- .../embedding/java/embedding/ExampleXML2PDF.java | 26 +-- .../embedding/java/embedding/MultipleFO2PDF.java | 36 ++-- .../java/embedding/events/ExampleEvents.java | 40 ++-- .../java/embedding/intermediate/ExampleConcat.java | 56 ++--- .../java/embedding/intermediate/ExampleStamp.java | 38 ++-- .../java/embedding/model/ProjectMember.java | 10 +- .../java/embedding/model/ProjectTeam.java | 6 +- .../embedding/model/ProjectTeamInputSource.java | 6 +- .../java/embedding/model/ProjectTeamXMLReader.java | 20 +- .../java/embedding/tools/AbstractObjectReader.java | 14 +- .../tools/EasyGenerationContentHandlerProxy.java | 22 +- .../fop/hyphenation/HyphenationTreeAnalysis.java | 42 ++-- .../fop/hyphenation/TernaryTreeAnalysis.java | 82 ++++---- .../fop/mathml/ImageLoaderFactoryMathML.java | 16 +- .../org/apache/fop/mathml/ImageLoaderMathML.java | 6 +- .../src/org/apache/fop/mathml/MathMLElement.java | 12 +- .../apache/fop/mathml/MathMLElementMapping.java | 8 +- .../src/org/apache/fop/mathml/MathMLObj.java | 6 +- .../src/org/apache/fop/mathml/PreloaderMathML.java | 24 +-- .../plan/src/org/apache/fop/plan/ActionInfo.java | 8 +- .../plan/src/org/apache/fop/plan/EventList.java | 8 +- .../plan/src/org/apache/fop/plan/GroupInfo.java | 8 +- examples/plan/src/org/apache/fop/plan/Main.java | 6 +- .../plan/src/org/apache/fop/plan/PlanDrawer.java | 8 +- .../plan/src/org/apache/fop/plan/PlanElement.java | 10 +- .../org/apache/fop/plan/PlanElementMapping.java | 8 +- .../plan/src/org/apache/fop/plan/PlanHints.java | 8 +- examples/plan/src/org/apache/fop/plan/PlanObj.java | 6 +- .../plan/src/org/apache/fop/plan/PlanRenderer.java | 10 +- .../src/org/apache/fop/plan/PreloaderPlan.java | 14 +- .../src/org/apache/fop/plan/SimplePlanDrawer.java | 26 +-- .../apache/fop/tools/EventConventionException.java | 2 +- .../apache/fop/tools/EventProducerCollector.java | 18 +- .../fop/tools/EventProducerCollectorTask.java | 23 ++- .../fop/text/linebreak/GenerateLineBreakUtils.java | 14 +- src/documentation/content/xdocs/DnI/BookMaker.java | 20 +- src/documentation/content/xdocs/trunk/anttask.xml | 2 +- src/java/org/apache/fop/Version.java | 8 +- src/java/org/apache/fop/apps/FOPException.java | 14 +- src/java/org/apache/fop/apps/FOURIResolver.java | 26 +-- src/java/org/apache/fop/apps/FOUserAgent.java | 10 +- src/java/org/apache/fop/apps/Fop.java | 18 +- src/java/org/apache/fop/apps/FopFactory.java | 14 +- .../apache/fop/apps/FopFactoryConfigurator.java | 4 +- .../org/apache/fop/apps/FormattingResults.java | 4 +- .../org/apache/fop/apps/PageSequenceResults.java | 4 +- .../apache/fop/area/AbstractOffDocumentItem.java | 10 +- src/java/org/apache/fop/area/Area.java | 36 ++-- .../org/apache/fop/area/AreaEventProducer.java | 12 +- src/java/org/apache/fop/area/AreaTreeHandler.java | 58 +++--- src/java/org/apache/fop/area/AreaTreeModel.java | 10 +- src/java/org/apache/fop/area/AreaTreeObject.java | 10 +- src/java/org/apache/fop/area/AreaTreeParser.java | 78 +++---- src/java/org/apache/fop/area/BeforeFloat.java | 6 +- src/java/org/apache/fop/area/Block.java | 10 +- src/java/org/apache/fop/area/BlockParent.java | 8 +- src/java/org/apache/fop/area/BlockViewport.java | 6 +- src/java/org/apache/fop/area/BodyRegion.java | 8 +- src/java/org/apache/fop/area/BookmarkData.java | 10 +- src/java/org/apache/fop/area/CTM.java | 8 +- .../apache/fop/area/CachedRenderPagesModel.java | 12 +- src/java/org/apache/fop/area/DestinationData.java | 6 +- src/java/org/apache/fop/area/Footnote.java | 6 +- src/java/org/apache/fop/area/IDTracker.java | 36 ++-- src/java/org/apache/fop/area/LineArea.java | 22 +- src/java/org/apache/fop/area/LinkResolver.java | 6 +- src/java/org/apache/fop/area/MainReference.java | 8 +- src/java/org/apache/fop/area/NormalFlow.java | 8 +- .../fop/area/OffDocumentExtensionAttachment.java | 6 +- src/java/org/apache/fop/area/OffDocumentItem.java | 10 +- src/java/org/apache/fop/area/Page.java | 30 +-- src/java/org/apache/fop/area/PageSequence.java | 16 +- src/java/org/apache/fop/area/PageViewport.java | 110 +++++----- src/java/org/apache/fop/area/RegionReference.java | 18 +- src/java/org/apache/fop/area/RegionViewport.java | 10 +- src/java/org/apache/fop/area/RenderPagesModel.java | 16 +- src/java/org/apache/fop/area/Resolvable.java | 8 +- src/java/org/apache/fop/area/Span.java | 44 ++-- src/java/org/apache/fop/area/Trait.java | 20 +- .../apache/fop/area/inline/AbstractTextArea.java | 18 +- src/java/org/apache/fop/area/inline/Anchor.java | 6 +- src/java/org/apache/fop/area/inline/Container.java | 6 +- .../org/apache/fop/area/inline/FilledArea.java | 12 +- .../org/apache/fop/area/inline/ForeignObject.java | 12 +- src/java/org/apache/fop/area/inline/Image.java | 6 +- .../org/apache/fop/area/inline/InlineArea.java | 38 ++-- .../apache/fop/area/inline/InlineBlockParent.java | 4 +- .../org/apache/fop/area/inline/InlineParent.java | 8 +- src/java/org/apache/fop/area/inline/Leader.java | 8 +- src/java/org/apache/fop/area/inline/Space.java | 4 +- src/java/org/apache/fop/area/inline/SpaceArea.java | 4 +- src/java/org/apache/fop/area/inline/TextArea.java | 24 +-- .../fop/area/inline/UnresolvedPageNumber.java | 14 +- src/java/org/apache/fop/area/inline/Viewport.java | 6 +- src/java/org/apache/fop/area/inline/WordArea.java | 8 +- .../org/apache/fop/cli/AreaTreeInputHandler.java | 12 +- src/java/org/apache/fop/cli/ImageInputHandler.java | 4 +- .../org/apache/fop/datatypes/CompoundDatatype.java | 8 +- src/java/org/apache/fop/datatypes/FODimension.java | 6 +- src/java/org/apache/fop/datatypes/KeepValue.java | 4 +- src/java/org/apache/fop/datatypes/Length.java | 6 +- src/java/org/apache/fop/datatypes/LengthBase.java | 10 +- src/java/org/apache/fop/datatypes/Numeric.java | 14 +- src/java/org/apache/fop/datatypes/PercentBase.java | 16 +- .../apache/fop/datatypes/PercentBaseContext.java | 8 +- .../fop/datatypes/SimplePercentBaseContext.java | 10 +- .../org/apache/fop/datatypes/URISpecification.java | 14 +- .../datatypes/ValidationPercentBaseContext.java | 14 +- .../apache/fop/events/CompositeEventListener.java | 6 +- .../apache/fop/events/DefaultEventBroadcaster.java | 16 +- src/java/org/apache/fop/events/Event.java | 24 +-- .../org/apache/fop/events/EventBroadcaster.java | 10 +- .../apache/fop/events/EventExceptionManager.java | 10 +- src/java/org/apache/fop/events/EventFormatter.java | 24 +-- src/java/org/apache/fop/events/EventListener.java | 2 +- .../apache/fop/events/FOPEventListenerProxy.java | 10 +- .../apache/fop/events/LoggingEventListener.java | 12 +- .../fop/events/PropertyExceptionFactory.java | 4 +- .../apache/fop/events/ResourceEventProducer.java | 12 +- .../UnsupportedOperationExceptionFactory.java | 4 +- .../fop/events/ValidationExceptionFactory.java | 6 +- .../events/model/AbstractEventModelFactory.java | 6 +- .../apache/fop/events/model/EventModelFactory.java | 2 +- .../apache/fop/events/model/EventModelParser.java | 6 +- .../org/apache/fop/events/model/EventSeverity.java | 12 +- src/java/org/apache/fop/fo/CharIterator.java | 6 +- src/java/org/apache/fop/fo/Constants.java | 6 +- src/java/org/apache/fop/fo/ElementMapping.java | 10 +- .../org/apache/fop/fo/ElementMappingRegistry.java | 14 +- src/java/org/apache/fop/fo/FOElementMapping.java | 12 +- src/java/org/apache/fop/fo/FOEventHandler.java | 26 +-- src/java/org/apache/fop/fo/FONode.java | 8 +- src/java/org/apache/fop/fo/FOPropertyMapping.java | 14 +- src/java/org/apache/fop/fo/FOText.java | 4 +- src/java/org/apache/fop/fo/FOTreeBuilder.java | 88 ++++---- .../org/apache/fop/fo/FOTreeBuilderContext.java | 28 +-- .../apache/fop/fo/FOValidationEventProducer.java | 16 +- src/java/org/apache/fop/fo/FObj.java | 114 +++++------ src/java/org/apache/fop/fo/FObjMixed.java | 10 +- src/java/org/apache/fop/fo/GraphicsProperties.java | 6 +- src/java/org/apache/fop/fo/InlineCharIterator.java | 4 +- src/java/org/apache/fop/fo/NullCharIterator.java | 6 +- src/java/org/apache/fop/fo/OneCharIterator.java | 4 +- src/java/org/apache/fop/fo/PropertyList.java | 102 +++++----- src/java/org/apache/fop/fo/PropertyListMaker.java | 6 +- .../org/apache/fop/fo/RecursiveCharIterator.java | 4 +- src/java/org/apache/fop/fo/StaticPropertyList.java | 10 +- src/java/org/apache/fop/fo/UnknownXMLObj.java | 4 +- .../org/apache/fop/fo/ValidationException.java | 4 +- src/java/org/apache/fop/fo/XMLObj.java | 28 +-- .../org/apache/fop/fo/XMLWhiteSpaceHandler.java | 78 +++---- src/java/org/apache/fop/fo/expr/AbsFunction.java | 4 +- .../org/apache/fop/fo/expr/BodyStartFunction.java | 4 +- .../org/apache/fop/fo/expr/CMYKcolorFunction.java | 18 +- .../org/apache/fop/fo/expr/CeilingFunction.java | 6 +- src/java/org/apache/fop/fo/expr/FloorFunction.java | 6 +- .../org/apache/fop/fo/expr/FromParentFunction.java | 4 +- .../fop/fo/expr/FromTableColumnFunction.java | 4 +- src/java/org/apache/fop/fo/expr/Function.java | 4 +- src/java/org/apache/fop/fo/expr/FunctionBase.java | 4 +- .../org/apache/fop/fo/expr/ICCColorFunction.java | 38 ++-- .../apache/fop/fo/expr/InheritedPropFunction.java | 4 +- .../org/apache/fop/fo/expr/LabelEndFunction.java | 10 +- src/java/org/apache/fop/fo/expr/MaxFunction.java | 4 +- src/java/org/apache/fop/fo/expr/MinFunction.java | 4 +- .../org/apache/fop/fo/expr/NCnameProperty.java | 12 +- .../fop/fo/expr/NearestSpecPropFunction.java | 4 +- src/java/org/apache/fop/fo/expr/NumericOp.java | 46 ++--- .../org/apache/fop/fo/expr/NumericProperty.java | 8 +- .../org/apache/fop/fo/expr/PPColWidthFunction.java | 12 +- .../org/apache/fop/fo/expr/PropertyException.java | 6 +- src/java/org/apache/fop/fo/expr/PropertyInfo.java | 14 +- .../org/apache/fop/fo/expr/PropertyParser.java | 32 +-- .../org/apache/fop/fo/expr/PropertyTokenizer.java | 4 +- .../org/apache/fop/fo/expr/RGBColorFunction.java | 12 +- .../fop/fo/expr/RelativeNumericProperty.java | 26 +-- src/java/org/apache/fop/fo/expr/RoundFunction.java | 6 +- .../apache/fop/fo/expr/SystemColorFunction.java | 12 +- .../fop/fo/extensions/ExtensionAttachment.java | 2 +- .../fop/fo/extensions/ExtensionElementMapping.java | 16 +- .../org/apache/fop/fo/extensions/ExtensionObj.java | 10 +- .../apache/fop/fo/extensions/ExternalDocument.java | 6 +- .../fo/extensions/OldExtensionElementMapping.java | 6 +- .../fop/fo/extensions/destination/Destination.java | 8 +- .../svg/BatikExtensionElementMapping.java | 8 +- .../apache/fop/fo/extensions/svg/SVGElement.java | 16 +- .../fop/fo/extensions/svg/SVGElementMapping.java | 10 +- .../org/apache/fop/fo/extensions/svg/SVGObj.java | 8 +- .../fo/extensions/xmp/AbstractMetadataElement.java | 8 +- .../apache/fop/fo/extensions/xmp/RDFElement.java | 2 +- .../fop/fo/extensions/xmp/RDFElementMapping.java | 6 +- .../extensions/xmp/XMPContentHandlerFactory.java | 10 +- .../fop/fo/extensions/xmp/XMPElementMapping.java | 6 +- .../fop/fo/extensions/xmp/XMPMetaElement.java | 2 +- .../apache/fop/fo/extensions/xmp/XMPMetadata.java | 14 +- .../org/apache/fop/fo/flow/AbstractGraphics.java | 4 +- .../apache/fop/fo/flow/AbstractListItemPart.java | 8 +- .../fop/fo/flow/AbstractPageNumberCitation.java | 32 +-- .../apache/fop/fo/flow/AbstractRetrieveMarker.java | 4 +- src/java/org/apache/fop/fo/flow/BasicLink.java | 16 +- src/java/org/apache/fop/fo/flow/BidiOverride.java | 14 +- src/java/org/apache/fop/fo/flow/Block.java | 24 +-- .../org/apache/fop/fo/flow/BlockContainer.java | 20 +- src/java/org/apache/fop/fo/flow/Character.java | 34 ++-- .../org/apache/fop/fo/flow/ExternalGraphic.java | 12 +- src/java/org/apache/fop/fo/flow/Float.java | 14 +- src/java/org/apache/fop/fo/flow/Footnote.java | 24 +-- src/java/org/apache/fop/fo/flow/FootnoteBody.java | 12 +- .../org/apache/fop/fo/flow/InitialPropertySet.java | 10 +- src/java/org/apache/fop/fo/flow/Inline.java | 22 +- .../org/apache/fop/fo/flow/InlineContainer.java | 36 ++-- src/java/org/apache/fop/fo/flow/InlineLevel.java | 16 +- .../apache/fop/fo/flow/InstreamForeignObject.java | 20 +- src/java/org/apache/fop/fo/flow/Leader.java | 14 +- src/java/org/apache/fop/fo/flow/ListBlock.java | 16 +- src/java/org/apache/fop/fo/flow/ListItem.java | 14 +- src/java/org/apache/fop/fo/flow/ListItemBody.java | 8 +- src/java/org/apache/fop/fo/flow/ListItemLabel.java | 8 +- src/java/org/apache/fop/fo/flow/Marker.java | 88 ++++---- src/java/org/apache/fop/fo/flow/MultiCase.java | 6 +- .../org/apache/fop/fo/flow/MultiProperties.java | 10 +- .../org/apache/fop/fo/flow/MultiPropertySet.java | 10 +- src/java/org/apache/fop/fo/flow/MultiSwitch.java | 8 +- src/java/org/apache/fop/fo/flow/MultiToggle.java | 12 +- src/java/org/apache/fop/fo/flow/PageNumber.java | 24 +-- .../org/apache/fop/fo/flow/PageNumberCitation.java | 6 +- .../apache/fop/fo/flow/PageNumberCitationLast.java | 10 +- .../org/apache/fop/fo/flow/RetrieveMarker.java | 6 +- .../apache/fop/fo/flow/RetrieveTableMarker.java | 4 +- src/java/org/apache/fop/fo/flow/Wrapper.java | 18 +- .../apache/fop/fo/flow/table/BorderResolver.java | 8 +- .../fop/fo/flow/table/BorderSpecification.java | 10 +- .../fo/flow/table/CollapsingBorderResolver.java | 18 +- .../fop/fo/flow/table/ColumnNumberManager.java | 12 +- .../fo/flow/table/ColumnNumberManagerHolder.java | 6 +- .../fop/fo/flow/table/ConditionalBorder.java | 16 +- src/java/org/apache/fop/fo/flow/table/EffRow.java | 42 ++-- .../fop/fo/flow/table/FixedColRowGroupBuilder.java | 4 +- .../org/apache/fop/fo/flow/table/GridUnit.java | 36 ++-- .../org/apache/fop/fo/flow/table/PendingSpan.java | 6 +- .../apache/fop/fo/flow/table/PrimaryGridUnit.java | 26 +-- .../apache/fop/fo/flow/table/RowGroupBuilder.java | 20 +- .../fop/fo/flow/table/SeparateBorderResolver.java | 4 +- src/java/org/apache/fop/fo/flow/table/Table.java | 20 +- .../apache/fop/fo/flow/table/TableAndCaption.java | 8 +- .../org/apache/fop/fo/flow/table/TableBody.java | 4 +- .../org/apache/fop/fo/flow/table/TableCaption.java | 6 +- .../org/apache/fop/fo/flow/table/TableCell.java | 10 +- .../fop/fo/flow/table/TableCellContainer.java | 6 +- .../org/apache/fop/fo/flow/table/TableColumn.java | 4 +- .../fop/fo/flow/table/TableEventProducer.java | 8 +- .../org/apache/fop/fo/flow/table/TableFObj.java | 6 +- .../org/apache/fop/fo/flow/table/TableFooter.java | 4 +- .../org/apache/fop/fo/flow/table/TableHeader.java | 4 +- .../org/apache/fop/fo/flow/table/TablePart.java | 8 +- .../org/apache/fop/fo/flow/table/TableRow.java | 6 +- .../fo/flow/table/VariableColRowGroupBuilder.java | 6 +- .../fop/fo/pagination/AbstractPageSequence.java | 10 +- .../org/apache/fop/fo/pagination/ColorProfile.java | 20 +- .../pagination/ConditionalPageMasterReference.java | 20 +- .../org/apache/fop/fo/pagination/Declarations.java | 22 +- src/java/org/apache/fop/fo/pagination/Flow.java | 12 +- .../apache/fop/fo/pagination/LayoutMasterSet.java | 12 +- .../fop/fo/pagination/PageNumberGenerator.java | 6 +- .../fop/fo/pagination/PageProductionException.java | 18 +- .../org/apache/fop/fo/pagination/PageSequence.java | 44 ++-- .../fop/fo/pagination/PageSequenceMaster.java | 24 +-- .../fop/fo/pagination/PageSequenceWrapper.java | 8 +- src/java/org/apache/fop/fo/pagination/Region.java | 18 +- .../org/apache/fop/fo/pagination/RegionAfter.java | 10 +- .../org/apache/fop/fo/pagination/RegionBA.java | 6 +- .../org/apache/fop/fo/pagination/RegionBefore.java | 10 +- .../org/apache/fop/fo/pagination/RegionBody.java | 14 +- .../org/apache/fop/fo/pagination/RegionEnd.java | 12 +- .../org/apache/fop/fo/pagination/RegionSE.java | 4 +- .../org/apache/fop/fo/pagination/RegionStart.java | 10 +- .../RepeatablePageMasterAlternatives.java | 14 +- .../pagination/RepeatablePageMasterReference.java | 18 +- src/java/org/apache/fop/fo/pagination/Root.java | 48 ++--- .../org/apache/fop/fo/pagination/SideRegion.java | 6 +- .../apache/fop/fo/pagination/SimplePageMaster.java | 12 +- .../fo/pagination/SinglePageMasterReference.java | 22 +- .../apache/fop/fo/pagination/StaticContent.java | 6 +- .../fop/fo/pagination/SubSequenceSpecifier.java | 12 +- src/java/org/apache/fop/fo/pagination/Title.java | 6 +- .../fop/fo/pagination/bookmarks/Bookmark.java | 16 +- .../fop/fo/pagination/bookmarks/BookmarkTitle.java | 10 +- .../fop/fo/pagination/bookmarks/BookmarkTree.java | 6 +- .../fo/properties/BackgroundPositionShorthand.java | 30 +-- .../fo/properties/BorderWidthPropertyMaker.java | 18 +- .../fop/fo/properties/BoxPropShorthandParser.java | 4 +- .../fop/fo/properties/CharacterProperty.java | 12 +- .../apache/fop/fo/properties/ColorProperty.java | 28 +-- .../fop/fo/properties/CommonAbsolutePosition.java | 12 +- .../fop/fo/properties/CommonAccessibility.java | 6 +- .../org/apache/fop/fo/properties/CommonAural.java | 4 +- .../properties/CommonBorderPaddingBackground.java | 76 +++---- .../org/apache/fop/fo/properties/CommonFont.java | 72 +++---- .../fop/fo/properties/CommonHyphenation.java | 72 +++---- .../fop/fo/properties/CommonMarginBlock.java | 18 +- .../fop/fo/properties/CommonMarginInline.java | 4 +- .../fop/fo/properties/CommonRelativePosition.java | 12 +- .../fop/fo/properties/CommonTextDecoration.java | 20 +- .../fop/fo/properties/CompoundPropertyMaker.java | 44 ++-- .../fop/fo/properties/CondLengthProperty.java | 30 +-- .../fo/properties/CorrespondingPropertyMaker.java | 26 +-- .../fop/fo/properties/DimensionPropertyMaker.java | 18 +- .../org/apache/fop/fo/properties/EnumLength.java | 8 +- .../org/apache/fop/fo/properties/EnumNumber.java | 32 +-- .../org/apache/fop/fo/properties/EnumProperty.java | 8 +- .../org/apache/fop/fo/properties/FixedLength.java | 40 ++-- .../fop/fo/properties/FontFamilyProperty.java | 14 +- .../fop/fo/properties/FontShorthandParser.java | 8 +- .../fop/fo/properties/FontShorthandProperty.java | 34 ++-- .../fop/fo/properties/FontSizePropertyMaker.java | 22 +- .../fo/properties/FontStretchPropertyMaker.java | 16 +- .../fop/fo/properties/FontWeightPropertyMaker.java | 8 +- .../fop/fo/properties/GenericShorthandParser.java | 10 +- .../fop/fo/properties/IndentPropertyMaker.java | 46 ++--- .../org/apache/fop/fo/properties/KeepProperty.java | 24 +-- .../fop/fo/properties/LengthPairProperty.java | 20 +- .../apache/fop/fo/properties/LengthProperty.java | 10 +- .../fop/fo/properties/LengthRangeProperty.java | 42 ++-- .../fop/fo/properties/LineHeightPropertyMaker.java | 14 +- .../org/apache/fop/fo/properties/ListProperty.java | 6 +- .../apache/fop/fo/properties/NumberProperty.java | 28 +-- .../fo/properties/PageBreakShorthandParser.java | 12 +- .../fop/fo/properties/PageDimensionMaker.java | 34 ++-- .../apache/fop/fo/properties/PercentLength.java | 20 +- .../fop/fo/properties/PositionShorthandParser.java | 10 +- .../org/apache/fop/fo/properties/Property.java | 8 +- .../apache/fop/fo/properties/PropertyCache.java | 134 ++++++------ .../apache/fop/fo/properties/PropertyMaker.java | 60 +++--- .../fo/properties/ReferenceOrientationMaker.java | 14 +- .../apache/fop/fo/properties/ShorthandParser.java | 4 +- .../apache/fop/fo/properties/SpaceProperty.java | 16 +- .../fop/fo/properties/SpacingPropertyMaker.java | 8 +- .../apache/fop/fo/properties/StringProperty.java | 16 +- .../fop/fo/properties/TableBorderPrecedence.java | 8 +- .../apache/fop/fo/properties/TableColLength.java | 6 +- .../fop/fo/properties/TextDecorationProperty.java | 4 +- .../fop/fo/properties/ToBeImplementedProperty.java | 4 +- .../properties/VerticalAlignShorthandParser.java | 8 +- .../fo/properties/WhiteSpaceShorthandParser.java | 6 +- .../fop/fo/properties/XMLLangShorthandParser.java | 4 +- .../apache/fop/fonts/AbstractCodePointMapping.java | 20 +- src/java/org/apache/fop/fonts/BFEntry.java | 8 +- src/java/org/apache/fop/fonts/Base14Font.java | 6 +- src/java/org/apache/fop/fonts/CIDFont.java | 4 +- src/java/org/apache/fop/fonts/CIDFontType.java | 12 +- src/java/org/apache/fop/fonts/CIDSubset.java | 20 +- src/java/org/apache/fop/fonts/CustomFont.java | 26 +-- src/java/org/apache/fop/fonts/EmbedFontInfo.java | 4 +- src/java/org/apache/fop/fonts/Font.java | 4 +- src/java/org/apache/fop/fonts/FontCache.java | 4 +- src/java/org/apache/fop/fonts/FontCollection.java | 4 +- src/java/org/apache/fop/fonts/FontDescriptor.java | 4 +- .../org/apache/fop/fonts/FontEventAdapter.java | 14 +- .../org/apache/fop/fonts/FontEventListener.java | 8 +- src/java/org/apache/fop/fonts/FontInfo.java | 20 +- src/java/org/apache/fop/fonts/FontLoader.java | 16 +- .../apache/fop/fonts/FontManagerConfigurator.java | 4 +- src/java/org/apache/fop/fonts/FontMetrics.java | 34 ++-- src/java/org/apache/fop/fonts/FontReader.java | 10 +- src/java/org/apache/fop/fonts/FontResolver.java | 2 +- src/java/org/apache/fop/fonts/FontSelector.java | 10 +- src/java/org/apache/fop/fonts/FontSetup.java | 4 +- src/java/org/apache/fop/fonts/FontTriplet.java | 4 +- src/java/org/apache/fop/fonts/FontType.java | 12 +- src/java/org/apache/fop/fonts/FontUtil.java | 4 +- src/java/org/apache/fop/fonts/Glyphs.java | 10 +- src/java/org/apache/fop/fonts/LazyFont.java | 24 +-- src/java/org/apache/fop/fonts/MultiByteFont.java | 18 +- src/java/org/apache/fop/fonts/MutableFont.java | 32 +-- src/java/org/apache/fop/fonts/NamedCharacter.java | 20 +- .../apache/fop/fonts/SimpleSingleByteEncoding.java | 24 +-- .../org/apache/fop/fonts/SingleByteEncoding.java | 6 +- src/java/org/apache/fop/fonts/SingleByteFont.java | 38 ++-- src/java/org/apache/fop/fonts/Typeface.java | 20 +- .../apache/fop/fonts/apps/AbstractFontReader.java | 18 +- src/java/org/apache/fop/fonts/apps/PFMReader.java | 16 +- src/java/org/apache/fop/fonts/apps/TTFReader.java | 40 ++-- .../fop/fonts/autodetect/FontFileFinder.java | 8 +- .../apache/fop/fonts/autodetect/FontFinder.java | 10 +- .../fop/fonts/autodetect/FontInfoFinder.java | 8 +- .../fop/fonts/autodetect/MacFontDirFinder.java | 6 +- .../fop/fonts/autodetect/NativeFontDirFinder.java | 12 +- .../fop/fonts/autodetect/UnixFontDirFinder.java | 6 +- .../fop/fonts/autodetect/WindowsFontDirFinder.java | 10 +- .../fop/fonts/base14/Base14FontCollection.java | 6 +- .../fop/fonts/substitute/AttributeValue.java | 6 +- .../apache/fop/fonts/substitute/FontQualifier.java | 6 +- .../fop/fonts/substitute/FontSubstitution.java | 6 +- .../fop/fonts/substitute/FontSubstitutions.java | 4 +- .../substitute/FontSubstitutionsConfigurator.java | 8 +- .../fop/fonts/substitute/FontWeightRange.java | 6 +- .../apache/fop/fonts/truetype/FontFileReader.java | 6 +- .../apache/fop/fonts/truetype/TTFCmapEntry.java | 6 +- .../apache/fop/fonts/truetype/TTFDirTabEntry.java | 6 +- .../org/apache/fop/fonts/truetype/TTFFile.java | 60 +++--- .../apache/fop/fonts/truetype/TTFFontLoader.java | 28 +-- .../org/apache/fop/fonts/truetype/TTFMtxEntry.java | 12 +- .../apache/fop/fonts/truetype/TTFSubSetFile.java | 10 +- .../org/apache/fop/fonts/type1/AFMCharMetrics.java | 32 +-- src/java/org/apache/fop/fonts/type1/AFMFile.java | 50 ++--- src/java/org/apache/fop/fonts/type1/AFMParser.java | 142 ++++++------- .../fonts/type1/AFMWritingDirectionMetrics.java | 24 +-- src/java/org/apache/fop/fonts/type1/PFBData.java | 12 +- src/java/org/apache/fop/fonts/type1/PFBParser.java | 10 +- src/java/org/apache/fop/fonts/type1/PFMFile.java | 10 +- .../org/apache/fop/fonts/type1/PFMInputStream.java | 8 +- .../apache/fop/fonts/type1/Type1FontLoader.java | 30 +-- .../org/apache/fop/hyphenation/ByteVector.java | 6 +- .../org/apache/fop/hyphenation/CharVector.java | 6 +- src/java/org/apache/fop/hyphenation/Hyphen.java | 10 +- .../org/apache/fop/hyphenation/Hyphenation.java | 8 +- .../fop/hyphenation/HyphenationException.java | 4 +- .../apache/fop/hyphenation/HyphenationTree.java | 10 +- .../fop/hyphenation/HyphenationTreeCache.java | 18 +- .../fop/hyphenation/HyphenationTreeResolver.java | 2 +- .../org/apache/fop/hyphenation/Hyphenator.java | 32 +-- .../apache/fop/hyphenation/PatternConsumer.java | 6 +- .../org/apache/fop/hyphenation/PatternParser.java | 18 +- .../org/apache/fop/hyphenation/TernaryTree.java | 4 +- .../apache/fop/image/loader/batik/BatikUtil.java | 6 +- .../image/loader/batik/ImageConverterSVG2G2D.java | 10 +- .../image/loader/batik/ImageConverterWMF2G2D.java | 18 +- .../image/loader/batik/ImageLoaderFactorySVG.java | 14 +- .../image/loader/batik/ImageLoaderFactoryWMF.java | 14 +- .../fop/image/loader/batik/ImageLoaderSVG.java | 6 +- .../fop/image/loader/batik/ImageLoaderWMF.java | 6 +- .../apache/fop/image/loader/batik/ImageWMF.java | 14 +- .../fop/image/loader/batik/PreloaderSVG.java | 18 +- .../fop/image/loader/batik/PreloaderWMF.java | 18 +- .../fop/layoutmgr/AbstractBaseLayoutManager.java | 28 +-- .../org/apache/fop/layoutmgr/AbstractBreaker.java | 122 +++++------ .../fop/layoutmgr/AbstractLayoutManager.java | 20 +- .../AbstractPageSequenceLayoutManager.java | 70 +++---- .../org/apache/fop/layoutmgr/AreaAdditionUtil.java | 22 +- .../BalancingColumnBreakingAlgorithm.java | 16 +- .../fop/layoutmgr/BlockContainerLayoutManager.java | 196 +++++++++--------- .../apache/fop/layoutmgr/BlockKnuthSequence.java | 8 +- .../apache/fop/layoutmgr/BlockLayoutManager.java | 56 ++--- .../fop/layoutmgr/BlockLevelEventProducer.java | 26 +-- .../fop/layoutmgr/BlockLevelLayoutManager.java | 12 +- .../fop/layoutmgr/BlockStackingLayoutManager.java | 226 ++++++++++----------- .../org/apache/fop/layoutmgr/BorderElement.java | 6 +- .../fop/layoutmgr/BorderOrPaddingElement.java | 6 +- .../org/apache/fop/layoutmgr/BreakElement.java | 32 +-- .../apache/fop/layoutmgr/BreakingAlgorithm.java | 102 +++++----- .../fop/layoutmgr/ConditionalElementListener.java | 2 +- .../apache/fop/layoutmgr/ElementListObserver.java | 16 +- .../org/apache/fop/layoutmgr/ElementListUtils.java | 6 +- .../layoutmgr/ExternalDocumentLayoutManager.java | 54 ++--- .../apache/fop/layoutmgr/FlowLayoutManager.java | 30 +-- .../fop/layoutmgr/FootnoteBodyLayoutManager.java | 8 +- .../apache/fop/layoutmgr/InlineKnuthSequence.java | 8 +- src/java/org/apache/fop/layoutmgr/KeepUtil.java | 14 +- .../org/apache/fop/layoutmgr/KnuthBlockBox.java | 8 +- src/java/org/apache/fop/layoutmgr/KnuthBox.java | 12 +- .../org/apache/fop/layoutmgr/KnuthElement.java | 14 +- src/java/org/apache/fop/layoutmgr/KnuthGlue.java | 22 +- .../org/apache/fop/layoutmgr/KnuthPenalty.java | 24 +-- .../org/apache/fop/layoutmgr/KnuthPossPosIter.java | 8 +- .../org/apache/fop/layoutmgr/KnuthSequence.java | 24 +-- src/java/org/apache/fop/layoutmgr/LMiter.java | 4 +- .../org/apache/fop/layoutmgr/LayoutContext.java | 90 ++++---- .../org/apache/fop/layoutmgr/LayoutException.java | 16 +- .../org/apache/fop/layoutmgr/LayoutManager.java | 38 ++-- .../apache/fop/layoutmgr/LayoutManagerMaker.java | 6 +- .../apache/fop/layoutmgr/LayoutManagerMapping.java | 28 +-- .../org/apache/fop/layoutmgr/LeafPosition.java | 10 +- src/java/org/apache/fop/layoutmgr/ListElement.java | 14 +- .../org/apache/fop/layoutmgr/MinOptMaxUtil.java | 18 +- .../org/apache/fop/layoutmgr/NonLeafPosition.java | 10 +- .../org/apache/fop/layoutmgr/PaddingElement.java | 6 +- src/java/org/apache/fop/layoutmgr/Page.java | 14 +- src/java/org/apache/fop/layoutmgr/PageBreaker.java | 106 +++++----- .../fop/layoutmgr/PageBreakingAlgorithm.java | 60 +++--- .../org/apache/fop/layoutmgr/PageProvider.java | 40 ++-- .../fop/layoutmgr/PageSequenceLayoutManager.java | 20 +- src/java/org/apache/fop/layoutmgr/Position.java | 18 +- .../org/apache/fop/layoutmgr/PositionIterator.java | 8 +- src/java/org/apache/fop/layoutmgr/RelSide.java | 6 +- .../org/apache/fop/layoutmgr/SpaceElement.java | 18 +- .../org/apache/fop/layoutmgr/SpaceResolver.java | 118 +++++------ .../org/apache/fop/layoutmgr/SpaceSpecifier.java | 8 +- .../fop/layoutmgr/StaticContentLayoutManager.java | 84 ++++---- .../fop/layoutmgr/TopLevelLayoutManager.java | 6 +- src/java/org/apache/fop/layoutmgr/TraitSetter.java | 66 +++--- .../fop/layoutmgr/UnresolvedListElement.java | 6 +- .../layoutmgr/UnresolvedListElementWithLength.java | 22 +- .../inline/AbstractGraphicsLayoutManager.java | 28 +-- .../AbstractPageNumberCitationLayoutManager.java | 24 +-- .../fop/layoutmgr/inline/AlignmentContext.java | 64 +++--- .../layoutmgr/inline/BasicLinkLayoutManager.java | 4 +- .../layoutmgr/inline/BasicScaledBaselineTable.java | 22 +- .../fop/layoutmgr/inline/BidiLayoutManager.java | 4 +- .../layoutmgr/inline/CharacterLayoutManager.java | 12 +- .../fop/layoutmgr/inline/ContentLayoutManager.java | 18 +- .../inline/ExternalGraphicLayoutManager.java | 10 +- .../layoutmgr/inline/FootnoteLayoutManager.java | 16 +- .../apache/fop/layoutmgr/inline/HyphContext.java | 6 +- .../fop/layoutmgr/inline/ICLayoutManager.java | 4 +- .../apache/fop/layoutmgr/inline/ImageLayout.java | 40 ++-- .../fop/layoutmgr/inline/InlineLayoutManager.java | 94 ++++----- .../layoutmgr/inline/InlineLevelEventProducer.java | 6 +- .../layoutmgr/inline/InlineLevelLayoutManager.java | 10 +- .../inline/InlineStackingLayoutManager.java | 14 +- .../layoutmgr/inline/InstreamForeignObjectLM.java | 10 +- .../fop/layoutmgr/inline/KnuthInlineBox.java | 10 +- .../fop/layoutmgr/inline/LeaderLayoutManager.java | 34 ++-- .../layoutmgr/inline/LeafNodeLayoutManager.java | 32 +-- .../fop/layoutmgr/inline/LineLayoutManager.java | 212 +++++++++---------- .../layoutmgr/inline/LineLayoutPossibilities.java | 14 +- .../PageNumberCitationLastLayoutManager.java | 14 +- .../inline/PageNumberCitationLayoutManager.java | 12 +- .../layoutmgr/inline/PageNumberLayoutManager.java | 18 +- .../fop/layoutmgr/inline/ScaledBaselineTable.java | 16 +- .../inline/ScaledBaselineTableFactory.java | 10 +- .../fop/layoutmgr/inline/TextLayoutManager.java | 2 +- .../fop/layoutmgr/inline/WrapperLayoutManager.java | 6 +- .../fop/layoutmgr/list/ListBlockLayoutManager.java | 60 +++--- .../list/ListItemContentLayoutManager.java | 22 +- .../fop/layoutmgr/list/ListItemLayoutManager.java | 110 +++++----- .../org/apache/fop/layoutmgr/table/ActiveCell.java | 30 +-- .../org/apache/fop/layoutmgr/table/CellPart.java | 2 +- .../fop/layoutmgr/table/CollapsingBorderModel.java | 8 +- .../table/CollapsingBorderModelEyeCatching.java | 2 +- .../apache/fop/layoutmgr/table/ColumnSetup.java | 42 ++-- .../fop/layoutmgr/table/RowGroupLayoutManager.java | 20 +- .../org/apache/fop/layoutmgr/table/RowPainter.java | 20 +- .../table/TableAndCaptionLayoutManager.java | 14 +- .../layoutmgr/table/TableCaptionLayoutManager.java | 12 +- .../layoutmgr/table/TableCellLayoutManager.java | 16 +- .../layoutmgr/table/TableContentLayoutManager.java | 62 +++--- .../fop/layoutmgr/table/TableContentPosition.java | 2 +- .../fop/layoutmgr/table/TableLayoutManager.java | 82 ++++---- .../apache/fop/layoutmgr/table/TableStepper.java | 22 +- src/java/org/apache/fop/pdf/ASCII85Filter.java | 8 +- src/java/org/apache/fop/pdf/ASCIIHexFilter.java | 10 +- src/java/org/apache/fop/pdf/AbstractPDFStream.java | 34 ++-- src/java/org/apache/fop/pdf/AlphaRasterImage.java | 16 +- src/java/org/apache/fop/pdf/BitmapImage.java | 10 +- src/java/org/apache/fop/pdf/CCFFilter.java | 6 +- src/java/org/apache/fop/pdf/CMapBuilder.java | 16 +- src/java/org/apache/fop/pdf/DCTFilter.java | 6 +- src/java/org/apache/fop/pdf/FlateFilter.java | 6 +- .../org/apache/fop/pdf/InMemoryStreamCache.java | 8 +- src/java/org/apache/fop/pdf/NullFilter.java | 6 +- src/java/org/apache/fop/pdf/PDFAMode.java | 10 +- src/java/org/apache/fop/pdf/PDFAction.java | 6 +- src/java/org/apache/fop/pdf/PDFAnnotList.java | 6 +- src/java/org/apache/fop/pdf/PDFArray.java | 34 ++-- src/java/org/apache/fop/pdf/PDFCIDFont.java | 16 +- .../org/apache/fop/pdf/PDFCIDFontDescriptor.java | 6 +- src/java/org/apache/fop/pdf/PDFCIDSystemInfo.java | 6 +- src/java/org/apache/fop/pdf/PDFCMap.java | 8 +- src/java/org/apache/fop/pdf/PDFCharProcs.java | 8 +- src/java/org/apache/fop/pdf/PDFColor.java | 64 +++--- src/java/org/apache/fop/pdf/PDFColorSpace.java | 16 +- .../apache/fop/pdf/PDFConformanceException.java | 4 +- src/java/org/apache/fop/pdf/PDFDestination.java | 8 +- .../org/apache/fop/pdf/PDFDeviceColorSpace.java | 10 +- src/java/org/apache/fop/pdf/PDFDictionary.java | 22 +- src/java/org/apache/fop/pdf/PDFDocument.java | 30 +-- src/java/org/apache/fop/pdf/PDFEncoding.java | 24 +-- src/java/org/apache/fop/pdf/PDFEncryption.java | 12 +- src/java/org/apache/fop/pdf/PDFEncryptionJCE.java | 114 +++++------ .../org/apache/fop/pdf/PDFEncryptionManager.java | 20 +- .../org/apache/fop/pdf/PDFEncryptionParams.java | 12 +- src/java/org/apache/fop/pdf/PDFFactory.java | 14 +- src/java/org/apache/fop/pdf/PDFFileSpec.java | 12 +- src/java/org/apache/fop/pdf/PDFFilter.java | 8 +- .../org/apache/fop/pdf/PDFFilterException.java | 6 +- src/java/org/apache/fop/pdf/PDFFilterList.java | 32 +-- src/java/org/apache/fop/pdf/PDFFont.java | 18 +- src/java/org/apache/fop/pdf/PDFFontDescriptor.java | 24 +-- src/java/org/apache/fop/pdf/PDFFontNonBase14.java | 14 +- src/java/org/apache/fop/pdf/PDFFontTrueType.java | 8 +- src/java/org/apache/fop/pdf/PDFFontType0.java | 12 +- src/java/org/apache/fop/pdf/PDFFontType1.java | 8 +- src/java/org/apache/fop/pdf/PDFFontType3.java | 10 +- src/java/org/apache/fop/pdf/PDFFormXObject.java | 22 +- src/java/org/apache/fop/pdf/PDFFunction.java | 4 +- src/java/org/apache/fop/pdf/PDFGState.java | 12 +- src/java/org/apache/fop/pdf/PDFGoTo.java | 8 +- src/java/org/apache/fop/pdf/PDFGoToRemote.java | 6 +- .../org/apache/fop/pdf/PDFICCBasedColorSpace.java | 10 +- src/java/org/apache/fop/pdf/PDFICCStream.java | 14 +- src/java/org/apache/fop/pdf/PDFImage.java | 12 +- src/java/org/apache/fop/pdf/PDFImageXObject.java | 20 +- src/java/org/apache/fop/pdf/PDFInfo.java | 28 +-- src/java/org/apache/fop/pdf/PDFInternalLink.java | 6 +- src/java/org/apache/fop/pdf/PDFLink.java | 6 +- src/java/org/apache/fop/pdf/PDFMetadata.java | 42 ++-- src/java/org/apache/fop/pdf/PDFName.java | 24 +-- src/java/org/apache/fop/pdf/PDFNameTreeNode.java | 10 +- src/java/org/apache/fop/pdf/PDFNames.java | 12 +- src/java/org/apache/fop/pdf/PDFNull.java | 14 +- src/java/org/apache/fop/pdf/PDFNumber.java | 16 +- src/java/org/apache/fop/pdf/PDFNumberTreeNode.java | 10 +- src/java/org/apache/fop/pdf/PDFNumsArray.java | 22 +- src/java/org/apache/fop/pdf/PDFObject.java | 56 ++--- src/java/org/apache/fop/pdf/PDFOutline.java | 12 +- src/java/org/apache/fop/pdf/PDFOutputIntent.java | 20 +- src/java/org/apache/fop/pdf/PDFPage.java | 18 +- src/java/org/apache/fop/pdf/PDFPageLabels.java | 10 +- src/java/org/apache/fop/pdf/PDFPages.java | 10 +- src/java/org/apache/fop/pdf/PDFPathPaint.java | 6 +- src/java/org/apache/fop/pdf/PDFPattern.java | 14 +- src/java/org/apache/fop/pdf/PDFProfile.java | 46 ++--- src/java/org/apache/fop/pdf/PDFRectangle.java | 6 +- src/java/org/apache/fop/pdf/PDFReference.java | 20 +- .../org/apache/fop/pdf/PDFResourceContext.java | 6 +- src/java/org/apache/fop/pdf/PDFResources.java | 16 +- src/java/org/apache/fop/pdf/PDFRoot.java | 36 ++-- src/java/org/apache/fop/pdf/PDFShading.java | 8 +- src/java/org/apache/fop/pdf/PDFState.java | 12 +- src/java/org/apache/fop/pdf/PDFStream.java | 18 +- src/java/org/apache/fop/pdf/PDFT1Stream.java | 12 +- src/java/org/apache/fop/pdf/PDFTTFStream.java | 10 +- src/java/org/apache/fop/pdf/PDFText.java | 24 +-- src/java/org/apache/fop/pdf/PDFTextUtil.java | 42 ++-- src/java/org/apache/fop/pdf/PDFToUnicodeCMap.java | 20 +- src/java/org/apache/fop/pdf/PDFUri.java | 6 +- src/java/org/apache/fop/pdf/PDFWArray.java | 12 +- src/java/org/apache/fop/pdf/PDFWritable.java | 10 +- src/java/org/apache/fop/pdf/PDFXMode.java | 8 +- src/java/org/apache/fop/pdf/PDFXObject.java | 12 +- src/java/org/apache/fop/pdf/StreamCache.java | 6 +- .../org/apache/fop/pdf/StreamCacheFactory.java | 20 +- .../org/apache/fop/pdf/TempFileStreamCache.java | 8 +- .../org/apache/fop/pdf/TransitionDictionary.java | 6 +- .../fop/render/AbstractFOEventHandlerMaker.java | 10 +- .../fop/render/AbstractGenericSVGHandler.java | 12 +- .../fop/render/AbstractGraphics2DAdapter.java | 20 +- .../fop/render/AbstractPathOrientedRenderer.java | 144 ++++++------- .../org/apache/fop/render/AbstractRenderer.java | 48 ++--- .../fop/render/AbstractRendererConfigurator.java | 4 +- .../apache/fop/render/AbstractRendererMaker.java | 8 +- .../org/apache/fop/render/DefaultFontResolver.java | 6 +- .../org/apache/fop/render/Graphics2DAdapter.java | 14 +- .../apache/fop/render/Graphics2DImagePainter.java | 6 +- src/java/org/apache/fop/render/ImageAdapter.java | 10 +- .../fop/render/PrintRendererConfigurator.java | 12 +- src/java/org/apache/fop/render/Renderer.java | 14 +- .../apache/fop/render/RendererConfigurator.java | 4 +- .../org/apache/fop/render/RendererContext.java | 16 +- .../fop/render/RendererContextConstants.java | 10 +- .../apache/fop/render/RendererEventProducer.java | 2 +- .../org/apache/fop/render/RendererFactory.java | 54 ++--- src/java/org/apache/fop/render/XMLHandler.java | 12 +- .../apache/fop/render/XMLHandlerConfigurator.java | 8 +- .../org/apache/fop/render/XMLHandlerRegistry.java | 22 +- .../apache/fop/render/afp/AFPEventProducer.java | 8 +- .../fop/render/afp/AFPGraphics2DAdapter.java | 12 +- .../fop/render/afp/AFPRendererConfigurator.java | 12 +- .../render/afp/AFPRendererContextConstants.java | 2 +- .../org/apache/fop/render/afp/AFPSVGHandler.java | 6 +- .../afp/exceptions/NestedRuntimeException.java | 26 +-- .../afp/exceptions/RendererRuntimeException.java | 6 +- .../render/afp/extensions/AFPExtensionHandler.java | 14 +- .../afp/extensions/AFPExtensionHandlerFactory.java | 2 +- .../fop/render/afp/extensions/AFPPageSetup.java | 4 +- .../afp/extensions/AbstractAFPExtensionObject.java | 4 +- .../fop/render/afp/fonts/AFPFontCollection.java | 10 +- .../apache/fop/render/afp/fonts/CharacterSet.java | 32 +-- .../fop/render/afp/fonts/FopCharacterSet.java | 2 +- .../fop/render/afp/modca/AbstractDescriptor.java | 4 +- .../render/afp/modca/AbstractNamedAFPObject.java | 6 +- .../apache/fop/render/afp/modca/MapCodedFont.java | 4 +- .../apache/fop/render/afp/modca/NoOperation.java | 26 +-- .../fop/render/afp/modca/ObjectAreaDescriptor.java | 2 +- .../org/apache/fop/render/afp/modca/Overlay.java | 2 +- .../fop/render/afp/modca/PageDescriptor.java | 16 +- .../apache/fop/render/afp/tools/BinaryUtils.java | 4 +- .../render/afp/tools/StructuredFieldReader.java | 2 +- .../org/apache/fop/render/awt/AWTRenderer.java | 24 +-- .../apache/fop/render/awt/AWTRendererMaker.java | 8 +- .../org/apache/fop/render/awt/viewer/Command.java | 6 +- .../fop/render/awt/viewer/GoToPageDialog.java | 8 +- .../fop/render/awt/viewer/ImageProxyPanel.java | 6 +- .../fop/render/awt/viewer/PreviewDialog.java | 14 +- .../apache/fop/render/awt/viewer/PreviewPanel.java | 14 +- .../apache/fop/render/awt/viewer/Renderable.java | 2 +- .../fop/render/awt/viewer/StatusListener.java | 4 +- .../apache/fop/render/awt/viewer/Translator.java | 8 +- .../render/bitmap/BitmapRendererEventProducer.java | 10 +- .../fop/render/bitmap/MultiFileRenderingUtil.java | 10 +- .../org/apache/fop/render/bitmap/PNGRenderer.java | 8 +- .../apache/fop/render/bitmap/PNGRendererMaker.java | 8 +- .../fop/render/bitmap/PNGRenderer_onthefly.java | 2 +- .../org/apache/fop/render/bitmap/TIFFRenderer.java | 12 +- .../render/bitmap/TIFFRendererConfigurator.java | 8 +- .../fop/render/bitmap/TIFFRendererMaker.java | 6 +- .../fop/render/java2d/Base14FontCollection.java | 4 +- .../fop/render/java2d/CustomFontMetricsMapper.java | 4 +- .../fop/render/java2d/FontMetricsMapper.java | 6 +- .../fop/render/java2d/InstalledFontCollection.java | 6 +- .../fop/render/java2d/Java2DFontMetrics.java | 28 +-- .../fop/render/java2d/Java2DGraphics2DAdapter.java | 14 +- .../fop/render/java2d/Java2DGraphicsState.java | 6 +- .../render/java2d/Java2DRendererConfigurator.java | 4 +- .../java2d/Java2DRendererContextConstants.java | 2 +- .../apache/fop/render/java2d/Java2DSVGHandler.java | 24 +-- .../fop/render/java2d/SystemFontMetricsMapper.java | 6 +- .../pcl/DefaultMonochromeBitmapConverter.java | 4 +- .../render/pcl/JAIMonochromeBitmapConverter.java | 12 +- .../fop/render/pcl/MonochromeBitmapConverter.java | 6 +- .../apache/fop/render/pcl/PCLEventProducer.java | 8 +- .../org/apache/fop/render/pcl/PCLGenerator.java | 152 +++++++------- .../org/apache/fop/render/pcl/PCLGraphics2D.java | 40 ++-- .../fop/render/pcl/PCLGraphics2DAdapter.java | 22 +- .../apache/fop/render/pcl/PCLPageDefinition.java | 52 ++--- .../fop/render/pcl/PCLRendererConfigurator.java | 20 +- .../apache/fop/render/pcl/PCLRendererContext.java | 18 +- .../apache/fop/render/pcl/PCLRendererMaker.java | 6 +- .../org/apache/fop/render/pcl/PCLSVGHandler.java | 8 +- .../fop/render/pdf/AbstractImageAdapter.java | 26 +-- src/java/org/apache/fop/render/pdf/CTMHelper.java | 28 +-- .../fop/render/pdf/ImageRawCCITTFaxAdapter.java | 8 +- .../apache/fop/render/pdf/ImageRawJPEGAdapter.java | 14 +- .../fop/render/pdf/ImageRenderedAdapter.java | 32 +-- .../apache/fop/render/pdf/PDFEventProducer.java | 8 +- .../fop/render/pdf/PDFGraphics2DAdapter.java | 24 +-- .../org/apache/fop/render/pdf/PDFImageHandler.java | 14 +- .../fop/render/pdf/PDFImageHandlerGraphics2D.java | 4 +- .../fop/render/pdf/PDFImageHandlerRawCCITTFax.java | 8 +- .../fop/render/pdf/PDFImageHandlerRawJPEG.java | 8 +- .../fop/render/pdf/PDFImageHandlerRegistry.java | 26 +-- .../render/pdf/PDFImageHandlerRenderedImage.java | 10 +- .../apache/fop/render/pdf/PDFImageHandlerXML.java | 4 +- .../org/apache/fop/render/pdf/PDFRenderer.java | 180 ++++++++-------- .../fop/render/pdf/PDFRendererConfigurator.java | 22 +- .../render/pdf/PDFRendererContextConstants.java | 2 +- .../apache/fop/render/pdf/PDFRendererMaker.java | 8 +- .../org/apache/fop/render/pdf/PDFSVGHandler.java | 34 ++-- .../apache/fop/render/print/PageableRenderer.java | 28 +-- .../org/apache/fop/render/print/PagesMode.java | 8 +- .../org/apache/fop/render/print/PrintRenderer.java | 22 +- .../fop/render/print/PrintRendererMaker.java | 6 +- .../apache/fop/render/ps/AbstractPSTranscoder.java | 4 +- .../org/apache/fop/render/ps/EPSTranscoder.java | 6 +- .../apache/fop/render/ps/ImageEncoderCCITTFax.java | 8 +- .../org/apache/fop/render/ps/ImageEncoderJPEG.java | 4 +- .../org/apache/fop/render/ps/PSEventProducer.java | 8 +- src/java/org/apache/fop/render/ps/PSFontUtils.java | 30 +-- .../apache/fop/render/ps/PSGraphics2DAdapter.java | 16 +- .../apache/fop/render/ps/PSImageFormResource.java | 12 +- .../org/apache/fop/render/ps/PSImageUtils.java | 6 +- src/java/org/apache/fop/render/ps/PSRenderer.java | 188 ++++++++--------- .../fop/render/ps/PSRendererConfigurator.java | 8 +- .../fop/render/ps/PSRendererContextConstants.java | 2 +- .../org/apache/fop/render/ps/PSRendererMaker.java | 6 +- .../org/apache/fop/render/ps/PSSVGHandler.java | 12 +- .../apache/fop/render/ps/PSSupportedFlavors.java | 26 +-- .../apache/fop/render/ps/PSTextElementBridge.java | 6 +- .../org/apache/fop/render/ps/PSTextPainter.java | 58 +++--- .../org/apache/fop/render/ps/PSTranscoder.java | 4 +- .../org/apache/fop/render/ps/ResourceHandler.java | 40 ++-- .../ps/extensions/AbstractPSCommentElement.java | 8 +- .../ps/extensions/AbstractPSExtensionElement.java | 22 +- .../ps/extensions/AbstractPSExtensionObject.java | 18 +- .../ps/extensions/PSCommentAfterElement.java | 6 +- .../ps/extensions/PSCommentBeforeElement.java | 6 +- .../ps/extensions/PSExtensionAttachment.java | 12 +- .../ps/extensions/PSExtensionElementMapping.java | 10 +- .../render/ps/extensions/PSExtensionHandler.java | 18 +- .../ps/extensions/PSExtensionHandlerFactory.java | 2 +- .../ps/extensions/PSPageSetupCodeElement.java | 6 +- .../fop/render/ps/extensions/PSSetPageDevice.java | 6 +- .../ps/extensions/PSSetPageDeviceElement.java | 6 +- .../fop/render/ps/extensions/PSSetupCode.java | 12 +- .../render/ps/extensions/PSSetupCodeElement.java | 10 +- .../fop/render/rtf/BorderAttributesConverter.java | 16 +- .../apache/fop/render/rtf/FOPRtfAttributes.java | 14 +- .../apache/fop/render/rtf/FoUnitsConverter.java | 4 +- .../fop/render/rtf/ListAttributesConverter.java | 16 +- .../fop/render/rtf/PageAttributesConverter.java | 16 +- .../apache/fop/render/rtf/RTFEventProducer.java | 14 +- .../fop/render/rtf/RTFFOEventHandlerMaker.java | 8 +- src/java/org/apache/fop/render/rtf/RTFHandler.java | 96 ++++----- .../fop/render/rtf/TableAttributesConverter.java | 32 +-- .../fop/render/rtf/TextAttributesConverter.java | 40 ++-- .../render/rtf/rtflib/exceptions/RtfException.java | 4 +- .../rtflib/exceptions/RtfStructureException.java | 4 +- .../rtf/rtflib/rtfdoc/IBorderAttributes.java | 4 +- .../rtf/rtflib/rtfdoc/IRtfAfterContainer.java | 4 +- .../rtf/rtflib/rtfdoc/IRtfBeforeContainer.java | 4 +- .../rtf/rtflib/rtfdoc/IRtfBookmarkContainer.java | 4 +- .../rtfdoc/IRtfExternalGraphicContainer.java | 4 +- .../rtf/rtflib/rtfdoc/IRtfHyperLinkContainer.java | 4 +- .../rtf/rtflib/rtfdoc/IRtfJforCmdContainer.java | 4 +- .../rtf/rtflib/rtfdoc/IRtfListContainer.java | 4 +- .../fop/render/rtf/rtflib/rtfdoc/IRtfOptions.java | 4 +- .../rtf/rtflib/rtfdoc/IRtfPageBreakContainer.java | 4 +- .../rtf/rtflib/rtfdoc/IRtfPageContainer.java | 4 +- .../rtfdoc/IRtfPageNumberCitationContainer.java | 4 +- .../rtf/rtflib/rtfdoc/IRtfPageNumberContainer.java | 4 +- .../rtf/rtflib/rtfdoc/IRtfParagraphContainer.java | 4 +- .../rtfdoc/IRtfParagraphKeepTogetherContainer.java | 4 +- .../rtf/rtflib/rtfdoc/IRtfTableContainer.java | 4 +- .../rtf/rtflib/rtfdoc/IRtfTextContainer.java | 4 +- .../rtf/rtflib/rtfdoc/IRtfTextrunContainer.java | 6 +- .../render/rtf/rtflib/rtfdoc/ITableAttributes.java | 12 +- .../rtf/rtflib/rtfdoc/ITableColumnsInfo.java | 8 +- .../rtf/rtflib/rtfdoc/IrtfTemplateContainer.java | 4 +- .../rtfdoc/ParagraphKeeptogetherContext.java | 4 +- .../fop/render/rtf/rtflib/rtfdoc/RtfAfter.java | 4 +- .../rtf/rtflib/rtfdoc/RtfAfterBeforeBase.java | 6 +- .../render/rtf/rtflib/rtfdoc/RtfAttributes.java | 10 +- .../fop/render/rtf/rtflib/rtfdoc/RtfBefore.java | 4 +- .../fop/render/rtf/rtflib/rtfdoc/RtfBookmark.java | 4 +- .../rtflib/rtfdoc/RtfBookmarkContainerImpl.java | 4 +- .../render/rtf/rtflib/rtfdoc/RtfColorTable.java | 6 +- .../fop/render/rtf/rtflib/rtfdoc/RtfContainer.java | 4 +- .../render/rtf/rtflib/rtfdoc/RtfDocumentArea.java | 4 +- .../fop/render/rtf/rtflib/rtfdoc/RtfElement.java | 10 +- .../rtf/rtflib/rtfdoc/RtfExternalGraphic.java | 58 +++--- .../render/rtf/rtflib/rtfdoc/RtfExtraRowSet.java | 4 +- .../fop/render/rtf/rtflib/rtfdoc/RtfFile.java | 6 +- .../render/rtf/rtflib/rtfdoc/RtfFontManager.java | 6 +- .../fop/render/rtf/rtflib/rtfdoc/RtfFontTable.java | 4 +- .../fop/render/rtf/rtflib/rtfdoc/RtfFootnote.java | 20 +- .../fop/render/rtf/rtflib/rtfdoc/RtfGenerator.java | 6 +- .../fop/render/rtf/rtflib/rtfdoc/RtfHeader.java | 6 +- .../fop/render/rtf/rtflib/rtfdoc/RtfHyperLink.java | 8 +- .../fop/render/rtf/rtflib/rtfdoc/RtfJforCmd.java | 4 +- .../fop/render/rtf/rtflib/rtfdoc/RtfLineBreak.java | 4 +- .../fop/render/rtf/rtflib/rtfdoc/RtfList.java | 12 +- .../fop/render/rtf/rtflib/rtfdoc/RtfListItem.java | 48 ++--- .../fop/render/rtf/rtflib/rtfdoc/RtfListStyle.java | 10 +- .../rtf/rtflib/rtfdoc/RtfListStyleBullet.java | 14 +- .../rtf/rtflib/rtfdoc/RtfListStyleNumber.java | 20 +- .../render/rtf/rtflib/rtfdoc/RtfListStyleText.java | 26 +-- .../fop/render/rtf/rtflib/rtfdoc/RtfListTable.java | 30 +-- .../fop/render/rtf/rtflib/rtfdoc/RtfNull.java | 4 +- .../fop/render/rtf/rtflib/rtfdoc/RtfOptions.java | 4 +- .../fop/render/rtf/rtflib/rtfdoc/RtfPage.java | 6 +- .../fop/render/rtf/rtflib/rtfdoc/RtfPageArea.java | 4 +- .../fop/render/rtf/rtflib/rtfdoc/RtfPageBreak.java | 4 +- .../render/rtf/rtflib/rtfdoc/RtfPageNumber.java | 4 +- .../rtf/rtflib/rtfdoc/RtfPageNumberCitation.java | 8 +- .../fop/render/rtf/rtflib/rtfdoc/RtfParagraph.java | 4 +- .../rtflib/rtfdoc/RtfParagraphKeepTogether.java | 4 +- .../fop/render/rtf/rtflib/rtfdoc/RtfSection.java | 6 +- .../render/rtf/rtflib/rtfdoc/RtfSpaceManager.java | 28 +-- .../render/rtf/rtflib/rtfdoc/RtfSpaceSplitter.java | 28 +-- .../fop/render/rtf/rtflib/rtfdoc/RtfString.java | 16 +- .../rtf/rtflib/rtfdoc/RtfStringConverter.java | 6 +- .../rtf/rtflib/rtfdoc/RtfStyleSheetTable.java | 4 +- .../fop/render/rtf/rtflib/rtfdoc/RtfTable.java | 22 +- .../fop/render/rtf/rtflib/rtfdoc/RtfTableCell.java | 50 ++--- .../fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java | 32 +-- .../fop/render/rtf/rtflib/rtfdoc/RtfTemplate.java | 4 +- .../fop/render/rtf/rtflib/rtfdoc/RtfText.java | 6 +- .../fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java | 130 ++++++------ .../rtf/rtflib/rtfdoc/WhitespaceCollapser.java | 10 +- .../render/rtf/rtflib/tools/BuilderContext.java | 4 +- .../render/rtf/rtflib/tools/ImageConstants.java | 4 +- .../fop/render/rtf/rtflib/tools/ImageUtil.java | 6 +- .../fop/render/rtf/rtflib/tools/TableContext.java | 42 ++-- src/java/org/apache/fop/render/txt/Helper.java | 34 ++-- .../org/apache/fop/render/txt/TXTRenderer.java | 82 ++++---- .../fop/render/txt/TXTRendererConfigurator.java | 6 +- .../apache/fop/render/txt/TXTRendererMaker.java | 6 +- src/java/org/apache/fop/render/txt/TXTState.java | 24 +-- src/java/org/apache/fop/render/txt/TXTStream.java | 12 +- .../render/txt/border/AbstractBorderElement.java | 18 +- .../fop/render/txt/border/BorderManager.java | 22 +- .../fop/render/txt/border/DashedBorderElement.java | 44 ++-- .../fop/render/txt/border/DottedBorderElement.java | 4 +- .../txt/border/SolidAndDoubleBorderElement.java | 70 +++---- .../apache/fop/render/xml/AbstractXMLRenderer.java | 14 +- .../org/apache/fop/render/xml/XMLRenderer.java | 12 +- .../apache/fop/render/xml/XMLRendererMaker.java | 6 +- .../org/apache/fop/servlet/FopPrintServlet.java | 18 +- src/java/org/apache/fop/servlet/FopServlet.java | 14 +- .../fop/servlet/ServletContextURIResolver.java | 10 +- src/java/org/apache/fop/svg/ACIUtils.java | 8 +- .../org/apache/fop/svg/AbstractFOPTranscoder.java | 30 +-- .../apache/fop/svg/FOPSAXSVGDocumentFactory.java | 12 +- .../org/apache/fop/svg/GraphicsConfiguration.java | 10 +- src/java/org/apache/fop/svg/PDFAElementBridge.java | 8 +- src/java/org/apache/fop/svg/PDFANode.java | 8 +- .../fop/svg/PDFBatikFlowTextElementBridge.java | 10 +- src/java/org/apache/fop/svg/PDFBridgeContext.java | 22 +- src/java/org/apache/fop/svg/PDFContext.java | 2 +- .../org/apache/fop/svg/PDFDocumentGraphics2D.java | 4 +- .../fop/svg/PDFDocumentGraphics2DConfigurator.java | 4 +- .../org/apache/fop/svg/PDFFlowExtTextPainter.java | 6 +- .../org/apache/fop/svg/PDFFlowTextPainter.java | 8 +- src/java/org/apache/fop/svg/PDFGraphics2D.java | 4 +- .../apache/fop/svg/PDFGraphicsConfiguration.java | 6 +- src/java/org/apache/fop/svg/PDFGraphicsDevice.java | 6 +- .../org/apache/fop/svg/PDFImageElementBridge.java | 28 +-- .../fop/svg/PDFSVGFlowRootElementBridge.java | 10 +- .../org/apache/fop/svg/PDFTextElementBridge.java | 6 +- src/java/org/apache/fop/svg/PDFTextPainter.java | 36 ++-- src/java/org/apache/fop/svg/PDFTextUtil.java | 20 +- src/java/org/apache/fop/svg/PDFTranscoder.java | 42 ++-- src/java/org/apache/fop/svg/SVGEventProducer.java | 12 +- src/java/org/apache/fop/svg/SVGUserAgent.java | 10 +- src/java/org/apache/fop/svg/SVGUtilities.java | 4 +- .../org/apache/fop/svg/SimpleSVGUserAgent.java | 10 +- .../apache/fop/text/linebreak/LineBreakStatus.java | 70 +++---- .../apache/fop/text/linebreak/LineBreakUtils.java | 90 ++++---- src/java/org/apache/fop/tools/TestConverter.java | 16 +- .../org/apache/fop/tools/anttasks/FileCompare.java | 8 +- .../org/apache/fop/tools/anttasks/RunTest.java | 10 +- .../fop/tools/anttasks/SerializeHyphPattern.java | 6 +- src/java/org/apache/fop/traits/BlockProps.java | 8 +- src/java/org/apache/fop/traits/BorderProps.java | 24 +-- src/java/org/apache/fop/traits/InlineProps.java | 6 +- src/java/org/apache/fop/traits/LayoutProps.java | 6 +- src/java/org/apache/fop/traits/MinOptMax.java | 10 +- src/java/org/apache/fop/traits/SpaceVal.java | 16 +- src/java/org/apache/fop/util/BreakUtil.java | 6 +- src/java/org/apache/fop/util/CMYKColorSpace.java | 6 +- src/java/org/apache/fop/util/CharUtilities.java | 12 +- .../apache/fop/util/CloseBlockerOutputStream.java | 6 +- src/java/org/apache/fop/util/ColorExt.java | 16 +- src/java/org/apache/fop/util/ColorProfileUtil.java | 4 +- src/java/org/apache/fop/util/ColorSpaceCache.java | 20 +- src/java/org/apache/fop/util/ColorUtil.java | 66 +++--- .../org/apache/fop/util/CommandLineLogger.java | 20 +- .../org/apache/fop/util/ContentHandlerFactory.java | 16 +- .../fop/util/ContentHandlerFactoryRegistry.java | 22 +- src/java/org/apache/fop/util/ConversionUtils.java | 36 ++-- src/java/org/apache/fop/util/DOM2SAX.java | 12 +- .../fop/util/DOMBuilderContentHandlerFactory.java | 22 +- src/java/org/apache/fop/util/DataURIResolver.java | 8 +- src/java/org/apache/fop/util/DataURLUtil.java | 6 +- .../org/apache/fop/util/DefaultErrorListener.java | 4 +- .../apache/fop/util/DelegatingContentHandler.java | 34 ++-- src/java/org/apache/fop/util/ListUtil.java | 10 +- src/java/org/apache/fop/util/LogUtil.java | 6 +- src/java/org/apache/fop/util/QName.java | 8 +- .../org/apache/fop/util/UnclosableInputStream.java | 6 +- src/java/org/apache/fop/util/UnitConv.java | 24 +-- .../org/apache/fop/util/WriterOutputStream.java | 6 +- .../org/apache/fop/util/XMLResourceBundle.java | 46 ++--- .../fop/util/text/AdvancedMessageFormat.java | 90 ++++---- .../org/apache/fop/util/text/ChoiceFieldPart.java | 14 +- .../org/apache/fop/util/text/EqualsFieldPart.java | 14 +- .../apache/fop/util/text/GlyphNameFieldPart.java | 12 +- .../org/apache/fop/util/text/HexFieldPart.java | 10 +- src/java/org/apache/fop/util/text/IfFieldPart.java | 18 +- .../org/apache/fop/util/text/LocatorFormatter.java | 6 +- .../org/apache/fop/render/mif/MIFElement.java | 6 +- .../fop/render/mif/MIFFOEventHandlerMaker.java | 8 +- src/sandbox/org/apache/fop/render/mif/MIFFile.java | 6 +- .../org/apache/fop/render/mif/MIFHandler.java | 14 +- .../org/apache/fop/render/mif/PGFElement.java | 6 +- .../org/apache/fop/render/mif/RefElement.java | 6 +- .../org/apache/fop/render/mif/RulingElement.java | 6 +- .../org/apache/fop/render/svg/SVGRenderer.java | 20 +- .../apache/fop/render/svg/SVGRendererMaker.java | 8 +- .../org/apache/fop/render/svg/SVGSVGHandler.java | 2 +- .../fop/AbstractBasicTranscoderTestCase.java | 16 +- test/java/org/apache/fop/AbstractFOPTestCase.java | 6 +- test/java/org/apache/fop/BasicDriverTestCase.java | 24 +-- test/java/org/apache/fop/BasicDriverTestSuite.java | 6 +- .../org/apache/fop/BasicPDFTranscoderTestCase.java | 8 +- .../org/apache/fop/BasicPSTranscoderTestCase.java | 8 +- .../org/apache/fop/BasicTranscoderTestSuite.java | 6 +- test/java/org/apache/fop/DebugHelper.java | 6 +- test/java/org/apache/fop/DigestFilterTestCase.java | 4 +- test/java/org/apache/fop/GenericFOPTestCase.java | 8 +- .../org/apache/fop/KnuthAlgorithmTestCase.java | 20 +- test/java/org/apache/fop/StandardTestSuite.java | 6 +- .../java/org/apache/fop/URIResolutionTestCase.java | 54 ++--- test/java/org/apache/fop/UtilityCodeTestSuite.java | 6 +- .../config/BaseConstructiveUserConfigTestCase.java | 4 +- .../config/BaseDestructiveUserConfigTestCase.java | 4 +- .../apache/fop/config/BaseUserConfigTestCase.java | 4 +- .../fop/config/FontAttributesMissingTestCase.java | 4 +- .../org/apache/fop/config/FontBaseBadTestCase.java | 6 +- .../apache/fop/config/FontEmbedUrlBadTestCase.java | 4 +- .../fop/config/FontEmbedUrlMalformedTestCase.java | 6 +- .../fop/config/FontMetricsUrlBadTestCase.java | 6 +- .../config/FontMetricsUrlMalformedTestCase.java | 6 +- .../FontTripletAttributeMissingTestCase.java | 6 +- .../apache/fop/config/FontsAutoDetectTestCase.java | 4 +- .../fop/config/FontsDirectoryBadTestCase.java | 10 +- .../config/FontsDirectoryRecursiveTestCase.java | 8 +- .../org/apache/fop/config/UserConfigTestSuite.java | 4 +- .../fop/datatypes/URISpecificationTestCase.java | 8 +- .../org/apache/fop/events/BasicEventTestCase.java | 20 +- .../org/apache/fop/events/TestEventProducer.java | 8 +- .../fop/fo/flow/table/AbstractTableTestCase.java | 6 +- .../table/CollapsedConditionalBorderTestCase.java | 4 +- .../fop/fo/flow/table/ErrorCheckTestCase.java | 4 +- .../fop/fo/flow/table/IllegalRowSpanTestCase.java | 4 +- .../fop/fo/flow/table/RowGroupBuilderTestCase.java | 8 +- .../table/TableColumnColumnNumberTestCase.java | 6 +- .../fop/fo/flow/table/TooManyColumnsTestCase.java | 4 +- .../org/apache/fop/fonts/TrueTypeAnsiTestCase.java | 20 +- .../org/apache/fop/fotreetest/FOTreeTestSuite.java | 24 +-- .../org/apache/fop/fotreetest/FOTreeTester.java | 22 +- .../apache/fop/fotreetest/FOTreeUnitTester.java | 6 +- .../org/apache/fop/fotreetest/ResultCollector.java | 14 +- .../apache/fop/fotreetest/ext/AssertElement.java | 24 +-- .../fop/fotreetest/ext/TestElementMapping.java | 8 +- .../org/apache/fop/fotreetest/ext/TestObj.java | 6 +- .../image/loader/batik/ImageLoaderTestCase.java | 26 +-- .../image/loader/batik/ImagePreloaderTestCase.java | 30 +-- .../fop/intermediate/AreaTreeParserTestCase.java | 52 ++--- .../intermediate/IntermediateFormatTestSuite.java | 8 +- .../apache/fop/layoutengine/ElementListCheck.java | 62 +++--- .../fop/layoutengine/ElementListCollector.java | 18 +- .../org/apache/fop/layoutengine/EvalCheck.java | 10 +- .../apache/fop/layoutengine/LayoutEngineCheck.java | 2 +- .../fop/layoutengine/LayoutEngineTestSuite.java | 36 ++-- .../org/apache/fop/layoutengine/LayoutResult.java | 8 +- .../org/apache/fop/layoutengine/ResultCheck.java | 8 +- .../org/apache/fop/layoutengine/TrueCheck.java | 10 +- test/java/org/apache/fop/memory/MemoryEater.java | 34 ++-- .../java/org/apache/fop/pdf/PDFObjectTestCase.java | 10 +- .../org/apache/fop/render/pdf/BasePDFTestCase.java | 2 +- .../fop/render/pdf/PDFAMetadataTestCase.java | 14 +- .../org/apache/fop/render/pdf/PDFCMapTestCase.java | 10 +- .../apache/fop/render/pdf/PDFEncodingTestCase.java | 24 +-- .../fop/render/pdf/PDFsRGBSettingsTestCase.java | 4 +- .../apache/fop/render/rtf/Bug39607TestCase.java | 4 +- .../fop/render/rtf/RichTextFormatTestSuite.java | 6 +- .../fop/render/rtf/rtflib/testdocs/BasicLink.java | 4 +- .../rtf/rtflib/testdocs/CreateTestDocuments.java | 4 +- .../rtf/rtflib/testdocs/DummyTableColumnsInfo.java | 4 +- .../rtf/rtflib/testdocs/ExternalGraphic.java | 4 +- .../render/rtf/rtflib/testdocs/ListInTable.java | 4 +- .../rtf/rtflib/testdocs/MergedTableCells.java | 4 +- .../render/rtf/rtflib/testdocs/NestedTable.java | 4 +- .../rtf/rtflib/testdocs/ParagraphAlignment.java | 4 +- .../render/rtf/rtflib/testdocs/SimpleDocument.java | 4 +- .../render/rtf/rtflib/testdocs/SimpleLists.java | 4 +- .../render/rtf/rtflib/testdocs/SimpleTable.java | 4 +- .../render/rtf/rtflib/testdocs/TestDocument.java | 4 +- .../render/rtf/rtflib/testdocs/TextAttributes.java | 4 +- .../fop/render/rtf/rtflib/testdocs/Whitespace.java | 4 +- .../fop/text/linebreak/LineBreakStatusTest.java | 118 +++++------ .../fop/text/linebreak/LineBreakUtilsTest.java | 8 +- test/java/org/apache/fop/threading/FOPTestbed.java | 24 +-- .../java/org/apache/fop/threading/FOProcessor.java | 4 +- .../org/apache/fop/threading/FOProcessorImpl.java | 6 +- test/java/org/apache/fop/threading/Main.java | 14 +- .../org/apache/fop/traits/BorderPropsTestCase.java | 8 +- .../fop/util/AdvancedMessageFormatTestCase.java | 32 +-- .../org/apache/fop/util/ColorUtilTestCase.java | 32 +-- .../fop/util/ConsoleEventListenerForTests.java | 4 +- .../apache/fop/util/DataURIResolverTestCase.java | 14 +- test/java/org/apache/fop/util/DigestFilter.java | 6 +- .../apache/fop/util/ElementListUtilsTestCase.java | 28 +-- .../org/apache/fop/util/PDFNumberTestCase.java | 14 +- .../java/org/apache/fop/util/UnitConvTestCase.java | 4 +- .../apache/fop/util/XMLResourceBundleTestCase.java | 6 +- .../apache/fop/visual/AbstractBitmapProducer.java | 6 +- .../fop/visual/AbstractPSPDFBitmapProducer.java | 30 +-- .../fop/visual/AbstractRedirectorLineHandler.java | 2 +- test/java/org/apache/fop/visual/BatchDiffer.java | 30 +-- .../org/apache/fop/visual/BitmapComparator.java | 26 +-- .../java/org/apache/fop/visual/BitmapProducer.java | 2 +- .../apache/fop/visual/BitmapProducerJava2D.java | 8 +- .../org/apache/fop/visual/BitmapProducerPDF.java | 6 +- .../org/apache/fop/visual/BitmapProducerPS.java | 6 +- test/java/org/apache/fop/visual/ConvertUtils.java | 18 +- .../org/apache/fop/visual/ProducerContext.java | 8 +- .../apache/fop/visual/RedirectorLineHandler.java | 2 +- .../apache/fop/visual/ReferenceBitmapLoader.java | 2 +- .../org/apache/fop/visual/StreamRedirector.java | 4 +- 1082 files changed, 9285 insertions(+), 9270 deletions(-) (limited to 'src/java/org/apache/fop/render/ps/extensions/PSCommentAfterElement.java') diff --git a/examples/embedding/java/embedding/ExampleAWTViewer.java b/examples/embedding/java/embedding/ExampleAWTViewer.java index 716ea1487..9822e47e5 100644 --- a/examples/embedding/java/embedding/ExampleAWTViewer.java +++ b/examples/embedding/java/embedding/ExampleAWTViewer.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 embedding; //Java diff --git a/examples/embedding/java/embedding/ExampleDOM2PDF.java b/examples/embedding/java/embedding/ExampleDOM2PDF.java index 9caa5b72a..6bf05827c 100644 --- a/examples/embedding/java/embedding/ExampleDOM2PDF.java +++ b/examples/embedding/java/embedding/ExampleDOM2PDF.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 embedding; // Java @@ -55,7 +55,7 @@ public class ExampleDOM2PDF { // configure fopFactory as desired private FopFactory fopFactory = FopFactory.newInstance(); - + /** xsl-fo namespace URI */ protected static String foNS = "http://www.w3.org/1999/XSL/Format"; @@ -68,31 +68,31 @@ public class ExampleDOM2PDF { try { FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); // configure foUserAgent as desired - + // Setup output OutputStream out = new java.io.FileOutputStream(pdf); out = new java.io.BufferedOutputStream(out); - + try { // Construct fop with desired output format and output stream Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out); - + // Setup Identity Transformer TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(); // identity transformer - + // Setup input for XSLT transformation Source src = new DOMSource(xslfoDoc); - + // 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 { out.close(); } - + } catch (Exception e) { e.printStackTrace(System.err); System.exit(-1); @@ -107,24 +107,24 @@ public class ExampleDOM2PDF { public static void main(String[] args) { try { System.out.println("FOP ExampleDOM2PDF\n"); - + //Setup directories File baseDir = new File("."); File outDir = new File(baseDir, "out"); outDir.mkdirs(); - + //Setup output file File pdffile = new File(outDir, "ResultDOM2PDF.pdf"); System.out.println("PDF Output File: " + pdffile); System.out.println(); - + Document foDoc = buildDOMDocument(); - + ExampleDOM2PDF app = new ExampleDOM2PDF(); app.convertDOM2PDF(foDoc, pdffile); - + System.out.println("Success!"); - + } catch (Exception e) { e.printStackTrace(System.err); System.exit(-1); @@ -140,15 +140,15 @@ public class ExampleDOM2PDF { // Create a sample XSL-FO DOM document Document foDoc = null; Element root = null, ele1 = null, ele2 = null, ele3 = null; - + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); DocumentBuilder db = dbf.newDocumentBuilder(); foDoc = db.newDocument(); - + root = foDoc.createElementNS(foNS, "fo:root"); foDoc.appendChild(root); - + ele1 = foDoc.createElementNS(foNS, "fo:layout-master-set"); root.appendChild(ele1); ele2 = foDoc.createElementNS(foNS, "fo:simple-page-master"); @@ -178,7 +178,7 @@ public class ExampleDOM2PDF { * @param newNodeName name of the new node * @param textVal content of the element */ - protected static void addElement(Node parent, String newNodeName, + protected static void addElement(Node parent, String newNodeName, String textVal) { if (textVal == null) { return; diff --git a/examples/embedding/java/embedding/ExampleFO2JPSPrint.java b/examples/embedding/java/embedding/ExampleFO2JPSPrint.java index a67e2bdad..4f18b71ab 100644 --- a/examples/embedding/java/embedding/ExampleFO2JPSPrint.java +++ b/examples/embedding/java/embedding/ExampleFO2JPSPrint.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 embedding; // Java @@ -54,12 +54,12 @@ public class ExampleFO2JPSPrint { // configure fopFactory as desired private FopFactory fopFactory = FopFactory.newInstance(); - + private DocPrintJob createDocPrintJob() { PrintService[] services = PrintServiceLookup.lookupPrintServices( DocFlavor.SERVICE_FORMATTED.PAGEABLE, null); PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet(); - PrintService printService = ServiceUI.printDialog(null, 50, 50, + PrintService printService = ServiceUI.printDialog(null, 50, 50, services, services[0], null, attributes); if (printService != null) { return printService.createPrintJob(); @@ -67,7 +67,7 @@ public class ExampleFO2JPSPrint { return null; } } - + /** * Prints an FO file using JPS. * @param fo the FO file @@ -78,7 +78,7 @@ public class ExampleFO2JPSPrint { */ public void printFO(File fo) throws IOException, FOPException, TransformerException, PrintException { - + //Set up DocPrintJob instance DocPrintJob printJob = createDocPrintJob(); @@ -88,20 +88,20 @@ public class ExampleFO2JPSPrint { PageableRenderer renderer = new PageableRenderer(); renderer.setUserAgent(userAgent); userAgent.setRendererOverride(renderer); - + // Construct FOP with desired output format Fop fop = fopFactory.newFop(userAgent); // Setup JAXP using identity transformer TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(); // identity transformer - + // Setup input stream Source src = new StreamSource(fo); // 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); @@ -117,23 +117,23 @@ public class ExampleFO2JPSPrint { try { System.out.println("FOP ExampleFO2JPSPrint\n"); System.out.println("Preparing..."); - + //Setup directories File baseDir = new File("."); File outDir = new File(baseDir, "out"); outDir.mkdirs(); - //Setup input and output files + //Setup input and output files File fofile = new File(baseDir, "xml/fo/helloworld.fo"); System.out.println("Input: XSL-FO (" + fofile + ")"); System.out.println("Output: JPS (Java Printing System)"); System.out.println(); System.out.println("Transforming..."); - + ExampleFO2JPSPrint app = new ExampleFO2JPSPrint(); app.printFO(fofile); - + System.out.println("Success!"); } catch (Exception e) { e.printStackTrace(System.err); diff --git a/examples/embedding/java/embedding/ExampleFO2OldStylePrint.java b/examples/embedding/java/embedding/ExampleFO2OldStylePrint.java index d9bc1d11d..885482dfb 100644 --- a/examples/embedding/java/embedding/ExampleFO2OldStylePrint.java +++ b/examples/embedding/java/embedding/ExampleFO2OldStylePrint.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 embedding; // Java @@ -44,7 +44,7 @@ public class ExampleFO2OldStylePrint { // configure fopFactory as desired private FopFactory fopFactory = FopFactory.newInstance(); - + /** * Prints an FO file using an old-style PrinterJob. * @param fo the FO file @@ -52,7 +52,7 @@ public class ExampleFO2OldStylePrint { * @throws FOPException In case of a FOP problem */ public void printFO(File fo) throws IOException, FOPException { - + //Set up PrinterJob instance PrinterJob printerJob = PrinterJob.getPrinterJob(); printerJob.setJobName("FOP Printing Example"); @@ -68,13 +68,13 @@ public class ExampleFO2OldStylePrint { // Setup JAXP using identity transformer TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(); // identity transformer - + // Setup input stream Source src = new StreamSource(fo); // 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); @@ -93,23 +93,23 @@ public class ExampleFO2OldStylePrint { try { System.out.println("FOP ExampleFO2OldStylePrint\n"); System.out.println("Preparing..."); - + //Setup directories File baseDir = new File("."); File outDir = new File(baseDir, "out"); outDir.mkdirs(); - //Setup input and output files + //Setup input and output files File fofile = new File(baseDir, "xml/fo/helloworld.fo"); System.out.println("Input: XSL-FO (" + fofile + ")"); System.out.println("Output: old-style printing using PrinterJob"); System.out.println(); System.out.println("Transforming..."); - + ExampleFO2OldStylePrint app = new ExampleFO2OldStylePrint(); app.printFO(fofile); - + System.out.println("Success!"); } catch (Exception e) { e.printStackTrace(System.err); diff --git a/examples/embedding/java/embedding/ExampleFO2PDF.java b/examples/embedding/java/embedding/ExampleFO2PDF.java index 3b239f11b..6ae674908 100644 --- a/examples/embedding/java/embedding/ExampleFO2PDF.java +++ b/examples/embedding/java/embedding/ExampleFO2PDF.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 embedding; // Java @@ -60,13 +60,13 @@ public class ExampleFO2PDF { * @throws FOPException In case of a FOP problem */ public void convertFO2PDF(File fo, File pdf) throws IOException, FOPException { - + OutputStream out = null; - + try { FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); // configure foUserAgent as desired - + // Setup output stream. Note: Using BufferedOutputStream // for performance reasons (helpful with FileOutputStreams). out = new FileOutputStream(pdf); @@ -78,24 +78,24 @@ public class ExampleFO2PDF { // Setup JAXP using identity transformer TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(); // identity transformer - + // Setup input stream Source src = new StreamSource(fo); // 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); - + // Result processing FormattingResults foResults = fop.getResults(); java.util.List pageSequences = foResults.getPageSequences(); for (java.util.Iterator it = pageSequences.iterator(); it.hasNext();) { PageSequenceResults pageSequenceResults = (PageSequenceResults)it.next(); - System.out.println("PageSequence " - + (String.valueOf(pageSequenceResults.getID()).length() > 0 - ? pageSequenceResults.getID() : "") + System.out.println("PageSequence " + + (String.valueOf(pageSequenceResults.getID()).length() > 0 + ? pageSequenceResults.getID() : "") + " generated " + pageSequenceResults.getPageCount() + " pages."); } System.out.println("Generated " + foResults.getPageCount() + " pages in total."); @@ -117,13 +117,13 @@ public class ExampleFO2PDF { try { System.out.println("FOP ExampleFO2PDF\n"); System.out.println("Preparing..."); - + //Setup directories File baseDir = new File("."); File outDir = new File(baseDir, "out"); outDir.mkdirs(); - //Setup input and output files + //Setup input and output files File fofile = new File(baseDir, "xml/fo/helloworld.fo"); //File fofile = new File(baseDir, "../fo/pagination/franklin_2pageseqs.fo"); File pdffile = new File(outDir, "ResultFO2PDF.pdf"); @@ -132,10 +132,10 @@ public class ExampleFO2PDF { System.out.println("Output: PDF (" + pdffile + ")"); System.out.println(); System.out.println("Transforming..."); - + ExampleFO2PDF app = new ExampleFO2PDF(); app.convertFO2PDF(fofile, pdffile); - + System.out.println("Success!"); } catch (Exception e) { e.printStackTrace(System.err); diff --git a/examples/embedding/java/embedding/ExampleFO2PDFUsingSAXParser.java b/examples/embedding/java/embedding/ExampleFO2PDFUsingSAXParser.java index c9422e1b9..e49eaed24 100644 --- a/examples/embedding/java/embedding/ExampleFO2PDFUsingSAXParser.java +++ b/examples/embedding/java/embedding/ExampleFO2PDFUsingSAXParser.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 embedding; // Java @@ -69,13 +69,13 @@ public class ExampleFO2PDFUsingSAXParser { // configure foUserAgent as desired OutputStream out = null; - + try { // Setup output stream. Note: Using BufferedOutputStream // for performance reasons (helpful with FileOutputStreams). out = new FileOutputStream(pdf); out = new BufferedOutputStream(out); - + // Construct fop and setup output format Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out); @@ -85,7 +85,7 @@ public class ExampleFO2PDFUsingSAXParser { factory.setNamespaceAware(true); // throws ParserConfigurationException SAXParser parser = factory.newSAXParser(); - + // Obtain FOP's DefaultHandler // throws FOPException DefaultHandler dh = fop.getDefaultHandler(); @@ -108,13 +108,13 @@ public class ExampleFO2PDFUsingSAXParser { try { System.out.println("FOP ExampleFO2PDFUsingSAXParser\n"); System.out.println("Preparing..."); - + //Setup directories File baseDir = new File("."); File outDir = new File(baseDir, "out"); outDir.mkdirs(); - //Setup input and output files + //Setup input and output files File fofile = new File(baseDir, "xml/fo/helloworld.fo"); File pdffile = new File(outDir, "ResultFO2PDFUsingSAXParser.pdf"); @@ -122,10 +122,10 @@ public class ExampleFO2PDFUsingSAXParser { System.out.println("Output: PDF (" + pdffile + ")"); System.out.println(); System.out.println("Transforming..."); - + ExampleFO2PDFUsingSAXParser app = new ExampleFO2PDFUsingSAXParser(); app.convertFO2PDF(fofile, pdffile); - + System.out.println("Success!"); } catch (Exception e) { e.printStackTrace(System.err); diff --git a/examples/embedding/java/embedding/ExampleFO2RTF.java b/examples/embedding/java/embedding/ExampleFO2RTF.java index b33fb13b8..68d63304f 100644 --- a/examples/embedding/java/embedding/ExampleFO2RTF.java +++ b/examples/embedding/java/embedding/ExampleFO2RTF.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 embedding; // Java @@ -60,12 +60,12 @@ public class ExampleFO2RTF { * @throws FOPException In case of a FOP problem */ public void convertFO2RTF(File fo, File rtf) throws IOException, FOPException { - + FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); // configure foUserAgent as desired OutputStream out = null; - + try { // Setup output stream. Note: Using BufferedOutputStream // for performance reasons (helpful with FileOutputStreams). @@ -74,25 +74,25 @@ public class ExampleFO2RTF { // Construct fop with desired output format Fop fop = fopFactory.newFop(MimeConstants.MIME_RTF, 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); // 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); - + // Please note: getResults() won't work for RTF and other flow formats (like MIF) // as the layout engine is not involved in the conversion. The page-breaking // is done by the application opening the generated file (like MS Word). //FormattingResults foResults = fop.getResults(); - + } catch (Exception e) { e.printStackTrace(System.err); System.exit(-1); @@ -110,13 +110,13 @@ public class ExampleFO2RTF { try { System.out.println("FOP ExampleFO2RTF\n"); System.out.println("Preparing..."); - + //Setup directories File baseDir = new File("."); File outDir = new File(baseDir, "out"); outDir.mkdirs(); - //Setup input and output files + //Setup input and output files File fofile = new File(baseDir, "xml/fo/helloworld.fo"); File rtffile = new File(outDir, "ResultFO2RTF.rtf"); @@ -124,10 +124,10 @@ public class ExampleFO2RTF { System.out.println("Output: PDF (" + rtffile + ")"); System.out.println(); System.out.println("Transforming..."); - + ExampleFO2RTF app = new ExampleFO2RTF(); app.convertFO2RTF(fofile, rtffile); - + System.out.println("Success!"); } catch (Exception e) { e.printStackTrace(System.err); diff --git a/examples/embedding/java/embedding/ExampleObj2PDF.java b/examples/embedding/java/embedding/ExampleObj2PDF.java index c3dcbc5d6..666b7e433 100644 --- a/examples/embedding/java/embedding/ExampleObj2PDF.java +++ b/examples/embedding/java/embedding/ExampleObj2PDF.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 embedding; // Java @@ -43,7 +43,7 @@ import org.apache.fop.apps.MimeConstants; import embedding.model.ProjectTeam; /** - * This class demonstrates the conversion of an arbitrary object file to a + * This class demonstrates the conversion of an arbitrary object file to a * PDF using JAXP (XSLT) and FOP (XSL:FO). */ public class ExampleObj2PDF { @@ -60,9 +60,9 @@ public class ExampleObj2PDF { * @throws FOPException In case of a FOP problem * @throws TransformerException In case of a XSL transformation problem */ - public void convertProjectTeam2PDF(ProjectTeam team, File xslt, File pdf) + public void convertProjectTeam2PDF(ProjectTeam team, File xslt, File pdf) throws IOException, FOPException, TransformerException { - + FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); // configure foUserAgent as desired @@ -76,10 +76,10 @@ public class ExampleObj2PDF { // Setup XSLT TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(new StreamSource(xslt)); - + // Setup input for XSLT transformation Source src = team.getSourceForProjectTeam(); - + // Resulting SAX events (the generated FO) must be piped through to FOP Result res = new SAXResult(fop.getDefaultHandler()); @@ -99,7 +99,7 @@ public class ExampleObj2PDF { try { System.out.println("FOP ExampleObj2PDF\n"); System.out.println("Preparing..."); - + // Setup directories File baseDir = new File("."); File outDir = new File(baseDir, "out"); @@ -117,7 +117,7 @@ public class ExampleObj2PDF { ExampleObj2PDF app = new ExampleObj2PDF(); app.convertProjectTeam2PDF(ExampleObj2XML.createSampleProjectTeam(), xsltfile, pdffile); - + System.out.println("Success!"); } catch (Exception e) { e.printStackTrace(System.err); diff --git a/examples/embedding/java/embedding/ExampleObj2XML.java b/examples/embedding/java/embedding/ExampleObj2XML.java index 90f9ba5b0..71a027192 100644 --- a/examples/embedding/java/embedding/ExampleObj2XML.java +++ b/examples/embedding/java/embedding/ExampleObj2XML.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 embedding; //Hava @@ -36,7 +36,7 @@ import embedding.model.ProjectTeam; /** - * This class demonstrates the conversion of an arbitrary object file to an + * This class demonstrates the conversion of an arbitrary object file to an * XML file. */ public class ExampleObj2XML { @@ -48,20 +48,20 @@ public class ExampleObj2XML { * @throws IOException In case of an I/O problem * @throws TransformerException In case of a XSL transformation problem */ - public void convertProjectTeam2XML(ProjectTeam team, File xml) + public void convertProjectTeam2XML(ProjectTeam team, File xml) throws IOException, TransformerException { - + //Setup XSLT TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(); /* Note: We use the identity transformer, no XSL transformation is done. - The transformer is basically just used to serialize the + The transformer is basically just used to serialize the generated document to XML. */ - + //Setup input Source src = team.getSourceForProjectTeam(); - + //Setup output Result res = new StreamResult(xml); @@ -97,7 +97,7 @@ public class ExampleObj2XML { try { System.out.println("FOP ExampleObj2XML\n"); System.out.println("Preparing..."); - + //Setup directories File baseDir = new File("."); File outDir = new File(baseDir, "out"); @@ -113,7 +113,7 @@ public class ExampleObj2XML { ExampleObj2XML app = new ExampleObj2XML(); app.convertProjectTeam2XML(createSampleProjectTeam(), xmlfile); - + System.out.println("Success!"); } catch (Exception e) { e.printStackTrace(System.err); diff --git a/examples/embedding/java/embedding/ExampleSVG2PDF.java b/examples/embedding/java/embedding/ExampleSVG2PDF.java index ca0f46146..d152db7ae 100644 --- a/examples/embedding/java/embedding/ExampleSVG2PDF.java +++ b/examples/embedding/java/embedding/ExampleSVG2PDF.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 embedding; //Java @@ -47,22 +47,22 @@ public class ExampleSVG2PDF { * @throws TranscoderException In case of a transcoding problem */ public void convertSVG2PDF(File svg, File pdf) throws IOException, TranscoderException { - + //Create transcoder Transcoder transcoder = new PDFTranscoder(); //Transcoder transcoder = new org.apache.fop.render.ps.PSTranscoder(); - + //Setup input InputStream in = new java.io.FileInputStream(svg); try { TranscoderInput input = new TranscoderInput(in); - + //Setup output OutputStream out = new java.io.FileOutputStream(pdf); out = new java.io.BufferedOutputStream(out); try { TranscoderOutput output = new TranscoderOutput(out); - + //Do the transformation transcoder.transcode(input, output); } finally { @@ -82,13 +82,13 @@ public class ExampleSVG2PDF { try { System.out.println("FOP ExampleSVG2PDF\n"); System.out.println("Preparing..."); - + //Setup directories File baseDir = new File("."); File outDir = new File(baseDir, "out"); outDir.mkdirs(); - //Setup input and output files + //Setup input and output files File svgfile = new File(baseDir, "xml/svg/helloworld.svg"); File pdffile = new File(outDir, "ResultSVG2PDF.pdf"); @@ -96,10 +96,10 @@ public class ExampleSVG2PDF { System.out.println("Output: PDF (" + pdffile + ")"); System.out.println(); System.out.println("Transforming..."); - + ExampleSVG2PDF app = new ExampleSVG2PDF(); app.convertSVG2PDF(svgfile, pdffile); - + System.out.println("Success!"); } catch (Exception e) { e.printStackTrace(System.err); diff --git a/examples/embedding/java/embedding/ExampleXML2FO.java b/examples/embedding/java/embedding/ExampleXML2FO.java index 07b946435..c5638c45b 100644 --- a/examples/embedding/java/embedding/ExampleXML2FO.java +++ b/examples/embedding/java/embedding/ExampleXML2FO.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 embedding; //Java @@ -47,19 +47,19 @@ public class ExampleXML2FO { * @throws IOException In case of an I/O problem * @throws TransformerException In case of a XSL transformation problem */ - public void convertXML2FO(File xml, File xslt, File fo) + public void convertXML2FO(File xml, File xslt, File fo) throws IOException, TransformerException { - + //Setup output OutputStream out = new java.io.FileOutputStream(fo); try { //Setup XSLT TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(new StreamSource(xslt)); - + //Setup input for XSLT transformation Source src = new StreamSource(xml); - + //Resulting SAX events (the generated FO) must be piped through to FOP Result res = new StreamResult(out); @@ -85,7 +85,7 @@ public class ExampleXML2FO { File outDir = new File(baseDir, "out"); outDir.mkdirs(); - //Setup input and output files + //Setup input and output files File xmlfile = new File(baseDir, "xml/xml/projectteam.xml"); File xsltfile = new File(baseDir, "xml/xslt/projectteam2fo.xsl"); File fofile = new File(outDir, "ResultXML2FO.fo"); @@ -95,10 +95,10 @@ public class ExampleXML2FO { System.out.println("Output: XSL-FO (" + fofile + ")"); System.out.println(); System.out.println("Transforming..."); - + ExampleXML2FO app = new ExampleXML2FO(); app.convertXML2FO(xmlfile, xsltfile, fofile); - + System.out.println("Success!"); } catch (Exception e) { e.printStackTrace(System.err); diff --git a/examples/embedding/java/embedding/ExampleXML2PDF.java b/examples/embedding/java/embedding/ExampleXML2PDF.java index 2769b032a..a7c8e2a41 100644 --- a/examples/embedding/java/embedding/ExampleXML2PDF.java +++ b/examples/embedding/java/embedding/ExampleXML2PDF.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 embedding; //Java @@ -38,7 +38,7 @@ import org.apache.fop.apps.FopFactory; import org.apache.fop.apps.MimeConstants; /** - * This class demonstrates the conversion of an XML file to PDF using + * This class demonstrates the conversion of an XML file to PDF using * JAXP (XSLT) and FOP (XSL-FO). */ public class ExampleXML2PDF { @@ -57,7 +57,7 @@ public class ExampleXML2PDF { File outDir = new File(baseDir, "out"); outDir.mkdirs(); - // Setup input and output files + // Setup input and output files File xmlfile = new File(baseDir, "xml/xml/projectteam.xml"); File xsltfile = new File(baseDir, "xml/xslt/projectteam2fo.xsl"); File pdffile = new File(outDir, "ResultXML2PDF.pdf"); @@ -67,7 +67,7 @@ public class ExampleXML2PDF { System.out.println("Output: PDF (" + pdffile + ")"); System.out.println(); System.out.println("Transforming..."); - + // configure fopFactory as desired FopFactory fopFactory = FopFactory.newInstance(); @@ -77,30 +77,30 @@ public class ExampleXML2PDF { // Setup output OutputStream out = new java.io.FileOutputStream(pdffile); out = new java.io.BufferedOutputStream(out); - + try { // Construct fop with desired output format Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out); - + // Setup XSLT TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(new StreamSource(xsltfile)); - + // Set the value of a in the stylesheet transformer.setParameter("versionParam", "2.0"); - + // Setup input for XSLT transformation Source src = new StreamSource(xmlfile); - + // 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 { out.close(); } - + System.out.println("Success!"); } catch (Exception e) { e.printStackTrace(System.err); diff --git a/examples/embedding/java/embedding/MultipleFO2PDF.java b/examples/embedding/java/embedding/MultipleFO2PDF.java index 7a30f0905..a9ace7cf0 100644 --- a/examples/embedding/java/embedding/MultipleFO2PDF.java +++ b/examples/embedding/java/embedding/MultipleFO2PDF.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 embedding; // Java @@ -59,26 +59,26 @@ public class MultipleFO2PDF { // JAXP TransformerFactory can be reused, too private TransformerFactory factory = TransformerFactory.newInstance(); - + /** * Converts an FO file to a PDF file using FOP * @param fo the FO file * @param pdf the target PDF file - * @throws TransformerException in case of a transformation problem + * @throws TransformerException in case of a transformation problem * @throws IOException in case of an I/O problem * @throws FOPException in case of a FOP problem * @return the formatting results of the run */ - public FormattingResults convertFO2PDF(File fo, File pdf) + public FormattingResults convertFO2PDF(File fo, File pdf) throws TransformerException, IOException, FOPException { - + OutputStream out = null; Fop fop; - + try { FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); // configure foUserAgent as desired - + // Setup output stream. Note: Using BufferedOutputStream // for performance reasons (helpful with FileOutputStreams). out = new FileOutputStream(pdf); @@ -89,13 +89,13 @@ public class MultipleFO2PDF { // Setup JAXP using identity transformer Transformer transformer = factory.newTransformer(); // identity transformer - + // Setup input stream Source src = new StreamSource(fo); // 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 { @@ -105,7 +105,7 @@ public class MultipleFO2PDF { return fop.getResults(); } - /** + /** * Listens on standard in for names of fo files to be transformed to pdf. * 'quit' or the null string (for piped input) cause the listener to stop listening. */ @@ -116,10 +116,10 @@ public class MultipleFO2PDF { File outDir = new File(baseDir, "out"); outDir.mkdirs(); BufferedReader in = new BufferedReader(new java.io.InputStreamReader(System.in)); - + while (true) { try { - // Listen for the input file name + // Listen for the input file name System.out.print("Input XSL-FO file ('quit' to stop): "); String foname = in.readLine(); if (foname == null) { @@ -146,9 +146,9 @@ public class MultipleFO2PDF { java.util.List pageSequences = foResults.getPageSequences(); for (java.util.Iterator it = pageSequences.iterator(); it.hasNext();) { PageSequenceResults pageSequenceResults = (PageSequenceResults)it.next(); - System.out.println("PageSequence " - + (String.valueOf(pageSequenceResults.getID()).length() > 0 - ? pageSequenceResults.getID() : "") + System.out.println("PageSequence " + + (String.valueOf(pageSequenceResults.getID()).length() > 0 + ? pageSequenceResults.getID() : "") + " generated " + pageSequenceResults.getPageCount() + " pages."); } System.out.println("Generated " + foResults.getPageCount() + " pages in total."); @@ -161,7 +161,7 @@ public class MultipleFO2PDF { } } } - + /** * Main method. Set up the listener. * @param args command-line arguments diff --git a/examples/embedding/java/embedding/events/ExampleEvents.java b/examples/embedding/java/embedding/events/ExampleEvents.java index 9c52e4ba1..4f0b5c0c2 100644 --- a/examples/embedding/java/embedding/events/ExampleEvents.java +++ b/examples/embedding/java/embedding/events/ExampleEvents.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 embedding.events; import java.io.BufferedOutputStream; @@ -68,21 +68,21 @@ public class ExampleEvents { */ 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); @@ -94,13 +94,13 @@ public class ExampleEvents { // 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); @@ -114,7 +114,7 @@ public class ExampleEvents { 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"); @@ -122,16 +122,16 @@ public class ExampleEvents { + "!!! ===---"); //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 { @@ -152,7 +152,7 @@ public class ExampleEvents { } } } - + /** * This method extracts the original exception from some exception. The exception @@ -185,7 +185,7 @@ public class ExampleEvents { try { System.out.println("FOP ExampleEvents\n"); System.out.println("Preparing..."); - + //Setup directories File baseDir = new File("."); File outDir = new File(baseDir, "out"); @@ -199,9 +199,9 @@ public class ExampleEvents { 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) { @@ -215,7 +215,7 @@ public class ExampleEvents { System.out.println("Aborted!"); System.exit(-1); } - + System.out.println("Success!"); } catch (Exception e) { //Some other error (shouldn't happen in this example) diff --git a/examples/embedding/java/embedding/intermediate/ExampleConcat.java b/examples/embedding/java/embedding/intermediate/ExampleConcat.java index 07790309d..6967ebc8a 100644 --- a/examples/embedding/java/embedding/intermediate/ExampleConcat.java +++ b/examples/embedding/java/embedding/intermediate/ExampleConcat.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 embedding.intermediate; import java.io.File; @@ -81,26 +81,26 @@ public class ExampleConcat { * @throws FOPException In case of a FOP problem * @throws TransformerException In case of a XSL transformation problem */ - public void convertToIntermediate(Source src, Source xslt, File intermediate) + public void convertToIntermediate(Source src, Source xslt, File intermediate) throws IOException, FOPException, TransformerException { - + //Create a user agent FOUserAgent userAgent = fopFactory.newFOUserAgent(); - + //Create an instance of the target renderer so the XMLRenderer can use its font setup Renderer targetRenderer = userAgent.getRendererFactory().createRenderer( - userAgent, MimeConstants.MIME_PDF); - + userAgent, MimeConstants.MIME_PDF); + //Create the XMLRenderer to create the intermediate format (area tree XML) XMLRenderer xmlRenderer = new XMLRenderer(); xmlRenderer.setUserAgent(userAgent); - + //Tell the XMLRenderer to mimic the target renderer xmlRenderer.mimicRenderer(targetRenderer); - + //Make sure the prepared XMLRenderer is used userAgent.setRendererOverride(xmlRenderer); - + // Setup output OutputStream out = new java.io.FileOutputStream(intermediate); out = new java.io.BufferedOutputStream(out); @@ -117,7 +117,7 @@ public class ExampleConcat { } else { transformer = factory.newTransformer(); } - + // Resulting SAX events (the generated FO) must be piped through to FOP Result res = new SAXResult(fop.getDefaultHandler()); @@ -136,7 +136,7 @@ public class ExampleConcat { * @throws TransformerException In case of a XSL transformation problem * @throws SAXException In case of an XML-related problem */ - public void concatToPDF(File[] files, File pdffile) + public void concatToPDF(File[] files, File pdffile) throws IOException, TransformerException, SAXException { // Setup output OutputStream out = new java.io.FileOutputStream(pdffile); @@ -147,23 +147,23 @@ public class ExampleConcat { FOUserAgent userAgent = fopFactory.newFOUserAgent(); //Construct the AreaTreeModel that will received the individual pages - AreaTreeModel treeModel = new RenderPagesModel(userAgent, + AreaTreeModel treeModel = new RenderPagesModel(userAgent, MimeConstants.MIME_PDF, fontInfo, out); - + //Iterate over all intermediate files AreaTreeParser parser = new AreaTreeParser(); for (int i = 0; i < files.length; i++) { Source src = new StreamSource(files[i]); parser.parse(src, treeModel, userAgent); } - + //Signal the end of the processing. The renderer can finalize the target document. treeModel.endDocument(); } finally { out.close(); } } - + /** * Main method. * @param args command-line arguments @@ -171,12 +171,12 @@ public class ExampleConcat { public static void main(String[] args) { try { System.out.println("FOP ExampleConcat\n"); - + //Setup directories File baseDir = new File("."); File outDir = new File(baseDir, "out"); outDir.mkdirs(); - + //Setup output file File xsltfile = new File(baseDir, "xml/xslt/projectteam2fo.xsl"); File[] files = new File[] { @@ -184,31 +184,31 @@ public class ExampleConcat { new File(outDir, "team2.at.xml")}; File pdffile = new File(outDir, "ResultConcat.pdf"); for (int i = 0; i < files.length; i++) { - System.out.println("Intermediate file " + (i + 1) + ": " + System.out.println("Intermediate file " + (i + 1) + ": " + files[i].getCanonicalPath()); } System.out.println("PDF Output File: " + pdffile.getCanonicalPath()); System.out.println(); - + ProjectTeam team1 = ExampleObj2XML.createSampleProjectTeam(); ProjectTeam team2 = createAnotherProjectTeam(); - + ExampleConcat app = new ExampleConcat(); - + //Create intermediate files app.convertToIntermediate( - team1.getSourceForProjectTeam(), + team1.getSourceForProjectTeam(), new StreamSource(xsltfile), files[0]); app.convertToIntermediate( - team2.getSourceForProjectTeam(), + team2.getSourceForProjectTeam(), new StreamSource(xsltfile), files[1]); - + //Concatenate the individual intermediate files to one document app.concatToPDF(files, pdffile); - + System.out.println("Success!"); - + } catch (Exception e) { e.printStackTrace(System.err); System.exit(-1); diff --git a/examples/embedding/java/embedding/intermediate/ExampleStamp.java b/examples/embedding/java/embedding/intermediate/ExampleStamp.java index b1b0b77e7..c6123b718 100644 --- a/examples/embedding/java/embedding/intermediate/ExampleStamp.java +++ b/examples/embedding/java/embedding/intermediate/ExampleStamp.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 embedding.intermediate; import java.io.File; @@ -50,7 +50,7 @@ public class ExampleStamp { // configure fopFactory as desired private FopFactory fopFactory = FopFactory.newInstance(); - + /** * Stamps an intermediate file and renders it to a PDF file. * @param atfile the intermediate file (area tree XML) @@ -60,7 +60,7 @@ public class ExampleStamp { * @throws TransformerException In case of a XSL transformation problem * @throws SAXException In case of an XML-related problem */ - public void stampToPDF(File atfile, File stampSheet, File pdffile) + public void stampToPDF(File atfile, File stampSheet, File pdffile) throws IOException, TransformerException, SAXException { // Setup output OutputStream out = new java.io.FileOutputStream(pdffile); @@ -71,31 +71,31 @@ public class ExampleStamp { FOUserAgent userAgent = fopFactory.newFOUserAgent(); //Construct the AreaTreeModel that will received the individual pages - AreaTreeModel treeModel = new RenderPagesModel(userAgent, + AreaTreeModel treeModel = new RenderPagesModel(userAgent, MimeConstants.MIME_PDF, fontInfo, out); - + //Iterate over all intermediate files AreaTreeParser parser = new AreaTreeParser(); Source src = new StreamSource(atfile); Source xslt = new StreamSource(stampSheet); - + //Setup Transformer for XSLT processing TransformerFactory tFactory = TransformerFactory.newInstance(); Transformer transformer = tFactory.newTransformer(xslt); - + //Send XSLT result to AreaTreeParser SAXResult res = new SAXResult(parser.getContentHandler(treeModel, userAgent)); - + //Start XSLT transformation and area tree parsing transformer.transform(src, res); - + //Signal the end of the processing. The renderer can finalize the target document. treeModel.endDocument(); } finally { out.close(); } } - + /** * Main method. * @param args command-line arguments @@ -103,12 +103,12 @@ public class ExampleStamp { public static void main(String[] args) { try { System.out.println("FOP ExampleConcat\n"); - + //Setup directories File baseDir = new File("."); File outDir = new File(baseDir, "out"); outDir.mkdirs(); - + //Setup output file File xsltfile = new File(baseDir, "xml/xslt/projectteam2fo.xsl"); File atfile = new File(outDir, "team.at.xml"); @@ -120,19 +120,19 @@ public class ExampleStamp { System.out.println(); ProjectTeam team1 = ExampleObj2XML.createSampleProjectTeam(); - + //Create intermediate file ExampleConcat concatapp = new ExampleConcat(); concatapp.convertToIntermediate( - team1.getSourceForProjectTeam(), + team1.getSourceForProjectTeam(), new StreamSource(xsltfile), atfile); - + //Stamp document and produce a PDF from the intermediate format ExampleStamp app = new ExampleStamp(); app.stampToPDF(atfile, stampxsltfile, pdffile); - + System.out.println("Success!"); - + } catch (Exception e) { e.printStackTrace(System.err); System.exit(-1); diff --git a/examples/embedding/java/embedding/model/ProjectMember.java b/examples/embedding/java/embedding/model/ProjectMember.java index 0efc6d514..4b602b87f 100644 --- a/examples/embedding/java/embedding/model/ProjectMember.java +++ b/examples/embedding/java/embedding/model/ProjectMember.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 embedding.model; /** @@ -34,8 +34,8 @@ public class ProjectMember { */ public ProjectMember() { } - - + + /** * Convenience constructor. * @param name name of the project member diff --git a/examples/embedding/java/embedding/model/ProjectTeam.java b/examples/embedding/java/embedding/model/ProjectTeam.java index 3dfceb3db..47ae2b569 100644 --- a/examples/embedding/java/embedding/model/ProjectTeam.java +++ b/examples/embedding/java/embedding/model/ProjectTeam.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 embedding.model; import java.util.List; diff --git a/examples/embedding/java/embedding/model/ProjectTeamInputSource.java b/examples/embedding/java/embedding/model/ProjectTeamInputSource.java index 2953f41d7..dd9d31236 100644 --- a/examples/embedding/java/embedding/model/ProjectTeamInputSource.java +++ b/examples/embedding/java/embedding/model/ProjectTeamInputSource.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 embedding.model; import org.xml.sax.InputSource; diff --git a/examples/embedding/java/embedding/model/ProjectTeamXMLReader.java b/examples/embedding/java/embedding/model/ProjectTeamXMLReader.java index c86f94f9a..b08351a86 100644 --- a/examples/embedding/java/embedding/model/ProjectTeamXMLReader.java +++ b/examples/embedding/java/embedding/model/ProjectTeamXMLReader.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 embedding.model; //Java @@ -60,18 +60,18 @@ public class ProjectTeamXMLReader extends AbstractObjectReader { if (handler == null) { throw new IllegalStateException("ContentHandler not set"); } - + //Start the document handler.startDocument(); - + //Generate SAX events for the ProjectTeam generateFor(projectTeam); - + //End the document - handler.endDocument(); + handler.endDocument(); } - + /** * Generates SAX events for a ProjectTeam object. * @param projectTeam ProjectTeam object to use @@ -84,7 +84,7 @@ public class ProjectTeamXMLReader extends AbstractObjectReader { if (handler == null) { throw new IllegalStateException("ContentHandler not set"); } - + handler.startElement("projectteam"); handler.element("projectname", projectTeam.getProjectName()); Iterator i = projectTeam.getMembers().iterator(); @@ -107,7 +107,7 @@ public class ProjectTeamXMLReader extends AbstractObjectReader { if (handler == null) { throw new IllegalStateException("ContentHandler not set"); } - + handler.startElement("member"); handler.element("name", projectMember.getName()); handler.element("function", projectMember.getFunction()); diff --git a/examples/embedding/java/embedding/tools/AbstractObjectReader.java b/examples/embedding/java/embedding/tools/AbstractObjectReader.java index 8ec4836bb..641a90ca3 100644 --- a/examples/embedding/java/embedding/tools/AbstractObjectReader.java +++ b/examples/embedding/java/embedding/tools/AbstractObjectReader.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 embedding.tools; //Java @@ -33,7 +33,7 @@ import org.xml.sax.ErrorHandler; import org.xml.sax.EntityResolver; /** - * This class can be used as base class for XMLReaders that generate SAX + * This class can be used as base class for XMLReaders that generate SAX * events from Java objects. */ @@ -43,10 +43,10 @@ public abstract class AbstractObjectReader implements XMLReader { "http://xml.org/sax/features/namespaces"; private static final String NS_PREFIXES = "http://xml.org/sax/features/namespace-prefixes"; - + private Map features = new java.util.HashMap(); private ContentHandler orgHandler; - + /** Proxy for easy SAX event generation */ protected EasyGenerationContentHandlerProxy handler; /** Error handler */ @@ -60,7 +60,7 @@ public abstract class AbstractObjectReader implements XMLReader { setFeature(NAMESPACES, false); setFeature(NS_PREFIXES, false); } - + /* ============ XMLReader interface ============ */ /** diff --git a/examples/embedding/java/embedding/tools/EasyGenerationContentHandlerProxy.java b/examples/embedding/java/embedding/tools/EasyGenerationContentHandlerProxy.java index fe35ad426..c9780a1c1 100644 --- a/examples/embedding/java/embedding/tools/EasyGenerationContentHandlerProxy.java +++ b/examples/embedding/java/embedding/tools/EasyGenerationContentHandlerProxy.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 embedding.tools; //SAX @@ -28,10 +28,10 @@ import org.xml.sax.helpers.AttributesImpl; /** * This class is an implementation of ContentHandler which acts as a proxy to - * another ContentHandler and has the purpose to provide a few handy methods + * another ContentHandler and has the purpose to provide a few handy methods * that make life easier when generating SAX events. *
- * Note: This class is only useful for simple cases with no namespaces. + * Note: This class is only useful for simple cases with no namespaces. */ public class EasyGenerationContentHandlerProxy implements ContentHandler { @@ -64,8 +64,8 @@ public class EasyGenerationContentHandlerProxy implements ContentHandler { /** * Sends the notification of the beginning of an element. * @param name Name for the element. - * @param atts The attributes attached to the element. If there are no - * attributes, it shall be an empty Attributes object. + * @param atts The attributes attached to the element. If there are no + * attributes, it shall be an empty Attributes object. * @throws SAXException Any SAX exception, possibly wrapping another exception. */ public void startElement(String name, Attributes atts) throws SAXException { @@ -108,8 +108,8 @@ public class EasyGenerationContentHandlerProxy implements ContentHandler { * Sends notifications for a whole element with some String content. * @param name Name for the element. * @param value Content of the element. - * @param atts The attributes attached to the element. If there are no - * attributes, it shall be an empty Attributes object. + * @param atts The attributes attached to the element. If there are no + * attributes, it shall be an empty Attributes object. * @throws SAXException Any SAX exception, possibly wrapping another exception. */ public void element(String name, String value, Attributes atts) throws SAXException { @@ -165,7 +165,7 @@ public class EasyGenerationContentHandlerProxy implements ContentHandler { /** * @see org.xml.sax.ContentHandler#startElement(String, String, String, Attributes) */ - public void startElement(String namespaceURI, String localName, + public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { target.startElement(namespaceURI, localName, qName, atts); } @@ -174,7 +174,7 @@ public class EasyGenerationContentHandlerProxy implements ContentHandler { /** * @see org.xml.sax.ContentHandler#endElement(String, String, String) */ - public void endElement(String namespaceURI, String localName, String qName) + public void endElement(String namespaceURI, String localName, String qName) throws SAXException { target.endElement(namespaceURI, localName, qName); } diff --git a/examples/hyphenation/src/org/apache/fop/hyphenation/HyphenationTreeAnalysis.java b/examples/hyphenation/src/org/apache/fop/hyphenation/HyphenationTreeAnalysis.java index ccd86ab25..dc8e16202 100644 --- a/examples/hyphenation/src/org/apache/fop/hyphenation/HyphenationTreeAnalysis.java +++ b/examples/hyphenation/src/org/apache/fop/hyphenation/HyphenationTreeAnalysis.java @@ -33,15 +33,15 @@ import java.util.zip.ZipFile; import java.util.zip.ZipEntry; /** - * This class provides some useful methods to print the structure of a HyphenationTree object + * This class provides some useful methods to print the structure of a HyphenationTree object */ public class HyphenationTreeAnalysis extends TernaryTreeAnalysis { /** - * The HyphenationTree object to analyse + * The HyphenationTree object to analyse */ protected HyphenationTree ht; - + /** * @param ht the HyphenationTree object */ @@ -49,7 +49,7 @@ public class HyphenationTreeAnalysis extends TernaryTreeAnalysis { super(ht); this.ht = ht; } - + /** * Class representing a node of the HyphenationTree object */ @@ -65,7 +65,7 @@ public class HyphenationTreeAnalysis extends TernaryTreeAnalysis { value = readValue().toString(); } } - + private StringBuffer readValue() { StringBuffer s = new StringBuffer(); int i = (int) ht.eq[index]; @@ -100,7 +100,7 @@ public class HyphenationTreeAnalysis extends TernaryTreeAnalysis { return super.toNodeString(); } } - + /* (non-Javadoc) * @see org.apache.fop.hyphenation.TernaryTreeAnalysis.Node#toCompactString() */ @@ -118,7 +118,7 @@ public class HyphenationTreeAnalysis extends TernaryTreeAnalysis { return super.toCompactString(); } } - + /* (non-Javadoc) * @see java.lang.Object#toString() */ @@ -130,7 +130,7 @@ public class HyphenationTreeAnalysis extends TernaryTreeAnalysis { } return s.toString(); } - + } private void addNode(int nodeIndex, List strings, NodeString ns) { @@ -182,7 +182,7 @@ public class HyphenationTreeAnalysis extends TernaryTreeAnalysis { } tree.append(indentString); tree.append(ns.string + "\n"); - + if (i + 1 == strings.size()) { continue; } @@ -199,10 +199,10 @@ public class HyphenationTreeAnalysis extends TernaryTreeAnalysis { } tree.append(indentString + "\n"); } - + return tree.toString(); } - + /** * Construct the tree representation of the HyphenationTree object * @return the string representing the tree @@ -214,7 +214,7 @@ public class HyphenationTreeAnalysis extends TernaryTreeAnalysis { addNode(1, strings, ns); return toTree(strings); } - + /** * Construct the compact node representation of the HyphenationTree object * @return the string representing the tree @@ -229,7 +229,7 @@ public class HyphenationTreeAnalysis extends TernaryTreeAnalysis { } return s.toString(); } - + /** * Construct the node representation of the HyphenationTree object * @return the string representing the tree @@ -244,17 +244,17 @@ public class HyphenationTreeAnalysis extends TernaryTreeAnalysis { } return s.toString(); } - + /** * Construct the printed representation of the HyphenationTree object * @return the string representing the tree */ public String toString() { StringBuffer s = new StringBuffer(); - + s.append("classes: \n"); s.append((new TernaryTreeAnalysis(ht.classmap)).toString()); - + s.append("\npatterns: \n"); s.append(super.toString()); s.append("vspace: "); @@ -275,12 +275,12 @@ public class HyphenationTreeAnalysis extends TernaryTreeAnalysis { } } s.append("\n"); - + return s.toString(); } /** - * Provide interactive access to a HyphenationTree object and its representation methods + * Provide interactive access to a HyphenationTree object and its representation methods * @param args the arguments */ public static void main(String[] args) { @@ -327,7 +327,7 @@ public class HyphenationTreeAnalysis extends TernaryTreeAnalysis { System.out.print("Object file name: "); token = in.readLine().trim(); try { - String[] parts = token.split(":"); + String[] parts = token.split(":"); InputStream is = null; if (parts.length == 1) { is = new FileInputStream(token); @@ -399,7 +399,7 @@ public class HyphenationTreeAnalysis extends TernaryTreeAnalysis { try { BufferedReader reader = new BufferedReader(new FileReader(token)); String line; - + starttime = System.currentTimeMillis(); while ((line = reader.readLine()) != null) { // System.out.print("\nline: "); @@ -422,7 +422,7 @@ public class HyphenationTreeAnalysis extends TernaryTreeAnalysis { long result = endtime - starttime; System.out.println(counter + " words in " + result + " Milliseconds hyphenated"); - + } else if (token.equals("q")) { break; } diff --git a/examples/hyphenation/src/org/apache/fop/hyphenation/TernaryTreeAnalysis.java b/examples/hyphenation/src/org/apache/fop/hyphenation/TernaryTreeAnalysis.java index 9ac6ff804..a783716a5 100644 --- a/examples/hyphenation/src/org/apache/fop/hyphenation/TernaryTreeAnalysis.java +++ b/examples/hyphenation/src/org/apache/fop/hyphenation/TernaryTreeAnalysis.java @@ -23,15 +23,15 @@ import java.util.ArrayList; import java.util.List; /** - * This class provides some useful methods to print the structure of a TernaryTree object + * This class provides some useful methods to print the structure of a TernaryTree object */ public class TernaryTreeAnalysis { /** - * The TernaryTree object to analyse + * The TernaryTree object to analyse */ protected TernaryTree tt; - + /** * @param tt the TernaryTree object */ @@ -43,27 +43,27 @@ public class TernaryTreeAnalysis { * Class representing a string of nodes in the tree representation of a TernaryTree */ public static class NodeString { - + /** - * The node string being constructed + * The node string being constructed */ public StringBuffer string = new StringBuffer(); - + /** - * The indent of the node string + * The indent of the node string */ public int indent; - + /** - * The list of branchpoints into the high direction + * The list of branchpoints into the high direction */ public List high = new ArrayList(); - + /** - * The list of branchpoints into the low direction + * The list of branchpoints into the low direction */ public List low = new ArrayList(); - + /** * @param indent the indent of the nodestring */ @@ -78,34 +78,34 @@ public class TernaryTreeAnalysis { * Class representing a node of the TernaryTree object */ protected class Node { - + /** - * The index of the node + * The index of the node */ protected int index = 0; - + /** - * The index of the high node + * The index of the high node */ protected int high = 0; - + /** - * The index of the high node + * The index of the high node */ protected int low = 0; - + /** - * The index of the equal node + * The index of the equal node */ protected int equal = 0; - + /** - * The key following the node + * The key following the node */ protected String key = null; - + /** - * True if this is a leaf node + * True if this is a leaf node */ protected boolean isLeafNode = false; @@ -132,7 +132,7 @@ public class TernaryTreeAnalysis { equal = tt.eq[index]; } } - + private StringBuffer readKey() { StringBuffer s = new StringBuffer(); int i = (int) tt.lo[index]; @@ -160,7 +160,7 @@ public class TernaryTreeAnalysis { } return s.toString(); } - + /** * Construct the compact string representation of the node * @return the string representing the node @@ -184,7 +184,7 @@ public class TernaryTreeAnalysis { } return s.toString(); } - + /* (non-Javadoc) * @see java.lang.Object#toString() */ @@ -204,9 +204,9 @@ public class TernaryTreeAnalysis { } return s.toString(); } - + } - + /** * Construct the compact node representation of the TernaryTree object * @return the string representing the tree @@ -221,7 +221,7 @@ public class TernaryTreeAnalysis { } return s.toString(); } - + /** * Construct the node representation of the TernaryTree object * @return the string representing the tree @@ -236,7 +236,7 @@ public class TernaryTreeAnalysis { } return s.toString(); } - + private static StringBuffer toString(char[] c) { StringBuffer s = new StringBuffer(); for (int i = 0; i < c.length; ++i) { @@ -244,8 +244,8 @@ public class TernaryTreeAnalysis { s.append(","); } return s; - } - + } + /* (non-Javadoc) * @see java.lang.Object#toString() */ @@ -255,15 +255,15 @@ public class TernaryTreeAnalysis { s.append("hi: "); s.append(toString(tt.hi)); s.append("\n"); - + s.append("eq: "); s.append(toString(tt.eq)); s.append("\n"); - + s.append("lo: "); s.append(toString(tt.lo)); s.append("\n"); - + s.append("sc: "); for (int i = 0; i < tt.sc.length; ++i) { if (tt.sc[i] == 0) { @@ -275,7 +275,7 @@ public class TernaryTreeAnalysis { } } s.append("\n"); - + s.append("kv: "); for (int i = 0; i < tt.kv.length(); ++i) { if (tt.kv.get(i) == 0) { @@ -285,17 +285,17 @@ public class TernaryTreeAnalysis { } } s.append("\n"); - + s.append("freenode: "); s.append((int) tt.freenode); s.append("\n"); - + s.append("root: "); s.append((int) tt.root); s.append("\n"); - + return s.toString(); } - + } diff --git a/examples/mathml/src/org/apache/fop/mathml/ImageLoaderFactoryMathML.java b/examples/mathml/src/org/apache/fop/mathml/ImageLoaderFactoryMathML.java index b0e94222a..cac43c721 100644 --- a/examples/mathml/src/org/apache/fop/mathml/ImageLoaderFactoryMathML.java +++ b/examples/mathml/src/org/apache/fop/mathml/ImageLoaderFactoryMathML.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,28 +30,28 @@ public class ImageLoaderFactoryMathML extends AbstractImageLoaderFactory { /** MathML MIME type */ public static final String MIME_MATHML = "text/mathml"; - + private static final ImageFlavor[] FLAVORS = new ImageFlavor[] { ImageFlavor.GRAPHICS2D}; - + private static final String[] MIMES = new String[] { MIME_MATHML}; - + /** {@inheritDoc} */ public String[] getSupportedMIMETypes() { return MIMES; } - + /** {@inheritDoc} */ public ImageFlavor[] getSupportedFlavors(String mime) { return FLAVORS; } - + /** {@inheritDoc} */ public ImageLoader newImageLoader(ImageFlavor targetFlavor) { return new ImageLoaderMathML(targetFlavor); } - + /** {@inheritDoc} */ public int getUsagePenalty(String mime, ImageFlavor flavor) { return 0; diff --git a/examples/mathml/src/org/apache/fop/mathml/ImageLoaderMathML.java b/examples/mathml/src/org/apache/fop/mathml/ImageLoaderMathML.java index 900b9d614..d110ca3dc 100644 --- a/examples/mathml/src/org/apache/fop/mathml/ImageLoaderMathML.java +++ b/examples/mathml/src/org/apache/fop/mathml/ImageLoaderMathML.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. @@ -47,7 +47,7 @@ public class ImageLoaderMathML extends AbstractImageLoader { } this.targetFlavor = targetFlavor; } - + /** {@inheritDoc} */ public ImageFlavor getTargetFlavor() { return this.targetFlavor; diff --git a/examples/mathml/src/org/apache/fop/mathml/MathMLElement.java b/examples/mathml/src/org/apache/fop/mathml/MathMLElement.java index 82bd85a17..9bd326f2b 100644 --- a/examples/mathml/src/org/apache/fop/mathml/MathMLElement.java +++ b/examples/mathml/src/org/apache/fop/mathml/MathMLElement.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.mathml; import java.awt.Color; @@ -59,9 +59,9 @@ public class MathMLElement extends MathMLObj { } /** {@inheritDoc} */ - public void processNode(String elementName, - Locator locator, - Attributes attlist, + public void processNode(String elementName, + Locator locator, + Attributes attlist, PropertyList propertyList) throws FOPException { super.processNode(elementName, locator, attlist, propertyList); createBasicDocument(); diff --git a/examples/mathml/src/org/apache/fop/mathml/MathMLElementMapping.java b/examples/mathml/src/org/apache/fop/mathml/MathMLElementMapping.java index fdfa0b5c7..c9854d1c7 100644 --- a/examples/mathml/src/org/apache/fop/mathml/MathMLElementMapping.java +++ b/examples/mathml/src/org/apache/fop/mathml/MathMLElementMapping.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.mathml; import java.util.HashMap; @@ -32,7 +32,7 @@ import org.apache.fop.fo.FONode; public class MathMLElementMapping extends ElementMapping { /** MathML Namespace */ - public static final String NAMESPACE = "http://www.w3.org/1998/Math/MathML"; + public static final String NAMESPACE = "http://www.w3.org/1998/Math/MathML"; /** Main constructor. */ public MathMLElementMapping() { diff --git a/examples/mathml/src/org/apache/fop/mathml/MathMLObj.java b/examples/mathml/src/org/apache/fop/mathml/MathMLObj.java index 9d2b78047..f2f5317e3 100644 --- a/examples/mathml/src/org/apache/fop/mathml/MathMLObj.java +++ b/examples/mathml/src/org/apache/fop/mathml/MathMLObj.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.mathml; // FOP diff --git a/examples/mathml/src/org/apache/fop/mathml/PreloaderMathML.java b/examples/mathml/src/org/apache/fop/mathml/PreloaderMathML.java index 3015462ce..193ccf6e3 100644 --- a/examples/mathml/src/org/apache/fop/mathml/PreloaderMathML.java +++ b/examples/mathml/src/org/apache/fop/mathml/PreloaderMathML.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.mathml; import java.awt.Dimension; @@ -58,8 +58,8 @@ public class PreloaderMathML extends AbstractImagePreloader { private static Log log = LogFactory.getLog(PreloaderMathML.class); private boolean jeuclidAvailable = true; - - /** {@inheritDoc} */ + + /** {@inheritDoc} */ public ImageInfo preloadImage(String uri, Source src, ImageContext context) throws IOException { if (!ImageUtil.hasInputStream(src)) { @@ -89,21 +89,21 @@ public class PreloaderMathML extends AbstractImagePreloader { * class. */ class Loader { - + private ImageInfo getImage(String uri, Source src, ImageContext context) { InputStream in = new UnclosableInputStream(ImageUtil.needInputStream(src)); try { int length = in.available(); in.mark(length + 1); - + TransformerFactory tFactory = TransformerFactory.newInstance(); Transformer transformer = tFactory.newTransformer(); Source source = new StreamSource(in); SAXMathBuilder mathBuilder = new SAXMathBuilder(); SAXResult res = new SAXResult(mathBuilder); transformer.transform(source, res); - + String fontname = "Helvetica"; int fontstyle = 0; int displayfontsize = 12; @@ -122,7 +122,7 @@ public class PreloaderMathML extends AbstractImagePreloader { mathBuilder.getMathRootElement(), fontname, fontstyle, inlinefontsize, displayfontsize); - + ImageInfo info = new ImageInfo(uri, "text/mathml"); final ImageSize size = new ImageSize(); size.setSizeInMillipoints( @@ -142,13 +142,13 @@ public class PreloaderMathML extends AbstractImagePreloader { public void paint(Graphics2D g2d, Rectangle2D area) { base.paint(g2d); } - + }; - + //The whole image had to be loaded for this, so keep it Image image = new ImageGraphics2D(info, painter); info.getCustomObjects().put(ImageInfo.ORIGINAL_IMAGE, image); - + return info; } catch (NoClassDefFoundError ncdfe) { try { diff --git a/examples/plan/src/org/apache/fop/plan/ActionInfo.java b/examples/plan/src/org/apache/fop/plan/ActionInfo.java index 350ccce8f..1535ed5ec 100644 --- a/examples/plan/src/org/apache/fop/plan/ActionInfo.java +++ b/examples/plan/src/org/apache/fop/plan/ActionInfo.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,13 +16,13 @@ */ /* $Id$ */ - + package org.apache.fop.plan; import java.util.Date; public class ActionInfo { - + public static final int TASK = 1; public static final int MILESTONE = 2; public static final int GROUPING = 3; diff --git a/examples/plan/src/org/apache/fop/plan/EventList.java b/examples/plan/src/org/apache/fop/plan/EventList.java index 188c9975a..53b32f7c0 100644 --- a/examples/plan/src/org/apache/fop/plan/EventList.java +++ b/examples/plan/src/org/apache/fop/plan/EventList.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,13 +16,13 @@ */ /* $Id$ */ - + package org.apache.fop.plan; import java.util.List; public class EventList { - + private List data = new java.util.ArrayList(); public void addGroupInfo(GroupInfo set) { diff --git a/examples/plan/src/org/apache/fop/plan/GroupInfo.java b/examples/plan/src/org/apache/fop/plan/GroupInfo.java index e94170d76..a83228197 100644 --- a/examples/plan/src/org/apache/fop/plan/GroupInfo.java +++ b/examples/plan/src/org/apache/fop/plan/GroupInfo.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,13 +16,13 @@ */ /* $Id$ */ - + package org.apache.fop.plan; import java.util.List; public class GroupInfo { - + private String name; private List actions = new java.util.ArrayList(); diff --git a/examples/plan/src/org/apache/fop/plan/Main.java b/examples/plan/src/org/apache/fop/plan/Main.java index c2b1a5ad5..7b6f5a05e 100644 --- a/examples/plan/src/org/apache/fop/plan/Main.java +++ b/examples/plan/src/org/apache/fop/plan/Main.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.plan; import java.io.InputStream; diff --git a/examples/plan/src/org/apache/fop/plan/PlanDrawer.java b/examples/plan/src/org/apache/fop/plan/PlanDrawer.java index 8398659e0..7f79bb737 100644 --- a/examples/plan/src/org/apache/fop/plan/PlanDrawer.java +++ b/examples/plan/src/org/apache/fop/plan/PlanDrawer.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.plan; import java.util.HashMap; @@ -27,7 +27,7 @@ import org.w3c.dom.Document; * This interface defines how a plan drawer is converted. */ public interface PlanDrawer { - + Document createDocument(EventList data, float w, float h, HashMap hints); } diff --git a/examples/plan/src/org/apache/fop/plan/PlanElement.java b/examples/plan/src/org/apache/fop/plan/PlanElement.java index d910076c6..e7fb8a1e7 100644 --- a/examples/plan/src/org/apache/fop/plan/PlanElement.java +++ b/examples/plan/src/org/apache/fop/plan/PlanElement.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.plan; import java.awt.geom.Point2D; @@ -48,7 +48,7 @@ public class PlanElement extends PlanObj { } /** {@inheritDoc} */ - public void processNode(String elementName, Locator locator, + public void processNode(String elementName, Locator locator, Attributes attlist, PropertyList propertyList) throws FOPException { super.processNode(elementName, locator, attlist, propertyList); @@ -67,7 +67,7 @@ public class PlanElement extends PlanObj { svgDoc = pr.createSVGDocument(doc); width = pr.getWidth(); height = pr.getHeight(); - + doc = svgDoc; } } catch (Throwable t) { diff --git a/examples/plan/src/org/apache/fop/plan/PlanElementMapping.java b/examples/plan/src/org/apache/fop/plan/PlanElementMapping.java index c33c25edf..781fd8371 100644 --- a/examples/plan/src/org/apache/fop/plan/PlanElementMapping.java +++ b/examples/plan/src/org/apache/fop/plan/PlanElementMapping.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.plan; import org.w3c.dom.DOMImplementation; @@ -30,7 +30,7 @@ import org.apache.fop.fo.FONode; public class PlanElementMapping extends ElementMapping { /** Plan Namespace */ - public static final String NAMESPACE = "http://xmlgraphics.apache.org/fop/plan"; + public static final String NAMESPACE = "http://xmlgraphics.apache.org/fop/plan"; /** Main constructor. */ public PlanElementMapping() { diff --git a/examples/plan/src/org/apache/fop/plan/PlanHints.java b/examples/plan/src/org/apache/fop/plan/PlanHints.java index 0411262ab..2a2c1333a 100644 --- a/examples/plan/src/org/apache/fop/plan/PlanHints.java +++ b/examples/plan/src/org/apache/fop/plan/PlanHints.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,14 +16,14 @@ */ /* $Id$ */ - + package org.apache.fop.plan; /** * This interface defines some constants for use in the plan package. */ public interface PlanHints { - + /** Border attribute */ public static final String PLAN_BORDER = "border"; /** Legend attribute */ diff --git a/examples/plan/src/org/apache/fop/plan/PlanObj.java b/examples/plan/src/org/apache/fop/plan/PlanObj.java index 36f3243a6..ca26a8039 100644 --- a/examples/plan/src/org/apache/fop/plan/PlanObj.java +++ b/examples/plan/src/org/apache/fop/plan/PlanObj.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.plan; // FOP diff --git a/examples/plan/src/org/apache/fop/plan/PlanRenderer.java b/examples/plan/src/org/apache/fop/plan/PlanRenderer.java index 0b592adc6..8b7978259 100644 --- a/examples/plan/src/org/apache/fop/plan/PlanRenderer.java +++ b/examples/plan/src/org/apache/fop/plan/PlanRenderer.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.plan; @@ -34,9 +34,9 @@ import org.w3c.dom.NodeList; import org.apache.batik.dom.svg.SVGDOMImplementation; public class PlanRenderer { - + private static final String SVG_NAMESPACE = SVGDOMImplementation.SVG_NAMESPACE_URI; - + private String fontFamily = "sansserif"; private float fontSize = 12; private String type = ""; diff --git a/examples/plan/src/org/apache/fop/plan/PreloaderPlan.java b/examples/plan/src/org/apache/fop/plan/PreloaderPlan.java index 58d5be477..b8a7a612c 100644 --- a/examples/plan/src/org/apache/fop/plan/PreloaderPlan.java +++ b/examples/plan/src/org/apache/fop/plan/PreloaderPlan.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.plan; import java.io.IOException; @@ -52,7 +52,7 @@ public class PreloaderPlan extends AbstractImagePreloader { /** Logger instance */ private static Log log = LogFactory.getLog(PreloaderPlan.class); - /** {@inheritDoc} */ + /** {@inheritDoc} */ public ImageInfo preloadImage(String uri, Source src, ImageContext context) throws IOException { if (!ImageUtil.hasInputStream(src)) { @@ -75,13 +75,13 @@ public class PreloaderPlan extends AbstractImagePreloader { Source source = new StreamSource(in); DOMResult res = new DOMResult(); transformer.transform(source, res); - + //Have to render the plan to know its size PlanRenderer pr = new PlanRenderer(); Document svgDoc = pr.createSVGDocument((Document)res.getNode()); float width = pr.getWidth(); float height = pr.getHeight(); - + //Return converted SVG image ImageInfo info = new ImageInfo(uri, "image/svg+xml"); final ImageSize size = new ImageSize(); @@ -97,7 +97,7 @@ public class PreloaderPlan extends AbstractImagePreloader { Image image = new ImageXMLDOM(info, svgDoc, svgDoc.getDocumentElement().getNamespaceURI()); info.getCustomObjects().put(ImageInfo.ORIGINAL_IMAGE, image); - + return info; } catch (TransformerException e) { try { diff --git a/examples/plan/src/org/apache/fop/plan/SimplePlanDrawer.java b/examples/plan/src/org/apache/fop/plan/SimplePlanDrawer.java index 71025f15b..b49256a31 100644 --- a/examples/plan/src/org/apache/fop/plan/SimplePlanDrawer.java +++ b/examples/plan/src/org/apache/fop/plan/SimplePlanDrawer.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.plan; import java.text.DateFormat; @@ -35,9 +35,9 @@ import org.apache.fop.svg.SVGUtilities; * Simple plan drawer implementation. */ public class SimplePlanDrawer implements PlanDrawer { - + private static final String SVG_NAMESPACE = SVGDOMImplementation.SVG_NAMESPACE_URI; - + private float fontSize; private HashMap hints; private java.awt.Font font = null; @@ -91,8 +91,8 @@ public class SimplePlanDrawer implements PlanDrawer { svgRoot.setAttributeNS(null, "width", "" + width); svgRoot.setAttributeNS(null, "height", "" + height); svgRoot.setAttributeNS(null, "style", - "font-size:" + 8 - + ";font-family:" + "font-size:" + 8 + + ";font-family:" + hints.get(PlanHints.FONT_FAMILY)); font = new java.awt.Font((String)hints.get(PlanHints.FONT_FAMILY), @@ -249,8 +249,8 @@ public class SimplePlanDrawer implements PlanDrawer { taskGraphic = SVGUtilities.createRect(doc, left + daysToStart * 300 / (totalDays - 2), topEdge + 2, days * 300 / (totalDays - 2), 10); - taskGraphic.setAttributeNS(null, - "style", + taskGraphic.setAttributeNS(null, + "style", "stroke:black;fill:blue;stroke-width:1;clip-path:url(#clip3)"); g.appendChild(taskGraphic); break; @@ -259,8 +259,8 @@ public class SimplePlanDrawer implements PlanDrawer { "m " + (left + daysToStart * 300 / (totalDays - 2) - 6) + " " + (topEdge + 6) + "l6 6l6-6l-6-6z"); - taskGraphic.setAttributeNS(null, - "style", + taskGraphic.setAttributeNS(null, + "style", "stroke:black;fill:black;stroke-width:1;clip-path:url(#clip3)"); g.appendChild(taskGraphic); text = SVGUtilities.createText(doc, @@ -271,7 +271,7 @@ public class SimplePlanDrawer implements PlanDrawer { break; case ActionInfo.GROUPING: taskGraphic = SVGUtilities.createPath(doc, - "m " + (left + "m " + (left + daysToStart * 300 / (totalDays - 2) - 6) + " " + (topEdge + 6) + "l6 -6l" + (days * 300 / (totalDays - 2)) @@ -279,7 +279,7 @@ public class SimplePlanDrawer implements PlanDrawer { + -(days * 300 / (totalDays - 2) - 8) + " 0l-4 4l-6-6z"); taskGraphic.setAttributeNS(null, - "style", + "style", "stroke:black;fill:black;stroke-width:1;clip-path:url(#clip3)"); g.appendChild(taskGraphic); break; diff --git a/src/codegen/java/org/apache/fop/tools/EventConventionException.java b/src/codegen/java/org/apache/fop/tools/EventConventionException.java index 27a7fcd50..363850b95 100644 --- a/src/codegen/java/org/apache/fop/tools/EventConventionException.java +++ b/src/codegen/java/org/apache/fop/tools/EventConventionException.java @@ -33,5 +33,5 @@ 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 index ebb960a8e..2e008a130 100644 --- a/src/codegen/java/org/apache/fop/tools/EventProducerCollector.java +++ b/src/codegen/java/org/apache/fop/tools/EventProducerCollector.java @@ -46,7 +46,7 @@ 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); @@ -59,7 +59,7 @@ public class EventProducerCollector { m.put("double", Double.class); PRIMITIVE_MAP = Collections.unmodifiableMap(m); } - + private DocletTagFactory tagFactory; private EventModel model = new EventModel(); @@ -81,21 +81,25 @@ public class EventProducerCollector { /** * Scans a file and processes it if it extends the {@link EventProducer} interface. * @param src the source file (a Java source file) + * @return true if the file contained an EventProducer interface * @throws IOException if an I/O error occurs * @throws EventConventionException if the EventProducer conventions are violated * @throws ClassNotFoundException if a required class cannot be found */ - public void scanFile(File src) + public boolean scanFile(File src) throws IOException, EventConventionException, ClassNotFoundException { JavaDocBuilder builder = new JavaDocBuilder(this.tagFactory); builder.addSource(src); JavaClass[] classes = builder.getClasses(); + boolean eventProducerFound = false; for (int i = 0, c = classes.length; i < c; i++) { JavaClass clazz = classes[i]; if (clazz.isInterface() && implementsInterface(clazz, CLASSNAME_EVENT_PRODUCER)) { processEventProducerInterface(clazz); + eventProducerFound = true; } } + return eventProducerFound; } private boolean implementsInterface(JavaClass clazz, String intf) { @@ -146,13 +150,13 @@ public class EventProducerCollector { 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 { + } else { severity = EventSeverity.INFO; } EventMethodModel methodMeta = new EventMethodModel( @@ -192,7 +196,7 @@ public class EventProducerCollector { public EventModel getModel() { return this.model; } - + /** * Saves the accumulated event model to an XML file. * @param modelFile the target model file @@ -201,5 +205,5 @@ public class EventProducerCollector { 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 index e00b05b55..b089a361e 100644 --- a/src/codegen/java/org/apache/fop/tools/EventProducerCollectorTask.java +++ b/src/codegen/java/org/apache/fop/tools/EventProducerCollectorTask.java @@ -63,16 +63,21 @@ public class EventProducerCollectorTask extends Task { public void execute() throws BuildException { try { EventProducerCollector collector = new EventProducerCollector(); - processFileSets(collector); + long lastModified = processFileSets(collector); File parentDir = getModelFile().getParentFile(); if (!parentDir.exists() && !parentDir.mkdirs()) { throw new BuildException( "Could not create target directory for event model file: " + parentDir); } - collector.saveModelToXML(getModelFile()); - log("Event model written to " + getModelFile()); + if (!getModelFile().exists() || lastModified > getModelFile().lastModified()) { + collector.saveModelToXML(getModelFile()); + log("Event model written to " + getModelFile()); + } if (getTranslationFile() != null) { - updateTranslationFile(); + if (!getTranslationFile().exists() + || lastModified > getTranslationFile().lastModified()) { + updateTranslationFile(); + } } } catch (ClassNotFoundException e) { throw new BuildException(e); @@ -164,12 +169,14 @@ public class EventProducerCollectorTask extends Task { /** * Processes the file sets defined for the task. * @param collector the collector to use for collecting the event producers + * @return the time of the latest modification of any of the files inspected * @throws IOException if an I/O error occurs * @throws EventConventionException if the EventProducer conventions are violated * @throws ClassNotFoundException if a required class cannot be found */ - protected void processFileSets(EventProducerCollector collector) + protected long processFileSets(EventProducerCollector collector) throws IOException, EventConventionException, ClassNotFoundException { + long lastModified = 0; Iterator iter = filesets.iterator(); while (iter.hasNext()) { FileSet fs = (FileSet)iter.next(); @@ -179,9 +186,13 @@ public class EventProducerCollectorTask extends Task { for (int i = 0, c = srcFiles.length; i < c; i++) { String filename = srcFiles[i]; File src = new File(directory, filename); - collector.scanFile(src); + boolean eventProducerFound = collector.scanFile(src); + if (eventProducerFound) { + lastModified = Math.max(lastModified, src.lastModified()); + } } } + return lastModified; } /** diff --git a/src/codegen/unicode/java/org/apache/fop/text/linebreak/GenerateLineBreakUtils.java b/src/codegen/unicode/java/org/apache/fop/text/linebreak/GenerateLineBreakUtils.java index 532e6a44b..cb0288334 100644 --- a/src/codegen/unicode/java/org/apache/fop/text/linebreak/GenerateLineBreakUtils.java +++ b/src/codegen/unicode/java/org/apache/fop/text/linebreak/GenerateLineBreakUtils.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. @@ -67,7 +67,7 @@ public class GenerateLineBreakUtils { * table for the table driven line breaking algorithm described in * UTR #14. * TODO: Code points above the base plane are simply ignored. - * + * * @param lineBreakFileName Name of line break property file (part of Unicode files). * @param propertyValueFileName Name of property values alias file (part of Unicode files). * @param breakPairFileName Name of pair table file (not part of the unicode files). @@ -109,7 +109,7 @@ public class GenerateLineBreakUtils { if (line != null) { lineTokens = line.split("\\s+"); byte columnNumber = 0; - + for (int i = 0; i < lineTokens.length; ++i) { name = lineTokens[i]; if (name.length() > 0) { @@ -481,7 +481,7 @@ public class GenerateLineBreakUtils { * Read line break property value names and the actual properties for the Unicode * characters from the respective Unicode files. * TODO: Code points above the base plane are simply ignored. - * + * * @param lineBreakFileName Name of line break property file. * @param propertyValueFileName Name of property values alias file. * @throws Exception in case anything goes wrong. @@ -600,7 +600,7 @@ public class GenerateLineBreakUtils { * Determine a good block size for the two stage optimized storage of the * line breaking properties. Note: the memory utilization calculation is a rule of thumb, * don't take it too serious. - * + * * @param lineBreakFileName Name of line break property file. * @param propertyValueFileName Name of property values alias file. * @throws Exception in case anything goes wrong. diff --git a/src/documentation/content/xdocs/DnI/BookMaker.java b/src/documentation/content/xdocs/DnI/BookMaker.java index 3f8366b4b..5a70cb030 100644 --- a/src/documentation/content/xdocs/DnI/BookMaker.java +++ b/src/documentation/content/xdocs/DnI/BookMaker.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. @@ -75,7 +75,7 @@ import org.apache.fop.apps.FOPException; import org.apache.fop.messaging.MessageHandler; /** - * This class converts an XML file to PDF using + * This class converts an XML file to PDF using * JAXP (XSLT) and FOP (XSL:FO). */ public class BookMaker implements ErrorHandler { @@ -113,7 +113,7 @@ public class BookMaker implements ErrorHandler { throw e; } - public void makeBook() + public void makeBook() throws IOException, FOPException, TransformerException, FactoryConfigurationError, ParserConfigurationException, SAXException { @@ -160,7 +160,7 @@ public class BookMaker implements ErrorHandler { + " as SAX parser"); xmlReader.setErrorHandler(this); xmlReader.setEntityResolver(resolver); - + // Setup SAX source fis = new FileInputStream(xmlFile); is = new InputSource(fis); @@ -175,7 +175,7 @@ public class BookMaker implements ErrorHandler { + " as SAX parser"); xmlReader.setErrorHandler(this); xmlReader.setEntityResolver(resolver); - + // Setup SAX source fis = new FileInputStream(xsltFile); is = new InputSource(fis); @@ -210,7 +210,7 @@ public class BookMaker implements ErrorHandler { + " as TrAX transformer"); // Set the value of parameters, if any, defined for stylesheet - if (xsltParams != null) { + if (xsltParams != null) { for (int i = 0; i < xsltParams.size(); i += 2) { transformer.setParameter ((String) xsltParams.elementAt(i), @@ -299,7 +299,7 @@ public class BookMaker implements ErrorHandler { } if (cl.hasOption("xsl")) { app.xsltFile = new File(cl.getOptionValue("xsl")); - } + } if (cl.hasOption("out")) { app.outFile = new File(cl.getOptionValue("out")); } @@ -323,9 +323,9 @@ public class BookMaker implements ErrorHandler { } app.logger.info(""); app.logger.info("Transforming..."); - + app.makeBook(); - + app.logger.info("Transforming done"); } catch (Exception e) { app.logger.error(ExceptionUtil.printStackTrace(e)); diff --git a/src/documentation/content/xdocs/trunk/anttask.xml b/src/documentation/content/xdocs/trunk/anttask.xml index 7b07802b1..9dd508ad1 100644 --- a/src/documentation/content/xdocs/trunk/anttask.xml +++ b/src/documentation/content/xdocs/trunk/anttask.xml @@ -150,7 +150,7 @@ throwexceptions - Controls whether or not an exception is thrown if an error occurs during rendering. + Controls whether or not an exception is thrown if an error occurs during rendering. Default is true diff --git a/src/java/org/apache/fop/Version.java b/src/java/org/apache/fop/Version.java index 7e421ad29..86861a60b 100644 --- a/src/java/org/apache/fop/Version.java +++ b/src/java/org/apache/fop/Version.java @@ -25,7 +25,7 @@ package org.apache.fop; * as this package equals the one specified in the manifest. */ public final class Version { - + private Version() { } /** @@ -40,11 +40,11 @@ public final class Version { } if (version == null) { //Fallback if FOP is used in a development environment - String headURL + String headURL = "$HeadURL$"; version = headURL; final String pathPrefix = "/xmlgraphics/fop/"; - int pos = version.indexOf(pathPrefix); + int pos = version.indexOf(pathPrefix); if (pos >= 0) { version = version.substring(pos + pathPrefix.length() - 1, version.length() - 2); pos = version.indexOf("/src/"); @@ -57,5 +57,5 @@ public final class Version { } return version; } - + } diff --git a/src/java/org/apache/fop/apps/FOPException.java b/src/java/org/apache/fop/apps/FOPException.java index d8ac2e2f7..ef84cc5fa 100644 --- a/src/java/org/apache/fop/apps/FOPException.java +++ b/src/java/org/apache/fop/apps/FOPException.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 class FOPException extends SAXException { private String systemId; private int line; private int column; - + private String localizedMessage; /** @@ -80,7 +80,7 @@ public class FOPException extends SAXException { /** * Constructs a new exception with the specified detail message and cause. * @param message the detail message - * @param cause the cause + * @param cause the cause */ public FOPException(String message, Exception cause) { super(message, cause); @@ -212,7 +212,7 @@ public class FOPException extends SAXException { } } } - + /** * Sets the localized message for this exception. * @param msg the localized message @@ -230,6 +230,6 @@ public class FOPException extends SAXException { } } - - + + } diff --git a/src/java/org/apache/fop/apps/FOURIResolver.java b/src/java/org/apache/fop/apps/FOURIResolver.java index 878a2745a..9a49b28f1 100644 --- a/src/java/org/apache/fop/apps/FOURIResolver.java +++ b/src/java/org/apache/fop/apps/FOURIResolver.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,7 +42,7 @@ import org.apache.fop.util.DataURIResolver; /** * Provides FOP specific URI resolution. This is the default URIResolver * {@link FOUserAgent} will use unless overidden. - * + * * @see javax.xml.transform.URIResolver */ public class FOURIResolver implements javax.xml.transform.URIResolver { @@ -96,7 +96,7 @@ public class FOURIResolver implements javax.xml.transform.URIResolver { /** * Additional constructor - * + * * @param throwExceptions * true if exceptions are to be thrown if the URIs cannot be * resolved. @@ -107,7 +107,7 @@ public class FOURIResolver implements javax.xml.transform.URIResolver { /** * Handles resolve exceptions appropriately. - * + * * @param errorStr * error string * @param strict @@ -133,7 +133,7 @@ public class FOURIResolver implements javax.xml.transform.URIResolver { * If the method is successful it will return a Source of type * {@link javax.xml.transform.stream.StreamSource} with its SystemID set to * the resolved URL used to open the underlying InputStream. - * + * * @param href * An href attribute, which may be relative or absolute. * @param base @@ -212,13 +212,13 @@ public class FOURIResolver implements javax.xml.transform.URIResolver { /* * This piece of code is based on the following statement in * RFC2396 section 5.2: - * + * * 3) If the scheme component is defined, indicating that * the reference starts with a scheme name, then the * reference is interpreted as an absolute URI and we are * done. Otherwise, the reference URI's scheme is inherited * from the base URI's scheme component. - * + * * Due to a loophole in prior specifications [RFC1630], some * parsers allow the scheme name to be present in a relative * URI if it is the same as the base URI scheme. @@ -228,7 +228,7 @@ public class FOURIResolver implements javax.xml.transform.URIResolver { * removing the scheme if it matches that of the base URI * and the scheme is known to always use the * syntax. - * + * * The URL class does not implement this work around, so we * do. */ @@ -281,7 +281,7 @@ public class FOURIResolver implements javax.xml.transform.URIResolver { * before the connect() method is called. Subclass FOURIResolver and * override this method to do things like adding the user name and password * for HTTP basic authentication. - * + * * @param connection * the URLConnection instance * @param href @@ -295,7 +295,7 @@ public class FOURIResolver implements javax.xml.transform.URIResolver { * This is a convenience method for users who want to override * updateURLConnection for HTTP basic authentication. Simply call it using * the right username and password. - * + * * @param connection * the URLConnection to set up for HTTP basic authentication * @param username @@ -327,7 +327,7 @@ public class FOURIResolver implements javax.xml.transform.URIResolver { * Sets the custom URI Resolver. It is used for resolving factory-level URIs like * hyphenation patterns and as backup for URI resolution performed during a * rendering run. - * + * * @param resolver * the new URI resolver */ @@ -337,7 +337,7 @@ public class FOURIResolver implements javax.xml.transform.URIResolver { /** * Returns the custom URI Resolver. - * + * * @return the URI Resolver or null, if none is set */ public URIResolver getCustomURIResolver() { diff --git a/src/java/org/apache/fop/apps/FOUserAgent.java b/src/java/org/apache/fop/apps/FOUserAgent.java index c7a904f29..f051dc281 100644 --- a/src/java/org/apache/fop/apps/FOUserAgent.java +++ b/src/java/org/apache/fop/apps/FOUserAgent.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. @@ -468,7 +468,7 @@ public class FOUserAgent { /** * Gets the default page-height to use as fallback, * in case page-height="auto" - * + * * @return the page-height, as a String * @see FopFactory#getPageHeight() */ @@ -479,7 +479,7 @@ public class FOUserAgent { /** * Gets the default page-width to use as fallback, * in case page-width="auto" - * + * * @return the page-width, as a String * @see FopFactory#getPageWidth() */ @@ -522,7 +522,7 @@ public class FOUserAgent { /** * Controls the use of SAXLocators to provide location information in error * messages. - * + * * @param enableLocator false if SAX Locators should be disabled */ public void setLocatorEnabled(boolean enableLocator) { diff --git a/src/java/org/apache/fop/apps/Fop.java b/src/java/org/apache/fop/apps/Fop.java index d1a56789f..0527ea290 100644 --- a/src/java/org/apache/fop/apps/Fop.java +++ b/src/java/org/apache/fop/apps/Fop.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,13 +30,13 @@ import org.apache.fop.fo.FOTreeBuilder; * Primary class that activates the FOP process for embedded usage. *

* JAXP is the standard method of embedding FOP in Java programs. - * Please check our + * Please check our * embedding page - * for samples (these are also available within the distribution in + * for samples (these are also available within the distribution in * FOP_DIR\examples\embedding) *

* Methods within FOUserAgent are available to customize portions of the - * process. For example, a specific Renderer object can be specified, + * process. For example, a specific Renderer object can be specified, * also ElementMappings which determine elements in the FO that can be * processed) can be added. *

@@ -58,7 +58,7 @@ public class Fop { private FOTreeBuilder foTreeBuilder = null; /** - * Constructor for use with already-created FOUserAgents. It uses MIME types to select the + * Constructor for use with already-created FOUserAgents. It uses MIME types to select the * output format (ex. "application/pdf" for PDF). * @param outputFormat the MIME type of the output format to use (ex. "application/pdf"). * @param ua FOUserAgent object @@ -72,9 +72,9 @@ public class Fop { if (foUserAgent == null) { foUserAgent = FopFactory.newInstance().newFOUserAgent(); } - + this.stream = stream; - + createDefaultHandler(); } @@ -119,7 +119,7 @@ public class Fop { * page-sequence. Call this method only after the rendering process is * finished. Note that the results are only available for output formats * which make use of FOP's layout engine (PDF, PS, etc.). - * @return the results of the rendering process, or null for flow-oriented + * @return the results of the rendering process, or null for flow-oriented * output formats like RTF and MIF. */ public FormattingResults getResults() { diff --git a/src/java/org/apache/fop/apps/FopFactory.java b/src/java/org/apache/fop/apps/FopFactory.java index 2d4029da8..883afdcfa 100644 --- a/src/java/org/apache/fop/apps/FopFactory.java +++ b/src/java/org/apache/fop/apps/FopFactory.java @@ -537,7 +537,7 @@ public class FopFactory implements ImageContext { /** * Gets the default page-height to use as fallback, * in case page-height="auto" - * + * * @return the page-height, as a String */ public String getPageHeight() { @@ -547,7 +547,7 @@ public class FopFactory implements ImageContext { /** * Sets the page-height to use as fallback, in case * page-height="auto" - * + * * @param pageHeight page-height as a String */ public void setPageHeight(String pageHeight) { @@ -560,7 +560,7 @@ public class FopFactory implements ImageContext { /** * Gets the default page-width to use as fallback, * in case page-width="auto" - * + * * @return the page-width, as a String */ public String getPageWidth() { @@ -570,7 +570,7 @@ public class FopFactory implements ImageContext { /** * Sets the page-width to use as fallback, in case * page-width="auto" - * + * * @param pageWidth page-width as a String */ public void setPageWidth(String pageWidth) { @@ -729,13 +729,13 @@ public class FopFactory implements ImageContext { /** * 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. * If that fails null is returned. - * + * * @param baseUri 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 diff --git a/src/java/org/apache/fop/apps/FopFactoryConfigurator.java b/src/java/org/apache/fop/apps/FopFactoryConfigurator.java index ffcc1332b..e71173845 100644 --- a/src/java/org/apache/fop/apps/FopFactoryConfigurator.java +++ b/src/java/org/apache/fop/apps/FopFactoryConfigurator.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/apps/FormattingResults.java b/src/java/org/apache/fop/apps/FormattingResults.java index af421f4ac..0c0cddcc6 100644 --- a/src/java/org/apache/fop/apps/FormattingResults.java +++ b/src/java/org/apache/fop/apps/FormattingResults.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/apps/PageSequenceResults.java b/src/java/org/apache/fop/apps/PageSequenceResults.java index 16c74f66b..241f4a5f9 100644 --- a/src/java/org/apache/fop/apps/PageSequenceResults.java +++ b/src/java/org/apache/fop/apps/PageSequenceResults.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/area/AbstractOffDocumentItem.java b/src/java/org/apache/fop/area/AbstractOffDocumentItem.java index 94cfa9e09..bdec281d4 100644 --- a/src/java/org/apache/fop/area/AbstractOffDocumentItem.java +++ b/src/java/org/apache/fop/area/AbstractOffDocumentItem.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.area; /** @@ -51,10 +51,10 @@ public abstract class AbstractOffDocumentItem implements OffDocumentItem { */ public static final int START_OF_DOC = 2; - + /** Indicates in what phase the item should be processed. */ protected int whenToProcess = IMMEDIATELY; - + /** * Get an indicator of when this item should be processed * @return int constant (IMMEDIATELY, AFTER_PAGE, START_OF_DOC, END_OF_DOC) diff --git a/src/java/org/apache/fop/area/Area.java b/src/java/org/apache/fop/area/Area.java index ab9590685..87ba2146a 100644 --- a/src/java/org/apache/fop/area/Area.java +++ b/src/java/org/apache/fop/area/Area.java @@ -167,9 +167,9 @@ public class Area extends AreaTreeObject implements Serializable { } /** - * Get the inline progression dimension of the content rectangle + * Get the inline progression dimension of the content rectangle * for this area. - * + * * @return the inline progression dimension * @see ipd */ @@ -218,7 +218,7 @@ public class Area extends AreaTreeObject implements Serializable { * @return the total BPD allocation for this area */ public int getAllocBPD() { - return getSpaceBefore() + getBorderAndPaddingWidthBefore() + getBPD() + return getSpaceBefore() + getBorderAndPaddingWidthBefore() + getBPD() + getBorderAndPaddingWidthAfter() + getSpaceAfter(); } @@ -233,7 +233,7 @@ public class Area extends AreaTreeObject implements Serializable { if (bps != null) { margin = bps.width; } - + Integer padWidth = (Integer) getTrait(Trait.PADDING_BEFORE); if (padWidth != null) { margin += padWidth.intValue(); @@ -241,7 +241,7 @@ public class Area extends AreaTreeObject implements Serializable { return margin; } - + /** * Return the sum of region border- and padding-after * @@ -249,12 +249,12 @@ public class Area extends AreaTreeObject implements Serializable { */ public int getBorderAndPaddingWidthAfter() { int margin = 0; - + BorderProps bps = (BorderProps) getTrait(Trait.BORDER_AFTER); if (bps != null) { margin = bps.width; } - + Integer padWidth = (Integer) getTrait(Trait.PADDING_AFTER); if (padWidth != null) { margin += padWidth.intValue(); @@ -274,7 +274,7 @@ public class Area extends AreaTreeObject implements Serializable { if (bps != null) { margin = bps.width; } - + Integer padWidth = (Integer) getTrait(Trait.PADDING_START); if (padWidth != null) { margin += padWidth.intValue(); @@ -294,7 +294,7 @@ public class Area extends AreaTreeObject implements Serializable { if (bps != null) { margin = bps.width; } - + Integer padWidth = (Integer) getTrait(Trait.PADDING_END); if (padWidth != null) { margin += padWidth.intValue(); @@ -316,7 +316,7 @@ public class Area extends AreaTreeObject implements Serializable { } return margin; } - + /** * Returns the space after * @@ -330,7 +330,7 @@ public class Area extends AreaTreeObject implements Serializable { } return margin; } - + /** * Returns the space start * @@ -344,7 +344,7 @@ public class Area extends AreaTreeObject implements Serializable { } return margin; } - + /** * Returns the space end * @@ -358,7 +358,7 @@ public class Area extends AreaTreeObject implements Serializable { } return margin; } - + /** * Add a child to this area. * The default is to do nothing. Subclasses must override @@ -395,7 +395,7 @@ public class Area extends AreaTreeObject implements Serializable { public boolean hasTraits() { return (this.props != null); } - + /** * Get a trait from this area. * @@ -405,7 +405,7 @@ public class Area extends AreaTreeObject implements Serializable { public Object getTrait(Object oTraitCode) { return (props != null ? props.get(oTraitCode) : null); } - + /** * Checks whether a certain trait is set on this area. * @param oTraitCode the trait key @@ -414,7 +414,7 @@ public class Area extends AreaTreeObject implements Serializable { public boolean hasTrait(Object oTraitCode) { return (getTrait(oTraitCode) != null); } - + /** * Get a boolean trait from this area. * @param oTraitCode the trait key @@ -440,10 +440,10 @@ public class Area extends AreaTreeObject implements Serializable { + " could not be converted to an integer"); } } - + /** * {@inheritDoc} - * @return ipd and bpd of area + * @return ipd and bpd of area * */ public String toString() { StringBuffer sb = new StringBuffer(super.toString()); diff --git a/src/java/org/apache/fop/area/AreaEventProducer.java b/src/java/org/apache/fop/area/AreaEventProducer.java index 7747d2d79..325367199 100644 --- a/src/java/org/apache/fop/area/AreaEventProducer.java +++ b/src/java/org/apache/fop/area/AreaEventProducer.java @@ -31,7 +31,7 @@ public interface AreaEventProducer 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 AreaEventProducer extends EventProducer { * @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 @@ -60,7 +60,7 @@ public interface AreaEventProducer extends EventProducer { * @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 @@ -69,7 +69,7 @@ public interface AreaEventProducer extends EventProducer { * @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 @@ -78,7 +78,7 @@ public interface AreaEventProducer extends EventProducer { * @event.severity ERROR */ void pageSaveError(Object source, String page, Exception e); - + /** * A page could not be rendered. * @param source the event source @@ -87,5 +87,5 @@ public interface AreaEventProducer extends EventProducer { * @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 3c89fd3d9..128fc8ce9 100644 --- a/src/java/org/apache/fop/area/AreaTreeHandler.java +++ b/src/java/org/apache/fop/area/AreaTreeHandler.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 @@ import org.apache.fop.layoutmgr.TopLevelLayoutManager; /** * Area tree handler for formatting objects. - * + * * Concepts: The area tree is to be as small as possible. With minimal classes * and data to fully represent an area tree for formatting objects. The area * tree needs to be simple to render and follow the spec closely. This area tree @@ -61,7 +61,7 @@ import org.apache.fop.layoutmgr.TopLevelLayoutManager; * type of renderer. */ public class AreaTreeHandler extends FOEventHandler { - + private static Log log = LogFactory.getLog(AreaTreeHandler.class); // Recorder of debug statistics @@ -78,7 +78,7 @@ public class AreaTreeHandler extends FOEventHandler { // The fo:root node of the document private Root rootFObj; - + // The formatting results to be handed back to the caller. private FormattingResults results = new FormattingResults(); @@ -88,7 +88,7 @@ public class AreaTreeHandler extends FOEventHandler { /** * Constructor. - * + * * @param userAgent FOUserAgent object for process * @param outputFormat the MIME type of the output format to use (ex. * "application/pdf"). @@ -107,7 +107,7 @@ public class AreaTreeHandler extends FOEventHandler { } this.idTracker = new IDTracker(); - + if (log.isDebugEnabled()) { statistics = new Statistics(); } @@ -115,7 +115,7 @@ public class AreaTreeHandler extends FOEventHandler { /** * Sets up the AreaTreeModel instance for use by the AreaTreeHandler. - * + * * @param userAgent FOUserAgent object for process * @param outputFormat the MIME type of the output format to use (ex. * "application/pdf"). @@ -129,7 +129,7 @@ public class AreaTreeHandler extends FOEventHandler { /** * Get the area tree model for this area tree. - * + * * @return AreaTreeModel the model being used for this area tree */ public AreaTreeModel getAreaTreeModel() { @@ -138,7 +138,7 @@ public class AreaTreeHandler extends FOEventHandler { /** * Get the LayoutManager maker for this area tree. - * + * * @return LayoutManagerMaker the LayoutManager maker being used for this * area tree */ @@ -148,7 +148,7 @@ public class AreaTreeHandler extends FOEventHandler { /** * Get the IDTracker for this area tree. - * + * * @return IDTracker used to track reference ids for items in this area tree */ public IDTracker getIDTracker() { @@ -157,7 +157,7 @@ public class AreaTreeHandler extends FOEventHandler { /** * Get information about the rendered output, like number of pages created. - * + * * @return the results structure */ public FormattingResults getResults() { @@ -167,7 +167,7 @@ public class AreaTreeHandler extends FOEventHandler { /** * Prepare AreaTreeHandler for document processing This is called from * FOTreeBuilder.startDocument() - * + * * @throws SAXException * if there is an error */ @@ -193,7 +193,7 @@ public class AreaTreeHandler extends FOEventHandler { public void startPageSequence(PageSequence pageSequence) { startAbstractPageSequence(pageSequence); } - + private void startAbstractPageSequence(AbstractPageSequence pageSequence) { rootFObj = pageSequence.getRoot(); finishPrevPageSequence(pageSequence.getInitialPageNumber()); @@ -217,7 +217,7 @@ public class AreaTreeHandler extends FOEventHandler { /** * End the PageSequence. The PageSequence formats Pages and adds them to the * AreaTree. The area tree then handles what happens with the pages. - * + * * @param pageSequence the page sequence ending */ public void endPageSequence(PageSequence pageSequence) { @@ -248,20 +248,20 @@ public class AreaTreeHandler extends FOEventHandler { if (statistics != null) { statistics.end(); } - + ExternalDocumentLayoutManager edLM; edLM = getLayoutManagerMaker().makeExternalDocumentLayoutManager(this, document); edLM.activateLayout(); // preserve the current PageSequenceLayoutManger for the // force-page-count check at the beginning of the next PageSequence prevPageSeqLM = edLM; - + } /** * Called by the PageSequenceLayoutManager when it is finished with a * page-sequence. - * + * * @param pageSequence the page-sequence just finished * @param pageCount The number of pages generated for the page-sequence */ @@ -275,7 +275,7 @@ public class AreaTreeHandler extends FOEventHandler { /** * End the document. - * + * * @throws SAXException if there is some error */ public void endDocument() throws SAXException { @@ -313,7 +313,7 @@ public class AreaTreeHandler extends FOEventHandler { * Add a OffDocumentItem to the area tree model. This checks if the * OffDocumentItem is resolvable and attempts to resolve or add the * resolvable ids for later resolution. - * + * * @param odi the OffDocumentItem to add. */ private void addOffDocumentItem(OffDocumentItem odi) { @@ -342,7 +342,7 @@ public class AreaTreeHandler extends FOEventHandler { /** * Generates and returns a unique key for a page viewport. - * + * * @return the generated key. */ public String generatePageViewportKey() { @@ -354,7 +354,7 @@ public class AreaTreeHandler extends FOEventHandler { * Tie a PageViewport with an ID found on a child area of the PV. Note that * an area with a given ID may be on more than one PV, hence an ID may have * more than one PV associated with it. - * + * * @param id the property ID of the area * @param pv a page viewport that contains the area with this ID * @deprecated use getIDTracker().associateIDWithPageViewport(id, pv) instead @@ -367,7 +367,7 @@ public class AreaTreeHandler extends FOEventHandler { * This method tie an ID to the areaTreeHandler until this one is ready to * be processed. This is used in page-number-citation-last processing so we * know when an id can be resolved. - * + * * @param id the id of the object being processed * @deprecated use getIDTracker().signalPendingID(id) instead */ @@ -379,7 +379,7 @@ public class AreaTreeHandler extends FOEventHandler { * Signals that all areas for the formatting object with the given ID have * been generated. This is used to determine when page-number-citation-last * ref-ids can be resolved. - * + * * @param id the id of the formatting object which was just finished * @deprecated use getIDTracker().signalIDProcessed(id) instead */ @@ -389,7 +389,7 @@ public class AreaTreeHandler extends FOEventHandler { /** * Check if an ID has already been resolved - * + * * @param id the id to check * @return true if the ID has been resolved * @deprecated use getIDTracker().alreadyResolvedID(id) instead @@ -400,7 +400,7 @@ public class AreaTreeHandler extends FOEventHandler { /** * Tries to resolve all unresolved ID references on the given page. - * + * * @param pv page viewport whose ID refs to resolve * @deprecated use getIDTracker().tryIDResolution(pv) instead */ @@ -410,7 +410,7 @@ public class AreaTreeHandler extends FOEventHandler { /** * Get the list of page viewports that have an area with a given id. - * + * * @param id the id to lookup * @return the list of PageViewports * @deprecated use getIDTracker().getPageViewportsContainingID(id) instead @@ -421,7 +421,7 @@ public class AreaTreeHandler extends FOEventHandler { /** * Add an Resolvable object with an unresolved idref - * + * * @param idref the idref whose target id has not yet been located * @param res the Resolvable object needing the idref to be resolved * @deprecated use getIDTracker().addUnresolvedIDRef(idref, res) instead @@ -429,7 +429,7 @@ public class AreaTreeHandler extends FOEventHandler { public void addUnresolvedIDRef(String idref, Resolvable res) { idTracker.addUnresolvedIDRef(idref, res); } - + private class Statistics { // for statistics gathering private Runtime runtime; diff --git a/src/java/org/apache/fop/area/AreaTreeModel.java b/src/java/org/apache/fop/area/AreaTreeModel.java index 544ff612a..e5f6db17b 100644 --- a/src/java/org/apache/fop/area/AreaTreeModel.java +++ b/src/java/org/apache/fop/area/AreaTreeModel.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.area; // Java @@ -80,7 +80,7 @@ public class AreaTreeModel { } /** - * Handle an OffDocumentItem + * Handle an OffDocumentItem * @param ext the extension to handle */ public void handleOffDocumentItem(OffDocumentItem ext) { }; @@ -98,7 +98,7 @@ public class AreaTreeModel { public PageSequence getCurrentPageSequence() { return this.currentPageSequence; } - + /** * Get the page sequence count. * @return the number of page sequences in the document. diff --git a/src/java/org/apache/fop/area/AreaTreeObject.java b/src/java/org/apache/fop/area/AreaTreeObject.java index 7fa30aee9..5929e7c4e 100644 --- a/src/java/org/apache/fop/area/AreaTreeObject.java +++ b/src/java/org/apache/fop/area/AreaTreeObject.java @@ -33,7 +33,7 @@ public abstract class AreaTreeObject { /** Foreign attributes */ protected Map foreignAttributes = null; - + /** Extension attachments */ protected List/**/ extensionAttachments = null; @@ -48,7 +48,7 @@ public abstract class AreaTreeObject { } this.foreignAttributes.put(name, value); } - + /** * Set foreign attributes from a Map. * @param atts a Map with attributes (keys: QName, values: String) @@ -61,11 +61,11 @@ public abstract class AreaTreeObject { while (iter.hasNext()) { 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) + //The casting is only to ensure type safety (too bad we can't use generics, yet) setForeignAttribute((QName)entry.getKey(), value); } } - + /** * Returns the value of a foreign attribute on the area. * @param name the qualified name of the attribute @@ -78,7 +78,7 @@ public abstract class AreaTreeObject { return null; } } - + /** @return the foreign attributes associated with this area */ public Map getForeignAttributes() { if (this.foreignAttributes != null) { diff --git a/src/java/org/apache/fop/area/AreaTreeParser.java b/src/java/org/apache/fop/area/AreaTreeParser.java index e4de505b0..ab41b4214 100644 --- a/src/java/org/apache/fop/area/AreaTreeParser.java +++ b/src/java/org/apache/fop/area/AreaTreeParser.java @@ -85,7 +85,7 @@ public class AreaTreeParser { /** Logger instance */ protected static Log log = LogFactory.getLog(AreaTreeParser.class); - private static SAXTransformerFactory tFactory + private static SAXTransformerFactory tFactory = (SAXTransformerFactory)SAXTransformerFactory.newInstance(); /** @@ -96,11 +96,11 @@ public class AreaTreeParser { * @param userAgent the user agent * @throws TransformerException if an error occurs while parsing the area tree XML */ - public void parse(Source src, AreaTreeModel treeModel, FOUserAgent userAgent) + public void parse(Source src, AreaTreeModel treeModel, FOUserAgent userAgent) throws TransformerException { Transformer transformer = tFactory.newTransformer(); transformer.setErrorListener(new DefaultErrorListener(log)); - + SAXResult res = new SAXResult(getContentHandler(treeModel, userAgent)); transformer.transform(src, res); @@ -131,7 +131,7 @@ public class AreaTreeParser { private CharBuffer content = CharBuffer.allocate(64); private boolean ignoreCharacters = true; - + private PageViewport currentPageViewport; private Map pageViewportsByKey = new java.util.HashMap(); // set of "ID firsts" that have already been assigned to a PV: @@ -328,7 +328,7 @@ public class AreaTreeParser { public void endElement() { //nop } - + public boolean ignoreCharacters() { return true; } @@ -409,7 +409,7 @@ public class AreaTreeParser { currentPageViewport = null; } } - + private class RegionViewportMaker extends AbstractMaker { public void startElement(Attributes attributes) { @@ -427,10 +427,10 @@ public class AreaTreeParser { setTraits(attributes, rv, SUBSET_COLOR); areaStack.push(rv); } - + public void endElement() { assertObjectOfClass(areaStack.pop(), RegionViewport.class); - } + } } private class RegionBeforeMaker extends AbstractMaker { @@ -438,7 +438,7 @@ public class AreaTreeParser { public void startElement(Attributes attributes) { pushNewRegionReference(attributes, Constants.FO_REGION_BEFORE); } - + public void endElement() { assertObjectOfClass(areaStack.pop(), RegionReference.class); } @@ -465,7 +465,7 @@ public class AreaTreeParser { assertObjectOfClass(areaStack.pop(), RegionReference.class); } } - + private class RegionEndMaker extends AbstractMaker { public void startElement(Attributes attributes) { @@ -488,7 +488,7 @@ public class AreaTreeParser { int columnCount = getAttributeAsInteger(attributes, "columnCount", 1); int columnGap = getAttributeAsInteger(attributes, "columnGap", 0); RegionViewport rv = getCurrentRegionViewport(); - body = new BodyRegion(Constants.FO_REGION_BODY, + body = new BodyRegion(Constants.FO_REGION_BODY, regionName, rv, columnCount, columnGap); transferForeignObjects(attributes, body); body.setCTM(getAttributeAsCTM(attributes, "ctm")); @@ -498,10 +498,10 @@ public class AreaTreeParser { Constants.FO_REGION_BODY, rv); areaStack.push(body); } - + public void endElement() { assertObjectOfClass(areaStack.pop(), BodyRegion.class); - } + } } private class FlowMaker extends AbstractMaker { @@ -518,12 +518,12 @@ public class AreaTreeParser { setAreaAttributes(attributes, flow); areaStack.push(flow); } - + public void endElement() { assertObjectOfClass(areaStack.pop(), NormalFlow.class); - } + } } - + private class MainReferenceMaker extends AbstractMaker { public void startElement(Attributes attributes) { @@ -540,7 +540,7 @@ public class AreaTreeParser { int ipd = getAttributeAsInteger(attributes, "ipd", 0); int columnCount = getAttributeAsInteger(attributes, "columnCount", 1); BodyRegion body = getCurrentBodyRegion(); - Span span = new Span(columnCount, + Span span = new Span(columnCount, body.getColumnGap(), ipd); transferForeignObjects(attributes, span); setAreaAttributes(attributes, span); @@ -557,20 +557,20 @@ public class AreaTreeParser { fn.setTop(getAttributeAsInteger(attributes, "top-offset", 0)); areaStack.push(fn); } - + public void endElement() { assertObjectOfClass(areaStack.pop(), Footnote.class); - } + } } private class BeforeFloatMaker extends AbstractMaker { public void startElement(Attributes attributes) { - BeforeFloat bf = getCurrentBodyRegion().getBeforeFloat(); + BeforeFloat bf = getCurrentBodyRegion().getBeforeFloat(); transferForeignObjects(attributes, bf); areaStack.push(bf); } - + public void endElement() { assertObjectOfClass(areaStack.pop(), BeforeFloat.class); } @@ -622,7 +622,7 @@ public class AreaTreeParser { parent.addChildArea(block); areaStack.push(block); } - + public void endElement() { assertObjectOfClass(areaStack.pop(), Block.class); } @@ -702,7 +702,7 @@ public class AreaTreeParser { parent.addChildArea(ibp); areaStack.push(ibp); } - + public void endElement() { assertObjectOfClass(areaStack.pop(), InlineBlockParent.class); } @@ -724,13 +724,13 @@ public class AreaTreeParser { text.setOffset(getAttributeAsInteger(attributes, "offset", 0)); text.setTextLetterSpaceAdjust(getAttributeAsInteger(attributes, "tlsadjust", 0)); - text.setTextWordSpaceAdjust(getAttributeAsInteger(attributes, + text.setTextWordSpaceAdjust(getAttributeAsInteger(attributes, "twsadjust", 0)); Area parent = (Area)areaStack.peek(); parent.addChildArea(text); areaStack.push(text); } - + public void endElement() { assertObjectOfClass(areaStack.pop(), TextArea.class); } @@ -740,7 +740,7 @@ public class AreaTreeParser { public void endElement() { int offset = getAttributeAsInteger(lastAttributes, "offset", 0); - int[] letterAdjust + int[] letterAdjust = ConversionUtils.toIntArray( lastAttributes.getValue("letter-adjust"), "\\s"); content.flip(); @@ -749,14 +749,14 @@ public class AreaTreeParser { word.setParentArea(text); text.addChildArea(word); } - + public boolean ignoreCharacters() { return false; } } private class SpaceMaker extends AbstractMaker { - + public void endElement() { int offset = getAttributeAsInteger(lastAttributes, "offset", 0); //TODO the isAdjustable parameter is currently not used/implemented @@ -778,7 +778,7 @@ public class AreaTreeParser { parent.addChildArea(space); } } - + public boolean ignoreCharacters() { return false; } @@ -822,12 +822,12 @@ public class AreaTreeParser { parent.addChildArea(viewport); areaStack.push(viewport); } - + public void endElement() { assertObjectOfClass(areaStack.pop(), Viewport.class); } } - + private class ImageMaker extends AbstractMaker { public void startElement(Attributes attributes) { @@ -839,12 +839,12 @@ public class AreaTreeParser { getCurrentViewport().setContent(image); } } - + private class ForeignObjectMaker extends AbstractMaker { public void startElement(Attributes attributes) throws SAXException { String ns = attributes.getValue("ns"); - domImplementation + domImplementation = elementMappingRegistry.getDOMImplementationForNamespace(ns); if (domImplementation == null) { throw new SAXException("No DOMImplementation could be" @@ -941,11 +941,11 @@ public class AreaTreeParser { private void assertObjectOfClass(Object obj, Class clazz) { if (!clazz.isInstance(obj)) { - throw new IllegalStateException("Object is not an instance of " + throw new IllegalStateException("Object is not an instance of " + clazz.getName() + " but of " + obj.getClass().getName()); } } - + /** * Handles objects created by "sub-parsers" that implement the ObjectSource interface. * An example of object handled here are ExtensionAttachments. @@ -969,7 +969,7 @@ public class AreaTreeParser { area.setIPD(Integer.parseInt(attributes.getValue("ipd"))); area.setBPD(Integer.parseInt(attributes.getValue("bpd"))); } - + private static final Object[] SUBSET_COMMON = new Object[] { Trait.PROD_ID}; private static final Object[] SUBSET_LINK = new Object[] { @@ -1078,7 +1078,7 @@ public class AreaTreeParser { } } - private static int getAttributeAsInteger(Attributes attributes, String name, + private static int getAttributeAsInteger(Attributes attributes, String name, int defaultValue) { String s = attributes.getValue(name); if (s == null) { @@ -1123,7 +1123,7 @@ public class AreaTreeParser { } } } - + /** {@inheritDoc} */ public void characters(char[] ch, int start, int length) throws SAXException { if (delegate != null) { @@ -1132,7 +1132,7 @@ public class AreaTreeParser { int maxLength = this.content.capacity() - this.content.position(); if (maxLength < length) { // allocate a larger buffer and transfer content - CharBuffer newContent + CharBuffer newContent = CharBuffer.allocate(this.content.position() + length); this.content.flip(); newContent.put(this.content); diff --git a/src/java/org/apache/fop/area/BeforeFloat.java b/src/java/org/apache/fop/area/BeforeFloat.java index 9fc048af1..490476368 100644 --- a/src/java/org/apache/fop/area/BeforeFloat.java +++ b/src/java/org/apache/fop/area/BeforeFloat.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.area; /** diff --git a/src/java/org/apache/fop/area/Block.java b/src/java/org/apache/fop/area/Block.java index 21fa7c49d..7a2465859 100644 --- a/src/java/org/apache/fop/area/Block.java +++ b/src/java/org/apache/fop/area/Block.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.area; @@ -59,7 +59,7 @@ public class Block extends BlockParent { private int positioning = STACK; protected transient boolean allowBPDUpdate = true; - + // a block with may contain the dominant styling info in // terms of most lines or blocks with info @@ -120,7 +120,7 @@ public class Block extends BlockParent { public boolean isStacked() { return (getPositioning() == Block.STACK || getPositioning() == Block.RELATIVE); } - + /** * @return the start-indent trait */ diff --git a/src/java/org/apache/fop/area/BlockParent.java b/src/java/org/apache/fop/area/BlockParent.java index 8e4f71250..1be0b785d 100644 --- a/src/java/org/apache/fop/area/BlockParent.java +++ b/src/java/org/apache/fop/area/BlockParent.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.area; import java.util.ArrayList; @@ -60,7 +60,7 @@ public class BlockParent extends Area { } children.add(childArea); } - + /** * Add the block area to this block parent. * diff --git a/src/java/org/apache/fop/area/BlockViewport.java b/src/java/org/apache/fop/area/BlockViewport.java index 167e7c5b3..60bf1fb22 100644 --- a/src/java/org/apache/fop/area/BlockViewport.java +++ b/src/java/org/apache/fop/area/BlockViewport.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.area; /** diff --git a/src/java/org/apache/fop/area/BodyRegion.java b/src/java/org/apache/fop/area/BodyRegion.java index dc63ae778..7b183a188 100644 --- a/src/java/org/apache/fop/area/BodyRegion.java +++ b/src/java/org/apache/fop/area/BodyRegion.java @@ -55,7 +55,7 @@ public class BodyRegion extends RegionReference { * @param columnCount the number of columns * @param columnGap the gap between columns */ - public BodyRegion(int regionClass, String regionName, RegionViewport parent, + public BodyRegion(int regionClass, String regionName, RegionViewport parent, int columnCount, int columnGap) { super(regionClass, regionName, parent); this.columnCount = columnCount; @@ -76,7 +76,7 @@ public class BodyRegion extends RegionReference { public int getColumnGap() { return this.columnGap; } - + /** * Get the main reference area. * @@ -135,14 +135,14 @@ public class BodyRegion extends RegionReference { } return getBPD() - usedBPD; } - + /** * Clone this object. * * @return a shallow copy of this object */ public Object clone() { - BodyRegion br = new BodyRegion(getRegionClass(), getRegionName(), regionViewport, + BodyRegion br = new BodyRegion(getRegionClass(), getRegionName(), regionViewport, getColumnCount(), getColumnGap()); br.setCTM(getCTM()); br.setIPD(getIPD()); diff --git a/src/java/org/apache/fop/area/BookmarkData.java b/src/java/org/apache/fop/area/BookmarkData.java index 07290824e..d009cb425 100644 --- a/src/java/org/apache/fop/area/BookmarkData.java +++ b/src/java/org/apache/fop/area/BookmarkData.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.area; import java.util.Collection; @@ -33,7 +33,7 @@ import org.apache.fop.fo.pagination.bookmarks.BookmarkTree; * child bookmark-items under it. */ public class BookmarkData extends AbstractOffDocumentItem implements Resolvable { - + private List subData = new java.util.ArrayList(); // bookmark-title for this fo:bookmark @@ -92,7 +92,7 @@ public class BookmarkData extends AbstractOffDocumentItem implements Resolvable } refs.add(bd); } - + /** * Create a new bookmark data root object. * This constructor is called by the AreaTreeParser when the diff --git a/src/java/org/apache/fop/area/CTM.java b/src/java/org/apache/fop/area/CTM.java index c9fb52311..099ab38fa 100644 --- a/src/java/org/apache/fop/area/CTM.java +++ b/src/java/org/apache/fop/area/CTM.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. @@ -133,7 +133,7 @@ public class CTM implements Serializable { switch (wm) { case Constants.EN_LR_TB: return new CTM(CTM_LRTB); - case Constants.EN_RL_TB: + case Constants.EN_RL_TB: wmctm = new CTM(CTM_RLTB); wmctm.e = ipd; return wmctm; @@ -269,7 +269,7 @@ public class CTM implements Serializable { public AffineTransform toAffineTransform() { return new AffineTransform(toArray()); } - + /** * Construct a coordinate transformation matrix (CTM). * @param absRefOrient absolute reference orientation diff --git a/src/java/org/apache/fop/area/CachedRenderPagesModel.java b/src/java/org/apache/fop/area/CachedRenderPagesModel.java index b34a7e8d1..f522b978b 100644 --- a/src/java/org/apache/fop/area/CachedRenderPagesModel.java +++ b/src/java/org/apache/fop/area/CachedRenderPagesModel.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.area; import java.io.BufferedInputStream; @@ -52,7 +52,7 @@ public class CachedRenderPagesModel extends RenderPagesModel { /** Base directory to save temporary file in, typically points to the user's temp dir. */ protected File baseDir; - + /** * Main Constructor * @param userAgent FOUserAgent object for process @@ -61,14 +61,14 @@ public class CachedRenderPagesModel extends RenderPagesModel { * @param stream OutputStream * @throws FOPException if the renderer cannot be properly initialized */ - public CachedRenderPagesModel (FOUserAgent userAgent, String outputFormat, + public CachedRenderPagesModel (FOUserAgent userAgent, String outputFormat, FontInfo fontInfo, OutputStream stream) throws FOPException { super(userAgent, outputFormat, fontInfo, stream); this.baseDir = new File(System.getProperty("java.io.tmpdir")); } /** - * {@inheritDoc} + * {@inheritDoc} */ protected boolean checkPreparedPages(PageViewport newpage, boolean renderUnresolved) { for (Iterator iter = prepared.iterator(); iter.hasNext();) { diff --git a/src/java/org/apache/fop/area/DestinationData.java b/src/java/org/apache/fop/area/DestinationData.java index 2cff02ef4..cb2d6eccb 100644 --- a/src/java/org/apache/fop/area/DestinationData.java +++ b/src/java/org/apache/fop/area/DestinationData.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. @@ -56,7 +56,7 @@ public class DestinationData extends AbstractOffDocumentItem implements Resolvab this.idRef = idRef; this.idRefs = new String[] {idRef}; } - + /** * Get the idref for this destination * diff --git a/src/java/org/apache/fop/area/Footnote.java b/src/java/org/apache/fop/area/Footnote.java index 0366740b0..a25f5467e 100644 --- a/src/java/org/apache/fop/area/Footnote.java +++ b/src/java/org/apache/fop/area/Footnote.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.area; // may combine with before float into a conditional area diff --git a/src/java/org/apache/fop/area/IDTracker.java b/src/java/org/apache/fop/area/IDTracker.java index a701af70b..b55ed7983 100644 --- a/src/java/org/apache/fop/area/IDTracker.java +++ b/src/java/org/apache/fop/area/IDTracker.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. @@ -33,7 +33,7 @@ import org.apache.commons.logging.LogFactory; * on a PageViewport level. */ public class IDTracker { - + private static final Log log = LogFactory.getLog(IDTracker.class); // HashMap of ID's whose area is located on one or more consecutive @@ -48,12 +48,12 @@ public class IDTracker { private Set unfinishedIDs = new java.util.HashSet(); private Set alreadyResolvedIDs = new java.util.HashSet(); - + /** * Tie a PageViewport with an ID found on a child area of the PV. Note that * an area with a given ID may be on more than one PV, hence an ID may have * more than one PV associated with it. - * + * * @param id the property ID of the area * @param pv a page viewport that contains the area with this ID */ @@ -76,7 +76,7 @@ public class IDTracker { tryIDResolution(id, pv, pvList); } } else { - /* TODO: The check is a quick-fix to avoid a waste + /* TODO: The check is a quick-fix to avoid a waste * when adding inline-ids to the page */ if (!pvList.contains(pv)) { pvList.add(pv); @@ -88,7 +88,7 @@ public class IDTracker { * This method tie an ID to the areaTreeHandler until this one is ready to * be processed. This is used in page-number-citation-last processing so we * know when an id can be resolved. - * + * * @param id the id of the object being processed */ public void signalPendingID(String id) { @@ -102,7 +102,7 @@ public class IDTracker { * Signals that all areas for the formatting object with the given ID have * been generated. This is used to determine when page-number-citation-last * ref-ids can be resolved. - * + * * @param id the id of the formatting object which was just finished */ public void signalIDProcessed(String id) { @@ -126,20 +126,20 @@ public class IDTracker { unresolvedIDRefs.remove(id); } } - + /** * Check if an ID has already been resolved - * + * * @param id the id to check * @return true if the ID has been resolved */ public boolean alreadyResolvedID(String id) { return (alreadyResolvedIDs.contains(id)); } - + /** * Tries to resolve all unresolved ID references on the given page. - * + * * @param id ID to resolve * @param pv page viewport whose ID refs to resolve * @param pvList of PageViewports @@ -162,7 +162,7 @@ public class IDTracker { /** * Tries to resolve all unresolved ID references on the given page. - * + * * @param pv page viewport whose ID refs to resolve */ public void tryIDResolution(PageViewport pv) { @@ -176,20 +176,20 @@ public class IDTracker { } } } - + /** * Get the list of page viewports that have an area with a given id. - * + * * @param id the id to lookup * @return the list of PageViewports */ public List getPageViewportsContainingID(String id) { return (List) idLocations.get(id); } - + /** * Add an Resolvable object with an unresolved idref - * + * * @param idref the idref whose target id has not yet been located * @param res the Resolvable object needing the idref to be resolved */ @@ -201,5 +201,5 @@ public class IDTracker { } // add Resolvable object to this HashSet todo.add(res); - } + } } diff --git a/src/java/org/apache/fop/area/LineArea.java b/src/java/org/apache/fop/area/LineArea.java index 449a5d915..bbf947499 100644 --- a/src/java/org/apache/fop/area/LineArea.java +++ b/src/java/org/apache/fop/area/LineArea.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.area; import org.apache.fop.area.inline.InlineArea; @@ -44,7 +44,7 @@ public class LineArea extends Area { private int availableShrink; private double variationFactor; private boolean bAddedToAreaTree; - + private LineAdjustingInfo(int alignment, int diff, int stretch, int shrink) { lineAlignment = alignment; @@ -55,7 +55,7 @@ public class LineArea extends Area { bAddedToAreaTree = false; } } - + private LineAdjustingInfo adjustingInfo = null; // this class can contain the dominant char styling info @@ -67,7 +67,7 @@ public class LineArea extends Area { * default constructor: * nothing to do */ - public LineArea() { + public LineArea() { } /** @@ -142,7 +142,7 @@ public class LineArea extends Area { setIPD(ipd); setBPD(bpd); } - + /** * receive notification about the ipd variation of a descendant area * and perform the needed adjustment, according to the alignment; @@ -151,12 +151,12 @@ public class LineArea extends Area { *

  • left-aligned text needs no adjustement;
  • *
  • right-aligned text and centered text are handled locally, * adjusting the indent of this LineArea;
  • - *
  • justified text requires a more complex adjustment, as the + *
  • justified text requires a more complex adjustment, as the * variation factor computed on the basis of the total * stretch and shrink of the line must be applied in every - * descendant leaf areas (text areas and leader areas).
  • + * descendant leaf areas (text areas and leader areas). * - * @param ipdVariation the difference between old and new ipd + * @param ipdVariation the difference between old and new ipd */ public void handleIPDVariation(int ipdVariation) { switch (adjustingInfo.lineAlignment) { @@ -186,7 +186,7 @@ public class LineArea extends Area { throw new RuntimeException(); } } - + /** * apply the variation factor to all descendant areas * and destroy the AdjustingInfo object if there are diff --git a/src/java/org/apache/fop/area/LinkResolver.java b/src/java/org/apache/fop/area/LinkResolver.java index 0fdd4ba4c..51a952ddc 100644 --- a/src/java/org/apache/fop/area/LinkResolver.java +++ b/src/java/org/apache/fop/area/LinkResolver.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 LinkResolver implements Resolvable, Serializable { /** * Resolve by adding an internal link to the first PageViewport in the list. * - * {@inheritDoc} + * {@inheritDoc} */ public void resolveIDRef(String id, List pages) { resolveIDRef(id, (PageViewport)pages.get(0)); diff --git a/src/java/org/apache/fop/area/MainReference.java b/src/java/org/apache/fop/area/MainReference.java index 55728f8fd..0922ebd01 100644 --- a/src/java/org/apache/fop/area/MainReference.java +++ b/src/java/org/apache/fop/area/MainReference.java @@ -43,7 +43,7 @@ public class MainReference extends Area { this.parent = parent; addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE); } - + /** * Add a span area to this area. * @@ -58,11 +58,11 @@ public class MainReference extends Area { RegionViewport rv = parent.getRegionViewport(); int ipdWidth = (int) parent.getIPD() - rv.getBorderAndPaddingWidthStart() - rv.getBorderAndPaddingWidthEnd(); - - Span newSpan = new Span(((spanAll) ? 1 : getColumnCount()), + + Span newSpan = new Span(((spanAll) ? 1 : getColumnCount()), getColumnGap(), ipdWidth); spanAreas.add(newSpan); - return getCurrentSpan(); + return getCurrentSpan(); } /** diff --git a/src/java/org/apache/fop/area/NormalFlow.java b/src/java/org/apache/fop/area/NormalFlow.java index c9fc8380a..5e0192389 100644 --- a/src/java/org/apache/fop/area/NormalFlow.java +++ b/src/java/org/apache/fop/area/NormalFlow.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.area; /** @@ -33,7 +33,7 @@ public class NormalFlow extends BlockParent { addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE); setIPD(ipd); } - + /** {@inheritDoc} */ public void addBlock(Block block) { super.addBlock(block); diff --git a/src/java/org/apache/fop/area/OffDocumentExtensionAttachment.java b/src/java/org/apache/fop/area/OffDocumentExtensionAttachment.java index 7fd811d45..c8d653bd0 100644 --- a/src/java/org/apache/fop/area/OffDocumentExtensionAttachment.java +++ b/src/java/org/apache/fop/area/OffDocumentExtensionAttachment.java @@ -29,7 +29,7 @@ import org.apache.fop.fo.extensions.ExtensionAttachment; public class OffDocumentExtensionAttachment implements OffDocumentItem { private ExtensionAttachment attachment; - + /** * Main constructor * @param attachment the extension attachment to wrap. @@ -37,7 +37,7 @@ public class OffDocumentExtensionAttachment implements OffDocumentItem { public OffDocumentExtensionAttachment(ExtensionAttachment attachment) { this.attachment = attachment; } - + /** @return the extension attachment. */ public ExtensionAttachment getAttachment() { return this.attachment; @@ -52,5 +52,5 @@ public class OffDocumentExtensionAttachment implements OffDocumentItem { public String getName() { return attachment.getCategory(); } - + } diff --git a/src/java/org/apache/fop/area/OffDocumentItem.java b/src/java/org/apache/fop/area/OffDocumentItem.java index e4e07f974..c2c0a3f68 100644 --- a/src/java/org/apache/fop/area/OffDocumentItem.java +++ b/src/java/org/apache/fop/area/OffDocumentItem.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.area; /** @@ -45,7 +45,7 @@ public interface OffDocumentItem { */ int END_OF_DOC = 2; - + /** * Get an indicator of when this item should be processed * @return int constant (IMMEDIATELY, AFTER_PAGE, END_OF_DOC) @@ -57,5 +57,5 @@ public interface OffDocumentItem { * @return String name of ODI */ String getName(); - + } diff --git a/src/java/org/apache/fop/area/Page.java b/src/java/org/apache/fop/area/Page.java index ddc2a95ab..167d28e6b 100644 --- a/src/java/org/apache/fop/area/Page.java +++ b/src/java/org/apache/fop/area/Page.java @@ -59,9 +59,9 @@ public class Page extends AreaTreeObject implements Serializable, Cloneable { /** Set to true to make this page behave as if it were not empty. */ private boolean fakeNonEmpty = false; - + /** - * Empty constructor, for cloning + * Empty constructor, for cloning */ public Page() { } @@ -78,7 +78,7 @@ public class Page extends AreaTreeObject implements Serializable, Cloneable { // Get absolute margin properties (top, left, bottom, right) CommonMarginBlock mProps = spm.getCommonMarginBlock(); - + /* * Create the page reference area rectangle (0,0 is at top left * of the "page media" and y increases @@ -92,20 +92,20 @@ public class Page extends AreaTreeObject implements Serializable, Cloneable { * That's why we 'cheat' here and setup a context for the height but * use the LengthBase.BLOCK_WIDTH. */ - SimplePercentBaseContext pageWidthContext + SimplePercentBaseContext pageWidthContext = new SimplePercentBaseContext(null, LengthBase.CONTAINING_BLOCK_WIDTH , pageViewPortDims.ipd); SimplePercentBaseContext pageHeightContext = new SimplePercentBaseContext(null, LengthBase.CONTAINING_BLOCK_WIDTH , pageViewPortDims.bpd); - Rectangle pageRefRect + Rectangle pageRefRect = new Rectangle(mProps.marginLeft.getValue(pageWidthContext) , mProps.marginTop.getValue(pageHeightContext) - , pageViewPortDims.ipd - - mProps.marginLeft.getValue(pageWidthContext) + , pageViewPortDims.ipd + - mProps.marginLeft.getValue(pageWidthContext) - mProps.marginRight.getValue(pageWidthContext) - , pageViewPortDims.bpd + , pageViewPortDims.bpd - mProps.marginTop.getValue(pageHeightContext) - mProps.marginBottom.getValue(pageHeightContext)); @@ -142,7 +142,7 @@ public class Page extends AreaTreeObject implements Serializable, Cloneable { public void fakeNonEmpty() { this.fakeNonEmpty = true; } - + /** * Creates a RegionViewport Area object for this pagination Region. * @param r the region the viewport is to be created for @@ -161,11 +161,11 @@ public class Page extends AreaTreeObject implements Serializable, Cloneable { rv.setBPD((int)relRegionRect.getHeight()); rv.setIPD((int)relRegionRect.getWidth()); TraitSetter.addBackground(rv, r.getCommonBorderPaddingBackground(), null); - rv.setClip(r.getOverflow() == Constants.EN_HIDDEN + rv.setClip(r.getOverflow() == Constants.EN_HIDDEN || r.getOverflow() == Constants.EN_ERROR_IF_OVERFLOW); return rv; } - + /** * Set the region reference position within the region viewport. * This sets the transform that is used to place the contents of @@ -177,15 +177,15 @@ public class Page extends AreaTreeObject implements Serializable, Cloneable { * where x=distance from left, y=distance from bottom, width=right-left * height=top-bottom */ - private void setRegionReferencePosition(RegionReference rr, Region r, + private void setRegionReferencePosition(RegionReference rr, Region r, Rectangle2D absRegVPRect) { FODimension reldims = new FODimension(0, 0); rr.setCTM(CTM.getCTMandRelDims(r.getReferenceOrientation(), r.getWritingMode(), absRegVPRect, reldims)); rr.setIPD(reldims.ipd); rr.setBPD(reldims.bpd); - } - + } + /** * Set the region on this page. * @@ -219,7 +219,7 @@ public class Page extends AreaTreeObject implements Serializable, Cloneable { case Constants.FO_REGION_START: return regionStart; case Constants.FO_REGION_BODY: - return regionBody; + return regionBody; case Constants.FO_REGION_END: return regionEnd; case Constants.FO_REGION_AFTER: diff --git a/src/java/org/apache/fop/area/PageSequence.java b/src/java/org/apache/fop/area/PageSequence.java index 3b65f7701..887fdb43d 100644 --- a/src/java/org/apache/fop/area/PageSequence.java +++ b/src/java/org/apache/fop/area/PageSequence.java @@ -30,7 +30,7 @@ public class PageSequence { private LineArea title; private String language; private String country; - + /** * Main constructor * @param title the title for the page-sequence, may be null @@ -38,14 +38,14 @@ public class PageSequence { public PageSequence(LineArea title) { setTitle(title); } - + /** * @return the title of the page sequence in form of a line area, or null if there's no title */ public LineArea getTitle() { return this.title; } - + /** * Sets the page sequence's title. * @param title the title @@ -53,7 +53,7 @@ public class PageSequence { public void setTitle(LineArea title) { this.title = title; } - + /** * Adds a new page to the page sequence * @param page the page to be added @@ -61,7 +61,7 @@ public class PageSequence { public void addPage(PageViewport page) { this.pages.add(page); } - + /** * @return the number of pages currently in this page sequence */ @@ -77,7 +77,7 @@ public class PageSequence { public PageViewport getPage(int idx) { return (PageViewport)this.pages.get(idx); } - + /** * Indicates whether a page is the first in this page sequence. * @param page the page to be inspected @@ -106,7 +106,7 @@ public class PageSequence { this.language = language; } } - + /** * Returns the country of the page-sequence. * @return the country (the value of the country property, "none" is mapped to null) @@ -126,5 +126,5 @@ public class PageSequence { this.country = country; } } - + } diff --git a/src/java/org/apache/fop/area/PageViewport.java b/src/java/org/apache/fop/area/PageViewport.java index a69925ebb..a7523530b 100644 --- a/src/java/org/apache/fop/area/PageViewport.java +++ b/src/java/org/apache/fop/area/PageViewport.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,18 +52,18 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl private Page page; private Rectangle2D viewArea; private String simplePageMasterName; - + /** - * Unique key to identify the page. pageNumberString and pageIndex are both no option + * Unique key to identify the page. pageNumberString and pageIndex are both no option * for this. */ private String pageKey; - + private int pageNumber = -1; private String pageNumberString = null; private int pageIndex = -1; //-1 = undetermined private boolean blank; - + private transient PageSequence pageSequence; // list of id references and the rectangle on the page @@ -86,7 +86,7 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl private Map markerFirstAny = null; private Map markerLastEnd = null; private Map markerLastAny = null; - + //Arbitrary attachments to the page from extensions that need to pass information //down to the renderers. private List/**/ extensionAttachments = null; @@ -117,7 +117,7 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl } /** - * Copy constructor. + * Copy constructor. * @param original the original PageViewport to copy from */ public PageViewport(PageViewport original) { @@ -142,7 +142,7 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl * @param simplePageMasterName name of the original simple-page-master that generated this page * @param blank true if this is a blank page */ - public PageViewport(Rectangle2D viewArea, int pageNumber, String pageStr, + public PageViewport(Rectangle2D viewArea, int pageNumber, String pageStr, String simplePageMasterName, boolean blank) { this.viewArea = viewArea; this.pageNumber = pageNumber; @@ -150,7 +150,7 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl this.simplePageMasterName = simplePageMasterName; this.blank = blank; } - + /** * Sets the page sequence this page belongs to * @param seq the page sequence @@ -158,12 +158,12 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl public void setPageSequence(PageSequence seq) { this.pageSequence = seq; } - + /** @return the page sequence this page belongs to */ public PageSequence getPageSequence() { return this.pageSequence; } - + /** * Get the view area rectangle of this viewport. * @return the rectangle for this viewport @@ -179,7 +179,7 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl public Page getPage() { return page; } - + /** * Sets the page object for this PageViewport. * @param page the page @@ -212,15 +212,15 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl public void setPageIndex(int index) { this.pageIndex = index; } - + /** - * @return the overall page index of the page in this rendering run (zero-based, + * @return the overall page index of the page in this rendering run (zero-based, * -1 if it is undetermined). */ public int getPageIndex() { return this.pageIndex; } - + /** * Sets the unique key for this PageViewport that will be used to reference this page. * @param key the unique key. @@ -228,7 +228,7 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl public void setKey(String key) { this.pageKey = key; } - + /** * Get the key for this page viewport. * This is used so that a serializable key can be used to @@ -293,7 +293,7 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl * @return true if the page is resolved and can be rendered */ public boolean isResolved() { - return unresolvedIDRefs == null + return unresolvedIDRefs == null || unresolvedIDRefs.size() == 0; } @@ -307,7 +307,7 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl } /** - * {@inheritDoc} + * {@inheritDoc} */ public void resolveIDRef(String id, List pages) { if (page == null) { @@ -346,7 +346,7 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl * are starting, replacing earlier markers. * For "last-ending-within-page" it adds all markers that * are ending, replacing earlier markers. - * + * * Should this logic be placed in the Page layout manager. * * @param marks the map of markers to add @@ -361,12 +361,12 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl return; } if (log.isDebugEnabled()) { - log.debug("--" + marks.keySet() + ": " - + (starting ? "starting" : "ending") - + (isfirst ? ", first" : "") + log.debug("--" + marks.keySet() + ": " + + (starting ? "starting" : "ending") + + (isfirst ? ", first" : "") + (islast ? ", last" : "")); } - + // at the start of the area, register is-first and any areas if (starting) { if (isfirst) { @@ -382,14 +382,14 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl if (!markerFirstStart.containsKey(key)) { markerFirstStart.put(key, marks.get(key)); if (log.isTraceEnabled()) { - log.trace("page " + pageNumberString + ": " + log.trace("page " + pageNumberString + ": " + "Adding marker " + key + " to FirstStart"); } } if (!markerFirstAny.containsKey(key)) { markerFirstAny.put(key, marks.get(key)); if (log.isTraceEnabled()) { - log.trace("page " + pageNumberString + ": " + log.trace("page " + pageNumberString + ": " + "Adding marker " + key + " to FirstAny"); } } @@ -400,7 +400,7 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl // last on page: replace all markerLastStart.putAll(marks); if (log.isTraceEnabled()) { - log.trace("page " + pageNumberString + ": " + log.trace("page " + pageNumberString + ": " + "Adding all markers to LastStart"); } } else { @@ -413,7 +413,7 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl if (!markerFirstAny.containsKey(key)) { markerFirstAny.put(key, marks.get(key)); if (log.isTraceEnabled()) { - log.trace("page " + pageNumberString + ": " + log.trace("page " + pageNumberString + ": " + "Adding marker " + key + " to FirstAny"); } } @@ -428,7 +428,7 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl // last on page: replace all markerLastEnd.putAll(marks); if (log.isTraceEnabled()) { - log.trace("page " + pageNumberString + ": " + log.trace("page " + pageNumberString + ": " + "Adding all markers to LastEnd"); } } @@ -438,7 +438,7 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl // last on page: replace all markerLastAny.putAll(marks); if (log.isTraceEnabled()) { - log.trace("page " + pageNumberString + ": " + log.trace("page " + pageNumberString + ": " + "Adding all markers to LastAny"); } } @@ -449,7 +449,7 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl * This will retrieve a marker with the class name * and position. * - * @param name The class name of the marker to retrieve + * @param name The class name of the marker to retrieve * @param pos the position to retrieve * @return Object the marker found or null */ @@ -497,10 +497,10 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl throw new RuntimeException(); } if (log.isTraceEnabled()) { - log.trace("page " + pageNumberString + ": " + "Retrieving marker " + name - + " at position " + posName); + log.trace("page " + pageNumberString + ": " + "Retrieving marker " + name + + " at position " + posName); } - return mark; + return mark; } /** Dumps the current marker data to the logger. */ @@ -513,7 +513,7 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl log.trace("LastStart: " + this.markerLastStart); } } - + /** * Save the page contents to an object stream. * The map of unresolved references are set on the page so that @@ -577,12 +577,12 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl sb.append(getPageNumberString()); return sb.toString(); } - + /** @return the name of the simple-page-master that created this page */ public String getSimplePageMasterName() { return this.simplePageMasterName; } - + /** * Adds a new ExtensionAttachment instance to this page. * @param attachment the ExtensionAttachment @@ -593,7 +593,7 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl } extensionAttachments.add(attachment); } - + /** @return the list of extension attachments for this page */ public List getExtensionAttachments() { if (this.extensionAttachments == null) { @@ -602,12 +602,12 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl return this.extensionAttachments; } } - + /** @return True if this is a blank page. */ public boolean isBlank() { return this.blank; } - + /** * Convenience method to get BodyRegion of this PageViewport * @return BodyRegion object @@ -615,62 +615,62 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl public BodyRegion getBodyRegion() { return (BodyRegion) getPage().getRegionViewport( Constants.FO_REGION_BODY).getRegionReference(); - } + } /** * Convenience method to create a new Span for this * this PageViewport. - * + * * @param spanAll whether this is a single-column span * @return Span object created */ public Span createSpan(boolean spanAll) { return getBodyRegion().getMainReference().createSpan(spanAll); - } + } /** * Convenience method to get the span-reference-area currently * being processed - * + * * @return span currently being processed. */ public Span getCurrentSpan() { return getBodyRegion().getMainReference().getCurrentSpan(); } - + /** - * Convenience method to get the normal-flow-reference-area + * Convenience method to get the normal-flow-reference-area * currently being processed - * + * * @return span currently being processed. */ public NormalFlow getCurrentFlow() { return getCurrentSpan().getCurrentFlow(); } - + /** - * Convenience method to increment the Span to the + * Convenience method to increment the Span to the * next NormalFlow to be processed, and to return that flow. - * + * * @return the next NormalFlow in the Span. */ public NormalFlow moveToNextFlow() { return getCurrentSpan().moveToNextFlow(); } - + /** - * Convenience method to return a given region-reference-area, + * Convenience method to return a given region-reference-area, * keyed by the Constants class identifier for the corresponding - * formatting object (ie. Constants.FO_REGION_BODY, FO_REGION_START, + * formatting object (ie. Constants.FO_REGION_BODY, FO_REGION_START, * etc.) - * + * * @param id the Constants class identifier for the region. * @return the corresponding region-reference-area for this page. */ public RegionReference getRegionReference(int id) { return getPage().getRegionViewport(id).getRegionReference(); } - + /** @return whether this page viewport has any extension attachments */ public boolean hasExtensionAttachments() { return this.extensionAttachments != null && !this.extensionAttachments.isEmpty(); diff --git a/src/java/org/apache/fop/area/RegionReference.java b/src/java/org/apache/fop/area/RegionReference.java index bd2aa0341..bee597673 100644 --- a/src/java/org/apache/fop/area/RegionReference.java +++ b/src/java/org/apache/fop/area/RegionReference.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,17 +30,17 @@ import org.apache.fop.fo.pagination.Region; * so the page master can make copies from the original page and regions. */ public class RegionReference extends Area implements Cloneable { - + /** Reference to the region FO. */ //protected Region regionFO; private int regionClass; private String regionName; private CTM ctm; - + // the list of block areas from the static flow private ArrayList blocks = new ArrayList(); - + /** the parent RegionViewport for this object */ protected RegionViewport regionViewport; @@ -78,7 +78,7 @@ public class RegionReference extends Area implements Cloneable { // subtract bpd of borders and padding before / after return super.getBPD() - getBorderAndPaddingWidthBefore() - getBorderAndPaddingWidthAfter(); } - + /** {@inheritDoc} */ public int getIPD() { // subtract ipd of borders and padding start / end @@ -97,7 +97,7 @@ public class RegionReference extends Area implements Cloneable { public void setCTM(CTM ctm) { this.ctm = ctm; } - + /** * @return Returns the parent RegionViewport. */ @@ -136,7 +136,7 @@ public class RegionReference extends Area implements Cloneable { public String getRegionName() { return this.regionName; } - + /** * Add a block area to this region reference area. * @@ -145,7 +145,7 @@ public class RegionReference extends Area implements Cloneable { public void addBlock(Block block) { addChildArea(block); } - + /** * Clone this region. * This is used when cloning the page by the page master. diff --git a/src/java/org/apache/fop/area/RegionViewport.java b/src/java/org/apache/fop/area/RegionViewport.java index 586048a1b..d55ecefbb 100644 --- a/src/java/org/apache/fop/area/RegionViewport.java +++ b/src/java/org/apache/fop/area/RegionViewport.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.area; import java.awt.geom.Rectangle2D; @@ -25,7 +25,7 @@ import java.util.HashMap; /** * Region Viewport area. - * This object represents the region-viewport-area. It has a + * This object represents the region-viewport-area. It has a * region-reference-area as its child. These areas are described * in the fo:region-body description in the XSL Recommendation. */ @@ -76,7 +76,7 @@ public class RegionViewport extends Area implements Cloneable { public boolean isClip() { return this.clip; } - + /** * Get the view area of this viewport. * diff --git a/src/java/org/apache/fop/area/RenderPagesModel.java b/src/java/org/apache/fop/area/RenderPagesModel.java index 39a188bde..13995b099 100644 --- a/src/java/org/apache/fop/area/RenderPagesModel.java +++ b/src/java/org/apache/fop/area/RenderPagesModel.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.area; // Java @@ -46,7 +46,7 @@ public class RenderPagesModel extends AreaTreeModel { * The renderer that will render the pages. */ protected Renderer renderer; - + /** * Pages that have been prepared but not rendered yet. */ @@ -62,7 +62,7 @@ public class RenderPagesModel extends AreaTreeModel { * @param stream OutputStream * @throws FOPException if the renderer cannot be properly initialized */ - public RenderPagesModel (FOUserAgent userAgent, String outputFormat, + public RenderPagesModel (FOUserAgent userAgent, String outputFormat, FontInfo fontInfo, OutputStream stream) throws FOPException { super(); @@ -113,7 +113,7 @@ public class RenderPagesModel extends AreaTreeModel { try { renderer.renderPage(page); } catch (RuntimeException re) { - String err = "Error while rendering page " + page.getPageNumberString(); + String err = "Error while rendering page " + page.getPageNumberString(); log.error(err, re); throw re; } catch (IOException ioe) { @@ -122,9 +122,9 @@ public class RenderPagesModel extends AreaTreeModel { eventProducer.ioError(this, ioe); } catch (FOPException e) { //TODO use error handler to handle this FOPException or propagate exception - String err = "Error while rendering page " + page.getPageNumberString(); + String err = "Error while rendering page " + page.getPageNumberString(); log.error(err, e); - throw new IllegalStateException("Fatal error occurred. Cannot continue. " + throw new IllegalStateException("Fatal error occurred. Cannot continue. " + e.getClass().getName() + ": " + err); } page.clear(); diff --git a/src/java/org/apache/fop/area/Resolvable.java b/src/java/org/apache/fop/area/Resolvable.java index e9c0198ce..cc2569e8a 100644 --- a/src/java/org/apache/fop/area/Resolvable.java +++ b/src/java/org/apache/fop/area/Resolvable.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.area; import java.util.List; @@ -52,7 +52,7 @@ public interface Resolvable { * identifies to the AreaTreeHandler which idrefs it needs * resolved. After the idrefs are resolved, the ATH calls this * method to allow the Resolvable object to update itself with - * the PageViewport information. + * the PageViewport information. * * @param id an ID matching one of the Resolvable object's * unresolved idref's. diff --git a/src/java/org/apache/fop/area/Span.java b/src/java/org/apache/fop/area/Span.java index cf9dd3c42..69b37f4b3 100644 --- a/src/java/org/apache/fop/area/Span.java +++ b/src/java/org/apache/fop/area/Span.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.area; import java.util.List; @@ -27,7 +27,7 @@ import java.util.List; * within the main-reference-area * This object holds one or more normal-flow-reference-area children * based on the column-count trait in effect for this span. - * See fo:region-body definition in the XSL Rec for more information. + * See fo:region-body definition in the XSL Rec for more information. */ public class Span extends Area { // the list of flow reference areas in this span area @@ -36,13 +36,13 @@ public class Span extends Area { private int colGap; private int colWidth; // width for each normal flow, calculated value private int curFlowIdx; // n-f-r-a currently being processed, zero-based - + /** * Create a span area with the number of columns for this span area. * * @param colCount the number of columns in the span - * @param colGap the column gap between each column - * @param ipd the total ipd of the span + * @param colGap the column gap between each column + * @param ipd the total ipd of the span */ public Span(int colCount, int colGap, int ipd) { addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE); @@ -57,7 +57,7 @@ public class Span extends Area { * Create the normal flows for this Span */ private void createNormalFlows() { - flowAreas = new java.util.ArrayList(colCount); + flowAreas = new java.util.ArrayList(colCount); colWidth = (ipd - ((colCount - 1) * colGap)) / colCount; for (int i = 0; i < colCount; i++) { @@ -104,28 +104,28 @@ public class Span extends Area { if (colRequested >= 0 && colRequested < colCount) { return (NormalFlow) flowAreas.get(colRequested); } else { // internal error - throw new IllegalArgumentException("Invalid column number " - + colRequested + " requested; only 0-" + (colCount - 1) + throw new IllegalArgumentException("Invalid column number " + + colRequested + " requested; only 0-" + (colCount - 1) + " available."); } } - + /** * Get the NormalFlow area currently being processed * * @return the current NormalFlow */ public NormalFlow getCurrentFlow() { - return getNormalFlow(curFlowIdx); + return getNormalFlow(curFlowIdx); } - + /** @return the index of the current normal flow */ public int getCurrentFlowIndex() { return curFlowIdx; } - + /** - * Indicate to the Span that the next column is being + * Indicate to the Span that the next column is being * processed. * * @return the new NormalFlow (in the next column) @@ -138,17 +138,17 @@ public class Span extends Area { throw new IllegalStateException("(Internal error.) No more flows left in span."); } } - + /** - * Indicates if the Span has unprocessed flows. + * Indicates if the Span has unprocessed flows. * - * @return true if Span can increment to the next flow, + * @return true if Span can increment to the next flow, * false otherwise. */ public boolean hasMoreFlows() { - return (curFlowIdx < colCount - 1); + return (curFlowIdx < colCount - 1); } - + /** * Called to notify the span that all its flows have been fully generated so it can update * its own BPD extent. @@ -160,7 +160,7 @@ public class Span extends Area { } bpd = maxFlowBPD; } - + /** * Indicates whether any child areas have been added to this span area. * @@ -179,7 +179,7 @@ public class Span extends Area { } return (areaCount == 0); } - + /** {@inheritDoc} */ public String toString() { StringBuffer sb = new StringBuffer(super.toString()); diff --git a/src/java/org/apache/fop/area/Trait.java b/src/java/org/apache/fop/area/Trait.java index e7b39ad2b..45c0432f4 100644 --- a/src/java/org/apache/fop/area/Trait.java +++ b/src/java/org/apache/fop/area/Trait.java @@ -175,19 +175,19 @@ public class Trait implements Serializable { /** The space-before trait. */ public static final Integer SPACE_BEFORE = new Integer(29); - + /** The space-after trait. */ public static final Integer SPACE_AFTER = new Integer(30); - + /** The is-reference-area trait. */ public static final Integer IS_REFERENCE_AREA = new Integer(31); - + /** The is-viewport-area trait. */ public static final Integer IS_VIEWPORT_AREA = new Integer(32); - + /** Blinking trait used when rendering inline parent. */ public static final Integer BLINK = new Integer(33); - + /** Trait for color of underline decorations when rendering inline parent. */ public static final Integer UNDERLINE_COLOR = new Integer(34); /** Trait for color of overline decorations when rendering inline parent. */ @@ -197,9 +197,9 @@ public class Trait implements Serializable { /** Maximum value used by trait keys */ public static final int MAX_TRAIT_KEY = 36; - + private static final TraitInfo[] TRAIT_INFO = new TraitInfo[MAX_TRAIT_KEY + 1]; - + private static class TraitInfo { private String name; private Class clazz; // Class of trait data @@ -221,7 +221,7 @@ public class Trait implements Serializable { private static void put(Integer key, TraitInfo info) { TRAIT_INFO[key.intValue()] = info; } - + static { // Create a hashmap mapping trait code to name for external representation //put(ID_LINK, new TraitInfo("id-link", String.class)); @@ -518,7 +518,7 @@ public class Trait implements Serializable { /** The background image url if any. */ private String url = null; - + /** The background image if any. */ private ImageInfo imageInfo = null; @@ -658,7 +658,7 @@ public class Trait implements Serializable { throw new IllegalStateException("Illegal repeat style: " + repeat); } } - + /** * Return the string for debugging. * {@inheritDoc} diff --git a/src/java/org/apache/fop/area/inline/AbstractTextArea.java b/src/java/org/apache/fop/area/inline/AbstractTextArea.java index 3f0376310..e73a8355c 100644 --- a/src/java/org/apache/fop/area/inline/AbstractTextArea.java +++ b/src/java/org/apache/fop/area/inline/AbstractTextArea.java @@ -36,7 +36,7 @@ public abstract class AbstractTextArea extends InlineParent { * (this is equivalent to the property word-spacing.optimum) */ protected int spaceDifference = 0; - + /** * Constructor * @@ -70,7 +70,7 @@ public abstract class AbstractTextArea extends InlineParent { public AbstractTextArea(int stretch, int shrink, int adj) { textAdjustingInfo = new TextAdjustingInfo(stretch, shrink, adj); } - + /** * Get text word space adjust. * @@ -108,9 +108,9 @@ public abstract class AbstractTextArea extends InlineParent { } /** - * Set the difference between optimal width of a space and + * Set the difference between optimal width of a space and * default width of a space according to the font; this part - * of the space adjustment is fixed and must not be + * of the space adjustment is fixed and must not be * multiplied by the variation factor. * @param spaceDiff the space difference */ @@ -129,22 +129,22 @@ public abstract class AbstractTextArea extends InlineParent { int lineStretch, int lineShrink) { if (textAdjustingInfo != null) { // compute the new adjustments: - // if the variation factor is negative, it means that before + // if the variation factor is negative, it means that before // the ipd variation the line had to stretch and now it has // to shrink (or vice versa); - // in this case, if the stretch and shrink are not equally - // divided among the inline areas, we must compute a + // in this case, if the stretch and shrink are not equally + // divided among the inline areas, we must compute a // balancing factor double balancingFactor = 1.0; if (variationFactor < 0) { if (textWordSpaceAdjust < 0) { // from a negative adjustment to a positive one - balancingFactor + balancingFactor = ((double) textAdjustingInfo.availableStretch / textAdjustingInfo.availableShrink) * ((double) lineShrink / lineStretch); } else { // from a positive adjustment to a negative one - balancingFactor + balancingFactor = ((double) textAdjustingInfo.availableShrink / textAdjustingInfo.availableStretch) * ((double) lineStretch / lineShrink); } diff --git a/src/java/org/apache/fop/area/inline/Anchor.java b/src/java/org/apache/fop/area/inline/Anchor.java index 4114025c8..ec6dbbcfb 100644 --- a/src/java/org/apache/fop/area/inline/Anchor.java +++ b/src/java/org/apache/fop/area/inline/Anchor.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.area.inline; /** diff --git a/src/java/org/apache/fop/area/inline/Container.java b/src/java/org/apache/fop/area/inline/Container.java index b22d09687..98c0aaef0 100644 --- a/src/java/org/apache/fop/area/inline/Container.java +++ b/src/java/org/apache/fop/area/inline/Container.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.area.inline; import org.apache.fop.area.Area; diff --git a/src/java/org/apache/fop/area/inline/FilledArea.java b/src/java/org/apache/fop/area/inline/FilledArea.java index 5f6d49f4c..7df62e79b 100644 --- a/src/java/org/apache/fop/area/inline/FilledArea.java +++ b/src/java/org/apache/fop/area/inline/FilledArea.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.area.inline; import java.util.List; @@ -35,7 +35,7 @@ import java.util.Iterator; */ public class FilledArea extends InlineParent { private int unitWidth; - + /** * Create a new filled area. */ @@ -98,7 +98,7 @@ public class FilledArea extends InlineParent { } return bpd; } - + /** * Get the child areas for this filled area. * This copies the references of the inline areas so that @@ -115,7 +115,7 @@ public class FilledArea extends InlineParent { } return newList; } - + /** * Recursively apply the variation factor to all descendant areas * @param variationFactor the variation factor that must be applied to adjustments diff --git a/src/java/org/apache/fop/area/inline/ForeignObject.java b/src/java/org/apache/fop/area/inline/ForeignObject.java index 953d969f6..3c36b3195 100644 --- a/src/java/org/apache/fop/area/inline/ForeignObject.java +++ b/src/java/org/apache/fop/area/inline/ForeignObject.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.area.inline; import org.apache.fop.area.Area; @@ -30,9 +30,9 @@ import org.w3c.dom.Document; * This holds an xml document and the associated namespace. */ public class ForeignObject extends Area { - + private static final long serialVersionUID = -214947698798577885L; - + private Document doc; private String namespace; @@ -63,7 +63,7 @@ public class ForeignObject extends Area { public void setDocument(Document document) { this.doc = document; } - + /** * Get the document for this foreign object. * diff --git a/src/java/org/apache/fop/area/inline/Image.java b/src/java/org/apache/fop/area/inline/Image.java index 1689dd6c5..7d802db49 100644 --- a/src/java/org/apache/fop/area/inline/Image.java +++ b/src/java/org/apache/fop/area/inline/Image.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.area.inline; import org.apache.fop.area.Area; diff --git a/src/java/org/apache/fop/area/inline/InlineArea.java b/src/java/org/apache/fop/area/inline/InlineArea.java index 2e24af3c3..6d5d9ca98 100644 --- a/src/java/org/apache/fop/area/inline/InlineArea.java +++ b/src/java/org/apache/fop/area/inline/InlineArea.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 @@ import org.apache.fop.area.Trait; * in a line area. */ public class InlineArea extends Area { - + /** * this class stores information about potential adjustments * that can be used in order to re-compute adjustments when a @@ -42,7 +42,7 @@ public class InlineArea extends Area { protected int availableShrink; /** total adjustment (= ipd - width of fixed elements) */ protected int adjustment; - + /** * Constructor * @@ -55,10 +55,10 @@ public class InlineArea extends Area { availableShrink = shrink; adjustment = adj; } - + /** * Apply the variation factor - * + * * @param variationFactor the factor by which the adjustment is to be changed * @return the IPD increase */ @@ -68,19 +68,19 @@ public class InlineArea extends Area { return adjustment - oldAdjustment; } } - + /** * offset position from before edge of parent area */ protected int offset = 0; - + /** * parent area * it is needed in order to recompute adjust ratio and indents * when a page-number or a page-number-citation is resolved */ private Area parentArea = null; - + /** * ipd variation of child areas: if this area has not already * been added and cannot notify its parent area, store the variation @@ -92,7 +92,7 @@ public class InlineArea extends Area { * The adjustment information object */ protected InlineAdjustingInfo adjustingInfo = null; - + /** * @return the adjustment information object */ @@ -109,7 +109,7 @@ public class InlineArea extends Area { public void setAdjustingInfo(int stretch, int shrink, int adjustment) { adjustingInfo = new InlineAdjustingInfo(stretch, shrink, adjustment); } - + /** * Modify the adjustment value in the adjustment information object * @param adjustment the new adjustment value @@ -119,7 +119,7 @@ public class InlineArea extends Area { adjustingInfo.adjustment = adjustment; } } - + /** * Increase the inline progression dimensions of this area. * This is used for inline parent areas that contain mulitple child areas. @@ -165,7 +165,7 @@ public class InlineArea extends Area { public Area getParentArea() { return parentArea; } - + /** * Set the parent for the child area. * @@ -177,7 +177,7 @@ public class InlineArea extends Area { ((InlineArea) childArea).setParentArea(this); } } - + /** *@return true if the inline area is underlined. */ @@ -189,17 +189,17 @@ public class InlineArea extends Area { public boolean hasOverline() { return getTraitAsBoolean(Trait.OVERLINE); } - + /** @return true if the inline area has a line through. */ public boolean hasLineThrough() { return getTraitAsBoolean(Trait.LINETHROUGH); } - + /** @return true if the inline area is blinking. */ public boolean isBlinking() { return getTraitAsBoolean(Trait.BLINK); } - + /** * recursively apply the variation factor to all descendant areas * @param variationFactor the variation factor that must be applied to adjustments @@ -215,12 +215,12 @@ public class InlineArea extends Area { } return false; } - + public void handleIPDVariation(int ipdVariation) { increaseIPD(ipdVariation); notifyIPDVariation(ipdVariation); } - + /** * notify the parent area about the ipd variation of this area * or of a descendant area diff --git a/src/java/org/apache/fop/area/inline/InlineBlockParent.java b/src/java/org/apache/fop/area/inline/InlineBlockParent.java index 7cb611939..e580b1667 100644 --- a/src/java/org/apache/fop/area/inline/InlineBlockParent.java +++ b/src/java/org/apache/fop/area/inline/InlineBlockParent.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/area/inline/InlineParent.java b/src/java/org/apache/fop/area/inline/InlineParent.java index 4b55d45be..cbc5b578c 100644 --- a/src/java/org/apache/fop/area/inline/InlineParent.java +++ b/src/java/org/apache/fop/area/inline/InlineParent.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 @@ public class InlineParent extends InlineArea { /** Controls whether the IPD is automatically adjusted based on the area's children. */ protected transient boolean autoSize; - + /** * Create a new inline parent to add areas to. */ @@ -82,7 +82,7 @@ public class InlineParent extends InlineArea { public boolean applyVariationFactor(double variationFactor, int lineStretch, int lineShrink) { boolean bUnresolvedAreasPresent = false; - // recursively apply variation factor to descendant areas + // recursively apply variation factor to descendant areas for (int i = 0, len = inlines.size(); i < len; i++) { bUnresolvedAreasPresent |= ((InlineArea)inlines.get(i)) .applyVariationFactor(variationFactor, lineStretch, lineShrink); diff --git a/src/java/org/apache/fop/area/inline/Leader.java b/src/java/org/apache/fop/area/inline/Leader.java index 1bcc72eab..cd7b2e9f3 100644 --- a/src/java/org/apache/fop/area/inline/Leader.java +++ b/src/java/org/apache/fop/area/inline/Leader.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. @@ -71,7 +71,7 @@ public class Leader extends InlineArea { setRuleStyle(Constants.EN_NONE); } } - + /** * Set the rule thickness of the rule in miilipoints. * @@ -104,7 +104,7 @@ public class Leader extends InlineArea { throw new IllegalStateException("Unsupported rule style: " + getRuleStyle()); } } - + /** * Get the rule thickness of the rule in miilipoints. * diff --git a/src/java/org/apache/fop/area/inline/Space.java b/src/java/org/apache/fop/area/inline/Space.java index e0e9982bf..9a24de0d3 100644 --- a/src/java/org/apache/fop/area/inline/Space.java +++ b/src/java/org/apache/fop/area/inline/Space.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/area/inline/SpaceArea.java b/src/java/org/apache/fop/area/inline/SpaceArea.java index 9481795a4..287f09dfc 100644 --- a/src/java/org/apache/fop/area/inline/SpaceArea.java +++ b/src/java/org/apache/fop/area/inline/SpaceArea.java @@ -22,7 +22,7 @@ package org.apache.fop.area.inline; * A space */ public class SpaceArea extends InlineArea { - + /** * The space for this space area */ @@ -44,7 +44,7 @@ public class SpaceArea extends InlineArea { offset = o; isAdjustable = a; } - + /** * @return Returns the space. */ diff --git a/src/java/org/apache/fop/area/inline/TextArea.java b/src/java/org/apache/fop/area/inline/TextArea.java index fc7463af0..f736b894c 100644 --- a/src/java/org/apache/fop/area/inline/TextArea.java +++ b/src/java/org/apache/fop/area/inline/TextArea.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. @@ -47,20 +47,20 @@ public class TextArea extends AbstractTextArea { public void removeText() { inlines.clear(); } - + /** * Create and add a WordArea child to this TextArea. - * + * * @param word the word string * @param offset the offset for the next area */ public void addWord(String word, int offset) { addWord(word, offset, null); } - + /** * Create and add a WordArea child to this TextArea. - * + * * @param word the word string * @param offset the offset for the next area * @param letterAdjust the letter adjustment array (may be null) @@ -70,10 +70,10 @@ public class TextArea extends AbstractTextArea { addChildArea(wordArea); wordArea.setParentArea(this); } - + /** * Create and add a SpaceArea child to this TextArea - * + * * @param space the space character * @param offset the offset for the next area * @param adjustable is this space adjustable? @@ -83,13 +83,13 @@ public class TextArea extends AbstractTextArea { addChildArea(spaceArea); spaceArea.setParentArea(this); } - + /** * Get the whole text string. - * Renderers whose space adjustment handling is not affected + * Renderers whose space adjustment handling is not affected * by multi-byte characters can use this method to render the - * whole TextArea at once; the other renderers (for example - * PDFRenderer) have to implement renderWord(WordArea) and + * whole TextArea at once; the other renderers (for example + * PDFRenderer) have to implement renderWord(WordArea) and * renderSpace(SpaceArea) in order to correctly place each * text fragment. * diff --git a/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java b/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java index db94ce6a1..43a995670 100644 --- a/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java +++ b/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.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.area.inline; import org.apache.fop.area.PageViewport; @@ -41,10 +41,10 @@ public class UnresolvedPageNumber extends TextArea implements Resolvable { public static final boolean FIRST = true; /** Indicates that the reference refers to the last area generated by a formatting object. */ public static final boolean LAST = false; - + //Transient fields private transient Font font; - + /** * Create a new unresolved page number. * @@ -54,7 +54,7 @@ public class UnresolvedPageNumber extends TextArea implements Resolvable { public UnresolvedPageNumber(String id, Font f) { this(id, f, FIRST); } - + /** * Create a new unresolved page number. * @@ -98,7 +98,7 @@ public class UnresolvedPageNumber extends TextArea implements Resolvable { PageViewport page; if (pageType == FIRST) { page = (PageViewport)pages.get(0); - } else { + } else { page = (PageViewport)pages.get(pages.size() - 1); } // replace the text diff --git a/src/java/org/apache/fop/area/inline/Viewport.java b/src/java/org/apache/fop/area/inline/Viewport.java index 0dc0112bd..489f5afda 100644 --- a/src/java/org/apache/fop/area/inline/Viewport.java +++ b/src/java/org/apache/fop/area/inline/Viewport.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. @@ -91,7 +91,7 @@ public class Viewport extends InlineArea { public void setContent(Area content) { this.content = content; } - + /** * Get the content area for this viewport. * diff --git a/src/java/org/apache/fop/area/inline/WordArea.java b/src/java/org/apache/fop/area/inline/WordArea.java index 1f5fa2037..70d10ef9b 100644 --- a/src/java/org/apache/fop/area/inline/WordArea.java +++ b/src/java/org/apache/fop/area/inline/WordArea.java @@ -25,10 +25,10 @@ public class WordArea extends InlineArea { /** The text for this word area */ protected String word; - + /** The correction offset for the next area */ protected int offset = 0; - + /** An array of width for adjusting the individual letters (optional) */ protected int[] letterAdjust; @@ -63,10 +63,10 @@ public class WordArea extends InlineArea { public void setOffset(int o) { offset = o; } - + /** @return the array of letter adjust widths */ public int[] getLetterAdjustArray() { return this.letterAdjust; } - + } diff --git a/src/java/org/apache/fop/cli/AreaTreeInputHandler.java b/src/java/org/apache/fop/cli/AreaTreeInputHandler.java index b32cfcacd..e56d03774 100644 --- a/src/java/org/apache/fop/cli/AreaTreeInputHandler.java +++ b/src/java/org/apache/fop/cli/AreaTreeInputHandler.java @@ -43,7 +43,7 @@ public class AreaTreeInputHandler extends InputHandler { * Constructor for XML->XSLT->area tree XML input * @param xmlfile XML file * @param xsltfile XSLT file - * @param params Vector of command-line parameters (name, value, + * @param params Vector of command-line parameters (name, value, * name, value, ...) for XSL stylesheet, null if none */ public AreaTreeInputHandler(File xmlfile, File xsltfile, Vector params) { @@ -59,20 +59,20 @@ public class AreaTreeInputHandler extends InputHandler { } /** {@inheritDoc} */ - public void renderTo(FOUserAgent userAgent, String outputFormat, OutputStream out) + public void renderTo(FOUserAgent userAgent, String outputFormat, OutputStream out) throws FOPException { FontInfo fontInfo = new FontInfo(); - AreaTreeModel treeModel = new RenderPagesModel(userAgent, + AreaTreeModel treeModel = new RenderPagesModel(userAgent, outputFormat, fontInfo, out); - + //Iterate over all intermediate files AreaTreeParser parser = new AreaTreeParser(); - + // Resulting SAX events (the generated FO) must be piped through to FOP Result res = new SAXResult(parser.getContentHandler(treeModel, userAgent)); transformTo(res); - + try { treeModel.endDocument(); } catch (SAXException e) { diff --git a/src/java/org/apache/fop/cli/ImageInputHandler.java b/src/java/org/apache/fop/cli/ImageInputHandler.java index fe3d5021f..b8439bc7a 100644 --- a/src/java/org/apache/fop/cli/ImageInputHandler.java +++ b/src/java/org/apache/fop/cli/ImageInputHandler.java @@ -35,7 +35,7 @@ public class ImageInputHandler extends InputHandler { * Main constructor. * @param imagefile the image file * @param xsltfile XSLT file (may be null in which case the default stylesheet is used) - * @param params Vector of command-line parameters (name, value, + * @param params Vector of command-line parameters (name, value, * name, value, ...) for XSL stylesheet, null if none */ public ImageInputHandler(File imagefile, File xsltfile, Vector params) { @@ -47,7 +47,7 @@ public class ImageInputHandler extends InputHandler { return new StreamSource(new StringReader( "" + this.sourcefile.toURI().toASCIIString() + "")); } - + /** {@inheritDoc} */ protected Source createXSLTSource() { Source src = super.createXSLTSource(); diff --git a/src/java/org/apache/fop/datatypes/CompoundDatatype.java b/src/java/org/apache/fop/datatypes/CompoundDatatype.java index 85805933a..ad1c8bddf 100644 --- a/src/java/org/apache/fop/datatypes/CompoundDatatype.java +++ b/src/java/org/apache/fop/datatypes/CompoundDatatype.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.datatypes; import org.apache.fop.fo.Constants; @@ -26,7 +26,7 @@ import org.apache.fop.fo.properties.Property; * This interface is used as a base for compound datatypes. */ public interface CompoundDatatype extends Constants { - + /** * Sets a component of the compound datatype. * @param cmpId ID of the component diff --git a/src/java/org/apache/fop/datatypes/FODimension.java b/src/java/org/apache/fop/datatypes/FODimension.java index 8c50cf52a..cf8acdbb5 100644 --- a/src/java/org/apache/fop/datatypes/FODimension.java +++ b/src/java/org/apache/fop/datatypes/FODimension.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. @@ -40,7 +40,7 @@ public class FODimension { this.ipd = ipd; this.bpd = bpd; } - + public String toString() { StringBuffer sb = new StringBuffer(super.toString()); sb.append(" {ipd=").append(Integer.toString(ipd)); diff --git a/src/java/org/apache/fop/datatypes/KeepValue.java b/src/java/org/apache/fop/datatypes/KeepValue.java index 312df9a04..51d8bbd51 100644 --- a/src/java/org/apache/fop/datatypes/KeepValue.java +++ b/src/java/org/apache/fop/datatypes/KeepValue.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/datatypes/Length.java b/src/java/org/apache/fop/datatypes/Length.java index a8b6435b1..5e2ef8e53 100644 --- a/src/java/org/apache/fop/datatypes/Length.java +++ b/src/java/org/apache/fop/datatypes/Length.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 @@ public interface Length extends Numeric { * @return the length in millipoints */ int getValue(); - + /** * Returns the length in 1/1000ths of a point (millipoints) * @param context The context for the length calculation (for percentage based lengths) diff --git a/src/java/org/apache/fop/datatypes/LengthBase.java b/src/java/org/apache/fop/datatypes/LengthBase.java index 8a321f2c6..137ca94fa 100644 --- a/src/java/org/apache/fop/datatypes/LengthBase.java +++ b/src/java/org/apache/fop/datatypes/LengthBase.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. @@ -76,7 +76,7 @@ public class LengthBase implements PercentBase { /** For percentages based on other length properties */ private Length baseLength; - + /** * Constructor * @param plist property list for this @@ -133,11 +133,11 @@ public class LengthBase implements PercentBase { /** {@inheritDoc} */ public String toString() { return super.toString() - + "[fo=" + fobj + "," + + "[fo=" + fobj + "," + "baseType=" + baseType + "," + "baseLength=" + baseLength + "]"; } - + /**@return the base length as a {@link Length} */ public Length getBaseLength() { return baseLength; diff --git a/src/java/org/apache/fop/datatypes/Numeric.java b/src/java/org/apache/fop/datatypes/Numeric.java index 495a65ce0..32ae78921 100644 --- a/src/java/org/apache/fop/datatypes/Numeric.java +++ b/src/java/org/apache/fop/datatypes/Numeric.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.fo.expr.PropertyException; * must be resolved against base value before the value can be used. *

    * To support relative numerics internally in the expresion parser and - * during evaulation one additional methods exists: isAbsolute() which + * during evaulation one additional methods exists: isAbsolute() which * return true for absolute numerics and false for relative numerics. */ public interface Numeric { @@ -40,7 +40,7 @@ public interface Numeric { * @throws PropertyException */ double getNumericValue() throws PropertyException; - + /** * Return the value of this Numeric * @param context The context for the length calculation (for percentage based lengths) @@ -78,10 +78,10 @@ public interface Numeric { public int getValue(PercentBaseContext context); /** - * Return the resolved value. This method will becalled during evaluation - * of the expression tree and relative numerics can then return a + * Return the resolved value. This method will becalled during evaluation + * of the expression tree and relative numerics can then return a * resolved absolute Numeric. Absolute numerics can just return themself. - * + * * @return A resolved value. * @throws PropertyException */ diff --git a/src/java/org/apache/fop/datatypes/PercentBase.java b/src/java/org/apache/fop/datatypes/PercentBase.java index 6452086de..6bc9ac939 100644 --- a/src/java/org/apache/fop/datatypes/PercentBase.java +++ b/src/java/org/apache/fop/datatypes/PercentBase.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,28 +26,28 @@ import org.apache.fop.fo.expr.PropertyException; * computations */ public interface PercentBase { - + /** * Determines whether a numeric property is created or one with a percentage * base. * @return 0 for length, 1 for percentage */ int getDimension(); - + /** - * @return the base value (this will be used as the base to which a percentage will be + * @return the base value (this will be used as the base to which a percentage will be * applied to compute the length of the referencing item) */ double getBaseValue(); /** * @param context The context for percentage evaluation - * @return the integer size in millipoints of the object (this will be used - * as the base to which a percentage will be applied to compute the length + * @return the integer size in millipoints of the object (this will be used + * as the base to which a percentage will be applied to compute the length * of the referencing item) * @throws PropertyException if a problem occurs during evaluation of this * value. */ int getBaseLength(PercentBaseContext context) throws PropertyException; - + } diff --git a/src/java/org/apache/fop/datatypes/PercentBaseContext.java b/src/java/org/apache/fop/datatypes/PercentBaseContext.java index bf01482f0..9744f417e 100644 --- a/src/java/org/apache/fop/datatypes/PercentBaseContext.java +++ b/src/java/org/apache/fop/datatypes/PercentBaseContext.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.datatypes; import org.apache.fop.fo.FObj; @@ -37,5 +37,5 @@ public interface PercentBaseContext { * @return The base length value of the given kind */ public int getBaseLength(int lengthBase, FObj fobj); - + } diff --git a/src/java/org/apache/fop/datatypes/SimplePercentBaseContext.java b/src/java/org/apache/fop/datatypes/SimplePercentBaseContext.java index 3b3c87525..271702f4e 100644 --- a/src/java/org/apache/fop/datatypes/SimplePercentBaseContext.java +++ b/src/java/org/apache/fop/datatypes/SimplePercentBaseContext.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. @@ -25,14 +25,14 @@ import org.apache.fop.fo.FObj; * Class to implement a simple lookup context for a single percent base value. */ public class SimplePercentBaseContext implements PercentBaseContext { - + private PercentBaseContext parentContext; private int lengthBase; private int lengthBaseValue; /** * @param parentContext the context to be used for all percentages other than lengthBase - * @param lengthBase the particular percentage length base for which this context provides + * @param lengthBase the particular percentage length base for which this context provides * a value * @param lengthBaseValue the value to be returned for requests to the given lengthBase */ @@ -46,7 +46,7 @@ public class SimplePercentBaseContext implements PercentBaseContext { /** * Returns the value for the given lengthBase. - * {@inheritDoc} + * {@inheritDoc} */ public int getBaseLength(int lengthBase, FObj fobj) { // if its for us return our value otherwise delegate to parent context diff --git a/src/java/org/apache/fop/datatypes/URISpecification.java b/src/java/org/apache/fop/datatypes/URISpecification.java index 99d445b4d..9311851ea 100644 --- a/src/java/org/apache/fop/datatypes/URISpecification.java +++ b/src/java/org/apache/fop/datatypes/URISpecification.java @@ -57,19 +57,19 @@ public class URISpecification { private static final String PUNCT = ",;:$&+="; private static final String RESERVED = PUNCT + "?/[]@"; - + private static boolean isValidURIChar(char ch) { return true; } - + private static boolean isDigit(char ch) { return (ch >= '0' && ch <= '9'); } - + private static boolean isAlpha(char ch) { return (ch >= 'A' && ch <= 'Z') || (ch >= 'A' && ch <= 'z'); } - + private static boolean isHexDigit(char ch) { return (ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'F') || (ch >= 'a' && ch <= 'f'); } @@ -83,7 +83,7 @@ public class URISpecification { } return false; } - + private static boolean isUnreserved(char ch) { if (isDigit(ch) || isAlpha(ch)) { return true; @@ -93,7 +93,7 @@ public class URISpecification { } return false; } - + private final static char[] HEX_DIGITS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' @@ -137,5 +137,5 @@ public class URISpecification { } return sb.toString(); } - + } diff --git a/src/java/org/apache/fop/datatypes/ValidationPercentBaseContext.java b/src/java/org/apache/fop/datatypes/ValidationPercentBaseContext.java index 6301c4d85..dba6d89ff 100644 --- a/src/java/org/apache/fop/datatypes/ValidationPercentBaseContext.java +++ b/src/java/org/apache/fop/datatypes/ValidationPercentBaseContext.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,11 +26,11 @@ import org.apache.fop.fo.FObj; * but should still already be checked. The actual value returned is not so important in this * case. But it's important that zero and non-zero values can be distinguished. *

    - * Example: A table with collapsing border model has no padding. The Table FO should be able + * Example: A table with collapsing border model has no padding. The Table FO should be able * to check if non-zero values (even percentages) have been specified. */ public final class ValidationPercentBaseContext implements PercentBaseContext { - + /** * Main constructor. */ @@ -39,7 +39,7 @@ public final class ValidationPercentBaseContext implements PercentBaseContext { /** * Returns the value for the given lengthBase. - * {@inheritDoc} + * {@inheritDoc} */ public int getBaseLength(int lengthBase, FObj fobj) { //Simply return a dummy value which produces a non-zero value when a non-zero percentage @@ -48,7 +48,7 @@ public final class ValidationPercentBaseContext implements PercentBaseContext { } private static PercentBaseContext pseudoContextForValidation = null; - + /** @return a base context for validation purposes. See class description. */ public static PercentBaseContext getPseudoContext() { if (pseudoContextForValidation == null) { @@ -56,5 +56,5 @@ public final class ValidationPercentBaseContext implements PercentBaseContext { } return pseudoContextForValidation; } - + } diff --git a/src/java/org/apache/fop/events/CompositeEventListener.java b/src/java/org/apache/fop/events/CompositeEventListener.java index a65728b71..2b5cbffb2 100644 --- a/src/java/org/apache/fop/events/CompositeEventListener.java +++ b/src/java/org/apache/fop/events/CompositeEventListener.java @@ -27,7 +27,7 @@ import java.util.List; 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). @@ -49,7 +49,7 @@ public class CompositeEventListener implements EventListener { 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 @@ -57,7 +57,7 @@ public class CompositeEventListener implements EventListener { public boolean hasEventListeners() { return (getListenerCount() > 0); } - + /** {@inheritDoc} */ public synchronized void processEvent(Event event) { for (int i = 0, c = getListenerCount(); i < c; i++) { diff --git a/src/java/org/apache/fop/events/DefaultEventBroadcaster.java b/src/java/org/apache/fop/events/DefaultEventBroadcaster.java index bb1752a72..cd415a8d7 100644 --- a/src/java/org/apache/fop/events/DefaultEventBroadcaster.java +++ b/src/java/org/apache/fop/events/DefaultEventBroadcaster.java @@ -42,7 +42,7 @@ 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); @@ -57,7 +57,7 @@ public class DefaultEventBroadcaster implements EventBroadcaster { public boolean hasEventListeners() { return this.listeners.hasEventListeners(); } - + /** {@inheritDoc} */ public void broadcastEvent(Event event) { this.listeners.processEvent(event); @@ -65,7 +65,7 @@ public class DefaultEventBroadcaster implements EventBroadcaster { 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()) { @@ -81,7 +81,7 @@ public class DefaultEventBroadcaster implements EventBroadcaster { public static void addEventModel(EventModel eventModel) { eventModels.add(eventModel); } - + /** {@inheritDoc} */ public EventProducer getEventProducerFor(Class clazz) { if (!EventProducer.class.isAssignableFrom(clazz)) { @@ -97,7 +97,7 @@ public class DefaultEventBroadcaster implements EventBroadcaster { } return producer; } - + private EventProducerModel getEventProducerModel(Class clazz) { for (int i = 0, c = eventModels.size(); i < c; i++) { EventModel eventModel = (EventModel)eventModels.get(i); @@ -108,7 +108,7 @@ public class DefaultEventBroadcaster implements EventBroadcaster { } 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. @@ -147,7 +147,7 @@ public class DefaultEventBroadcaster implements EventBroadcaster { } Event ev = new Event(args[0], eventID, methodModel.getSeverity(), params); broadcastEvent(ev); - + if (ev.getSeverity() == EventSeverity.FATAL) { EventExceptionManager.throwException(ev, methodModel.getExceptionClass()); @@ -156,5 +156,5 @@ public class DefaultEventBroadcaster implements EventBroadcaster { } }); } - + } diff --git a/src/java/org/apache/fop/events/Event.java b/src/java/org/apache/fop/events/Event.java index d3da1809e..e820db995 100644 --- a/src/java/org/apache/fop/events/Event.java +++ b/src/java/org/apache/fop/events/Event.java @@ -32,11 +32,11 @@ import org.apache.fop.events.model.EventSeverity; 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 @@ -50,7 +50,7 @@ public class Event extends EventObject { setSeverity(severity); this.params = params; } - + /** * Returns the event identifier. * @return the event identifier @@ -58,7 +58,7 @@ public class Event extends EventObject { public String getEventID() { return this.eventID; } - + /** * Returns the event group identifier. * @return the event group identifier (or null if there is no group identifier) @@ -71,7 +71,7 @@ public class Event extends EventObject { return null; } } - + /** * Returns the severity level. * @return the severity level @@ -79,7 +79,7 @@ public class Event extends EventObject { 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. @@ -101,7 +101,7 @@ public class Event extends EventObject { return null; } } - + /** * Returns an unmodifiable {@link java.util.Map} with all event parameters. * @return the parameter map @@ -109,7 +109,7 @@ public class Event extends EventObject { 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 @@ -117,13 +117,13 @@ public class Event extends EventObject { 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 @@ -137,7 +137,7 @@ public class Event extends EventObject { this.params.put(name, value); return this; } - + /** * Returns the accumulated parameter map. * @return the accumulated parameter map @@ -146,5 +146,5 @@ public class Event extends EventObject { return this.params; } } - + } diff --git a/src/java/org/apache/fop/events/EventBroadcaster.java b/src/java/org/apache/fop/events/EventBroadcaster.java index 6c8df7375..bd522d329 100644 --- a/src/java/org/apache/fop/events/EventBroadcaster.java +++ b/src/java/org/apache/fop/events/EventBroadcaster.java @@ -31,31 +31,31 @@ public interface EventBroadcaster { * @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 index 44b1ef7b1..f6a115450 100644 --- a/src/java/org/apache/fop/events/EventExceptionManager.java +++ b/src/java/org/apache/fop/events/EventExceptionManager.java @@ -30,7 +30,7 @@ import org.apache.xmlgraphics.util.Service; public class EventExceptionManager { private static final Map EXCEPTION_FACTORIES = new java.util.HashMap(); - + static { Iterator iter; iter = Service.providers(ExceptionFactory.class, true); @@ -39,7 +39,7 @@ public class EventExceptionManager { 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. @@ -61,20 +61,20 @@ public class EventExceptionManager { 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 diff --git a/src/java/org/apache/fop/events/EventFormatter.java b/src/java/org/apache/fop/events/EventFormatter.java index 56964039b..fc779eb18 100644 --- a/src/java/org/apache/fop/events/EventFormatter.java +++ b/src/java/org/apache/fop/events/EventFormatter.java @@ -40,16 +40,16 @@ import org.apache.fop.util.text.AdvancedMessageFormat.PartFactory; 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 @@ -74,7 +74,7 @@ public final class EventFormatter { } return format(event, bundle); } - + /** * Formats an event using a given locale. * @param event the event @@ -150,11 +150,11 @@ public final class EventFormatter { 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; } @@ -170,14 +170,14 @@ public final class EventFormatter { 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 { @@ -190,7 +190,7 @@ public final class EventFormatter { public String getFormat() { return "lookup"; } - + } } diff --git a/src/java/org/apache/fop/events/EventListener.java b/src/java/org/apache/fop/events/EventListener.java index cb2d8b965..4889d3299 100644 --- a/src/java/org/apache/fop/events/EventListener.java +++ b/src/java/org/apache/fop/events/EventListener.java @@ -33,5 +33,5 @@ public interface EventListener extends java.util.EventListener { * @param event the event */ void processEvent(Event event); - + } diff --git a/src/java/org/apache/fop/events/FOPEventListenerProxy.java b/src/java/org/apache/fop/events/FOPEventListenerProxy.java index d4c237844..d57ef1e15 100644 --- a/src/java/org/apache/fop/events/FOPEventListenerProxy.java +++ b/src/java/org/apache/fop/events/FOPEventListenerProxy.java @@ -29,29 +29,29 @@ import org.apache.fop.layoutmgr.BlockLevelEventProducer; * 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. + * 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 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)) { diff --git a/src/java/org/apache/fop/events/LoggingEventListener.java b/src/java/org/apache/fop/events/LoggingEventListener.java index 9ba8ed2df..03467303e 100644 --- a/src/java/org/apache/fop/events/LoggingEventListener.java +++ b/src/java/org/apache/fop/events/LoggingEventListener.java @@ -32,17 +32,17 @@ 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. @@ -51,7 +51,7 @@ public class LoggingEventListener implements EventListener { public LoggingEventListener(Log log) { this(log, true); } - + /** * Creates an instance logging to a given logger. * @param log the target logger @@ -61,7 +61,7 @@ public class LoggingEventListener implements EventListener { this.log = log; this.skipFatal = skipFatal; } - + /** * Returns the target logger for this instance. * @return the target logger @@ -69,7 +69,7 @@ public class LoggingEventListener implements EventListener { public Log getLog() { return this.log; } - + /** {@inheritDoc} */ public void processEvent(Event event) { String msg = EventFormatter.format(event); diff --git a/src/java/org/apache/fop/events/PropertyExceptionFactory.java b/src/java/org/apache/fop/events/PropertyExceptionFactory.java index 667c4a16e..753019b31 100644 --- a/src/java/org/apache/fop/events/PropertyExceptionFactory.java +++ b/src/java/org/apache/fop/events/PropertyExceptionFactory.java @@ -38,10 +38,10 @@ public class PropertyExceptionFactory implements ExceptionFactory { } 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 index 21da4f1d7..607d2fab1 100644 --- a/src/java/org/apache/fop/events/ResourceEventProducer.java +++ b/src/java/org/apache/fop/events/ResourceEventProducer.java @@ -38,7 +38,7 @@ public interface ResourceEventProducer extends EventProducer { * Provider class for the event producer. */ class Provider { - + /** * Returns an event producer. * @param broadcaster the event broadcaster to use @@ -59,7 +59,7 @@ public interface ResourceEventProducer extends EventProducer { * @event.severity ERROR */ void imageNotFound(Object source, String uri, FileNotFoundException fnfe, Locator loc); - + /** * Error while processing image. * @param source the event source @@ -69,7 +69,7 @@ public interface ResourceEventProducer extends EventProducer { * @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 @@ -105,7 +105,7 @@ public interface ResourceEventProducer extends EventProducer { * @event.severity ERROR */ void ifoNoIntrinsicSize(Object source, Locator loc); - + /** * Error processing foreign XML content. * @param source the event source @@ -124,7 +124,7 @@ public interface ResourceEventProducer extends EventProducer { * @event.severity ERROR */ void foreignXMLNoHandler(Object source, Document doc, String namespaceURI); - + /** * Cannot delete a temporary file. * @param source the event source @@ -132,5 +132,5 @@ public interface ResourceEventProducer extends EventProducer { * @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 index 06ce8dd25..7ec9d19b2 100644 --- a/src/java/org/apache/fop/events/UnsupportedOperationExceptionFactory.java +++ b/src/java/org/apache/fop/events/UnsupportedOperationExceptionFactory.java @@ -34,10 +34,10 @@ public class UnsupportedOperationExceptionFactory implements ExceptionFactory { 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 index 9dba84007..760c4ec58 100644 --- a/src/java/org/apache/fop/events/ValidationExceptionFactory.java +++ b/src/java/org/apache/fop/events/ValidationExceptionFactory.java @@ -41,11 +41,11 @@ public class ValidationExceptionFactory implements ExceptionFactory { } 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 index ee980f34e..fbb8b1550 100644 --- a/src/java/org/apache/fop/events/model/AbstractEventModelFactory.java +++ b/src/java/org/apache/fop/events/model/AbstractEventModelFactory.java @@ -45,17 +45,17 @@ public abstract class AbstractEventModelFactory implements EventModelFactory { if (in == null) { throw new MissingResourceException( "File " + resourceName + " not found", - DefaultEventBroadcaster.class.getName(), ""); + DefaultEventBroadcaster.class.getName(), ""); } try { return EventModelParser.parse(new StreamSource(in)); } catch (TransformerException e) { throw new MissingResourceException( "Error reading " + resourceName + ": " + e.getMessage(), - DefaultEventBroadcaster.class.getName(), ""); + DefaultEventBroadcaster.class.getName(), ""); } finally { IOUtils.closeQuietly(in); } } - + } diff --git a/src/java/org/apache/fop/events/model/EventModelFactory.java b/src/java/org/apache/fop/events/model/EventModelFactory.java index cd760501c..ea5b2cdbb 100644 --- a/src/java/org/apache/fop/events/model/EventModelFactory.java +++ b/src/java/org/apache/fop/events/model/EventModelFactory.java @@ -29,5 +29,5 @@ public interface EventModelFactory { * @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 index 600e495c5..ddb1bf663 100644 --- a/src/java/org/apache/fop/events/model/EventModelParser.java +++ b/src/java/org/apache/fop/events/model/EventModelParser.java @@ -45,7 +45,7 @@ public class EventModelParser { /** Logger instance */ protected static Log log = LogFactory.getLog(EventModelParser.class); - private static SAXTransformerFactory tFactory + private static SAXTransformerFactory tFactory = (SAXTransformerFactory)SAXTransformerFactory.newInstance(); /** @@ -54,11 +54,11 @@ public class EventModelParser { * @return the created event model structure * @throws TransformerException if an error occurs while parsing the XML file */ - public static EventModel parse(Source src) + 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)); diff --git a/src/java/org/apache/fop/events/model/EventSeverity.java b/src/java/org/apache/fop/events/model/EventSeverity.java index d37c53c1e..c0d886154 100644 --- a/src/java/org/apache/fop/events/model/EventSeverity.java +++ b/src/java/org/apache/fop/events/model/EventSeverity.java @@ -26,7 +26,7 @@ import java.io.Serializable; public final class EventSeverity implements Serializable { private static final long serialVersionUID = 4108175215810759243L; - + /** info level */ public static final EventSeverity INFO = new EventSeverity("INFO"); /** warning level */ @@ -35,7 +35,7 @@ public final class EventSeverity implements Serializable { public static final EventSeverity ERROR = new EventSeverity("ERROR"); /** fatal error */ public static final EventSeverity FATAL = new EventSeverity("FATAL"); - + private String name; /** @@ -50,7 +50,7 @@ public final class EventSeverity implements Serializable { public String getName() { return this.name; } - + /** * Returns the enumeration/singleton object based on its name. * @param name the name of the enumeration value @@ -69,14 +69,14 @@ public final class EventSeverity implements Serializable { 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/CharIterator.java b/src/java/org/apache/fop/fo/CharIterator.java index 1d6b312a7..68070da3f 100644 --- a/src/java/org/apache/fop/fo/CharIterator.java +++ b/src/java/org/apache/fop/fo/CharIterator.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.fo; import java.util.Iterator; diff --git a/src/java/org/apache/fop/fo/Constants.java b/src/java/org/apache/fop/fo/Constants.java index ae4c11229..91ff780bd 100644 --- a/src/java/org/apache/fop/fo/Constants.java +++ b/src/java/org/apache/fop/fo/Constants.java @@ -170,7 +170,7 @@ public interface Constants { /** FO element constant */ int FO_ROOT = 66; /** FO element constant - XSL 1.1 */ - int FO_SCALING_VALUE_CITATION = 67; + int FO_SCALING_VALUE_CITATION = 67; /** FO element constant */ int FO_SIMPLE_PAGE_MASTER = 68; /** FO element constant */ @@ -1166,9 +1166,9 @@ public interface Constants { /** Enumeration constant -- font shorthand */ int EN_STATUS_BAR = 185; /** Enumeration constant -- for page-position, XSL 1.1 */ - int EN_ONLY = 186; + int EN_ONLY = 186; /** Enumeration constant -- for instream-foreign-object and external-graphic, XSL 1.1 */ - int EN_SCALE_DOWN_TO_FIT = 187; + int EN_SCALE_DOWN_TO_FIT = 187; /** Enumeration constant -- for instream-foreign-object and external-graphic, XSL 1.1 */ int EN_SCALE_UP_TO_FIT = 188; /** Enumeration constant -- for fo:basic-link show-destination */ diff --git a/src/java/org/apache/fop/fo/ElementMapping.java b/src/java/org/apache/fop/fo/ElementMapping.java index 502fb07b8..9e9bb6c59 100644 --- a/src/java/org/apache/fop/fo/ElementMapping.java +++ b/src/java/org/apache/fop/fo/ElementMapping.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 @@ public abstract class ElementMapping { public String getNamespaceURI() { return namespaceURI; } - + /** * Returns the DOMImplementation used by this ElementMapping. The value returned may be null * for cases where no DOM is used to represent the element tree (XSL-FO, for example). This @@ -95,7 +95,7 @@ public abstract class ElementMapping { public String getStandardPrefix() { return null; } - + /** * Indicates whether a particular attribute of the namespace is a property, i.e. the attribute * value should be converted to a property value. @@ -105,7 +105,7 @@ public abstract class ElementMapping { public boolean isAttributeProperty(QName attributeName) { return false; } - + /** * Initializes the set of maker objects associated with this ElementMapping */ diff --git a/src/java/org/apache/fop/fo/ElementMappingRegistry.java b/src/java/org/apache/fop/fo/ElementMappingRegistry.java index abc4ec834..4a6904f73 100644 --- a/src/java/org/apache/fop/fo/ElementMappingRegistry.java +++ b/src/java/org/apache/fop/fo/ElementMappingRegistry.java @@ -43,7 +43,7 @@ public class ElementMappingRegistry { /** logging instance */ protected Log log = LogFactory.getLog(ElementMappingRegistry.class); - + /** * Table mapping element names to the makers of objects * representing formatting objects. @@ -64,7 +64,7 @@ public class ElementMappingRegistry { // Add standard element mappings setupDefaultMappings(); } - + /** * Sets all the element and property list mappings to their default values. */ @@ -127,7 +127,7 @@ public class ElementMappingRegistry { * @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. */ - public Maker findFOMaker(String namespaceURI, String localName, Locator locator) + public Maker findFOMaker(String namespaceURI, String localName, Locator locator) throws FOPException { Map table = (Map)fobjTable.get(namespaceURI); Maker fobjMaker = null; @@ -141,7 +141,7 @@ public class ElementMappingRegistry { if (fobjMaker == null) { if (namespaces.containsKey(namespaceURI.intern())) { - throw new FOPException(FONode.errorText(locator) + throw new FOPException(FONode.errorText(locator) + "No element mapping definition found for " + FONode.getNodeString(namespaceURI, localName), locator); } else { @@ -154,7 +154,7 @@ public class ElementMappingRegistry { /** * Tries to determine the DOMImplementation that is used to handled a particular namespace. * The method may return null for namespaces that don't result in a DOM. It is mostly used - * in namespaces occurring in foreign objects. + * in namespaces occurring in foreign objects. * @param namespaceURI the namespace URI * @return the handling DOMImplementation, or null if not applicable */ @@ -166,7 +166,7 @@ public class ElementMappingRegistry { return mapping.getDOMImplementation(); } } - + /** * Returns an ElementMapping class for a namespace URI if there is one. * @param namespaceURI the namespace URI @@ -176,7 +176,7 @@ public class ElementMappingRegistry { public ElementMapping getElementMapping(String namespaceURI) { return (ElementMapping)this.namespaces.get(namespaceURI); } - + /** * Indicates whether a namespace is known to FOP. * @param namespaceURI the namespace URI diff --git a/src/java/org/apache/fop/fo/FOElementMapping.java b/src/java/org/apache/fop/fo/FOElementMapping.java index facb1c304..0a7e40955 100644 --- a/src/java/org/apache/fop/fo/FOElementMapping.java +++ b/src/java/org/apache/fop/fo/FOElementMapping.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.util.QName; * Element mapping class for all XSL-FO elements. */ public class FOElementMapping extends ElementMapping { - + /** The XSL-FO namespace URI */ public static final String URI = "http://www.w3.org/1999/XSL/Format"; @@ -143,12 +143,12 @@ public class FOElementMapping extends ElementMapping { public String getStandardPrefix() { return "fo"; } - + /** {@inheritDoc} */ public boolean isAttributeProperty(QName attributeName) { return true; //All XSL-FO attributes are to be converted to properties. } - + static class RootMaker extends ElementMapping.Maker { public FONode make(FONode parent) { return new org.apache.fop.fo.pagination.Root(parent); @@ -364,7 +364,7 @@ public class FOElementMapping extends ElementMapping { return new org.apache.fop.fo.flow.PageNumberCitationLast(parent); } } - + static class TableAndCaptionMaker extends ElementMapping.Maker { public FONode make(FONode parent) { return new org.apache.fop.fo.flow.table.TableAndCaption(parent); diff --git a/src/java/org/apache/fop/fo/FOEventHandler.java b/src/java/org/apache/fop/fo/FOEventHandler.java index 90856d57a..238a4ced6 100644 --- a/src/java/org/apache/fop/fo/FOEventHandler.java +++ b/src/java/org/apache/fop/fo/FOEventHandler.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,13 +63,13 @@ import org.apache.fop.fonts.FontInfo; * as our MIF and RTF output targets. */ public abstract class FOEventHandler { - - /** + + /** * The FOUserAgent for this process */ protected FOUserAgent foUserAgent; - /** + /** * The Font information relevant for this document */ protected FontInfo fontInfo; @@ -142,37 +142,37 @@ public abstract class FOEventHandler { } /** - * + * * @param pageCite PageNumberCitation that is starting. */ public void startPageNumberCitation(PageNumberCitation pageCite) { } /** - * + * * @param pageCite PageNumberCitation that is ending. */ public void endPageNumberCitation(PageNumberCitation pageCite) { } /** - * + * * @param pageLast PageNumberCitationLast that is starting. */ public void startPageNumberCitationLast(PageNumberCitationLast pageLast) { } /** - * + * * @param pageLast PageNumberCitationLast that is ending. */ public void endPageNumberCitationLast(PageNumberCitationLast pageLast) { } /** - * This method is called to indicate the start of a new fo:flow + * This method is called to indicate the start of a new fo:flow * or fo:static-content. - * This method also handles fo:static-content tags, because the + * This method also handles fo:static-content tags, because the * StaticContent class is derived from the Flow class. * * @param fl Flow that is starting. @@ -447,7 +447,7 @@ public abstract class FOEventHandler { */ public void startFootnote(Footnote footnote) { } - + /** * Process the ending of a footnote. * @param footnote Footnote that is ending @@ -461,7 +461,7 @@ public abstract class FOEventHandler { */ public void startFootnoteBody(FootnoteBody body) { } - + /** * Process the ending of a footnote body. * @param body FootnoteBody that is ending diff --git a/src/java/org/apache/fop/fo/FONode.java b/src/java/org/apache/fop/fo/FONode.java index 87d3bfa3c..087bcf96c 100644 --- a/src/java/org/apache/fop/fo/FONode.java +++ b/src/java/org/apache/fop/fo/FONode.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. @@ -163,7 +163,7 @@ public abstract class FONode implements Cloneable { public FOTreeBuilderContext getBuilderContext() { return parent.getBuilderContext(); } - + /** * Indicates whether this node is a child of an fo:marker. * @return true if this node is a child of an fo:marker @@ -338,7 +338,7 @@ public abstract class FONode implements Cloneable { * endXXX() events in the {@link FOEventHandler}. * The method is called by the default {@link #endOfNode()} * implementation. - * + * * @throws FOPException in case there was an error */ public void finalizeNode() throws FOPException { diff --git a/src/java/org/apache/fop/fo/FOPropertyMapping.java b/src/java/org/apache/fop/fo/FOPropertyMapping.java index 60317cf0d..e890b9e24 100644 --- a/src/java/org/apache/fop/fo/FOPropertyMapping.java +++ b/src/java/org/apache/fop/fo/FOPropertyMapping.java @@ -101,7 +101,7 @@ public final class FOPropertyMapping implements Constants { * are used be the actual makers as a parameter to .useGeneric(...). */ private void createGenerics() { - + PropertyMaker sub; genericColor = new ColorProperty.Maker(0); @@ -277,13 +277,13 @@ public final class FOPropertyMapping implements Constants { * @return the maker array. */ public static PropertyMaker[] getGenericMappings() { - + if (s_generics == null) { /* this method was never called before */ s_generics = new PropertyMaker[PROPERTY_COUNT + 1]; FOPropertyMapping gp = new FOPropertyMapping(); - - /* Create the shorthand first. They are + + /* Create the shorthand first. They are * referenced by the real properties. */ gp.createShorthandProperties(); @@ -313,7 +313,7 @@ public final class FOPropertyMapping implements Constants { gp.createTableProperties(); gp.createWritingModeProperties(); gp.createMiscProperties(); - + // Hardcode the subproperties. addSubpropMakerName("length", CP_LENGTH); addSubpropMakerName("conditionality", CP_CONDITIONALITY); @@ -1848,7 +1848,7 @@ public final class FOPropertyMapping implements Constants { m.setInherited(true); m.setDefault("2"); addPropertyMaker("widows", m); - + // fox:widow-content-limit m = new LengthProperty.Maker(PR_X_WIDOW_CONTENT_LIMIT); m.setInherited(true); @@ -2773,7 +2773,7 @@ public final class FOPropertyMapping implements Constants { m.setDefault("normal"); m.setDatatypeParser(new WhiteSpaceShorthandParser()); addPropertyMaker("white-space", m); - + // xml:lang m = new StringProperty.Maker(PR_XML_LANG); m.setInherited(true); diff --git a/src/java/org/apache/fop/fo/FOText.java b/src/java/org/apache/fop/fo/FOText.java index 217997ace..eb0627b4b 100644 --- a/src/java/org/apache/fop/fo/FOText.java +++ b/src/java/org/apache/fop/fo/FOText.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/fo/FOTreeBuilder.java b/src/java/org/apache/fop/fo/FOTreeBuilder.java index 6682ff703..762cd0d46 100644 --- a/src/java/org/apache/fop/fo/FOTreeBuilder.java +++ b/src/java/org/apache/fop/fo/FOTreeBuilder.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,43 +63,43 @@ public class FOTreeBuilder extends DefaultHandler { /** Main DefaultHandler that handles the FO namespace. */ protected MainFOHandler mainFOHandler; - + /** Current delegate ContentHandler to receive the SAX events */ protected ContentHandler delegate; /** Provides information used during tree building stage. */ private FOTreeBuilderContext builderContext; - + /** The object that handles formatting and rendering to a stream */ private FOEventHandler foEventHandler; /** The SAX locator object managing the line and column counters */ - private Locator locator; - + private Locator locator; + /** The user agent for this processing run. */ private FOUserAgent userAgent; - + private boolean used = false; private boolean empty = true; - + private int depth; - + /** * FOTreeBuilder constructor - * + * * @param outputFormat the MIME type of the output format to use (ex. "application/pdf"). * @param foUserAgent the {@link FOUserAgent} in effect for this process * @param stream the OutputStream to direct the results to * @throws FOPException if the FOTreeBuilder cannot be properly created */ public FOTreeBuilder( - String outputFormat, + String outputFormat, FOUserAgent foUserAgent, - OutputStream stream) + OutputStream stream) throws FOPException { this.userAgent = foUserAgent; - this.elementMappingRegistry = userAgent.getFactory().getElementMappingRegistry(); + this.elementMappingRegistry = userAgent.getFactory().getElementMappingRegistry(); //This creates either an AreaTreeHandler and ultimately a Renderer, or //one of the RTF-, MIF- etc. Handlers. foEventHandler = foUserAgent.getRendererFactory().createFOEventHandler( @@ -116,16 +116,16 @@ public class FOTreeBuilder extends DefaultHandler { public void setDocumentLocator(Locator locator) { this.locator = locator; } - - /** + + /** * @return a {@link Locator} instance if it is available and not disabled */ protected Locator getEffectiveLocator() { return (userAgent.isLocatorEnabled() ? this.locator : null); } - + /** {@inheritDoc} */ - public void characters(char[] data, int start, int length) + public void characters(char[] data, int start, int length) throws SAXException { delegate.characters(data, start, length); } @@ -136,7 +136,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 @@ -204,7 +204,7 @@ public class FOTreeBuilder extends DefaultHandler { /** * Provides access to the underlying {@link FOEventHandler} object. - * + * * @return the FOEventHandler object */ public FOEventHandler getEventHandler() { @@ -215,30 +215,30 @@ public class FOTreeBuilder extends DefaultHandler { * Returns the results of the rendering process. Information includes * the total number of pages generated and the number of pages per * page-sequence. - * + * * @return the results of the rendering process. */ public FormattingResults getResults() { if (getEventHandler() instanceof AreaTreeHandler) { return ((AreaTreeHandler) getEventHandler()).getResults(); } else { - //No formatting results available for output formats no + //No formatting results available for output formats no //involving the layout engine. return null; } } - + /** * Main DefaultHandler implementation which builds the FO tree. */ private class MainFOHandler extends DefaultHandler { - + /** Current formatting object being handled */ protected FONode currentFObj = null; /** Current propertyList for the node being handled */ protected PropertyList currentPropertyList; - + /** Current marker nesting-depth */ private int nestedMarkerDepth = 0; @@ -253,7 +253,7 @@ public class FOTreeBuilder extends DefaultHandler { // Check to ensure first node encountered is an fo:root if (rootFObj == null) { empty = false; - if (!namespaceURI.equals(FOElementMapping.URI) + if (!namespaceURI.equals(FOElementMapping.URI) || !localName.equals("root")) { FOValidationEventProducer eventProducer = FOValidationEventProducer.Provider.get( @@ -267,7 +267,7 @@ public class FOTreeBuilder extends DefaultHandler { currentFObj.validateChildNode(locator, namespaceURI, localName); } } - + ElementMapping.Maker fobjMaker = findFOMaker(namespaceURI, localName); try { @@ -279,7 +279,7 @@ public class FOTreeBuilder extends DefaultHandler { } propertyList = foNode.createPropertyList( currentPropertyList, foEventHandler); - foNode.processNode(localName, getEffectiveLocator(), + foNode.processNode(localName, getEffectiveLocator(), attlist, propertyList); if (foNode.getNameId() == Constants.FO_MARKER) { if (builderContext.inMarker()) { @@ -295,19 +295,19 @@ public class FOTreeBuilder extends DefaultHandler { ContentHandlerFactory chFactory = foNode.getContentHandlerFactory(); if (chFactory != null) { ContentHandler subHandler = chFactory.createContentHandler(); - if (subHandler instanceof ObjectSource + if (subHandler instanceof ObjectSource && foNode instanceof ObjectBuiltListener) { ((ObjectSource) subHandler).setObjectBuiltListener( (ObjectBuiltListener) foNode); } - + subHandler.startDocument(); - subHandler.startElement(namespaceURI, localName, + subHandler.startElement(namespaceURI, localName, rawName, attlist); depth = 1; delegate = subHandler; } - + if (currentFObj != null) { currentFObj.addChildNode(foNode); } @@ -330,28 +330,28 @@ public class FOTreeBuilder extends DefaultHandler { throws SAXException { if (currentFObj == null) { throw new SAXException( - "endElement() called for " + rawName + "endElement() called for " + rawName + " where there is no current element."); - } else if (!currentFObj.getLocalName().equals(localName) + } else if (!currentFObj.getLocalName().equals(localName) || !currentFObj.getNamespaceURI().equals(uri)) { - throw new SAXException("Mismatch: " + currentFObj.getLocalName() - + " (" + currentFObj.getNamespaceURI() + throw new SAXException("Mismatch: " + currentFObj.getLocalName() + + " (" + currentFObj.getNamespaceURI() + ") vs. " + localName + " (" + uri + ")"); } - + // fo:characters can potentially be removed during // white-space handling. // Do not notify the FOEventHandler. if (currentFObj.getNameId() != Constants.FO_CHARACTER) { currentFObj.endOfNode(); } - + if (currentPropertyList != null && currentPropertyList.getFObj() == currentFObj && !builderContext.inMarker()) { currentPropertyList = currentPropertyList.getParentPropertyList(); } - + if (currentFObj.getNameId() == Constants.FO_MARKER) { if (nestedMarkerDepth == 0) { builderContext.switchMarkerContext(false); @@ -359,19 +359,19 @@ public class FOTreeBuilder extends DefaultHandler { nestedMarkerDepth--; } } - + if (currentFObj.getParent() == null) { log.debug("endElement for top-level " + currentFObj.getName()); } - + currentFObj = currentFObj.getParent(); } /** {@inheritDoc} */ - public void characters(char[] data, int start, int length) + public void characters(char[] data, int start, int length) throws FOPException { if (currentFObj != null) { - currentFObj.addCharacters(data, start, length, + currentFObj.addCharacters(data, start, length, currentPropertyList, getEffectiveLocator()); } } @@ -380,10 +380,10 @@ public class FOTreeBuilder extends DefaultHandler { 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 diff --git a/src/java/org/apache/fop/fo/FOTreeBuilderContext.java b/src/java/org/apache/fop/fo/FOTreeBuilderContext.java index 0cbdd7797..870b2b599 100644 --- a/src/java/org/apache/fop/fo/FOTreeBuilderContext.java +++ b/src/java/org/apache/fop/fo/FOTreeBuilderContext.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 class FOTreeBuilderContext { * This is used so we know if the FO tree contains duplicates. */ private Set idReferences = new HashSet(); - + /** * The property list maker. */ @@ -42,12 +42,12 @@ public class FOTreeBuilderContext { * The XMLWhitespaceHandler for this tree */ protected XMLWhiteSpaceHandler whiteSpaceHandler = new XMLWhiteSpaceHandler(); - + /** * Indicates whether processing descendants of a marker */ private boolean inMarker = false; - + /** * Returns the set of ID references. * @return the ID references @@ -58,22 +58,22 @@ public class FOTreeBuilderContext { /** * Return the propertyListMaker. - * + * * @return the currently active {@link PropertyListMaker} */ public PropertyListMaker getPropertyListMaker() { return propertyListMaker; } - + /** * Set a new propertyListMaker. - * + * * @param propertyListMaker the new {@link PropertyListMaker} to use */ public void setPropertyListMaker(PropertyListMaker propertyListMaker) { this.propertyListMaker = propertyListMaker; } - + /** * Return the XMLWhiteSpaceHandler * @return the whiteSpaceHandler @@ -86,22 +86,22 @@ public class FOTreeBuilderContext { * Switch to or from marker context * (used by FOTreeBuilder when processing * a marker) - * - * @param inMarker true if a marker is being processed; + * + * @param inMarker true if a marker is being processed; * false otherwise * */ protected void switchMarkerContext(boolean inMarker) { this.inMarker = inMarker; } - + /** * Check whether in marker context - * + * * @return true if a marker is being processed */ protected boolean inMarker() { return this.inMarker; } - + } diff --git a/src/java/org/apache/fop/fo/FOValidationEventProducer.java b/src/java/org/apache/fop/fo/FOValidationEventProducer.java index 61bd68340..889bf706a 100644 --- a/src/java/org/apache/fop/fo/FOValidationEventProducer.java +++ b/src/java/org/apache/fop/fo/FOValidationEventProducer.java @@ -37,7 +37,7 @@ public interface FOValidationEventProducer extends EventProducer { * Provider class for the event producer. */ class Provider { - + /** * Returns an event producer. * @param broadcaster the event broadcaster to use @@ -55,12 +55,12 @@ public interface FOValidationEventProducer extends EventProducer { * @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 + * @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 @@ -74,7 +74,7 @@ public interface FOValidationEventProducer extends EventProducer { 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 @@ -112,7 +112,7 @@ public interface FOValidationEventProducer extends EventProducer { */ 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 @@ -334,7 +334,7 @@ public interface FOValidationEventProducer extends EventProducer { */ void invalidFORoot(Object source, String elementName, Locator loc) throws ValidationException; - + /** * No FO document was found. * @param source the event source @@ -342,7 +342,7 @@ public interface FOValidationEventProducer extends EventProducer { * @event.severity FATAL */ void emptyDocument(Object source) throws ValidationException; - + /** * An unknown/unsupported formatting object has been encountered. * @param source the event source @@ -353,5 +353,5 @@ public interface FOValidationEventProducer extends EventProducer { */ 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 20573fa7a..e0624df69 100644 --- a/src/java/org/apache/fop/fo/FObj.java +++ b/src/java/org/apache/fop/fo/FObj.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,22 +42,22 @@ import org.apache.fop.fo.properties.PropertyMaker; * All standard formatting object classes extend this class. */ public abstract class FObj extends FONode implements Constants { - + /** the list of property makers */ private static final PropertyMaker[] propertyListTable = FOPropertyMapping.getGenericMappings(); - - /** + + /** * pointer to the descendant subtree */ protected FONode firstChild; - + /** The list of extension attachments, null if none */ private List extensionAttachments = null; - + /** The map of foreign attributes, null if none */ private Map foreignAttributes = null; - + /** Used to indicate if this FO is either an Out Of Line FO (see rec) * or a descendant of one. Used during FO validation. */ @@ -65,7 +65,7 @@ public abstract class FObj extends FONode implements Constants { /** Markers added to this element. */ private Map markers = null; - + // The value of properties relevant for all fo objects private String id = null; // End of property values @@ -77,7 +77,7 @@ public abstract class FObj extends FONode implements Constants { */ public FObj(FONode parent) { super(parent); - + // determine if isOutOfLineFODescendant should be set if (parent != null && parent instanceof FObj) { if (((FObj) parent).getIsOutOfLineFODescendant()) { @@ -101,7 +101,7 @@ public abstract class FObj extends FONode implements Constants { } return fobj; } - + /** * Returns the PropertyMaker for a given property ID. * @param propId the property ID @@ -112,8 +112,8 @@ public abstract class FObj extends FONode implements Constants { } /** {@inheritDoc} */ - public void processNode(String elementName, Locator locator, - Attributes attlist, PropertyList pList) + public void processNode(String elementName, Locator locator, + Attributes attlist, PropertyList pList) throws FOPException { setLocator(locator); pList.addAttributesToList(attlist); @@ -125,10 +125,10 @@ public abstract class FObj extends FONode implements Constants { } /** - * Create a default property list for this element. + * Create a default property list for this element. * {@inheritDoc} */ - protected PropertyList createPropertyList(PropertyList parent, + protected PropertyList createPropertyList(PropertyList parent, FOEventHandler foEventHandler) throws FOPException { return getBuilderContext().getPropertyListMaker().make(this, parent); } @@ -158,7 +158,7 @@ public abstract class FObj extends FONode implements Constants { * Setup the id for this formatting object. * Most formatting objects can have an id that can be referenced. * This methods checks that the id isn't already used by another FO - * + * * @param id the id to check * @throws ValidationException if the ID is already defined elsewhere * (strict validation only) @@ -186,11 +186,11 @@ public abstract class FObj extends FONode implements Constants { protected void addChildNode(FONode child) throws FOPException { if (child.getNameId() == FO_MARKER) { addMarker((Marker) child); - } else { + } else { ExtensionAttachment attachment = child.getExtensionAttachment(); if (attachment != null) { - /* This removes the element from the normal children, - * so no layout manager is being created for them + /* This removes the element from the normal children, + * so no layout manager is being created for them * as they are only additional information. */ addExtensionAttachment(attachment); @@ -215,11 +215,11 @@ public abstract class FObj extends FONode implements Constants { * @param parent the (cloned) parent node * @throws FOPException when the child could not be added to the parent */ - protected static void addChildTo(FONode child, FObj parent) + protected static void addChildTo(FONode child, FObj parent) throws FOPException { parent.addChildNode(child); } - + /** {@inheritDoc} */ public void removeChild(FONode child) { FONode nextChild = null; @@ -239,7 +239,7 @@ public abstract class FObj extends FONode implements Constants { } } } - + /** * Find the nearest parent, grandparent, etc. FONode that is also an FObj * @return FObj the nearest ancestor FONode that is an FObj @@ -276,7 +276,7 @@ public abstract class FObj extends FONode implements Constants { 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 @@ -307,7 +307,7 @@ public abstract class FObj extends FONode implements Constants { /** * Notifies a FObj that one of it's children is removed. - * This method is subclassed by Block to clear the + * This method is subclassed by Block to clear the * firstInlineChild variable in case it doesn't generate * any areas (see addMarker()). * @param node the node that was removed @@ -315,7 +315,7 @@ public abstract class FObj extends FONode implements Constants { void notifyChildRemoval(FONode node) { //nop } - + /** * Add the marker to this formatting object. * If this object can contain markers it checks that the marker @@ -392,7 +392,7 @@ public abstract class FObj extends FONode implements Constants { return null; } } - + /** {@inheritDoc} */ protected String gatherContextInfo() { if (getLocator() != null) { @@ -422,11 +422,11 @@ public abstract class FObj extends FONode implements Constants { * incoming node is a member of the "%block;" parameter entity * as defined in Sect. 6.2 of the XSL 1.0 & 1.1 Recommendations * @param nsURI namespace URI of incoming node - * @param lName local name (i.e., no prefix) of incoming node + * @param lName local name (i.e., no prefix) of incoming node * @return true if a member, false if not */ protected boolean isBlockItem(String nsURI, String lName) { - return (FO_URI.equals(nsURI) + return (FO_URI.equals(nsURI) && ("block".equals(lName) || "table".equals(lName) || "table-and-caption".equals(lName) @@ -441,11 +441,11 @@ public abstract class FObj extends FONode implements Constants { * incoming node is a member of the "%inline;" parameter entity * as defined in Sect. 6.2 of the XSL 1.0 & 1.1 Recommendations * @param nsURI namespace URI of incoming node - * @param lName local name (i.e., no prefix) of incoming node + * @param lName local name (i.e., no prefix) of incoming node * @return true if a member, false if not */ protected boolean isInlineItem(String nsURI, String lName) { - return (FO_URI.equals(nsURI) + return (FO_URI.equals(nsURI) && ("bidi-override".equals(lName) || "character".equals(lName) || "external-graphic".equals(lName) @@ -470,7 +470,7 @@ public abstract class FObj extends FONode implements Constants { * incoming node is a member of the "%block;" parameter entity * or "%inline;" parameter entity * @param nsURI namespace URI of incoming node - * @param lName local name (i.e., no prefix) of incoming node + * @param lName local name (i.e., no prefix) of incoming node * @return true if a member, false if not */ protected boolean isBlockOrInlineItem(String nsURI, String lName) { @@ -482,11 +482,11 @@ public abstract class FObj extends FONode implements Constants { * incoming node is a member of the neutral item list * as defined in Sect. 6.2 of the XSL 1.0 & 1.1 Recommendations * @param nsURI namespace URI of incoming node - * @param lName local name (i.e., no prefix) of incoming node + * @param lName local name (i.e., no prefix) of incoming node * @return true if a member, false if not */ boolean isNeutralItem(String nsURI, String lName) { - return (FO_URI.equals(nsURI) + return (FO_URI.equals(nsURI) && ("multi-switch".equals(lName) || "multi-properties".equals(lName) || "wrapper".equals(lName) @@ -494,12 +494,12 @@ public abstract class FObj extends FONode implements Constants { || "retrieve-marker".equals(lName) || "retrieve-table-marker".equals(lName))); } - + /** * Convenience method for validity checking. Checks if the * current node has an ancestor of a given name. * @param ancestorID ID of node name to check for (e.g., FO_ROOT) - * @return number of levels above FO where ancestor exists, + * @return number of levels above FO where ancestor exists, * -1 if not found */ protected int findAncestor(int ancestorID) { @@ -514,19 +514,19 @@ public abstract class FObj extends FONode implements Constants { } return -1; } - + /** * Clears the list of child nodes. */ public void clearChildNodes() { this.firstChild = null; } - + /** @return the "id" property. */ public String getId() { return id; } - + /** @return whether this object has an id set */ public boolean hasId() { return id != null && id.length() > 0; @@ -543,9 +543,9 @@ public abstract class FObj extends FONode implements Constants { } /** - * Add a new extension attachment to this FObj. + * Add a new extension attachment to this FObj. * (see org.apache.fop.fo.FONode for details) - * + * * @param attachment the attachment to add. */ void addExtensionAttachment(ExtensionAttachment attachment) { @@ -557,13 +557,13 @@ public abstract class FObj extends FONode implements Constants { extensionAttachments = new java.util.ArrayList(); } if (log.isDebugEnabled()) { - log.debug("ExtensionAttachment of category " - + attachment.getCategory() + " added to " + log.debug("ExtensionAttachment of category " + + attachment.getCategory() + " added to " + getName() + ": " + attachment); } extensionAttachments.add(attachment); } - + /** @return the extension attachments of this FObj. */ public List getExtensionAttachments() { if (extensionAttachments == null) { @@ -584,7 +584,7 @@ public abstract class FObj extends FONode implements Constants { * @param value the attribute value */ public void addForeignAttribute(QName attributeName, String value) { - /* TODO: Handle this over FOP's property mechanism so we can use + /* TODO: Handle this over FOP's property mechanism so we can use * inheritance. */ if (attributeName == null) { @@ -595,7 +595,7 @@ public abstract class FObj extends FONode implements Constants { } foreignAttributes.put(attributeName, value); } - + /** @return the map of foreign attributes */ public Map getForeignAttributes() { if (foreignAttributes == null) { @@ -604,7 +604,7 @@ public abstract class FObj extends FONode implements Constants { return foreignAttributes; } } - + /** {@inheritDoc} */ public String toString() { return (super.toString() + "[@id=" + this.id + "]"); @@ -612,28 +612,28 @@ public abstract class FObj extends FONode implements Constants { /** Basic {@link FONodeIterator} implementation */ public class FObjIterator implements FONodeIterator { - + private static final int F_NONE_ALLOWED = 0; private static final int F_SET_ALLOWED = 1; private static final int F_REMOVE_ALLOWED = 2; - + private FONode currentNode; private final FObj parentNode; private int currentIndex; private int flags = F_NONE_ALLOWED; - + FObjIterator(FObj parent) { this.parentNode = parent; this.currentNode = parent.firstChild; this.currentIndex = 0; this.flags = F_NONE_ALLOWED; } - + /** {@inheritDoc} */ public FObj parentNode() { return parentNode; } - + /** {@inheritDoc} */ public Object next() { if (currentNode != null) { @@ -665,7 +665,7 @@ public abstract class FObj extends FONode implements Constants { throw new NoSuchElementException(); } } - + /** {@inheritDoc} */ public void set(Object o) { if ((flags & F_SET_ALLOWED) == F_SET_ALLOWED) { @@ -683,7 +683,7 @@ public abstract class FObj extends FONode implements Constants { throw new IllegalStateException(); } } - + /** {@inheritDoc} */ public void add(Object o) { FONode newNode = (FONode) o; @@ -718,7 +718,7 @@ public abstract class FObj extends FONode implements Constants { || (currentNode.siblings != null && currentNode.siblings[0] != null); } - + /** {@inheritDoc} */ public int nextIndex() { return currentIndex + 1; @@ -759,19 +759,19 @@ public abstract class FObj extends FONode implements Constants { } return currentNode; } - + /** {@inheritDoc} */ public FONode firstNode() { currentNode = parentNode.firstChild; currentIndex = 0; return currentNode; } - + /** {@inheritDoc} */ public FONode nextNode() { return (FONode) next(); } - + /** {@inheritDoc} */ public FONode previousNode() { return (FONode) previous(); diff --git a/src/java/org/apache/fop/fo/FObjMixed.java b/src/java/org/apache/fop/fo/FObjMixed.java index 068c2d635..64faa3253 100644 --- a/src/java/org/apache/fop/fo/FObjMixed.java +++ b/src/java/org/apache/fop/fo/FObjMixed.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. @@ -71,7 +71,7 @@ public abstract class FObjMixed extends FObj { // send character[s]() events to the FOEventHandler sendCharacters(); } - + } /** @@ -180,10 +180,10 @@ public abstract class FObjMixed extends FObj { /** * Returns a {@link CharIterator} over this FO's character content - * + * * @return iterator for this object */ public CharIterator charIterator() { return new RecursiveCharIterator(this); - } + } } \ No newline at end of file diff --git a/src/java/org/apache/fop/fo/GraphicsProperties.java b/src/java/org/apache/fop/fo/GraphicsProperties.java index 5cee68679..a22d59c24 100644 --- a/src/java/org/apache/fop/fo/GraphicsProperties.java +++ b/src/java/org/apache/fop/fo/GraphicsProperties.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. @@ -47,7 +47,7 @@ public interface GraphicsProperties { * @return the "width" property. */ Length getWidth(); - + /** * @return the "content-height" property. */ diff --git a/src/java/org/apache/fop/fo/InlineCharIterator.java b/src/java/org/apache/fop/fo/InlineCharIterator.java index 8a375097e..f71753dde 100644 --- a/src/java/org/apache/fop/fo/InlineCharIterator.java +++ b/src/java/org/apache/fop/fo/InlineCharIterator.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/fo/NullCharIterator.java b/src/java/org/apache/fop/fo/NullCharIterator.java index bb98b4a52..2b2a2a9a0 100644 --- a/src/java/org/apache/fop/fo/NullCharIterator.java +++ b/src/java/org/apache/fop/fo/NullCharIterator.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 java.util.NoSuchElementException; public class NullCharIterator extends CharIterator { private static CharIterator instance; - + public static CharIterator getInstance() { if (instance == null) { instance = new NullCharIterator(); diff --git a/src/java/org/apache/fop/fo/OneCharIterator.java b/src/java/org/apache/fop/fo/OneCharIterator.java index 1d96320c1..e2c7275e8 100644 --- a/src/java/org/apache/fop/fo/OneCharIterator.java +++ b/src/java/org/apache/fop/fo/OneCharIterator.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/fo/PropertyList.java b/src/java/org/apache/fop/fo/PropertyList.java index e3e9f9f83..13f983841 100644 --- a/src/java/org/apache/fop/fo/PropertyList.java +++ b/src/java/org/apache/fop/fo/PropertyList.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. @@ -149,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 if there is a problem evaluating the property + * @throws PropertyException if there is a problem evaluating the property */ public Property get(int propId) throws PropertyException { return get(propId, true, true); @@ -161,11 +161,11 @@ public abstract class PropertyList { * inheritable, to return the inherited value. If all else fails, it returns * the default value. * @param propId the property's id - * @param bTryInherit true for inherited properties, or when the inherited + * @param bTryInherit true for inherited properties, or when the inherited * value is needed * @param bTryDefault true when the default value may be used as a last resort * @return the property - * @throws PropertyException if there is a problem evaluating the property + * @throws PropertyException if there is a problem evaluating the property */ public Property get(int propId, boolean bTryInherit, boolean bTryDefault) throws PropertyException { @@ -189,7 +189,7 @@ public abstract class PropertyList { public Property getNearestSpecified(int propId) throws PropertyException { Property p = null; PropertyList pList = parentPropertyList; - + while (pList != null) { p = pList.getExplicit(propId); if (p != null) { @@ -198,8 +198,8 @@ public abstract class PropertyList { pList = pList.parentPropertyList; } } - - // If no explicit value found on any of the ancestor-nodes, + + // If no explicit value found on any of the ancestor-nodes, // return initial (default) value. return makeProperty(propId); } @@ -238,7 +238,7 @@ public abstract class PropertyList { } /** - * Return the "writing-mode" property value. + * Return the "writing-mode" property value. * @return the "writing-mode" property value. */ public int getWritingMode() { @@ -266,34 +266,34 @@ public abstract class PropertyList { /** * Adds the attributes, passed in by the parser to the PropertyList - * + * * @param attributes Collection of attributes passed to us from the parser. * @throws ValidationException if there is an attribute that does not * map to a property id (strict validation only) */ - public void addAttributesToList(Attributes attributes) + public void addAttributesToList(Attributes attributes) throws ValidationException { /* - * If column-number/number-columns-spanned are specified, then we - * need them before all others (possible from-table-column() on any + * If column-number/number-columns-spanned are specified, then we + * need them before all others (possible from-table-column() on any * other property further in the list... */ String attributeName = "column-number"; String attributeValue = attributes.getValue(attributeName); - convertAttributeToProperty(attributes, attributeName, + convertAttributeToProperty(attributes, attributeName, attributeValue); attributeName = "number-columns-spanned"; attributeValue = attributes.getValue(attributeName); - convertAttributeToProperty(attributes, attributeName, + convertAttributeToProperty(attributes, attributeName, attributeValue); - + /* * If font-size is set on this FO, must set it first, since * other attributes specified in terms of "ems" depend on it. */ attributeName = "font"; attributeValue = attributes.getValue(attributeName); - convertAttributeToProperty(attributes, attributeName, + convertAttributeToProperty(attributes, attributeName, attributeValue); if (attributeValue == null) { /* @@ -302,19 +302,19 @@ public abstract class PropertyList { */ attributeName = "font-size"; attributeValue = attributes.getValue(attributeName); - convertAttributeToProperty(attributes, attributeName, + convertAttributeToProperty(attributes, attributeName, attributeValue); } - + String attributeNS; - FopFactory factory = getFObj().getUserAgent().getFactory(); + FopFactory factory = getFObj().getUserAgent().getFactory(); for (int i = 0; i < attributes.getLength(); i++) { /* convert all attributes with the same namespace as the fo element * the "xml:lang" property is a special case */ attributeNS = attributes.getURI(i); attributeName = attributes.getQName(i); attributeValue = attributes.getValue(i); - if (attributeNS == null || attributeNS.length() == 0 + if (attributeNS == null || attributeNS.length() == 0 || "xml:lang".equals(attributeName)) { convertAttributeToProperty(attributes, attributeName, attributeValue); } else if (!factory.isNamespaceIgnored(attributeNS)) { @@ -322,10 +322,10 @@ public abstract class PropertyList { attributeNS); QName attr = new QName(attributeNS, attributeName); if (mapping != null) { - if (mapping.isAttributeProperty(attr) + if (mapping.isAttributeProperty(attr) && mapping.getStandardPrefix() != null) { - convertAttributeToProperty(attributes, - mapping.getStandardPrefix() + ":" + attr.getLocalName(), + convertAttributeToProperty(attributes, + mapping.getStandardPrefix() + ":" + attr.getLocalName(), attributeValue); } else { getFObj().addForeignAttribute(attr, attributeValue); @@ -336,7 +336,7 @@ public abstract class PropertyList { } } } - + /** * Validates a property name. * @param propertyName the property name to check @@ -360,34 +360,34 @@ public abstract class PropertyList { * @param attributes Collection of attributes * @param attributeName Attribute name to convert * @param attributeValue Attribute value to assign to property - * @throws ValidationException in case the property name is invalid + * @throws ValidationException in case the property name is invalid * for the FO namespace */ private void convertAttributeToProperty(Attributes attributes, String attributeName, - String attributeValue) + String attributeValue) throws ValidationException { - + if (attributeValue != null) { if (attributeName.startsWith("xmlns:")) { //Ignore namespace declarations return; } - + /* 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 + + if (propId == -1 || (subpropId == -1 && subPropertyName != null)) { handleInvalidProperty(new QName(null, attributeName)); } FObj parentFO = fobj.findNearestAncestorFObj(); - + PropertyMaker propertyMaker = findMaker(propId); if (propertyMaker == null) { log.warn("No PropertyMaker registered for " + attributeName @@ -401,7 +401,7 @@ public abstract class PropertyList { /* Do nothing if the base property has already been created. * This is e.g. the case when a compound attribute was * specified before the base attribute; in these cases - * the base attribute was already created in + * the base attribute was already created in * findBaseProperty() */ if (getExplicit(propId) != null) { @@ -410,7 +410,7 @@ public abstract class PropertyList { prop = propertyMaker.make(this, attributeValue, parentFO); } else { // e.g. "leader-length.maximum" Property baseProperty - = findBaseProperty(attributes, parentFO, propId, + = findBaseProperty(attributes, parentFO, propId, basePropertyName, propertyMaker); prop = propertyMaker.make(baseProperty, subpropId, this, attributeValue, parentFO); @@ -446,13 +446,13 @@ public abstract class PropertyList { * e.g. */ String basePropertyValue = attributes.getValue(basePropertyName); - + if (basePropertyValue != null && propertyMaker != null) { baseProperty = propertyMaker.make(this, basePropertyValue, parentFO); return baseProperty; } - + return null; // could not find base property } @@ -462,7 +462,7 @@ public abstract class PropertyList { * @throws ValidationException if an exception needs to be thrown depending on the * validation settings */ - protected void handleInvalidProperty(QName attr) + protected void handleInvalidProperty(QName attr) throws ValidationException { if (!attr.getQName().startsWith("xmlns")) { fobj.getFOValidationEventProducer().invalidProperty(this, fobj.getName(), @@ -509,7 +509,7 @@ public abstract class PropertyList { */ private Property getShorthand(int propId) throws PropertyException { PropertyMaker propertyMaker = findMaker(propId); - + if (propertyMaker != null) { return propertyMaker.getShorthand(this); } else { @@ -545,11 +545,11 @@ public abstract class PropertyList { for (int prop = 1; prop <= Constants.PROPERTY_COUNT; prop++) { maker = findMaker(prop); inheritableProperty[prop] = (maker != null && maker.isInherited()); - } + } } return inheritableProperty[propId]; - } + } /** * @param propId Id of property @@ -569,11 +569,11 @@ public abstract class PropertyList { * @return a BorderAndPadding object * @throws PropertyException if there's a problem while processing the properties */ - public CommonBorderPaddingBackground getBorderPaddingBackgroundProps() + public CommonBorderPaddingBackground getBorderPaddingBackgroundProps() throws PropertyException { return CommonBorderPaddingBackground.getInstance(this); } - + /** * Constructs a CommonHyphenation object. * @return the CommonHyphenation object @@ -582,7 +582,7 @@ public abstract class PropertyList { public CommonHyphenation getHyphenationProps() throws PropertyException { return CommonHyphenation.getInstance(this); } - + /** * Constructs a CommonMarginBlock object. * @return the CommonMarginBlock object @@ -591,7 +591,7 @@ public abstract class PropertyList { public CommonMarginBlock getMarginBlockProps() throws PropertyException { return new CommonMarginBlock(this); } - + /** * Constructs a CommonMarginInline object. * @return the CommonMarginInline object @@ -600,9 +600,9 @@ public abstract class PropertyList { public CommonMarginInline getMarginInlineProps() throws PropertyException { return new CommonMarginInline(this); } - + /** - * Constructs a CommonAccessibility object. + * Constructs a CommonAccessibility object. * @return the CommonAccessibility object * @throws PropertyException if there's a problem while processing the properties */ @@ -628,7 +628,7 @@ public abstract class PropertyList { public CommonRelativePosition getRelativePositionProps() throws PropertyException { return new CommonRelativePosition(this); } - + /** * Constructs a CommonAbsolutePosition object. * @return the CommonAbsolutePosition object @@ -636,19 +636,19 @@ public abstract class PropertyList { */ public CommonAbsolutePosition getAbsolutePositionProps() throws PropertyException { return new CommonAbsolutePosition(this); - } - + } + /** * Constructs a CommonFont object. - * + * * @return A CommonFont object * @throws PropertyException if there's a problem while processing the properties */ public CommonFont getFontProps() throws PropertyException { return CommonFont.getInstance(this); } - + /** * Constructs a CommonTextDecoration object. * @return a CommonTextDecoration object diff --git a/src/java/org/apache/fop/fo/PropertyListMaker.java b/src/java/org/apache/fop/fo/PropertyListMaker.java index 018b0ea7d..e48541af5 100755 --- a/src/java/org/apache/fop/fo/PropertyListMaker.java +++ b/src/java/org/apache/fop/fo/PropertyListMaker.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. @@ -20,7 +20,7 @@ package org.apache.fop.fo; /** - * A PropertyListMaker is a factory that creates PropertyLists. + * A PropertyListMaker is a factory that creates PropertyLists. */ public interface PropertyListMaker { PropertyList make(FObj fobj, PropertyList parentPropertyList); diff --git a/src/java/org/apache/fop/fo/RecursiveCharIterator.java b/src/java/org/apache/fop/fo/RecursiveCharIterator.java index a4aa28e37..0e9138586 100644 --- a/src/java/org/apache/fop/fo/RecursiveCharIterator.java +++ b/src/java/org/apache/fop/fo/RecursiveCharIterator.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/fo/StaticPropertyList.java b/src/java/org/apache/fop/fo/StaticPropertyList.java index de020126f..5e6559e84 100755 --- a/src/java/org/apache/fop/fo/StaticPropertyList.java +++ b/src/java/org/apache/fop/fo/StaticPropertyList.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,9 +26,9 @@ import org.apache.fop.fo.properties.Property; public class StaticPropertyList extends PropertyList { private final Property[] explicit; private final Property[] values; - + /** - * Construct a StaticPropertyList. + * Construct a StaticPropertyList. * @param fObjToAttach The FObj object. * @param parentPropertyList The parent property list. */ @@ -65,7 +65,7 @@ public class StaticPropertyList extends PropertyList { * @param propId The property ID */ public Property get(int propId, boolean bTryInherit, boolean bTryDefault) - throws PropertyException + throws PropertyException { Property p = values[propId]; if (p == null) { diff --git a/src/java/org/apache/fop/fo/UnknownXMLObj.java b/src/java/org/apache/fop/fo/UnknownXMLObj.java index 487aed2fa..4db2cf0fe 100644 --- a/src/java/org/apache/fop/fo/UnknownXMLObj.java +++ b/src/java/org/apache/fop/fo/UnknownXMLObj.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/fo/ValidationException.java b/src/java/org/apache/fop/fo/ValidationException.java index 645d3db4d..103c5fcc8 100755 --- a/src/java/org/apache/fop/fo/ValidationException.java +++ b/src/java/org/apache/fop/fo/ValidationException.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/fo/XMLObj.java b/src/java/org/apache/fop/fo/XMLObj.java index 683ca5a03..97aa435e7 100644 --- a/src/java/org/apache/fop/fo/XMLObj.java +++ b/src/java/org/apache/fop/fo/XMLObj.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. @@ -40,7 +40,7 @@ import org.xml.sax.Locator; public abstract class XMLObj extends FONode implements ObjectBuiltListener { private static final String XMLNS_NAMESPACE_URI = "http://www.w3.org/2000/xmlns/"; - + // temp reference for attributes private Attributes attr = null; @@ -66,7 +66,7 @@ public abstract class XMLObj extends FONode implements ObjectBuiltListener { * {@inheritDoc} *
    Here, blocks XSL-FO's from having non-FO parents. */ - 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); @@ -74,7 +74,7 @@ public abstract class XMLObj extends FONode implements ObjectBuiltListener { } /** {@inheritDoc} */ - public void processNode(String elementName, Locator locator, + public void processNode(String elementName, Locator locator, Attributes attlist, PropertyList propertyList) throws FOPException { setLocator(locator); name = elementName; @@ -90,17 +90,17 @@ public abstract class XMLObj extends FONode implements ObjectBuiltListener { /** * Returns the dimensions of the generated area in pts. - * + * * @param view Point2D instance to receive the dimensions * @return the requested dimensions in pts. */ public Point2D getDimension(Point2D view) { return null; } - + /** * Retrieve the intrinsic alignment-adjust of the child element. - * + * * @return the intrinsic alignment-adjust. */ public Length getIntrinsicAlignmentAdjust() { @@ -149,10 +149,10 @@ public abstract class XMLObj extends FONode implements ObjectBuiltListener { } } } - + /** * Add the top-level element to the DOM document - * + * * @param doc DOM document * @param svgRoot non-XSL-FO element to be added as the root of this document */ @@ -163,7 +163,7 @@ public abstract class XMLObj extends FONode implements ObjectBuiltListener { /** * Create an empty DOM document - * + * * @return DOM document */ public Document createBasicDocument() { @@ -183,7 +183,7 @@ public abstract class XMLObj extends FONode implements ObjectBuiltListener { element.setAttributeNS(XMLNS_NAMESPACE_URI, "xmlns", getNamespaceURI()); } - + } catch (Exception e) { //TODO this is ugly because there may be subsequent failures like NPEs log.error("Error while trying to instantiate a DOM Document", e); @@ -205,7 +205,7 @@ public abstract class XMLObj extends FONode implements ObjectBuiltListener { /** * Add parsed characters to this object - * + * * @param data array of characters contaning the text to add * @param start starting array element to add * @param length number of characters from the array to add @@ -223,6 +223,6 @@ public abstract class XMLObj extends FONode implements ObjectBuiltListener { public void notifyObjectBuilt(Object obj) { this.doc = (Document)obj; } - + } diff --git a/src/java/org/apache/fop/fo/XMLWhiteSpaceHandler.java b/src/java/org/apache/fop/fo/XMLWhiteSpaceHandler.java index d8915b124..759cdaed9 100644 --- a/src/java/org/apache/fop/fo/XMLWhiteSpaceHandler.java +++ b/src/java/org/apache/fop/fo/XMLWhiteSpaceHandler.java @@ -27,7 +27,7 @@ import org.apache.fop.util.CharUtilities; /** * Class encapsulating the functionality for white-space-handling * during refinement stage. - * The handleWhiteSpace() methods are called during + * The handleWhiteSpace() methods are called during * FOTree-building and marker-cloning: *
    *

      @@ -47,8 +47,8 @@ import org.apache.fop.util.CharUtilities; * after the previous non-text child *
    *
    - * The iteration always starts at firstTextNode, - * goes on until the last text-node is reached, and deals only + * The iteration always starts at firstTextNode, + * goes on until the last text-node is reached, and deals only * with FOText or Character nodes. *
    * Note: if the method is called from an inline's endOfNode(), @@ -60,25 +60,25 @@ import org.apache.fop.util.CharUtilities; * of the ancestor block. */ public class XMLWhiteSpaceHandler { - + /** True if we are in a run of white space */ private boolean inWhiteSpace = false; /** True if the last char was a linefeed */ private boolean afterLinefeed = true; /** Counter, increased every time a non-white-space is encountered */ private int nonWhiteSpaceCount; - + private int linefeedTreatment; private int whiteSpaceTreatment; private int whiteSpaceCollapse; private boolean endOfBlock; private boolean nextChildIsBlockLevel; private RecursiveCharIterator charIter; - + private List pendingInlines; private Stack nestedBlockStack = new java.util.Stack(); private CharIterator firstWhiteSpaceInSeq; - + /** * Handle white-space for the fo that is passed in, starting at * firstTextNode @@ -93,14 +93,14 @@ public class XMLWhiteSpaceHandler { Block currentBlock = null; int foId = fo.getNameId(); - + /* set the current block */ switch (foId) { case Constants.FO_BLOCK: currentBlock = (Block) fo; if (nestedBlockStack.empty() || fo != nestedBlockStack.peek()) { if (nextChild != null) { - /* if already in a block, push the current block + /* if already in a block, push the current block * onto the stack of nested blocks */ nestedBlockStack.push(currentBlock); @@ -111,7 +111,7 @@ public class XMLWhiteSpaceHandler { } } break; - + case Constants.FO_RETRIEVE_MARKER: /* look for the nearest block ancestor, if any */ FONode ancestor = fo; @@ -119,19 +119,19 @@ public class XMLWhiteSpaceHandler { ancestor = ancestor.getParent(); } while (ancestor.getNameId() != Constants.FO_BLOCK && ancestor.getNameId() != Constants.FO_STATIC_CONTENT); - + if (ancestor.getNameId() == Constants.FO_BLOCK) { currentBlock = (Block) ancestor; nestedBlockStack.push(currentBlock); } break; - + default: if (!nestedBlockStack.empty()) { currentBlock = (Block) nestedBlockStack.peek(); } } - + if (currentBlock != null) { linefeedTreatment = currentBlock.getLinefeedTreatment(); whiteSpaceCollapse = currentBlock.getWhitespaceCollapse(); @@ -141,9 +141,9 @@ public class XMLWhiteSpaceHandler { whiteSpaceCollapse = Constants.EN_TRUE; whiteSpaceTreatment = Constants.EN_IGNORE_IF_SURROUNDING_LINEFEED; } - + endOfBlock = (nextChild == null && fo == currentBlock); - + if (firstTextNode == null) { //no text means no white-space to handle; return early afterLinefeed = (fo == currentBlock && fo.firstChild == null); @@ -153,10 +153,10 @@ public class XMLWhiteSpaceHandler { } return; } - + charIter = new RecursiveCharIterator(fo, firstTextNode); inWhiteSpace = false; - + if (fo == currentBlock || currentBlock == null || (foId == Constants.FO_RETRIEVE_MARKER @@ -172,7 +172,7 @@ public class XMLWhiteSpaceHandler { || previousChildId == Constants.FO_BLOCK_CONTAINER); } } - + if (foId == Constants.FO_WRAPPER) { FONode parent = fo.parent; int parentId = parent.getNameId(); @@ -187,7 +187,7 @@ public class XMLWhiteSpaceHandler { endOfBlock = (nextChild == null); } } - + if (nextChild != null) { int nextChildId = nextChild.getNameId(); nextChildIsBlockLevel = ( @@ -199,20 +199,20 @@ public class XMLWhiteSpaceHandler { } else { nextChildIsBlockLevel = false; } - + handleWhiteSpace(); - - if (fo == currentBlock + + if (fo == currentBlock && (endOfBlock || nextChildIsBlockLevel)) { handlePendingInlines(); } - + if (nextChild == null) { if (fo != currentBlock) { /* current FO is not a block, and is about to end */ if (nonWhiteSpaceCount > 0 && pendingInlines != null) { - /* there is non-white-space text between the pending - * inline(s) and the end of the non-block node; + /* there is non-white-space text between the pending + * inline(s) and the end of the non-block node; * clear list of pending inlines */ pendingInlines.clear(); } @@ -222,7 +222,7 @@ public class XMLWhiteSpaceHandler { addPendingInline(fo); } } else { - /* end of block: clear the references and pop the + /* end of block: clear the references and pop the * nested block stack */ if (!nestedBlockStack.empty()) { nestedBlockStack.pop(); @@ -231,7 +231,7 @@ public class XMLWhiteSpaceHandler { } } } - + /** * Handle white-space for the fo that is passed in, starting at * firstTextNode (when a nested FO is encountered) @@ -241,13 +241,13 @@ public class XMLWhiteSpaceHandler { public void handleWhiteSpace(FObjMixed fo, FONode firstTextNode) { handleWhiteSpace(fo, firstTextNode, null); } - + private void handleWhiteSpace() { - + EOLchecker lfCheck = new EOLchecker(charIter); - + nonWhiteSpaceCount = 0; - + while (charIter.hasNext()) { if (!inWhiteSpace) { firstWhiteSpaceInSeq = charIter.mark(); @@ -265,7 +265,7 @@ public class XMLWhiteSpaceHandler { switch (CharUtilities.classOf(currentChar)) { case CharUtilities.XMLWHITESPACE: // Some kind of whitespace character, except linefeed. - if (inWhiteSpace + if (inWhiteSpace && whiteSpaceCollapse == Constants.EN_TRUE) { // We are in a run of whitespace and should collapse // Just delete the char @@ -343,14 +343,14 @@ public class XMLWhiteSpaceHandler { } } } - + private void addPendingInline(FObjMixed fo) { if (pendingInlines == null) { pendingInlines = new java.util.ArrayList(5); } pendingInlines.add(new PendingInline(fo, firstWhiteSpaceInSeq)); } - + private void handlePendingInlines() { if (!(pendingInlines == null || pendingInlines.isEmpty())) { if (nonWhiteSpaceCount == 0) { @@ -370,7 +370,7 @@ public class XMLWhiteSpaceHandler { } } } - + /** * Helper class, used during white-space handling to look ahead, and * see if the next character is a linefeed (or if there will be @@ -401,7 +401,7 @@ public class XMLWhiteSpaceHandler { } // No more characters == end of text run // means EOL if there either is a nested block to be added, - // or if this is the last text node in the current block + // or if this is the last text node in the current block nextIsEOL = nextChildIsBlockLevel || endOfBlock; } return nextIsEOL; @@ -411,16 +411,16 @@ public class XMLWhiteSpaceHandler { nextIsEOL = false; } } - + /** - * Helper class to store unfinished inline nodes together + * Helper class to store unfinished inline nodes together * with an iterator that starts at the first white-space * character in the sequence of trailing white-space */ private class PendingInline { protected FObjMixed fo; protected CharIterator firstTrailingWhiteSpace; - + PendingInline(FObjMixed fo, CharIterator firstTrailingWhiteSpace) { this.fo = fo; this.firstTrailingWhiteSpace = firstTrailingWhiteSpace; diff --git a/src/java/org/apache/fop/fo/expr/AbsFunction.java b/src/java/org/apache/fop/fo/expr/AbsFunction.java index 64936459f..0e8355faa 100644 --- a/src/java/org/apache/fop/fo/expr/AbsFunction.java +++ b/src/java/org/apache/fop/fo/expr/AbsFunction.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/fo/expr/BodyStartFunction.java b/src/java/org/apache/fop/fo/expr/BodyStartFunction.java index a1c0259fa..eb68b2a23 100644 --- a/src/java/org/apache/fop/fo/expr/BodyStartFunction.java +++ b/src/java/org/apache/fop/fo/expr/BodyStartFunction.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/fo/expr/CMYKcolorFunction.java b/src/java/org/apache/fop/fo/expr/CMYKcolorFunction.java index 3aab1325d..fe86860f4 100644 --- a/src/java/org/apache/fop/fo/expr/CMYKcolorFunction.java +++ b/src/java/org/apache/fop/fo/expr/CMYKcolorFunction.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.fo.expr; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.fo.properties.ColorProperty; @@ -26,22 +26,22 @@ import org.apache.fop.fo.properties.Property; * Implements the cmyk() function. */ class CMYKcolorFunction extends FunctionBase { - + /** - * cmyk takes four arguments. - * {@inheritDoc} + * cmyk takes four arguments. + * {@inheritDoc} */ public int nbArgs() { return 4; } - + /** {@inheritDoc} */ public Property eval(Property[] args, PropertyInfo pInfo) throws PropertyException { StringBuffer sb = new StringBuffer(); sb.append("cmyk(" + args[0] + "," + args[1] + "," + args[2] + "," + args[3] + ")"); - FOUserAgent ua = (pInfo == null) - ? null + FOUserAgent ua = (pInfo == null) + ? null : (pInfo.getFO() == null ? null : pInfo.getFO().getUserAgent()); return ColorProperty.getInstance(ua, sb.toString()); } diff --git a/src/java/org/apache/fop/fo/expr/CeilingFunction.java b/src/java/org/apache/fop/fo/expr/CeilingFunction.java index 29ac1940a..875c88751 100644 --- a/src/java/org/apache/fop/fo/expr/CeilingFunction.java +++ b/src/java/org/apache/fop/fo/expr/CeilingFunction.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.fo.expr; import org.apache.fop.fo.properties.NumberProperty; diff --git a/src/java/org/apache/fop/fo/expr/FloorFunction.java b/src/java/org/apache/fop/fo/expr/FloorFunction.java index 9cdbf1a28..043473140 100644 --- a/src/java/org/apache/fop/fo/expr/FloorFunction.java +++ b/src/java/org/apache/fop/fo/expr/FloorFunction.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.fo.expr; import org.apache.fop.fo.properties.NumberProperty; diff --git a/src/java/org/apache/fop/fo/expr/FromParentFunction.java b/src/java/org/apache/fop/fo/expr/FromParentFunction.java index b09d3c95f..b1e9d689d 100644 --- a/src/java/org/apache/fop/fo/expr/FromParentFunction.java +++ b/src/java/org/apache/fop/fo/expr/FromParentFunction.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/fo/expr/FromTableColumnFunction.java b/src/java/org/apache/fop/fo/expr/FromTableColumnFunction.java index 66cafc2ac..df84939f1 100644 --- a/src/java/org/apache/fop/fo/expr/FromTableColumnFunction.java +++ b/src/java/org/apache/fop/fo/expr/FromTableColumnFunction.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/fo/expr/Function.java b/src/java/org/apache/fop/fo/expr/Function.java index a06627f6c..78e40fad2 100644 --- a/src/java/org/apache/fop/fo/expr/Function.java +++ b/src/java/org/apache/fop/fo/expr/Function.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/fo/expr/FunctionBase.java b/src/java/org/apache/fop/fo/expr/FunctionBase.java index 24d2fef49..b5040c635 100644 --- a/src/java/org/apache/fop/fo/expr/FunctionBase.java +++ b/src/java/org/apache/fop/fo/expr/FunctionBase.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/fo/expr/ICCColorFunction.java b/src/java/org/apache/fop/fo/expr/ICCColorFunction.java index 9444639a5..2069945f1 100644 --- a/src/java/org/apache/fop/fo/expr/ICCColorFunction.java +++ b/src/java/org/apache/fop/fo/expr/ICCColorFunction.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.fo.expr; import org.apache.fop.datatypes.PercentBase; import org.apache.fop.datatypes.PercentBaseContext; @@ -29,16 +29,16 @@ import org.apache.fop.fo.properties.Property; * Implements the rgb-icc() function. */ class ICCColorFunction extends FunctionBase { - + /** - * rgb-icc takes a variable number of arguments. - * At least 4 should be passed - returns -4 - * {@inheritDoc} + * rgb-icc takes a variable number of arguments. + * At least 4 should be passed - returns -4 + * {@inheritDoc} */ public int nbArgs() { return -4; } - + /** {@inheritDoc} */ public PercentBase getPercentBase() { return new ICCPercentBase(); @@ -52,7 +52,7 @@ class ICCColorFunction extends FunctionBase { Declarations decls = pInfo.getFO().getRoot().getDeclarations(); ColorProfile cp = null; if (decls == null) { - //function used in a color-specification + //function used in a color-specification //on a FO occurring: //a) before the fo:declarations, //b) or in a document without fo:declarations? @@ -63,27 +63,27 @@ class ICCColorFunction extends FunctionBase { } else { cp = decls.getColorProfile(colorProfileName); if (cp == null) { - PropertyException pe = new PropertyException("The " + colorProfileName + PropertyException pe = new PropertyException("The " + colorProfileName + " color profile was not declared"); pe.setPropertyInfo(pInfo); throw pe; } } String src = cp.getSrc(); - + float red = 0, green = 0, blue = 0; red = args[0].getNumber().floatValue(); green = args[1].getNumber().floatValue(); blue = args[2].getNumber().floatValue(); /* Verify rgb replacement arguments */ - if ((red < 0 || red > 255) - || (green < 0 || green > 255) + if ((red < 0 || red > 255) + || (green < 0 || green > 255) || (blue < 0 || blue > 255)) { throw new PropertyException("Color values out of range. " + "Arguments to rgb-icc() must be [0..255] or [0%..100%]"); } - - // rgb-icc is replaced with fop-rgb-icc which has an extra fifth argument containing the + + // rgb-icc is replaced with fop-rgb-icc which has an extra fifth argument containing the // color profile src attribute as it is defined in the color-profile declarations element. StringBuffer sb = new StringBuffer(); sb.append("fop-rgb-icc("); @@ -92,19 +92,19 @@ class ICCColorFunction extends FunctionBase { sb.append(',').append(blue / 255f); for (int ix = 3; ix < args.length; ix++) { if (ix == 3) { - sb.append(',').append(colorProfileName); - sb.append(',').append(src); + sb.append(',').append(colorProfileName); + sb.append(',').append(src); } else { sb.append(',').append(args[ix]); } } sb.append(")"); - + return ColorProperty.getInstance(pInfo.getUserAgent(), sb.toString()); } private static final class ICCPercentBase implements PercentBase { - + /** {@inheritDoc} */ public int getBaseLength(PercentBaseContext context) throws PropertyException { return 0; diff --git a/src/java/org/apache/fop/fo/expr/InheritedPropFunction.java b/src/java/org/apache/fop/fo/expr/InheritedPropFunction.java index e24c78caa..94c4fdf22 100644 --- a/src/java/org/apache/fop/fo/expr/InheritedPropFunction.java +++ b/src/java/org/apache/fop/fo/expr/InheritedPropFunction.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/fo/expr/LabelEndFunction.java b/src/java/org/apache/fop/fo/expr/LabelEndFunction.java index 8a02d21d6..65be6cf9f 100644 --- a/src/java/org/apache/fop/fo/expr/LabelEndFunction.java +++ b/src/java/org/apache/fop/fo/expr/LabelEndFunction.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,13 +70,13 @@ public class LabelEndFunction extends FunctionBase { LengthBase.CONTAINING_REFAREA_WIDTH); PercentLength refWidth = new PercentLength(1.0, base); - Numeric labelEnd = distance; + Numeric labelEnd = distance; labelEnd = NumericOp.addition(labelEnd, startIndent); //TODO add start-intrusion-adjustment labelEnd = NumericOp.subtraction(labelEnd, separation); - + labelEnd = NumericOp.subtraction(refWidth, labelEnd); - + return (Property) labelEnd; } diff --git a/src/java/org/apache/fop/fo/expr/MaxFunction.java b/src/java/org/apache/fop/fo/expr/MaxFunction.java index 26e1a8f4c..fd2fee0b1 100644 --- a/src/java/org/apache/fop/fo/expr/MaxFunction.java +++ b/src/java/org/apache/fop/fo/expr/MaxFunction.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/fo/expr/MinFunction.java b/src/java/org/apache/fop/fo/expr/MinFunction.java index 5e5fc7bee..979d16b27 100644 --- a/src/java/org/apache/fop/fo/expr/MinFunction.java +++ b/src/java/org/apache/fop/fo/expr/MinFunction.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/fo/expr/NCnameProperty.java b/src/java/org/apache/fop/fo/expr/NCnameProperty.java index 8e2f8e27f..6bc16f2a9 100644 --- a/src/java/org/apache/fop/fo/expr/NCnameProperty.java +++ b/src/java/org/apache/fop/fo/expr/NCnameProperty.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,13 +42,13 @@ public class NCnameProperty extends Property { /** * If a system color, return the corresponding value. - * - * @param foUserAgent + * + * @param foUserAgent * Reference to FOP user agent - keeps track of cached ColorMaps for ICC colors * @return Color object corresponding to the NCName */ public Color getColor(FOUserAgent foUserAgent) { - try { + try { return ColorUtil.parseColorString(foUserAgent, ncName); } catch (PropertyException e) { //Not logging this error since for properties like "border" you would get an awful @@ -71,7 +71,7 @@ public class NCnameProperty extends Property { public Object getObject() { return this.ncName; } - + /** * @return ncName for this */ diff --git a/src/java/org/apache/fop/fo/expr/NearestSpecPropFunction.java b/src/java/org/apache/fop/fo/expr/NearestSpecPropFunction.java index cdde96092..3e0dda565 100644 --- a/src/java/org/apache/fop/fo/expr/NearestSpecPropFunction.java +++ b/src/java/org/apache/fop/fo/expr/NearestSpecPropFunction.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/fo/expr/NumericOp.java b/src/java/org/apache/fop/fo/expr/NumericOp.java index af77bb44c..9fe35d96d 100755 --- a/src/java/org/apache/fop/fo/expr/NumericOp.java +++ b/src/java/org/apache/fop/fo/expr/NumericOp.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,12 +23,12 @@ import org.apache.fop.datatypes.PercentBaseContext; import org.apache.fop.datatypes.Numeric; /** - * This class contains static methods to evaluate operations on Numeric + * This class contains static methods to evaluate operations on Numeric * operands. If the operands are absolute numerics the result is computed * rigth away and a new absolute numeric is return. If one of the operands are * relative a n operation node is created with the operation and the operands. * The evaluation of the operation can then occur when getNumericValue() is - * called. + * called. */ public class NumericOp { /** @@ -46,16 +46,16 @@ public class NumericOp { return new RelativeNumericProperty(RelativeNumericProperty.ADDITION, op1, op2); } } - + public static Numeric addition2(Numeric op1, Numeric op2, PercentBaseContext context) throws PropertyException { if (op1.getDimension() != op2.getDimension()) { throw new PropertyException("Can't subtract Numerics of different dimensions"); } return numeric(op1.getNumericValue(context) + op2.getNumericValue(context), op1.getDimension()); } - + /** - * Add the second operand from the first and return a new Numeric + * Add the second operand from the first and return a new Numeric * representing the result. * @param op1 The first operand. * @param op2 The second operand. @@ -77,9 +77,9 @@ public class NumericOp { } return numeric(op1.getNumericValue(context) - op2.getNumericValue(context), op1.getDimension()); } - + /** - * Multiply the two operands and return a new Numeric representing the + * Multiply the two operands and return a new Numeric representing the * result. * @param op1 The first operand. * @param op2 The second operand. @@ -93,16 +93,16 @@ public class NumericOp { } else { return new RelativeNumericProperty(RelativeNumericProperty.MULTIPLY, op1, op2); } - } + } public static Numeric multiply2(Numeric op1, Numeric op2, PercentBaseContext context) throws PropertyException { - return numeric(op1.getNumericValue(context) * op2.getNumericValue(context), + return numeric(op1.getNumericValue(context) * op2.getNumericValue(context), op1.getDimension() + op2.getDimension()); } - + /** - * Divide the second operand into the first and return a new - * Numeric representing the + * Divide the second operand into the first and return a new + * Numeric representing the * result. * @param op1 The first operand. * @param op2 The second operand. @@ -117,12 +117,12 @@ public class NumericOp { return new RelativeNumericProperty(RelativeNumericProperty.DIVIDE, op1, op2); } } - + public static Numeric divide2(Numeric op1, Numeric op2, PercentBaseContext context) throws PropertyException { - return numeric(op1.getNumericValue(context) / op2.getNumericValue(context), + return numeric(op1.getNumericValue(context) / op2.getNumericValue(context), op1.getDimension() - op2.getDimension()); } - + /** * Return the remainder of a division of the two operand Numeric. * @param op1 The first operand. @@ -136,7 +136,7 @@ public class NumericOp { return new RelativeNumericProperty(RelativeNumericProperty.MODULO, op1, op2); } } - + public static Numeric modulo2(Numeric op1, Numeric op2, PercentBaseContext context) throws PropertyException { return numeric(op1.getNumericValue(context) % op2.getNumericValue(context), op1.getDimension()); } @@ -157,7 +157,7 @@ public class NumericOp { public static Numeric abs2(Numeric op, PercentBaseContext context) throws PropertyException { return numeric(Math.abs(op.getNumericValue(context)), op.getDimension()); } - + /** * Return the negation of a Numeric. * @param op the operand. @@ -174,7 +174,7 @@ public class NumericOp { public static Numeric negate2(Numeric op, PercentBaseContext context) throws PropertyException { return numeric(- op.getNumericValue(context), op.getDimension()); } - + /** * Return the larger of the two Numerics. * @param op1 The first operand. @@ -196,7 +196,7 @@ public class NumericOp { } return op1.getNumericValue(context) > op2.getNumericValue(context) ? op1 : op2; } - + /** * Return the smaller of two Numerics. * @param op1 The first operand. @@ -218,9 +218,9 @@ public class NumericOp { } return op1.getNumericValue(context) <= op2.getNumericValue(context) ? op1 : op2; } - + /** - * Create a new absolute numeric with the specified value and dimension. + * Create a new absolute numeric with the specified value and dimension. * @param value * @param dimension * @return a new absolute numeric. diff --git a/src/java/org/apache/fop/fo/expr/NumericProperty.java b/src/java/org/apache/fop/fo/expr/NumericProperty.java index 54fe1f2f7..f80e1f5a5 100644 --- a/src/java/org/apache/fop/fo/expr/NumericProperty.java +++ b/src/java/org/apache/fop/fo/expr/NumericProperty.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.fo.expr; import java.awt.Color; @@ -30,7 +30,7 @@ import org.apache.fop.fo.properties.Property; /** * A numeric property which hold the final absolute result of an expression - * calculations. + * calculations. */ public class NumericProperty extends Property implements Numeric, Length { private double value; diff --git a/src/java/org/apache/fop/fo/expr/PPColWidthFunction.java b/src/java/org/apache/fop/fo/expr/PPColWidthFunction.java index 394035b49..5defda0fe 100644 --- a/src/java/org/apache/fop/fo/expr/PPColWidthFunction.java +++ b/src/java/org/apache/fop/fo/expr/PPColWidthFunction.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. @@ -40,8 +40,8 @@ public class PPColWidthFunction extends FunctionBase { return 1; } - /** - * @return the {@link PercentBase} for the proportional-column-width() + /** + * @return the {@link PercentBase} for the proportional-column-width() * function */ public PercentBase getPercentBase() { @@ -68,7 +68,7 @@ public class PPColWidthFunction extends FunctionBase { throw new PropertyException("proportional-column-width() function " + "may only be used on fo:table-column."); } - + Table t = (Table) pList.getParentFObj(); if (t.isAutoLayout()) { throw new PropertyException("proportional-column-width() function " @@ -96,6 +96,6 @@ public class PPColWidthFunction extends FunctionBase { public int getDimension() { return 0; } - + } } diff --git a/src/java/org/apache/fop/fo/expr/PropertyException.java b/src/java/org/apache/fop/fo/expr/PropertyException.java index d16d1c8ff..2d1d04913 100644 --- a/src/java/org/apache/fop/fo/expr/PropertyException.java +++ b/src/java/org/apache/fop/fo/expr/PropertyException.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 PropertyException extends FOPException { this.propertyName = ((PropertyException)cause).propertyName; } } - + /** * Sets the property context information. * @param propInfo the property info instance diff --git a/src/java/org/apache/fop/fo/expr/PropertyInfo.java b/src/java/org/apache/fop/fo/expr/PropertyInfo.java index 039e8783e..2bce0793f 100644 --- a/src/java/org/apache/fop/fo/expr/PropertyInfo.java +++ b/src/java/org/apache/fop/fo/expr/PropertyInfo.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 PropertyInfo { public PropertyMaker getPropertyMaker() { return maker; } - + /** * push a function onto the function stack * @param func function to push onto stack @@ -117,15 +117,15 @@ public class PropertyInfo { /** * Convenience shortcut to get a reference to the FOUserAgent - * + * * @return the FOUserAgent */ protected FOUserAgent getUserAgent() { - return (plist.getFObj() != null) - ? plist.getFObj().getUserAgent() + return (plist.getFObj() != null) + ? plist.getFObj().getUserAgent() : null; } - + private PercentBase getFunctionPercentBase() { if (stkFunction != null) { Function f = (Function)stkFunction.peek(); diff --git a/src/java/org/apache/fop/fo/expr/PropertyParser.java b/src/java/org/apache/fop/fo/expr/PropertyParser.java index c63142773..7ae1db7f3 100644 --- a/src/java/org/apache/fop/fo/expr/PropertyParser.java +++ b/src/java/org/apache/fop/fo/expr/PropertyParser.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 final class PropertyParser extends PropertyTokenizer { private static final String RELUNIT = "em"; private static final HashMap FUNCTION_TABLE = new HashMap(); - + static { // Initialize the HashMap of XSL-defined functions FUNCTION_TABLE.put("ceiling", new CeilingFunction()); @@ -310,10 +310,10 @@ public final class PropertyParser extends PropertyTokenizer { propInfo.currentFontSize()); } else { if ("px".equals(unitPart)) { - //pass the ratio between source-resolution and + //pass the ratio between source-resolution and //the default resolution of 72dpi prop = FixedLength.getInstance( - numPart, unitPart, + numPart, unitPart, propInfo.getPropertyList().getFObj() .getUserAgent().getSourceResolution() / 72.0f); } else { @@ -344,7 +344,7 @@ public final class PropertyParser extends PropertyTokenizer { } propInfo.popFunction(); return prop; - + default: // TODO: add the token or the expr to the error message. throw new PropertyException("syntax error"); @@ -357,7 +357,7 @@ public final class PropertyParser extends PropertyTokenizer { * Parse a comma separated list of function arguments. Each argument * may itself be an expression. This method consumes the closing right * parenthesis of the argument list. - * @param function The function object for which the arguments are + * @param function The function object for which the arguments are * collected. * @return An array of Property objects representing the arguments * found. @@ -397,27 +397,27 @@ public final class PropertyParser extends PropertyTokenizer { } return args; } - + /** - * + * * Parse a comma separated list of function arguments. Each argument * may itself be an expression. This method consumes the closing right * parenthesis of the argument list. - * - * The method differs from parseArgs in that it accepts a variable + * + * The method differs from parseArgs in that it accepts a variable * number of arguments. - * - * @param function The function object for which the arguments are + * + * @param function The function object for which the arguments are * collected. * @return An array of Property objects representing the arguments * found. * @throws PropertyException If the number of arguments found isn't equal * to the number expected. - * - * TODO Merge this with parseArgs? + * + * TODO Merge this with parseArgs? */ Property[] parseVarArgs(Function function) throws PropertyException { - // For variable argument functions the minimum number of arguments is returned as a + // For variable argument functions the minimum number of arguments is returned as a // negative integer from the nbArgs method int nbArgs = -function.nbArgs(); List args = new LinkedList(); diff --git a/src/java/org/apache/fop/fo/expr/PropertyTokenizer.java b/src/java/org/apache/fop/fo/expr/PropertyTokenizer.java index 5fe5f4445..2ddcd0922 100644 --- a/src/java/org/apache/fop/fo/expr/PropertyTokenizer.java +++ b/src/java/org/apache/fop/fo/expr/PropertyTokenizer.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/fo/expr/RGBColorFunction.java b/src/java/org/apache/fop/fo/expr/RGBColorFunction.java index ba39662eb..1c7a91503 100644 --- a/src/java/org/apache/fop/fo/expr/RGBColorFunction.java +++ b/src/java/org/apache/fop/fo/expr/RGBColorFunction.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.fo.expr; import org.apache.fop.datatypes.PercentBaseContext; @@ -28,7 +28,7 @@ import org.apache.fop.fo.properties.Property; * Implements the rgb() function. */ class RGBColorFunction extends FunctionBase { - + /** {@inheritDoc} */ public int nbArgs() { return 3; @@ -46,8 +46,8 @@ class RGBColorFunction extends FunctionBase { /** {@inheritDoc} */ public Property eval(Property[] args, PropertyInfo pInfo) throws PropertyException { - return ColorProperty.getInstance(pInfo.getUserAgent(), - "rgb(" + args[0] + "," + return ColorProperty.getInstance(pInfo.getUserAgent(), + "rgb(" + args[0] + "," + args[1] + "," + args[2] + ")"); } diff --git a/src/java/org/apache/fop/fo/expr/RelativeNumericProperty.java b/src/java/org/apache/fop/fo/expr/RelativeNumericProperty.java index 647528692..a4e257546 100755 --- a/src/java/org/apache/fop/fo/expr/RelativeNumericProperty.java +++ b/src/java/org/apache/fop/fo/expr/RelativeNumericProperty.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.fo.properties.TableColLength; /** - * This class represent a node in a property expression tree. + * This class represent a node in a property expression tree. * It is created when an operation involve relative expression and is used * to delay evaluation of the operation until the time where getNumericValue() - * or getValue() is called. + * or getValue() is called. */ public class RelativeNumericProperty extends Property implements Length { public static final int ADDITION = 1; @@ -42,10 +42,10 @@ public class RelativeNumericProperty extends Property implements Length { public static final int ABS = 7; public static final int MAX = 8; public static final int MIN = 9; - + // Used in the toString() method, indexed by operation id. private static String operations = " +-*/%"; - + /** * The operation identifier. */ @@ -62,7 +62,7 @@ public class RelativeNumericProperty extends Property implements Length { * The dimension of the result. */ private int dimension; - + /** * Constructor for a two argument operation. * @param operation the operation opcode: ADDITION, SUBTRACTION, ... @@ -124,12 +124,12 @@ public class RelativeNumericProperty extends Property implements Length { case MIN: return NumericOp.min2(op1, op2, context); default: - throw new PropertyException("Unknown expr operation " + operation); + throw new PropertyException("Unknown expr operation " + operation); } } /** - * Return the resolved (calculated) value of the expression. + * Return the resolved (calculated) value of the expression. * {@inheritDoc} */ public double getNumericValue() throws PropertyException { @@ -152,14 +152,14 @@ public class RelativeNumericProperty extends Property implements Length { /** * Return false since an expression is only created when there is relative - * numerics involved. + * numerics involved. */ public boolean isAbsolute() { return false; } /** - * Cast this numeric as a Length. + * Cast this numeric as a Length. */ public Length getLength() { if (dimension == 1) { @@ -205,7 +205,7 @@ public class RelativeNumericProperty extends Property implements Length { * If this value is not 0, the actual value of the Length cannot be known * without looking at all of the columns in the table to determine the value * of a "table-unit". - * + * * @return The number of table units which are included in this length * specification. */ @@ -261,7 +261,7 @@ public class RelativeNumericProperty extends Property implements Length { */ public String toString() { switch (operation) { - case ADDITION: case SUBTRACTION: + case ADDITION: case SUBTRACTION: case DIVIDE: case MULTIPLY: case MODULO: return "(" + op1 + " " + operations.charAt(operation) + op2 + ")"; case NEGATE: diff --git a/src/java/org/apache/fop/fo/expr/RoundFunction.java b/src/java/org/apache/fop/fo/expr/RoundFunction.java index a28a46e28..a29c33e5b 100644 --- a/src/java/org/apache/fop/fo/expr/RoundFunction.java +++ b/src/java/org/apache/fop/fo/expr/RoundFunction.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.fo.expr; diff --git a/src/java/org/apache/fop/fo/expr/SystemColorFunction.java b/src/java/org/apache/fop/fo/expr/SystemColorFunction.java index b32c38e54..eeb1870f7 100644 --- a/src/java/org/apache/fop/fo/expr/SystemColorFunction.java +++ b/src/java/org/apache/fop/fo/expr/SystemColorFunction.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.fo.expr; import org.apache.fop.apps.FOUserAgent; @@ -27,7 +27,7 @@ import org.apache.fop.fo.properties.Property; * Implements the system-color() function. */ class SystemColorFunction extends FunctionBase { - + /** {@inheritDoc} */ public int nbArgs() { return 1; @@ -36,8 +36,8 @@ class SystemColorFunction extends FunctionBase { /** {@inheritDoc} */ public Property eval(Property[] args, PropertyInfo pInfo) throws PropertyException { - FOUserAgent ua = (pInfo == null) - ? null + FOUserAgent ua = (pInfo == null) + ? null : (pInfo.getFO() == null ? null : pInfo.getFO().getUserAgent()); return ColorProperty.getInstance(ua, "system-color(" + args[0] + ")"); diff --git a/src/java/org/apache/fop/fo/extensions/ExtensionAttachment.java b/src/java/org/apache/fop/fo/extensions/ExtensionAttachment.java index ed4f69041..993768c81 100644 --- a/src/java/org/apache/fop/fo/extensions/ExtensionAttachment.java +++ b/src/java/org/apache/fop/fo/extensions/ExtensionAttachment.java @@ -35,5 +35,5 @@ public interface ExtensionAttachment { * @return the category URI */ String getCategory(); - + } diff --git a/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java b/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java index fc61167b2..56521b7e8 100644 --- a/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java +++ b/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.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. @@ -33,12 +33,12 @@ import org.apache.fop.fo.extensions.destination.Destination; * Element mapping for FOP's proprietary extension to XSL-FO. */ public class ExtensionElementMapping extends ElementMapping { - + /** The FOP extension namespace URI */ public static final String URI = "http://xmlgraphics.apache.org/fop/extensions"; private static final Set propertyAttributes = new java.util.HashSet(); - + static { //These are FOP's standard extension properties (fox:*) propertyAttributes.add("block-progression-unit"); @@ -46,7 +46,7 @@ public class ExtensionElementMapping extends ElementMapping { propertyAttributes.add("orphan-content-limit"); propertyAttributes.add("internal-destination"); } - + /** * Constructor. */ @@ -66,7 +66,7 @@ public class ExtensionElementMapping extends ElementMapping { foObjs.put("external-document", new ExternalDocumentMaker()); } } - + static class DestinationMaker extends ElementMapping.Maker { public FONode make(FONode parent) { return new Destination(parent); @@ -83,7 +83,7 @@ public class ExtensionElementMapping extends ElementMapping { public String getStandardPrefix() { return "fox"; } - + /** {@inheritDoc} */ public boolean isAttributeProperty(QName attributeName) { if (!URI.equals(attributeName.getNamespaceURI())) { @@ -91,5 +91,5 @@ public class ExtensionElementMapping extends ElementMapping { } return propertyAttributes.contains(attributeName.getLocalName()); } - + } diff --git a/src/java/org/apache/fop/fo/extensions/ExtensionObj.java b/src/java/org/apache/fop/fo/extensions/ExtensionObj.java index f22c6fbbc..da732f421 100644 --- a/src/java/org/apache/fop/fo/extensions/ExtensionObj.java +++ b/src/java/org/apache/fop/fo/extensions/ExtensionObj.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 abstract class ExtensionObj extends FObj { /** * {@inheritDoc} */ - public void processNode(String elementName, Locator locator, + public void processNode(String elementName, Locator locator, Attributes attlist, PropertyList pList) throws FOPException { @@ -53,9 +53,9 @@ public abstract class ExtensionObj extends FObj { } /** - * Create a default property list for this element. + * Create a default property list for this element. */ - protected PropertyList createPropertyList(PropertyList parent, + protected PropertyList createPropertyList(PropertyList parent, FOEventHandler foEventHandler) throws FOPException { return null; } diff --git a/src/java/org/apache/fop/fo/extensions/ExternalDocument.java b/src/java/org/apache/fop/fo/extensions/ExternalDocument.java index b8707726f..bea6f6f61 100644 --- a/src/java/org/apache/fop/fo/extensions/ExternalDocument.java +++ b/src/java/org/apache/fop/fo/extensions/ExternalDocument.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. @@ -76,7 +76,7 @@ public class ExternalDocument extends AbstractPageSequence implements GraphicsPr textAlign = pList.get(PR_TEXT_ALIGN).getEnum(); width = pList.get(PR_WIDTH).getLength(); src = pList.get(PR_SRC).getString(); - + if (this.src == null || this.src.length() == 0) { missingPropertyError("src"); } diff --git a/src/java/org/apache/fop/fo/extensions/OldExtensionElementMapping.java b/src/java/org/apache/fop/fo/extensions/OldExtensionElementMapping.java index fb1810db1..e5ab93c35 100644 --- a/src/java/org/apache/fop/fo/extensions/OldExtensionElementMapping.java +++ b/src/java/org/apache/fop/fo/extensions/OldExtensionElementMapping.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.fo.UnknownXMLObj; * Element mapping for the old FOP extension namespace. */ public class OldExtensionElementMapping extends ElementMapping { - + /** The old FOP extension namespace URI (FOP 0.20.5 and earlier) */ public static final String URI = "http://xml.apache.org/fop/extensions"; 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 e3a2bbac4..98114bb23 100644 --- a/src/java/org/apache/fop/fo/extensions/destination/Destination.java +++ b/src/java/org/apache/fop/fo/extensions/destination/Destination.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,14 +50,14 @@ public class Destination extends FONode { /** * {@inheritDoc} */ - public void processNode(String elementName, Locator locator, + public void processNode(String elementName, Locator locator, Attributes attlist, PropertyList pList) throws FOPException { internalDestination = attlist.getValue("internal-destination"); if (internalDestination == null || internalDestination.length() == 0) { missingPropertyError("internal-destination"); } } - + /** * {@inheritDoc} */ diff --git a/src/java/org/apache/fop/fo/extensions/svg/BatikExtensionElementMapping.java b/src/java/org/apache/fop/fo/extensions/svg/BatikExtensionElementMapping.java index a39562877..2cc451b64 100644 --- a/src/java/org/apache/fop/fo/extensions/svg/BatikExtensionElementMapping.java +++ b/src/java/org/apache/fop/fo/extensions/svg/BatikExtensionElementMapping.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,10 +32,10 @@ import org.w3c.dom.DOMImplementation; * of the http://xml.apache.org/batik/ext namespace. */ public class BatikExtensionElementMapping extends ElementMapping { - + /** Namespace URI for Batik extension elements */ public static final String URI = "http://xml.apache.org/batik/ext"; - + private boolean batikAvail = true; /** Main constructor. */ diff --git a/src/java/org/apache/fop/fo/extensions/svg/SVGElement.java b/src/java/org/apache/fop/fo/extensions/svg/SVGElement.java index 7711130b1..a40b80190 100644 --- a/src/java/org/apache/fop/fo/extensions/svg/SVGElement.java +++ b/src/java/org/apache/fop/fo/extensions/svg/SVGElement.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,14 +65,14 @@ public class SVGElement extends SVGObj { * {@inheritDoc} */ public ContentHandlerFactory getContentHandlerFactory() { - return new DOMBuilderContentHandlerFactory(getNamespaceURI(), + return new DOMBuilderContentHandlerFactory(getNamespaceURI(), SVGDOMImplementation.getDOMImplementation()); } - + /** * {@inheritDoc} */ - public void processNode(String elementName, Locator locator, + public void processNode(String elementName, Locator locator, Attributes attlist, PropertyList propertyList) throws FOPException { super.processNode(elementName, locator, attlist, propertyList); init(); @@ -91,11 +91,11 @@ public class SVGElement extends SVGObj { /* if width and height are zero, get the bounds of the content. */ try { - URL baseURL = new URL(getUserAgent().getBaseURL() == null - ? new java.io.File("").toURI().toURL().toExternalForm() + URL baseURL = new URL(getUserAgent().getBaseURL() == null + ? new java.io.File("").toURI().toURL().toExternalForm() : getUserAgent().getBaseURL()); if (baseURL != null) { - SVGOMDocument svgdoc = (SVGOMDocument)doc; + SVGOMDocument svgdoc = (SVGOMDocument)doc; svgdoc.setURLObject(baseURL); //The following line should not be called to leave FOP compatible to Batik 1.6. //svgdoc.setDocumentURI(baseURL.toString()); diff --git a/src/java/org/apache/fop/fo/extensions/svg/SVGElementMapping.java b/src/java/org/apache/fop/fo/extensions/svg/SVGElementMapping.java index 586fd2d92..167baf723 100644 --- a/src/java/org/apache/fop/fo/extensions/svg/SVGElementMapping.java +++ b/src/java/org/apache/fop/fo/extensions/svg/SVGElementMapping.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,13 +37,13 @@ import org.w3c.dom.DOMImplementation; * that create the SVG Document. */ public class SVGElementMapping extends ElementMapping { - + /** the SVG namespace */ public static final String URI = SVGDOMImplementation.SVG_NAMESPACE_URI; - + /** logging instance */ protected Log log = LogFactory.getLog(SVGElementMapping.class); - + private boolean batikAvailable = true; /** Main constructor. */ diff --git a/src/java/org/apache/fop/fo/extensions/svg/SVGObj.java b/src/java/org/apache/fop/fo/extensions/svg/SVGObj.java index 93193aac4..b23e0f6c6 100644 --- a/src/java/org/apache/fop/fo/extensions/svg/SVGObj.java +++ b/src/java/org/apache/fop/fo/extensions/svg/SVGObj.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.fo.XMLObj; * This aids in the construction of the SVG Document. */ public class SVGObj extends XMLObj { - + /** * Constructs an SVG object (called by Maker). * @@ -46,6 +46,6 @@ public class SVGObj extends XMLObj { public String getNormalNamespacePrefix() { return "svg"; } - + } diff --git a/src/java/org/apache/fop/fo/extensions/xmp/AbstractMetadataElement.java b/src/java/org/apache/fop/fo/extensions/xmp/AbstractMetadataElement.java index 0fff78623..f4b770bbe 100644 --- a/src/java/org/apache/fop/fo/extensions/xmp/AbstractMetadataElement.java +++ b/src/java/org/apache/fop/fo/extensions/xmp/AbstractMetadataElement.java @@ -32,7 +32,7 @@ import org.apache.xmlgraphics.xmp.Metadata; public abstract class AbstractMetadataElement extends FONode implements ObjectBuiltListener { private XMPMetadata attachment; - + /** * Main constructor. * @param parent the parent formatting object @@ -40,14 +40,14 @@ public abstract class AbstractMetadataElement extends FONode implements ObjectBu public AbstractMetadataElement(FONode parent) { super(parent); } - + /** * {@inheritDoc} */ public ContentHandlerFactory getContentHandlerFactory() { return new XMPContentHandlerFactory(); } - + /** {@inheritDoc} */ public ExtensionAttachment getExtensionAttachment() { if (parent instanceof FObj) { @@ -65,5 +65,5 @@ public abstract class AbstractMetadataElement extends FONode implements ObjectBu attachment.setMetadata((Metadata)obj); } - + } diff --git a/src/java/org/apache/fop/fo/extensions/xmp/RDFElement.java b/src/java/org/apache/fop/fo/extensions/xmp/RDFElement.java index 6a67575c5..cf1c40c4a 100644 --- a/src/java/org/apache/fop/fo/extensions/xmp/RDFElement.java +++ b/src/java/org/apache/fop/fo/extensions/xmp/RDFElement.java @@ -34,7 +34,7 @@ public class RDFElement extends AbstractMetadataElement { public RDFElement(FONode parent) { super(parent); } - + /** {@inheritDoc} */ public String getLocalName() { return "RDF"; diff --git a/src/java/org/apache/fop/fo/extensions/xmp/RDFElementMapping.java b/src/java/org/apache/fop/fo/extensions/xmp/RDFElementMapping.java index e2aa1ba95..ff84ee11f 100644 --- a/src/java/org/apache/fop/fo/extensions/xmp/RDFElementMapping.java +++ b/src/java/org/apache/fop/fo/extensions/xmp/RDFElementMapping.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.w3c.dom.DOMImplementation; * Setup the element mapping for XMP metadata. */ public class RDFElementMapping extends ElementMapping { - + /** Main constructor. */ public RDFElementMapping() { namespaceURI = XMPConstants.RDF_NAMESPACE; diff --git a/src/java/org/apache/fop/fo/extensions/xmp/XMPContentHandlerFactory.java b/src/java/org/apache/fop/fo/extensions/xmp/XMPContentHandlerFactory.java index 5c30801f2..02a74b86d 100644 --- a/src/java/org/apache/fop/fo/extensions/xmp/XMPContentHandlerFactory.java +++ b/src/java/org/apache/fop/fo/extensions/xmp/XMPContentHandlerFactory.java @@ -30,7 +30,7 @@ import org.xml.sax.SAXException; */ public class XMPContentHandlerFactory implements ContentHandlerFactory { - private static final String[] NAMESPACES = new String[] + private static final String[] NAMESPACES = new String[] {XMPConstants.XMP_NAMESPACE, XMPConstants.RDF_NAMESPACE}; /** {@inheritDoc} */ @@ -49,7 +49,7 @@ public class XMPContentHandlerFactory implements ContentHandlerFactory { private class FOPXMPHandler extends XMPHandler implements ObjectSource { private ObjectBuiltListener obListener; - + public Object getObject() { return getMetadata(); } @@ -58,14 +58,14 @@ public class XMPContentHandlerFactory implements ContentHandlerFactory { public void setObjectBuiltListener(ObjectBuiltListener listener) { this.obListener = listener; } - + /** {@inheritDoc} */ public void endDocument() throws SAXException { if (obListener != null) { obListener.notifyObjectBuilt(getObject()); } } - + } - + } diff --git a/src/java/org/apache/fop/fo/extensions/xmp/XMPElementMapping.java b/src/java/org/apache/fop/fo/extensions/xmp/XMPElementMapping.java index dd250f8b4..b2b3570f2 100644 --- a/src/java/org/apache/fop/fo/extensions/xmp/XMPElementMapping.java +++ b/src/java/org/apache/fop/fo/extensions/xmp/XMPElementMapping.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.w3c.dom.DOMImplementation; * Setup the element mapping for XMP metadata. */ public class XMPElementMapping extends ElementMapping { - + /** Main constructor. */ public XMPElementMapping() { namespaceURI = XMPConstants.XMP_NAMESPACE; diff --git a/src/java/org/apache/fop/fo/extensions/xmp/XMPMetaElement.java b/src/java/org/apache/fop/fo/extensions/xmp/XMPMetaElement.java index 2d3058d3f..f99ccd2aa 100644 --- a/src/java/org/apache/fop/fo/extensions/xmp/XMPMetaElement.java +++ b/src/java/org/apache/fop/fo/extensions/xmp/XMPMetaElement.java @@ -34,7 +34,7 @@ public class XMPMetaElement extends AbstractMetadataElement { public XMPMetaElement(FONode parent) { super(parent); } - + /** {@inheritDoc} */ public String getLocalName() { return "xmpmeta"; diff --git a/src/java/org/apache/fop/fo/extensions/xmp/XMPMetadata.java b/src/java/org/apache/fop/fo/extensions/xmp/XMPMetadata.java index bdfd1fc29..224741294 100644 --- a/src/java/org/apache/fop/fo/extensions/xmp/XMPMetadata.java +++ b/src/java/org/apache/fop/fo/extensions/xmp/XMPMetadata.java @@ -35,7 +35,7 @@ public class XMPMetadata implements ExtensionAttachment, Serializable, XMLizable /** The category URI for this extension attachment. */ public static final String CATEGORY = XMPConstants.XMP_NAMESPACE; - + private Metadata meta; private boolean readOnly = true; @@ -45,7 +45,7 @@ public class XMPMetadata implements ExtensionAttachment, Serializable, XMLizable public XMPMetadata() { //nop } - + /** * Default constructor. * @param metadata the XMP metadata @@ -53,12 +53,12 @@ public class XMPMetadata implements ExtensionAttachment, Serializable, XMLizable public XMPMetadata(Metadata metadata) { this.meta = metadata; } - + /** @return the XMP metadata */ public Metadata getMetadata() { return this.meta; } - + /** * Sets the XMP metadata. * @param metadata the XMP metadata @@ -66,7 +66,7 @@ public class XMPMetadata implements ExtensionAttachment, Serializable, XMLizable public void setMetadata(Metadata metadata) { this.meta = metadata; } - + /** @return true if the XMP metadata is marked read-only. */ public boolean isReadOnly() { return readOnly; @@ -84,10 +84,10 @@ public class XMPMetadata implements ExtensionAttachment, Serializable, XMLizable public String getCategory() { return CATEGORY; } - + /** {@inheritDoc} */ public void toSAX(ContentHandler handler) throws SAXException { getMetadata().toSAX(handler); } - + } diff --git a/src/java/org/apache/fop/fo/flow/AbstractGraphics.java b/src/java/org/apache/fop/fo/flow/AbstractGraphics.java index 19cea1510..d72682282 100644 --- a/src/java/org/apache/fop/fo/flow/AbstractGraphics.java +++ b/src/java/org/apache/fop/fo/flow/AbstractGraphics.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/fo/flow/AbstractListItemPart.java b/src/java/org/apache/fop/fo/flow/AbstractListItemPart.java index 092358891..b0e93e9c6 100644 --- a/src/java/org/apache/fop/fo/flow/AbstractListItemPart.java +++ b/src/java/org/apache/fop/fo/flow/AbstractListItemPart.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 abstract class AbstractListItemPart extends FObj { /** * Base constructor - * + * * @param parent {@link FONode} that is the parent of this object */ public AbstractListItemPart(FONode parent) { @@ -62,7 +62,7 @@ public abstract class AbstractListItemPart extends FObj { * {@inheritDoc} *
    XSL Content Model: marker* (%block;)+ */ - 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)) { if (localName.equals("marker")) { diff --git a/src/java/org/apache/fop/fo/flow/AbstractPageNumberCitation.java b/src/java/org/apache/fop/fo/flow/AbstractPageNumberCitation.java index 8849d4d1c..5f420efb8 100644 --- a/src/java/org/apache/fop/fo/flow/AbstractPageNumberCitation.java +++ b/src/java/org/apache/fop/fo/flow/AbstractPageNumberCitation.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,12 +38,12 @@ import org.apache.fop.fo.properties.SpaceProperty; /** * Common base class for the - * fo:page-number-citation and + * fo:page-number-citation and * * fo:page-number-citation-last objects. */ public abstract class AbstractPageNumberCitation extends FObj { - + // The value of properties relevant for fo:page-number-citation(-last). private CommonBorderPaddingBackground commonBorderPaddingBackground; private CommonFont commonFont; @@ -73,12 +73,12 @@ public abstract class AbstractPageNumberCitation extends FObj { // private int wrapOption; // End of property values - // Properties which are not explicitely listed but are still applicable + // Properties which are not explicitely listed but are still applicable private Color color; /** * Base constructor - * + * * @param parent {@link FONode} that is the parent of this object */ public AbstractPageNumberCitation(FONode parent) { @@ -99,7 +99,7 @@ public abstract class AbstractPageNumberCitation extends FObj { refId = pList.get(PR_REF_ID).getString(); textDecoration = pList.getTextDecorationProps(); // textShadow = pList.get(PR_TEXT_SHADOW); - + // implicit properties color = pList.get(Constants.PR_COLOR).getColor(getUserAgent()); } @@ -116,7 +116,7 @@ public abstract class AbstractPageNumberCitation extends FObj { * {@inheritDoc} *
    XSL Content Model: empty */ - 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); @@ -135,29 +135,29 @@ public abstract class AbstractPageNumberCitation extends FObj { /** @return the "text-decoration" property. */ public CommonTextDecoration getTextDecoration() { - return textDecoration; + return textDecoration; } - + /** @return the "alignment-adjust" property */ public Length getAlignmentAdjust() { return alignmentAdjust; } - + /** @return the "alignment-baseline" property */ public int getAlignmentBaseline() { return alignmentBaseline; } - + /** @return the "baseline-shift" property */ public Length getBaselineShift() { return baselineShift; } - + /** @return the "dominant-baseline" property */ public int getDominantBaseline() { return dominantBaseline; } - + /** @return the {@link CommonBorderPaddingBackground} */ public CommonBorderPaddingBackground getCommonBorderPaddingBackground() { return commonBorderPaddingBackground; @@ -167,10 +167,10 @@ public abstract class AbstractPageNumberCitation extends FObj { public SpaceProperty getLineHeight() { return lineHeight; } - + /** @return the "ref-id" property. */ public String getRefId() { return refId; } - + } diff --git a/src/java/org/apache/fop/fo/flow/AbstractRetrieveMarker.java b/src/java/org/apache/fop/fo/flow/AbstractRetrieveMarker.java index c88147350..ebba1fda5 100644 --- a/src/java/org/apache/fop/fo/flow/AbstractRetrieveMarker.java +++ b/src/java/org/apache/fop/fo/flow/AbstractRetrieveMarker.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/fo/flow/BasicLink.java b/src/java/org/apache/fop/fo/flow/BasicLink.java index 82d0134bd..ee3171188 100644 --- a/src/java/org/apache/fop/fo/flow/BasicLink.java +++ b/src/java/org/apache/fop/fo/flow/BasicLink.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.fo.ValidationException; * fo:basic-link object. * * This class contains the logic to determine the link represented by this FO, - * and whether that link is external (uses a URI) or internal (an id + * and whether that link is external (uses a URI) or internal (an id * reference). */ public class BasicLink extends Inline { @@ -55,7 +55,7 @@ public class BasicLink extends Inline { /** * Construct a BasicLink instance with the given {@link FONode} * as its parent. - * + * * @param parent {@link FONode} that is the parent of this object */ public BasicLink(FONode parent) { @@ -74,8 +74,8 @@ public class BasicLink extends Inline { // targetPresentationContext = pList.get(PR_TARGET_PRESENTATION_CONTEXT); // targetStylesheet = pList.get(PR_TARGET_STYLESHEET); - // per spec, internal takes precedence if both specified - if (internalDestination.length() > 0) { + // per spec, internal takes precedence if both specified + if (internalDestination.length() > 0) { externalDestination = null; } else if (externalDestination.length() == 0) { // slightly stronger than spec "should be specified" @@ -96,7 +96,7 @@ public class BasicLink extends Inline { } /** {@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)) { if (localName.equals("marker")) { @@ -162,7 +162,7 @@ public class BasicLink extends Inline { public String getLocalName() { return "basic-link"; } - + /** * {@inheritDoc} * @return {@link org.apache.fop.fo.Constants#FO_BASIC_LINK} diff --git a/src/java/org/apache/fop/fo/flow/BidiOverride.java b/src/java/org/apache/fop/fo/flow/BidiOverride.java index 492e6c4ba..6e4a74379 100644 --- a/src/java/org/apache/fop/fo/flow/BidiOverride.java +++ b/src/java/org/apache/fop/fo/flow/BidiOverride.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. @@ -54,12 +54,12 @@ public class BidiOverride extends FObjMixed { /** * Base constructor - * + * * @param parent FONode that is the parent of this object */ public BidiOverride(FONode parent) { super(parent); - + /* Check to see if this node can have block-level children. * See validateChildNode() below. */ @@ -94,15 +94,15 @@ public class BidiOverride extends FObjMixed { *
    XSL Content Model: marker* (#PCDATA|%inline;|%block;)* *
    Additionally: "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 + * children, unless it has a nearer ancestor that is an * fo:inline-container." */ - 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)) { if (localName.equals("marker")) { if (blockOrInlineItemFound) { - nodesOutOfOrderError(loc, "fo:marker", + nodesOutOfOrderError(loc, "fo:marker", "(#PCDATA|%inline;|%block;)"); } } else if (!isBlockOrInlineItem(nsURI, localName)) { diff --git a/src/java/org/apache/fop/fo/flow/Block.java b/src/java/org/apache/fop/fo/flow/Block.java index 40175ce49..d1df9c21d 100644 --- a/src/java/org/apache/fop/fo/flow/Block.java +++ b/src/java/org/apache/fop/fo/flow/Block.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. @@ -86,10 +86,10 @@ public class Block extends FObjMixed { // private Length textAltitude; // private int visibility; // End of property values - + /** * Base constructor - * + * * @param parent FONode that is the parent of this object * */ @@ -254,22 +254,22 @@ public class Block extends FObjMixed { *
    XSL Content Model: marker* initial-property-set? (#PCDATA|%inline;|%block;)* *
    Additionally: "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 + * children, unless it has a nearer ancestor that is an * fo:inline-container." */ - 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)) { if ("marker".equals(localName)) { if (blockOrInlineItemFound || initialPropertySetFound) { - nodesOutOfOrderError(loc, "fo:marker", + nodesOutOfOrderError(loc, "fo:marker", "initial-property-set? (#PCDATA|%inline;|%block;)"); } } else if ("initial-property-set".equals(localName)) { if (initialPropertySetFound) { tooManyNodesError(loc, "fo:initial-property-set"); } else if (blockOrInlineItemFound) { - nodesOutOfOrderError(loc, "fo:initial-property-set", + nodesOutOfOrderError(loc, "fo:initial-property-set", "(#PCDATA|%inline;|%block;)"); } else { initialPropertySetFound = true; @@ -286,17 +286,17 @@ public class Block extends FObjMixed { public int getLinefeedTreatment() { return linefeedTreatment; } - + /** @return the "white-space-treatment" property */ public int getWhitespaceTreatment() { return whiteSpaceTreatment; } - + /** @return the "white-space-collapse" property */ public int getWhitespaceCollapse() { return whiteSpaceCollapse; } - + /** @return the {@link CommonRelativePosition} */ public CommonRelativePosition getCommonRelativePosition() { return this.commonRelativePosition; @@ -334,5 +334,5 @@ public class Block extends FObjMixed { public int getNameId() { return FO_BLOCK; } - + } diff --git a/src/java/org/apache/fop/fo/flow/BlockContainer.java b/src/java/org/apache/fop/fo/flow/BlockContainer.java index 431dae954..25b3f2a2a 100644 --- a/src/java/org/apache/fop/fo/flow/BlockContainer.java +++ b/src/java/org/apache/fop/fo/flow/BlockContainer.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 BlockContainer extends FObj { /** * Creates a new BlockContainer instance as a child of * the given {@link FONode}. - * + * * @param parent {@link FONode} that is the parent of this object */ public BlockContainer(FONode parent) { @@ -104,13 +104,13 @@ public class BlockContainer extends FObj { /** * {@inheritDoc} *
    XSL Content Model: marker* (%block;)+ - *
    BUT: "In addition an fo:block-container that does not generate an - * absolutely positioned area may have a sequence of zero or more + *
    BUT: "In addition an fo:block-container that does not generate an + * absolutely positioned area may have a sequence of zero or more * fo:markers as its initial children." * The latter refers to block-containers with absolute-position="absolute" * or absolute-position="fixed". */ - 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)) { if ("marker".equals(localName)) { @@ -148,7 +148,7 @@ public class BlockContainer extends FObj { public CommonAbsolutePosition getCommonAbsolutePosition() { return commonAbsolutePosition; } - + /** @return the {@link CommonMarginBlock} */ public CommonMarginBlock getCommonMarginBlock() { return commonMarginBlock; @@ -170,7 +170,7 @@ public class BlockContainer extends FObj { public int getDisplayAlign() { return displayAlign; } - + /** @return the "break-after" property. */ public int getBreakAfter() { return breakAfter; @@ -220,12 +220,12 @@ public class BlockContainer extends FObj { public int getWritingMode() { return writingMode; } - + /** {@inheritDoc} */ public String getLocalName() { return "block-container"; } - + /** * {@inheritDoc} * @return {@link org.apache.fop.fo.Constants#FO_BLOCK_CONTAINER} diff --git a/src/java/org/apache/fop/fo/flow/Character.java b/src/java/org/apache/fop/fo/flow/Character.java index 7fd98b0ef..f76b3225d 100644 --- a/src/java/org/apache/fop/fo/flow/Character.java +++ b/src/java/org/apache/fop/fo/flow/Character.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. @@ -120,7 +120,7 @@ public class Character extends FObj { * {@inheritDoc} *
    XSL Content Model: empty */ - 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); @@ -161,25 +161,25 @@ public class Character extends FObj { public Length getAlignmentAdjust() { return alignmentAdjust; } - + /** @return the "alignment-baseline" property */ public int getAlignmentBaseline() { return alignmentBaseline; } - + /** @return the "baseline-shift" property */ public Length getBaselineShift() { return baselineShift; } - + /** @return the "dominant-baseline" property */ public int getDominantBaseline() { return dominantBaseline; } - + /** @return the "letter-spacing" property */ public Property getLetterSpacing() { - return letterSpacing; + return letterSpacing; } /** @return the "line-height" property */ @@ -189,29 +189,29 @@ public class Character extends FObj { /** @return the "text-decoration" property. */ public CommonTextDecoration getTextDecoration() { - return textDecoration; + return textDecoration; } - + /** @return the "word-spacing" property */ public Property getWordSpacing() { - return wordSpacing; + return wordSpacing; } /** @return the "keep-with-next" property */ public KeepProperty getKeepWithNext() { return keepWithNext; } - + /** @return the "keep-with-previous" property */ public KeepProperty getKeepWithPrevious() { return keepWithPrevious; } - + /** {@inheritDoc} */ public String getLocalName() { return "character"; } - + /** * {@inheritDoc} * @return {@link org.apache.fop.fo.Constants#FO_CHARACTER} @@ -219,16 +219,16 @@ public class Character extends FObj { public int getNameId() { return FO_CHARACTER; } - + private class FOCharIterator extends CharIterator { private boolean bFirst = true; private Character foChar; - + FOCharIterator(Character foChar) { this.foChar = foChar; } - + public boolean hasNext() { return bFirst; } diff --git a/src/java/org/apache/fop/fo/flow/ExternalGraphic.java b/src/java/org/apache/fop/fo/flow/ExternalGraphic.java index bfe54cbd9..fa952000d 100644 --- a/src/java/org/apache/fop/fo/flow/ExternalGraphic.java +++ b/src/java/org/apache/fop/fo/flow/ExternalGraphic.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 @@ import org.apache.fop.fo.properties.FixedLength; * inline area that can be added to the area tree. */ public class ExternalGraphic extends AbstractGraphics { - + // The value of properties relevant for fo:external-graphic. // All but one of the e-g properties are kept in AbstractGraphics private String src; @@ -56,7 +56,7 @@ public class ExternalGraphic extends AbstractGraphics { private int intrinsicWidth; private int intrinsicHeight; private Length intrinsicAlignmentAdjust; - + /** * Create a new ExternalGraphic node that is a child * of the given {@link FONode}. @@ -71,7 +71,7 @@ public class ExternalGraphic extends AbstractGraphics { public void bind(PropertyList pList) throws FOPException { super.bind(pList); src = pList.get(PR_SRC).getString(); - + //Additional processing: obtain the image's intrinsic size and baseline information url = URISpecification.getURL(src); FOUserAgent userAgent = getUserAgent(); @@ -113,7 +113,7 @@ public class ExternalGraphic extends AbstractGraphics { * {@inheritDoc} *
    XSL Content Model: empty */ - 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); diff --git a/src/java/org/apache/fop/fo/flow/Float.java b/src/java/org/apache/fop/fo/flow/Float.java index 90bc423fd..815b30393 100644 --- a/src/java/org/apache/fop/fo/flow/Float.java +++ b/src/java/org/apache/fop/fo/flow/Float.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,15 +39,15 @@ public class Float extends FObj { // End of property values static boolean notImplementedWarningGiven = false; - + /** * Base constructor - * + * * @param parent the parent {@link FONode} */ public Float(FONode parent) { super(parent); - + if (!notImplementedWarningGiven) { getFOValidationEventProducer().unimplementedFeature(this, getName(), getName(), getLocator()); @@ -64,7 +64,7 @@ public class Float extends FObj { * {@inheritDoc} *
    XSL Content Model: (%block;)+ */ - 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)) { if (!isBlockItem(nsURI, localName)) { @@ -84,7 +84,7 @@ public class Float extends FObj { public String getLocalName() { return "float"; } - + /** * {@inheritDoc} * @return {@link org.apache.fop.fo.Constants#FO_FLOAT} diff --git a/src/java/org/apache/fop/fo/flow/Footnote.java b/src/java/org/apache/fop/fo/flow/Footnote.java index 5b13b502c..e73701c3b 100644 --- a/src/java/org/apache/fop/fo/flow/Footnote.java +++ b/src/java/org/apache/fop/fo/flow/Footnote.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,7 +42,7 @@ public class Footnote extends FObj { /** * Create a Footnote instance that is a child of the * given {@link FONode} - * + * * @param parent {@link FONode} that is the parent of this object */ public Footnote(FONode parent) { @@ -53,7 +53,7 @@ public class Footnote extends FObj { public void bind(PropertyList pList) throws FOPException { // No active properties -> do nothing. } - + /** {@inheritDoc} */ protected void startOfNode() throws FOPException { getFOEventHandler().startFootnote(this); @@ -62,7 +62,7 @@ public class Footnote extends FObj { /** * Make sure content model satisfied, if so then tell the * {@link org.apache.fop.fo.FOEventHandler} that we are at the end of the footnote. - * + * * {@inheritDoc} */ protected void endOfNode() throws FOPException { @@ -78,11 +78,11 @@ public class Footnote extends FObj { *
    XSL Content Model: (inline,footnote-body) * @todo implement additional constraint: A fo:footnote is not permitted * to have a fo:float, fo:footnote, or fo:marker as a descendant. - * @todo implement additional constraint: A fo:footnote is not - * permitted to have as a descendant a fo:block-container that + * @todo implement additional constraint: A fo:footnote is not + * permitted to have as a descendant a fo:block-container that * generates an absolutely positioned area. */ - 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)) { if (localName.equals("inline")) { @@ -94,7 +94,7 @@ public class Footnote extends FObj { nodesOutOfOrderError(loc, "fo:inline", "fo:footnote-body"); } else if (footnoteBody != null) { tooManyNodesError(loc, "fo:footnote-body"); - } + } } else { invalidChildError(loc, nsURI, localName); } @@ -112,7 +112,7 @@ public class Footnote extends FObj { /** * Public accessor for inline FO - * + * * @return the {@link Inline} child */ public Inline getFootnoteCitation() { @@ -121,7 +121,7 @@ public class Footnote extends FObj { /** * Public accessor for footnote-body FO - * + * * @return the {@link FootnoteBody} child */ public FootnoteBody getFootnoteBody() { @@ -132,7 +132,7 @@ public class Footnote extends FObj { public String getLocalName() { return "footnote"; } - + /** * {@inheritDoc} * @return {@link org.apache.fop.fo.Constants#FO_FOOTNOTE} diff --git a/src/java/org/apache/fop/fo/flow/FootnoteBody.java b/src/java/org/apache/fop/fo/flow/FootnoteBody.java index 711d56c60..eb26a2009 100644 --- a/src/java/org/apache/fop/fo/flow/FootnoteBody.java +++ b/src/java/org/apache/fop/fo/flow/FootnoteBody.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 FootnoteBody extends FObj { /** * Base constructor - * + * * @param parent FONode that is the parent of this object */ public FootnoteBody(FONode parent) { @@ -57,7 +57,7 @@ public class FootnoteBody extends FObj { /** * Make sure the content model is satisfied, if so then tell the - * {@link org.apache.fop.fo.FOEventHandler} that we are at the + * {@link org.apache.fop.fo.FOEventHandler} that we are at the * end of the footnote-body. * {@inheritDoc} */ @@ -72,7 +72,7 @@ public class FootnoteBody extends FObj { * {@inheritDoc} *
    XSL Content Model: (%block;)+ */ - 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)) { if (!isBlockItem(nsURI, localName)) { @@ -85,7 +85,7 @@ public class FootnoteBody extends FObj { public String getLocalName() { return "footnote-body"; } - + /** * {@inheritDoc} * @return {@link org.apache.fop.fo.Constants#FO_FOOTNOTE_BODY} diff --git a/src/java/org/apache/fop/fo/flow/InitialPropertySet.java b/src/java/org/apache/fop/fo/flow/InitialPropertySet.java index a7f62535f..0df7379f2 100644 --- a/src/java/org/apache/fop/fo/flow/InitialPropertySet.java +++ b/src/java/org/apache/fop/fo/flow/InitialPropertySet.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,7 +53,7 @@ public class InitialPropertySet extends FObj { /** * Base constructor - * + * * @param parent {@link FONode} that is the parent of this object */ public InitialPropertySet(FONode parent) { @@ -72,7 +72,7 @@ public class InitialPropertySet extends FObj { * {@inheritDoc} *
    XSL Content Model: empty */ - 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); @@ -88,7 +88,7 @@ public class InitialPropertySet extends FObj { public String getLocalName() { return "initial-property-set"; } - + /** * {@inheritDoc} * @return {@link org.apache.fop.fo.Constants#FO_INITIAL_PROPERTY_SET} diff --git a/src/java/org/apache/fop/fo/flow/Inline.java b/src/java/org/apache/fop/fo/flow/Inline.java index a770b0f06..dae7d306b 100644 --- a/src/java/org/apache/fop/fo/flow/Inline.java +++ b/src/java/org/apache/fop/fo/flow/Inline.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 Inline extends InlineLevel { /** * Base constructor - * + * * @param parent {@link FONode} that is the parent of this object */ public Inline(FONode parent) { @@ -71,7 +71,7 @@ public class Inline extends InlineLevel { /** {@inheritDoc} */ protected void startOfNode() throws FOPException { super.startOfNode(); - + /* Check to see if this node can have block-level children. * See validateChildNode() below. */ @@ -106,12 +106,12 @@ public class Inline extends InlineLevel { * or fo:footnote may not have block-level children, unless it has a * nearer ancestor that is an fo:inline-container." (paraphrased)
    */ - 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)) { if (localName.equals("marker")) { if (blockOrInlineItemFound) { - nodesOutOfOrderError(loc, "fo:marker", + nodesOutOfOrderError(loc, "fo:marker", "(#PCDATA|%inline;|%block;)"); } } else if (!isBlockOrInlineItem(nsURI, localName)) { @@ -128,27 +128,27 @@ public class Inline extends InlineLevel { public Length getAlignmentAdjust() { return alignmentAdjust; } - + /** @return the "alignment-baseline" property */ public int getAlignmentBaseline() { return alignmentBaseline; } - + /** @return the "baseline-shift" property */ public Length getBaselineShift() { return baselineShift; } - + /** @return the "dominant-baseline" property */ public int getDominantBaseline() { return dominantBaseline; } - + /** {@inheritDoc} */ public String getLocalName() { return "inline"; } - + /** * {@inheritDoc} * @return {@link org.apache.fop.fo.Constants#FO_INLINE} diff --git a/src/java/org/apache/fop/fo/flow/InlineContainer.java b/src/java/org/apache/fop/fo/flow/InlineContainer.java index c26730b3a..d2422a24b 100644 --- a/src/java/org/apache/fop/fo/flow/InlineContainer.java +++ b/src/java/org/apache/fop/fo/flow/InlineContainer.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 @@ import org.apache.fop.fo.properties.SpaceProperty; * fo:inline-container object. */ public class InlineContainer extends FObj { - + // The value of properties relevant for fo:inline-container. private Length alignmentAdjust; private int alignmentBaseline; @@ -69,7 +69,7 @@ public class InlineContainer extends FObj { /** * Base constructor - * + * * @param parent {@link FONode} that is the parent of this object */ public InlineContainer(FONode parent) { @@ -99,7 +99,7 @@ public class InlineContainer extends FObj { * {@inheritDoc} *
    XSL Content Model: marker* (%block;)+ */ - 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)) { if (localName.equals("marker")) { @@ -125,27 +125,27 @@ public class InlineContainer extends FObj { public Length getAlignmentAdjust() { return alignmentAdjust; } - + /** @return the "alignment-baseline" property */ public int getAlignmentBaseline() { return alignmentBaseline; } - + /** @return the "baseline-shift" property */ public Length getBaselineShift() { return baselineShift; } - + /** @return the "block-progression-dimension" property */ public LengthRangeProperty getBlockProgressionDimension() { return blockProgressionDimension; } - + /** @return the "clip" property */ public int getClip() { return clip; } - + /**@return Returns the {@link CommonBorderPaddingBackground} */ public CommonBorderPaddingBackground getCommonBorderPaddingBackground() { return this.commonBorderPaddingBackground; @@ -160,17 +160,17 @@ public class InlineContainer extends FObj { public int getDominantBaseline() { return dominantBaseline; } - + /** @return the "keep-together" property */ public KeepProperty getKeepTogether() { return keepTogether; } - + /** @return the "inline-progression-dimension" property */ public LengthRangeProperty getInlineProgressionDimension() { return inlineProgressionDimension; } - + /** @return the "line-height" property */ public SpaceProperty getLineHeight() { return lineHeight; @@ -180,22 +180,22 @@ public class InlineContainer extends FObj { public int getOverflow() { return overflow; } - + /** @return the "reference-orientation" property */ public int getReferenceOrientation() { return referenceOrientation.getValue(); } - + /** @return the "writing-mode" property */ public int getWritingMode() { return writingMode; } - + /** {@inheritDoc} */ public String getLocalName() { return "inline-container"; } - + /** * {@inheritDoc} * @return {@link org.apache.fop.fo.Constants#FO_INLINE_CONTAINER} @@ -203,5 +203,5 @@ public class InlineContainer extends FObj { public int getNameId() { return FO_INLINE_CONTAINER; } - + } diff --git a/src/java/org/apache/fop/fo/flow/InlineLevel.java b/src/java/org/apache/fop/fo/flow/InlineLevel.java index 92af98d3c..5410e1ca7 100644 --- a/src/java/org/apache/fop/fo/flow/InlineLevel.java +++ b/src/java/org/apache/fop/fo/flow/InlineLevel.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.fo.properties.SpaceProperty; * formatting objects. */ public abstract class InlineLevel extends FObjMixed { - + // The value of properties relevant for inline-level FOs. private CommonBorderPaddingBackground commonBorderPaddingBackground; private CommonMarginInline commonMarginInline; @@ -49,7 +49,7 @@ public abstract class InlineLevel extends FObjMixed { /** * Base constructor - * + * * @param parent {@link FONode} that is the parent of this object */ protected InlineLevel(FONode parent) { @@ -76,7 +76,7 @@ public abstract class InlineLevel extends FObjMixed { /** @return the {@link CommonBorderPaddingBackground} */ public CommonBorderPaddingBackground getCommonBorderPaddingBackground() { return commonBorderPaddingBackground; - } + } /** @return the {@link CommonFont} */ public CommonFont getCommonFont() { @@ -92,15 +92,15 @@ public abstract class InlineLevel extends FObjMixed { public SpaceProperty getLineHeight() { return lineHeight; } - + /** @return the "keep-with-next" property */ public KeepProperty getKeepWithNext() { return keepWithNext; } - + /** @return the "keep-with-previous" property */ public KeepProperty getKeepWithPrevious() { return keepWithPrevious; } - + } diff --git a/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java b/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java index 3583087d4..fe478770e 100644 --- a/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java +++ b/src/java/org/apache/fop/fo/flow/InstreamForeignObject.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,7 +38,7 @@ import org.apache.fop.fo.XMLObj; * This is an atomic inline object that contains XML data. */ public class InstreamForeignObject extends AbstractGraphics { - + // The value of properties relevant for fo:instream-foreign-object. // All property values contained in AbstractGraphics // End of property values @@ -48,9 +48,9 @@ public class InstreamForeignObject extends AbstractGraphics { private boolean instrisicSizeDetermined; private Length intrinsicAlignmentAdjust; - + /** - * Constructs an instream-foreign-object object + * Constructs an instream-foreign-object object * (called by {@link org.apache.fop.fo.ElementMapping.Maker}). * * @param parent the parent {@link FONode} @@ -61,7 +61,7 @@ public class InstreamForeignObject extends AbstractGraphics { /** * Make sure content model satisfied, if so then tell the - * {@link org.apache.fop.fo.FOEventHandler} that we are at + * {@link org.apache.fop.fo.FOEventHandler} that we are at * the end of the instream-foreign-object. * {@inheritDoc} */ @@ -76,7 +76,7 @@ public class InstreamForeignObject extends AbstractGraphics { * {@inheritDoc} *
    XSL Content Model: one (1) non-XSL namespace child */ - 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); @@ -89,7 +89,7 @@ public class InstreamForeignObject extends AbstractGraphics { public String getLocalName() { return "instream-foreign-object"; } - + /** * {@inheritDoc} * @return {@link org.apache.fop.fo.Constants#FO_INSTREAM_FOREIGN_OBJECT} @@ -139,7 +139,7 @@ public class InstreamForeignObject extends AbstractGraphics { prepareIntrinsicSize(); return intrinsicAlignmentAdjust; } - + /** {@inheritDoc} */ protected void addChildNode(FONode child) throws FOPException { super.addChildNode(child); @@ -149,5 +149,5 @@ public class InstreamForeignObject extends AbstractGraphics { public XMLObj getChildXMLObj() { return (XMLObj) firstChild; } - + } diff --git a/src/java/org/apache/fop/fo/flow/Leader.java b/src/java/org/apache/fop/fo/flow/Leader.java index b73534d87..d72ed1e63 100644 --- a/src/java/org/apache/fop/fo/flow/Leader.java +++ b/src/java/org/apache/fop/fo/flow/Leader.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 Leader extends InlineLevel { /** * Base constructor - * + * * @param parent {@link FONode} that is the parent of this object */ public Leader(FONode parent) { @@ -130,22 +130,22 @@ public class Leader extends InlineLevel { public Length getAlignmentAdjust() { return alignmentAdjust; } - + /** @return the "alignment-baseline" property */ public int getAlignmentBaseline() { return alignmentBaseline; } - + /** @return the "baseline-shift" property */ public Length getBaselineShift() { return baselineShift; } - + /** @return the "dominant-baseline" property */ public int getDominantBaseline() { return dominantBaseline; } - + /** {@inheritDoc} */ public String getLocalName() { return "leader"; diff --git a/src/java/org/apache/fop/fo/flow/ListBlock.java b/src/java/org/apache/fop/fo/flow/ListBlock.java index 8c7777e6a..dfadc9c02 100644 --- a/src/java/org/apache/fop/fo/flow/ListBlock.java +++ b/src/java/org/apache/fop/fo/flow/ListBlock.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. @@ -56,13 +56,13 @@ public class ListBlock extends FObj { /** extension properties */ private Length widowContentLimit; private Length orphanContentLimit; - + // used for child node validation private boolean hasListItem = false; /** * Base constructor - * + * * @param parent {@link FONode} that is the parent of this object */ public ListBlock(FONode parent) { @@ -89,10 +89,10 @@ public class ListBlock extends FObj { super.startOfNode(); getFOEventHandler().startList(this); } - + /** * Make sure the content model is satisfied, if so then tell the - * {@link org.apache.fop.fo.FOEventHandler} that we are at the end + * {@link org.apache.fop.fo.FOEventHandler} that we are at the end * of the list-block. * {@inheritDoc} */ @@ -107,7 +107,7 @@ public class ListBlock extends FObj { * {@inheritDoc} *
    XSL Content Model: marker* (list-item)+ */ - 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)) { if (localName.equals("marker")) { @@ -171,7 +171,7 @@ public class ListBlock extends FObj { public String getLocalName() { return "list-block"; } - + /** * {@inheritDoc} * @return {@link org.apache.fop.fo.Constants#FO_LIST_BLOCK} diff --git a/src/java/org/apache/fop/fo/flow/ListItem.java b/src/java/org/apache/fop/fo/flow/ListItem.java index 398d91558..95760c00b 100644 --- a/src/java/org/apache/fop/fo/flow/ListItem.java +++ b/src/java/org/apache/fop/fo/flow/ListItem.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. @@ -56,7 +56,7 @@ public class ListItem extends FObj { /** * Base constructor - * + * * @param parent {@link FONode} that is the parent of this object */ public ListItem(FONode parent) { @@ -93,7 +93,7 @@ public class ListItem extends FObj { * {@inheritDoc} *
    XSL Content Model: marker* (list-item-label,list-item-body) */ - 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)) { if (localName.equals("marker")) { @@ -118,12 +118,12 @@ public class ListItem extends FObj { /** * {@inheritDoc} - * @todo see if can/should rely on base class for this + * @todo see if can/should rely on base class for this * (i.e., add to childNodes instead) */ public void addChildNode(FONode child) { int nameId = child.getNameId(); - + if (nameId == FO_LIST_ITEM_LABEL) { label = (ListItemLabel) child; } else if (nameId == FO_LIST_ITEM_BODY) { @@ -184,7 +184,7 @@ public class ListItem extends FObj { public String getLocalName() { return "list-item"; } - + /** * {@inheritDoc} * @return {@link org.apache.fop.fo.Constants#FO_LIST_ITEM} diff --git a/src/java/org/apache/fop/fo/flow/ListItemBody.java b/src/java/org/apache/fop/fo/flow/ListItemBody.java index 226cacd12..853beb20b 100644 --- a/src/java/org/apache/fop/fo/flow/ListItemBody.java +++ b/src/java/org/apache/fop/fo/flow/ListItemBody.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,12 +46,12 @@ public class ListItemBody extends AbstractListItemPart { super.endOfNode(); getFOEventHandler().endListBody(); } - + /** {@inheritDoc} */ public String getLocalName() { return "list-item-body"; } - + /** * {@inheritDoc} * @return {@link org.apache.fop.fo.Constants#FO_LIST_ITEM_BODY} diff --git a/src/java/org/apache/fop/fo/flow/ListItemLabel.java b/src/java/org/apache/fop/fo/flow/ListItemLabel.java index 7fbbe77d3..1c757686c 100644 --- a/src/java/org/apache/fop/fo/flow/ListItemLabel.java +++ b/src/java/org/apache/fop/fo/flow/ListItemLabel.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 @@ public class ListItemLabel extends AbstractListItemPart { /** * Base constructor - * + * * @param parent {@link FONode} that is the parent of this object */ public ListItemLabel(FONode parent) { @@ -53,7 +53,7 @@ public class ListItemLabel extends AbstractListItemPart { public String getLocalName() { return "list-item-label"; } - + /** * {@inheritDoc} * @return {@link org.apache.fop.fo.Constants#FO_LIST_ITEM_LABEL} diff --git a/src/java/org/apache/fop/fo/flow/Marker.java b/src/java/org/apache/fop/fo/flow/Marker.java index ea6721686..1e8b352bb 100644 --- a/src/java/org/apache/fop/fo/flow/Marker.java +++ b/src/java/org/apache/fop/fo/flow/Marker.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 Marker extends FObjMixed { /** * Create a marker fo. - * + * * @param parent the parent {@link FONode} */ public Marker(FONode parent) { @@ -59,32 +59,32 @@ public class Marker extends FObjMixed { /** {@inheritDoc} */ public void bind(PropertyList pList) throws FOPException { if (findAncestor(FO_FLOW) < 0) { - invalidChildError(locator, getParent().getName(), FO_URI, getName(), + invalidChildError(locator, getParent().getName(), FO_URI, getName(), "rule.markerDescendantOfFlow"); } - + markerClassName = pList.get(PR_MARKER_CLASS_NAME).getString(); - + if (markerClassName == null || markerClassName.equals("")) { missingPropertyError("marker-class-name"); - } + } } - + /** - * Retrieve the property list of the given {@link FONode} + * Retrieve the property list of the given {@link FONode} * descendant - * + * * @param foNode the {@link FONode} whose property list is requested * @return the {@link MarkerPropertyList} for the given node */ protected MarkerPropertyList getPropertyListFor(FONode foNode) { - return (MarkerPropertyList) + return (MarkerPropertyList) descendantPropertyLists.get(foNode); } - + /** {@inheritDoc} */ protected void startOfNode() { - FOTreeBuilderContext builderContext = getBuilderContext(); + FOTreeBuilderContext builderContext = getBuilderContext(); // Push a new property list maker which will make MarkerPropertyLists. savePropertyListMaker = builderContext.getPropertyListMaker(); builderContext.setPropertyListMaker(new PropertyListMaker() { @@ -95,7 +95,7 @@ public class Marker extends FObjMixed { } }); } - + /** {@inheritDoc} */ protected void endOfNode() throws FOPException { super.endOfNode(); @@ -112,7 +112,7 @@ public class Marker extends FObjMixed { * the fo:marker's children."
    * @todo implement "additional" constraint, possibly within fo:retrieve-marker */ - 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)) { if (!isBlockOrInlineItem(nsURI, localName)) { @@ -120,12 +120,12 @@ public class Marker extends FObjMixed { } } } - + /** {@inheritDoc} */ protected boolean inMarker() { return true; } - + /** @return the "marker-class-name" property */ public String getMarkerClassName() { return markerClassName; @@ -135,7 +135,7 @@ public class Marker extends FObjMixed { public String getLocalName() { return "marker"; } - + /** * {@inheritDoc} * @return {@link org.apache.fop.fo.Constants#FO_MARKER} @@ -156,15 +156,15 @@ public class Marker extends FObjMixed { * specified properties/attributes as bundles of name-value-namespace * strings */ - protected class MarkerPropertyList extends PropertyList + protected class MarkerPropertyList extends PropertyList implements Attributes { - + /** the array of attributes **/ private MarkerAttribute[] attribs; - + /** * Overriding default constructor - * + * * @param fobj the {@link FObj} to attach * @param parentPropertyList ignored */ @@ -175,34 +175,34 @@ public class Marker extends FObjMixed { */ super(fobj, null); } - + /** * Override that doesn't convert the attributes to {@link Property} * instances, but simply stores the attributes for later processing. - * + * * {@inheritDoc} */ - public void addAttributesToList(Attributes attributes) + public void addAttributesToList(Attributes attributes) throws ValidationException { - + this.attribs = new MarkerAttribute[attributes.getLength()]; String name; String value; String namespace; String qname; - + for (int i = attributes.getLength(); --i >= 0;) { namespace = attributes.getURI(i); qname = attributes.getQName(i); name = attributes.getLocalName(i); value = attributes.getValue(i); - - this.attribs[i] = + + this.attribs[i] = MarkerAttribute.getInstance(namespace, qname, name, value); } } - + /** Null implementation; not used by this type of {@link PropertyList} */ public void putExplicit(int propId, Property value) { //nop @@ -224,7 +224,7 @@ public class Marker extends FObjMixed { /** {@inheritDoc} */ public String getURI(int index) { - if (attribs != null + if (attribs != null && index < attribs.length && index >= 0 && attribs[index] != null) { @@ -236,7 +236,7 @@ public class Marker extends FObjMixed { /** {@inheritDoc} */ public String getLocalName(int index) { - if (attribs != null + if (attribs != null && index < attribs.length && index >= 0 && attribs[index] != null) { @@ -248,7 +248,7 @@ public class Marker extends FObjMixed { /** {@inheritDoc} */ public String getQName(int index) { - if (attribs != null + if (attribs != null && index < attribs.length && index >= 0 && attribs[index] != null) { @@ -265,7 +265,7 @@ public class Marker extends FObjMixed { /** {@inheritDoc} */ public String getValue(int index) { - if (attribs != null + if (attribs != null && index < attribs.length && index >= 0 && attribs[index] != null) { @@ -295,7 +295,7 @@ public class Marker extends FObjMixed { int index = -1; if (attribs != null && qname != null) { for (int i = attribs.length; --i >= 0;) { - if (attribs[i] != null + if (attribs[i] != null && qname.equals(attribs[i].qname)) { break; } @@ -332,18 +332,18 @@ public class Marker extends FObjMixed { return null; } } - + /** Convenience inner class */ private static final class MarkerAttribute { - - private static Map attributeCache = + + private static Map attributeCache = Collections.synchronizedMap(new java.util.WeakHashMap()); protected String namespace; protected String qname; protected String name; protected String value; - + /** * Main constructor * @param namespace the namespace URI @@ -351,14 +351,14 @@ public class Marker extends FObjMixed { * @param name the name * @param value the value */ - private MarkerAttribute(String namespace, String qname, + private MarkerAttribute(String namespace, String qname, String name, String value) { this.namespace = namespace; this.qname = qname; this.name = (name == null ? qname : name); this.value = value; } - + /** * Convenience method, reduces the number * of distinct MarkerAttribute instances @@ -367,13 +367,13 @@ public class Marker extends FObjMixed { * @param qname the fully qualified name of the attribute * @param name the attribute name * @param value the attribute value - * @return the single MarkerAttribute instance corresponding to + * @return the single MarkerAttribute instance corresponding to * the name/value-pair */ private static MarkerAttribute getInstance( String namespace, String qname, String name, String value) { - MarkerAttribute newInstance = + MarkerAttribute newInstance = new MarkerAttribute(namespace, qname, name, value); if (attributeCache.containsKey(newInstance)) { return (MarkerAttribute) attributeCache.get(newInstance); @@ -382,7 +382,7 @@ public class Marker extends FObjMixed { return newInstance; } } - + /** {@inheritDoc} */ public boolean equals(Object o) { if (o instanceof MarkerAttribute) { diff --git a/src/java/org/apache/fop/fo/flow/MultiCase.java b/src/java/org/apache/fop/fo/flow/MultiCase.java index 284d82d63..b2d630ba7 100644 --- a/src/java/org/apache/fop/fo/flow/MultiCase.java +++ b/src/java/org/apache/fop/fo/flow/MultiCase.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,7 +42,7 @@ public class MultiCase extends FObj { /** * Base constructor - * + * * @param parent {@link FONode} that is the parent of this object */ public MultiCase(FONode parent) { diff --git a/src/java/org/apache/fop/fo/flow/MultiProperties.java b/src/java/org/apache/fop/fo/flow/MultiProperties.java index ef015a9c1..091934203 100644 --- a/src/java/org/apache/fop/fo/flow/MultiProperties.java +++ b/src/java/org/apache/fop/fo/flow/MultiProperties.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 MultiProperties extends FObj { /** * Base constructor - * + * * @param parent {@link FONode} that is the parent of this object */ public MultiProperties(FONode parent) { @@ -69,7 +69,7 @@ public class MultiProperties extends FObj { * {@inheritDoc} *
    XSL Content Model: (multi-property-set+, wrapper) */ - 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)) { if (localName.equals("multi-property-set")) { @@ -89,7 +89,7 @@ public class MultiProperties extends FObj { } } } - + /** {@inheritDoc} */ public String getLocalName() { return "multi-properties"; diff --git a/src/java/org/apache/fop/fo/flow/MultiPropertySet.java b/src/java/org/apache/fop/fo/flow/MultiPropertySet.java index 0736976b4..96e73ec97 100644 --- a/src/java/org/apache/fop/fo/flow/MultiPropertySet.java +++ b/src/java/org/apache/fop/fo/flow/MultiPropertySet.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 MultiPropertySet extends FObj { /** * Base constructor - * + * * @param parent {@link FONode} that is the parent of this object */ public MultiPropertySet(FONode parent) { @@ -64,7 +64,7 @@ public class MultiPropertySet extends FObj { * {@inheritDoc} *
    XSL Content Model: empty */ - 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); @@ -75,7 +75,7 @@ public class MultiPropertySet extends FObj { public String getLocalName() { return "multi-property-set"; } - + /** * {@inheritDoc} * @return {@link org.apache.fop.fo.Constants#FO_MULTI_PROPERTY_SET} diff --git a/src/java/org/apache/fop/fo/flow/MultiSwitch.java b/src/java/org/apache/fop/fo/flow/MultiSwitch.java index 81cb2aff9..1db72159e 100644 --- a/src/java/org/apache/fop/fo/flow/MultiSwitch.java +++ b/src/java/org/apache/fop/fo/flow/MultiSwitch.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. @@ -43,7 +43,7 @@ public class MultiSwitch extends FObj { /** * Base constructor - * + * * @param parent {@link FONode} that is the parent of this object */ public MultiSwitch(FONode parent) { @@ -74,7 +74,7 @@ public class MultiSwitch extends FObj { * {@inheritDoc} *
    XSL Content Model: (multi-case+) */ - 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)) { if (!localName.equals("multi-case")) { diff --git a/src/java/org/apache/fop/fo/flow/MultiToggle.java b/src/java/org/apache/fop/fo/flow/MultiToggle.java index bcb1f806a..aacfda8eb 100644 --- a/src/java/org/apache/fop/fo/flow/MultiToggle.java +++ b/src/java/org/apache/fop/fo/flow/MultiToggle.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,12 +38,12 @@ public class MultiToggle extends FObj { // private CommonAccessibility commonAccessibility; // public ToBeImplementedProperty prSwitchTo; // End of property values - + static boolean notImplementedWarningGiven = false; /** * Base constructor - * + * * @param parent {@link FONode} that is the parent of this object */ public MultiToggle(FONode parent) { @@ -66,7 +66,7 @@ public class MultiToggle extends FObj { * {@inheritDoc} *
    XSL Content Model: (#PCDATA|%inline;|%block;)* */ - 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)) { if (!isBlockOrInlineItem(nsURI, localName)) { @@ -79,7 +79,7 @@ public class MultiToggle extends FObj { public String getLocalName() { return "multi-toggle"; } - + /** * {@inheritDoc} * @return {@link org.apache.fop.fo.Constants#FO_MULTI_TOGGLE} diff --git a/src/java/org/apache/fop/fo/flow/PageNumber.java b/src/java/org/apache/fop/fo/flow/PageNumber.java index 3b91c6b44..dc834d708 100644 --- a/src/java/org/apache/fop/fo/flow/PageNumber.java +++ b/src/java/org/apache/fop/fo/flow/PageNumber.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. @@ -68,12 +68,12 @@ public class PageNumber extends FObj { // private int wrapOption; // End of property values - // Properties which are not explicitely listed but are still applicable + // Properties which are not explicitely listed but are still applicable private Color color; - + /** * Base constructor - * + * * @param parent {@link FONode} that is the parent of this object */ public PageNumber(FONode parent) { @@ -113,7 +113,7 @@ public class PageNumber extends FObj { * {@inheritDoc} *
    XSL Content Model: empty */ - 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); @@ -137,34 +137,34 @@ public class PageNumber extends FObj { /** @return the "text-decoration" property. */ public CommonTextDecoration getTextDecoration() { - return textDecoration; + return textDecoration; } /** @return the "alignment-adjust" property */ public Length getAlignmentAdjust() { return alignmentAdjust; } - + /** @return the "alignment-baseline" property */ public int getAlignmentBaseline() { return alignmentBaseline; } - + /** @return the "baseline-shift" property */ public Length getBaselineShift() { return baselineShift; } - + /** @return the "dominant-baseline" property */ public int getDominantBaseline() { return dominantBaseline; } - + /** @return the "line-height" property */ public SpaceProperty getLineHeight() { return lineHeight; } - + /** {@inheritDoc} */ public String getLocalName() { return "page-number"; diff --git a/src/java/org/apache/fop/fo/flow/PageNumberCitation.java b/src/java/org/apache/fop/fo/flow/PageNumberCitation.java index b31bc9a11..0ebb6eb3d 100644 --- a/src/java/org/apache/fop/fo/flow/PageNumberCitation.java +++ b/src/java/org/apache/fop/fo/flow/PageNumberCitation.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. @@ -33,7 +33,7 @@ public class PageNumberCitation extends AbstractPageNumberCitation { /** * Main constructor - * + * * @param parent {@link FONode} that is the parent of this object */ public PageNumberCitation(FONode parent) { diff --git a/src/java/org/apache/fop/fo/flow/PageNumberCitationLast.java b/src/java/org/apache/fop/fo/flow/PageNumberCitationLast.java index 9e98c06be..6a08568b1 100644 --- a/src/java/org/apache/fop/fo/flow/PageNumberCitationLast.java +++ b/src/java/org/apache/fop/fo/flow/PageNumberCitationLast.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,13 +34,13 @@ public class PageNumberCitationLast extends AbstractPageNumberCitation { /** * Main constructor - * + * * @param parent the parent {@link FONode} */ public PageNumberCitationLast(FONode parent) { super(parent); } - + /** {@inheritDoc} */ protected void startOfNode() throws FOPException { super.startOfNode(); @@ -57,7 +57,7 @@ public class PageNumberCitationLast extends AbstractPageNumberCitation { public String getLocalName() { return "page-number-citation-last"; } - + /** * {@inheritDoc} * @return {@link org.apache.fop.fo.Constants#FO_PAGE_NUMBER_CITATION_LAST} diff --git a/src/java/org/apache/fop/fo/flow/RetrieveMarker.java b/src/java/org/apache/fop/fo/flow/RetrieveMarker.java index c696d3d14..0d0331359 100644 --- a/src/java/org/apache/fop/fo/flow/RetrieveMarker.java +++ b/src/java/org/apache/fop/fo/flow/RetrieveMarker.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,5 +109,5 @@ public class RetrieveMarker extends AbstractRetrieveMarker { */ public int getNameId() { return FO_RETRIEVE_MARKER; - } + } } \ No newline at end of file diff --git a/src/java/org/apache/fop/fo/flow/RetrieveTableMarker.java b/src/java/org/apache/fop/fo/flow/RetrieveTableMarker.java index 9d04e308d..c58ecc628 100644 --- a/src/java/org/apache/fop/fo/flow/RetrieveTableMarker.java +++ b/src/java/org/apache/fop/fo/flow/RetrieveTableMarker.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/fo/flow/Wrapper.java b/src/java/org/apache/fop/fo/flow/Wrapper.java index 5ed594ecc..74072da87 100644 --- a/src/java/org/apache/fop/fo/flow/Wrapper.java +++ b/src/java/org/apache/fop/fo/flow/Wrapper.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,20 +31,20 @@ import org.apache.fop.fo.ValidationException; /** * Class modelling the * fo:wrapper object. - * The fo:wrapper object serves as a property holder for + * The fo:wrapper object serves as a property holder for * its child node objects. */ public class Wrapper extends FObjMixed { // The value of properties relevant for fo:wrapper. // End of property values - + // used for FO validation private boolean blockOrInlineItemFound = false; /** * Create a Wrapper instance that is a child of the * given {@link FONode} - * + * * @param parent {@link FONode} that is the parent of this object */ public Wrapper(FONode parent) { @@ -54,16 +54,16 @@ public class Wrapper extends FObjMixed { /** * {@inheritDoc} *
    XSL Content Model: marker* (#PCDATA|%inline;|%block;)* - *
    Additionally (unimplemented): "An fo:wrapper that is a child of an - * fo:multi-properties is only permitted to have children that would + *
    Additionally (unimplemented): "An fo:wrapper that is a child of an + * fo:multi-properties is only permitted to have children that would * be permitted in place of the fo:multi-properties." */ - 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)) { if ("marker".equals(localName)) { if (blockOrInlineItemFound) { - nodesOutOfOrderError(loc, "fo:marker", + nodesOutOfOrderError(loc, "fo:marker", "(#PCDATA|%inline;|%block;)"); } } else if (isBlockOrInlineItem(nsURI, localName)) { diff --git a/src/java/org/apache/fop/fo/flow/table/BorderResolver.java b/src/java/org/apache/fop/fo/flow/table/BorderResolver.java index 82bdac845..1b856abff 100644 --- a/src/java/org/apache/fop/fo/flow/table/BorderResolver.java +++ b/src/java/org/apache/fop/fo/flow/table/BorderResolver.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 @@ interface BorderResolver { /** * Receives notification of the end of a row. - * + * * @param row the row that has just been finished * @param container the FO element holding the given row */ @@ -37,7 +37,7 @@ interface BorderResolver { /** * Receives notification of the start of a table-header/footer/body. - * + * * @param part the part that has started */ void startPart(TablePart part); diff --git a/src/java/org/apache/fop/fo/flow/table/BorderSpecification.java b/src/java/org/apache/fop/fo/flow/table/BorderSpecification.java index ce6e1b802..3fa3eb15b 100644 --- a/src/java/org/apache/fop/fo/flow/table/BorderSpecification.java +++ b/src/java/org/apache/fop/fo/flow/table/BorderSpecification.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 @@ public/*TODO*/ class BorderSpecification { /** * Creates a new border specification. - * + * * @param borderInfo the border's informations * @param holder the FO element declaring this border */ @@ -56,7 +56,7 @@ public/*TODO*/ class BorderSpecification { /** * Returns this border's informations. - * + * * @return this border's informations */ public/*TODO*/ BorderInfo getBorderInfo() { @@ -65,7 +65,7 @@ public/*TODO*/ class BorderSpecification { /** * Returns the FO element declaring this border. - * + * * @return one of {@link Constants#FO_TABLE}, {@link Constants#FO_TABLE_COLUMN}, * {@link Constants#FO_TABLE_HEADER}, {@link Constants#FO_TABLE_FOOTER}, * {@link Constants#FO_TABLE_BODY}, {@link Constants#FO_TABLE_ROW}, diff --git a/src/java/org/apache/fop/fo/flow/table/CollapsingBorderResolver.java b/src/java/org/apache/fop/fo/flow/table/CollapsingBorderResolver.java index 3a887166a..783c2ff8f 100644 --- a/src/java/org/apache/fop/fo/flow/table/CollapsingBorderResolver.java +++ b/src/java/org/apache/fop/fo/flow/table/CollapsingBorderResolver.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. @@ -82,7 +82,7 @@ class CollapsingBorderResolver implements BorderResolver { /** * Integrates border-before specified on the table and its column. - * + * * @param row the first row of the table (in the header, or in the body if the * table has no header) * @param withNormal @@ -103,7 +103,7 @@ class CollapsingBorderResolver implements BorderResolver { /** * Resolves border-after for the first row, border-before for the second one. - * + * * @param rowBefore * @param rowAfter */ @@ -129,7 +129,7 @@ class CollapsingBorderResolver implements BorderResolver { /** * Integrates border-after specified on the table and its columns. - * + * * @param row the last row of the footer, or of the last body if the table has no * footer * @param withNormal @@ -149,7 +149,7 @@ class CollapsingBorderResolver implements BorderResolver { * Integrates either border-before specified on the table and its columns if the * table has no header, or border-after specified on the cells of the header's * last row. For the case the grid unit are at the top of a page. - * + * * @param row */ void integrateLeadingBorders(List/**/ row) { @@ -165,7 +165,7 @@ class CollapsingBorderResolver implements BorderResolver { * Integrates either border-after specified on the table and its columns if the * table has no footer, or border-before specified on the cells of the footer's * first row. For the case the grid unit are at the bottom of a page. - * + * * @param row */ void integrateTrailingBorders(List/**/ row) { @@ -193,7 +193,7 @@ class CollapsingBorderResolver implements BorderResolver { *
  • Integrates the border-before of the containing part, if first row;
  • *
  • Resolves border-start/end between grid units.
  • * - * + * * @param row the row being finished * @param container the containing element */ @@ -402,7 +402,7 @@ class CollapsingBorderResolver implements BorderResolver { * TODO The border resolution must be done only once for each table column, * even if it's repeated; otherwise, re-resolving against the table's borders * will lead to null border specifications. - * + * * Eventually table columns should probably be cloned instead. */ index += col.getNumberColumnsRepeated(); diff --git a/src/java/org/apache/fop/fo/flow/table/ColumnNumberManager.java b/src/java/org/apache/fop/fo/flow/table/ColumnNumberManager.java index 9fbe415d8..1f73f5f10 100644 --- a/src/java/org/apache/fop/fo/flow/table/ColumnNumberManager.java +++ b/src/java/org/apache/fop/fo/flow/table/ColumnNumberManager.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. @@ -40,7 +40,7 @@ public class ColumnNumberManager { /** * Returns the number of the column that shall receive the next parsed cell. - * + * * @return a column number, 1-based */ int getCurrentColumnNumber() { @@ -50,7 +50,7 @@ public class ColumnNumberManager { /** * Flags columns start to end as occupied, * and updates the number of the next available column. - * + * * @param start start number, inclusive, 1-based * @param end end number, inclusive */ @@ -68,7 +68,7 @@ public class ColumnNumberManager { /** * Resets the record of occupied columns, taking into account columns already occupied * by previous spanning cells, and computes the number of the first free column. - * + * * @param pendingSpans List<PendingSpan> of possible spans over the next row */ void prepareForNextRow(List pendingSpans) { @@ -95,7 +95,7 @@ public class ColumnNumberManager { /** * Checks whether a given column-number is already in use * for the current row. - * + * * @param colNr the column-number to check * @return true if column-number is already occupied */ diff --git a/src/java/org/apache/fop/fo/flow/table/ColumnNumberManagerHolder.java b/src/java/org/apache/fop/fo/flow/table/ColumnNumberManagerHolder.java index 5b253709b..6eb6bab53 100644 --- a/src/java/org/apache/fop/fo/flow/table/ColumnNumberManagerHolder.java +++ b/src/java/org/apache/fop/fo/flow/table/ColumnNumberManagerHolder.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 @@ public interface ColumnNumberManagerHolder { /** * Returns the encapsulated ColumnNumberManage instance. - * + * * @return a {@link ColumnNumberManager} instance */ ColumnNumberManager getColumnNumberManager(); diff --git a/src/java/org/apache/fop/fo/flow/table/ConditionalBorder.java b/src/java/org/apache/fop/fo/flow/table/ConditionalBorder.java index 389681f1d..5ff01b7fa 100644 --- a/src/java/org/apache/fop/fo/flow/table/ConditionalBorder.java +++ b/src/java/org/apache/fop/fo/flow/table/ConditionalBorder.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 ConditionalBorder { /** * Creates a new conditional border. - * + * * @param borderSpecification the border specification to take as a basis * @param collapsingBorderModel the model that will be used to resolved borders */ @@ -83,7 +83,7 @@ public class ConditionalBorder { /** * Resolves and updates the relevant parts of this border as well as the given one. - * + * * @param competitor * @param withNormal * @param withLeadingTrailing @@ -122,7 +122,7 @@ public class ConditionalBorder { * {@link #integrateSegment(ConditionalBorder, boolean, boolean, boolean)}, this * method nicely handles the case where the CollapsingBorderModel returns null, by * keeping the components to their old values. - * + * * @param competitor * @param withNormal * @param withLeadingTrailing @@ -156,7 +156,7 @@ public class ConditionalBorder { /** * Updates this border after taking into account the given segment. The * CollapsingBorderModel is not expected to return null. - * + * * @param segment * @param withNormal * @param withLeadingTrailing @@ -181,7 +181,7 @@ public class ConditionalBorder { /** * Returns a shallow copy of this border. - * + * * @return a copy of this border */ ConditionalBorder copy() { @@ -195,7 +195,7 @@ public class ConditionalBorder { /** * Returns a default border specification. - * + * * @param collapsingBorderModel the model that will be used to resolve borders * @return a border with style 'none' for all of the three components */ diff --git a/src/java/org/apache/fop/fo/flow/table/EffRow.java b/src/java/org/apache/fop/fo/flow/table/EffRow.java index fc8209b01..16d507303 100644 --- a/src/java/org/apache/fop/fo/flow/table/EffRow.java +++ b/src/java/org/apache/fop/fo/flow/table/EffRow.java @@ -34,19 +34,19 @@ import org.apache.fop.util.BreakUtil; * the row as well as some additional values. */ public class EffRow { - + /** Indicates that the row is the first in a table-body */ public static final int FIRST_IN_PART = GridUnit.FIRST_IN_PART; /** Indicates that the row is the last in a table-body */ public static final int LAST_IN_PART = GridUnit.LAST_IN_PART; - + private List gridUnits = new java.util.ArrayList(); private int index; /** One of HEADER, FOOTER, BODY */ private int bodyType; private MinOptMax height; private MinOptMax explicitHeight; - + /** * Creates a new effective row instance. * @param index index of the row @@ -70,45 +70,45 @@ public class EffRow { public int getIndex() { return this.index; } - + /** - * @return an indicator what type of body this EffRow is in (one of HEADER, FOOTER, BODY + * @return an indicator what type of body this EffRow is in (one of HEADER, FOOTER, BODY * as found on TableRowIterator) */ public int getBodyType() { return this.bodyType; } - + /** @return the table-row FO for this EffRow, or null if there is no table-row. */ public TableRow getTableRow() { return getGridUnit(0).getRow(); } - + /** * Returns the calculated height for this EffRow, including the cells' * bpds/paddings/borders, and the table's border-separation. - * + * * @return the row's height */ public MinOptMax getHeight() { return this.height; } - + /** * Sets the calculated height for this EffRow, including everything (cells' bpds, * paddings, borders, and border-separation). - * + * * @param mom the calculated height */ public void setHeight(MinOptMax mom) { this.height = mom; } - + /** @return the explicit height of the EffRow (as specified through properties) */ public MinOptMax getExplicitHeight() { return this.explicitHeight; } - + /** * Sets the height for this row that resulted from the explicit height properties specified * by the user. @@ -117,12 +117,12 @@ public class EffRow { public void setExplicitHeight(MinOptMax mom) { this.explicitHeight = mom; } - + /** @return the list of GridUnits for this EffRow */ public List getGridUnits() { return gridUnits; } - + /** * Returns the grid unit at a given position. * @param column index of the grid unit in the row (zero based) @@ -131,9 +131,9 @@ public class EffRow { public GridUnit getGridUnit(int column) { return (GridUnit)gridUnits.get(column); } - + /** - * Returns the grid unit at a given position. In contrast to getGridUnit() this + * Returns the grid unit at a given position. In contrast to getGridUnit() this * method returns null if there's no grid unit at the given position. The number of * grid units for row x can be smaller than the number of grid units for row x-1. * @param column index of the grid unit in the row (zero based) @@ -167,7 +167,7 @@ public class EffRow { /** * Returns the strength of the keep constraint if the enclosing (if any) fo:table-row element * of this row, or if any of the cells starting on this row, have keep-with-previous set. - * + * * @return the strength of the keep-with-previous constraint */ public int getKeepWithPreviousStrength() { @@ -189,7 +189,7 @@ public class EffRow { /** * Returns the strength of the keep constraint if the enclosing (if any) fo:table-row element * of this row, or if any of the cells ending on this row, have keep-with-next set. - * + * * @return the strength of the keep-with-next constraint */ public int getKeepWithNextStrength() { @@ -224,7 +224,7 @@ public class EffRow { } return strength; } - + /** * Returns the break class for this row. This is a combination of break-before set on * the first children of any cells starting on this row. @@ -233,7 +233,7 @@ public class EffRow { * belongs to a group of spanned rows (see XSL-FO 1.1, 7.20.2). *

    Note: this works only after getNextKuthElements on the * corresponding TableCellLM have been called!

    - * + * * @return one of {@link Constants#EN_AUTO}, {@link Constants#EN_COLUMN}, {@link * Constants#EN_PAGE}, {@link Constants#EN_EVEN_PAGE}, {@link Constants#EN_ODD_PAGE} */ @@ -257,7 +257,7 @@ public class EffRow { * belongs to a group of spanned rows (see XSL-FO 1.1, 7.20.1). *

    Note: this works only after getNextKuthElements on the * corresponding TableCellLM have been called!

    - * + * * @return 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/fo/flow/table/FixedColRowGroupBuilder.java b/src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java index a7719528a..275905f2d 100644 --- a/src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java +++ b/src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.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/fo/flow/table/GridUnit.java b/src/java/org/apache/fop/fo/flow/table/GridUnit.java index 3d48a6836..229a7177f 100644 --- a/src/java/org/apache/fop/fo/flow/table/GridUnit.java +++ b/src/java/org/apache/fop/fo/flow/table/GridUnit.java @@ -78,7 +78,7 @@ public class GridUnit { /** * Creates a new grid unit. - * + * * @param table the containing table * @param colSpanIndex index of this grid unit in the span, in column direction * @param rowSpanIndex index of this grid unit in the span, in row direction @@ -90,7 +90,7 @@ public class GridUnit { /** * Creates a new grid unit. - * + * * @param cell table cell which occupies this grid unit * @param colSpanIndex index of this grid unit in the span, in column direction * @param rowSpanIndex index of this grid unit in the span, in row direction @@ -103,7 +103,7 @@ public class GridUnit { /** * Creates a new grid unit. - * + * * @param primary the before-start grid unit of the cell containing this grid unit * @param colSpanIndex index of this grid unit in the span, in column direction * @param rowSpanIndex index of this grid unit in the span, in row direction @@ -161,7 +161,7 @@ public class GridUnit { /** * Returns the fo:table-row element (if any) this grid unit belongs to. - * + * * @return the row containing this grid unit, or null if there is no fo:table-row * element in the corresponding table-part */ @@ -175,7 +175,7 @@ public class GridUnit { /** * Returns the before-start grid unit of the cell containing this grid unit. - * + * * @return the before-start grid unit of the cell containing this grid unit. */ public PrimaryGridUnit getPrimary() { @@ -184,7 +184,7 @@ public class GridUnit { /** * Is this grid unit the before-start grid unit of the cell? - * + * * @return true if this grid unit is the before-start grid unit of the cell */ public boolean isPrimary() { @@ -193,7 +193,7 @@ public class GridUnit { /** * Does this grid unit belong to an empty cell? - * + * * @return true if this grid unit belongs to an empty cell */ public boolean isEmpty() { @@ -227,7 +227,7 @@ public class GridUnit { /** * Returns the resolved border-before of this grid unit, in the collapsing-border * model. - * + * * @param which one of {@link ConditionalBorder#NORMAL}, * {@link ConditionalBorder#LEADING_TRAILING} or {@link ConditionalBorder#REST} * @return the corresponding border @@ -249,7 +249,7 @@ public class GridUnit { /** * Returns the resolved border-after of this grid unit, in the collapsing-border * model. - * + * * @param which one of {@link ConditionalBorder#NORMAL}, * {@link ConditionalBorder#LEADING_TRAILING} or {@link ConditionalBorder#REST} * @return the corresponding border @@ -271,7 +271,7 @@ public class GridUnit { /** * Returns the resolved border-start of this grid unit, in the collapsing-border * model. - * + * * @return the corresponding border */ public BorderInfo getBorderStart() { @@ -281,7 +281,7 @@ public class GridUnit { /** * Returns the resolved border-end of this grid unit, in the collapsing-border * model. - * + * * @return the corresponding border */ public BorderInfo getBorderEnd() { @@ -291,7 +291,7 @@ public class GridUnit { /** * Resolve collapsing borders for the given cell. Used in case of the collapsing * border model. - * + * * @param other neighbouring grid unit * @param side the side to resolve (one of * CommonBorderPaddingBackground.BEFORE|AFTER|START|END) @@ -327,7 +327,7 @@ public class GridUnit { /** * For the given side, integrates in the conflict resolution the border segment of the * given parent element. - * + * * @param side the side to consider (either CommonBorderPaddingBackground.BEFORE or * AFTER) * @param parent a table element whose corresponding border coincides on the given @@ -351,7 +351,7 @@ public class GridUnit { /** * For the given side, integrates in the conflict resolution the border segment of the * given parent element. - * + * * @param side the side to consider (one of * CommonBorderPaddingBackground.BEFORE|AFTER|START|END) * @param parent a table element whose corresponding border coincides on the given side @@ -376,7 +376,7 @@ public class GridUnit { /** * For the given side, integrates in the conflict resolution the given border segment. - * + * * @param side the side to consider (one of CommonBorderPaddingBackground.START|END) * @param segment a border specification to integrate at the given side */ @@ -409,7 +409,7 @@ public class GridUnit { /** * Returns a flag for this GridUnit. - * + * * @param which the requested flag * @return the value of the flag */ @@ -419,7 +419,7 @@ public class GridUnit { /** * Sets a flag on a GridUnit. - * + * * @param which the flag to set * @param value the new value for the flag */ @@ -433,7 +433,7 @@ public class GridUnit { /** * Sets the given flag on this grid unit. - * + * * @param which the flag to set */ public void setFlag(int which) { diff --git a/src/java/org/apache/fop/fo/flow/table/PendingSpan.java b/src/java/org/apache/fop/fo/flow/table/PendingSpan.java index 7d1b9c133..321684fae 100644 --- a/src/java/org/apache/fop/fo/flow/table/PendingSpan.java +++ b/src/java/org/apache/fop/fo/flow/table/PendingSpan.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 @@ class PendingSpan { /** * Constructor - * + * * @param rows number of rows spanned */ public PendingSpan(int rows) { diff --git a/src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java b/src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java index a4b064a53..3254e928b 100644 --- a/src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java +++ b/src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java @@ -75,7 +75,7 @@ public class PrimaryGridUnit extends GridUnit { /** * Returns the fo:table-header/footer/body element containing this cell. - * + * * @return the enclosing table part */ public TablePart getTablePart() { @@ -119,7 +119,7 @@ public class PrimaryGridUnit extends GridUnit { * border model the border-separation is included. In the collapsing model only half * of them is counted, since the other halves belong to the neighbouring cells; also, * the returned value is the maximum of the segments of each applicable grid unit. - * + * * @return the sum of the before and after border widths */ public int getBeforeAfterBorderWidth() { @@ -133,7 +133,7 @@ public class PrimaryGridUnit extends GridUnit { * model only half of the border is counted, since the other half belongs to the * preceding cell; also, the returned value is the maximum of the segments of each * applicable grid unit. - * + * * @param rowIndex index of the span for which the border must be computed, 0-based * @param which one of {@link ConditionalBorder#NORMAL}, * {@link ConditionalBorder#LEADING_TRAILING} or {@link ConditionalBorder#REST} @@ -179,7 +179,7 @@ public class PrimaryGridUnit extends GridUnit { * model only half of the border is counted, since the other half belongs to the * following cell; also, the returned value is the maximum of the segments of each * applicable grid unit. - * + * * @param rowIndex index of the span for which the border must be computed, 0-based * @param which one of {@link ConditionalBorder#NORMAL}, * {@link ConditionalBorder#LEADING_TRAILING} or {@link ConditionalBorder#REST} @@ -222,7 +222,7 @@ public class PrimaryGridUnit extends GridUnit { /** * Returns the width of the before-after for the last row-span of this cell. See * {@link #getAfterBorderWidth(int, int)}. - * + * * @param which one of {@link ConditionalBorder#NORMAL}, * {@link ConditionalBorder#LEADING_TRAILING} or {@link ConditionalBorder#REST} * @return the after border width @@ -264,7 +264,7 @@ public class PrimaryGridUnit extends GridUnit { * enclosing table part, of the first row spanned by the cell. Note that if the table * has several table-body children, then the index grows continuously across them; * they are considered to form one single part, the "body of the table". - * + * * @return the index of the row this grid unit belongs to, 0-based. */ public int getRowIndex() { @@ -273,7 +273,7 @@ public class PrimaryGridUnit extends GridUnit { /** * Returns the index of the column this grid unit belongs to. - * + * * @return the column index, 0-based */ public int getColIndex() { @@ -331,7 +331,7 @@ public class PrimaryGridUnit extends GridUnit { /** * Returns the strength of the keep constraint if the first child block (or its descendants) * of this cell has keep-with-previous. - * + * * @return the keep-with-previous strength */ public int getKeepWithPreviousStrength() { @@ -349,7 +349,7 @@ public class PrimaryGridUnit extends GridUnit { /** * Returns the strength of the keep constraint if the last child block (or its descendants) of * this cell has keep-with-next. - * + * * @return the keep-with-next strength */ public int getKeepWithNextStrength() { @@ -366,7 +366,7 @@ public class PrimaryGridUnit extends GridUnit { /** * Returns the class of the before break for the first child element of this cell. - * + * * @return one of {@link Constants#EN_AUTO}, {@link Constants#EN_COLUMN}, {@link * Constants#EN_PAGE}, {@link Constants#EN_EVEN_PAGE}, {@link Constants#EN_ODD_PAGE} */ @@ -376,7 +376,7 @@ public class PrimaryGridUnit extends GridUnit { /** * Don't use, reserved for TableCellLM. TODO - * + * * @param breakBefore the breakBefore to set */ public void setBreakBefore(int breakBefore) { @@ -385,7 +385,7 @@ public class PrimaryGridUnit extends GridUnit { /** * Returns the class of the before after for the last child element of this cell. - * + * * @return one of {@link Constants#EN_AUTO}, {@link Constants#EN_COLUMN}, {@link * Constants#EN_PAGE}, {@link Constants#EN_EVEN_PAGE}, {@link Constants#EN_ODD_PAGE} */ @@ -395,7 +395,7 @@ public class PrimaryGridUnit extends GridUnit { /** * Don't use, reserved for TableCellLM. TODO - * + * * @param breakAfter the breakAfter to set */ public void setBreakAfter(int breakAfter) { diff --git a/src/java/org/apache/fop/fo/flow/table/RowGroupBuilder.java b/src/java/org/apache/fop/fo/flow/table/RowGroupBuilder.java index 9748a77aa..276372bd4 100644 --- a/src/java/org/apache/fop/fo/flow/table/RowGroupBuilder.java +++ b/src/java/org/apache/fop/fo/flow/table/RowGroupBuilder.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. @@ -33,7 +33,7 @@ abstract class RowGroupBuilder { /** * Creates and initialises a new builder for the given table. - * + * * @param t a table */ protected RowGroupBuilder(Table t) { @@ -43,14 +43,14 @@ abstract class RowGroupBuilder { /** * Adds a table-cell to the current row-group, creating {@link GridUnit}s accordingly. - * + * * @param cell the cell to add */ abstract void addTableCell(TableCell cell); /** * Receives notification of the start of an fo:table-row element. - * + * * @param tableRow the row being started */ abstract void startTableRow(TableRow tableRow); @@ -66,17 +66,17 @@ abstract class RowGroupBuilder { * Receives notification of the end of the current row, when the source contains no * fo:table-row element. If the current row finishes the row group, the * {@link TablePart#addRowGroup(List)} method of the given table part will be called. - * + * *

    If the source does contain explicit fo:table-row elements, then the * {@link #endTableRow()} method will be called instead.

    - * + * * @param part the part containing the current row */ abstract void endRow(TablePart part); /** * Receives notification of the start of a table-header/footer/body. - * + * * @param part the part being started */ abstract void startTablePart(TablePart part); @@ -85,14 +85,14 @@ abstract class RowGroupBuilder { * Receives notification of the end of a table-header/footer/body. The current * row-group is checked for emptiness. This row group builder is reset for handling * further possible table parts. - * + * * @throws ValidationException if a row-spanning cell overflows the given table part */ abstract void endTablePart() throws ValidationException; /** * Receives notification of the end of the table. - * + * * @throws ValidationException if a row-spanning cell overflows one of the table's parts */ abstract void endTable() throws ValidationException; diff --git a/src/java/org/apache/fop/fo/flow/table/SeparateBorderResolver.java b/src/java/org/apache/fop/fo/flow/table/SeparateBorderResolver.java index afd05823b..c3cc30676 100644 --- a/src/java/org/apache/fop/fo/flow/table/SeparateBorderResolver.java +++ b/src/java/org/apache/fop/fo/flow/table/SeparateBorderResolver.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/fo/flow/table/Table.java b/src/java/org/apache/fop/fo/flow/table/Table.java index 9feb77c9c..efd1f1c93 100644 --- a/src/java/org/apache/fop/fo/flow/table/Table.java +++ b/src/java/org/apache/fop/fo/flow/table/Table.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. @@ -224,7 +224,7 @@ public class Table extends TableFObj implements ColumnNumberManagerHolder { /** {@inheritDoc} */ public void finalizeNode() throws FOPException { - + if (!tableBodyFound) { missingChildElementError( "(marker*,table-column*,table-header?,table-footer?" @@ -246,9 +246,9 @@ public class Table extends TableFObj implements ColumnNumberManagerHolder { this.propList = null; rowGroupBuilder = null; } - + } - + /** {@inheritDoc} */ protected void addChildNode(FONode child) throws FOPException { @@ -274,7 +274,7 @@ public class Table extends TableFObj implements ColumnNumberManagerHolder { } else { rowGroupBuilder = new VariableColRowGroupBuilder(this); } - + } switch (childId) { case FO_TABLE_FOOTER: @@ -309,7 +309,7 @@ public class Table extends TableFObj implements ColumnNumberManagerHolder { * Creates the appropriate number of additional implicit columns to match the given * column number. Used when the table has no explicit column: the number of columns is * then determined by the row that has the most columns. - * + * * @param columnNumber the table must at least have this number of column * @throws FOPException if there was an error creating the property list for implicit * columns @@ -339,7 +339,7 @@ public class Table extends TableFObj implements ColumnNumberManagerHolder { /** * Adds a column to the columns List, and updates the columnIndex * used for determining initial values for column-number - * + * * @param col the column to add */ private void addColumnNode(TableColumn col) { @@ -385,7 +385,7 @@ public class Table extends TableFObj implements ColumnNumberManagerHolder { /** * Returns the column at the given index. - * + * * @param index index of the column to be retrieved, 0-based * @return the corresponding column (may be an implicitly created column) */ @@ -395,7 +395,7 @@ public class Table extends TableFObj implements ColumnNumberManagerHolder { /** * Returns the number of columns of this table. - * + * * @return the number of columns, implicit or explicit, in this table */ public int getNumberOfColumns() { 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 7c45c21f2..548a9c4fa 100644 --- a/src/java/org/apache/fop/fo/flow/table/TableAndCaption.java +++ b/src/java/org/apache/fop/fo/flow/table/TableAndCaption.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 TableAndCaption extends FObj { // private KeepProperty keepWithPrevious; // private int textAlign; // End of property values - + static boolean notImplementedWarningGiven = false; /** used for FO validation */ @@ -86,7 +86,7 @@ public class TableAndCaption extends FObj { * {@inheritDoc} *
    XSL Content Model: marker* table-caption? table */ - 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)) { 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 b4071e255..0ddfa97e3 100644 --- a/src/java/org/apache/fop/fo/flow/table/TableBody.java +++ b/src/java/org/apache/fop/fo/flow/table/TableBody.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/fo/flow/table/TableCaption.java b/src/java/org/apache/fop/fo/flow/table/TableCaption.java index 80fccb236..bbc9b52bc 100644 --- a/src/java/org/apache/fop/fo/flow/table/TableCaption.java +++ b/src/java/org/apache/fop/fo/flow/table/TableCaption.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. @@ -82,7 +82,7 @@ public class TableCaption extends FObj { * {@inheritDoc} *
    XSL Content Model: marker* (%block;) */ - 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)) { if (localName.equals("marker")) { 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 21da54128..637ee2a9a 100644 --- a/src/java/org/apache/fop/fo/flow/table/TableCell.java +++ b/src/java/org/apache/fop/fo/flow/table/TableCell.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. @@ -108,7 +108,7 @@ public class TableCell extends TableFObj { /** {@inheritDoc} */ public void finalizeNode() throws FOPException { - + if (!blockItemFound) { missingChildElementError("marker* (%block;)+", true); } @@ -118,9 +118,9 @@ public class TableCell extends TableFObj { getUserAgent().getEventBroadcaster()); eventProducer.startEndRowUnderTableRowWarning(this, getLocator()); } - + } - + /** * {@inheritDoc} *
    XSL Content Model: marker* (%block;)+ 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 1d1a29b35..9b4fe755f 100644 --- a/src/java/org/apache/fop/fo/flow/table/TableCellContainer.java +++ b/src/java/org/apache/fop/fo/flow/table/TableCellContainer.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 abstract class TableCellContainer extends TableFObj implements ColumnNumb /** * Returns the enclosing table-header/footer/body of this container. - * + * * @return this for TablePart, or the parent element for TableRow */ abstract TablePart getTablePart(); 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 025f5a74f..5047822da 100644 --- a/src/java/org/apache/fop/fo/flow/table/TableColumn.java +++ b/src/java/org/apache/fop/fo/flow/table/TableColumn.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/fo/flow/table/TableEventProducer.java b/src/java/org/apache/fop/fo/flow/table/TableEventProducer.java index 9c4a82dd6..d6abf609e 100644 --- a/src/java/org/apache/fop/fo/flow/table/TableEventProducer.java +++ b/src/java/org/apache/fop/fo/flow/table/TableEventProducer.java @@ -33,7 +33,7 @@ public interface TableEventProducer extends EventProducer { /** Provider class for the event producer. */ class Provider { - + /** * Returns an event producer. * @param broadcaster the event broadcaster to use @@ -83,7 +83,7 @@ public interface TableEventProducer extends EventProducer { */ 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 @@ -93,7 +93,7 @@ public interface TableEventProducer extends EventProducer { void startEndRowUnderTableRowWarning(Object source, Locator loc); /** - * Column-number or number of cells in the row overflows the number of fo:table-column + * 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 @@ -166,5 +166,5 @@ public interface TableEventProducer extends EventProducer { 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 f459ecd65..ec508580c 100644 --- a/src/java/org/apache/fop/fo/flow/table/TableFObj.java +++ b/src/java/org/apache/fop/fo/flow/table/TableFObj.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. @@ -234,7 +234,7 @@ public abstract class TableFObj extends FObj { setCollapsedBorders(); } } - + /** * Prepares the borders of this element if the collapsing-border model is in use. * Conflict resolution with parent elements is done where applicable. diff --git a/src/java/org/apache/fop/fo/flow/table/TableFooter.java b/src/java/org/apache/fop/fo/flow/table/TableFooter.java index a89a2e431..cfd0136dc 100644 --- a/src/java/org/apache/fop/fo/flow/table/TableFooter.java +++ b/src/java/org/apache/fop/fo/flow/table/TableFooter.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/fo/flow/table/TableHeader.java b/src/java/org/apache/fop/fo/flow/table/TableHeader.java index 7f4173754..a0ad40798 100644 --- a/src/java/org/apache/fop/fo/flow/table/TableHeader.java +++ b/src/java/org/apache/fop/fo/flow/table/TableHeader.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/fo/flow/table/TablePart.java b/src/java/org/apache/fop/fo/flow/table/TablePart.java index 4d20db8c4..b1db59d91 100644 --- a/src/java/org/apache/fop/fo/flow/table/TablePart.java +++ b/src/java/org/apache/fop/fo/flow/table/TablePart.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 abstract class TablePart extends TableCellContainer { public void processNode(String elementName, Locator locator, Attributes attlist, PropertyList pList) throws FOPException { - + super.processNode(elementName, locator, attlist, pList); if (!inMarker()) { Table t = getTable(); @@ -94,7 +94,7 @@ public abstract class TablePart extends TableCellContainer { } columnNumberManager = new ColumnNumberManager(); } - + } /** {@inheritDoc} */ 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 ac6eafc2f..4d11f8780 100644 --- a/src/java/org/apache/fop/fo/flow/table/TableRow.java +++ b/src/java/org/apache/fop/fo/flow/table/TableRow.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. @@ -118,7 +118,7 @@ public class TableRow extends TableCellContainer { columnNumberManager = null; } } - + /** * {@inheritDoc} String, String) *
    XSL Content Model: (table-cell+) diff --git a/src/java/org/apache/fop/fo/flow/table/VariableColRowGroupBuilder.java b/src/java/org/apache/fop/fo/flow/table/VariableColRowGroupBuilder.java index 23c16d1f2..f005c8fbe 100644 --- a/src/java/org/apache/fop/fo/flow/table/VariableColRowGroupBuilder.java +++ b/src/java/org/apache/fop/fo/flow/table/VariableColRowGroupBuilder.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. @@ -43,7 +43,7 @@ class VariableColRowGroupBuilder extends RowGroupBuilder { private static interface Event { /** * Plays this event - * + * * @param rowGroupBuilder the delegate builder which will actually create the row * groups * @throws ValidationException if a row-spanning cell overflows its parent body diff --git a/src/java/org/apache/fop/fo/pagination/AbstractPageSequence.java b/src/java/org/apache/fop/fo/pagination/AbstractPageSequence.java index f0928a8ca..dce36f95c 100644 --- a/src/java/org/apache/fop/fo/pagination/AbstractPageSequence.java +++ b/src/java/org/apache/fop/fo/pagination/AbstractPageSequence.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.fo.PropertyList; * fox:external-document extension object. */ public abstract class AbstractPageSequence extends FObj { - + // The value of properties relevant for fo:page-sequence. protected Numeric initialPageNumber; protected int forcePageCount; @@ -81,7 +81,7 @@ public abstract class AbstractPageSequence extends FObj { */ public void initPageNumber() { int pageNumberType = 0; - + if (initialPageNumber.getEnum() != 0) { // auto | auto-odd | auto-even. startingPageNumber = getRoot().getEndingPageNumberOfPreviousSequence() + 1; @@ -143,7 +143,7 @@ public abstract class AbstractPageSequence extends FObj { public Numeric getInitialPageNumber() { return initialPageNumber; } - + /** * Get the value of the reference-orientation property. * @return the "reference-orientation" property diff --git a/src/java/org/apache/fop/fo/pagination/ColorProfile.java b/src/java/org/apache/fop/fo/pagination/ColorProfile.java index 0af1aa42d..7fac8655e 100644 --- a/src/java/org/apache/fop/fo/pagination/ColorProfile.java +++ b/src/java/org/apache/fop/fo/pagination/ColorProfile.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 ColorProfile extends FObj { * {@inheritDoc} *
    XSL 1.0/FOP: EMPTY (no child nodes permitted) */ - 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); @@ -78,7 +78,7 @@ public class ColorProfile extends FObj { public String getLocalName() { return "color-profile"; } - + /** * {@inheritDoc} * @return {@link org.apache.fop.fo.Constants#FO_COLOR_PROFILE} @@ -86,26 +86,26 @@ public class ColorProfile extends FObj { public int getNameId() { return FO_COLOR_PROFILE; } - - /** + + /** * Get src attribute - * + * * @return value of color-profile src attribute */ public String getSrc() { return this.src; } - + /** * Get rendering-intent attribute - * + * * Returned value is one of * Constants.EN_AUTO * Constants.EN_PERCEPTUAL * Constants.EN_RELATIVE_COLOMETRIC * Constants.EN_SATURATION * Constants.EN_ABSOLUTE_COLORMETRIC - * + * * @return Rendering intent attribute */ public int getRenderingIntent() { diff --git a/src/java/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java b/src/java/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java index 7c76109f4..eaa8c2491 100644 --- a/src/java/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java +++ b/src/java/org/apache/fop/fo/pagination/ConditionalPageMasterReference.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.fo.ValidationException; /** * Class modelling the * fo:conditional-page-master-reference object. - * + * * This is a reference to a page master with a set of conditions. * The conditions must be satisfied for the referenced master to * be used. @@ -45,7 +45,7 @@ public class ConditionalPageMasterReference extends FObj { private int oddOrEven; private int blankOrNotBlank; // End of property values - + /** * Create a ConditionalPageMasterReference instance that is a * child of the given {@link FONode}. @@ -65,7 +65,7 @@ public class ConditionalPageMasterReference extends FObj { if (masterReference == null || masterReference.equals("")) { missingPropertyError("master-reference"); - } + } } /** {@inheritDoc} */ @@ -76,12 +76,12 @@ public class ConditionalPageMasterReference extends FObj { private RepeatablePageMasterAlternatives getConcreteParent() { return (RepeatablePageMasterAlternatives) parent; } - + /** * {@inheritDoc} *
    XSL Content Model: empty */ - protected void validateChildNode(Locator loc, String nsURI, String localName) + protected void validateChildNode(Locator loc, String nsURI, String localName) throws ValidationException { invalidChildError(loc, nsURI, localName); } @@ -158,7 +158,7 @@ public class ConditionalPageMasterReference extends FObj { public String getMasterReference() { return masterReference; } - + /** * Get the value for the page-position property. * @return the page-position property value @@ -166,12 +166,12 @@ public class ConditionalPageMasterReference extends FObj { public int getPagePosition() { return this.pagePosition; } - + /** {@inheritDoc} */ public String getLocalName() { return "conditional-page-master-reference"; } - + /** * {@inheritDoc} * @return {@link org.apache.fop.fo.Constants#FO_CONDITIONAL_PAGE_MASTER_REFERENCE} diff --git a/src/java/org/apache/fop/fo/pagination/Declarations.java b/src/java/org/apache/fop/fo/pagination/Declarations.java index eb24cffe0..1385bccc9 100644 --- a/src/java/org/apache/fop/fo/pagination/Declarations.java +++ b/src/java/org/apache/fop/fo/pagination/Declarations.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 Declarations extends FObj { *
    XSL 1.0: (color-profile)+ (and non-XSL NS nodes) *
    FOP/XSL 1.1: (color-profile)* (and non-XSL NS nodes) */ - 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)) { if (!localName.equals("color-profile")) { @@ -88,7 +88,7 @@ public class Declarations extends FObj { cp.getName(), "color-profile-name", locator); } } else { - log.debug("Ignoring element " + node.getName() + log.debug("Ignoring element " + node.getName() + " inside fo:declarations."); } } @@ -112,7 +112,7 @@ public class Declarations extends FObj { public String getLocalName() { return "declarations"; } - + /** * {@inheritDoc} * @return {@link org.apache.fop.fo.Constants#FO_DECLARATIONS} @@ -120,13 +120,13 @@ public class Declarations extends FObj { public int getNameId() { return FO_DECLARATIONS; } - + /** * Return ColorProfile with given name. - * - * @param cpName Name of ColorProfile, i.e. the value of the color-profile-name attribute of + * + * @param cpName Name of ColorProfile, i.e. the value of the color-profile-name attribute of * the fo:color-profile element - * @return The org.apache.fop.fo.pagination.ColorProfile object associated with this + * @return The org.apache.fop.fo.pagination.ColorProfile object associated with this * color-profile-name or null */ public ColorProfile getColorProfile(String cpName) { @@ -136,6 +136,6 @@ public class Declarations extends FObj { } return profile; } - - + + } diff --git a/src/java/org/apache/fop/fo/pagination/Flow.java b/src/java/org/apache/fop/fo/pagination/Flow.java index d3682fa81..153f06fc1 100644 --- a/src/java/org/apache/fop/fo/pagination/Flow.java +++ b/src/java/org/apache/fop/fo/pagination/Flow.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 @@ public class Flow extends FObj { // The value of properties relevant for fo:flow. private String flowName; // End of property values - + /** used for FO validation */ private boolean blockItemFound = false; @@ -53,7 +53,7 @@ public class Flow extends FObj { super.bind(pList); flowName = pList.get(PR_FLOW_NAME).getString(); } - + /** {@inheritDoc} */ protected void startOfNode() throws FOPException { if (flowName == null || flowName.equals("")) { @@ -92,7 +92,7 @@ public class Flow extends FObj { * {@inheritDoc} *
    XSL Content Model: marker* (%block;)+ */ - 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)) { if (localName.equals("marker")) { @@ -124,7 +124,7 @@ public class Flow extends FObj { public String getLocalName() { return "flow"; } - + /** * {@inheritDoc} * @return {@link org.apache.fop.fo.Constants#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 7f081579d..482ec83c4 100644 --- a/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java +++ b/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.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. @@ -81,11 +81,11 @@ public class LayoutMasterSet extends FObj { * {@inheritDoc} *
    XSL/FOP: (simple-page-master|page-sequence-master)+ */ - 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)) { - if (!localName.equals("simple-page-master") - && !localName.equals("page-sequence-master")) { + if (!localName.equals("simple-page-master") + && !localName.equals("page-sequence-master")) { invalidChildError(loc, nsURI, localName); } } @@ -207,7 +207,7 @@ public class LayoutMasterSet extends FObj { public String getLocalName() { return "layout-master-set"; } - + /** * {@inheritDoc} * @return {@link org.apache.fop.fo.Constants#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 50620f678..485fb67cc 100644 --- a/src/java/org/apache/fop/fo/pagination/PageNumberGenerator.java +++ b/src/java/org/apache/fop/fo/pagination/PageNumberGenerator.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.fo.pagination; /** diff --git a/src/java/org/apache/fop/fo/pagination/PageProductionException.java b/src/java/org/apache/fop/fo/pagination/PageProductionException.java index 068e38ff8..bb09db6f4 100644 --- a/src/java/org/apache/fop/fo/pagination/PageProductionException.java +++ b/src/java/org/apache/fop/fo/pagination/PageProductionException.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 @@ public class PageProductionException extends RuntimeException { private String localizedMessage; private Locator locator; - + /** * Creates a new PageProductionException. * @param message the message @@ -47,7 +47,7 @@ public class PageProductionException extends RuntimeException { super(message); setLocator(locator); } - + /** * Set a location associated with the exception. * @param locator the locator holding the location. @@ -64,7 +64,7 @@ public class PageProductionException extends RuntimeException { public Locator getLocator() { return this.locator; } - + /** * Sets the localized message for this exception. * @param msg the localized message @@ -81,7 +81,7 @@ public class PageProductionException extends RuntimeException { return super.getLocalizedMessage(); } } - + /** Exception factory for {@link PageProductionException}. */ public static class PageProductionExceptionFactory implements ExceptionFactory { @@ -96,11 +96,11 @@ public class PageProductionException extends RuntimeException { } return ex; } - + /** {@inheritDoc} */ public Class getExceptionClass() { return PageProductionException.class; } - - } + + } } diff --git a/src/java/org/apache/fop/fo/pagination/PageSequence.java b/src/java/org/apache/fop/fo/pagination/PageSequence.java index c8f7c66d7..bdcb27198 100644 --- a/src/java/org/apache/fop/fo/pagination/PageSequence.java +++ b/src/java/org/apache/fop/fo/pagination/PageSequence.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 @@ import org.apache.fop.fo.ValidationException; * fo:page-sequence object. */ public class PageSequence extends AbstractPageSequence { - + // The value of properties relevant for fo:page-sequence. private String country; private String language; @@ -87,10 +87,10 @@ public class PageSequence extends AbstractPageSequence { language = pList.get(PR_LANGUAGE).getString(); masterReference = pList.get(PR_MASTER_REFERENCE).getString(); //writingMode = pList.getWritingMode(); - + if (masterReference == null || masterReference.equals("")) { missingPropertyError("master-reference"); - } + } } /** {@inheritDoc} */ @@ -124,7 +124,7 @@ public class PageSequence extends AbstractPageSequence { * {@inheritDoc} XSL Content Model: (title?,static-content*,flow) */ - 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)) { if (localName.equals("title")) { @@ -138,7 +138,7 @@ public class PageSequence extends AbstractPageSequence { } else if (localName.equals("static-content")) { if (mainFlow != null) { nodesOutOfOrderError(loc, "fo:static-content", "fo:flow"); - } + } } else if (localName.equals("flow")) { if (mainFlow != null) { tooManyNodesError(loc, "fo:flow"); @@ -186,8 +186,8 @@ public class PageSequence extends AbstractPageSequence { flowName, flow.getLocator()); } - if (!getRoot().getLayoutMasterSet().regionNameExists(flowName) - && !flowName.equals("xsl-before-float-separator") + if (!getRoot().getLayoutMasterSet().regionNameExists(flowName) + && !flowName.equals("xsl-before-float-separator") && !flowName.equals("xsl-footnote-separator")) { getFOValidationEventProducer().flowNameNotMapped(this, flow.getName(), flowName, flow.getLocator()); @@ -226,7 +226,7 @@ public class PageSequence extends AbstractPageSequence { * Determine if this PageSequence already has a flow with the given flow-name * Used for validation of incoming fo:flow or fo:static-content objects * @param flowName The flow-name to search for - * @return true if flow-name already defined within this page sequence, + * @return true if flow-name already defined within this page sequence, * false otherwise */ public boolean hasFlowName(String flowName) { @@ -237,7 +237,7 @@ public class PageSequence extends AbstractPageSequence { public Map getFlowMap() { return this.flowMap; } - + /** * Public accessor for determining the next page master to use within this page sequence. * @param page the page number of the page to be created @@ -251,9 +251,9 @@ public class PageSequence extends AbstractPageSequence { * @return the SimplePageMaster to use for this page * @throws PageProductionException if there's a problem determining the page master */ - public SimplePageMaster getNextSimplePageMaster(int page, - boolean isFirstPage, - boolean isLastPage, + public SimplePageMaster getNextSimplePageMaster(int page, + boolean isFirstPage, + boolean isLastPage, boolean isOnlyPage, boolean isBlank) throws PageProductionException { @@ -263,13 +263,13 @@ public class PageSequence extends AbstractPageSequence { boolean isOddPage = ((page % 2) == 1); if (log.isDebugEnabled()) { log.debug("getNextSimplePageMaster(page=" + page - + " isOdd=" + isOddPage - + " isFirst=" + isFirstPage + + " isOdd=" + isOddPage + + " isFirst=" + isFirstPage + " isLast=" + isLastPage + " isOnly=" + isOnlyPage + " isBlank=" + isBlank + ")"); } - return pageSequenceMaster.getNextSimplePageMaster(isOddPage, + return pageSequenceMaster.getNextSimplePageMaster(isOddPage, isFirstPage, isLastPage, isOnlyPage, isBlank); } @@ -293,7 +293,7 @@ public class PageSequence extends AbstractPageSequence { return pageSequenceMaster.hasPagePositionLast(); } } - + /** @return true if the page-sequence has a page-master with page-position="only" */ public boolean hasPagePositionOnly() { if (pageSequenceMaster == null) { @@ -302,7 +302,7 @@ public class PageSequence extends AbstractPageSequence { return pageSequenceMaster.hasPagePositionOnly(); } } - + /** * Get the value of the master-reference property. * @return the "master-reference" property @@ -323,7 +323,7 @@ public class PageSequence extends AbstractPageSequence { public int getNameId() { return FO_PAGE_SEQUENCE; } - + /** * Get the value of the country property. * @return the country property value @@ -331,7 +331,7 @@ public class PageSequence extends AbstractPageSequence { public String getCountry() { return this.country; } - + /** * Get the value of the language property. * @return the language property value @@ -347,5 +347,5 @@ public class PageSequence extends AbstractPageSequence { this.mainFlow = null; this.flowMap.clear(); } - + } diff --git a/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java b/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java index a16514705..b1d8d4055 100644 --- a/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java +++ b/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.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,7 +42,7 @@ public class PageSequenceMaster extends FObj { // The value of properties relevant for fo:page-sequence-master. private String masterName; // End of property values - + private LayoutMasterSet layoutMasterSet; private List subSequenceSpecifiers; private SubSequenceSpecifier currentSubSequence; @@ -68,7 +68,7 @@ public class PageSequenceMaster extends FObj { /** {@inheritDoc} */ public void bind(PropertyList pList) throws FOPException { masterName = pList.get(PR_MASTER_NAME).getString(); - + if (masterName == null || masterName.equals("")) { missingPropertyError("master-name"); } @@ -80,7 +80,7 @@ public class PageSequenceMaster extends FObj { layoutMasterSet = parent.getRoot().getLayoutMasterSet(); layoutMasterSet.addPageSequenceMaster(masterName, this); } - + /** {@inheritDoc} */ protected void endOfNode() throws FOPException { if (firstChild == null) { @@ -94,12 +94,12 @@ public class PageSequenceMaster extends FObj { *
    XSL/FOP: (single-page-master-reference|repeatable-page-master-reference| * repeatable-page-master-alternatives)+ */ - 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)) { - if (!"single-page-master-reference".equals(localName) + if (!"single-page-master-reference".equals(localName) && !"repeatable-page-master-reference".equals(localName) - && !"repeatable-page-master-alternatives".equals(localName)) { + && !"repeatable-page-master-alternatives".equals(localName)) { invalidChildError(loc, nsURI, localName); } } @@ -159,19 +159,19 @@ public class PageSequenceMaster extends FObj { } return (currentSubSequence != null); } - + /** @return true if the page-sequence-master has a page-master with page-position="last" */ public boolean hasPagePositionLast() { return (currentSubSequence != null && currentSubSequence.hasPagePositionLast()); } - + /** @return true if the page-sequence-master has a page-master with page-position="only" */ public boolean hasPagePositionOnly() { return (currentSubSequence != null && currentSubSequence.hasPagePositionOnly()); } - + /** * Returns the next simple-page-master. * @param isOddPage True if the next page number is odd @@ -230,7 +230,7 @@ public class PageSequenceMaster extends FObj { public String getLocalName() { return "page-sequence-master"; } - + /** * {@inheritDoc} * @return {@link org.apache.fop.fo.Constants#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 f8a37d8c0..247384770 100644 --- a/src/java/org/apache/fop/fo/pagination/PageSequenceWrapper.java +++ b/src/java/org/apache/fop/fo/pagination/PageSequenceWrapper.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 @@ public class PageSequenceWrapper extends FObj { private String indexClass; private String indexKey; // End of property values - + /** * Create a PageSequenceWrapper instance that is a child of * the given parent {@link FONode}. @@ -59,7 +59,7 @@ public class PageSequenceWrapper extends FObj { * {@inheritDoc} *
    XSL/FOP: (bookmark+) */ - 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)) { if (!(localName.equals("page-sequence") diff --git a/src/java/org/apache/fop/fo/pagination/Region.java b/src/java/org/apache/fop/fo/pagination/Region.java index 753e8f735..87e9c4590 100644 --- a/src/java/org/apache/fop/fo/pagination/Region.java +++ b/src/java/org/apache/fop/fo/pagination/Region.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,7 +46,7 @@ public abstract class Region extends FObj { private Numeric referenceOrientation; private int writingMode; // End of property values - + private SimplePageMaster layoutMaster; /** @@ -68,7 +68,7 @@ public abstract class Region extends FObj { regionName = pList.get(PR_REGION_NAME).getString(); referenceOrientation = pList.get(PR_REFERENCE_ORIENTATION).getNumeric(); writingMode = pList.getWritingMode(); - + // regions may have name, or default if (regionName.equals("")) { regionName = getDefaultRegionName(); @@ -80,7 +80,7 @@ public abstract class Region extends FObj { regionName, getLocator()); } } - + //TODO do we need context for getBPPaddingAndBorder() and getIPPaddingAndBorder()? if ((getCommonBorderPaddingBackground().getBPPaddingAndBorder(false, null) != 0 || getCommonBorderPaddingBackground().getIPPaddingAndBorder(false, null) != 0)) { @@ -93,7 +93,7 @@ public abstract class Region extends FObj { * {@inheritDoc} String, String) *
    XSL Content Model: empty */ - 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); @@ -149,7 +149,7 @@ public abstract class Region extends FObj { * @return the Background Properties (border and padding are not used here). */ public CommonBorderPaddingBackground getCommonBorderPaddingBackground() { - return commonBorderPaddingBackground; + return commonBorderPaddingBackground; } /** @return the "region-name" property. */ @@ -166,12 +166,12 @@ public abstract class Region extends FObj { public int getOverflow() { return overflow; } - + /** @return the display-align property. */ public int getDisplayAlign() { return displayAlign; } - + /** @return the "reference-orientation" property. */ public int getReferenceOrientation() { return referenceOrientation.getValue(); diff --git a/src/java/org/apache/fop/fo/pagination/RegionAfter.java b/src/java/org/apache/fop/fo/pagination/RegionAfter.java index 91aadce76..2189fa67b 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionAfter.java +++ b/src/java/org/apache/fop/fo/pagination/RegionAfter.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 class RegionAfter extends RegionBA { /** {@inheritDoc} */ public Rectangle getViewportRectangle (FODimension reldims, SimplePageMaster spm) { - /* Special rules apply to resolving extent as values are resolved relative + /* Special rules apply to resolving extent as values are resolved relative * to the page size and reference orientation. */ SimplePercentBaseContext pageWidthContext; SimplePercentBaseContext pageHeightContext; if (spm.getReferenceOrientation() % 180 == 0) { - pageWidthContext = new SimplePercentBaseContext(null, + pageWidthContext = new SimplePercentBaseContext(null, LengthBase.CUSTOM_BASE, spm.getPageWidth().getValue()); pageHeightContext = new SimplePercentBaseContext(null, @@ -59,7 +59,7 @@ public class RegionAfter extends RegionBA { spm.getPageHeight().getValue()); } else { // invert width and height since top left are rotated by 90 (cl or ccl) - pageWidthContext = new SimplePercentBaseContext(null, + pageWidthContext = new SimplePercentBaseContext(null, LengthBase.CUSTOM_BASE, spm.getPageHeight().getValue()); pageHeightContext = new SimplePercentBaseContext(null, diff --git a/src/java/org/apache/fop/fo/pagination/RegionBA.java b/src/java/org/apache/fop/fo/pagination/RegionBA.java index 4cedee6d1..149e470cf 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionBA.java +++ b/src/java/org/apache/fop/fo/pagination/RegionBA.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 @@ public abstract class RegionBA extends SideRegion { // The value of properties relevant for fo:region-[before|after]. private int precedence; // End of property values - + /** * Create a RegionBA instance that is a child of the * given parent {@link FONode}. diff --git a/src/java/org/apache/fop/fo/pagination/RegionBefore.java b/src/java/org/apache/fop/fo/pagination/RegionBefore.java index fbcf7e8e7..71ea26818 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionBefore.java +++ b/src/java/org/apache/fop/fo/pagination/RegionBefore.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,13 +50,13 @@ public class RegionBefore extends RegionBA { /** {@inheritDoc} */ public Rectangle getViewportRectangle (FODimension reldims, SimplePageMaster spm) { - /* Special rules apply to resolving extent as values are resolved relative + /* Special rules apply to resolving extent as values are resolved relative * to the page size and reference orientation. */ SimplePercentBaseContext pageWidthContext; SimplePercentBaseContext pageHeightContext; if (spm.getReferenceOrientation() % 180 == 0) { - pageWidthContext = new SimplePercentBaseContext(null, + pageWidthContext = new SimplePercentBaseContext(null, LengthBase.CUSTOM_BASE, spm.getPageWidth().getValue()); pageHeightContext = new SimplePercentBaseContext(null, @@ -64,7 +64,7 @@ public class RegionBefore extends RegionBA { spm.getPageHeight().getValue()); } else { // invert width and height since top left are rotated by 90 (cl or ccl) - pageWidthContext = new SimplePercentBaseContext(null, + pageWidthContext = new SimplePercentBaseContext(null, LengthBase.CUSTOM_BASE, spm.getPageHeight().getValue()); pageHeightContext = new SimplePercentBaseContext(null, diff --git a/src/java/org/apache/fop/fo/pagination/RegionBody.java b/src/java/org/apache/fop/fo/pagination/RegionBody.java index c9dd792db..43499678a 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionBody.java +++ b/src/java/org/apache/fop/fo/pagination/RegionBody.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. @@ -58,7 +58,7 @@ public class RegionBody extends Region { commonMarginBlock = pList.getMarginBlockProps(); columnCount = pList.get(PR_COLUMN_COUNT).getNumeric(); columnGap = pList.get(PR_COLUMN_GAP).getLength(); - + 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 @@ -103,13 +103,13 @@ public class RegionBody extends Region { * all margin properties are configured to using BLOCK_WIDTH. * That's why we 'cheat' here and setup a context for the height but * use the LengthBase.BLOCK_WIDTH. - * Also the values are resolved relative to the page size + * Also the values are resolved relative to the page size * and reference orientation. */ SimplePercentBaseContext pageWidthContext; SimplePercentBaseContext pageHeightContext; if (spm.getReferenceOrientation() % 180 == 0) { - pageWidthContext = new SimplePercentBaseContext(null, + pageWidthContext = new SimplePercentBaseContext(null, LengthBase.CONTAINING_BLOCK_WIDTH, spm.getPageWidth().getValue()); pageHeightContext = new SimplePercentBaseContext(null, @@ -117,7 +117,7 @@ public class RegionBody extends Region { spm.getPageHeight().getValue()); } else { // invert width and height since top left are rotated by 90 (cl or ccl) - pageWidthContext = new SimplePercentBaseContext(null, + pageWidthContext = new SimplePercentBaseContext(null, LengthBase.CONTAINING_BLOCK_WIDTH, spm.getPageHeight().getValue()); pageHeightContext = new SimplePercentBaseContext(null, @@ -152,7 +152,7 @@ public class RegionBody extends Region { public String getLocalName() { return "region-body"; } - + /** * {@inheritDoc} * @return {@link org.apache.fop.fo.Constants#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 1b1abd53c..611b1edf6 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionEnd.java +++ b/src/java/org/apache/fop/fo/pagination/RegionEnd.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 class RegionEnd extends RegionSE { /** {@inheritDoc} */ public Rectangle getViewportRectangle (FODimension reldims, SimplePageMaster spm) { - /* Special rules apply to resolving extent as values are resolved relative + /* Special rules apply to resolving extent as values are resolved relative * to the page size and reference orientation. */ SimplePercentBaseContext pageWidthContext; SimplePercentBaseContext pageHeightContext; if (spm.getReferenceOrientation() % 180 == 0) { - pageWidthContext = new SimplePercentBaseContext(null, + pageWidthContext = new SimplePercentBaseContext(null, LengthBase.CUSTOM_BASE, spm.getPageWidth().getValue()); pageHeightContext = new SimplePercentBaseContext(null, @@ -59,7 +59,7 @@ public class RegionEnd extends RegionSE { spm.getPageHeight().getValue()); } else { // invert width and height since top left are rotated by 90 (cl or ccl) - pageWidthContext = new SimplePercentBaseContext(null, + pageWidthContext = new SimplePercentBaseContext(null, LengthBase.CUSTOM_BASE, spm.getPageHeight().getValue()); pageHeightContext = new SimplePercentBaseContext(null, @@ -91,7 +91,7 @@ public class RegionEnd extends RegionSE { public String getLocalName() { return "region-end"; } - + /** * {@inheritDoc} * @return {@link org.apache.fop.fo.Constants#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 15f61096b..f106e8a36 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionSE.java +++ b/src/java/org/apache/fop/fo/pagination/RegionSE.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/fo/pagination/RegionStart.java b/src/java/org/apache/fop/fo/pagination/RegionStart.java index e11a8f201..12b578634 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionStart.java +++ b/src/java/org/apache/fop/fo/pagination/RegionStart.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 class RegionStart extends RegionSE { /** {@inheritDoc} */ public Rectangle getViewportRectangle (FODimension reldims, SimplePageMaster spm) { - /* Special rules apply to resolving extent as values are resolved relative + /* Special rules apply to resolving extent as values are resolved relative * to the page size and reference orientation. */ SimplePercentBaseContext pageWidthContext; SimplePercentBaseContext pageHeightContext; if (spm.getReferenceOrientation() % 180 == 0) { - pageWidthContext = new SimplePercentBaseContext(null, + pageWidthContext = new SimplePercentBaseContext(null, LengthBase.CUSTOM_BASE, spm.getPageWidth().getValue()); pageHeightContext = new SimplePercentBaseContext(null, @@ -59,7 +59,7 @@ public class RegionStart extends RegionSE { spm.getPageHeight().getValue()); } else { // invert width and height since top left are rotated by 90 (cl or ccl) - pageWidthContext = new SimplePercentBaseContext(null, + pageWidthContext = new SimplePercentBaseContext(null, LengthBase.CUSTOM_BASE, spm.getPageHeight().getValue()); pageHeightContext = new SimplePercentBaseContext(null, diff --git a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java index 5c06dd40d..d1e710c89 100644 --- a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java +++ b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.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. @@ -43,7 +43,7 @@ public class RepeatablePageMasterAlternatives extends FObj // The value of properties relevant for fo:repeatable-page-master-alternatives. private Property maximumRepeats; // End of property values - + private static final int INFINITE = -1; private int numberConsumed = 0; @@ -86,7 +86,7 @@ public class RepeatablePageMasterAlternatives extends FObj * {@inheritDoc} *
    XSL/FOP: (conditional-page-master-reference+) */ - 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)) { if (!localName.equals("conditional-page-master-reference")) { @@ -168,17 +168,17 @@ public class RepeatablePageMasterAlternatives extends FObj return true; } } - + /** {@inheritDoc} */ public boolean hasPagePositionLast() { return this.hasPagePositionLast; } - + /** {@inheritDoc} */ public boolean hasPagePositionOnly() { return this.hasPagePositionOnly; } - + /** {@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 1cf77675d..60f8e0d6a 100644 --- a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java +++ b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.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,7 +42,7 @@ public class RepeatablePageMasterReference extends FObj private String masterReference; private Property maximumRepeats; // End of property values - + private static final int INFINITE = -1; private int numberConsumed = 0; @@ -60,10 +60,10 @@ public class RepeatablePageMasterReference extends FObj public void bind(PropertyList pList) throws FOPException { masterReference = pList.get(PR_MASTER_REFERENCE).getString(); maximumRepeats = pList.get(PR_MAXIMUM_REPEATS); - + if (masterReference == null || masterReference.equals("")) { missingPropertyError("master-reference"); - } + } } /** {@inheritDoc} */ @@ -76,12 +76,12 @@ public class RepeatablePageMasterReference extends FObj pageSequenceMaster.addSubsequenceSpecifier(this); } } - + /** * {@inheritDoc} *
    XSL Content Model: empty */ - protected void validateChildNode(Locator loc, String nsURI, String localName) + protected void validateChildNode(Locator loc, String nsURI, String localName) throws ValidationException { invalidChildError(loc, nsURI, localName); } @@ -125,7 +125,7 @@ public class RepeatablePageMasterReference extends FObj this.numberConsumed = 0; } - + /** {@inheritDoc} */ public boolean goToPrevious() { if (numberConsumed == 0) { @@ -135,7 +135,7 @@ public class RepeatablePageMasterReference extends FObj return true; } } - + /** {@inheritDoc} */ public boolean hasPagePositionLast() { return false; diff --git a/src/java/org/apache/fop/fo/pagination/Root.java b/src/java/org/apache/fop/fo/pagination/Root.java index c6346e9fb..fcbb54abd 100644 --- a/src/java/org/apache/fop/fo/pagination/Root.java +++ b/src/java/org/apache/fop/fo/pagination/Root.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,12 +63,12 @@ public class Root extends FObj { * Context class used while building the FO tree. */ private FOTreeBuilderContext builderContext; - + /** * FOEventHandler object for this FO Tree */ private FOEventHandler foEventHandler = null; - + /** * Base constructor * @@ -88,7 +88,7 @@ public class Root extends FObj { /** {@inheritDoc} */ protected void endOfNode() throws FOPException { if (!pageSequenceFound || layoutMasterSet == null) { - missingChildElementError("(layout-master-set, declarations?, " + missingChildElementError("(layout-master-set, declarations?, " + "bookmark-tree?, (page-sequence|fox:external-document)+)"); } } @@ -98,14 +98,14 @@ public class Root extends FObj { *
    XSL 1.0 Spec: (layout-master-set,declarations?,page-sequence+) *
    FOP: (layout-master-set, declarations?, fox:bookmarks?, page-sequence+) */ - 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)) { - if (localName.equals("layout-master-set")) { + if (localName.equals("layout-master-set")) { if (layoutMasterSet != null) { tooManyNodesError(loc, "fo:layout-master-set"); } - } else if (localName.equals("declarations")) { + } else if (localName.equals("declarations")) { if (layoutMasterSet == null) { nodesOutOfOrderError(loc, "fo:layout-master-set", "fo:declarations"); } else if (declarations != null) { @@ -123,7 +123,7 @@ public class Root extends FObj { } else if (pageSequenceFound) { nodesOutOfOrderError(loc, "fo:bookmark-tree", "fo:page-sequence"); } - } else if (localName.equals("page-sequence")) { + } else if (localName.equals("page-sequence")) { if (layoutMasterSet == null) { nodesOutOfOrderError(loc, "fo:layout-master-set", "fo:page-sequence"); } else { @@ -142,7 +142,7 @@ public class Root extends FObj { //Ignore non-FO elements under root } } - + /** @inheritDoc */ protected void validateChildNode(Locator loc, FONode child) throws ValidationException { @@ -159,15 +159,15 @@ public class Root extends FObj { this.foEventHandler = foEventHandler; } - /** - * This method overrides the FONode version. The FONode version calls the - * method by the same name for the parent object. Since Root is at the top - * of the tree, it returns the actual FOEventHandler object. Thus, any FONode - * can use this chain to find which FOEventHandler it is being built for. - * @return the FOEventHandler implementation that this Root is attached to - */ - public FOEventHandler getFOEventHandler() { - return foEventHandler; + /** + * This method overrides the FONode version. The FONode version calls the + * method by the same name for the parent object. Since Root is at the top + * of the tree, it returns the actual FOEventHandler object. Thus, any FONode + * can use this chain to find which FOEventHandler it is being built for. + * @return the FOEventHandler implementation that this Root is attached to + */ + public FOEventHandler getFOEventHandler() { + return foEventHandler; } /** @@ -182,7 +182,7 @@ public class Root extends FObj { public FOTreeBuilderContext getBuilderContext() { return this.builderContext; } - + /** * Gets the last page number generated by the previous page-sequence * @return the last page number, 0 if no page sequences yet generated @@ -207,15 +207,15 @@ public class Root extends FObj { * @param additionalPages the total pages generated by the sequence (for statistics) * @throws IllegalArgumentException for negative additional page counts */ - public void notifyPageSequenceFinished(int lastPageNumber, int additionalPages) { - + public void notifyPageSequenceFinished(int lastPageNumber, int additionalPages) { + if (additionalPages >= 0) { totalPagesGenerated += additionalPages; - endingPageNumberOfPreviousSequence = lastPageNumber; + endingPageNumberOfPreviousSequence = lastPageNumber; } else { throw new IllegalArgumentException( "Number of additional pages must be zero or greater."); - } + } } /** diff --git a/src/java/org/apache/fop/fo/pagination/SideRegion.java b/src/java/org/apache/fop/fo/pagination/SideRegion.java index 552ca871b..1b78de73f 100644 --- a/src/java/org/apache/fop/fo/pagination/SideRegion.java +++ b/src/java/org/apache/fop/fo/pagination/SideRegion.java @@ -30,7 +30,7 @@ import org.apache.fop.fo.PropertyList; public abstract class SideRegion extends Region { private Length extent; - + /** * Creates a new side region. * @param parent the parent node @@ -45,10 +45,10 @@ public abstract class SideRegion extends Region { super.bind(pList); extent = pList.get(PR_EXTENT).getLength(); } - + /** @return the "extent" property. */ public Length getExtent() { return extent; } - + } diff --git a/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java b/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java index b296b8579..b0ec96406 100644 --- a/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java +++ b/src/java/org/apache/fop/fo/pagination/SimplePageMaster.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. @@ -80,7 +80,7 @@ public class SimplePageMaster extends FObj { pageWidth = pList.get(PR_PAGE_WIDTH).getLength(); referenceOrientation = pList.get(PR_REFERENCE_ORIENTATION).getNumeric(); writingMode = pList.getWritingMode(); - + if (masterName == null || masterName.equals("")) { missingPropertyError("master-name"); } @@ -112,7 +112,7 @@ public class SimplePageMaster extends FObj { * {@inheritDoc} *
    XSL Content Model: (region-body,region-before?,region-after?,region-start?,region-end?) */ - 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)) { if (localName.equals("region-body")) { @@ -247,12 +247,12 @@ public class SimplePageMaster extends FObj { public Length getPageHeight() { return pageHeight; } - + /** @return the "writing-mode" property. */ public int getWritingMode() { return writingMode; } - + /** @return the "reference-orientation" property. */ public int getReferenceOrientation() { return referenceOrientation.getValue(); diff --git a/src/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java b/src/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java index f58f32d1f..89416a534 100644 --- a/src/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java +++ b/src/java/org/apache/fop/fo/pagination/SinglePageMasterReference.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,13 +34,13 @@ import org.apache.fop.fo.ValidationException; * This is a reference for a single page. It returns the * master name only once until reset. */ -public class SinglePageMasterReference extends FObj +public class SinglePageMasterReference extends FObj implements SubSequenceSpecifier { // The value of properties relevant for fo:single-page-master-reference. private String masterReference; // End of property values - + private static final int FIRST = 0; private static final int DONE = 1; @@ -62,7 +62,7 @@ public class SinglePageMasterReference extends FObj if (masterReference == null || masterReference.equals("")) { missingPropertyError("master-reference"); - } + } } /** {@inheritDoc} */ @@ -70,12 +70,12 @@ public class SinglePageMasterReference extends FObj PageSequenceMaster pageSequenceMaster = (PageSequenceMaster) parent; pageSequenceMaster.addSubsequenceSpecifier(this); } - + /** * {@inheritDoc} *
    XSL Content Model: empty */ - 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); @@ -100,8 +100,8 @@ public class SinglePageMasterReference extends FObj public void reset() { this.state = FIRST; } - - + + /** {@inheritDoc} */ public boolean goToPrevious() { @@ -112,7 +112,7 @@ public class SinglePageMasterReference extends FObj return true; } } - + /** {@inheritDoc} */ public boolean hasPagePositionLast() { return false; @@ -122,7 +122,7 @@ public class SinglePageMasterReference extends FObj public boolean hasPagePositionOnly() { return false; } - + /** {@inheritDoc} */ public String getLocalName() { return "single-page-master-reference"; diff --git a/src/java/org/apache/fop/fo/pagination/StaticContent.java b/src/java/org/apache/fop/fo/pagination/StaticContent.java index 9a5e47d8a..4084a250a 100644 --- a/src/java/org/apache/fop/fo/pagination/StaticContent.java +++ b/src/java/org/apache/fop/fo/pagination/StaticContent.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 @@ public class StaticContent extends Flow { * {@inheritDoc} *
    XSL Content Model: (%block;)+ */ - 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)) { if (!isBlockItem(nsURI, localName)) { diff --git a/src/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.java b/src/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.java index 68c8ed9b9..a8eddf5d3 100644 --- a/src/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.java +++ b/src/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.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.fo.pagination; @@ -25,7 +25,7 @@ package org.apache.fop.fo.pagination; * and are capable of looking up an appropriate {@link SimplePageMaster}. */ public interface SubSequenceSpecifier { - + /** * Returns the name of the next page master. * @param isOddPage True if the next page number is odd @@ -57,9 +57,9 @@ public interface SubSequenceSpecifier { /** @return true if the subsequence has a page master for page-position "last" */ boolean hasPagePositionLast(); - + /** @return true if the subsequence has a page master for page-position "only" */ boolean hasPagePositionOnly(); - + } diff --git a/src/java/org/apache/fop/fo/pagination/Title.java b/src/java/org/apache/fop/fo/pagination/Title.java index 03afcf5f6..5838e6ae1 100644 --- a/src/java/org/apache/fop/fo/pagination/Title.java +++ b/src/java/org/apache/fop/fo/pagination/Title.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,7 +46,7 @@ public class Title extends InlineLevel { * {@inheritDoc} String, String) *
    XSL/FOP: (#PCDATA|%inline;)* */ - 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)) { if (!isInlineItem(nsURI, localName)) { 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 ac1ef66de..5969729d4 100644 --- a/src/java/org/apache/fop/fo/pagination/bookmarks/Bookmark.java +++ b/src/java/org/apache/fop/fo/pagination/bookmarks/Bookmark.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.fo.ValidationException; /** * Class modelling the - * fo:bookmark object, first introduced in the + * fo:bookmark object, first introduced in the * XSL 1.1 WD. */ public class Bookmark extends FObj { @@ -42,7 +42,7 @@ public class Bookmark extends FObj { private String internalDestination; private String externalDestination; private boolean bShow = true; // from starting-state property - + // Valid, but unused properties. Commented out for performance // private CommonAccessibility commonAccessibility; @@ -63,8 +63,8 @@ public class Bookmark extends FObj { internalDestination = pList.get(PR_INTERNAL_DESTINATION).getString(); bShow = (pList.get(PR_STARTING_STATE).getEnum() == EN_SHOW); - // per spec, internal takes precedence if both specified - if (internalDestination.length() > 0) { + // per spec, internal takes precedence if both specified + if (internalDestination.length() > 0) { externalDestination = null; } else if (externalDestination.length() == 0) { // slightly stronger than spec "should be specified" @@ -79,7 +79,7 @@ public class Bookmark extends FObj { * {@inheritDoc} *
    XSL/FOP: (bookmark-title, bookmark*) */ - 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)) { if (localName.equals("bookmark-title")) { @@ -89,7 +89,7 @@ public class Bookmark extends FObj { } else if (localName.equals("bookmark")) { if (bookmarkTitle == null) { nodesOutOfOrderError(loc, "fo:bookmark-title", "fo:bookmark"); - } + } } else { invalidChildError(loc, nsURI, localName); } 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 6cee46752..fc508dc96 100644 --- a/src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTitle.java +++ b/src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTitle.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,7 +46,7 @@ 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 @@ -64,7 +64,7 @@ public class BookmarkTitle extends FObj { * {@inheritDoc} *
    XSL/FOP: empty */ - 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); @@ -79,7 +79,7 @@ public class BookmarkTitle extends FObj { public String getTitle() { return title; } - + /** {@inheritDoc} */ public String getLocalName() { return "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 9df049251..22bf0769b 100644 --- a/src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTree.java +++ b/src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTree.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 BookmarkTree extends FObj { * {@inheritDoc} *
    XSL/FOP: (bookmark+) */ - 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)) { if (!localName.equals("bookmark")) { diff --git a/src/java/org/apache/fop/fo/properties/BackgroundPositionShorthand.java b/src/java/org/apache/fop/fo/properties/BackgroundPositionShorthand.java index 6307ad1c5..709fdf7f2 100644 --- a/src/java/org/apache/fop/fo/properties/BackgroundPositionShorthand.java +++ b/src/java/org/apache/fop/fo/properties/BackgroundPositionShorthand.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. @@ -43,16 +43,16 @@ public class BackgroundPositionShorthand extends ListProperty { /** * Construct an instance of a Maker for the given property. - * + * * @param propId The Constant ID of the property to be made. */ public Maker(int propId) { super(propId); } - - - /** - * {@inheritDoc} + + + /** + * {@inheritDoc} * If only background-position-horizontal is * specified, background-position-vertical is set * to "50%". @@ -60,7 +60,7 @@ public class BackgroundPositionShorthand extends ListProperty { public Property make(PropertyList propertyList, String value, FObj fo) throws PropertyException { Property p = super.make(propertyList, value, fo); if (p.getList().size() == 1) { - /* only background-position-horizontal specified + /* only background-position-horizontal specified * through the shorthand, as a length or percentage: * background-position-vertical=50% (see: XSL-FO 1.1 -- 7.31.2) */ @@ -71,8 +71,8 @@ public class BackgroundPositionShorthand extends ListProperty { return p; } - /** - * {@inheritDoc} + /** + * {@inheritDoc} * Returns a {@link org.apache.fop.datatypes.PercentBase} whose * getDimension() returns 1. */ @@ -92,11 +92,11 @@ public class BackgroundPositionShorthand extends ListProperty { public int getDimension() { return 1; } - + }; } } - + /** * Inner class to provide shorthand parsing capabilities * @@ -109,7 +109,7 @@ public class BackgroundPositionShorthand extends ListProperty { PropertyMaker maker, PropertyList propertyList) throws PropertyException { - + int index = -1; List propList = property.getList(); if (propId == Constants.PR_BACKGROUND_POSITION_HORIZONTAL) { @@ -119,8 +119,8 @@ public class BackgroundPositionShorthand extends ListProperty { } if (index >= 0) { return maker.convertProperty( - (Property) propList.get(index), - propertyList, + (Property) propList.get(index), + propertyList, propertyList.getFObj()); } // else: invalid index? shouldn't happen... return null; diff --git a/src/java/org/apache/fop/fo/properties/BorderWidthPropertyMaker.java b/src/java/org/apache/fop/fo/properties/BorderWidthPropertyMaker.java index 341baca1a..7c2854759 100644 --- a/src/java/org/apache/fop/fo/properties/BorderWidthPropertyMaker.java +++ b/src/java/org/apache/fop/fo/properties/BorderWidthPropertyMaker.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,21 +24,21 @@ import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.expr.PropertyException; /** - * This subclass of LengthProperty.Maker handles the special treatment of + * This subclass of LengthProperty.Maker handles the special treatment of * border width described in 7.7.20. */ public class BorderWidthPropertyMaker extends LengthProperty.Maker { - int borderStyleId = 0; - + int borderStyleId = 0; + /** * Create a length property which check the value of the border-*-style - * property and return a length of 0 when the style is "none". + * property and return a length of 0 when the style is "none". * @param propId the border-*-width of the property. */ public BorderWidthPropertyMaker(int propId) { super(propId); } - + /** * Set the propId of the style property for the same side. * @param borderStyleId @@ -50,9 +50,9 @@ public class BorderWidthPropertyMaker extends LengthProperty.Maker { /** * Check the value of the style property and return a length of 0 when * the style is NONE. - * {@inheritDoc} + * {@inheritDoc} */ - + public Property get(int subpropId, PropertyList propertyList, boolean bTryInherit, boolean bTryDefault) throws PropertyException diff --git a/src/java/org/apache/fop/fo/properties/BoxPropShorthandParser.java b/src/java/org/apache/fop/fo/properties/BoxPropShorthandParser.java index c71bc830f..feee406ab 100644 --- a/src/java/org/apache/fop/fo/properties/BoxPropShorthandParser.java +++ b/src/java/org/apache/fop/fo/properties/BoxPropShorthandParser.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/fo/properties/CharacterProperty.java b/src/java/org/apache/fop/fo/properties/CharacterProperty.java index f42591fe8..c078da0c7 100644 --- a/src/java/org/apache/fop/fo/properties/CharacterProperty.java +++ b/src/java/org/apache/fop/fo/properties/CharacterProperty.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.fo.PropertyList; * Superclass for properties that wrap a character value */ public final class CharacterProperty extends Property { - + /** * Inner class for creating instances of CharacterProperty */ @@ -58,7 +58,7 @@ public final class CharacterProperty extends Property { private CharacterProperty(char character) { this.character = character; } - + public static CharacterProperty getInstance(char character) { return (CharacterProperty) cache.fetch( new CharacterProperty(character)); @@ -85,7 +85,7 @@ public final class CharacterProperty extends Property { return new Character(character).toString(); } - /** + /** * {@inheritDoc} */ public boolean equals(Object obj) { @@ -96,7 +96,7 @@ public final class CharacterProperty extends Property { } } - /** + /** * {@inheritDoc} */ public int hashCode() { diff --git a/src/java/org/apache/fop/fo/properties/ColorProperty.java b/src/java/org/apache/fop/fo/properties/ColorProperty.java index a2a3d2150..925d275af 100644 --- a/src/java/org/apache/fop/fo/properties/ColorProperty.java +++ b/src/java/org/apache/fop/fo/properties/ColorProperty.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,16 +31,16 @@ import org.apache.fop.util.ColorUtil; * Class for properties that wrap Color values */ public final class ColorProperty extends Property { - + /** cache holding canonical ColorProperty instances */ private static final PropertyCache cache = new PropertyCache(ColorProperty.class); - + /** * The color represented by this property. */ protected final Color color; - + /** * Inner class for creating instances of ColorTypeProperty */ @@ -57,7 +57,7 @@ public final class ColorProperty extends Property { * Return a ColorProperty object based on the passed Property object. * This method is called if the Property object built by the parser * isn't the right type for this property. - * + * * @param p * The Property object return by the expression parser * @param propertyList @@ -70,7 +70,7 @@ public final class ColorProperty extends Property { * for invalid or inconsistent FO input */ public Property convertProperty(Property p, - PropertyList propertyList, FObj fo) + PropertyList propertyList, FObj fo) throws PropertyException { if (p instanceof ColorProperty) { return p; @@ -89,10 +89,10 @@ public final class ColorProperty extends Property { /** * Set the color given a particular String. For a full List of supported * values please see ColorUtil. - * + * * @param foUserAgent FOP user agent * @param value RGB value as String to be parsed - * @return the canonical ColorProperty instance corresponding + * @return the canonical ColorProperty instance corresponding * to the given value * @throws PropertyException if the value can't be parsed * @see ColorUtil#parseColorString(FOUserAgent, String) @@ -106,13 +106,13 @@ public final class ColorProperty extends Property { /** * Create a new ColorProperty with a given color. - * + * * @param value the color to use. */ private ColorProperty(Color value) { this.color = value; } - + /** * Returns an AWT instance of this color * @param foUserAgent FOP user agent @@ -141,19 +141,19 @@ public final class ColorProperty extends Property { public Object getObject() { return this; } - + /** {@inheritDoc} */ public boolean equals(Object o) { if (this == o) { return true; } - + if (o instanceof ColorProperty) { return ((ColorProperty) o).color.equals(this.color); } return false; } - + /** {@inheritDoc} */ public int hashCode() { return this.color.hashCode(); diff --git a/src/java/org/apache/fop/fo/properties/CommonAbsolutePosition.java b/src/java/org/apache/fop/fo/properties/CommonAbsolutePosition.java index 36e7377f4..e32e9dbd9 100644 --- a/src/java/org/apache/fop/fo/properties/CommonAbsolutePosition.java +++ b/src/java/org/apache/fop/fo/properties/CommonAbsolutePosition.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,12 +44,12 @@ public class CommonAbsolutePosition { * The "right" property. */ public Length right; - + /** * The "bottom" property. */ public Length bottom; - + /** * The "left" property. */ @@ -64,9 +64,9 @@ public class CommonAbsolutePosition { top = pList.get(Constants.PR_TOP).getLength(); bottom = pList.get(Constants.PR_BOTTOM).getLength(); left = pList.get(Constants.PR_LEFT).getLength(); - right = pList.get(Constants.PR_RIGHT).getLength(); + right = pList.get(Constants.PR_RIGHT).getLength(); } - + public String toString() { StringBuffer sb = new StringBuffer("CommonAbsolutePosition{"); sb.append(" absPos="); diff --git a/src/java/org/apache/fop/fo/properties/CommonAccessibility.java b/src/java/org/apache/fop/fo/properties/CommonAccessibility.java index e97ba5a0a..74edf046b 100644 --- a/src/java/org/apache/fop/fo/properties/CommonAccessibility.java +++ b/src/java/org/apache/fop/fo/properties/CommonAccessibility.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 CommonAccessibility { if ("none".equals(role)) { role = null; } - + } diff --git a/src/java/org/apache/fop/fo/properties/CommonAural.java b/src/java/org/apache/fop/fo/properties/CommonAural.java index f5e20584a..a47f183f1 100644 --- a/src/java/org/apache/fop/fo/properties/CommonAural.java +++ b/src/java/org/apache/fop/fo/properties/CommonAural.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/fo/properties/CommonBorderPaddingBackground.java b/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java index 35913ce3a..94639a5a6 100755 --- a/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java +++ b/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.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,14 +39,14 @@ import org.apache.fop.fo.expr.PropertyException; */ public class CommonBorderPaddingBackground { - /** - * cache holding all canonical instances + /** + * cache holding all canonical instances * (w/ absolute background-position-* and padding-*) */ private static final PropertyCache cache = new PropertyCache(CommonBorderPaddingBackground.class); - + private int hash = -1; - + /** * The "background-attachment" property. */ @@ -91,17 +91,17 @@ public class CommonBorderPaddingBackground { public static final int END = 3; /** - * + * */ public static class BorderInfo { - + /** cache holding all canonical instances */ private static final PropertyCache cache = new PropertyCache(BorderInfo.class); - + private int mStyle; // Enum for border style private Color mColor; // Border color private CondLengthProperty mWidth; - + private int hash = -1; /** @@ -115,7 +115,7 @@ public class CommonBorderPaddingBackground { /** * Returns a BorderInfo instance corresponding to the given values - * + * * @param style the border-style * @param width the border-width * @param color the border-color @@ -149,7 +149,7 @@ public class CommonBorderPaddingBackground { /** * Convenience method returning the border-width, * taking into account values of "none" and "hidden" - * + * * @return the retained border-width */ public int getRetainedWidth() { @@ -173,23 +173,23 @@ public class CommonBorderPaddingBackground { sb.append("}"); return sb.toString(); } - + /** {@inheritDoc} */ public boolean equals(Object obj) { if (this == obj) { return true; } - + if (obj instanceof BorderInfo) { BorderInfo bi = (BorderInfo)obj; return (this.mColor == bi.mColor && this.mStyle == bi.mStyle && this.mWidth == bi.mWidth); } - + return false; } - + /** {@inheritDoc} */ public int hashCode() { if (this.hash == -1) { @@ -207,9 +207,9 @@ public class CommonBorderPaddingBackground { * A border info with style "none". Used as a singleton, in the collapsing-border model, * for elements which don't specify any border on some of their sides. */ - private static final BorderInfo defaultBorderInfo + private static final BorderInfo defaultBorderInfo = BorderInfo.getInstance(Constants.EN_NONE, new ConditionalNullLength(), null); - + /** * A conditional length of value 0. Returned by the * {@link CommonBorderPaddingBackground#getBorderInfo(int)} method when the @@ -265,7 +265,7 @@ public class CommonBorderPaddingBackground { /** * Returns a default BorderInfo of style none. - * + * * @return a BorderInfo instance with style set to {@link Constants#EN_NONE} */ public static BorderInfo getDefaultBorderInfo() { @@ -277,14 +277,14 @@ public class CommonBorderPaddingBackground { /** * Construct a CommonBorderPaddingBackground object. - * + * * @param pList The PropertyList to get properties from. * @throws PropertyException if there's an error while binding the properties */ private CommonBorderPaddingBackground(PropertyList pList) throws PropertyException { backgroundAttachment = pList.get(Constants.PR_BACKGROUND_ATTACHMENT).getEnum(); - + Color bc = pList.get(Constants.PR_BACKGROUND_COLOR).getColor( pList.getFObj().getUserAgent()); if (bc.getAlpha() == 0) { @@ -332,16 +332,16 @@ public class CommonBorderPaddingBackground { } /** - * Obtain a CommonBorderPaddingBackground instance based on the + * Obtain a CommonBorderPaddingBackground instance based on the * related property valus in the given {@link PropertyList} - * + * * @param pList the {@link PropertyList} to use * @return a CommonBorderPaddingBackground instance (cached if possible) * @throws PropertyException in case of an error */ - public static CommonBorderPaddingBackground getInstance(PropertyList pList) + public static CommonBorderPaddingBackground getInstance(PropertyList pList) throws PropertyException { - + CommonBorderPaddingBackground newInstance = new CommonBorderPaddingBackground(pList); CommonBorderPaddingBackground cachedInstance = null; @@ -355,9 +355,9 @@ public class CommonBorderPaddingBackground { && (newInstance.backgroundPositionVertical == null || newInstance.backgroundPositionVertical.isAbsolute())) { cachedInstance = cache.fetch(newInstance); } - + /* for non-cached, or not-yet-cached instances, preload the image */ - if ((cachedInstance == null + if ((cachedInstance == null || cachedInstance == newInstance) && !("".equals(newInstance.backgroundImage))) { //Additional processing: preload image @@ -374,14 +374,14 @@ public class CommonBorderPaddingBackground { } //TODO Report to caller so he can decide to throw an exception } - + return (cachedInstance != null ? cachedInstance : newInstance); } private void initBorderInfo(PropertyList pList, int side, int colorProp, int styleProp, int widthProp, int paddingProp) throws PropertyException { - + padding[side] = pList.get(paddingProp).getCondLength(); // If style = none, force width to 0, don't get Color (spec 7.7.20) int style = pList.get(styleProp).getEnum(); @@ -391,7 +391,7 @@ public class CommonBorderPaddingBackground { pList.get(widthProp).getCondLength(), pList.get(colorProp).getColor(ua)), side); } - + } /** @@ -517,7 +517,7 @@ public class CommonBorderPaddingBackground { /** * The border-color for the given side - * + * * @param side one of {@link #BEFORE}, {@link #AFTER}, {@link #START}, {@link #END} * @return the border-color for the given side */ @@ -531,7 +531,7 @@ public class CommonBorderPaddingBackground { /** * The border-style for the given side - * + * * @param side one of {@link #BEFORE}, {@link #AFTER}, {@link #START}, {@link #END} * @return the border-style for the given side */ @@ -547,7 +547,7 @@ public class CommonBorderPaddingBackground { * Return the padding for the given side, taking into account * the conditionality and evaluating any percentages in the given * context. - * + * * @param side one of {@link #BEFORE}, {@link #AFTER}, {@link #START}, {@link #END} * @param discard true if the conditionality component should be considered * @param context the context for percentage-resolution @@ -620,7 +620,7 @@ public class CommonBorderPaddingBackground { + getBorderStartWidth(false) + getBorderEndWidth(false)) > 0); } - /** + /** * @param context for percentage based evaluation. * @return true if padding is non-zero. */ @@ -634,7 +634,7 @@ public class CommonBorderPaddingBackground { return (borderInfo[BEFORE] != null || borderInfo[AFTER] != null || borderInfo[START] != null || borderInfo[END] != null); } - + /** {@inheritDoc} */ public boolean equals(Object obj) { if (this == obj) { @@ -657,10 +657,10 @@ public class CommonBorderPaddingBackground { && this.padding[START] == cbpb.padding[START] && this.padding[END] == cbpb.padding[END]); } - + return false; } - + /** {@inheritDoc} */ public int hashCode() { if (this.hash == -1) { @@ -681,7 +681,7 @@ public class CommonBorderPaddingBackground { hash = 37 * hash + (padding[END] == null ? 0 : padding[END].hashCode()); this.hash = hash; } - + return this.hash; } } diff --git a/src/java/org/apache/fop/fo/properties/CommonFont.java b/src/java/org/apache/fop/fo/properties/CommonFont.java index ca543a050..11275fdd3 100755 --- a/src/java/org/apache/fop/fo/properties/CommonFont.java +++ b/src/java/org/apache/fop/fo/properties/CommonFont.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,10 +38,10 @@ public final class CommonFont { /** cache holding canonical CommonFont instances (only those with * absolute font-size and font-size-adjust) */ private static final PropertyCache cache = new PropertyCache(CommonFont.class); - + /** hashcode of this instance */ private int hash = 0; - + /** The "font-family" property. */ private final FontFamilyProperty fontFamily; @@ -59,17 +59,17 @@ public final class CommonFont { /** The "font-weight" property. */ private final EnumProperty fontWeight; - + /** The "font-size" property. */ public final Length fontSize; /** The "font-size-adjust" property. */ public final Numeric fontSizeAdjust; - + /** * Construct a CommonFont instance - * + * * @param fontFamily the font-family property * @param fontSelectionStrategy the font-selection-strategy property * @param fontStretch the font-stretch property @@ -84,8 +84,8 @@ public final class CommonFont { EnumProperty fontStretch, EnumProperty fontStyle, EnumProperty fontVariant, - EnumProperty fontWeight, - Length fontSize, + EnumProperty fontWeight, + Length fontSize, Numeric fontSizeAdjust) { this.fontFamily = fontFamily; this.fontSelectionStrategy = fontSelectionStrategy; @@ -103,7 +103,7 @@ public final class CommonFont { * the entire instance will be cached. * If not, then a distinct instance will be returned, with * as much cached information as possible. - * + * * @param pList the PropertyList to get the properties from * @return a CommonFont instance corresponding to the properties * @throws PropertyException if there was a problem getting the properties @@ -117,19 +117,19 @@ public final class CommonFont { EnumProperty fontWeight = (EnumProperty) pList.get(Constants.PR_FONT_WEIGHT); Numeric fontSizeAdjust = pList.get(Constants.PR_FONT_SIZE_ADJUST).getNumeric(); Length fontSize = pList.get(Constants.PR_FONT_SIZE).getLength(); - - CommonFont commonFont = new CommonFont(fontFamily, - fontSelectionStrategy, - fontStretch, - fontStyle, - fontVariant, + + CommonFont commonFont = new CommonFont(fontFamily, + fontSelectionStrategy, + fontStretch, + fontStyle, + fontVariant, fontWeight, fontSize, fontSizeAdjust); - + return cache.fetch(commonFont); } - + /** @return an array with the font-family names */ private String[] getFontFamily() { List lst = fontFamily.getList(); @@ -139,12 +139,12 @@ public final class CommonFont { } return fontFamily; } - + /** @return the first font-family name in the list */ public String getFirstFontFamily() { return ((Property) fontFamily.list.get(0)).getString(); } - + /** @return the "font-selection-strategy" property */ public int getFontSelectionStrategy() { return fontSelectionStrategy.getEnum(); @@ -154,12 +154,12 @@ public final class CommonFont { public int getFontStretch() { return fontStretch.getEnum(); } - + /** @return the "font-style" property */ public int getFontStyle() { return fontStyle.getEnum(); } - + /** @return the "font-variant" property */ public int getFontVariant() { return fontVariant.getEnum(); @@ -169,11 +169,11 @@ public final class CommonFont { public int getFontWeight() { return fontWeight.getEnum(); } - + /** - * Create and return an array of FontTriplets based on + * Create and return an array of FontTriplets based on * the properties stored in the instance variables. - * + * * @param fontInfo * @return a Font object. */ @@ -194,13 +194,13 @@ public final class CommonFont { String style; switch (fontStyle.getEnum()) { - case Constants.EN_ITALIC: + case Constants.EN_ITALIC: style = "italic"; break; - case Constants.EN_OBLIQUE: + case Constants.EN_OBLIQUE: style = "oblique"; break; - case Constants.EN_BACKSLANT: + case Constants.EN_BACKSLANT: style = "backslant"; break; default: @@ -210,22 +210,22 @@ public final class CommonFont { // various kinds of keywords too //int fontVariant = propertyList.get("font-variant").getEnum(); FontTriplet[] triplets = fontInfo.fontLookup( - getFontFamily(), + getFontFamily(), style, font_weight); return triplets; } /** {@inheritDoc} */ public boolean equals(Object o) { - + if (o == null) { return false; } - + if (this == o) { return true; } - + if (o instanceof CommonFont) { CommonFont cf = (CommonFont) o; return (cf.fontFamily == this.fontFamily) @@ -238,12 +238,12 @@ public final class CommonFont { && (cf.fontSizeAdjust == this.fontSizeAdjust); } return false; - + } - + /** {@inheritDoc} */ public int hashCode() { - + if (this.hash == -1) { int hash = 17; hash = 37 * hash + (fontSize == null ? 0 : fontSize.hashCode()); @@ -257,6 +257,6 @@ public final class CommonFont { this.hash = hash; } return hash; - + } } diff --git a/src/java/org/apache/fop/fo/properties/CommonHyphenation.java b/src/java/org/apache/fop/fo/properties/CommonHyphenation.java index a294b2bbd..0e32f250a 100644 --- a/src/java/org/apache/fop/fo/properties/CommonHyphenation.java +++ b/src/java/org/apache/fop/fo/properties/CommonHyphenation.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,11 +37,11 @@ public final class CommonHyphenation { /** Logger */ protected static Log log = LogFactory.getLog(CommonHyphenation.class); - + private static final PropertyCache cache = new PropertyCache(CommonHyphenation.class); - + private int hash = 0; - + /** The "language" property */ public final StringProperty language; @@ -65,7 +65,7 @@ public final class CommonHyphenation { /** * Construct a CommonHyphenation object holding the given properties - * + * */ private CommonHyphenation(StringProperty language, StringProperty country, @@ -82,46 +82,46 @@ public final class CommonHyphenation { this.hyphenationPushCharacterCount = hyphenationPushCharacterCount; this.hyphenationRemainCharacterCount = hyphenationRemainCharacterCount; } - + /** * Gets the canonical CommonHyphenation instance corresponding - * to the values of the related properties present on the given + * to the values of the related properties present on the given * PropertyList - * + * * @param propertyList the PropertyList */ public static CommonHyphenation getInstance(PropertyList propertyList) throws PropertyException { - StringProperty language = + StringProperty language = (StringProperty) propertyList.get(Constants.PR_LANGUAGE); - StringProperty country = + StringProperty country = (StringProperty) propertyList.get(Constants.PR_COUNTRY); - StringProperty script = + StringProperty script = (StringProperty) propertyList.get(Constants.PR_SCRIPT); - EnumProperty hyphenate = + EnumProperty hyphenate = (EnumProperty) propertyList.get(Constants.PR_HYPHENATE); - CharacterProperty hyphenationCharacter = + CharacterProperty hyphenationCharacter = (CharacterProperty) propertyList.get(Constants.PR_HYPHENATION_CHARACTER); - NumberProperty hyphenationPushCharacterCount = + NumberProperty hyphenationPushCharacterCount = (NumberProperty) propertyList.get(Constants.PR_HYPHENATION_PUSH_CHARACTER_COUNT); - NumberProperty hyphenationRemainCharacterCount = + NumberProperty hyphenationRemainCharacterCount = (NumberProperty) propertyList.get(Constants.PR_HYPHENATION_REMAIN_CHARACTER_COUNT); - + CommonHyphenation instance = new CommonHyphenation( - language, - country, - script, - hyphenate, - hyphenationCharacter, - hyphenationPushCharacterCount, + language, + country, + script, + hyphenate, + hyphenationCharacter, + hyphenationPushCharacterCount, hyphenationRemainCharacterCount); - + return cache.fetch(instance); - + } - + private static final char HYPHEN_MINUS = '-'; private static final char MINUS_SIGN = '\u2212'; - + /** * Returns the effective hyphenation character for a font. The hyphenation character specified * in XSL-FO may be substituted if it's not available in the font. @@ -166,13 +166,13 @@ public final class CommonHyphenation { if (warn) { log.warn("Substituted specified hyphenation character (0x" + Integer.toHexString(hyphChar) - + ") with 0x" + Integer.toHexString(effHyphChar) - + " because the font doesn't have the specified hyphenation character: " + + ") with 0x" + Integer.toHexString(effHyphChar) + + " because the font doesn't have the specified hyphenation character: " + font.getFontTriplet()); } return effHyphChar; } - + /** * Returns the IPD for the hyphenation character for a font. * @param font the font @@ -182,7 +182,7 @@ public final class CommonHyphenation { char hyphChar = getHyphChar(font); return font.getCharWidth(hyphChar); } - + /** {@inheritDoc} */ public boolean equals(Object obj) { if (obj == this) { @@ -200,7 +200,7 @@ public final class CommonHyphenation { } return false; } - + /** {@inheritDoc} */ public int hashCode() { if (this.hash == 0) { @@ -209,15 +209,15 @@ public final class CommonHyphenation { hash = 37 * hash + (script == null ? 0 : script.hashCode()); hash = 37 * hash + (country == null ? 0 : country.hashCode()); hash = 37 * hash + (hyphenate == null ? 0 : hyphenate.hashCode()); - hash = 37 * hash + + hash = 37 * hash + (hyphenationCharacter == null ? 0 : hyphenationCharacter.hashCode()); - hash = 37 * hash + + hash = 37 * hash + (hyphenationPushCharacterCount == null ? 0 : hyphenationPushCharacterCount.hashCode()); - hash = 37 * hash + + hash = 37 * hash + (hyphenationRemainCharacterCount == null ? 0 : hyphenationRemainCharacterCount.hashCode()); this.hash = hash; } return this.hash; } - + } diff --git a/src/java/org/apache/fop/fo/properties/CommonMarginBlock.java b/src/java/org/apache/fop/fo/properties/CommonMarginBlock.java index 6ca9e5817..8d63b3d22 100644 --- a/src/java/org/apache/fop/fo/properties/CommonMarginBlock.java +++ b/src/java/org/apache/fop/fo/properties/CommonMarginBlock.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. @@ -86,17 +86,17 @@ public class CommonMarginBlock { startIndent = pList.get(Constants.PR_START_INDENT).getLength(); endIndent = pList.get(Constants.PR_END_INDENT).getLength(); } - + /** {@inheritDoc} */ public String toString() { - return "CommonMarginBlock:\n" - + "Margins (top, bottom, left, right): (" - + marginTop + ", " + marginBottom + ", " + return "CommonMarginBlock:\n" + + "Margins (top, bottom, left, right): (" + + marginTop + ", " + marginBottom + ", " + marginLeft + ", " + marginRight + ")\n" - + "Space (before, after): (" - + spaceBefore + ", " + spaceAfter + ")\n" + + "Space (before, after): (" + + spaceBefore + ", " + spaceAfter + ")\n" + "Indents (start, end): (" + startIndent + ", " + endIndent + ")\n"; } - + } diff --git a/src/java/org/apache/fop/fo/properties/CommonMarginInline.java b/src/java/org/apache/fop/fo/properties/CommonMarginInline.java index eb892d0a4..c578e58b8 100644 --- a/src/java/org/apache/fop/fo/properties/CommonMarginInline.java +++ b/src/java/org/apache/fop/fo/properties/CommonMarginInline.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/fo/properties/CommonRelativePosition.java b/src/java/org/apache/fop/fo/properties/CommonRelativePosition.java index 504fb6362..f28a3edb3 100644 --- a/src/java/org/apache/fop/fo/properties/CommonRelativePosition.java +++ b/src/java/org/apache/fop/fo/properties/CommonRelativePosition.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 CommonRelativePosition { * The "relative-position" property. */ public int relativePosition; - + /** * The "top" property. */ @@ -44,12 +44,12 @@ public class CommonRelativePosition { * The "right" property. */ public Length right; - + /** * The "bottom" property. */ public Length bottom; - + /** * The "left" property. */ @@ -64,7 +64,7 @@ public class CommonRelativePosition { top = pList.get(Constants.PR_TOP).getLength(); bottom = pList.get(Constants.PR_BOTTOM).getLength(); left = pList.get(Constants.PR_LEFT).getLength(); - right = pList.get(Constants.PR_RIGHT).getLength(); + right = pList.get(Constants.PR_RIGHT).getLength(); } } diff --git a/src/java/org/apache/fop/fo/properties/CommonTextDecoration.java b/src/java/org/apache/fop/fo/properties/CommonTextDecoration.java index d56d9a101..f7c11578d 100644 --- a/src/java/org/apache/fop/fo/properties/CommonTextDecoration.java +++ b/src/java/org/apache/fop/fo/properties/CommonTextDecoration.java @@ -39,30 +39,30 @@ public class CommonTextDecoration { private static final int OVERLINE = 2; private static final int LINE_THROUGH = 4; private static final int BLINK = 8; - + private int decoration; private Color underColor; private Color overColor; private Color throughColor; - + /** * Creates a new CommonTextDecoration object with default values. */ public CommonTextDecoration() { } - + /** * Creates a CommonTextDecoration object from a property list. * @param pList the property list to build the object for * @return a CommonTextDecoration object or null if the obj would only have default values * @throws PropertyException if there's a problem while processing the property */ - public static CommonTextDecoration createFromPropertyList(PropertyList pList) + public static CommonTextDecoration createFromPropertyList(PropertyList pList) throws PropertyException { return calcTextDecoration(pList); } - - private static CommonTextDecoration calcTextDecoration(PropertyList pList) + + private static CommonTextDecoration calcTextDecoration(PropertyList pList) throws PropertyException { CommonTextDecoration deco = null; PropertyList parentList = pList.getParentPropertyList(); @@ -76,7 +76,7 @@ public class CommonTextDecoration { List list = textDecoProp.getList(); Iterator i = list.iterator(); while (i.hasNext()) { - Property prop = (Property)i.next(); + Property prop = (Property)i.next(); int propEnum = prop.getEnum(); FOUserAgent ua = (pList == null) ? null @@ -135,7 +135,7 @@ public class CommonTextDecoration { } return deco; } - + /** @return true if underline is active */ public boolean hasUnderline() { return (this.decoration & UNDERLINE) != 0; @@ -155,12 +155,12 @@ public class CommonTextDecoration { public boolean isBlinking() { return (this.decoration & BLINK) != 0; } - + /** @return the color of the underline mark */ public Color getUnderlineColor() { return this.underColor; } - + /** @return the color of the overline mark */ public Color getOverlineColor() { return this.overColor; diff --git a/src/java/org/apache/fop/fo/properties/CompoundPropertyMaker.java b/src/java/org/apache/fop/fo/properties/CompoundPropertyMaker.java index f15050fbe..45f6b2e9f 100644 --- a/src/java/org/apache/fop/fo/properties/CompoundPropertyMaker.java +++ b/src/java/org/apache/fop/fo/properties/CompoundPropertyMaker.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 @@ import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.expr.PropertyException; /** - * This class extends Property.Maker with support for sub-properties. + * This class extends Property.Maker with support for sub-properties. */ public class CompoundPropertyMaker extends PropertyMaker { /** * The list of subproperty makers supported by this compound maker. - */ - private PropertyMaker[] subproperties = + */ + private PropertyMaker[] subproperties = new PropertyMaker[Constants.COMPOUND_COUNT]; /** @@ -63,7 +63,7 @@ public class CompoundPropertyMaker extends PropertyMaker { } } } - + /** * Add a subproperty to this maker. * @param subproperty @@ -72,7 +72,7 @@ public class CompoundPropertyMaker extends PropertyMaker { // Place the base propId in the propId of the subproperty. subproperty.propId &= Constants.COMPOUND_MASK; subproperty.propId |= propId; - + subproperties[getSubpropIndex(subproperty.getPropId())] = subproperty; // Store the first subproperty with a setByShorthand. That subproperty @@ -81,8 +81,8 @@ public class CompoundPropertyMaker extends PropertyMaker { shorthandMaker = subproperty; } } - - + + /** * Return a Maker object which is used to set the values on components * of compound property types, such as "space". @@ -96,11 +96,11 @@ public class CompoundPropertyMaker extends PropertyMaker { public PropertyMaker getSubpropMaker(int subpropertyId) { return subproperties[getSubpropIndex(subpropertyId)]; } - + /** * Calculate the real value of a subproperty by unmasking and shifting * the value into the range [0 - (COMPOUND_COUNT-1)]. - * The value is used as index into the subproperties array. + * The value is used as index into the subproperties array. * @param propId the property id of the sub property. * @return the array index. */ @@ -111,7 +111,7 @@ public class CompoundPropertyMaker extends PropertyMaker { /** * For compound properties which can take enumerate values. - * Delegate the enumeration check to one of the subpropeties. + * Delegate the enumeration check to one of the subpropeties. * @param value the string containing the property value * @return the Property encapsulating the enumerated equivalent of the * input value @@ -136,7 +136,7 @@ public class CompoundPropertyMaker extends PropertyMaker { * Is 0 when retriving a base property. * @param propertyList The PropertyList object being built for this FO. * @param tryInherit true if inherited properties should be examined. - * @param tryDefault true if the default value should be returned. + * @param tryDefault true if the default value should be returned. */ public Property get(int subpropertyId, PropertyList propertyList, boolean tryInherit, boolean tryDefault) @@ -148,7 +148,7 @@ public class CompoundPropertyMaker extends PropertyMaker { } return p; } - + /** * Return a Property object based on the passed Property object. * This method is called if the Property object built by the parser @@ -165,7 +165,7 @@ public class CompoundPropertyMaker extends PropertyMaker { FObj fo) throws PropertyException { // Delegate to the subproperty maker to do conversions. p = shorthandMaker.convertProperty(p, propertyList, fo); - + if (p != null) { Property prop = makeCompound(propertyList, fo); CompoundDatatype pval = (CompoundDatatype) prop.getObject(); @@ -181,7 +181,7 @@ public class CompoundPropertyMaker extends PropertyMaker { } /** - * Make a compound property with default values. + * Make a compound property with default values. * @param propertyList The PropertyList object being built for this FO. * @return the Property object corresponding to the parameters * @throws PropertyException for invalid or inconsisten FO input @@ -193,7 +193,7 @@ public class CompoundPropertyMaker extends PropertyMaker { return makeCompound(propertyList, propertyList.getParentFObj()); } } - + /** * Create a Property object from an attribute specification. * @param propertyList The PropertyList object being built for this FO. @@ -201,14 +201,14 @@ public class CompoundPropertyMaker extends PropertyMaker { * @param fo The parent FO for the FO whose property is being made. * @return The initialized Property object. * @throws PropertyException for invalid or inconsistent FO input - */ + */ public Property make(PropertyList propertyList, String value, FObj fo) throws PropertyException { Property p = super.make(propertyList, value, fo); p = convertProperty(p, propertyList, fo); - return p; + return p; } - + /** * Return a property value for a compound property. If the property * value is already partially initialized, this method will modify it. @@ -243,7 +243,7 @@ public class CompoundPropertyMaker extends PropertyMaker { } return baseProperty; } - + /** * Create a empty compound property and fill it with default values for * the subproperties. @@ -265,5 +265,5 @@ public class CompoundPropertyMaker extends PropertyMaker { } } return p; - } + } } diff --git a/src/java/org/apache/fop/fo/properties/CondLengthProperty.java b/src/java/org/apache/fop/fo/properties/CondLengthProperty.java index 15d430051..aa913d969 100644 --- a/src/java/org/apache/fop/fo/properties/CondLengthProperty.java +++ b/src/java/org/apache/fop/fo/properties/CondLengthProperty.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,14 +31,14 @@ import org.apache.fop.fo.expr.PropertyException; * Superclass for properties that have conditional lengths */ public class CondLengthProperty extends Property implements CompoundDatatype { - + /** cache holding canonical instances (for absolute conditional lengths) */ private static final PropertyCache cache = new PropertyCache(CondLengthProperty.class); - + /** components */ private Property length; private EnumProperty conditionality; - + private boolean isCached = false; private int hash = -1; @@ -56,7 +56,7 @@ public class CondLengthProperty extends Property implements CompoundDatatype { /** * Create a new empty instance of CondLengthProperty. - * @return the new instance. + * @return the new instance. */ public Property makeNewProperty() { return new CondLengthProperty(); @@ -64,7 +64,7 @@ public class CondLengthProperty extends Property implements CompoundDatatype { /** * {@inheritDoc} - */ + */ public Property convertProperty(Property p, PropertyList propertyList, FObj fo) throws PropertyException { if (p instanceof KeepProperty) { @@ -75,7 +75,7 @@ public class CondLengthProperty extends Property implements CompoundDatatype { } /** - * {@inheritDoc} + * {@inheritDoc} */ public void setComponent(int cmpId, Property cmpnValue, boolean bIsDefault) { @@ -83,7 +83,7 @@ public class CondLengthProperty extends Property implements CompoundDatatype { throw new IllegalStateException( "CondLengthProperty.setComponent() called on a cached value!"); } - + if (cmpId == CP_LENGTH) { length = cmpnValue; } else if (cmpId == CP_CONDITIONALITY) { @@ -147,11 +147,11 @@ public class CondLengthProperty extends Property implements CompoundDatatype { /** {@inheritDoc} */ public String toString() { - return "CondLength[" + length.getObject().toString() - + ", " + (isDiscard() - ? conditionality.toString().toLowerCase() + return "CondLength[" + length.getObject().toString() + + ", " + (isDiscard() + ? conditionality.toString().toLowerCase() : conditionality.toString()) + "]"; - } + } /** * @return this.condLength @@ -188,7 +188,7 @@ public class CondLengthProperty extends Property implements CompoundDatatype { if (this == obj) { return true; } - + if (obj instanceof CondLengthProperty) { CondLengthProperty clp = (CondLengthProperty)obj; return (this.length == clp.length @@ -196,7 +196,7 @@ public class CondLengthProperty extends Property implements CompoundDatatype { } return false; } - + /** {@inheritDoc} */ public int hashCode() { if (this.hash == -1) { diff --git a/src/java/org/apache/fop/fo/properties/CorrespondingPropertyMaker.java b/src/java/org/apache/fop/fo/properties/CorrespondingPropertyMaker.java index add38161e..60237c53a 100644 --- a/src/java/org/apache/fop/fo/properties/CorrespondingPropertyMaker.java +++ b/src/java/org/apache/fop/fo/properties/CorrespondingPropertyMaker.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. @@ -33,19 +33,19 @@ public class CorrespondingPropertyMaker { protected int tb_rl; protected boolean useParent; private boolean relative; - + public CorrespondingPropertyMaker(PropertyMaker baseMaker) { this.baseMaker = baseMaker; baseMaker.setCorresponding(this); } - - + + public void setCorresponding(int lr_tb, int rl_tb, int tb_rl) { this.lr_tb = lr_tb; this.rl_tb = rl_tb; this.tb_rl = tb_rl; } - + /** * Controls whether the PropertyMaker accesses the parent property list or the current * property list for determining the writing mode. @@ -58,7 +58,7 @@ public class CorrespondingPropertyMaker { public void setRelative(boolean relative) { this.relative = relative; } - + /** * For properties that operate on a relative direction (before, after, * start, end) instead of an absolute direction (top, bottom, left, @@ -80,18 +80,18 @@ public class CorrespondingPropertyMaker { if (!relative) { return false; } - + PropertyList pList = getWMPropertyList(propertyList); if (pList != null) { int correspondingId = pList.getWritingMode(lr_tb, rl_tb, tb_rl); - + if (pList.getExplicit(correspondingId) != null) { return true; } - } + } return false; } - + /** * Return a Property object representing the value of this property, * based on other property values for this FO. @@ -108,7 +108,7 @@ public class CorrespondingPropertyMaker { return null; } int correspondingId = pList.getWritingMode(lr_tb, rl_tb, tb_rl); - + Property p = propertyList.getExplicitOrShorthand(correspondingId); if (p != null) { FObj parentFO = propertyList.getParentFObj(); @@ -116,7 +116,7 @@ public class CorrespondingPropertyMaker { } return p; } - + /** * Return the property list to use for fetching writing mode depending property * ids. diff --git a/src/java/org/apache/fop/fo/properties/DimensionPropertyMaker.java b/src/java/org/apache/fop/fo/properties/DimensionPropertyMaker.java index 6bd30929a..29715fe66 100644 --- a/src/java/org/apache/fop/fo/properties/DimensionPropertyMaker.java +++ b/src/java/org/apache/fop/fo/properties/DimensionPropertyMaker.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 @@ public class DimensionPropertyMaker extends CorrespondingPropertyMaker { public DimensionPropertyMaker(PropertyMaker baseMaker) { super(baseMaker); } - + public void setExtraCorresponding(int[][] extraCorresponding) { this.extraCorresponding = extraCorresponding; } @@ -47,7 +47,7 @@ public class DimensionPropertyMaker extends CorrespondingPropertyMaker { int wmcorr = extraCorresponding[i][0]; //propertyList.getWritingMode()]; if (propertyList.getExplicit(wmcorr) != null) return true; - } + } return false; } @@ -59,8 +59,8 @@ public class DimensionPropertyMaker extends CorrespondingPropertyMaker { } // Based on min-[width|height] - int wmcorr = propertyList.getWritingMode(extraCorresponding[0][0], - extraCorresponding[0][1], + int wmcorr = propertyList.getWritingMode(extraCorresponding[0][0], + extraCorresponding[0][1], extraCorresponding[0][2]); Property subprop = propertyList.getExplicitOrShorthand(wmcorr); if (subprop != null) { @@ -68,8 +68,8 @@ public class DimensionPropertyMaker extends CorrespondingPropertyMaker { } // Based on max-[width|height] - wmcorr = propertyList.getWritingMode(extraCorresponding[1][0], - extraCorresponding[1][1], + wmcorr = propertyList.getWritingMode(extraCorresponding[1][0], + extraCorresponding[1][1], extraCorresponding[1][2]); subprop = propertyList.getExplicitOrShorthand(wmcorr); // TODO: Don't set when NONE. @@ -78,5 +78,5 @@ public class DimensionPropertyMaker extends CorrespondingPropertyMaker { } return p; - } + } } diff --git a/src/java/org/apache/fop/fo/properties/EnumLength.java b/src/java/org/apache/fop/fo/properties/EnumLength.java index 95b759356..76fd0e5b7 100755 --- a/src/java/org/apache/fop/fo/properties/EnumLength.java +++ b/src/java/org/apache/fop/fo/properties/EnumLength.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.fo.properties; import org.apache.fop.datatypes.PercentBaseContext; @@ -26,7 +26,7 @@ import org.apache.fop.datatypes.PercentBaseContext; */ public class EnumLength extends LengthProperty { private Property enumProperty; - + public EnumLength(Property enumProperty) { this.enumProperty = enumProperty; } diff --git a/src/java/org/apache/fop/fo/properties/EnumNumber.java b/src/java/org/apache/fop/fo/properties/EnumNumber.java index 5e60b4e35..fdc359a06 100755 --- a/src/java/org/apache/fop/fo/properties/EnumNumber.java +++ b/src/java/org/apache/fop/fo/properties/EnumNumber.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.fo.properties; import org.apache.fop.datatypes.Numeric; @@ -32,7 +32,7 @@ public final class EnumNumber extends Property implements Numeric { private static final PropertyCache cache = new PropertyCache(EnumNumber.class); private final EnumProperty enumProperty; - + /** * Constructor * @param enumProperty the base EnumProperty @@ -44,7 +44,7 @@ public final class EnumNumber extends Property implements Numeric { /** * Returns the canonical EnumNumber instance corresponding * to the given Property - * + * * @param enumProperty the base EnumProperty * @return the canonical instance */ @@ -87,16 +87,16 @@ public final class EnumNumber extends Property implements Numeric { return 0; } - /** + /** * {@inheritDoc} * Always true for instances of this type */ public boolean isAbsolute() { return true; } - - /** - * {@inheritDoc} + + /** + * {@inheritDoc} * logs an error, because it's not supposed to be called */ public double getNumericValue(PercentBaseContext context) throws PropertyException { @@ -104,8 +104,8 @@ public final class EnumNumber extends Property implements Numeric { return 0; } - /** - * {@inheritDoc} + /** + * {@inheritDoc} * logs an error, because it's not supposed to be called */ public int getValue(PercentBaseContext context) { @@ -113,8 +113,8 @@ public final class EnumNumber extends Property implements Numeric { return 0; } - /** - * {@inheritDoc} + /** + * {@inheritDoc} * logs an error, because it's not supposed to be called */ public int getValue() { @@ -122,8 +122,8 @@ public final class EnumNumber extends Property implements Numeric { return 0; } - /** - * {@inheritDoc} + /** + * {@inheritDoc} * logs an error, because it's not supposed to be called */ public double getNumericValue() { @@ -131,7 +131,7 @@ public final class EnumNumber extends Property implements Numeric { return 0; } - /** + /** * {@inheritDoc} */ public Numeric getNumeric() { diff --git a/src/java/org/apache/fop/fo/properties/EnumProperty.java b/src/java/org/apache/fop/fo/properties/EnumProperty.java index d3043c5c3..07cfaadcc 100644 --- a/src/java/org/apache/fop/fo/properties/EnumProperty.java +++ b/src/java/org/apache/fop/fo/properties/EnumProperty.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.fo.expr.PropertyException; * Superclass for properties that wrap an enumeration value */ public final class EnumProperty extends Property { - + /** cache holding all canonical EnumProperty instances */ private static final PropertyCache cache = new PropertyCache(EnumProperty.class); @@ -102,7 +102,7 @@ public final class EnumProperty extends Property { public boolean equals(Object obj) { if (obj instanceof EnumProperty) { EnumProperty ep = (EnumProperty)obj; - return (ep.value == this.value) + return (ep.value == this.value) && ((ep.text == this.text) || (ep.text != null && ep.text.equals(this.text))); diff --git a/src/java/org/apache/fop/fo/properties/FixedLength.java b/src/java/org/apache/fop/fo/properties/FixedLength.java index 5636a4225..84d159edf 100644 --- a/src/java/org/apache/fop/fo/properties/FixedLength.java +++ b/src/java/org/apache/fop/fo/properties/FixedLength.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. @@ -25,7 +25,7 @@ import org.apache.fop.datatypes.PercentBaseContext; * An absolute length quantity in XSL */ public final class FixedLength extends LengthProperty { - + /** Describes the unit pica. */ public static final String PICA = "pc"; @@ -46,16 +46,16 @@ public final class FixedLength extends LengthProperty { /** cache holding all canonical FixedLength instances */ private static final PropertyCache cache = new PropertyCache(FixedLength.class); - + /** canonical zero-length instance */ public static final FixedLength ZERO_FIXED_LENGTH = new FixedLength(0, FixedLength.MPT, 1.0f); - + private int millipoints; /** * Set the length given a number of units, a unit name and * an assumed resolution (used in case the units are pixels) - * + * * @param numUnits quantity of input units * @param units input unit specifier * @param res input/source resolution @@ -63,11 +63,11 @@ public final class FixedLength extends LengthProperty { private FixedLength(double numUnits, String units, float res) { this.millipoints = convert(numUnits, units, res); } - + /** * Return the cached {@link FixedLength} instance corresponding * to the computed value in base-units (millipoints). - * + * * @param numUnits quantity of input units * @param units input unit specifier * @param sourceResolution input/source resolution (= ratio of pixels per pt) @@ -75,7 +75,7 @@ public final class FixedLength extends LengthProperty { * to the given number of units and unit specifier * in the given resolution */ - public static FixedLength getInstance(double numUnits, + public static FixedLength getInstance(double numUnits, String units, float sourceResolution) { if (numUnits == 0.0) { @@ -84,44 +84,44 @@ public final class FixedLength extends LengthProperty { return (FixedLength)cache.fetch( new FixedLength(numUnits, units, sourceResolution)); } - + } - + /** * Return the cached {@link FixedLength} instance corresponding * to the computed value * This method assumes a source-resolution of 1 (1px = 1pt) - * + * * @param numUnits input units * @param units unit specifier * @return the canonical FixedLength instance corresponding * to the given number of units and unit specifier */ - public static FixedLength getInstance(double numUnits, + public static FixedLength getInstance(double numUnits, String units) { return getInstance(numUnits, units, 1.0f); - + } - + /** * Return the cached {@link FixedLength} instance corresponding * to the computed value. - * This method assumes 'millipoints' (non-standard) as units, + * This method assumes 'millipoints' (non-standard) as units, * and an implied source-resolution of 1 (1px = 1pt). - * + * * @param numUnits input units * @return the canonical FixedLength instance corresponding * to the given number of units and unit specifier */ public static FixedLength getInstance(double numUnits) { return getInstance(numUnits, FixedLength.MPT, 1.0f); - + } - + /** * Convert the given length to a dimensionless integer representing * a whole number of base units (milli-points). - * + * * @param dvalue quantity of input units * @param unit input unit specifier (in, cm, etc.) * @param res the input/source resolution (in case the unit spec is "px") diff --git a/src/java/org/apache/fop/fo/properties/FontFamilyProperty.java b/src/java/org/apache/fop/fo/properties/FontFamilyProperty.java index 7404dbe9b..34a6b58d8 100644 --- a/src/java/org/apache/fop/fo/properties/FontFamilyProperty.java +++ b/src/java/org/apache/fop/fo/properties/FontFamilyProperty.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,9 +32,9 @@ public final class FontFamilyProperty extends ListProperty { /** cache holding all canonical FontFamilyProperty instances */ private static final PropertyCache cache = new PropertyCache(FontFamilyProperty.class); - + private int hash = 0; - + /** * Inner class for creating instances of ListProperty */ @@ -126,7 +126,7 @@ public final class FontFamilyProperty extends ListProperty { private FontFamilyProperty() { super(); } - + /** * Add a new property to the list * @param prop Property to be added to the list @@ -154,7 +154,7 @@ public final class FontFamilyProperty extends ListProperty { if (this == o) { return true; } - + if (o instanceof FontFamilyProperty) { FontFamilyProperty ffp = (FontFamilyProperty) o; return (this.list != null @@ -162,7 +162,7 @@ public final class FontFamilyProperty extends ListProperty { } return false; } - + /** {@inheritDoc} */ public int hashCode() { if (this.hash == 0) { diff --git a/src/java/org/apache/fop/fo/properties/FontShorthandParser.java b/src/java/org/apache/fop/fo/properties/FontShorthandParser.java index 89e029c5e..c22ba4745 100644 --- a/src/java/org/apache/fop/fo/properties/FontShorthandParser.java +++ b/src/java/org/apache/fop/fo/properties/FontShorthandParser.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,14 +29,14 @@ import org.apache.fop.fo.expr.PropertyException; public class FontShorthandParser extends GenericShorthandParser { /** - * {@inheritDoc} + * {@inheritDoc} */ public Property getValueForProperty(int propId, Property property, PropertyMaker maker, PropertyList propertyList) throws PropertyException { - + int index = -1; Property newProp; switch (propId) { diff --git a/src/java/org/apache/fop/fo/properties/FontShorthandProperty.java b/src/java/org/apache/fop/fo/properties/FontShorthandProperty.java index 638f77338..0cb44d7f8 100644 --- a/src/java/org/apache/fop/fo/properties/FontShorthandProperty.java +++ b/src/java/org/apache/fop/fo/properties/FontShorthandProperty.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,24 +39,24 @@ public class FontShorthandProperty extends ListProperty { Constants.PR_LINE_HEIGHT, Constants.PR_FONT_STYLE, Constants.PR_FONT_VARIANT, Constants.PR_FONT_WEIGHT }; - + /** * @param propId ID of the property for which Maker should be created */ public Maker(int propId) { super(propId); } - + /** - * {@inheritDoc} + * {@inheritDoc} */ - public Property make(PropertyList propertyList, + public Property make(PropertyList propertyList, String value, FObj fo) throws PropertyException { - + try { FontShorthandProperty newProp = new FontShorthandProperty(); newProp.setSpecifiedValue(value); - + String specVal = value; Property prop = null; if ("inherit".equals(specVal)) { @@ -80,14 +80,14 @@ public class FontShorthandProperty extends ListProperty { int spaceIndex = value.indexOf(' '); int quoteIndex = (value.indexOf('\'') == -1) ? value.indexOf('\"') : value.indexOf('\''); - if (spaceIndex == -1 + if (spaceIndex == -1 || (quoteIndex != -1 && spaceIndex > quoteIndex)) { /* no spaces or first space appears after the first * single/double quote, so malformed value string */ throw new PropertyException("Invalid property value: " - + "font=\"" + value + "\""); - } + + "font=\"" + value + "\""); + } PropertyMaker m = null; int fromIndex = spaceIndex + 1; int toIndex = specVal.length(); @@ -97,11 +97,11 @@ public class FontShorthandProperty extends ListProperty { boolean fontFamilyParsed = false; int commaIndex = value.indexOf(','); while (!fontFamilyParsed) { - /* value contains a (list of) possibly quoted - * font-family name(s) + /* value contains a (list of) possibly quoted + * font-family name(s) */ if (commaIndex == -1) { - /* no list, just a single name + /* no list, just a single name * (or first name in the list) */ if (quoteIndex != -1) { @@ -112,7 +112,7 @@ public class FontShorthandProperty extends ListProperty { m = FObj.getPropertyMakerFor(PROP_IDS[1]); prop = m.make(propertyList, specVal.substring(fromIndex), fo); newProp.addProperty(prop, 1); - fontFamilyParsed = true; + fontFamilyParsed = true; } else { if (quoteIndex != -1 && quoteIndex < commaIndex) { /* a quoted font-family name as first name @@ -131,7 +131,7 @@ public class FontShorthandProperty extends ListProperty { fromIndex = value.lastIndexOf(' ', toIndex - 1) + 1; value = specVal.substring(fromIndex, toIndex); int slashIndex = value.indexOf('/'); - String fontSize = value.substring(0, + String fontSize = value.substring(0, (slashIndex == -1) ? value.length() : slashIndex); m = FObj.getPropertyMakerFor(PROP_IDS[0]); prop = m.make(propertyList, fontSize, fo); @@ -190,7 +190,7 @@ public class FontShorthandProperty extends ListProperty { } } } - + private void addProperty(Property prop, int pos) { while (list.size() < (pos + 1)) { list.add(null); diff --git a/src/java/org/apache/fop/fo/properties/FontSizePropertyMaker.java b/src/java/org/apache/fop/fo/properties/FontSizePropertyMaker.java index b641b2abf..5096d6160 100644 --- a/src/java/org/apache/fop/fo/properties/FontSizePropertyMaker.java +++ b/src/java/org/apache/fop/fo/properties/FontSizePropertyMaker.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,30 +24,30 @@ import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.expr.PropertyException; /** - * This subclass of LengthProperty.Maker handles the special treatment of + * This subclass of LengthProperty.Maker handles the special treatment of * relative font sizes described in 7.8.4. */ -public class FontSizePropertyMaker +public class FontSizePropertyMaker extends LengthProperty.Maker implements Constants { /** The default normal font size in mpt */ private static final int FONT_SIZE_NORMAL = 12000; /** The factor to be applied when stepping font sizes upwards */ private static final double FONT_SIZE_GROWTH_FACTOR = 1.2; - + /** - * Create a length property which can handle relative font sizes + * Create a length property which can handle relative font sizes * @param propId the font size property id. */ public FontSizePropertyMaker(int propId) { super(propId); } - - + + /** * {@inheritDoc} * Contrary to basic lengths, percentages for font-size can be resolved - * here already: if the property evaluates to a {@link PercentLength}, + * here already: if the property evaluates to a {@link PercentLength}, * it is immediately replaced by the resolved {@link FixedLength}. */ public Property make(PropertyList propertyList, String value, FObj fo) throws PropertyException { @@ -82,7 +82,7 @@ public class FontSizePropertyMaker } return super.convertProperty(p, propertyList, fo); } - + /** * Calculates the nearest absolute font size to the given * font size. @@ -107,7 +107,7 @@ public class FontSizePropertyMaker } // baseFontSize is between last and next step font size // Return the step value closer to the baseFontSize - if (Math.abs(lastStepFontSize - baseFontSize) + if (Math.abs(lastStepFontSize - baseFontSize) <= Math.abs(baseFontSize - nextStepFontSize)) { return lastStepFontSize; } diff --git a/src/java/org/apache/fop/fo/properties/FontStretchPropertyMaker.java b/src/java/org/apache/fop/fo/properties/FontStretchPropertyMaker.java index 82f152ff5..eba62946d 100644 --- a/src/java/org/apache/fop/fo/properties/FontStretchPropertyMaker.java +++ b/src/java/org/apache/fop/fo/properties/FontStretchPropertyMaker.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,24 +24,24 @@ import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.expr.PropertyException; /** - * This subclass of EnumProperty.Maker handles the special treatment of + * This subclass of EnumProperty.Maker handles the special treatment of * relative font stretch values described in 7.8.5. */ -public class FontStretchPropertyMaker +public class FontStretchPropertyMaker extends EnumProperty.Maker implements Constants { - + /* Ordered list of absolute font stretch properties so we can easily find the next / * previous one */ private Property[] orderedFontStretchValues = null; - + /** - * Create an enum property which can handle relative font stretches + * Create an enum property which can handle relative font stretches * @param propId the font size property id. */ public FontStretchPropertyMaker(int propId) { super(propId); } - + /** * {@inheritDoc} * Implements the parts of 7.8.5 relevant to relative font stretches diff --git a/src/java/org/apache/fop/fo/properties/FontWeightPropertyMaker.java b/src/java/org/apache/fop/fo/properties/FontWeightPropertyMaker.java index 173b28f7c..278fec862 100644 --- a/src/java/org/apache/fop/fo/properties/FontWeightPropertyMaker.java +++ b/src/java/org/apache/fop/fo/properties/FontWeightPropertyMaker.java @@ -26,7 +26,7 @@ import org.apache.fop.fo.expr.PropertyInfo; import org.apache.fop.fo.expr.PropertyParser; public class FontWeightPropertyMaker extends EnumProperty.Maker { - + /** * Main constructor * @param propId the property id @@ -34,11 +34,11 @@ public class FontWeightPropertyMaker extends EnumProperty.Maker { public FontWeightPropertyMaker(int propId) { super(propId); } - + /** - * {@inheritDoc} + * {@inheritDoc} */ - public Property make(PropertyList pList, String value, FObj fo) + public Property make(PropertyList pList, String value, FObj fo) throws PropertyException { if ("inherit".equals(value)) { return super.make(pList, value, fo); diff --git a/src/java/org/apache/fop/fo/properties/GenericShorthandParser.java b/src/java/org/apache/fop/fo/properties/GenericShorthandParser.java index 5802112bc..b008c714d 100644 --- a/src/java/org/apache/fop/fo/properties/GenericShorthandParser.java +++ b/src/java/org/apache/fop/fo/properties/GenericShorthandParser.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.fo.expr.PropertyException; public class GenericShorthandParser implements ShorthandParser { /** - * Constructor. + * Constructor. */ public GenericShorthandParser() { } @@ -47,9 +47,9 @@ public class GenericShorthandParser implements ShorthandParser { return null; } } - + /** - * {@inheritDoc} + * {@inheritDoc} */ public Property getValueForProperty(int propId, Property property, diff --git a/src/java/org/apache/fop/fo/properties/IndentPropertyMaker.java b/src/java/org/apache/fop/fo/properties/IndentPropertyMaker.java index 75ecb9d24..d976fc6ea 100644 --- a/src/java/org/apache/fop/fo/properties/IndentPropertyMaker.java +++ b/src/java/org/apache/fop/fo/properties/IndentPropertyMaker.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. @@ -33,15 +33,15 @@ import org.apache.fop.fo.expr.PropertyException; */ public class IndentPropertyMaker extends CorrespondingPropertyMaker { /** - * The corresponding padding-* propIds + * The corresponding padding-* propIds */ - private int[] paddingCorresponding = null; + private int[] paddingCorresponding = null; /** - * The corresponding border-*-width propIds + * The corresponding border-*-width propIds */ private int[] borderWidthCorresponding = null; - + /** * Create a start-indent or end-indent property maker. * @param baseMaker the property maker to use @@ -57,7 +57,7 @@ public class IndentPropertyMaker extends CorrespondingPropertyMaker { public void setPaddingCorresponding(int[] paddingCorresponding) { this.paddingCorresponding = paddingCorresponding; } - + /** * Set the corresponding values for the border-*-width properties. * @param borderWidthCorresponding the corresping propids. @@ -65,9 +65,9 @@ public class IndentPropertyMaker extends CorrespondingPropertyMaker { public void setBorderWidthCorresponding(int[] borderWidthCorresponding) { this.borderWidthCorresponding = borderWidthCorresponding; } - + /** - * Calculate the corresponding value for start-indent and end-indent. + * Calculate the corresponding value for start-indent and end-indent. * @see CorrespondingPropertyMaker#compute(PropertyList) */ public Property compute(PropertyList propertyList) throws PropertyException { @@ -78,9 +78,9 @@ public class IndentPropertyMaker extends CorrespondingPropertyMaker { return computeConforming(propertyList); } } - + /** - * Calculate the corresponding value for start-indent and end-indent. + * Calculate the corresponding value for start-indent and end-indent. * @see CorrespondingPropertyMaker#compute(PropertyList) */ public Property computeConforming(PropertyList propertyList) throws PropertyException { @@ -92,7 +92,7 @@ public class IndentPropertyMaker extends CorrespondingPropertyMaker { Numeric padding = getCorresponding(paddingCorresponding, propertyList).getNumeric(); Numeric border = getCorresponding(borderWidthCorresponding, propertyList).getNumeric(); - + int marginProp = pList.getWritingMode(lr_tb, rl_tb, tb_rl); // Calculate the absolute margin. if (propertyList.getExplicitOrShorthand(marginProp) == null) { @@ -107,7 +107,7 @@ public class IndentPropertyMaker extends CorrespondingPropertyMaker { } else { //Margin is used Numeric margin = propertyList.get(marginProp).getNumeric(); - + Numeric v = FixedLength.ZERO_FIXED_LENGTH; if (!propertyList.getFObj().generatesReferenceAreas()) { // The inherited_value_of([start|end]-indent) @@ -119,23 +119,23 @@ public class IndentPropertyMaker extends CorrespondingPropertyMaker { v = NumericOp.addition(v, border); return (Property) v; } - + } - + private boolean isInherited(PropertyList pList) { if (pList.getFObj().getUserAgent().isBreakIndentInheritanceOnReferenceAreaBoundary()) { - FONode nd = pList.getFObj().getParent(); + FONode nd = pList.getFObj().getParent(); return !((nd instanceof FObj) && ((FObj)nd).generatesReferenceAreas()); } else { return true; } } - + /** * Calculate the corresponding value for start-indent and end-indent. * This method calculates indent following an alternative rule set that * tries to mimic many commercial solutions that chose to violate the - * XSL specification. + * XSL specification. * @see CorrespondingPropertyMaker#compute(PropertyList) */ public Property computeAlternativeRuleset(PropertyList propertyList) throws PropertyException { @@ -148,10 +148,10 @@ public class IndentPropertyMaker extends CorrespondingPropertyMaker { Numeric padding = getCorresponding(paddingCorresponding, propertyList).getNumeric(); Numeric border = getCorresponding(borderWidthCorresponding, propertyList).getNumeric(); - + int marginProp = pList.getWritingMode(lr_tb, rl_tb, tb_rl); - //Determine whether the nearest anscestor indent was specified through + //Determine whether the nearest anscestor indent was specified through //start-indent|end-indent or through a margin property. boolean marginNearest = false; PropertyList pl = propertyList.getParentPropertyList(); @@ -164,7 +164,7 @@ public class IndentPropertyMaker extends CorrespondingPropertyMaker { } pl = pl.getParentPropertyList(); } - + // Calculate the absolute margin. if (propertyList.getExplicitOrShorthand(marginProp) == null) { Property indent = propertyList.getExplicit(baseMaker.propId); @@ -181,7 +181,7 @@ public class IndentPropertyMaker extends CorrespondingPropertyMaker { } else { //Margin is used Numeric margin = propertyList.get(marginProp).getNumeric(); - + Numeric v = FixedLength.ZERO_FIXED_LENGTH; if (isInherited(propertyList)) { // The inherited_value_of([start|end]-indent) @@ -194,7 +194,7 @@ public class IndentPropertyMaker extends CorrespondingPropertyMaker { return (Property) v; } } - + private Property getCorresponding(int[] corresponding, PropertyList propertyList) throws PropertyException { PropertyList pList = getWMPropertyList(propertyList); diff --git a/src/java/org/apache/fop/fo/properties/KeepProperty.java b/src/java/org/apache/fop/fo/properties/KeepProperty.java index 67961b6e5..d2e2c70a7 100644 --- a/src/java/org/apache/fop/fo/properties/KeepProperty.java +++ b/src/java/org/apache/fop/fo/properties/KeepProperty.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,10 +28,10 @@ import org.apache.fop.fo.expr.PropertyException; * Class for properties that wrap Keep values */ public final class KeepProperty extends Property implements CompoundDatatype { - + /** class holding all canonical KeepProperty instances*/ private static final PropertyCache cache = new PropertyCache(KeepProperty.class); - + private boolean isCachedValue = false; private Property withinLine; private Property withinColumn; @@ -51,7 +51,7 @@ public final class KeepProperty extends Property implements CompoundDatatype { /** * Create a new empty instance of KeepProperty. - * @return the new instance. + * @return the new instance. */ public Property makeNewProperty() { return new KeepProperty(); @@ -59,7 +59,7 @@ public final class KeepProperty extends Property implements CompoundDatatype { /** * {@inheritDoc} - */ + */ public Property convertProperty(Property p, PropertyList propertyList, FObj fo) throws PropertyException { @@ -71,7 +71,7 @@ public final class KeepProperty extends Property implements CompoundDatatype { } /** - * {@inheritDoc} + * {@inheritDoc} */ public void setComponent(int cmpId, Property cmpnValue, boolean bIsDefault) { @@ -154,9 +154,9 @@ public final class KeepProperty extends Property implements CompoundDatatype { * @return String representation */ public String toString() { - return "Keep[" + - "withinLine:" + getWithinLine().getObject() + - ", withinColumn:" + getWithinColumn().getObject() + + return "Keep[" + + "withinLine:" + getWithinLine().getObject() + + ", withinColumn:" + getWithinColumn().getObject() + ", withinPage:" + getWithinPage().getObject() + "]"; } @@ -183,7 +183,7 @@ public final class KeepProperty extends Property implements CompoundDatatype { if (this == o) { return true; } - + if (o instanceof KeepProperty) { KeepProperty keep = (KeepProperty) o; return (keep.withinColumn == this.withinColumn) @@ -192,7 +192,7 @@ public final class KeepProperty extends Property implements CompoundDatatype { } return false; } - + /** {@inheritDoc} */ public int hashCode() { int hash = 17; diff --git a/src/java/org/apache/fop/fo/properties/LengthPairProperty.java b/src/java/org/apache/fop/fo/properties/LengthPairProperty.java index f89b7d8b7..9840c4683 100644 --- a/src/java/org/apache/fop/fo/properties/LengthPairProperty.java +++ b/src/java/org/apache/fop/fo/properties/LengthPairProperty.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 LengthPairProperty extends Property implements CompoundDatatype { /** * Create a new empty instance of LengthPairProperty. - * @return the new instance. + * @return the new instance. */ public Property makeNewProperty() { return new LengthPairProperty(); @@ -53,7 +53,7 @@ public class LengthPairProperty extends Property implements CompoundDatatype { /** * {@inheritDoc} - */ + */ public Property convertProperty(Property p, PropertyList propertyList, FObj fo) throws PropertyException { if (p instanceof LengthPairProperty) { @@ -69,7 +69,7 @@ public class LengthPairProperty extends Property implements CompoundDatatype { public LengthPairProperty() { super(); } - + /** * Creates a new LengthPairProperty. * @param ipd inline-progression-dimension @@ -80,7 +80,7 @@ public class LengthPairProperty extends Property implements CompoundDatatype { this.ipd = ipd; this.bpd = bpd; } - + /** * Creates a new LengthPairProperty which sets both bpd and ipd to the * same value. @@ -89,9 +89,9 @@ public class LengthPairProperty extends Property implements CompoundDatatype { public LengthPairProperty(Property len) { this(len, len); } - + /** - * {@inheritDoc} + * {@inheritDoc} */ public void setComponent(int cmpId, Property cmpnValue, boolean bIsDefault) { @@ -131,8 +131,8 @@ public class LengthPairProperty extends Property implements CompoundDatatype { /** {@inheritDoc} */ public String toString() { - return "LengthPair[" - + "ipd:" + getIPD().getObject() + return "LengthPair[" + + "ipd:" + getIPD().getObject() + ", bpd:" + getBPD().getObject() + "]"; } diff --git a/src/java/org/apache/fop/fo/properties/LengthProperty.java b/src/java/org/apache/fop/fo/properties/LengthProperty.java index 697aa75a7..4ffe38074 100644 --- a/src/java/org/apache/fop/fo/properties/LengthProperty.java +++ b/src/java/org/apache/fop/fo/properties/LengthProperty.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,9 +28,9 @@ import org.apache.fop.fo.expr.PropertyException; /** * Superclass for properties wrapping a Length value. */ -public abstract class LengthProperty extends Property +public abstract class LengthProperty extends Property implements Length, Numeric { - + /** * Inner class for making instances of LengthProperty */ @@ -38,7 +38,7 @@ public abstract class LengthProperty extends Property /** * Constructor - * + * * @param propId the id of the property for which a Maker should be created */ public Maker(int propId) { diff --git a/src/java/org/apache/fop/fo/properties/LengthRangeProperty.java b/src/java/org/apache/fop/fo/properties/LengthRangeProperty.java index aeab37972..3161fc517 100644 --- a/src/java/org/apache/fop/fo/properties/LengthRangeProperty.java +++ b/src/java/org/apache/fop/fo/properties/LengthRangeProperty.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,7 +53,7 @@ public class LengthRangeProperty extends Property implements CompoundDatatype { /** * Create a new empty instance of LengthRangeProperty. - * @return the new instance. + * @return the new instance. */ public Property makeNewProperty() { return new LengthRangeProperty(); @@ -64,16 +64,16 @@ public class LengthRangeProperty extends Property implements CompoundDatatype { && ((PercentLength) len).getPercentage() < 0) || (len.isAbsolute() && len.getValue() < 0)); } - - /** {@inheritDoc} */ - public Property convertProperty(Property p, + + /** {@inheritDoc} */ + public Property convertProperty(Property p, PropertyList propertyList, FObj fo) throws PropertyException { - + if (p instanceof LengthRangeProperty) { return p; } - + if (this.propId == PR_BLOCK_PROGRESSION_DIMENSION || this.propId == PR_INLINE_PROGRESSION_DIMENSION) { Length len = p.getLength(); @@ -86,13 +86,13 @@ public class LengthRangeProperty extends Property implements CompoundDatatype { } } } - + return super.convertProperty(p, propertyList, fo); } - - + + /** - * {@inheritDoc} + * {@inheritDoc} */ protected Property setSubprop(Property baseProperty, int subpropertyId, Property subproperty) { @@ -119,7 +119,7 @@ public class LengthRangeProperty extends Property implements CompoundDatatype { /** - * {@inheritDoc} + * {@inheritDoc} */ public void setComponent(int cmpId, Property cmpnValue, boolean bIsDefault) { @@ -191,7 +191,7 @@ public class LengthRangeProperty extends Property implements CompoundDatatype { } consistent = false; } - + // Minimum is prioritaire, if explicit private void checkConsistency(PercentBaseContext context) { if (consistent) { @@ -203,7 +203,7 @@ public class LengthRangeProperty extends Property implements CompoundDatatype { // Make sure max >= min // Must also control if have any allowed enum values! - if (!minimum.isAuto() && !maximum.isAuto() + if (!minimum.isAuto() && !maximum.isAuto() && minimum.getLength().getValue(context) > maximum.getLength().getValue(context)) { if ((bfSet & MINSET) != 0) { // if minimum is explicit, force max to min @@ -217,7 +217,7 @@ public class LengthRangeProperty extends Property implements CompoundDatatype { } } // Now make sure opt <= max and opt >= min - if (!optimum.isAuto() && !maximum.isAuto() + if (!optimum.isAuto() && !maximum.isAuto() && optimum.getLength().getValue(context) > maximum.getLength().getValue(context)) { if ((bfSet & OPTSET) != 0) { if ((bfSet & MAXSET) != 0) { @@ -231,8 +231,8 @@ public class LengthRangeProperty extends Property implements CompoundDatatype { // opt is default and max is explicit or default optimum = maximum; } - } else if (!optimum.isAuto() && !minimum.isAuto() - && optimum.getLength().getValue(context) + } else if (!optimum.isAuto() && !minimum.isAuto() + && optimum.getLength().getValue(context) < minimum.getLength().getValue(context)) { if ((bfSet & MINSET) != 0) { // if minimum is explicit, force opt to min @@ -244,7 +244,7 @@ public class LengthRangeProperty extends Property implements CompoundDatatype { minimum = optimum; // minimum was default value } } - + consistent = true; } @@ -278,8 +278,8 @@ public class LengthRangeProperty extends Property implements CompoundDatatype { /** {@inheritDoc} */ public String toString() { return "LengthRange[" - + "min:" + getMinimum(null).getObject() - + ", max:" + getMaximum(null).getObject() + + "min:" + getMinimum(null).getObject() + + ", max:" + getMaximum(null).getObject() + ", opt:" + getOptimum(null).getObject() + "]"; } diff --git a/src/java/org/apache/fop/fo/properties/LineHeightPropertyMaker.java b/src/java/org/apache/fop/fo/properties/LineHeightPropertyMaker.java index dd57502d8..4b408e83b 100644 --- a/src/java/org/apache/fop/fo/properties/LineHeightPropertyMaker.java +++ b/src/java/org/apache/fop/fo/properties/LineHeightPropertyMaker.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. @@ -33,7 +33,7 @@ import org.apache.fop.fo.expr.PropertyException; * value, instead of the computed value. * So when a line-height is create based on an attribute, the specified value * is stored in the property and in compute() the stored specified value of - * the nearest specified is used to recalculate the line-height. + * the nearest specified is used to recalculate the line-height. */ public class LineHeightPropertyMaker extends SpaceProperty.Maker { @@ -48,9 +48,9 @@ public class LineHeightPropertyMaker extends SpaceProperty.Maker { /** * {@inheritDoc} */ - public Property make(PropertyList propertyList, String value, FObj fo) + public Property make(PropertyList propertyList, String value, FObj fo) throws PropertyException { - /* if value was specified as a number/length/percentage then + /* if value was specified as a number/length/percentage then * conditionality and precedence components are overridden */ Property p = super.make(propertyList, value, fo); @@ -60,7 +60,7 @@ public class LineHeightPropertyMaker extends SpaceProperty.Maker { EnumProperty.getInstance(Constants.EN_FORCE, "FORCE"), true); return p; } - + /** * Recalculate the line-height value based on the nearest specified * value. @@ -80,7 +80,7 @@ public class LineHeightPropertyMaker extends SpaceProperty.Maker { } /** - * {@inheritDoc} + * {@inheritDoc} */ public Property convertProperty(Property p, PropertyList propertyList, diff --git a/src/java/org/apache/fop/fo/properties/ListProperty.java b/src/java/org/apache/fop/fo/properties/ListProperty.java index 46d8c9496..4c5208505 100644 --- a/src/java/org/apache/fop/fo/properties/ListProperty.java +++ b/src/java/org/apache/fop/fo/properties/ListProperty.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 ListProperty extends Property { protected ListProperty() { //nop } - + /** * @param prop the first Property to be added to the list */ diff --git a/src/java/org/apache/fop/fo/properties/NumberProperty.java b/src/java/org/apache/fop/fo/properties/NumberProperty.java index aa4791889..4d7c3b97b 100644 --- a/src/java/org/apache/fop/fo/properties/NumberProperty.java +++ b/src/java/org/apache/fop/fo/properties/NumberProperty.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,7 +51,7 @@ public final class NumberProperty extends Property implements Numeric { * {@inheritDoc} */ public Property convertProperty(Property p, - PropertyList propertyList, FObj fo) + PropertyList propertyList, FObj fo) throws PropertyException { if (p instanceof NumberProperty) { return p; @@ -79,12 +79,12 @@ public final class NumberProperty extends Property implements Numeric { } /** - * If the value is not positive, return a property with value 1 - * + * If the value is not positive, return a property with value 1 + * * {@inheritDoc} */ - public Property convertProperty(Property p, - PropertyList propertyList, FObj fo) + public Property convertProperty(Property p, + PropertyList propertyList, FObj fo) throws PropertyException { if (p instanceof EnumProperty) { return EnumNumber.getInstance(p); @@ -101,10 +101,10 @@ public final class NumberProperty extends Property implements Numeric { } } - + /** cache holding all canonical NumberProperty instances */ private static final PropertyCache cache = new PropertyCache(NumberProperty.class); - + private final Number number; /** @@ -132,7 +132,7 @@ public final class NumberProperty extends Property implements Numeric { private NumberProperty(int num) { this.number = new Integer(num); } - + /** * Returns the canonical NumberProperty instance * corresponding to the given Number @@ -143,7 +143,7 @@ public final class NumberProperty extends Property implements Numeric { return (NumberProperty)cache.fetch( new NumberProperty(num.doubleValue())); } - + /** * Returns the canonical NumberProperty instance * corresponding to the given Integer @@ -176,7 +176,7 @@ public final class NumberProperty extends Property implements Numeric { return (NumberProperty)cache.fetch( new NumberProperty(num)); } - + /** * Plain number always has a dimension of 0. * @return a dimension of 0. @@ -254,7 +254,7 @@ public final class NumberProperty extends Property implements Numeric { /** * Convert NumberProperty to a Color. Not sure why this is needed. - * @param foUserAgent FOUserAgent + * @param foUserAgent FOUserAgent * @return Color that corresponds to black */ public Color getColor(FOUserAgent foUserAgent) { @@ -268,7 +268,7 @@ public final class NumberProperty extends Property implements Numeric { public int hashCode() { return number.hashCode(); } - + /** {@inheritDoc} */ public boolean equals(Object o) { if (o == this) { diff --git a/src/java/org/apache/fop/fo/properties/PageBreakShorthandParser.java b/src/java/org/apache/fop/fo/properties/PageBreakShorthandParser.java index f04cdd3cc..066c00336 100644 --- a/src/java/org/apache/fop/fo/properties/PageBreakShorthandParser.java +++ b/src/java/org/apache/fop/fo/properties/PageBreakShorthandParser.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,9 +28,9 @@ import org.apache.fop.fo.expr.PropertyException; * Used to set the corresponding keep-* and break-* properties. */ public class PageBreakShorthandParser implements ShorthandParser { - + /** - * {@inheritDoc} + * {@inheritDoc} */ public Property getValueForProperty(int propId, Property property, @@ -38,11 +38,11 @@ public class PageBreakShorthandParser implements ShorthandParser { PropertyList propertyList) throws PropertyException { - if (propId == Constants.PR_KEEP_WITH_PREVIOUS + if (propId == Constants.PR_KEEP_WITH_PREVIOUS || propId == Constants.PR_KEEP_WITH_NEXT || propId == Constants.PR_KEEP_TOGETHER) { if (property.getEnum() == Constants.EN_AVOID) { - return maker.make(null, Constants.CP_WITHIN_PAGE, + return maker.make(null, Constants.CP_WITHIN_PAGE, propertyList, "always", propertyList.getFObj()); } } else if (propId == Constants.PR_BREAK_BEFORE diff --git a/src/java/org/apache/fop/fo/properties/PageDimensionMaker.java b/src/java/org/apache/fop/fo/properties/PageDimensionMaker.java index 542dcac32..53a9c1286 100644 --- a/src/java/org/apache/fop/fo/properties/PageDimensionMaker.java +++ b/src/java/org/apache/fop/fo/properties/PageDimensionMaker.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,38 +26,38 @@ import org.apache.fop.fo.expr.PropertyException; /** * Custom Maker for page-height / page-width - * + * */ public class PageDimensionMaker extends LengthProperty.Maker { - + /** * Constructor - * + * * @param propId the property Id */ public PageDimensionMaker(int propId) { super(propId); } - + /** - * Check the value of the page-width / page-height property. + * Check the value of the page-width / page-height property. * Return the default or user-defined fallback in case the value * was specified as "auto" - * + * * @see PropertyMaker#get(int, PropertyList, boolean, boolean) */ public Property get(int subpropId, PropertyList propertyList, - boolean tryInherit, boolean tryDefault) + boolean tryInherit, boolean tryDefault) throws PropertyException { - - Property p = super.get(0, propertyList, tryInherit, tryDefault); + + Property p = super.get(0, propertyList, tryInherit, tryDefault); FObj fo = propertyList.getFObj(); String fallbackValue = (propId == Constants.PR_PAGE_HEIGHT) ? fo.getUserAgent().getPageHeight() : fo.getUserAgent().getPageWidth(); - + if (p.getEnum() == Constants.EN_INDEFINITE) { - int otherId = (propId == Constants.PR_PAGE_HEIGHT) + int otherId = (propId == Constants.PR_PAGE_HEIGHT) ? Constants.PR_PAGE_WIDTH : Constants.PR_PAGE_HEIGHT; int writingMode = propertyList.get(Constants.PR_WRITING_MODE).getEnum(); int refOrientation = propertyList.get(Constants.PR_REFERENCE_ORIENTATION) @@ -66,10 +66,10 @@ public class PageDimensionMaker extends LengthProperty.Maker { && propertyList.getExplicit(otherId).getEnum() == Constants.EN_INDEFINITE) { //both set to "indefinite": //determine which one of the two defines the dimension - //in block-progression-direction, and set the other to + //in block-progression-direction, and set the other to //"auto" if ((writingMode != Constants.EN_TB_RL - && (refOrientation == 0 + && (refOrientation == 0 || refOrientation == 180 || refOrientation == -180)) || (writingMode == Constants.EN_TB_RL @@ -94,7 +94,7 @@ public class PageDimensionMaker extends LengthProperty.Maker { } else if (p.isAuto()) { return make(propertyList, fallbackValue, fo); } - + return p; - } + } } diff --git a/src/java/org/apache/fop/fo/properties/PercentLength.java b/src/java/org/apache/fop/fo/properties/PercentLength.java index 82f5e60f9..f89007f34 100644 --- a/src/java/org/apache/fop/fo/properties/PercentLength.java +++ b/src/java/org/apache/fop/fo/properties/PercentLength.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.fo.expr.PropertyException; * a percent specified length quantity in XSL */ public class PercentLength extends LengthProperty { - + /** * The percentage itself, expressed as a decimal value, e.g. for 95%, set * the value to .95 @@ -39,7 +39,7 @@ public class PercentLength extends LengthProperty { * {@link #factor} should be applied to compute the actual length */ private PercentBase lbase = null; - + private double resolvedValue; /** @@ -63,9 +63,9 @@ public class PercentLength extends LengthProperty { } /** - * Used during property resolution to check for + * Used during property resolution to check for * negative percentages - * + * * @return the percentage value */ protected double getPercentage() { @@ -95,7 +95,7 @@ public class PercentLength extends LengthProperty { return 0; } } - + /** {@inheritDoc} */ public String getString() { return (factor * 100.0) + "%"; @@ -103,7 +103,7 @@ public class PercentLength extends LengthProperty { /** * Return the length of this PercentLength. - * {@inheritDoc} + * {@inheritDoc} */ public int getValue() { return (int) getNumericValue(); @@ -113,12 +113,12 @@ public class PercentLength extends LengthProperty { public int getValue(PercentBaseContext context) { return (int) getNumericValue(context); } - + /** * @return the String equivalent of this */ public String toString() { - StringBuffer sb = + StringBuffer sb = new StringBuffer(PercentLength.class.getName()) .append("[factor=").append(factor) .append(",lbase=").append(lbase).append("]"); diff --git a/src/java/org/apache/fop/fo/properties/PositionShorthandParser.java b/src/java/org/apache/fop/fo/properties/PositionShorthandParser.java index 5f2468ed6..5040afeaf 100755 --- a/src/java/org/apache/fop/fo/properties/PositionShorthandParser.java +++ b/src/java/org/apache/fop/fo/properties/PositionShorthandParser.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,15 +27,15 @@ import org.apache.fop.fo.PropertyList; * values for absolute-position and relative-position. */ public class PositionShorthandParser implements ShorthandParser { - + /** - * {@inheritDoc} + * {@inheritDoc} */ public Property getValueForProperty(int propId, Property property, PropertyMaker maker, PropertyList propertyList) { - + int propVal = property.getEnum(); if (propId == Constants.PR_ABSOLUTE_POSITION) { switch (propVal) { diff --git a/src/java/org/apache/fop/fo/properties/Property.java b/src/java/org/apache/fop/fo/properties/Property.java index 5aef1b881..29e8faac5 100644 --- a/src/java/org/apache/fop/fo/properties/Property.java +++ b/src/java/org/apache/fop/fo/properties/Property.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 @@ import org.apache.fop.fo.Constants; * Base class for all property objects */ public class Property { - + /** Logger for all property classes */ protected static Log log = LogFactory.getLog(PropertyMaker.class); @@ -134,7 +134,7 @@ public class Property { public boolean isAuto() { return (getEnum() == Constants.EN_AUTO); } - + /** * This method expects to be overridden by subclasses * @return char property value diff --git a/src/java/org/apache/fop/fo/properties/PropertyCache.java b/src/java/org/apache/fop/fo/properties/PropertyCache.java index 6f87c0c45..f834a78ae 100644 --- a/src/java/org/apache/fop/fo/properties/PropertyCache.java +++ b/src/java/org/apache/fop/fo/properties/PropertyCache.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,35 +28,35 @@ import java.lang.ref.WeakReference; * The public access points are overloaded fetch() methods * that each correspond to a cached type. * It is designed especially to be used concurrently by multiple threads, - * drawing heavily upon the principles behind Java 1.5's - * ConcurrentHashMap. + * drawing heavily upon the principles behind Java 1.5's + * ConcurrentHashMap. */ public final class PropertyCache { - /** bitmask to apply to the hash to get to the + /** bitmask to apply to the hash to get to the * corresponding cache segment */ private static final int SEGMENT_MASK = 0x1F; - /** + /** * Indicates whether the cache should be used at all * Can be controlled by the system property: * org.apache.fop.fo.properties.use-cache */ private final boolean useCache; - + /** the segments array (length = 32) */ private CacheSegment[] segments = new CacheSegment[SEGMENT_MASK + 1]; /** the table of hash-buckets */ private CacheEntry[] table = new CacheEntry[8]; - + private Class runtimeType; - + final boolean[] votesForRehash = new boolean[SEGMENT_MASK + 1]; - + /* same hash function as used by java.util.HashMap */ private static int hash(Object x) { return hash(x.hashCode()); } - + private static int hash(int hashCode) { int h = hashCode; h += ~(h << 9); @@ -65,32 +65,32 @@ public final class PropertyCache { h ^= (h >>> 10); return h; } - + /* shortcut function */ private static boolean eq(Object p, Object q) { return (p == q || (p != null && p.equals(q))); } - + /* Class modeling a cached entry */ private final class CacheEntry extends WeakReference { volatile CacheEntry nextEntry; final int hash; - + /* main constructor */ public CacheEntry(Object p, CacheEntry nextEntry, ReferenceQueue refQueue) { super(p, refQueue); this.nextEntry = nextEntry; this.hash = p.hashCode(); } - + } - + /* Wrapper objects to synchronize on */ private final class CacheSegment { private int count = 0; private volatile ReferenceQueue staleEntries = new ReferenceQueue(); - } - + } + private void cleanSegment(int segmentIndex) { CacheEntry entry; CacheSegment segment = segments[segmentIndex]; @@ -145,7 +145,7 @@ public final class PropertyCache { } } } - + /* * Puts a new instance in the cache. * If the total number of entries for the corresponding @@ -154,14 +154,14 @@ public final class PropertyCache { * entries. */ private void put(Object o) { - + int hash = hash(o); CacheSegment segment = segments[hash & SEGMENT_MASK]; - + synchronized (segment) { int index = hash & (table.length - 1); CacheEntry entry = table[index]; - + if (entry == null) { entry = new CacheEntry(o, null, segment.staleEntries); table[index] = entry; @@ -176,23 +176,23 @@ public final class PropertyCache { segment.count++; } } - + if (segment.count > (2 * table.length)) { cleanSegment(hash & SEGMENT_MASK); } } } - + /* Gets a cached instance. Returns null if not found */ private Object get(Object o) { - + int hash = hash(o); int index = hash & (table.length - 1); - + CacheEntry entry = table[index]; Object q; - + /* try non-synched first */ for (CacheEntry e = entry; e != null; e = e.nextEntry) { if (e.hash == o.hashCode() @@ -201,7 +201,7 @@ public final class PropertyCache { return q; } } - + /* retry synched, only if the above attempt did not succeed, * as another thread may, in the meantime, have added a * corresponding entry */ @@ -218,14 +218,14 @@ public final class PropertyCache { } return null; } - + /* * Recursively acquires locks on all 32 segments, * extends the cache and redistributes the entries. - * + * */ private void rehash(int index) { - + CacheSegment seg = segments[index]; synchronized (seg) { if (index > 0) { @@ -239,9 +239,9 @@ public final class PropertyCache { for (int i = segments.length; --i >= 0;) { segments[i].count = 0; } - + CacheEntry[] newTable = new CacheEntry[newLength]; - + int hash, idx; Object o; newLength--; @@ -250,7 +250,7 @@ public final class PropertyCache { if ((o = c.get()) != null) { hash = c.hash; idx = hash & newLength; - newTable[idx] = new CacheEntry(o, newTable[idx], + newTable[idx] = new CacheEntry(o, newTable[idx], segments[hash & SEGMENT_MASK].staleEntries); segments[hash & SEGMENT_MASK].count++; } @@ -261,10 +261,10 @@ public final class PropertyCache { } } } - + /** * Default constructor. - * + * * @param c Runtime type of the objects that will be stored in the cache */ public PropertyCache(Class c) { @@ -278,13 +278,13 @@ public final class PropertyCache { } this.runtimeType = c; } - + /** * Generic fetch() method. - * Checks if the given Object is present in the cache - - * if so, returns a reference to the cached instance. + * Checks if the given Object is present in the cache - + * if so, returns a reference to the cached instance. * Otherwise the given object is added to the cache and returned. - * + * * @param obj the Object to check for * @return the cached instance */ @@ -292,81 +292,81 @@ public final class PropertyCache { if (!this.useCache) { return obj; } - + if (obj == null) { return null; } Object cacheEntry = get(obj); if (cacheEntry != null) { - return cacheEntry; + return cacheEntry; } put(obj); return obj; } - + /** - * Checks if the given {@link Property} is present in the cache - - * if so, returns a reference to the cached instance. + * Checks if the given {@link Property} is present in the cache - + * if so, returns a reference to the cached instance. * Otherwise the given object is added to the cache and returned. - * + * * @param prop the Property instance to check for * @return the cached instance */ public final Property fetch(Property prop) { - + return (Property) fetch((Object) prop); } - + /** - * Checks if the given {@link CommonHyphenation} is present in the cache - - * if so, returns a reference to the cached instance. + * Checks if the given {@link CommonHyphenation} is present in the cache - + * if so, returns a reference to the cached instance. * Otherwise the given object is added to the cache and returned. - * + * * @param chy the CommonHyphenation instance to check for * @return the cached instance */ public final CommonHyphenation fetch(CommonHyphenation chy) { - + return (CommonHyphenation) fetch((Object) chy); } - + /** - * Checks if the given {@link CommonFont} is present in the cache - - * if so, returns a reference to the cached instance. + * Checks if the given {@link CommonFont} is present in the cache - + * if so, returns a reference to the cached instance. * Otherwise the given object is added to the cache and returned. - * + * * @param cf the CommonFont instance to check for * @return the cached instance */ public final CommonFont fetch(CommonFont cf) { - + return (CommonFont) fetch((Object) cf); } /** - * Checks if the given {@link CommonBorderPaddingBackground} is present in the cache - - * if so, returns a reference to the cached instance. + * Checks if the given {@link CommonBorderPaddingBackground} is present in the cache - + * if so, returns a reference to the cached instance. * Otherwise the given object is added to the cache and returned. - * + * * @param cbpb the CommonBorderPaddingBackground instance to check for * @return the cached instance */ public final CommonBorderPaddingBackground fetch(CommonBorderPaddingBackground cbpb) { - + return (CommonBorderPaddingBackground) fetch((Object) cbpb); } /** - * Checks if the given {@link CommonBorderPaddingBackground.BorderInfo} is present in the cache - - * if so, returns a reference to the cached instance. + * Checks if the given {@link CommonBorderPaddingBackground.BorderInfo} is present in the cache - + * if so, returns a reference to the cached instance. * Otherwise the given object is added to the cache and returned. - * + * * @param bi the BorderInfo instance to check for * @return the cached instance */ public final CommonBorderPaddingBackground.BorderInfo fetch(CommonBorderPaddingBackground.BorderInfo bi) { - + return (CommonBorderPaddingBackground.BorderInfo) fetch((Object) bi); } @@ -374,6 +374,6 @@ public final class PropertyCache { public String toString() { return super.toString() + "[runtimeType=" + this.runtimeType + "]"; } - - + + } diff --git a/src/java/org/apache/fop/fo/properties/PropertyMaker.java b/src/java/org/apache/fop/fo/properties/PropertyMaker.java index b1162563d..0f4632110 100644 --- a/src/java/org/apache/fop/fo/properties/PropertyMaker.java +++ b/src/java/org/apache/fop/fo/properties/PropertyMaker.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,8 +123,8 @@ public class PropertyMaker implements Cloneable { /** * Add a enum constant. - * @param constant the enum constant - * @param value the Property value to use when the constant is specified + * @param constant the enum constant + * @param value the Property value to use when the constant is specified */ public void addEnum(String constant, Property value) { if (enums == null) { @@ -138,16 +138,16 @@ public class PropertyMaker implements Cloneable { * @param subproperty the PropertyMaker for the subproperty */ public void addSubpropMaker(PropertyMaker subproperty) { - throw new RuntimeException("Unable to add subproperties " + getClass()); + throw new RuntimeException("Unable to add subproperties " + getClass()); } /** - * Return a subproperty maker for the subpropertyId. - * @param subpropertyId The subpropertyId of the maker. + * Return a subproperty maker for the subpropertyId. + * @param subpropertyId The subpropertyId of the maker. * @return The subproperty maker. */ public PropertyMaker getSubpropMaker(int subpropertyId) { - throw new RuntimeException("Unable to add subproperties"); + throw new RuntimeException("Unable to add subproperties"); } /** @@ -155,7 +155,7 @@ public class PropertyMaker implements Cloneable { * shorthands list. Later the Integers are replaced with references * to the actual shorthand property makers. * @param shorthand a property maker thar is that is checked for - * shorthand values. + * shorthand values. */ public void addShorthand(PropertyMaker shorthand) { if (shorthands == null) { @@ -197,7 +197,7 @@ public class PropertyMaker implements Cloneable { } /** - * Set the percent base identifier for this maker. + * Set the percent base identifier for this maker. * @param percentBase the percent base (ex. LengthBase.FONTSIZE) */ public void setPercentBase(int percentBase) { @@ -205,9 +205,9 @@ public class PropertyMaker implements Cloneable { } /** - * Set the setByShorthand flag which only is applicable for subproperty - * makers. It should be true for the subproperties which must be - * assigned a value when the base property is assigned a attribute + * Set the setByShorthand flag which only is applicable for subproperty + * makers. It should be true for the subproperties which must be + * assigned a value when the base property is assigned a attribute * value directly. * @param setByShorthand true if this subproperty must be set when the base property is set */ @@ -217,7 +217,7 @@ public class PropertyMaker implements Cloneable { /** * Set the correspoding property information. - * @param corresponding a corresponding maker where the + * @param corresponding a corresponding maker where the * isForcedCorresponding and compute methods are delegated to. */ public void setCorresponding(CorrespondingPropertyMaker corresponding) { @@ -225,7 +225,7 @@ public class PropertyMaker implements Cloneable { } /** - * Create a new empty property. Must be overriden in compound + * Create a new empty property. Must be overriden in compound * subclasses. * @return a new instance of the Property for which this is a maker. */ @@ -243,13 +243,13 @@ public class PropertyMaker implements Cloneable { * @param propertyList the applicable property list * @param tryInherit true if inherited properties should be examined. * @return the property value - * @throws PropertyException if there is a problem evaluating the property + * @throws PropertyException if there is a problem evaluating the property */ - public Property findProperty(PropertyList propertyList, + public Property findProperty(PropertyList propertyList, boolean tryInherit) throws PropertyException { Property p = null; - + if (log.isTraceEnabled()) { log.trace("PropertyMaker.findProperty: " + FOPropertyMapping.getPropertyName(propId) @@ -267,9 +267,9 @@ public class PropertyMaker implements Cloneable { p = this.compute(propertyList); } } - if (p == null && tryInherit) { + if (p == null && tryInherit) { // else inherit (if has parent and is inheritable) - PropertyList parentPropertyList = propertyList.getParentPropertyList(); + PropertyList parentPropertyList = propertyList.getParentPropertyList(); if (parentPropertyList != null && isInherited()) { p = parentPropertyList.get(propId, true, false); } @@ -287,8 +287,8 @@ public class PropertyMaker implements Cloneable { * @param propertyList The PropertyList object being built for this FO. * @param tryInherit true if inherited properties should be examined. * @param tryDefault true if the default value should be returned. - * @return the property value - * @throws PropertyException if there is a problem evaluating the property + * @return the property value + * @throws PropertyException if there is a problem evaluating the property */ public Property get(int subpropertyId, PropertyList propertyList, boolean tryInherit, boolean tryDefault) @@ -370,7 +370,7 @@ public class PropertyMaker implements Cloneable { } /** - * Return the default value. + * Return the default value. * @param propertyList The PropertyList object being built for this FO. * @return the Property object corresponding to the parameters * @throws PropertyException for invalid or inconsisten FO input @@ -422,7 +422,7 @@ public class PropertyMaker implements Cloneable { .getExplicit(getPropId()); if (parentExplicit == null) { log.warn(FOPropertyMapping.getPropertyName(getPropId()) - + "=\"inherit\" on " + propertyList.getFObj().getName() + + "=\"inherit\" on " + propertyList.getFObj().getName() + ", but no explicit value found on the parent FO."); } } @@ -436,7 +436,7 @@ public class PropertyMaker implements Cloneable { newProp = PropertyParser.parse(pvalue, new PropertyInfo(this, propertyList)); - } + } if (newProp != null) { newProp = convertProperty(newProp, propertyList, fo); } @@ -475,7 +475,7 @@ public class PropertyMaker implements Cloneable { /** * Converts a shorthand property - * + * * @param propertyList the propertyList for which to convert * @param prop the shorthand property * @param fo ... @@ -538,7 +538,7 @@ public class PropertyMaker implements Cloneable { * file specifies a length value equivalent for these keywords, * such as "0.5pt" for "thin". * @param keyword the string value of property attribute. - * @return a String containing a parseable equivalent or null if + * @return a String containing a parseable equivalent or null if * the passed value isn't a keyword initializer for this Property */ protected String checkValueKeywords(String keyword) { @@ -549,7 +549,7 @@ public class PropertyMaker implements Cloneable { } } // TODO: should return null here? - return keyword; + return keyword; } /** @@ -642,7 +642,7 @@ public class PropertyMaker implements Cloneable { } return null; } - + /** @return the name of the property this maker is used for. */ public String getName() { return FOPropertyMapping.getPropertyName(propId); @@ -650,7 +650,7 @@ public class PropertyMaker implements Cloneable { /** * Return a clone of the makers. Used by useGeneric() to clone the - * subproperty makers of the generic compound makers. + * subproperty makers of the generic compound makers. * {@inheritDoc} */ public Object clone() { diff --git a/src/java/org/apache/fop/fo/properties/ReferenceOrientationMaker.java b/src/java/org/apache/fop/fo/properties/ReferenceOrientationMaker.java index 505afccd5..009b85b35 100644 --- a/src/java/org/apache/fop/fo/properties/ReferenceOrientationMaker.java +++ b/src/java/org/apache/fop/fo/properties/ReferenceOrientationMaker.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,16 +35,16 @@ public class ReferenceOrientationMaker extends Maker { public ReferenceOrientationMaker(int propId) { super(propId); } - + /** * Check the value of the reference-orientation property. - * - * {@inheritDoc} + * + * {@inheritDoc} */ public Property get(int subpropId, PropertyList propertyList, - boolean tryInherit, boolean tryDefault) + boolean tryInherit, boolean tryDefault) throws PropertyException { - + Property p = super.get(0, propertyList, tryInherit, tryDefault); int ro = 0; if (p != null) { diff --git a/src/java/org/apache/fop/fo/properties/ShorthandParser.java b/src/java/org/apache/fop/fo/properties/ShorthandParser.java index bf51c3f66..f0ec0e6e9 100644 --- a/src/java/org/apache/fop/fo/properties/ShorthandParser.java +++ b/src/java/org/apache/fop/fo/properties/ShorthandParser.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/fo/properties/SpaceProperty.java b/src/java/org/apache/fop/fo/properties/SpaceProperty.java index 98caa04ff..49f76f874 100644 --- a/src/java/org/apache/fop/fo/properties/SpaceProperty.java +++ b/src/java/org/apache/fop/fo/properties/SpaceProperty.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. @@ -47,7 +47,7 @@ public class SpaceProperty extends LengthRangeProperty { /** * Create a new empty instance of SpaceProperty. - * @return the new instance. + * @return the new instance. */ public Property makeNewProperty() { return new SpaceProperty(); @@ -69,7 +69,7 @@ public class SpaceProperty extends LengthRangeProperty { /** - * {@inheritDoc} + * {@inheritDoc} */ public void setComponent(int cmpId, Property cmpnValue, boolean bIsDefault) { @@ -138,10 +138,10 @@ public class SpaceProperty extends LengthRangeProperty { public String toString() { return "Space[" + - "min:" + getMinimum(null).getObject() + - ", max:" + getMaximum(null).getObject() + - ", opt:" + getOptimum(null).getObject() + - ", precedence:" + precedence.getObject() + + "min:" + getMinimum(null).getObject() + + ", max:" + getMaximum(null).getObject() + + ", opt:" + getOptimum(null).getObject() + + ", precedence:" + precedence.getObject() + ", conditionality:" + conditionality.getObject() + "]"; } diff --git a/src/java/org/apache/fop/fo/properties/SpacingPropertyMaker.java b/src/java/org/apache/fop/fo/properties/SpacingPropertyMaker.java index ba547b37a..19fa7baa7 100755 --- a/src/java/org/apache/fop/fo/properties/SpacingPropertyMaker.java +++ b/src/java/org/apache/fop/fo/properties/SpacingPropertyMaker.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.fo.expr.PropertyException; /** * A maker which creates 'letter-spacing' and 'word-spacing' properties. - * These two properties properties are standard space properties with + * These two properties properties are standard space properties with * additinal support for the 'normal' enum value. */ @@ -42,7 +42,7 @@ public class SpacingPropertyMaker extends SpaceProperty.Maker { /** * Support for the 'normal' value. */ - public Property convertProperty(Property p, + public Property convertProperty(Property p, PropertyList propertyList, FObj fo) throws PropertyException { if (p.getEnum() == Constants.EN_NORMAL) { diff --git a/src/java/org/apache/fop/fo/properties/StringProperty.java b/src/java/org/apache/fop/fo/properties/StringProperty.java index 087feb350..ec7e1f841 100644 --- a/src/java/org/apache/fop/fo/properties/StringProperty.java +++ b/src/java/org/apache/fop/fo/properties/StringProperty.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. @@ -81,13 +81,13 @@ public final class StringProperty extends Property { } } - + /** cache containing all canonical StringProperty instances */ private static final PropertyCache cache = new PropertyCache(StringProperty.class); - + /** canonical instance for empty strings */ public static final StringProperty EMPTY_STRING_PROPERTY = new StringProperty(""); - + private final String str; /** @@ -99,7 +99,7 @@ public final class StringProperty extends Property { } /** - * Return the canonical StringProperty instance + * Return the canonical StringProperty instance * corresponding to the given string value * @param str the base String * @return the canonical instance @@ -112,7 +112,7 @@ public final class StringProperty extends Property { new StringProperty(str)); } } - + /** @return the Object equivalent of this property */ public Object getObject() { return this.str; @@ -135,7 +135,7 @@ public final class StringProperty extends Property { } return false; } - + /** {@inheritDoc} */ public int hashCode() { return str.hashCode(); diff --git a/src/java/org/apache/fop/fo/properties/TableBorderPrecedence.java b/src/java/org/apache/fop/fo/properties/TableBorderPrecedence.java index 181dd00d5..4a2fc92f4 100644 --- a/src/java/org/apache/fop/fo/properties/TableBorderPrecedence.java +++ b/src/java/org/apache/fop/fo/properties/TableBorderPrecedence.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,10 +36,10 @@ public class TableBorderPrecedence extends NumberProperty.Maker{ public TableBorderPrecedence(int propId) { super(propId); } - + /** * Set default precedence according to the parent FObj - * + * * {@inheritDoc} */ public Property make(PropertyList propertyList) throws PropertyException { diff --git a/src/java/org/apache/fop/fo/properties/TableColLength.java b/src/java/org/apache/fop/fo/properties/TableColLength.java index 251007093..ccb85bcfb 100644 --- a/src/java/org/apache/fop/fo/properties/TableColLength.java +++ b/src/java/org/apache/fop/fo/properties/TableColLength.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 TableColLength extends LengthProperty { private double tcolUnits; /** - * The column the column-units are defined on. + * The column the column-units are defined on. */ private FObj column; diff --git a/src/java/org/apache/fop/fo/properties/TextDecorationProperty.java b/src/java/org/apache/fop/fo/properties/TextDecorationProperty.java index 4cb1b2f4a..3cbe56f00 100644 --- a/src/java/org/apache/fop/fo/properties/TextDecorationProperty.java +++ b/src/java/org/apache/fop/fo/properties/TextDecorationProperty.java @@ -84,7 +84,7 @@ public class TextDecorationProperty extends ListProperty { } return lst; } - + } /** @@ -156,5 +156,5 @@ public class TextDecorationProperty extends ListProperty { addProperty(prop); } } - + } diff --git a/src/java/org/apache/fop/fo/properties/ToBeImplementedProperty.java b/src/java/org/apache/fop/fo/properties/ToBeImplementedProperty.java index 20d3d7303..c04b1a892 100644 --- a/src/java/org/apache/fop/fo/properties/ToBeImplementedProperty.java +++ b/src/java/org/apache/fop/fo/properties/ToBeImplementedProperty.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/fo/properties/VerticalAlignShorthandParser.java b/src/java/org/apache/fop/fo/properties/VerticalAlignShorthandParser.java index d71dc4db1..c0950a794 100644 --- a/src/java/org/apache/fop/fo/properties/VerticalAlignShorthandParser.java +++ b/src/java/org/apache/fop/fo/properties/VerticalAlignShorthandParser.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,13 +23,13 @@ import org.apache.fop.fo.PropertyList; /** * A shorthand parser for the vertical-align shorthand. It is used to set - * values for alignment-baseline, alignment-adjust, baseline-shift + * values for alignment-baseline, alignment-adjust, baseline-shift * and dominant-baseline. */ public class VerticalAlignShorthandParser implements ShorthandParser, Constants { /** - * {@inheritDoc} + * {@inheritDoc} */ public Property getValueForProperty(int propId, Property property, diff --git a/src/java/org/apache/fop/fo/properties/WhiteSpaceShorthandParser.java b/src/java/org/apache/fop/fo/properties/WhiteSpaceShorthandParser.java index 2feb5e9c8..26df69c91 100644 --- a/src/java/org/apache/fop/fo/properties/WhiteSpaceShorthandParser.java +++ b/src/java/org/apache/fop/fo/properties/WhiteSpaceShorthandParser.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.fo.expr.PropertyException; public class WhiteSpaceShorthandParser implements ShorthandParser { /** - * {@inheritDoc} + * {@inheritDoc} */ public Property getValueForProperty(int propId, Property property, PropertyMaker maker, PropertyList propertyList) diff --git a/src/java/org/apache/fop/fo/properties/XMLLangShorthandParser.java b/src/java/org/apache/fop/fo/properties/XMLLangShorthandParser.java index 5a5cf95c5..efadd8957 100644 --- a/src/java/org/apache/fop/fo/properties/XMLLangShorthandParser.java +++ b/src/java/org/apache/fop/fo/properties/XMLLangShorthandParser.java @@ -25,14 +25,14 @@ import org.apache.fop.fo.expr.PropertyException; public class XMLLangShorthandParser extends GenericShorthandParser { private static final char HYPHEN_MINUS = '-'; - + /** {@inheritDoc} */ public Property getValueForProperty(int propId, Property property, PropertyMaker maker, PropertyList propertyList) throws PropertyException { - + String shorthandValue = property.getString(); int hyphenIndex = shorthandValue.indexOf(HYPHEN_MINUS); if (propId == Constants.PR_LANGUAGE) { diff --git a/src/java/org/apache/fop/fonts/AbstractCodePointMapping.java b/src/java/org/apache/fop/fonts/AbstractCodePointMapping.java index 3a2ac5022..56558b02e 100644 --- a/src/java/org/apache/fop/fonts/AbstractCodePointMapping.java +++ b/src/java/org/apache/fop/fonts/AbstractCodePointMapping.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,7 +38,7 @@ public class AbstractCodePointMapping implements SingleByteEncoding { private char[] unicodeMap; //code point to Unicode char private String[] charNameMap; //all character names in the encoding private Map fallbackMap; //Here we accumulate all mappings we have found through substitution - + /** * Main constructor. * @param name the name of the encoding @@ -140,7 +140,7 @@ public class AbstractCodePointMapping implements SingleByteEncoding { bot = mid + 1; } } - + //Fallback: using cache synchronized (this) { if (fallbackMap != null) { @@ -164,7 +164,7 @@ public class AbstractCodePointMapping implements SingleByteEncoding { } } } - + putFallbackCharacter(c, NOT_FOUND_CODE_POINT); return NOT_FOUND_CODE_POINT; } @@ -177,7 +177,7 @@ public class AbstractCodePointMapping implements SingleByteEncoding { this.fallbackMap.put(new Character(c), new Character(mapTo)); } } - + /** * Returns the main Unicode value that is associated with the given code point in the encoding. * Note that multiple Unicode values can theoretically be mapped to one code point in the @@ -200,10 +200,10 @@ public class AbstractCodePointMapping implements SingleByteEncoding { System.arraycopy(this.unicodeMap, 0, copy, 0, this.unicodeMap.length); return copy; } - + /** * Returns the index of a character/glyph with the given name. Note that this - * method is relatively slow and should only be used for fallback operations. + * method is relatively slow and should only be used for fallback operations. * @param charName the character name * @return the index of the character in the encoding or -1 if it doesn't exist */ @@ -219,7 +219,7 @@ public class AbstractCodePointMapping implements SingleByteEncoding { } return -1; } - + /** {@inheritDoc} */ public String[] getCharNameMap() { if (this.charNameMap != null) { @@ -235,7 +235,7 @@ public class AbstractCodePointMapping implements SingleByteEncoding { if (c != CharUtilities.NOT_A_CHARACTER) { String charName = Glyphs.charToGlyphName(c); if (charName.length() > 0) { - derived[i] = charName; + derived[i] = charName; } } } diff --git a/src/java/org/apache/fop/fonts/BFEntry.java b/src/java/org/apache/fop/fonts/BFEntry.java index 2cc527b61..4e0b169fd 100644 --- a/src/java/org/apache/fop/fonts/BFEntry.java +++ b/src/java/org/apache/fop/fonts/BFEntry.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,14 +16,14 @@ */ /* $Id$ */ - + package org.apache.fop.fonts; /** * This is just a holder class for bfentries, groups of characters of a base font (bf). */ public class BFEntry { - + private int unicodeStart; private int unicodeEnd; private int glyphStartIndex; diff --git a/src/java/org/apache/fop/fonts/Base14Font.java b/src/java/org/apache/fop/fonts/Base14Font.java index 26c11e72b..04349a148 100644 --- a/src/java/org/apache/fop/fonts/Base14Font.java +++ b/src/java/org/apache/fop/fonts/Base14Font.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.fonts; /** diff --git a/src/java/org/apache/fop/fonts/CIDFont.java b/src/java/org/apache/fop/fonts/CIDFont.java index 7216c8f15..8f468f7a4 100644 --- a/src/java/org/apache/fop/fonts/CIDFont.java +++ b/src/java/org/apache/fop/fonts/CIDFont.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/fonts/CIDFontType.java b/src/java/org/apache/fop/fonts/CIDFontType.java index 51b4a73d1..24132ffc2 100644 --- a/src/java/org/apache/fop/fonts/CIDFontType.java +++ b/src/java/org/apache/fop/fonts/CIDFontType.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.fonts; import org.apache.avalon.framework.ValuedEnum; @@ -59,8 +59,8 @@ public class CIDFontType extends ValuedEnum { throw new IllegalArgumentException("Invalid CID font type: " + name); } } - - + + /** * Returns the CID FontType by value. * @param value Value of the CID font type to look up @@ -75,5 +75,5 @@ public class CIDFontType extends ValuedEnum { throw new IllegalArgumentException("Invalid CID font type: " + value); } } - + } diff --git a/src/java/org/apache/fop/fonts/CIDSubset.java b/src/java/org/apache/fop/fonts/CIDSubset.java index 6bcfc0b71..c2505488b 100644 --- a/src/java/org/apache/fop/fonts/CIDSubset.java +++ b/src/java/org/apache/fop/fonts/CIDSubset.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. @@ -54,10 +54,10 @@ public class CIDSubset { * usedCharsIndex contains new glyph, original char (char selector -> Unicode) */ private Map/**/ usedCharsIndex = new java.util.HashMap(); - + public CIDSubset() { } - + /** * Adds the initial 3 glyphs which are the same for all CID subsets. */ @@ -73,7 +73,7 @@ public class CIDSubset { usedGlyphsIndex.put(new Integer(2), new Integer(2)); usedGlyphsCount++; } - + /** * Returns the original index of the glyph inside the (non-subset) font's glyph list. This * index can be used to access the character width information, for example. @@ -88,7 +88,7 @@ public class CIDSubset { return -1; } } - + /** * Returns the Unicode value for a subset index (character selector). If there's no such * Unicode value, the "NOT A CHARACTER" (0xFFFF) is returned. @@ -103,7 +103,7 @@ public class CIDSubset { return CharUtilities.NOT_A_CHARACTER; } } - + /** * Maps a character to a character selector for a font subset. If the character isn't in the * subset, yet, it is added and a new character selector returned. Otherwise, the already @@ -139,7 +139,7 @@ public class CIDSubset { public Map/**/ getSubsetGlyphs() { return Collections.unmodifiableMap(this.usedGlyphs); } - + /** * Returns a char array containing all Unicode characters that are in the subset. * @return a char array with all used Unicode characters @@ -159,7 +159,7 @@ public class CIDSubset { public int getSubsetSize() { return this.usedGlyphsCount; } - + /** * Returns a BitSet with bits set for each available glyph index. * @return a BitSet indicating available glyph indices @@ -173,5 +173,5 @@ public class CIDSubset { } return bitset; } - + } diff --git a/src/java/org/apache/fop/fonts/CustomFont.java b/src/java/org/apache/fop/fonts/CustomFont.java index 1f782b2ea..0b40dfecc 100644 --- a/src/java/org/apache/fop/fonts/CustomFont.java +++ b/src/java/org/apache/fop/fonts/CustomFont.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 abstract class CustomFont extends Typeface private String embedFileName = null; private String embedResourceName = null; private FontResolver resolver = null; - + private int capHeight = 0; private int xHeight = 0; private int ascender = 0; @@ -72,7 +72,7 @@ public abstract class CustomFont extends Typeface public String getFullName() { return fullName; } - + /** * Returns the font family names. * @return the font family names (a Set of Strings) @@ -117,7 +117,7 @@ public abstract class CustomFont extends Typeface if (resolver != null && embedFileName != null) { result = resolver.resolve(embedFileName); if (result == null) { - throw new IOException("Unable to resolve Source '" + throw new IOException("Unable to resolve Source '" + embedFileName + "' for embedded font"); } } @@ -194,7 +194,7 @@ public abstract class CustomFont extends Typeface public int getFlags() { return flags; } - + /** {@inheritDoc} */ public boolean isSymbolicFont() { return ((getFlags() & 4) != 0) || "ZapfDingbatsEncoding".equals(getEncodingName()); @@ -210,7 +210,7 @@ public abstract class CustomFont extends Typeface public int getWeight() { return this.weight; } - + /** * {@inheritDoc} */ @@ -293,20 +293,20 @@ public abstract class CustomFont extends Typeface public void setFullName(String name) { this.fullName = name; } - + /** {@inheritDoc} */ public void setFamilyNames(Set names) { this.familyNames = new java.util.HashSet(names); } - + /** * Sets the font's subfamily name. * @param subFamilyName the subfamily name of the font */ public void setFontSubFamilyName(String subFamilyName) { - this.fontSubName = subFamilyName; + this.fontSubName = subFamilyName; } - + /** * {@inheritDoc} */ @@ -374,7 +374,7 @@ public abstract class CustomFont extends Typeface weight = Math.min(900, weight); this.weight = weight; } - + /** * {@inheritDoc} */ @@ -439,7 +439,7 @@ public abstract class CustomFont extends Typeface } this.kerning.put(key, value); } - + /** * Replaces the existing kerning map with a new one. * @param kerningMap the kerning map (Map, the integers are diff --git a/src/java/org/apache/fop/fonts/EmbedFontInfo.java b/src/java/org/apache/fop/fonts/EmbedFontInfo.java index 9496b8459..3c4964b97 100644 --- a/src/java/org/apache/fop/fonts/EmbedFontInfo.java +++ b/src/java/org/apache/fop/fonts/EmbedFontInfo.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/fonts/Font.java b/src/java/org/apache/fop/fonts/Font.java index 3a0d82046..de6904d9b 100644 --- a/src/java/org/apache/fop/fonts/Font.java +++ b/src/java/org/apache/fop/fonts/Font.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/fonts/FontCache.java b/src/java/org/apache/fop/fonts/FontCache.java index f2ca741ff..2528989bb 100644 --- a/src/java/org/apache/fop/fonts/FontCache.java +++ b/src/java/org/apache/fop/fonts/FontCache.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/fonts/FontCollection.java b/src/java/org/apache/fop/fonts/FontCollection.java index 331d2639f..3c9bba7f4 100644 --- a/src/java/org/apache/fop/fonts/FontCollection.java +++ b/src/java/org/apache/fop/fonts/FontCollection.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/fonts/FontDescriptor.java b/src/java/org/apache/fop/fonts/FontDescriptor.java index fb9c7d02e..fadc73834 100644 --- a/src/java/org/apache/fop/fonts/FontDescriptor.java +++ b/src/java/org/apache/fop/fonts/FontDescriptor.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/fonts/FontEventAdapter.java b/src/java/org/apache/fop/fonts/FontEventAdapter.java index 516999f70..195d5d4f4 100644 --- a/src/java/org/apache/fop/fonts/FontEventAdapter.java +++ b/src/java/org/apache/fop/fonts/FontEventAdapter.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.fonts; import java.util.Map; @@ -32,7 +32,7 @@ import org.apache.fop.events.model.EventSeverity; public class FontEventAdapter implements FontEventListener { private EventBroadcaster eventBroadcaster; - + /** * Creates a new FontEventAdapter. * @param broadcaster the event broadcaster to send the generated events to @@ -40,7 +40,7 @@ public class FontEventAdapter implements FontEventListener { public FontEventAdapter(EventBroadcaster broadcaster) { this.eventBroadcaster = broadcaster; } - + /** * Returns the event group ID. * @return the event group ID @@ -48,7 +48,7 @@ public class FontEventAdapter implements FontEventListener { protected String getEventGroupID() { return getClass().getName(); } - + /** {@inheritDoc} */ public void fontSubstituted(Object source, FontTriplet requested, FontTriplet effective) { Map params = new java.util.HashMap(); @@ -78,5 +78,5 @@ public class FontEventAdapter implements FontEventListener { 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 index 512df0ac0..b508d7053 100644 --- a/src/java/org/apache/fop/fonts/FontEventListener.java +++ b/src/java/org/apache/fop/fonts/FontEventListener.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.fonts; @@ -48,5 +48,5 @@ public interface FontEventListener { * @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 314ef0480..f576c8208 100644 --- a/src/java/org/apache/fop/fonts/FontInfo.java +++ b/src/java/org/apache/fop/fonts/FontInfo.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. @@ -56,7 +56,7 @@ public class FontInfo { /** look up a font-name to get a font (that implements FontMetrics at least) */ private Map/**/ fonts = null; //(String = font key) - /** + /** * a collection of missing fonts; used to make sure the user gets * a warning for a missing font only once (not every time the font is used) */ @@ -141,7 +141,7 @@ public class FontInfo { /** * Log warning about duplicate font triplets. - * + * * @param triplet the duplicate font triplet * @param replacing true iff the new font will replace the old one * @param oldKey the old internal font name @@ -231,7 +231,7 @@ public class FontInfo { if (key != null) { internalFontKey = getInternalFontKey(key); } - + if (!substFont && internalFontKey == null) { return null; } @@ -374,10 +374,10 @@ public class FontInfo { if (families.length == 0) { throw new IllegalArgumentException("Specify at least one font family"); } - + // try matching without substitutions List/**/ matchedTriplets = fontLookup(families, style, weight, false); - + // if there are no matching font triplets found try with substitutions if (matchedTriplets.size() == 0) { matchedTriplets = fontLookup(families, style, weight, true); @@ -395,13 +395,13 @@ public class FontInfo { throw new IllegalStateException( "fontLookup must return an array with at least one " + "FontTriplet on the last call. Lookup: " + sb.toString()); - + } FontTriplet[] fontTriplets = new FontTriplet[matchedTriplets.size()]; matchedTriplets.toArray(fontTriplets); - + // found some matching fonts so return them - return fontTriplets; + return fontTriplets; } private Set/**/ getLoggedFontKeys() { diff --git a/src/java/org/apache/fop/fonts/FontLoader.java b/src/java/org/apache/fop/fonts/FontLoader.java index 2699ca6d5..6d2593fad 100644 --- a/src/java/org/apache/fop/fonts/FontLoader.java +++ b/src/java/org/apache/fop/fonts/FontLoader.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 FontLoader { boolean embedded, FontResolver resolver) throws IOException { return loadFont(fontUrl.toExternalForm(), subFontName, embedded, resolver); } - + /** * Loads a custom font from a URI. In the case of Type 1 fonts, the PFB file must be specified. * @param fontFileURI the URI to the font @@ -128,14 +128,14 @@ public abstract class FontLoader { * @throws IOException In case of an I/O error * @throws MalformedURLException If an invalid URL is built */ - public static InputStream openFontUri(FontResolver resolver, String uri) + public static InputStream openFontUri(FontResolver resolver, String uri) throws IOException, MalformedURLException { InputStream in = null; if (resolver != null) { Source source = resolver.resolve(uri); if (source == null) { - String err = "Cannot load font: failed to create Source for font file " - + uri; + String err = "Cannot load font: failed to create Source for font file " + + uri; throw new IOException(err); } if (source instanceof StreamSource) { @@ -146,7 +146,7 @@ public abstract class FontLoader { } if (in == null) { String err = "Cannot load font: failed to create InputStream from" - + " Source for font file " + uri; + + " Source for font file " + uri; throw new IOException(err); } } else { @@ -154,7 +154,7 @@ public abstract class FontLoader { } return in; } - + /** * Reads/parses the font data. * @throws IOException In case of an I/O error diff --git a/src/java/org/apache/fop/fonts/FontManagerConfigurator.java b/src/java/org/apache/fop/fonts/FontManagerConfigurator.java index 7f1c267da..43945b8f8 100644 --- a/src/java/org/apache/fop/fonts/FontManagerConfigurator.java +++ b/src/java/org/apache/fop/fonts/FontManagerConfigurator.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/fonts/FontMetrics.java b/src/java/org/apache/fop/fonts/FontMetrics.java index ce4b1ff00..7d5588690 100644 --- a/src/java/org/apache/fop/fonts/FontMetrics.java +++ b/src/java/org/apache/fop/fonts/FontMetrics.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.fonts; import java.util.Map; @@ -33,31 +33,31 @@ public interface FontMetrics { * @return the font name */ String getFontName(); - + /** * Returns the font's full name (Example: "Helvetica Bold Oblique"). * @return the font's full name */ String getFullName(); - + /** * Returns the font's family names as a Set of Strings (Example: "Helvetica"). * @return the font's family names (a Set of Strings) */ Set getFamilyNames(); - + /** * Returns the font name for font embedding (may include a prefix, Example: "1E28bcArialMT"). * @return the name for font embedding */ String getEmbedFontName(); - + /** * Returns the type of the font. * @return the font type */ FontType getFontType(); - + /** * Returns the maximum ascent of the font described by this @@ -66,7 +66,7 @@ public interface FontMetrics { * @return ascent in milliponts */ int getMaxAscent(int size); - + /** * Returns the ascent of the font described by this * FontMetrics object. It returns the nominal ascent within the em box. @@ -74,15 +74,15 @@ public interface FontMetrics { * @return ascent in milliponts */ int getAscender(int size); - + /** * Returns the size of a capital letter measured from the font's baseline. * @param size font size * @return height of capital characters */ int getCapHeight(int size); - - + + /** * Returns the descent of the font described by this * FontMetrics object. @@ -90,8 +90,8 @@ public interface FontMetrics { * @return descent in milliponts */ int getDescender(int size); - - + + /** * Determines the typical font height of this * FontMetrics object @@ -117,17 +117,17 @@ public interface FontMetrics { * @return an array of widths */ int[] getWidths(); - + /** * Indicates if the font has kering information. * @return True, if kerning is available. */ boolean hasKerningInfo(); - + /** * Returns the kerning map for the font. * @return the kerning map */ Map getKerningInfo(); - + } diff --git a/src/java/org/apache/fop/fonts/FontReader.java b/src/java/org/apache/fop/fonts/FontReader.java index 6f148f503..16da99baa 100644 --- a/src/java/org/apache/fop/fonts/FontReader.java +++ b/src/java/org/apache/fop/fonts/FontReader.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. @@ -154,7 +154,7 @@ public class FontReader extends DefaultHandler { } /** - * {@inheritDoc} + * {@inheritDoc} */ public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { @@ -222,7 +222,7 @@ public class FontReader extends DefaultHandler { } /** - * {@inheritDoc} + * {@inheritDoc} */ public void endElement(String uri, String localName, String qName) throws SAXException { String content = text.toString().trim(); @@ -298,7 +298,7 @@ public class FontReader extends DefaultHandler { } /** - * {@inheritDoc} + * {@inheritDoc} */ public void characters(char[] ch, int start, int length) { text.append(ch, start, length); diff --git a/src/java/org/apache/fop/fonts/FontResolver.java b/src/java/org/apache/fop/fonts/FontResolver.java index b054b054a..1da2339f7 100644 --- a/src/java/org/apache/fop/fonts/FontResolver.java +++ b/src/java/org/apache/fop/fonts/FontResolver.java @@ -35,5 +35,5 @@ public interface FontResolver { * @return A Source object, or null if the href could not resolved. */ Source resolve(String href); - + } diff --git a/src/java/org/apache/fop/fonts/FontSelector.java b/src/java/org/apache/fop/fonts/FontSelector.java index 5e3ed816e..a80a0e368 100644 --- a/src/java/org/apache/fop/fonts/FontSelector.java +++ b/src/java/org/apache/fop/fonts/FontSelector.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. @@ -54,7 +54,7 @@ public final class FontSelector { /** * Selects a font which is able to display the given character. - * + * * @param fobj * a Character object containing the character and its * attributes. @@ -70,7 +70,7 @@ public final class FontSelector { /** * Selects a font which is able to display the given character. - * + * * @param c * character to find. * @param text @@ -87,7 +87,7 @@ public final class FontSelector { /** * Selects a font which is able to display the most of the given characters. - * + * * @param charSeq * Text to go through * @param firstIndex diff --git a/src/java/org/apache/fop/fonts/FontSetup.java b/src/java/org/apache/fop/fonts/FontSetup.java index 7629e67c3..eea04a580 100644 --- a/src/java/org/apache/fop/fonts/FontSetup.java +++ b/src/java/org/apache/fop/fonts/FontSetup.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/fonts/FontTriplet.java b/src/java/org/apache/fop/fonts/FontTriplet.java index 906698e53..8e0acd8f2 100644 --- a/src/java/org/apache/fop/fonts/FontTriplet.java +++ b/src/java/org/apache/fop/fonts/FontTriplet.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/fonts/FontType.java b/src/java/org/apache/fop/fonts/FontType.java index 50ca2c8a6..0abe06a10 100644 --- a/src/java/org/apache/fop/fonts/FontType.java +++ b/src/java/org/apache/fop/fonts/FontType.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.fonts; import org.apache.avalon.framework.ValuedEnum; @@ -82,8 +82,8 @@ public class FontType extends ValuedEnum { throw new IllegalArgumentException("Invalid font type: " + name); } } - - + + /** * Returns the FontType by value. * @param value Value of the font type to look up @@ -106,5 +106,5 @@ public class FontType extends ValuedEnum { throw new IllegalArgumentException("Invalid font type: " + value); } } - + } diff --git a/src/java/org/apache/fop/fonts/FontUtil.java b/src/java/org/apache/fop/fonts/FontUtil.java index 5df5707f0..6ec89631f 100644 --- a/src/java/org/apache/fop/fonts/FontUtil.java +++ b/src/java/org/apache/fop/fonts/FontUtil.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/fonts/Glyphs.java b/src/java/org/apache/fop/fonts/Glyphs.java index 4fb6c4e5c..4da95d575 100644 --- a/src/java/org/apache/fop/fonts/Glyphs.java +++ b/src/java/org/apache/fop/fonts/Glyphs.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.fonts; /** @@ -179,7 +179,7 @@ public class Glyphs { '\u2022', // bullet '\u2013', // endash '\u2014', // emdash - '~', + '~', '\u2122', // trademark '\u0161', '\u203a', '\u0153', '\u2022', '\u017e', '\u0178', // 0xA0 ' ', '\u00a1', '\u00a2', '\u00a3', '\u00a4', '\u00a5', @@ -1276,7 +1276,7 @@ public class Glyphs { public static final String charToGlyphName(char ch) { return stringToGlyph(new Character(ch).toString()); } - + /** * Return the glyphname from a string, * eg, glyphToString("\\") returns "backslash" diff --git a/src/java/org/apache/fop/fonts/LazyFont.java b/src/java/org/apache/fop/fonts/LazyFont.java index 70b971fff..ebf31f258 100644 --- a/src/java/org/apache/fop/fonts/LazyFont.java +++ b/src/java/org/apache/fop/fonts/LazyFont.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. @@ -40,7 +40,7 @@ import org.apache.fop.apps.FOPException; public class LazyFont extends Typeface implements FontDescriptor { private static Log log = LogFactory.getLog(LazyFont.class); - + private String metricsFileName = null; private String fontEmbedPath = null; private boolean useKerning = false; @@ -52,14 +52,14 @@ public class LazyFont extends Typeface implements FontDescriptor { private FontDescriptor realFontDescriptor = null; private FontResolver resolver = null; - + /** * Main constructor * @param fontInfo the font info to embed * @param resolver the font resolver to handle font URIs */ public LazyFont(EmbedFontInfo fontInfo, FontResolver resolver) { - + this.metricsFileName = fontInfo.getMetricsFile(); this.fontEmbedPath = fontInfo.getEmbedFile(); this.useKerning = fontInfo.getKerning(); @@ -73,7 +73,7 @@ public class LazyFont extends Typeface implements FontDescriptor { return ( "metrics-url=" + metricsFileName + ", embed-url=" + fontEmbedPath + ", kerning=" + useKerning ); } - + private void load(boolean fail) { if (!isMetricsLoaded) { try { @@ -84,8 +84,8 @@ public class LazyFont extends Typeface implements FontDescriptor { Source source = resolver.resolve(metricsFileName); if (source == null) { String err - = "Cannot load font: failed to create Source from metrics file " - + metricsFileName; + = "Cannot load font: failed to create Source from metrics file " + + metricsFileName; if (fail) { throw new RuntimeException(err); } else { @@ -104,7 +104,7 @@ public class LazyFont extends Typeface implements FontDescriptor { String err = "Cannot load font: After URI resolution, the returned" + " Source object does not contain an InputStream" + " or a valid URL (system identifier) for metrics file: " - + metricsFileName; + + metricsFileName; if (fail) { throw new RuntimeException(err); } else { @@ -113,7 +113,7 @@ public class LazyFont extends Typeface implements FontDescriptor { return; } InputSource src = new InputSource(in); - src.setSystemId(source.getSystemId()); + src.setSystemId(source.getSystemId()); reader = new FontReader(src); } else { reader = new FontReader(new InputSource( @@ -182,7 +182,7 @@ public class LazyFont extends Typeface implements FontDescriptor { load(true); return realFont.hadMappingOperations(); } - + /** * {@inheritDoc} */ @@ -265,7 +265,7 @@ public class LazyFont extends Typeface implements FontDescriptor { } /** - * {@inheritDoc} + * {@inheritDoc} */ public int getWidth(int i, int size) { load(true); diff --git a/src/java/org/apache/fop/fonts/MultiByteFont.java b/src/java/org/apache/fop/fonts/MultiByteFont.java index 2f3031646..4843b308a 100644 --- a/src/java/org/apache/fop/fonts/MultiByteFont.java +++ b/src/java/org/apache/fop/fonts/MultiByteFont.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 @@ public class MultiByteFont extends CIDFont { private static int uniqueCounter = -1; private static final DecimalFormat COUNTER_FORMAT = new DecimalFormat("00000"); - + private String ttcName = null; private String encoding = "Identity-H"; @@ -40,7 +40,7 @@ public class MultiByteFont extends CIDFont { private String namePrefix = null; // Quasi unique prefix private CIDSubset subset = new CIDSubset(); - + /** A map from Unicode indices to glyph indices */ private BFEntry[] bfentries = null; @@ -50,7 +50,7 @@ public class MultiByteFont extends CIDFont { public MultiByteFont() { // Make sure that the 3 first glyphs are included subset.setupFirstThreeGlyphs(); - + // Create a quasiunique prefix for fontname synchronized (this.getClass()) { uniqueCounter++; @@ -59,7 +59,7 @@ public class MultiByteFont extends CIDFont { } } String cntString = COUNTER_FORMAT.format(uniqueCounter); - + //Subset prefix as described in chapter 5.5.3 of PDF 1.4 StringBuffer sb = new StringBuffer("E"); for (int i = 0, c = cntString.length(); i < c; i++) { @@ -104,11 +104,11 @@ public class MultiByteFont extends CIDFont { public void setCIDType(CIDFontType cidType) { this.cidType = cidType; } - + private String getPrefixedFontName() { return namePrefix + FontUtil.stripWhiteSpace(super.getFontName()); } - + /** {@inheritDoc} */ public String getEmbedFontName() { if (isEmbeddable()) { @@ -127,7 +127,7 @@ public class MultiByteFont extends CIDFont { public CIDSubset getCIDSubset() { return this.subset; } - + /** {@inheritDoc} */ public String getEncodingName() { return encoding; diff --git a/src/java/org/apache/fop/fonts/MutableFont.java b/src/java/org/apache/fop/fonts/MutableFont.java index 5ce1460be..5939bfed4 100644 --- a/src/java/org/apache/fop/fonts/MutableFont.java +++ b/src/java/org/apache/fop/fonts/MutableFont.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.fonts; import java.util.Map; @@ -33,7 +33,7 @@ public interface MutableFont { * @param name font name */ void setFontName(String name); - + /** * Sets the font's full name (usually the one that the operating system displays). Example: * "Helvetica Bold Oblique". @@ -46,7 +46,7 @@ public interface MutableFont { * @param names the font's family names (a Set of Strings) */ void setFamilyNames(Set names); - + /** * Sets the path to the embeddable font file. * @param path URI to the file @@ -64,13 +64,13 @@ public interface MutableFont { * @param capHeight capital height */ void setCapHeight(int capHeight); - + /** * Sets the ascent value. * @param ascender ascent height */ void setAscender(int ascender); - + /** * Sets the descent value. * @param descender descent value @@ -88,54 +88,54 @@ public interface MutableFont { * @param flags flags */ void setFlags(int flags); - + /** * Sets the font's StemV value. * @param stemV StemV */ void setStemV(int stemV); - + /** * Sets the font's italic angle. * @param italicAngle italic angle */ void setItalicAngle(int italicAngle); - + /** * Sets the font's default width * @param width default width */ void setMissingWidth(int width); - + /** * Sets the font type. * @param fontType font type */ void setFontType(FontType fontType); - + /** * Sets the index of the first character in the character table. * @param index index of first character */ void setFirstChar(int index); - + /** * Sets the index of the last character in the character table. * @param index index of the last character */ void setLastChar(int index); - + /** * Enables/disabled kerning. * @param enabled True if kerning should be enabled if available */ void setKerningEnabled(boolean enabled); - + /** * Adds an entry to the kerning table. * @param key Kerning key * @param value Kerning value */ void putKerningEntry(Integer key, Map value); - + } diff --git a/src/java/org/apache/fop/fonts/NamedCharacter.java b/src/java/org/apache/fop/fonts/NamedCharacter.java index 2c8007ba1..d63b22bea 100644 --- a/src/java/org/apache/fop/fonts/NamedCharacter.java +++ b/src/java/org/apache/fop/fonts/NamedCharacter.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,10 +28,10 @@ import org.apache.fop.util.CharUtilities; * sequence that this character represents. */ public class NamedCharacter { - + private String charName; private String unicodeSequence; - + /** * Main constructor. * @param charName the character name @@ -48,7 +48,7 @@ public class NamedCharacter { this.unicodeSequence = Glyphs.getUnicodeSequenceForGlyphName(charName); } } - + /** * Simple constructor. * @param charName the character name @@ -56,7 +56,7 @@ public class NamedCharacter { public NamedCharacter(String charName) { this(charName, null); } - + /** {@inheritDoc} */ public int hashCode() { final int prime = 31; @@ -87,7 +87,7 @@ public class NamedCharacter { public String getName() { return this.charName; } - + /** * Returns the Unicode sequence associated with this character. * @return the Unicode sequence (or null if no Unicode sequence is associated) @@ -95,7 +95,7 @@ public class NamedCharacter { public String getUnicodeSequence() { return this.unicodeSequence; } - + /** * Indicates whether a single Unicode value is associated with this character. * @return true if exactly one Unicode value is associated with this character, false otherwise @@ -103,7 +103,7 @@ public class NamedCharacter { public boolean hasSingleUnicodeValue() { return (this.unicodeSequence != null && this.unicodeSequence.length() == 1); } - + /** * Returns the single Unicode value associated with this named character. Check * {@link #hasSingleUnicodeValue()} before you call this method because an @@ -125,7 +125,7 @@ public class NamedCharacter { } return this.unicodeSequence.charAt(0); } - + /** {@inheritDoc} */ public String toString() { StringBuffer sb = new StringBuffer(this.unicodeSequence); diff --git a/src/java/org/apache/fop/fonts/SimpleSingleByteEncoding.java b/src/java/org/apache/fop/fonts/SimpleSingleByteEncoding.java index a5ba1a33b..6517f0328 100644 --- a/src/java/org/apache/fop/fonts/SimpleSingleByteEncoding.java +++ b/src/java/org/apache/fop/fonts/SimpleSingleByteEncoding.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 @@ public class SimpleSingleByteEncoding implements SingleByteEncoding { //List private Map charMap = new java.util.HashMap(); //Map - + /** * Main constructor. * @param name the encoding's name @@ -44,7 +44,7 @@ public class SimpleSingleByteEncoding implements SingleByteEncoding { public SimpleSingleByteEncoding(String name) { this.name = name; } - + /** {@inheritDoc} */ public String getName() { return this.name; @@ -65,11 +65,11 @@ public class SimpleSingleByteEncoding implements SingleByteEncoding { Arrays.fill(map, Glyphs.NOTDEF); for (int i = getFirstChar(); i <= getLastChar(); i++) { NamedCharacter ch = (NamedCharacter)this.mapping.get(i - 1); - map[i] = ch.getName(); + map[i] = ch.getName(); } return map; } - + /** * Returns the index of the first defined character. * @return the index of the first defined character (always 1 for this class) @@ -77,7 +77,7 @@ public class SimpleSingleByteEncoding implements SingleByteEncoding { public int getFirstChar() { return 1; } - + /** * Returns the index of the last defined character. * @return the index of the last defined character @@ -85,7 +85,7 @@ public class SimpleSingleByteEncoding implements SingleByteEncoding { public int getLastChar() { return this.mapping.size(); } - + /** * Returns the number of characters defined by this encoding. * @return the number of characters @@ -93,7 +93,7 @@ public class SimpleSingleByteEncoding implements SingleByteEncoding { public int getSize() { return this.mapping.size() + 1; } - + /** * Indicates whether the encoding is full (with 256 code points). * @return true if the encoding is full @@ -101,7 +101,7 @@ public class SimpleSingleByteEncoding implements SingleByteEncoding { public boolean isFull() { return (getSize() == 256); } - + /** * Adds a new character to the encoding. * @param ch the named character @@ -136,10 +136,10 @@ public class SimpleSingleByteEncoding implements SingleByteEncoding { return null; } } - + /** {@inheritDoc} */ public String toString() { return getName() + " (" + getSize() + " chars)"; } - + } diff --git a/src/java/org/apache/fop/fonts/SingleByteEncoding.java b/src/java/org/apache/fop/fonts/SingleByteEncoding.java index ac7241e24..bc680f983 100644 --- a/src/java/org/apache/fop/fonts/SingleByteEncoding.java +++ b/src/java/org/apache/fop/fonts/SingleByteEncoding.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,5 +46,5 @@ public interface SingleByteEncoding { * (unmapped code points are represented by a ".notdef" value) */ String[] getCharNameMap(); - + } diff --git a/src/java/org/apache/fop/fonts/SingleByteFont.java b/src/java/org/apache/fop/fonts/SingleByteFont.java index bdf0acc32..92e7c0547 100644 --- a/src/java/org/apache/fop/fonts/SingleByteFont.java +++ b/src/java/org/apache/fop/fonts/SingleByteFont.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. @@ -40,17 +40,17 @@ public class SingleByteFont extends CustomFont { private Map unencodedCharacters; //Map private List additionalEncodings; - + /** * Main constructor. */ public SingleByteFont() { setEncoding(CodePointMapping.WIN_ANSI_ENCODING); } - + /** {@inheritDoc} */ public boolean isEmbeddable() { - return (!(getEmbedFileName() == null + return (!(getEmbedFileName() == null && getEmbedResourceName() == null)); } @@ -66,7 +66,7 @@ public class SingleByteFont extends CustomFont { public SingleByteEncoding getEncoding() { return this.mapping; } - + /** {@inheritDoc} */ public int getWidth(int i, int size) { if (i < 256) { @@ -101,7 +101,7 @@ public class SingleByteFont extends CustomFont { if (d != SingleByteEncoding.NOT_FOUND_CODE_POINT) { return d; } - + //Check unencoded characters which are available in the font by character name d = mapUnencodedChar(c); if (d != SingleByteEncoding.NOT_FOUND_CODE_POINT) { @@ -121,7 +121,7 @@ public class SingleByteFont extends CustomFont { } SimpleSingleByteEncoding encoding = null; char mappedStart = 0; - int additionalsCount = this.additionalEncodings.size(); + int additionalsCount = this.additionalEncodings.size(); for (int i = 0; i < additionalsCount; i++) { mappedStart += 256; encoding = getAdditionalEncoding(i); @@ -172,7 +172,7 @@ public class SingleByteFont extends CustomFont { log.error("Font '" + super.getFontName() + "': " + e.getMessage()); } } - + /** * Sets the encoding of the font. * @param encoding the encoding (ex. "WinAnsiEncoding" or "SymbolEncoding") @@ -180,7 +180,7 @@ public class SingleByteFont extends CustomFont { public void setEncoding(String encoding) { updateMapping(encoding); } - + /** * Sets the encoding of the font. * @param encoding the encoding information @@ -225,7 +225,7 @@ public class SingleByteFont extends CustomFont { public boolean hasAdditionalEncodings() { return (this.additionalEncodings != null) && (this.additionalEncodings.size() > 0); } - + /** * Returns the number of additional encodings this single-byte font maintains. * @return the number of additional encodings @@ -237,7 +237,7 @@ public class SingleByteFont extends CustomFont { return 0; } } - + /** * Returns an additional encoding. * @param index the index of the additional encoding @@ -252,7 +252,7 @@ public class SingleByteFont extends CustomFont { throw new IndexOutOfBoundsException("No additional encodings available"); } } - + /** * Returns an array with the widths for an additional encoding. * @param index the index of the additional encoding @@ -269,25 +269,25 @@ public class SingleByteFont extends CustomFont { } return arr; } - + private static final class UnencodedCharacter { - + private NamedCharacter character; private int width; - + public UnencodedCharacter(NamedCharacter character, int width) { this.character = character; this.width = width; } - + public NamedCharacter getCharacter() { return this.character; } - + public int getWidth() { return this.width; } - + /** {@inheritDoc} */ public String toString() { return getCharacter().toString(); diff --git a/src/java/org/apache/fop/fonts/Typeface.java b/src/java/org/apache/fop/fonts/Typeface.java index 434e0735b..f4e317de3 100644 --- a/src/java/org/apache/fop/fonts/Typeface.java +++ b/src/java/org/apache/fop/fonts/Typeface.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.fonts; import java.util.Set; @@ -45,7 +45,7 @@ public abstract class Typeface implements FontMetrics { * long out of statistical interest. */ private long charMapOps = 0; - + /** An optional event listener that receives events such as missing glyphs etc. */ protected FontEventListener eventListener; @@ -71,9 +71,9 @@ public abstract class Typeface implements FontMetrics { protected void notifyMapOperation() { this.charMapOps++; } - + /** - * Indicates whether this font had to do any character mapping operations. If that was + * Indicates whether this font had to do any character mapping operations. If that was * not the case, it's an indication that the font has never actually been used. * @return true if the font had to do any character mapping operations */ @@ -87,7 +87,7 @@ public abstract class Typeface implements FontMetrics { * @return True if the character is supported, Falso otherwise */ public abstract boolean hasChar(char c); - + /** * Determines whether the font is a multibyte font. * @return True if it is multibyte @@ -100,7 +100,7 @@ public abstract class Typeface implements FontMetrics { public int getMaxAscent(int size) { return getAscender(size); } - + /** * Sets the font event listener that can be used to receive events about particular events * in this class. @@ -109,10 +109,10 @@ public abstract class Typeface implements FontMetrics { public void setEventListener(FontEventListener listener) { this.eventListener = listener; } - + /** * Provide proper warning if a glyph is not available. - * + * * @param c * the character which is missing. */ diff --git a/src/java/org/apache/fop/fonts/apps/AbstractFontReader.java b/src/java/org/apache/fop/fonts/apps/AbstractFontReader.java index 957a942a2..1c973cd51 100644 --- a/src/java/org/apache/fop/fonts/apps/AbstractFontReader.java +++ b/src/java/org/apache/fop/fonts/apps/AbstractFontReader.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.fonts.apps; import java.io.File; @@ -81,10 +81,10 @@ public abstract class AbstractFontReader { } return (String[])arguments.toArray(new String[0]); } - + /** * Sets the logging level. - * @param level the logging level ("debug", "info", "error" etc., see Jakarta Commons Logging) + * @param level the logging level ("debug", "info", "error" etc., see Jakarta Commons Logging) */ protected static void setLogLevel(String level) { // Set the evel for future loggers. @@ -94,7 +94,7 @@ public abstract class AbstractFontReader { ((CommandLineLogger) log).setLogLevel(level); } } - + /** * Determines the log level based of the options from the command-line. * @param options the command-line options @@ -120,7 +120,7 @@ public abstract class AbstractFontReader { public void writeFontXML(org.w3c.dom.Document doc, String target) throws TransformerException { writeFontXML(doc, new File(target)); } - + /** * Writes the generated DOM Document to a file. * @@ -130,7 +130,7 @@ public abstract class AbstractFontReader { */ public void writeFontXML(org.w3c.dom.Document doc, File target) throws TransformerException { log.info("Writing xml font file " + target + "..."); - + try { OutputStream out = new java.io.FileOutputStream(target); out = new java.io.BufferedOutputStream(out); @@ -147,5 +147,5 @@ public abstract class AbstractFontReader { throw new TransformerException("Error writing the output file", ioe); } } - + } diff --git a/src/java/org/apache/fop/fonts/apps/PFMReader.java b/src/java/org/apache/fop/fonts/apps/PFMReader.java index b14132ea3..18b40993d 100644 --- a/src/java/org/apache/fop/fonts/apps/PFMReader.java +++ b/src/java/org/apache/fop/fonts/apps/PFMReader.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.fonts.apps; import java.io.IOException; @@ -38,7 +38,7 @@ import org.w3c.dom.Element; * XML font metrics file for use in FOP. */ public class PFMReader extends AbstractFontReader { - + /** * Main constructor. */ @@ -94,7 +94,7 @@ public class PFMReader extends AbstractFontReader { // defined. LogFactory logFactory = LogFactory.getFactory(); if (System.getProperty("org.apache.commons.logging.Log") == null) { - logFactory.setAttribute("org.apache.commons.logging.Log", + logFactory.setAttribute("org.apache.commons.logging.Log", CommandLineLogger.class.getName()); } @@ -129,10 +129,10 @@ public class PFMReader extends AbstractFontReader { PFMFile pfm = app.loadPFM(arguments[0]); if (pfm != null) { app.preview(pfm); - + Document doc = app.constructFontXML(pfm, fontName, className, embResource, embFile); - + app.writeFontXML(doc, arguments[1]); } log.info("XML font metrics file successfullly created."); @@ -177,7 +177,7 @@ public class PFMReader extends AbstractFontReader { log.info("XHeight: " + pfm.getXHeight()); log.info("LowerCaseAscent: " + pfm.getLowerCaseAscent()); log.info("LowerCaseDescent: " + pfm.getLowerCaseDescent()); - log.info("Having widths for " + (pfm.getLastChar() - pfm.getFirstChar()) + log.info("Having widths for " + (pfm.getLastChar() - pfm.getFirstChar()) + " characters (" + pfm.getFirstChar() + "-" + pfm.getLastChar() + ")."); log.info("for example: Char " + pfm.getFirstChar() diff --git a/src/java/org/apache/fop/fonts/apps/TTFReader.java b/src/java/org/apache/fop/fonts/apps/TTFReader.java index c2cb4ecba..6e64f9144 100644 --- a/src/java/org/apache/fop/fonts/apps/TTFReader.java +++ b/src/java/org/apache/fop/fonts/apps/TTFReader.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.fonts.apps; import java.io.IOException; @@ -48,14 +48,14 @@ public class TTFReader extends AbstractFontReader { public static final String METRICS_VERSION_ATTR = "metrics-version"; /** Current version number for the metrics file */ public static final int METRICS_VERSION = 2; - + /** * Main constructor. */ public TTFReader() { super(); } - + private static void displayUsage() { System.out.println( "java " + TTFReader.class.getName() + " [options] fontfile.ttf xmlfile.xml"); @@ -118,7 +118,7 @@ public class TTFReader extends AbstractFontReader { // defined. LogFactory logFactory = LogFactory.getFactory(); if (System.getProperty("org.apache.commons.logging.Log") == null) { - logFactory.setAttribute("org.apache.commons.logging.Log", + logFactory.setAttribute("org.apache.commons.logging.Log", CommandLineLogger.class.getName()); } @@ -166,17 +166,17 @@ public class TTFReader extends AbstractFontReader { org.w3c.dom.Document doc = app.constructFontXML(ttf, fontName, className, embResource, embFile, isCid, ttcName); - + if (isCid) { log.info("Creating CID encoded metrics..."); } else { log.info("Creating WinAnsi encoded metrics..."); } - + if (doc != null) { app.writeFontXML(doc, arguments[1]); } - + if (ttf.isEmbeddable()) { log.info("This font contains no embedding license restrictions."); } else { @@ -274,7 +274,7 @@ public class TTFReader extends AbstractFontReader { } Set familyNames = ttf.getFamilyNames(); if (familyNames.size() > 0) { - String familyName = (String)familyNames.iterator().next(); + String familyName = (String)familyNames.iterator().next(); el = doc.createElement("family-name"); root.appendChild(el); el.appendChild(doc.createTextNode(familyName)); @@ -356,7 +356,7 @@ public class TTFReader extends AbstractFontReader { private void generateDOM4MultiByteExtras(Element parent, TTFFile ttf, boolean isCid) { Element el; Document doc = parent.getOwnerDocument(); - + Element mel = doc.createElement("multibyte-extras"); parent.appendChild(mel); @@ -421,11 +421,11 @@ public class TTFReader extends AbstractFontReader { el.setAttribute("wdt", String.valueOf(ttf.getCharWidth(i))); } } - + private void generateDOM4Kerning(Element parent, TTFFile ttf, boolean isCid) { Element el; Document doc = parent.getOwnerDocument(); - + // Get kerning Iterator iter; if (isCid) { @@ -464,8 +464,8 @@ public class TTFReader extends AbstractFontReader { } - /** - * Bugzilla 40739, check that attr has a metrics-version attribute + /** + * Bugzilla 40739, check that attr has a metrics-version attribute * compatible with ours. * @param attr attributes read from the root element of a metrics XML file * @throws SAXException if incompatible @@ -480,20 +480,20 @@ public class TTFReader extends AbstractFontReader { try { version = Integer.parseInt(str); if (version < METRICS_VERSION) { - err = "Incompatible " + METRICS_VERSION_ATTR + err = "Incompatible " + METRICS_VERSION_ATTR + " value (" + version + ", should be " + METRICS_VERSION + ")" - ; + ; } } catch (NumberFormatException e) { - err = "Invalid " + METRICS_VERSION_ATTR + err = "Invalid " + METRICS_VERSION_ATTR + " attribute value (" + str + ")"; } } - + if (err != null) { throw new SAXException( - err + err + " - please regenerate the font metrics file with " + "a more recent version of FOP." ); diff --git a/src/java/org/apache/fop/fonts/autodetect/FontFileFinder.java b/src/java/org/apache/fop/fonts/autodetect/FontFileFinder.java index c0cc03276..0d3bd6dcd 100644 --- a/src/java/org/apache/fop/fonts/autodetect/FontFileFinder.java +++ b/src/java/org/apache/fop/fonts/autodetect/FontFileFinder.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. @@ -125,7 +125,7 @@ public class FontFileFinder extends DirectoryWalker implements FontFinder { /** * Automagically finds a list of font files on local system - * + * * @return List<URL> of font files * @throws IOException io exception * {@inheritDoc} @@ -153,7 +153,7 @@ public class FontFileFinder extends DirectoryWalker implements FontFinder { /** * Searches a given directory for font files - * + * * @param dir directory to search * @return list of font files * @throws IOException thrown if an I/O exception of some sort has occurred diff --git a/src/java/org/apache/fop/fonts/autodetect/FontFinder.java b/src/java/org/apache/fop/fonts/autodetect/FontFinder.java index a21cbb067..ee0d1e07f 100644 --- a/src/java/org/apache/fop/fonts/autodetect/FontFinder.java +++ b/src/java/org/apache/fop/fonts/autodetect/FontFinder.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 java.util.List; * for available fonts. */ public interface FontFinder { - + /** * Finds a list of font files. - * + * * @return list of font files. List<URL> in the case of the * FontFinder, and List<File> in the case of the * FonrDirFinders. @@ -38,5 +38,5 @@ public interface FontFinder { * In case of an I/O problem */ List find() throws IOException; - + } diff --git a/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java b/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java index 9ab04282d..d0ff4a287 100644 --- a/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java +++ b/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.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 FontInfoFinder { /** * Attempts to determine FontTriplets from a given CustomFont. * It seems to be fairly accurate but will probably require some tweaking over time - * + * * @param customFont CustomFont * @param triplet Collection that will take the generated triplets */ @@ -160,7 +160,7 @@ public class FontInfoFinder { /** * Attempts to determine EmbedFontInfo from a given font file. - * + * * @param fontUrl font URL. Assumed to be local. * @param resolver font resolver used to resolve font * @param fontCache font cache (may be null) diff --git a/src/java/org/apache/fop/fonts/autodetect/MacFontDirFinder.java b/src/java/org/apache/fop/fonts/autodetect/MacFontDirFinder.java index 8083eebb8..1231badf2 100644 --- a/src/java/org/apache/fop/fonts/autodetect/MacFontDirFinder.java +++ b/src/java/org/apache/fop/fonts/autodetect/MacFontDirFinder.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,5 +35,5 @@ public class MacFontDirFinder extends NativeFontDirFinder { "/System/Library/Fonts/", // system "/Network/Library/Fonts/" // network }; - } + } } diff --git a/src/java/org/apache/fop/fonts/autodetect/NativeFontDirFinder.java b/src/java/org/apache/fop/fonts/autodetect/NativeFontDirFinder.java index 5339d541b..4072257b4 100644 --- a/src/java/org/apache/fop/fonts/autodetect/NativeFontDirFinder.java +++ b/src/java/org/apache/fop/fonts/autodetect/NativeFontDirFinder.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 java.util.List; * Native font finder base class */ public abstract class NativeFontDirFinder implements FontFinder { - + /** * Generic method used by Mac and Unix font finders. * @return list of natively existing font directories @@ -45,11 +45,11 @@ public abstract class NativeFontDirFinder implements FontFinder { } return fontDirList; } - + /** - * Returns an array of directories to search for fonts in. + * Returns an array of directories to search for fonts in. * @return an array of directories */ protected abstract String[] getSearchableDirectories(); - + } diff --git a/src/java/org/apache/fop/fonts/autodetect/UnixFontDirFinder.java b/src/java/org/apache/fop/fonts/autodetect/UnixFontDirFinder.java index d59fd5c7e..b6d596f03 100644 --- a/src/java/org/apache/fop/fonts/autodetect/UnixFontDirFinder.java +++ b/src/java/org/apache/fop/fonts/autodetect/UnixFontDirFinder.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,5 +36,5 @@ public class UnixFontDirFinder extends NativeFontDirFinder { "/usr/share/fonts", // system "/usr/X11R6/lib/X11/fonts" // X }; - } + } } diff --git a/src/java/org/apache/fop/fonts/autodetect/WindowsFontDirFinder.java b/src/java/org/apache/fop/fonts/autodetect/WindowsFontDirFinder.java index d87d22708..2e07229f6 100644 --- a/src/java/org/apache/fop/fonts/autodetect/WindowsFontDirFinder.java +++ b/src/java/org/apache/fop/fonts/autodetect/WindowsFontDirFinder.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,10 +29,10 @@ import java.util.List; * FontFinder for native Windows platforms */ public class WindowsFontDirFinder implements FontFinder { - + /** * Attempts to read windir environment variable on windows - * (disclaimer: This is a bit dirty but seems to work nicely) + * (disclaimer: This is a bit dirty but seems to work nicely) */ private String getWinDir(String osName) throws IOException { Process process = null; @@ -82,7 +82,7 @@ public class WindowsFontDirFinder implements FontFinder { fontDirList.add(psFontsDir); } } else { - String windowsDirName = osName.endsWith("NT") ? "WINNT" : "WINDOWS"; + String windowsDirName = osName.endsWith("NT") ? "WINNT" : "WINDOWS"; // look for true type font folder for (char driveLetter = 'C'; driveLetter <= 'E'; driveLetter++) { osFontsDir = new File( diff --git a/src/java/org/apache/fop/fonts/base14/Base14FontCollection.java b/src/java/org/apache/fop/fonts/base14/Base14FontCollection.java index 7bebccc88..1afc29b7b 100644 --- a/src/java/org/apache/fop/fonts/base14/Base14FontCollection.java +++ b/src/java/org/apache/fop/fonts/base14/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. @@ -32,7 +32,7 @@ public class Base14FontCollection implements FontCollection { /** * Main constructor - * + * * @param kerning set to true when font kerning is enabled */ public Base14FontCollection(boolean kerning) { diff --git a/src/java/org/apache/fop/fonts/substitute/AttributeValue.java b/src/java/org/apache/fop/fonts/substitute/AttributeValue.java index 44f2ff571..bfe888d3c 100644 --- a/src/java/org/apache/fop/fonts/substitute/AttributeValue.java +++ b/src/java/org/apache/fop/fonts/substitute/AttributeValue.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 AttributeValue extends java.util.ArrayList { /** * Returns an AttributeValue object holding the * value of the specified String. - * + * * @param valuesString the value to be parsed * @return an AttributeValue object holding the value * represented by the string argument. diff --git a/src/java/org/apache/fop/fonts/substitute/FontQualifier.java b/src/java/org/apache/fop/fonts/substitute/FontQualifier.java index 63ec13db1..3419ab2c7 100644 --- a/src/java/org/apache/fop/fonts/substitute/FontQualifier.java +++ b/src/java/org/apache/fop/fonts/substitute/FontQualifier.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. @@ -144,7 +144,7 @@ public class FontQualifier { /** * Returns a list of matching font triplet found in a given font info - * + * * @param fontInfo the font info * @return a list of matching font triplets */ diff --git a/src/java/org/apache/fop/fonts/substitute/FontSubstitution.java b/src/java/org/apache/fop/fonts/substitute/FontSubstitution.java index 7e9709a51..7725fc147 100644 --- a/src/java/org/apache/fop/fonts/substitute/FontSubstitution.java +++ b/src/java/org/apache/fop/fonts/substitute/FontSubstitution.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 FontSubstitution { /** * Main constructor - * + * * @param fromQualifier the substitution from qualifier * @param toQualifier the substitution to qualifier */ diff --git a/src/java/org/apache/fop/fonts/substitute/FontSubstitutions.java b/src/java/org/apache/fop/fonts/substitute/FontSubstitutions.java index cc4e74143..313ad04a8 100644 --- a/src/java/org/apache/fop/fonts/substitute/FontSubstitutions.java +++ b/src/java/org/apache/fop/fonts/substitute/FontSubstitutions.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/fonts/substitute/FontSubstitutionsConfigurator.java b/src/java/org/apache/fop/fonts/substitute/FontSubstitutionsConfigurator.java index 44950221d..0c6c0db0e 100644 --- a/src/java/org/apache/fop/fonts/substitute/FontSubstitutionsConfigurator.java +++ b/src/java/org/apache/fop/fonts/substitute/FontSubstitutionsConfigurator.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 FontSubstitutionsConfigurator { /** * Main constructor - * + * * @param cfg a configuration */ public FontSubstitutionsConfigurator(Configuration cfg) { @@ -59,7 +59,7 @@ public class FontSubstitutionsConfigurator { /** * Configures a font substitution catalog - * + * * @param substitutions font substitutions * @throws FOPException if something's wrong with the config data */ diff --git a/src/java/org/apache/fop/fonts/substitute/FontWeightRange.java b/src/java/org/apache/fop/fonts/substitute/FontWeightRange.java index 890d6cf7b..29ae0556d 100644 --- a/src/java/org/apache/fop/fonts/substitute/FontWeightRange.java +++ b/src/java/org/apache/fop/fonts/substitute/FontWeightRange.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 @@ public class FontWeightRange { /** * Returns an FontWeightRange object holding the * range values of the specified String. - * + * * @param weightRangeString the value range string * @return an FontWeightRange object holding the value ranges */ diff --git a/src/java/org/apache/fop/fonts/truetype/FontFileReader.java b/src/java/org/apache/fop/fonts/truetype/FontFileReader.java index 0d1af4785..d12b19654 100644 --- a/src/java/org/apache/fop/fonts/truetype/FontFileReader.java +++ b/src/java/org/apache/fop/fonts/truetype/FontFileReader.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.fonts.truetype; import java.io.File; diff --git a/src/java/org/apache/fop/fonts/truetype/TTFCmapEntry.java b/src/java/org/apache/fop/fonts/truetype/TTFCmapEntry.java index ce3f3efe9..171f71a76 100644 --- a/src/java/org/apache/fop/fonts/truetype/TTFCmapEntry.java +++ b/src/java/org/apache/fop/fonts/truetype/TTFCmapEntry.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.fonts.truetype; /** diff --git a/src/java/org/apache/fop/fonts/truetype/TTFDirTabEntry.java b/src/java/org/apache/fop/fonts/truetype/TTFDirTabEntry.java index c1dfc5ea0..405a71395 100644 --- a/src/java/org/apache/fop/fonts/truetype/TTFDirTabEntry.java +++ b/src/java/org/apache/fop/fonts/truetype/TTFDirTabEntry.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.fonts.truetype; import java.io.IOException; diff --git a/src/java/org/apache/fop/fonts/truetype/TTFFile.java b/src/java/org/apache/fop/fonts/truetype/TTFFile.java index 8c5211e67..f6b9ac020 100644 --- a/src/java/org/apache/fop/fonts/truetype/TTFFile.java +++ b/src/java/org/apache/fop/fonts/truetype/TTFFile.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. @@ -111,7 +111,7 @@ public class TTFFile { private int[] ansiWidth; private Map ansiIndex; - + // internal mapping of glyph indexes to unicode indexes // used for quick mappings in this class private Map glyphToUnicodeMap = new java.util.HashMap(); @@ -120,12 +120,12 @@ public class TTFFile { private TTFDirTabEntry currentDirTab; private boolean isCFF; - + /** * logging instance */ protected Log log = LogFactory.getLog(TTFFile.class); - + /** * Key-value helper class */ @@ -186,7 +186,7 @@ public class TTFFile { if (n < 0) { long rest1 = n % upem; long storrest = 1000 * rest1; - long ledd2 = (storrest != 0 ? rest1 / storrest : 0); + long ledd2 = (storrest != 0 ? rest1 / storrest : 0); ret = -((-1000 * n) / upem - (int)ledd2); } else { ret = (n / upem) * 1000 + ((n % upem) * 1000) / upem; @@ -329,7 +329,7 @@ public class TTFFile { Iterator e = v.listIterator(); while (e.hasNext()) { Integer aIdx = (Integer)e.next(); - ansiWidth[aIdx.intValue()] + ansiWidth[aIdx.intValue()] = mtxTab[glyphIdx].getWx(); if (log.isTraceEnabled()) { @@ -754,7 +754,7 @@ public class TTFFile { public boolean isCFF() { return this.isCFF; } - + /** * Read Table Directory from the current position in the * FontFileReader and fill the global HashMap dirTabs @@ -840,11 +840,11 @@ public class TTFFile { protected void readHorizontalHeader(FontFileReader in) throws IOException { seekTab(in, "hhea", 4); - hheaAscender = in.readTTFShort(); + hheaAscender = in.readTTFShort(); log.debug("hhea.Ascender: " + hheaAscender + " " + convertTTFUnit2PDFUnit(hheaAscender)); hheaDescender = in.readTTFShort(); log.debug("hhea.Descender: " + hheaDescender + " " + convertTTFUnit2PDFUnit(hheaDescender)); - + in.skip(2 + 2 + 3 * 2 + 8 * 2); nhmtx = in.readTTFUShort(); log.debug("Number of horizontal metrics: " + nhmtx); @@ -988,10 +988,10 @@ public class TTFFile { if (dirTabs.get("OS/2") != null) { seekTab(in, "OS/2", 2 * 2); this.usWeightClass = in.readTTFUShort(); - + // usWidthClass in.skip(2); - + int fsType = in.readTTFUShort(); if (fsType == 2) { isEmbeddable = false; @@ -1005,10 +1005,10 @@ public class TTFFile { in.skip(3 * 2); int v; os2Ascender = in.readTTFShort(); //sTypoAscender - log.debug("sTypoAscender: " + os2Ascender + log.debug("sTypoAscender: " + os2Ascender + " " + convertTTFUnit2PDFUnit(os2Ascender)); os2Descender = in.readTTFShort(); //sTypoDescender - log.debug("sTypoDescender: " + os2Descender + log.debug("sTypoDescender: " + os2Descender + " " + convertTTFUnit2PDFUnit(os2Descender)); v = in.readTTFShort(); //sTypoLineGap log.debug("sTypoLineGap: " + v); @@ -1021,7 +1021,7 @@ public class TTFFile { log.debug("sxHeight: " + this.os2xHeight); this.os2CapHeight = in.readTTFShort(); //sCapHeight log.debug("sCapHeight: " + this.os2CapHeight); - + } else { isEmbeddable = true; } @@ -1123,7 +1123,7 @@ public class TTFFile { int k = in.readTTFUShort(); int l = in.readTTFUShort(); - if (((platformID == 1 || platformID == 3) + if (((platformID == 1 || platformID == 3) && (encodingID == 0 || encodingID == 1))) { in.seekSet(j + in.readTTFUShort()); String txt; @@ -1132,9 +1132,9 @@ public class TTFFile { } else { txt = in.readTTFString(l); } - + if (log.isDebugEnabled()) { - log.debug(platformID + " " + log.debug(platformID + " " + encodingID + " " + languageID + " " + k + " " + txt); @@ -1182,11 +1182,11 @@ public class TTFFile { if (dirTab != null) { in.seekSet(dirTab.getOffset() + 4 + 4 + 2); xHeight = in.readTTFUShort(); - log.debug("xHeight from PCLT: " + xHeight + log.debug("xHeight from PCLT: " + xHeight + " " + convertTTFUnit2PDFUnit(xHeight)); in.skip(2 * 2); capHeight = in.readTTFUShort(); - log.debug("capHeight from PCLT: " + capHeight + log.debug("capHeight from PCLT: " + capHeight + " " + convertTTFUnit2PDFUnit(capHeight)); in.skip(2 + 16 + 8 + 6 + 1 + 1); @@ -1211,7 +1211,7 @@ public class TTFFile { * the hhea values are defined after the Apple interpretation, but not in every font. The * same problem is in the OS/2 table. FOP needs the ascender and descender to determine the * baseline so we need values which add up more or less to the "em box". However, due to - * accent modifiers a character can grow beyond the em box. + * accent modifiers a character can grow beyond the em box. */ private void determineAscDesc() { int hheaBoxHeight = hheaAscender - hheaDescender; @@ -1279,7 +1279,7 @@ public class TTFFile { } } } - log.debug("Ascender from glyph 'd': " + localAscender + log.debug("Ascender from glyph 'd': " + localAscender + " " + convertTTFUnit2PDFUnit(localAscender)); log.debug("Descender from glyph 'p': " + localDescender + " " + convertTTFUnit2PDFUnit(localDescender)); @@ -1351,7 +1351,7 @@ public class TTFFile { final Integer u2 = glyphToUnicode(j); if (iObj == null) { // happens for many fonts (Ubuntu font set), - // stray entries in the kerning table?? + // stray entries in the kerning table?? log.debug("Ignoring kerning pair because no Unicode index was" + " found for the first glyph " + i); } else if (u2 == null) { @@ -1370,7 +1370,7 @@ public class TTFFile { } // Create winAnsiEncoded kerning table from kerningTab - // (could probably be simplified, for now we remap back to CID indexes and + // (could probably be simplified, for now we remap back to CID indexes and // then to winAnsi) Iterator ae = kerningTab.keySet().iterator(); while (ae.hasNext()) { @@ -1534,7 +1534,7 @@ public class TTFFile { return null; } } - + /* * Helper classes, they are not very efficient, but that really * doesn't matter... @@ -1580,7 +1580,7 @@ public class TTFFile { /** * Map a glyph index to the corresponding unicode code point - * + * * @param glyphIndex * @return unicode code point * @throws IOException if glyphIndex not found @@ -1588,10 +1588,10 @@ public class TTFFile { private Integer glyphToUnicode(int glyphIndex) throws IOException { return (Integer) glyphToUnicodeMap.get(new Integer(glyphIndex)); } - + /** - * Map a unicode code point to the corresponding glyph index - * + * Map a unicode code point to the corresponding glyph index + * * @param unicodeIndex unicode code point * @return glyph index * @throws IOException if unicodeIndex not found @@ -1605,7 +1605,7 @@ public class TTFFile { } return result; } - + /** * Static main method to get info about a TrueType font. * @param args The command line arguments diff --git a/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java b/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java index 325c46971..e14514b51 100644 --- a/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java +++ b/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.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,7 +46,7 @@ public class TTFFontLoader extends FontLoader { private MultiByteFont multiFont; private SingleByteFont singleFont; private String subFontName; - + /** * Default constructor * @param fontFileURI the URI representing the font file @@ -55,7 +55,7 @@ public class TTFFontLoader extends FontLoader { public TTFFontLoader(String fontFileURI, FontResolver resolver) { this(fontFileURI, null, true, resolver); } - + /** * Additional constructor for TrueType Collections. * @param fontFileURI the URI representing the font file @@ -69,14 +69,14 @@ public class TTFFontLoader extends FontLoader { super(fontFileURI, embedded, resolver); this.subFontName = subFontName; } - + /** {@inheritDoc} */ protected void read() throws IOException { read(this.subFontName); } /** - * Reads a TrueType font. + * Reads a TrueType font. * @param ttcFontName the TrueType sub-font name of TrueType Collection (may be null for * normal TrueType fonts) * @throws IOException if an I/O error occurs @@ -96,16 +96,16 @@ public class TTFFontLoader extends FontLoader { IOUtils.closeQuietly(in); } } - - + + private void buildFont(TTFFile ttf, String ttcFontName) { if (ttf.isCFF()) { throw new UnsupportedOperationException( "OpenType fonts with CFF data are not supported, yet"); } - + boolean isCid = this.embedded; - + if (isCid) { multiFont = new MultiByteFont(); returnFont = multiFont; @@ -153,7 +153,7 @@ public class TTFFontLoader extends FontLoader { returnFont.setLastChar(ttf.getLastChar()); copyWidthsSingleByte(ttf); } - + copyKerning(ttf, isCid); if (this.embedded && ttf.isEmbeddable()) { multiFont.setEmbedFileName(this.fontFileURI); @@ -184,12 +184,12 @@ public class TTFFontLoader extends FontLoader { } } } - + /** * Copy kerning information. */ private void copyKerning(TTFFile ttf, boolean isCid) { - + // Get kerning Iterator iter; if (isCid) { @@ -209,5 +209,5 @@ public class TTFFontLoader extends FontLoader { } returnFont.putKerningEntry(kpx1, h2); } - } + } } diff --git a/src/java/org/apache/fop/fonts/truetype/TTFMtxEntry.java b/src/java/org/apache/fop/fonts/truetype/TTFMtxEntry.java index dae192404..6884a633d 100644 --- a/src/java/org/apache/fop/fonts/truetype/TTFMtxEntry.java +++ b/src/java/org/apache/fop/fonts/truetype/TTFMtxEntry.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.fonts.truetype; import java.util.List; @@ -37,7 +37,7 @@ class TTFMtxEntry { /** * Returns a String representation of this object. - * + * * @param t TTFFile to use for unit conversion * @return String String representation */ @@ -81,7 +81,7 @@ class TTFMtxEntry { public int getIndex() { return index; } - + /** * Determines whether this index represents a reserved character. * @return True if it is reserved @@ -89,7 +89,7 @@ class TTFMtxEntry { public boolean isIndexReserved() { return (getIndex() >= 32768) && (getIndex() <= 65535); } - + /** * Returns a String representation of the index taking into account if * the index is in the reserved range. diff --git a/src/java/org/apache/fop/fonts/truetype/TTFSubSetFile.java b/src/java/org/apache/fop/fonts/truetype/TTFSubSetFile.java index d593c4544..37e24836e 100644 --- a/src/java/org/apache/fop/fonts/truetype/TTFSubSetFile.java +++ b/src/java/org/apache/fop/fonts/truetype/TTFSubSetFile.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.fonts.truetype; import java.io.IOException; @@ -86,7 +86,7 @@ public class TTFSubSetFile extends TTFFile { } return numTables; } - + /** * Create the directory table */ @@ -651,7 +651,7 @@ public class TTFSubSetFile extends TTFFile { if (!checkTTC(in, name)) { throw new IOException("Failed to read font"); } - + //Copy the Map as we're going to modify it Map subsetGlyphs = new java.util.HashMap(glyphs); diff --git a/src/java/org/apache/fop/fonts/type1/AFMCharMetrics.java b/src/java/org/apache/fop/fonts/type1/AFMCharMetrics.java index 758078af4..4906f2c31 100644 --- a/src/java/org/apache/fop/fonts/type1/AFMCharMetrics.java +++ b/src/java/org/apache/fop/fonts/type1/AFMCharMetrics.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 AFMCharMetrics { private double widthX; private double widthY; private RectangularShape bBox; - + /** * Returns the character code. * @return the charCode (-1 if not part of the encoding) @@ -42,7 +42,7 @@ public class AFMCharMetrics { public int getCharCode() { return charCode; } - + /** * Indicates whether the character has a character code, i.e. is part of the default encoding. * @return true if there is a character code. @@ -50,7 +50,7 @@ public class AFMCharMetrics { public boolean hasCharCode() { return charCode >= 0; } - + /** * Sets the character code. * @param charCode the charCode to set @@ -58,7 +58,7 @@ public class AFMCharMetrics { public void setCharCode(int charCode) { this.charCode = charCode; } - + /** * Returns the named character represented by this instance. * @return the named character (or null if no named character is associated) @@ -66,7 +66,7 @@ public class AFMCharMetrics { public NamedCharacter getCharacter() { return this.character; } - + /** * Sets the named character represented by this instance. * @param ch the named character @@ -74,7 +74,7 @@ public class AFMCharMetrics { public void setCharacter(NamedCharacter ch) { this.character = ch; } - + /** * Sets the named character represented by this instance. * @param charName the character name (as defined in the Adobe glyph list) @@ -83,7 +83,7 @@ public class AFMCharMetrics { public void setCharacter(String charName, String unicodeSequence) { setCharacter(new NamedCharacter(charName, unicodeSequence)); } - + /** * Returns the Unicode sequence for this character. * @return the Unicode characters @@ -92,7 +92,7 @@ public class AFMCharMetrics { public String getUnicodeSequence() { return (getCharacter() != null ? getCharacter().getUnicodeSequence() : null); } - + /** * Returns the PostScript character name. * @return the charName (or null if no character name is associated) @@ -100,7 +100,7 @@ public class AFMCharMetrics { public String getCharName() { return (getCharacter() != null ? getCharacter().getName() : null); } - + /** * Returns the progression dimension in x-direction. * @return the widthX @@ -108,7 +108,7 @@ public class AFMCharMetrics { public double getWidthX() { return widthX; } - + /** * Sets the progression dimension in x-direction * @param widthX the widthX to set @@ -116,7 +116,7 @@ public class AFMCharMetrics { public void setWidthX(double widthX) { this.widthX = widthX; } - + /** * Returns the progression dimension in y-direction. * @return the widthY @@ -124,7 +124,7 @@ public class AFMCharMetrics { public double getWidthY() { return widthY; } - + /** * Sets the progression dimension in y-direction * @param widthY the widthY to set @@ -132,7 +132,7 @@ public class AFMCharMetrics { public void setWidthY(double widthY) { this.widthY = widthY; } - + /** * Returns the character's bounding box. * @return the bounding box (or null if it isn't available) @@ -163,5 +163,5 @@ public class AFMCharMetrics { sb.append(getCharName()).append(')'); return sb.toString(); } - + } diff --git a/src/java/org/apache/fop/fonts/type1/AFMFile.java b/src/java/org/apache/fop/fonts/type1/AFMFile.java index 3cb4b3343..c427ff22f 100644 --- a/src/java/org/apache/fop/fonts/type1/AFMFile.java +++ b/src/java/org/apache/fop/fonts/type1/AFMFile.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 AFMFile { private String fontName; private String fullName; private String familyName; - + private String weight; private RectangularShape fontBBox; - + private String encodingScheme; private String characterSet; - + private Number capHeight; private Number xHeight; private Number ascender; @@ -52,17 +52,17 @@ public class AFMFile { private AFMWritingDirectionMetrics[] writingDirectionMetrics = new AFMWritingDirectionMetrics[3]; - + private List charMetrics = new java.util.ArrayList(); //List private Map charNameToMetrics = new java.util.HashMap(); //Map private int firstChar = -1; private int lastChar = -1; - + private Map kerningMap; //Map> - + /** * Default constructor. */ @@ -149,10 +149,10 @@ public class AFMFile { public int[] getFontBBoxAsIntArray() { RectangularShape rect = getFontBBox(); return new int[] { - (int)Math.floor(rect.getMinX()), (int)Math.floor(rect.getMinY()), - (int)Math.ceil(rect.getMaxX()), (int)Math.ceil(rect.getMaxY())}; + (int)Math.floor(rect.getMinX()), (int)Math.floor(rect.getMinY()), + (int)Math.ceil(rect.getMaxX()), (int)Math.ceil(rect.getMaxY())}; } - + /** * Sets the FontBBox value. * @param fontBBox the fontBBox to set @@ -256,7 +256,7 @@ public class AFMFile { public void setDescender(Number descender) { this.descender = descender; } - + /** * Returns the StdHW value. * @return the descender @@ -272,7 +272,7 @@ public class AFMFile { public void setStdHW(Number stdHW) { this.stdHW = stdHW; } - + /** * Returns the StdVW value. * @return the descender @@ -288,7 +288,7 @@ public class AFMFile { public void setStdVW(Number stdVW) { this.stdVW = stdVW; } - + /** * Gets writing direction metrics. * @param index the writing direction (0, 1 or 2) @@ -297,7 +297,7 @@ public class AFMFile { public AFMWritingDirectionMetrics getWritingDirectionMetrics(int index) { return this.writingDirectionMetrics[index]; } - + /** * Sets writing direction metrics. * @param index the writing direction (0, 1 or 2) @@ -331,7 +331,7 @@ public class AFMFile { } } } - + /** * Returns the number of character available for this font. * @return the number of character @@ -339,7 +339,7 @@ public class AFMFile { public int getCharCount() { return this.charMetrics.size(); } - + /** * Returns the first character index in the encoding that has a glyph. * @return the first character index with a glyph @@ -347,7 +347,7 @@ public class AFMFile { public int getFirstChar() { return this.firstChar; } - + /** * Returns the last character index in the encoding that has a glyph. * @return the last character index with a glyph @@ -355,7 +355,7 @@ public class AFMFile { public int getLastChar() { return this.lastChar; } - + /** * Returns the character metrics associated with the character name. * @param name the character name @@ -364,7 +364,7 @@ public class AFMFile { public AFMCharMetrics getChar(String name) { return (AFMCharMetrics)this.charNameToMetrics.get(name); } - + /** * Returns the list of AFMCharMetrics instances representing all the available characters. * @return a List of AFMCharMetrics instances @@ -372,7 +372,7 @@ public class AFMFile { public List getCharMetrics() { return Collections.unmodifiableList(this.charMetrics); } - + /** * Adds a X-kerning entry. * @param name1 the name of the first character @@ -390,7 +390,7 @@ public class AFMFile { } entries.put(name2, new Dimension2DDouble(kx, 0)); } - + /** * Indicates whether the font has kerning information. * @return true if there is kerning information @@ -398,7 +398,7 @@ public class AFMFile { public boolean hasKerning() { return this.kerningMap != null; } - + /** * Creates and returns a kerning map for writing mode 0 (ltr) with character codes. * @return the kerning map or null if there is no kerning information. @@ -441,10 +441,10 @@ public class AFMFile { } return m; } - + /** {@inheritDoc} */ public String toString() { return "AFM: " + getFullName(); } - + } diff --git a/src/java/org/apache/fop/fonts/type1/AFMParser.java b/src/java/org/apache/fop/fonts/type1/AFMParser.java index 2e63ea729..0479c57a7 100644 --- a/src/java/org/apache/fop/fonts/type1/AFMParser.java +++ b/src/java/org/apache/fop/fonts/type1/AFMParser.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.fonts.NamedCharacter; * Parses the contents of a Type 1 AFM font metrics file into an object structure ({@link AFMFile}). */ public class AFMParser { - + private static final String START_FONT_METRICS = "StartFontMetrics"; //private static final String END_FONT_METRICS = "EndFontMetrics"; private static final String FONT_NAME = "FontName"; @@ -89,10 +89,10 @@ public class AFMParser { private static final int PARSE_NORMAL = 0; private static final int PARSE_CHAR_METRICS = 1; - + private static final Map VALUE_PARSERS; private static final Map PARSE_MODE_CHANGES; - + static { VALUE_PARSERS = new java.util.HashMap(); VALUE_PARSERS.put(START_FONT_METRICS, new StartFontMetrics()); @@ -142,7 +142,7 @@ public class AFMParser { PARSE_MODE_CHANGES.put(START_CHAR_METRICS, new Integer(PARSE_CHAR_METRICS)); PARSE_MODE_CHANGES.put(END_CHAR_METRICS, new Integer(PARSE_NORMAL)); } - + /** * Main constructor. */ @@ -164,7 +164,7 @@ public class AFMParser { IOUtils.closeQuietly(in); } } - + /** * Parses an AFM file from a stream. * @param in the stream to read from @@ -212,14 +212,14 @@ public class AFMParser { } return (AFMFile)stack.pop(); } - + private String parseLine(String line, Stack stack) throws IOException { int startpos = 0; //Find key startpos = skipToNonWhiteSpace(line, startpos); int endpos = skipToWhiteSpace(line, startpos); String key = line.substring(startpos, endpos); - + //Parse value startpos = skipToNonWhiteSpace(line, endpos); ValueHandler vp = (ValueHandler)VALUE_PARSERS.get(key); @@ -228,7 +228,7 @@ public class AFMParser { } return key; } - + private String parseCharMetrics(String line, Stack stack) throws IOException { int startpos = 0; AFMCharMetrics chm = new AFMCharMetrics(); @@ -245,13 +245,13 @@ public class AFMParser { //EOL: No more key so break break; } - + //Extract value startpos = skipToNonWhiteSpace(line, endpos); endpos = skipToSemicolon(line, startpos); String value = line.substring(startpos, endpos).trim(); startpos = endpos + 1; - + //Parse value ValueHandler vp = (ValueHandler)VALUE_PARSERS.get(key); if (vp != null) { @@ -266,7 +266,7 @@ public class AFMParser { afm.addCharMetrics(chm); return null; } - + private static int skipToNonWhiteSpace(String line, int startpos) { int pos = startpos; while (pos < line.length() && isWhitespace(line.charAt(pos))) { @@ -297,21 +297,21 @@ public class AFMParser { } // ---------------- Value Handlers --------------------------- - + private interface ValueHandler { void parse(String line, int startpos, Stack stack) throws IOException; } - + private abstract static class AbstractValueHandler implements ValueHandler { - + protected int findValue(String line, int startpos) { return skipToWhiteSpace(line, startpos); } - + protected String getStringValue(String line, int startpos) { return line.substring(startpos); } - + protected Number getNumberValue(String line, int startpos) { try { return new Integer(getIntegerValue(line, startpos)); @@ -319,23 +319,23 @@ public class AFMParser { return new Double(getDoubleValue(line, startpos)); } } - + protected int getIntegerValue(String line, int startpos) { int endpos = findValue(line, startpos); return Integer.parseInt(line.substring(startpos, endpos)); } - + protected double getDoubleValue(String line, int startpos) { int endpos = findValue(line, startpos); return Double.parseDouble(line.substring(startpos, endpos)); } - + protected Boolean getBooleanValue(String line, int startpos) { return Boolean.valueOf(getStringValue(line, startpos)); } - + } - + private static class StartFontMetrics extends AbstractValueHandler { public void parse(String line, int startpos, Stack stack) throws IOException { int endpos = findValue(line, startpos); @@ -348,14 +348,14 @@ public class AFMParser { stack.push(afm); } } - + private abstract static class BeanSetter extends AbstractValueHandler { private String method; - + public BeanSetter(String variable) { this.method = "set" + variable; } - + protected void setValue(Object target, Object value) { //Uses Java Beans API Statement statement = new Statement(target, method, new Object[] {value}); @@ -367,76 +367,76 @@ public class AFMParser { } } } - + private static class StringSetter extends BeanSetter { - + public StringSetter(String variable) { super(variable); } - + public void parse(String line, int startpos, Stack stack) throws IOException { String s = getStringValue(line, startpos); Object obj = stack.peek(); setValue(obj, s); } } - + private static class NamedCharacterSetter extends BeanSetter { - + public NamedCharacterSetter(String variable) { super(variable); } - + public void parse(String line, int startpos, Stack stack) throws IOException { NamedCharacter ch = new NamedCharacter(getStringValue(line, startpos)); Object obj = stack.peek(); setValue(obj, ch); } } - + private static class NumberSetter extends BeanSetter { public NumberSetter(String variable) { super(variable); } - + protected Object getContextObject(Stack stack) { return stack.peek(); } - + public void parse(String line, int startpos, Stack stack) throws IOException { Number num = getNumberValue(line, startpos); setValue(getContextObject(stack), num); } } - + private static class IntegerSetter extends NumberSetter { public IntegerSetter(String variable) { super(variable); } - + public void parse(String line, int startpos, Stack stack) throws IOException { int value = getIntegerValue(line, startpos); setValue(getContextObject(stack), new Integer(value)); } } - + private static class DoubleSetter extends NumberSetter { public DoubleSetter(String variable) { super(variable); } - + public void parse(String line, int startpos, Stack stack) throws IOException { double value = getDoubleValue(line, startpos); setValue(getContextObject(stack), new Double(value)); } } - + private static class WritingDirNumberSetter extends NumberSetter { public WritingDirNumberSetter(String variable) { super(variable); } - + protected Object getContextObject(Stack stack) { if (stack.peek() instanceof AFMWritingDirectionMetrics) { return (AFMWritingDirectionMetrics)stack.peek(); @@ -450,32 +450,32 @@ public class AFMParser { return wdm; } } - + } - + private static class WritingDirDoubleSetter extends WritingDirNumberSetter { public WritingDirDoubleSetter(String variable) { super(variable); } - + public void parse(String line, int startpos, Stack stack) throws IOException { double value = getDoubleValue(line, startpos); setValue(getContextObject(stack), new Double(value)); } } - + private static class BooleanSetter extends AbstractValueHandler { private String method; - + public BooleanSetter(String variable) { this.method = "set" + variable.substring(2); //Cut "Is" in front } - + protected Object getContextObject(Stack stack) { return (AFMFile)stack.peek(); } - + public void parse(String line, int startpos, Stack stack) throws IOException { Boolean b = getBooleanValue(line, startpos); //Uses Java Beans API @@ -489,13 +489,13 @@ public class AFMParser { } } } - + private static class WritingDirBooleanSetter extends BooleanSetter { public WritingDirBooleanSetter(String variable) { super(variable); } - + protected Object getContextObject(Stack stack) { if (stack.peek() instanceof AFMWritingDirectionMetrics) { return (AFMWritingDirectionMetrics)stack.peek(); @@ -509,13 +509,13 @@ public class AFMParser { return wdm; } } - + } - + private static class FontBBox extends AbstractValueHandler { public void parse(String line, int startpos, Stack stack) throws IOException { Rectangle rect = parseBBox(line, startpos); - + AFMFile afm = (AFMFile)stack.peek(); afm.setFontBBox(rect); } @@ -523,20 +523,20 @@ public class AFMParser { protected Rectangle parseBBox(String line, int startpos) { Rectangle rect = new Rectangle(); int endpos; - + endpos = findValue(line, startpos); rect.x = Integer.parseInt(line.substring(startpos, endpos)); startpos = skipToNonWhiteSpace(line, endpos); - + endpos = findValue(line, startpos); rect.y = Integer.parseInt(line.substring(startpos, endpos)); startpos = skipToNonWhiteSpace(line, endpos); - + endpos = findValue(line, startpos); int v = Integer.parseInt(line.substring(startpos, endpos)); rect.width = v - rect.x; startpos = skipToNonWhiteSpace(line, endpos); - + endpos = findValue(line, startpos); v = Integer.parseInt(line.substring(startpos, endpos)); rect.height = v - rect.y; @@ -544,11 +544,11 @@ public class AFMParser { return rect; } } - + private static class CharBBox extends FontBBox { public void parse(String line, int startpos, Stack stack) throws IOException { Rectangle rect = parseBBox(line, startpos); - + AFMCharMetrics metrics = (AFMCharMetrics)stack.peek(); metrics.setBBox(rect); } @@ -561,7 +561,7 @@ public class AFMParser { } } } - + private static class IsCIDFont extends AbstractValueHandler { public void parse(String line, int startpos, Stack stack) throws IOException { if (getBooleanValue(line, startpos).booleanValue()) { @@ -569,20 +569,20 @@ public class AFMParser { } } } - + private static class NotImplementedYet extends AbstractValueHandler { private String key; - + public NotImplementedYet(String key) { this.key = key; } - + public void parse(String line, int startpos, Stack stack) throws IOException { throw new IOException("Support for '" + key + "' has not been implemented, yet! Font is not supported."); } } - + private static class StartDirection extends AbstractValueHandler { public void parse(String line, int startpos, Stack stack) throws IOException { int index = getIntegerValue(line, startpos); @@ -592,7 +592,7 @@ public class AFMParser { stack.push(wdm); } } - + private static class EndDirection extends AbstractValueHandler { public void parse(String line, int startpos, Stack stack) throws IOException { if (!(stack.pop() instanceof AFMWritingDirectionMetrics)) { @@ -600,26 +600,26 @@ public class AFMParser { } } } - + private static class KPXHandler extends AbstractValueHandler { public void parse(String line, int startpos, Stack stack) throws IOException { AFMFile afm = (AFMFile)stack.peek(); int endpos; - + endpos = findValue(line, startpos); String name1 = line.substring(startpos, endpos); startpos = skipToNonWhiteSpace(line, endpos); - + endpos = findValue(line, startpos); String name2 = line.substring(startpos, endpos); startpos = skipToNonWhiteSpace(line, endpos); - + endpos = findValue(line, startpos); double kx = Double.parseDouble(line.substring(startpos, endpos)); startpos = skipToNonWhiteSpace(line, endpos); - + afm.addXKerning(name1, name2, kx); } } - + } diff --git a/src/java/org/apache/fop/fonts/type1/AFMWritingDirectionMetrics.java b/src/java/org/apache/fop/fonts/type1/AFMWritingDirectionMetrics.java index 5b6a9e43b..07d522bd9 100644 --- a/src/java/org/apache/fop/fonts/type1/AFMWritingDirectionMetrics.java +++ b/src/java/org/apache/fop/fonts/type1/AFMWritingDirectionMetrics.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 @@ public class AFMWritingDirectionMetrics { private Number underlineThickness; private double italicAngle; private boolean isFixedPitch; - + /** * Returns the UnderlinePosition value. * @return the underlinePosition @@ -36,15 +36,15 @@ public class AFMWritingDirectionMetrics { public Number getUnderlinePosition() { return underlinePosition; } - + /** - * Sets the UnderlinePosition value. + * Sets the UnderlinePosition value. * @param underlinePosition the underlinePosition to set */ public void setUnderlinePosition(Number underlinePosition) { this.underlinePosition = underlinePosition; } - + /** * Returns the UnderlineThickness value. * @return the underlineThickness @@ -52,7 +52,7 @@ public class AFMWritingDirectionMetrics { public Number getUnderlineThickness() { return underlineThickness; } - + /** * Sets the UnderlineThickness value. * @param underlineThickness the underlineThickness to set @@ -60,7 +60,7 @@ public class AFMWritingDirectionMetrics { public void setUnderlineThickness(Number underlineThickness) { this.underlineThickness = underlineThickness; } - + /** * Returns the ItalicAngle value. * @return the italicAngle @@ -68,7 +68,7 @@ public class AFMWritingDirectionMetrics { public double getItalicAngle() { return italicAngle; } - + /** * Sets the ItalicAngle value. * @param italicAngle the italicAngle to set @@ -76,7 +76,7 @@ public class AFMWritingDirectionMetrics { public void setItalicAngle(double italicAngle) { this.italicAngle = italicAngle; } - + /** * Returns the IsFixedPitch value. * @return the isFixedPitch @@ -84,7 +84,7 @@ public class AFMWritingDirectionMetrics { public boolean isFixedPitch() { return isFixedPitch; } - + /** * Set the IsFixedPitch value. * @param value the isFixedPitch to set @@ -92,5 +92,5 @@ public class AFMWritingDirectionMetrics { public void setFixedPitch(boolean value) { this.isFixedPitch = value; } - + } diff --git a/src/java/org/apache/fop/fonts/type1/PFBData.java b/src/java/org/apache/fop/fonts/type1/PFBData.java index 4575fe200..157dc8066 100644 --- a/src/java/org/apache/fop/fonts/type1/PFBData.java +++ b/src/java/org/apache/fop/fonts/type1/PFBData.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.fonts.type1; import java.io.OutputStream; @@ -24,7 +24,7 @@ import java.io.IOException; /** * Class that represents the contents of a PFB file. - * + * * @see PFBParser */ public class PFBData { @@ -33,12 +33,12 @@ public class PFBData { * Raw format, no special file structure */ public static final int PFB_RAW = 0; - + /** * PC format */ public static final int PFB_PC = 1; - + /** * MAC Format (unsupported, yet) */ diff --git a/src/java/org/apache/fop/fonts/type1/PFBParser.java b/src/java/org/apache/fop/fonts/type1/PFBParser.java index d0bc755b6..bd12c2c77 100644 --- a/src/java/org/apache/fop/fonts/type1/PFBParser.java +++ b/src/java/org/apache/fop/fonts/type1/PFBParser.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.fonts.type1; import java.io.IOException; @@ -29,7 +29,7 @@ import org.apache.commons.io.IOUtils; /** * This class represents a parser for Adobe Type 1 PFB files. - * + * * @see PFBData */ public class PFBParser { @@ -104,7 +104,7 @@ public class PFBParser { private static int swapInteger(final int value) { - return (((value >> 0) & 0xff) << 24) + return (((value >> 0) & 0xff) << 24) + (((value >> 8) & 0xff) << 16) + (((value >> 16) & 0xff) << 8) + (((value >> 24) & 0xff) << 0); diff --git a/src/java/org/apache/fop/fonts/type1/PFMFile.java b/src/java/org/apache/fop/fonts/type1/PFMFile.java index 69f8e836f..d2d587d90 100644 --- a/src/java/org/apache/fop/fonts/type1/PFMFile.java +++ b/src/java/org/apache/fop/fonts/type1/PFMFile.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. @@ -315,7 +315,7 @@ public class PFMFile { + ", 0x" + Integer.toHexString(dfCharSet) + "). Trying fallback to WinAnsi."); } - return "WinAnsi"; + return "WinAnsi"; } /** @@ -406,14 +406,14 @@ public class PFMFile { } /** - * Indicates whether the font is non-symbolic (Font uses the Adobe standard Latin character + * Indicates whether the font is non-symbolic (Font uses the Adobe standard Latin character * set or a subset of it). * @return true if the font is non-symbolic */ public boolean isNonSymbolic() { return (dfCharSet != 2); //!= Symbol fonts } - + /** * Returns the characteristics flags for the font as * needed for a PDF font descriptor (See PDF specs). diff --git a/src/java/org/apache/fop/fonts/type1/PFMInputStream.java b/src/java/org/apache/fop/fonts/type1/PFMInputStream.java index 8007ac049..596bf69bd 100644 --- a/src/java/org/apache/fop/fonts/type1/PFMInputStream.java +++ b/src/java/org/apache/fop/fonts/type1/PFMInputStream.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.fonts.type1; import java.io.IOException; @@ -33,7 +33,7 @@ public class PFMInputStream extends java.io.FilterInputStream { private DataInputStream datain; /** - * Constructs a PFMInputStream based on an InputStream representing the + * Constructs a PFMInputStream based on an InputStream representing the * PFM file. * * @param in The stream from which to read the PFM file diff --git a/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java b/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java index ffb572109..5438d3a42 100644 --- a/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java +++ b/src/java/org/apache/fop/fonts/type1/Type1FontLoader.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. @@ -40,7 +40,7 @@ import org.apache.fop.fonts.SingleByteFont; public class Type1FontLoader extends FontLoader { private SingleByteFont singleFont; - + /** * Constructs a new Type 1 font loader. * @param fontFileURI the URI to the PFB file of a Type 1 font @@ -48,7 +48,7 @@ public class Type1FontLoader extends FontLoader { * @param resolver the font resolver used to resolve URIs * @throws IOException In case of an I/O error */ - public Type1FontLoader(String fontFileURI, boolean embedded, FontResolver resolver) + public Type1FontLoader(String fontFileURI, boolean embedded, FontResolver resolver) throws IOException { super(fontFileURI, embedded, resolver); } @@ -59,14 +59,14 @@ public class Type1FontLoader extends FontLoader { + (Character.isUpperCase(pfbExt.charAt(2)) ? "M" : "m"); return pfbURI.substring(0, pfbURI.length() - 4) + "." + pfmExt; } - + private static final String[] AFM_EXTENSIONS = new String[] {".AFM", ".afm", ".Afm"}; - + /** {@inheritDoc} */ protected void read() throws IOException { AFMFile afm = null; PFMFile pfm = null; - + InputStream afmIn = null; for (int i = 0; i < AFM_EXTENSIONS.length; i++) { try { @@ -88,7 +88,7 @@ public class Type1FontLoader extends FontLoader { IOUtils.closeQuietly(afmIn); } } - + String pfmUri = getPFMURI(this.fontFileURI); InputStream pfmIn = null; try { @@ -104,7 +104,7 @@ public class Type1FontLoader extends FontLoader { IOUtils.closeQuietly(pfmIn); } } - + if (afm == null && pfm == null) { throw new java.io.FileNotFoundException( "Neither an AFM nor a PFM file was found for " + this.fontFileURI); @@ -124,7 +124,7 @@ public class Type1FontLoader extends FontLoader { singleFont.setEmbedFileName(this.fontFileURI); } returnFont = singleFont; - + handleEncoding(afm, pfm); handleFontName(afm, pfm); handleMetrics(afm, pfm); @@ -162,7 +162,7 @@ public class Type1FontLoader extends FontLoader { if (pfm.getCharSet() >= 0 && pfm.getCharSet() <= 2) { singleFont.setEncoding(pfm.getCharSetName() + "Encoding"); } else { - log.warn("The PFM reports an unsupported encoding (" + log.warn("The PFM reports an unsupported encoding (" + pfm.getCharSetName() + "). The font may not work as expected."); singleFont.setEncoding("WinAnsiEncoding"); //Try fallback, no guarantees! } @@ -203,7 +203,7 @@ public class Type1FontLoader extends FontLoader { if (afm.getDescender() != null) { returnFont.setDescender(afm.getDescender().intValue()); } - + returnFont.setFontBBox(afm.getFontBBoxAsIntArray()); if (afm.getStdVW() != null) { returnFont.setStemV(afm.getStdVW().intValue()); @@ -231,7 +231,7 @@ public class Type1FontLoader extends FontLoader { returnFont.setDescender(pfm.getLowerCaseDescent()); } } - + //Fallbacks when some crucial font metrics aren't available //(the following are all optional in AFM, but FontBBox is always available) if (returnFont.getXHeight(1) == 0) { @@ -285,7 +285,7 @@ public class Type1FontLoader extends FontLoader { if (returnFont.getCapHeight() == 0) { returnFont.setCapHeight(returnFont.getAscender()); } - + if (afm != null) { String charSet = afm.getCharacterSet(); int flags = 0; @@ -306,7 +306,7 @@ public class Type1FontLoader extends FontLoader { flags |= 64; //bit 7: Italic } returnFont.setFlags(flags); - + returnFont.setFirstChar(afm.getFirstChar()); returnFont.setLastChar(afm.getLastChar()); Iterator iter = afm.getCharMetrics().iterator(); diff --git a/src/java/org/apache/fop/hyphenation/ByteVector.java b/src/java/org/apache/fop/hyphenation/ByteVector.java index c4ca1d410..5a81a51ec 100644 --- a/src/java/org/apache/fop/hyphenation/ByteVector.java +++ b/src/java/org/apache/fop/hyphenation/ByteVector.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.hyphenation; import java.io.Serializable; diff --git a/src/java/org/apache/fop/hyphenation/CharVector.java b/src/java/org/apache/fop/hyphenation/CharVector.java index d0b51139e..ad8280f12 100644 --- a/src/java/org/apache/fop/hyphenation/CharVector.java +++ b/src/java/org/apache/fop/hyphenation/CharVector.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.hyphenation; import java.io.Serializable; diff --git a/src/java/org/apache/fop/hyphenation/Hyphen.java b/src/java/org/apache/fop/hyphenation/Hyphen.java index 848801fc5..268e3861d 100644 --- a/src/java/org/apache/fop/hyphenation/Hyphen.java +++ b/src/java/org/apache/fop/hyphenation/Hyphen.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.hyphenation; import java.io.Serializable; @@ -52,8 +52,8 @@ public class Hyphen implements Serializable { } public String toString() { - if (noBreak == null - && postBreak == null + if (noBreak == null + && postBreak == null && preBreak != null && preBreak.equals("-")) { return "-"; diff --git a/src/java/org/apache/fop/hyphenation/Hyphenation.java b/src/java/org/apache/fop/hyphenation/Hyphenation.java index b804164ff..fe4d6ba0c 100644 --- a/src/java/org/apache/fop/hyphenation/Hyphenation.java +++ b/src/java/org/apache/fop/hyphenation/Hyphenation.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.hyphenation; /** @@ -25,7 +25,7 @@ package org.apache.fop.hyphenation; * @author Carlos Villegas */ public class Hyphenation { - + private int[] hyphenPoints; private String word; diff --git a/src/java/org/apache/fop/hyphenation/HyphenationException.java b/src/java/org/apache/fop/hyphenation/HyphenationException.java index 1d2af2bb1..0a4e737c6 100644 --- a/src/java/org/apache/fop/hyphenation/HyphenationException.java +++ b/src/java/org/apache/fop/hyphenation/HyphenationException.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/hyphenation/HyphenationTree.java b/src/java/org/apache/fop/hyphenation/HyphenationTree.java index d145936c6..41d4cc63c 100644 --- a/src/java/org/apache/fop/hyphenation/HyphenationTree.java +++ b/src/java/org/apache/fop/hyphenation/HyphenationTree.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.hyphenation; import java.io.BufferedReader; @@ -41,7 +41,7 @@ import org.xml.sax.InputSource; * * @author Carlos Villegas */ -public class HyphenationTree extends TernaryTree +public class HyphenationTree extends TernaryTree implements PatternConsumer, Serializable { private static final long serialVersionUID = -7842107987915665573L; @@ -128,7 +128,7 @@ public class HyphenationTree extends TernaryTree InputSource src = new InputSource(f.toURI().toURL().toExternalForm()); loadPatterns(src); } catch (MalformedURLException e) { - throw new HyphenationException("Error converting the File '" + f + "' to a URL: " + throw new HyphenationException("Error converting the File '" + f + "' to a URL: " + e.getMessage()); } } diff --git a/src/java/org/apache/fop/hyphenation/HyphenationTreeCache.java b/src/java/org/apache/fop/hyphenation/HyphenationTreeCache.java index 04041525f..5831e2b98 100644 --- a/src/java/org/apache/fop/hyphenation/HyphenationTreeCache.java +++ b/src/java/org/apache/fop/hyphenation/HyphenationTreeCache.java @@ -31,7 +31,7 @@ public class HyphenationTreeCache { private Hashtable hyphenTrees = new Hashtable(); /** Used to avoid multiple error messages for the same language if a pattern file is missing. */ private Set missingHyphenationTrees; - + /** * Looks in the cache if a hyphenation tree is available and returns it if it is found. * @param lang the language @@ -40,7 +40,7 @@ public class HyphenationTreeCache { */ public HyphenationTree getHyphenationTree(String lang, String country) { String key = constructKey(lang, country); - + // first try to find it in the cache if (hyphenTrees.containsKey(key)) { return (HyphenationTree)hyphenTrees.get(key); @@ -50,7 +50,7 @@ public class HyphenationTreeCache { return null; } } - + /** * Constructs the key for the hyphenation pattern file. * @param lang the language @@ -65,7 +65,7 @@ public class HyphenationTreeCache { } return key; } - + /** * Cache a hyphenation tree under its key. * @param key the key (ex. "de_CH" or "en") @@ -74,10 +74,10 @@ public class HyphenationTreeCache { public void cache(String key, HyphenationTree hTree) { hyphenTrees.put(key, hTree); } - + /** * Notes a key to a hyphenation tree as missing. - * This is to avoid searching a second time for a hyphneation pattern file which is not + * This is to avoid searching a second time for a hyphneation pattern file which is not * available. * @param key the key (ex. "de_CH" or "en") */ @@ -87,10 +87,10 @@ public class HyphenationTreeCache { } missingHyphenationTrees.add(key); } - + /** * Indicates whether a hyphenation file has been requested before but it wasn't available. - * This is to avoid searching a second time for a hyphneation pattern file which is not + * This is to avoid searching a second time for a hyphneation pattern file which is not * available. * @param key the key (ex. "de_CH" or "en") * @return true if the hyphenation tree is unavailable @@ -98,5 +98,5 @@ public class HyphenationTreeCache { public boolean isMissing(String key) { return (missingHyphenationTrees != null && missingHyphenationTrees.contains(key)); } - + } diff --git a/src/java/org/apache/fop/hyphenation/HyphenationTreeResolver.java b/src/java/org/apache/fop/hyphenation/HyphenationTreeResolver.java index 39146c3d7..5aec688b0 100644 --- a/src/java/org/apache/fop/hyphenation/HyphenationTreeResolver.java +++ b/src/java/org/apache/fop/hyphenation/HyphenationTreeResolver.java @@ -34,5 +34,5 @@ public interface HyphenationTreeResolver { * @return A Source object, or null if the href could not resolved. */ Source resolve(String href); - + } diff --git a/src/java/org/apache/fop/hyphenation/Hyphenator.java b/src/java/org/apache/fop/hyphenation/Hyphenator.java index a537a9d01..401cc6e3b 100644 --- a/src/java/org/apache/fop/hyphenation/Hyphenator.java +++ b/src/java/org/apache/fop/hyphenation/Hyphenator.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.hyphenation; import java.io.BufferedInputStream; @@ -40,12 +40,12 @@ import org.xml.sax.InputSource; * @author Carlos Villegas */ public class Hyphenator { - + /** logging instance */ protected static Log log = LogFactory.getLog(Hyphenator.class); private static HyphenationTreeCache hTreeCache = null; - + private HyphenationTree hyphenTree = null; private int remainCharCount = 2; private int pushCharCount = 2; @@ -73,7 +73,7 @@ public class Hyphenator { } return hTreeCache; } - + /** * Returns a hyphenation tree for a given language and country. The hyphenation trees are * cached. @@ -83,9 +83,9 @@ public class Hyphenator { */ public static HyphenationTree getHyphenationTree(String lang, String country) { - return getHyphenationTree(lang, country, null); + return getHyphenationTree(lang, country, null); } - + /** * Returns a hyphenation tree for a given language and country. The hyphenation trees are * cached. @@ -98,12 +98,12 @@ public class Hyphenator { String country, HyphenationTreeResolver resolver) { String key = HyphenationTreeCache.constructKey(lang, country); HyphenationTreeCache cache = getHyphenationTreeCache(); - + // See if there was an error finding this hyphenation tree before if (cache.isMissing(key)) { return null; } - + HyphenationTree hTree; // first try to find it in the cache hTree = getHyphenationTreeCache().getHyphenationTree(lang, country); @@ -117,7 +117,7 @@ public class Hyphenator { if (hTree == null) { hTree = getFopHyphenationTree(key); } - + // put it into the pattern cache if (hTree != null) { cache.cache(key, hTree); @@ -165,7 +165,7 @@ public class Hyphenator { } return hTree; } - + /** * Returns a hyphenation tree. This method looks in the resources (getResourceStream) for * the hyphenation patterns. @@ -230,7 +230,7 @@ public class Hyphenator { }; return getUserHyphenationTree(key, resolver); } - + /** * Load tree from serialized file or xml file * using configuration settings @@ -301,7 +301,7 @@ public class Hyphenator { } try { InputSource src = new InputSource(in); - src.setSystemId(source.getSystemId()); + src.setSystemId(source.getSystemId()); hTree.loadPatterns(src); } finally { IOUtils.closeQuietly(in); @@ -341,7 +341,7 @@ public class Hyphenator { */ public static Hyphenation hyphenate(String lang, String country, HyphenationTreeResolver resolver, - String word, + String word, int leftMin, int rightMin) { HyphenationTree hTree = getHyphenationTree(lang, country, resolver); if (hTree == null) { @@ -360,7 +360,7 @@ public class Hyphenator { * @return the hyphenation result */ public static Hyphenation hyphenate(String lang, String country, - String word, + String word, int leftMin, int rightMin) { return hyphenate(lang, country, null, word, leftMin, rightMin); } diff --git a/src/java/org/apache/fop/hyphenation/PatternConsumer.java b/src/java/org/apache/fop/hyphenation/PatternConsumer.java index 4053f2767..6263b5534 100644 --- a/src/java/org/apache/fop/hyphenation/PatternConsumer.java +++ b/src/java/org/apache/fop/hyphenation/PatternConsumer.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.hyphenation; import java.util.ArrayList; diff --git a/src/java/org/apache/fop/hyphenation/PatternParser.java b/src/java/org/apache/fop/hyphenation/PatternParser.java index 2edf64676..6bd423a26 100644 --- a/src/java/org/apache/fop/hyphenation/PatternParser.java +++ b/src/java/org/apache/fop/hyphenation/PatternParser.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.hyphenation; // SAX @@ -84,7 +84,7 @@ public class PatternParser extends DefaultHandler implements PatternConsumer { public void parse(String filename) throws HyphenationException { parse(new File(filename)); } - + /** * Parses a hyphenation pattern file. * @param file the pattern file @@ -95,7 +95,7 @@ public class PatternParser extends DefaultHandler implements PatternConsumer { InputSource src = new InputSource(file.toURI().toURL().toExternalForm()); parse(src); } catch (MalformedURLException e) { - throw new HyphenationException("Error converting the File '" + file + "' to a URL: " + throw new HyphenationException("Error converting the File '" + file + "' to a URL: " + e.getMessage()); } } @@ -116,7 +116,7 @@ public class PatternParser extends DefaultHandler implements PatternConsumer { throw new HyphenationException(errMsg); } } - + /** * Creates a SAX parser using JAXP * @return the created SAX parser @@ -254,7 +254,7 @@ public class PatternParser extends DefaultHandler implements PatternConsumer { // /** - * {@inheritDoc} + * {@inheritDoc} */ public void startElement(String uri, String local, String raw, Attributes attrs) { @@ -283,7 +283,7 @@ public class PatternParser extends DefaultHandler implements PatternConsumer { } /** - * {@inheritDoc} + * {@inheritDoc} */ public void endElement(String uri, String local, String raw) { @@ -320,7 +320,7 @@ public class PatternParser extends DefaultHandler implements PatternConsumer { } /** - * {@inheritDoc} + * {@inheritDoc} */ public void characters(char ch[], int start, int length) { StringBuffer chars = new StringBuffer(length); diff --git a/src/java/org/apache/fop/hyphenation/TernaryTree.java b/src/java/org/apache/fop/hyphenation/TernaryTree.java index a6f5337bf..0824632a3 100644 --- a/src/java/org/apache/fop/hyphenation/TernaryTree.java +++ b/src/java/org/apache/fop/hyphenation/TernaryTree.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/image/loader/batik/BatikUtil.java b/src/java/org/apache/fop/image/loader/batik/BatikUtil.java index 1ae2a9917..558c3b043 100644 --- a/src/java/org/apache/fop/image/loader/batik/BatikUtil.java +++ b/src/java/org/apache/fop/image/loader/batik/BatikUtil.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,5 +37,5 @@ public class BatikUtil { } return false; } - + } 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 c8e031405..b7ea72bf0 100644 --- a/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java +++ b/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.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.image.loader.batik; import java.awt.Dimension; @@ -51,7 +51,7 @@ import org.apache.fop.svg.SimpleSVGUserAgent; * Note: The target flavor is "generic" Java2D. No Batik-specific bridges are hooked into the * conversion process. Specialized renderers may want to provide specialized adapters to profit * from target-format features (for example with PDF or PS). This converter is mainly for formats - * which only support bitmap images or rudimentary Java2D support. + * which only support bitmap images or rudimentary Java2D support. */ public class ImageConverterSVG2G2D extends AbstractImageConverter { @@ -126,7 +126,7 @@ public class ImageConverterSVG2G2D extends AbstractImageConverter { //TODO Refine and pipe through to caller log.debug(message); } - + }; } diff --git a/src/java/org/apache/fop/image/loader/batik/ImageConverterWMF2G2D.java b/src/java/org/apache/fop/image/loader/batik/ImageConverterWMF2G2D.java index 6babe4523..7bc8c2050 100644 --- a/src/java/org/apache/fop/image/loader/batik/ImageConverterWMF2G2D.java +++ b/src/java/org/apache/fop/image/loader/batik/ImageConverterWMF2G2D.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.image.loader.batik; import java.awt.Dimension; @@ -51,7 +51,7 @@ public class ImageConverterWMF2G2D extends AbstractImageConverter { Graphics2DImagePainter painter; painter = new Graphics2DImagePainterWMF(wmf); - + ImageGraphics2D g2dImage = new ImageGraphics2D(src.getInfo(), painter); return g2dImage; } @@ -69,11 +69,11 @@ public class ImageConverterWMF2G2D extends AbstractImageConverter { private static class Graphics2DImagePainterWMF implements Graphics2DImagePainter { private ImageWMF wmf; - + public Graphics2DImagePainterWMF(ImageWMF wmf) { this.wmf = wmf; } - + /** {@inheritDoc} */ public Dimension getImageSize() { return wmf.getSize().getDimensionMpt(); @@ -84,7 +84,7 @@ public class ImageConverterWMF2G2D extends AbstractImageConverter { WMFRecordStore wmfStore = wmf.getRecordStore(); double w = area.getWidth(); double h = area.getHeight(); - + //Fit in paint area g2d.translate(area.getX(), area.getY()); double sx = w / wmfStore.getWidthPixels(); @@ -101,7 +101,7 @@ public class ImageConverterWMF2G2D extends AbstractImageConverter { log.debug("Painting WMF took " + duration + " ms."); } } - + } - + } diff --git a/src/java/org/apache/fop/image/loader/batik/ImageLoaderFactorySVG.java b/src/java/org/apache/fop/image/loader/batik/ImageLoaderFactorySVG.java index fa58d8e4a..9203bf7e8 100644 --- a/src/java/org/apache/fop/image/loader/batik/ImageLoaderFactorySVG.java +++ b/src/java/org/apache/fop/image/loader/batik/ImageLoaderFactorySVG.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,25 +31,25 @@ public class ImageLoaderFactorySVG extends AbstractImageLoaderFactory { private static final ImageFlavor[] FLAVORS = new ImageFlavor[] { ImageFlavor.XML_DOM}; - + private static final String[] MIMES = new String[] { MimeConstants.MIME_SVG}; - + /** {@inheritDoc} */ public String[] getSupportedMIMETypes() { return MIMES; } - + /** {@inheritDoc} */ public ImageFlavor[] getSupportedFlavors(String mime) { return FLAVORS; } - + /** {@inheritDoc} */ public ImageLoader newImageLoader(ImageFlavor targetFlavor) { return new ImageLoaderSVG(targetFlavor); } - + /** {@inheritDoc} */ public int getUsagePenalty(String mime, ImageFlavor flavor) { return 0; diff --git a/src/java/org/apache/fop/image/loader/batik/ImageLoaderFactoryWMF.java b/src/java/org/apache/fop/image/loader/batik/ImageLoaderFactoryWMF.java index bfa004d7e..6c5384bdb 100644 --- a/src/java/org/apache/fop/image/loader/batik/ImageLoaderFactoryWMF.java +++ b/src/java/org/apache/fop/image/loader/batik/ImageLoaderFactoryWMF.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,25 +30,25 @@ public class ImageLoaderFactoryWMF extends AbstractImageLoaderFactory { private static final ImageFlavor[] FLAVORS = new ImageFlavor[] { ImageWMF.WMF_IMAGE}; - + private static final String[] MIMES = new String[] { ImageWMF.MIME_WMF}; - + /** {@inheritDoc} */ public String[] getSupportedMIMETypes() { return MIMES; } - + /** {@inheritDoc} */ public ImageFlavor[] getSupportedFlavors(String mime) { return FLAVORS; } - + /** {@inheritDoc} */ public ImageLoader newImageLoader(ImageFlavor targetFlavor) { return new ImageLoaderWMF(targetFlavor); } - + /** {@inheritDoc} */ public int getUsagePenalty(String mime, ImageFlavor flavor) { return 0; diff --git a/src/java/org/apache/fop/image/loader/batik/ImageLoaderSVG.java b/src/java/org/apache/fop/image/loader/batik/ImageLoaderSVG.java index 64aff962b..483d6c502 100644 --- a/src/java/org/apache/fop/image/loader/batik/ImageLoaderSVG.java +++ b/src/java/org/apache/fop/image/loader/batik/ImageLoaderSVG.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,7 +50,7 @@ public class ImageLoaderSVG extends AbstractImageLoader { } this.targetFlavor = targetFlavor; } - + /** {@inheritDoc} */ public ImageFlavor getTargetFlavor() { return this.targetFlavor; diff --git a/src/java/org/apache/fop/image/loader/batik/ImageLoaderWMF.java b/src/java/org/apache/fop/image/loader/batik/ImageLoaderWMF.java index e7f3e0f0a..bed3043c6 100644 --- a/src/java/org/apache/fop/image/loader/batik/ImageLoaderWMF.java +++ b/src/java/org/apache/fop/image/loader/batik/ImageLoaderWMF.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,7 +46,7 @@ public class ImageLoaderWMF extends AbstractImageLoader { } this.targetFlavor = targetFlavor; } - + /** {@inheritDoc} */ public ImageFlavor getTargetFlavor() { return this.targetFlavor; diff --git a/src/java/org/apache/fop/image/loader/batik/ImageWMF.java b/src/java/org/apache/fop/image/loader/batik/ImageWMF.java index f785d27cc..a927345f9 100644 --- a/src/java/org/apache/fop/image/loader/batik/ImageWMF.java +++ b/src/java/org/apache/fop/image/loader/batik/ImageWMF.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,9 +35,9 @@ public class ImageWMF extends AbstractImage { /** ImageFlavor for Batik's WMFRecordStore */ public static final ImageFlavor WMF_IMAGE = new ImageFlavor("WMFRecordStore"); - + private WMFRecordStore store; - + /** * Main constructor. * @param info the image info object @@ -47,7 +47,7 @@ public class ImageWMF extends AbstractImage { super(info); this.store = store; } - + /** {@inheritDoc} */ public ImageFlavor getFlavor() { return WMF_IMAGE; @@ -57,7 +57,7 @@ public class ImageWMF extends AbstractImage { public boolean isCacheable() { return true; } - + /** * Returns the contained WMF record store. * @return the WMFRecordStore @@ -65,5 +65,5 @@ public class ImageWMF extends AbstractImage { public WMFRecordStore getRecordStore() { return this.store; } - + } 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 20557a644..ce6cde9d9 100644 --- a/src/java/org/apache/fop/image/loader/batik/PreloaderSVG.java +++ b/src/java/org/apache/fop/image/loader/batik/PreloaderSVG.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.image.loader.batik; import java.awt.geom.AffineTransform; @@ -59,8 +59,8 @@ public class PreloaderSVG extends AbstractImagePreloader { private static Log log = LogFactory.getLog(PreloaderSVG.class); private boolean batikAvailable = true; - - /** {@inheritDoc} */ + + /** {@inheritDoc} */ public ImageInfo preloadImage(String uri, Source src, ImageContext context) throws IOException { ImageInfo info = null; @@ -122,7 +122,7 @@ public class PreloaderSVG extends AbstractImagePreloader { doc = (SVGDocument) factory.createSVGDocument(src.getSystemId(), in); } ImageInfo info = createImageInfo(uri, context, doc); - + return info; } catch (NoClassDefFoundError ncdfe) { if (in != null) { @@ -154,7 +154,7 @@ public class PreloaderSVG extends AbstractImagePreloader { private ImageInfo createImageInfo(String uri, ImageContext context, SVGDocument doc) { Element e = doc.getRootElement(); - float pxUnitToMillimeter = 25.4f / context.getSourceResolution(); + float pxUnitToMillimeter = 25.4f / context.getSourceResolution(); UserAgent userAg = new SimpleSVGUserAgent(pxUnitToMillimeter, new AffineTransform()) { @@ -162,7 +162,7 @@ public class PreloaderSVG extends AbstractImagePreloader { public void displayMessage(String message) { log.debug(message); } - + }; BridgeContext ctx = new BridgeContext(userAg); UnitProcessor.Context uctx = UnitProcessor.createContext(ctx, e); @@ -198,7 +198,7 @@ public class PreloaderSVG extends AbstractImagePreloader { info.getCustomObjects().put(ImageInfo.ORIGINAL_IMAGE, xmlImage); return info; } - + private boolean isSupportedSource(Source src) { if (src instanceof DOMSource) { DOMSource domSrc = (DOMSource)src; diff --git a/src/java/org/apache/fop/image/loader/batik/PreloaderWMF.java b/src/java/org/apache/fop/image/loader/batik/PreloaderWMF.java index abb740411..4e78f8193 100644 --- a/src/java/org/apache/fop/image/loader/batik/PreloaderWMF.java +++ b/src/java/org/apache/fop/image/loader/batik/PreloaderWMF.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.image.loader.batik; import java.io.DataInputStream; @@ -49,8 +49,8 @@ public class PreloaderWMF extends AbstractImagePreloader { private static Log log = LogFactory.getLog(PreloaderWMF.class); private boolean batikAvailable = true; - - /** {@inheritDoc} */ + + /** {@inheritDoc} */ public ImageInfo preloadImage(String uri, Source src, ImageContext context) throws IOException { if (!ImageUtil.hasInputStream(src)) { @@ -86,7 +86,7 @@ public class PreloaderWMF extends AbstractImagePreloader { InputStream in = new UnclosableInputStream(ImageUtil.needInputStream(src)); try { in.mark(4 + 1); - + DataInputStream din = new DataInputStream(in); int magic = EndianUtils.swapInteger(din.readInt()); din.reset(); @@ -97,11 +97,11 @@ public class PreloaderWMF extends AbstractImagePreloader { WMFRecordStore wmfStore = new WMFRecordStore(); wmfStore.read(din); IOUtils.closeQuietly(din); - + int width = wmfStore.getWidthUnits(); int height = wmfStore.getHeightUnits(); int dpi = wmfStore.getMetaFileUnitsPerInch(); - + ImageInfo info = new ImageInfo(uri, "image/x-wmf"); ImageSize size = new ImageSize(); size.setSizeInPixels(width, height); @@ -110,7 +110,7 @@ public class PreloaderWMF extends AbstractImagePreloader { info.setSize(size); ImageWMF img = new ImageWMF(info, wmfStore); info.getCustomObjects().put(ImageInfo.ORIGINAL_IMAGE, img); - + return info; } catch (NoClassDefFoundError ncdfe) { try { diff --git a/src/java/org/apache/fop/layoutmgr/AbstractBaseLayoutManager.java b/src/java/org/apache/fop/layoutmgr/AbstractBaseLayoutManager.java index 27189bf86..f7acf3eb5 100644 --- a/src/java/org/apache/fop/layoutmgr/AbstractBaseLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/AbstractBaseLayoutManager.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,9 +31,9 @@ import org.apache.fop.fo.FObj; * and the {@link org.apache.fop.datatypes.PercentBaseContext} interfaces * into a common base class for all higher LayoutManagers. */ -public abstract class AbstractBaseLayoutManager +public abstract class AbstractBaseLayoutManager implements LayoutManager, PercentBaseContext { - + /** Indicator if this LM generates reference areas. */ protected boolean generatesReferenceArea = false; /** Indicator if this LM generates block areas. */ @@ -67,7 +67,7 @@ public abstract class AbstractBaseLayoutManager } // --------- Property Resolution related functions --------- // - + /** {@inheritDoc} */ public int getBaseLength(int lengthBase, FObj fobjx) { if (fobjx == this.fobj) { @@ -201,7 +201,7 @@ public abstract class AbstractBaseLayoutManager throw new UnsupportedOperationException( "getContentAreaIPD() called when it should have been overridden"); } - + /** * {@inheritDoc} * NOTE: Should be overridden by subclasses. @@ -211,27 +211,27 @@ public abstract class AbstractBaseLayoutManager throw new UnsupportedOperationException( "getContentAreaBPD() called when it should have been overridden"); } - + /** {@inheritDoc} */ public boolean getGeneratesReferenceArea() { return generatesReferenceArea; } - + /** * Lets implementing LM set the flag indicating if they * generate reference areas. - * @param generatesReferenceArea if true the areas generates by this LM are + * @param generatesReferenceArea if true the areas generates by this LM are * reference areas. */ protected void setGeneratesReferenceArea(boolean generatesReferenceArea) { this.generatesReferenceArea = generatesReferenceArea; } - + /** {@inheritDoc} */ public boolean getGeneratesBlockArea() { return generatesBlockArea; } - + /** * Lets implementing LM set the flag indicating if they * generate block areas. @@ -240,17 +240,17 @@ public abstract class AbstractBaseLayoutManager protected void setGeneratesBlockArea(boolean generatesBlockArea) { this.generatesBlockArea = generatesBlockArea; } - + /** {@inheritDoc} */ public boolean getGeneratesLineArea() { return false; } - + /** * {@inheritDoc} */ public FObj getFObj() { return fobj; } - + } diff --git a/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java b/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java index c830220e7..624bc907a 100644 --- a/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java +++ b/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java @@ -61,7 +61,7 @@ public abstract class AbstractBreaker { public class BlockSequence extends BlockKnuthSequence { - /** Number of elements to ignore at the beginning of the list. */ + /** Number of elements to ignore at the beginning of the list. */ public int ignoreAtStart = 0; /** Number of elements to ignore at the end of the list. */ public int ignoreAtEnd = 0; @@ -69,17 +69,17 @@ public abstract class AbstractBreaker { /** * startOn represents where on the page/which page layout * should start for this BlockSequence. Acceptable values: - * Constants.EN_ANY (can continue from finished location - * of previous BlockSequence?), EN_COLUMN, EN_ODD_PAGE, - * EN_EVEN_PAGE. + * Constants.EN_ANY (can continue from finished location + * of previous BlockSequence?), EN_COLUMN, EN_ODD_PAGE, + * EN_EVEN_PAGE. */ private int startOn; private int displayAlign; - + /** * Creates a new BlockSequence. - * @param iStartOn the kind of page the sequence should start on. One of EN_ANY, EN_COLUMN, + * @param iStartOn the kind of page the sequence should start on. One of EN_ANY, EN_COLUMN, * EN_ODD_PAGE, EN_EVEN_PAGE. * @param displayAlign the value for the display-align property */ @@ -88,9 +88,9 @@ public abstract class AbstractBreaker { startOn = iStartOn; this.displayAlign = displayAlign; } - + /** - * @return the kind of page the sequence should start on. One of EN_ANY, EN_COLUMN, + * @return the kind of page the sequence should start on. One of EN_ANY, EN_COLUMN, * EN_ODD_PAGE, EN_EVEN_PAGE. */ public int getStartOn() { @@ -108,7 +108,7 @@ public abstract class AbstractBreaker { public KnuthSequence endSequence() { return endSequence(null); } - + /** * Finalizes a Knuth sequence. * @param breakPosition a Position instance for the last penalty (may be null) @@ -124,14 +124,14 @@ public abstract class AbstractBreaker { // add the elements representing the space at the end of the last line // and the forced break if (getDisplayAlign() == Constants.EN_X_DISTRIBUTE && isSinglePartFavored()) { - this.add(new KnuthPenalty(0, -KnuthElement.INFINITE, + this.add(new KnuthPenalty(0, -KnuthElement.INFINITE, false, breakPosition, false)); ignoreAtEnd = 1; } else { - this.add(new KnuthPenalty(0, KnuthElement.INFINITE, + this.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, null, false)); this.add(new KnuthGlue(0, 10000000, 0, null, false)); - this.add(new KnuthPenalty(0, -KnuthElement.INFINITE, + this.add(new KnuthPenalty(0, -KnuthElement.INFINITE, false, breakPosition, false)); ignoreAtEnd = 3; } @@ -171,10 +171,10 @@ public abstract class AbstractBreaker { protected abstract void addAreas(PositionIterator posIter, LayoutContext context); protected abstract LayoutManager getTopLevelLM(); protected abstract LayoutManager getCurrentChildLM(); - + /** * Controls the behaviour of the algorithm in cases where the first element of a part - * overflows a line/page. + * overflows a line/page. * @return true if the algorithm should try to send the element to the next line/page. */ protected boolean isPartOverflowRecoveryActivated() { @@ -187,7 +187,7 @@ public abstract class AbstractBreaker { protected boolean isSinglePartFavored() { return false; } - + /** * Returns the PageProvider if any. PageBreaker overrides this method because each * page may have a different available BPD which needs to be accessible to the breaking @@ -197,7 +197,7 @@ public abstract class AbstractBreaker { protected PageProvider getPageProvider() { return null; } - + /** * Creates and returns a PageBreakingLayoutListener for the PageBreakingAlgorithm to * notify about layout problems. @@ -206,11 +206,11 @@ public abstract class AbstractBreaker { protected PageBreakingAlgorithm.PageBreakingLayoutListener createLayoutListener() { return null; } - + /* * This method is to contain the logic to determine the LM's - * getNextKnuthElements() implementation(s) that are to be called. - * @return LinkedList of Knuth elements. + * getNextKnuthElements() implementation(s) that are to be called. + * @return LinkedList of Knuth elements. */ protected abstract List getNextKnuthElements(LayoutContext context, int alignment); @@ -218,18 +218,18 @@ public abstract class AbstractBreaker { public boolean isEmpty() { return (this.blockLists.isEmpty()); } - + protected void startPart(BlockSequence list, int breakClass) { //nop } - + /** * This method is called when no content is available for a part. Used to force empty pages. */ protected void handleEmptyContent() { - //nop + //nop } - + protected abstract void finishPart(PageBreakingAlgorithm alg, PageBreakPosition pbp); /** @@ -239,7 +239,7 @@ public abstract class AbstractBreaker { protected LayoutContext createLayoutContext() { return new LayoutContext(0); } - + /** * Used to update the LayoutContext in subclasses prior to starting a new element list. * @param context the LayoutContext to update @@ -247,7 +247,7 @@ public abstract class AbstractBreaker { protected void updateLayoutContext(LayoutContext context) { //nop } - + /** * Used for debugging purposes. Notifies all registered observers about the element list. * Override to set different parameters. @@ -256,7 +256,7 @@ public abstract class AbstractBreaker { protected void observeElementList(List elementList) { ElementListObserver.observe(elementList, "breaker", null); } - + /** * Starts the page breaking process. * @param flowBPD the constant available block-progression-dimension (used for every part) @@ -264,7 +264,7 @@ public abstract class AbstractBreaker { public void doLayout(int flowBPD) { doLayout(flowBPD, false); } - + /** * Starts the page breaking process. * @param flowBPD the constant available block-progression-dimension (used for every part) @@ -294,7 +294,7 @@ public abstract class AbstractBreaker { this.blockLists = new java.util.ArrayList(); log.debug("PLM> flow BPD =" + flowBPD); - + //*** Phase 1: Get Knuth elements *** int nextSequenceStartsOn = Constants.EN_ANY; while (hasMoreContent()) { @@ -306,7 +306,7 @@ public abstract class AbstractBreaker { log.debug("PLM> blockLists.size() = " + blockLists.size()); for (blockListIndex = 0; blockListIndex < blockLists.size(); blockListIndex++) { blockList = (BlockSequence) blockLists.get(blockListIndex); - + //debug code start if (log.isDebugEnabled()) { log.debug(" blockListIndex = " + blockListIndex); @@ -318,7 +318,7 @@ public abstract class AbstractBreaker { observeElementList(blockList); //debug code end - log.debug("PLM> start of algorithm (" + this.getClass().getName() + log.debug("PLM> start of algorithm (" + this.getClass().getName() + "), flow BPD =" + flowBPD); PageBreakingAlgorithm alg = new PageBreakingAlgorithm(getTopLevelLM(), getPageProvider(), createLayoutListener(), @@ -342,7 +342,7 @@ public abstract class AbstractBreaker { log.debug("PLM> iOptPageCount= " + iOptPageCount + " pageBreaks.size()= " + alg.getPageBreaks().size()); - + //*** Phase 3: Add areas *** doPhase3(alg, iOptPageCount, blockList, effectiveList); } @@ -351,36 +351,36 @@ public abstract class AbstractBreaker { } /** - * Phase 3 of Knuth algorithm: Adds the areas + * Phase 3 of Knuth algorithm: Adds the areas * @param alg PageBreakingAlgorithm instance which determined the breaks * @param partCount number of parts (pages) to be rendered * @param originalList original Knuth element list * @param effectiveList effective Knuth element list (after adjustments) */ - protected abstract void doPhase3(PageBreakingAlgorithm alg, int partCount, + protected abstract void doPhase3(PageBreakingAlgorithm alg, int partCount, BlockSequence originalList, BlockSequence effectiveList); - + /** - * Phase 3 of Knuth algorithm: Adds the areas + * Phase 3 of Knuth algorithm: Adds the areas * @param alg PageBreakingAlgorithm instance which determined the breaks * @param partCount number of parts (pages) to be rendered * @param originalList original Knuth element list * @param effectiveList effective Knuth element list (after adjustments) */ - protected void addAreas(PageBreakingAlgorithm alg, int partCount, + protected void addAreas(PageBreakingAlgorithm alg, int partCount, BlockSequence originalList, BlockSequence effectiveList) { addAreas(alg, 0, partCount, originalList, effectiveList); } - + /** - * Phase 3 of Knuth algorithm: Adds the areas + * Phase 3 of Knuth algorithm: Adds the areas * @param alg PageBreakingAlgorithm instance which determined the breaks * @param startPart index of the first part (page) to be rendered * @param partCount number of parts (pages) to be rendered * @param originalList original Knuth element list * @param effectiveList effective Knuth element list (after adjustments) */ - protected void addAreas(PageBreakingAlgorithm alg, int startPart, int partCount, + protected void addAreas(PageBreakingAlgorithm alg, int startPart, int partCount, BlockSequence originalList, BlockSequence effectiveList) { LayoutContext childLC; // add areas @@ -404,13 +404,13 @@ public abstract class AbstractBreaker { lastBreakClass = Constants.EN_COLUMN; } } - + //the end of the new part endElementIndex = pbp.getLeafPos(); // ignore the first elements added by the // PageSequenceLayoutManager - startElementIndex += (startElementIndex == 0) + startElementIndex += (startElementIndex == 0) ? effectiveList.ignoreAtStart : 0; @@ -420,16 +420,16 @@ public abstract class AbstractBreaker { + ", break class = " + lastBreakClass); startPart(effectiveList, lastBreakClass); - + int displayAlign = getCurrentDisplayAlign(); - + //The following is needed by SpaceResolver.performConditionalsNotification() //further down as there may be important Position elements in the element list trailer int notificationEndElementIndex = endElementIndex; // ignore the last elements added by the // PageSequenceLayoutManager - endElementIndex -= (endElementIndex == (originalList.size() - 1)) + endElementIndex -= (endElementIndex == (originalList.size() - 1)) ? effectiveList.ignoreAtEnd : 0; @@ -493,7 +493,7 @@ public abstract class AbstractBreaker { /* *** *** non-standard extension *** *** */ if (displayAlign == Constants.EN_X_FILL) { - int averageLineLength = optimizeLineLength(effectiveList, + int averageLineLength = optimizeLineLength(effectiveList, startElementIndex, endElementIndex); if (averageLineLength != 0) { childLC.setStackLimitBP(new MinOptMax(averageLineLength)); @@ -502,9 +502,9 @@ public abstract class AbstractBreaker { /* *** *** non-standard extension *** *** */ // Handle SpaceHandling(Break)Positions, see SpaceResolver! - SpaceResolver.performConditionalsNotification(effectiveList, + SpaceResolver.performConditionalsNotification(effectiveList, startElementIndex, notificationEndElementIndex, lastBreak); - + // Add areas now! addAreas(new KnuthPossPosIter(effectiveList, startElementIndex, endElementIndex + 1), childLC); @@ -528,7 +528,7 @@ public abstract class AbstractBreaker { * @param lastBreak index of the last break element */ /** - * Handles span changes reported through the LayoutContext. + * Handles span changes reported through the LayoutContext. * Only used by the PSLM and called by getNextBlockList(). * @param childLC the LayoutContext * @param nextSequenceStartsOn previous value for break handling @@ -543,12 +543,12 @@ public abstract class AbstractBreaker { * @param nextSequenceStartsOn indicates on what page the next sequence should start * @return the page on which the next content should appear after a hard break */ - protected int getNextBlockList(LayoutContext childLC, + protected int getNextBlockList(LayoutContext childLC, int nextSequenceStartsOn) { updateLayoutContext(childLC); //Make sure the span change signal is reset childLC.signalSpanChange(Constants.NOT_SET); - + BlockSequence blockList; List returnedList = getNextKnuthElements(childLC, alignment); if (returnedList != null) { @@ -557,10 +557,10 @@ public abstract class AbstractBreaker { return nextSequenceStartsOn; } blockList = new BlockSequence(nextSequenceStartsOn, getCurrentDisplayAlign()); - + //Only implemented by the PSLM nextSequenceStartsOn = handleSpanChange(childLC, nextSequenceStartsOn); - + Position breakPosition = null; if (((KnuthElement) ListUtil.getLast(returnedList)).isForcedBreak()) { KnuthPenalty breakPenalty = (KnuthPenalty) ListUtil @@ -585,7 +585,7 @@ public abstract class AbstractBreaker { nextSequenceStartsOn = Constants.EN_EVEN_PAGE; break; default: - throw new IllegalStateException("Invalid break class: " + throw new IllegalStateException("Invalid break class: " + breakPenalty.getBreakClass()); } } @@ -649,7 +649,7 @@ public abstract class AbstractBreaker { * Justifies the boxes and returns them as a new KnuthSequence. * @param blockList block list to justify * @param alg reference to the algorithm instance - * @param availableBPD the available BPD + * @param availableBPD the available BPD * @return the effective list */ private BlockSequence justifyBoxes(BlockSequence blockList, PageBreakingAlgorithm alg, int availableBPD) { @@ -659,7 +659,7 @@ public abstract class AbstractBreaker { 1, true, BreakingAlgorithm.ALL_BREAKS); log.debug("PLM> iOptPageNumber= " + iOptPageNumber); - // + // ListIterator sequenceIterator = blockList.listIterator(); ListIterator breakIterator = alg.getPageBreaks().listIterator(); KnuthElement thisElement = null; @@ -687,7 +687,7 @@ public abstract class AbstractBreaker { KnuthElement firstElement; while (!(firstElement = (KnuthElement) sequenceIterator .next()).isBox()) { - // + // log.debug("PLM> ignoring glue or penalty element " + "at the beginning of the sequence"); if (firstElement.isGlue()) { @@ -811,7 +811,7 @@ public abstract class AbstractBreaker { // create a new sequence: the new elements will contain the // Positions // which will be used in the addAreas() phase - BlockSequence effectiveList = new BlockSequence(blockList.getStartOn(), + BlockSequence effectiveList = new BlockSequence(blockList.getStartOn(), blockList.getDisplayAlign()); effectiveList.addAll(getCurrentChildLM().getChangedKnuthElements( blockList.subList(0, blockList.size() - blockList.ignoreAtEnd), @@ -828,7 +828,7 @@ public abstract class AbstractBreaker { private int adjustBlockSpaces(LinkedList spaceList, int difference, int total) { if (log.isDebugEnabled()) { - log.debug("AdjustBlockSpaces: difference " + difference + " / " + total + log.debug("AdjustBlockSpaces: difference " + difference + " / " + total + " on " + spaceList.size() + " spaces in block"); } ListIterator spaceListIterator = spaceList.listIterator(); @@ -839,8 +839,8 @@ public abstract class AbstractBreaker { partial += (difference > 0 ? blockSpace.getY() : blockSpace.getZ()); if (log.isDebugEnabled()) { log.debug("available = " + partial + " / " + total); - log.debug("competenza = " - + (((int)((float) partial * difference / total)) - adjustedDiff) + log.debug("competenza = " + + (((int)((float) partial * difference / total)) - adjustedDiff) + " / " + difference); } int newAdjust = ((BlockLevelLayoutManager) blockSpace.getLayoutManager()).negotiateBPDAdjustment(((int) ((float) partial * difference / total)) - adjustedDiff, blockSpace); @@ -888,5 +888,5 @@ public abstract class AbstractBreaker { } return adjustedDiff; } - + } diff --git a/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java b/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java index 13ea66d1f..a5393ced2 100644 --- a/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.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. @@ -294,7 +294,7 @@ public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager if (pos.getIndex() >= 0) { throw new IllegalStateException("Position already got its index"); } - + lastGeneratedPosition++; pos.setIndex(lastGeneratedPosition); return pos; @@ -383,27 +383,27 @@ public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager * Checks to see if the incoming {@link Position} * is the last one for this LM, and if so, calls * {@link #notifyEndOfLayout()} and cleans up. - * + * * @param pos the {@link Position} to check */ protected void checkEndOfLayout(Position pos) { if (pos != null && pos.getLM() == this && this.isLast(pos)) { - + notifyEndOfLayout(); - + /* References to the child LMs are no longer needed */ childLMs = null; curChildLM = null; childLMiter = null; - + /* markers that qualify have been transferred to the page */ markers = null; - - /* References to the FO's children can be released if the + + /* References to the FO's children can be released if the * LM is a descendant of the FlowLM. For static-content * the FO may still be needed on following pages. */ @@ -418,7 +418,7 @@ public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager } } } - + /** {@inheritDoc} */ public String toString() { return (super.toString() + (fobj != null ? "[fobj=" + fobj.toString() + "]" : "")); diff --git a/src/java/org/apache/fop/layoutmgr/AbstractPageSequenceLayoutManager.java b/src/java/org/apache/fop/layoutmgr/AbstractPageSequenceLayoutManager.java index 2b61fb6c6..758761303 100644 --- a/src/java/org/apache/fop/layoutmgr/AbstractPageSequenceLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/AbstractPageSequenceLayoutManager.java @@ -43,15 +43,15 @@ public abstract class AbstractPageSequenceLayoutManager extends AbstractLayoutMa private static Log log = LogFactory.getLog(AbstractPageSequenceLayoutManager.class); - /** + /** * AreaTreeHandler which activates the PSLM and controls * the rendering of its pages. */ protected AreaTreeHandler areaTreeHandler; - + /** ID tracker supplied by the AreaTreeHandler */ protected IDTracker idTracker; - + /** page sequence formatting object being processed by this class */ protected AbstractPageSequence pageSeq; @@ -62,7 +62,7 @@ public abstract class AbstractPageSequenceLayoutManager extends AbstractLayoutMa protected int currentPageNum = 0; /** The stating page number */ protected int startPageNum = 0; - + /** * Constructor * @@ -112,12 +112,12 @@ public abstract class AbstractPageSequenceLayoutManager extends AbstractLayoutMa startPageNum = pageSeq.getStartingPageNumber(); currentPageNum = startPageNum - 1; } - + /** * This returns the first PageViewport that contains an id trait * matching the idref argument, or null if no such PV exists. * - * @param idref the idref trait needing to be resolved + * @param idref the idref trait needing to be resolved * @return the first PageViewport that contains the ID trait */ public PageViewport getFirstPVWithID(String idref) { @@ -132,7 +132,7 @@ public abstract class AbstractPageSequenceLayoutManager extends AbstractLayoutMa * This returns the last PageViewport that contains an id trait * matching the idref argument, or null if no such PV exists. * - * @param idref the idref trait needing to be resolved + * @param idref the idref trait needing to be resolved * @return the last PageViewport that contains the ID trait */ public PageViewport getLastPVWithID(String idref) { @@ -142,7 +142,7 @@ public abstract class AbstractPageSequenceLayoutManager extends AbstractLayoutMa } return null; } - + /** * Add an ID reference to the current page. * When adding areas the area adds its ID reference. @@ -156,7 +156,7 @@ public abstract class AbstractPageSequenceLayoutManager extends AbstractLayoutMa idTracker.associateIDWithPageViewport(id, curPage.getPageViewport()); } } - + /** * Add an id reference of the layout manager in the AreaTreeHandler, * if the id hasn't been resolved yet @@ -175,7 +175,7 @@ public abstract class AbstractPageSequenceLayoutManager extends AbstractLayoutMa return true; } } - + /** * Notify the areaTreeHandler that the LayoutManagers containing * idrefs have finished creating areas @@ -184,16 +184,16 @@ public abstract class AbstractPageSequenceLayoutManager extends AbstractLayoutMa public void notifyEndOfLayout(String id) { idTracker.signalIDProcessed(id); } - + /** - * Identify an unresolved area (one needing an idref to be + * Identify an unresolved area (one needing an idref to be * resolved, e.g. the internal-destination of an fo:basic-link) * for both the AreaTreeHandler and PageViewport object. - * + * * The IDTracker keeps a document-wide list of idref's - * and the PV's needing them to be resolved. It uses this to + * and the PV's needing them to be resolved. It uses this to * send notifications to the PV's when an id has been resolved. - * + * * The PageViewport keeps lists of id's needing resolving, along * with the child areas (page-number-citation, basic-link, etc.) * of the PV needing their resolution. @@ -216,7 +216,7 @@ public abstract class AbstractPageSequenceLayoutManager extends AbstractLayoutMa * then the containing page does not have a qualifying area, * and all qualifying areas have ended. * Therefore we use last-ending-within-page (Constants.EN_LEWP) - * as the position. + * as the position. * * @param rm the RetrieveMarker instance whose properties are to * used to find the matching Marker. @@ -227,8 +227,8 @@ public abstract class AbstractPageSequenceLayoutManager extends AbstractLayoutMa AreaTreeModel areaTreeModel = areaTreeHandler.getAreaTreeModel(); String name = rm.getRetrieveClassName(); int pos = rm.getRetrievePosition(); - int boundary = rm.getRetrieveBoundary(); - + int boundary = rm.getRetrieveBoundary(); + // get marker from the current markers on area tree Marker mark = (Marker)getCurrentPV().getMarker(name, pos); if (mark == null && boundary != EN_PAGE) { @@ -271,10 +271,10 @@ public abstract class AbstractPageSequenceLayoutManager extends AbstractLayoutMa * @return the newly created page */ protected abstract Page createPage(int pageNumber, boolean isBlank); - + /** * Makes a new page - * + * * @param bIsBlank whether this page is blank or not * @param bIsLast whether this page is the last page or not * @return a new page @@ -289,14 +289,14 @@ public abstract class AbstractPageSequenceLayoutManager extends AbstractLayoutMa curPage = createPage(currentPageNum, isBlank); if (log.isDebugEnabled()) { - log.debug("[" + curPage.getPageViewport().getPageNumberString() + log.debug("[" + curPage.getPageViewport().getPageNumberString() + (isBlank ? "*" : "") + "]"); } - + addIDToPage(pageSeq.getId()); return curPage; } - + /** * Finishes a page in preparation for a new page. */ @@ -304,19 +304,19 @@ public abstract class AbstractPageSequenceLayoutManager extends AbstractLayoutMa if (log.isTraceEnabled()) { curPage.getPageViewport().dumpMarkers(); } - + // Try to resolve any unresolved IDs for the current page. - // + // idTracker.tryIDResolution(curPage.getPageViewport()); // Queue for ID resolution and rendering areaTreeHandler.getAreaTreeModel().addPage(curPage.getPageViewport()); if (log.isDebugEnabled()) { - log.debug("page finished: " + curPage.getPageViewport().getPageNumberString() + log.debug("page finished: " + curPage.getPageViewport().getPageNumberString() + ", current num: " + currentPageNum); } curPage = null; } - + /** {@inheritDoc} */ public void doForcePageCount(Numeric nextPageSeqInitialPageNumber) { @@ -325,14 +325,14 @@ public abstract class AbstractPageSequenceLayoutManager extends AbstractLayoutMa // xsl-spec version 1.0 (15.oct 2001) // auto | even | odd | end-on-even | end-on-odd | no-force | inherit // auto: - // Force the last page in this page-sequence to be an odd-page - // if the initial-page-number of the next page-sequence is even. - // Force it to be an even-page - // if the initial-page-number of the next page-sequence is odd. - // If there is no next page-sequence + // Force the last page in this page-sequence to be an odd-page + // if the initial-page-number of the next page-sequence is even. + // Force it to be an even-page + // if the initial-page-number of the next page-sequence is odd. + // If there is no next page-sequence // or if the value of its initial-page-number is "auto" do not force any page. - - // if force-page-count is auto then set the value of forcePageCount + + // if force-page-count is auto then set the value of forcePageCount // depending on the initial-page-number of the next page-sequence if (nextPageSeqInitialPageNumber != null && forcePageCount == Constants.EN_AUTO) { if (nextPageSeqInitialPageNumber.getEnum() != 0) { @@ -381,5 +381,5 @@ public abstract class AbstractPageSequenceLayoutManager extends AbstractLayoutMa finishPage(); } } - + } diff --git a/src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java b/src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java index 1b0d02639..a429359ad 100644 --- a/src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java +++ b/src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java @@ -49,7 +49,7 @@ public class AreaAdditionUtil { * @param parentIter the position iterator * @param layoutContext the layout context */ - public static void addAreas(BlockStackingLayoutManager bslm, + public static void addAreas(BlockStackingLayoutManager bslm, PositionIterator parentIter, LayoutContext layoutContext) { LayoutManager childLM = null; LayoutContext lc = new LayoutContext(0); @@ -57,9 +57,9 @@ public class AreaAdditionUtil { LayoutManager lastLM = null; Position firstPos = null; Position lastPos = null; - + // "unwrap" the NonLeafPositions stored in parentIter - // and put them in a new list; + // and put them in a new list; LinkedList positionList = new LinkedList(); Position pos; while (parentIter.hasNext()) { @@ -93,11 +93,11 @@ public class AreaAdditionUtil { //correctly determine first and last conditions. The Iterator //doesn't give us that info. } - + if (bslm != null) { bslm.addMarkersToPage( - true, - bslm.isFirst(firstPos), + true, + bslm.isFirst(firstPos), bslm.isLast(lastPos)); } @@ -120,15 +120,15 @@ public class AreaAdditionUtil { lc.setStackLimitsFrom(layoutContext); childLM.addAreas(childPosIter, lc); } - + if (bslm != null) { bslm.addMarkersToPage( - false, - bslm.isFirst(firstPos), + false, + bslm.isFirst(firstPos), bslm.isLast(lastPos)); } - + } - + } diff --git a/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java b/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java index a28fdbfbc..2bb499a36 100644 --- a/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java +++ b/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java @@ -30,11 +30,11 @@ import org.apache.fop.traits.MinOptMax; public class BalancingColumnBreakingAlgorithm extends PageBreakingAlgorithm { private Log log = LogFactory.getLog(BalancingColumnBreakingAlgorithm.class); - + private int columnCount; private int fullLen; private int idealPartLen; - + public BalancingColumnBreakingAlgorithm(LayoutManager topLevelLM, PageProvider pageProvider, PageBreakingLayoutListener layoutListener, @@ -43,18 +43,18 @@ public class BalancingColumnBreakingAlgorithm extends PageBreakingAlgorithm { boolean partOverflowRecovery, int columnCount) { super(topLevelLM, pageProvider, layoutListener, - alignment, alignmentLast, + alignment, alignmentLast, footnoteSeparatorLength, partOverflowRecovery, false, false); this.columnCount = columnCount; this.considerTooShort = true; //This is important! } - + /** {@inheritDoc} */ protected double computeDemerits(KnuthNode activeNode, KnuthElement element, int fitnessClass, double r) { double dem = super.computeDemerits(activeNode, element, fitnessClass, r); if (log.isTraceEnabled()) { - log.trace("original demerit=" + dem + " " + totalWidth + log.trace("original demerit=" + dem + " " + totalWidth + " line=" + activeNode.line + "/" + columnCount + " pos=" + activeNode.position + "/" + (par.size() - 1)); } @@ -71,7 +71,7 @@ public class BalancingColumnBreakingAlgorithm extends PageBreakingAlgorithm { avgRestLen = restLen / remParts; } if (log.isTraceEnabled()) { - log.trace("remaining parts: " + remParts + " rest len: " + restLen + log.trace("remaining parts: " + remParts + " rest len: " + restLen + " avg=" + avgRestLen); } double balance = (idealPartLen - partLen) / 1000f; @@ -92,9 +92,9 @@ public class BalancingColumnBreakingAlgorithm extends PageBreakingAlgorithm { dem = dem * 1.2f; } } - //Step 2: This helps keep the trailing parts shorter than the previous ones + //Step 2: This helps keep the trailing parts shorter than the previous ones dem += (avgRestLen) / 1000f; - + if (activeNode.line >= columnCount) { //We don't want more columns than available dem = Double.MAX_VALUE; diff --git a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java index 4aa73cc37..17eb44049 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.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,14 +44,14 @@ import org.apache.fop.util.ListUtil; /** * LayoutManager for a block-container FO. */ -public class BlockContainerLayoutManager extends BlockStackingLayoutManager +public class BlockContainerLayoutManager extends BlockStackingLayoutManager implements ConditionalElementListener { /** * logging instance */ private static Log log = LogFactory.getLog(BlockContainerLayoutManager.class); - + private BlockViewport viewportBlockArea; private Block referenceArea; @@ -62,11 +62,11 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager private Length height; //private int vpContentIPD; private int vpContentBPD; - + // When viewport should grow with the content. private boolean autoHeight = true; private boolean inlineElementList = false; - + /* holds the (one-time use) fo:block space-before and -after properties. Large fo:blocks are split into multiple Area.Blocks to accomodate the subsequent @@ -78,7 +78,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager //TODO space-before|after: handle space-resolution rules private MinOptMax foBlockSpaceBefore; private MinOptMax foBlockSpaceAfter; - + private boolean discardBorderBefore; private boolean discardBorderAfter; private boolean discardPaddingBefore; @@ -86,7 +86,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager private MinOptMax effSpaceBefore; private MinOptMax effSpaceAfter; - + /** * Create a new block container layout manager. * @param node block-container node to create the layout manager for. @@ -94,7 +94,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager public BlockContainerLayoutManager(BlockContainer node) { super(node); } - + /** {@inheritDoc} */ public void initialize() { abProps = getBlockContainerFO().getCommonAbsolutePosition(); @@ -103,7 +103,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager foBlockSpaceAfter = new SpaceVal(getBlockContainerFO().getCommonMarginBlock() .spaceAfter, this).getSpace(); startIndent = getBlockContainerFO().getCommonMarginBlock().startIndent.getValue(this); - endIndent = getBlockContainerFO().getCommonMarginBlock().endIndent.getValue(this); + endIndent = getBlockContainerFO().getCommonMarginBlock().endIndent.getValue(this); boolean rotated = (getBlockContainerFO().getReferenceOrientation() % 180 != 0); if (rotated) { @@ -117,7 +117,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager width = getBlockContainerFO().getInlineProgressionDimension() .getOptimum(this).getLength(); } - + bpUnit = 0; //layoutProps.blockProgressionUnit; if (bpUnit == 0) { // use optimum space values @@ -133,11 +133,11 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager .spaceAfter.getSpace().getMinimum(this).getLength().getValue(this); } } - + private void resetSpaces() { - this.discardBorderBefore = false; - this.discardBorderAfter = false; - this.discardPaddingBefore = false; + this.discardBorderBefore = false; + this.discardBorderAfter = false; + this.discardPaddingBefore = false; this.discardPaddingAfter = false; this.effSpaceBefore = null; this.effSpaceAfter = null; @@ -153,11 +153,11 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager int overflow = getBlockContainerFO().getOverflow(); return (overflow == EN_HIDDEN || overflow == EN_ERROR_IF_OVERFLOW); } - + private int getSpaceBefore() { return foBlockSpaceBefore.opt; } - + private int getBPIndents() { int indents = 0; /* TODO This is wrong isn't it? @@ -170,16 +170,16 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager .getBPPaddingAndBorder(false, this); return indents; } - + private boolean isAbsoluteOrFixed() { - return (abProps.absolutePosition == EN_ABSOLUTE) + return (abProps.absolutePosition == EN_ABSOLUTE) || (abProps.absolutePosition == EN_FIXED); } private boolean isFixed() { return (abProps.absolutePosition == EN_FIXED); } - + /** {@inheritDoc} */ public int getContentAreaBPD() { if (autoHeight) { @@ -188,26 +188,26 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager return this.vpContentBPD; } } - + /** {@inheritDoc} */ public List getNextKnuthElements(LayoutContext context, int alignment) { resetSpaces(); if (isAbsoluteOrFixed()) { return getNextKnuthElementsAbsolute(context, alignment); } - + autoHeight = false; //boolean rotated = (getBlockContainerFO().getReferenceOrientation() % 180 != 0); int maxbpd = context.getStackLimitBP().opt; int allocBPD; - if (height.getEnum() == EN_AUTO + if (height.getEnum() == EN_AUTO || (!height.isAbsolute() && getAncestorBlockAreaBPD() <= 0)) { - //auto height when height="auto" or "if that dimension is not specified explicitly + //auto height when height="auto" or "if that dimension is not specified explicitly //(i.e., it depends on content's block-progression-dimension)" (XSL 1.0, 7.14.1) allocBPD = maxbpd; autoHeight = true; if (getBlockContainerFO().getReferenceOrientation() == 0) { - //Cannot easily inline element list when ref-or="180" + //Cannot easily inline element list when ref-or="180" inlineElementList = true; } } else { @@ -223,7 +223,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager int contentWidth = width.getValue(this); updateContentAreaIPDwithOverconstrainedAdjust(contentWidth); } - + double contentRectOffsetX = 0; contentRectOffsetX += getBlockContainerFO() .getCommonMarginBlock().startIndent.getValue(this); @@ -232,7 +232,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager .getCommonBorderPaddingBackground().getBorderBeforeWidth(false); contentRectOffsetY += getBlockContainerFO() .getCommonBorderPaddingBackground().getPaddingBefore(false, this); - + updateRelDims(contentRectOffsetX, contentRectOffsetY, autoHeight); int availableIPD = referenceIPD - getIPIndents(); @@ -243,13 +243,13 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager getContentAreaIPD(), context.getRefIPD(), getBlockContainerFO().getLocator()); } - + MinOptMax stackLimit = new MinOptMax(relDims.bpd); List returnedList; List contentList = new LinkedList(); List returnList = new LinkedList(); - + if (!breakBeforeServed) { try { if (addKnuthElementsForBreakBefore(returnList, context)) { @@ -264,7 +264,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager addKnuthElementsForSpaceBefore(returnList, alignment); context.updateKeepWithPreviousPending(getKeepWithPreviousStrength()); } - + addKnuthElementsForBorderPaddingBefore(returnList, !firstVisibleMarkServed); firstVisibleMarkServed = true; @@ -366,7 +366,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager returnList.add(new KnuthBox(vpContentBPD, notifyPos(bcPosition), false)); //TODO Handle min/opt/max for block-progression-dimension /* These two elements will be used to add stretchability to the above box - returnList.add(new KnuthPenalty(0, KnuthElement.INFINITE, + returnList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, returnPosition, false)); returnList.add(new KnuthGlue(0, 1 * constantLineHeight, 0, LINE_NUMBER_ADJUSTMENT, returnPosition, false)); @@ -375,7 +375,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager if (contentOverflows) { BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Provider.get( getBlockContainerFO().getUserAgent().getEventBroadcaster()); - boolean canRecover = (getBlockContainerFO().getOverflow() != EN_ERROR_IF_OVERFLOW); + boolean canRecover = (getBlockContainerFO().getOverflow() != EN_ERROR_IF_OVERFLOW); eventProducer.viewportOverflow(this, getBlockContainerFO().getName(), breaker.getOverflowAmount(), needClip(), canRecover, getBlockContainerFO().getLocator()); @@ -384,7 +384,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager addKnuthElementsForBorderPaddingAfter(returnList, true); addKnuthElementsForSpaceAfter(returnList, alignment); - //All child content is processed. Only break-after can occur now, so... + //All child content is processed. Only break-after can occur now, so... context.clearPendingMarks(); addKnuthElementsForBreakAfter(returnList, context); @@ -393,7 +393,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager setFinished(true); return returnList; } - + private List getNextKnuthElementsAbsolute(LayoutContext context, int alignment) { autoHeight = false; @@ -403,7 +403,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager int allocBPD, allocIPD; if (height.getEnum() == EN_AUTO || (!height.isAbsolute() && getAncestorBlockAreaBPD() <= 0)) { - //auto height when height="auto" or "if that dimension is not specified explicitly + //auto height when height="auto" or "if that dimension is not specified explicitly //(i.e., it depends on content's blockprogression-dimension)" (XSL 1.0, 7.14.1) allocBPD = 0; if (abProps.bottom.getEnum() != EN_AUTO) { @@ -411,7 +411,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager if (isFixed()) { availHeight = (int)getCurrentPV().getViewArea().getHeight(); } else { - availHeight = context.getStackLimitBP().opt; + availHeight = context.getStackLimitBP().opt; } allocBPD = availHeight; allocBPD -= offset.y; @@ -456,7 +456,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager if (width.getEnum() == EN_AUTO) { int availWidth; if (isFixed()) { - availWidth = (int)getCurrentPV().getViewArea().getWidth(); + availWidth = (int)getCurrentPV().getViewArea().getWidth(); } else { availWidth = context.getRefIPD(); } @@ -500,7 +500,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager vpContentBPD = allocBPD - getBPIndents(); setContentAreaIPD(allocIPD - getIPIndents()); - + updateRelDims(0, 0, autoHeight); MinOptMax range = new MinOptMax(relDims.ipd); @@ -521,12 +521,12 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager if (!breaker.isEmpty()) { Position bcPosition = new BlockContainerPosition(this, breaker); returnList.add(new KnuthBox(0, notifyPos(bcPosition), false)); - + //TODO Maybe check for page overflow when autoHeight=true if (!autoHeight & (contentOverflows)) { BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Provider.get( getBlockContainerFO().getUserAgent().getEventBroadcaster()); - boolean canRecover = (getBlockContainerFO().getOverflow() != EN_ERROR_IF_OVERFLOW); + boolean canRecover = (getBlockContainerFO().getOverflow() != EN_ERROR_IF_OVERFLOW); eventProducer.viewportOverflow(this, getBlockContainerFO().getName(), breaker.getOverflowAmount(), needClip(), canRecover, getBlockContainerFO().getLocator()); @@ -539,16 +539,16 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager private void updateRelDims(double xOffset, double yOffset, boolean skipAutoHeight) { Rectangle2D rect = new Rectangle2D.Double( - xOffset, yOffset, + xOffset, yOffset, getContentAreaIPD(), this.vpContentBPD); relDims = new FODimension(0, 0); absoluteCTM = CTM.getCTMandRelDims( getBlockContainerFO().getReferenceOrientation(), - getBlockContainerFO().getWritingMode(), + getBlockContainerFO().getWritingMode(), rect, relDims); } - + private class BlockContainerPosition extends NonLeafPosition { private BlockContainerBreaker breaker; @@ -557,23 +557,23 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager super(lm, null); this.breaker = breaker; } - + public BlockContainerBreaker getBreaker() { return this.breaker; } - + } - + private class BlockContainerBreaker extends AbstractBreaker { - + private BlockContainerLayoutManager bclm; private MinOptMax ipd; - + //Info for deferred adding of areas private PageBreakingAlgorithm deferredAlg; private BlockSequence deferredOriginalList; private BlockSequence deferredEffectiveList; - + public BlockContainerBreaker(BlockContainerLayoutManager bclm, MinOptMax ipd) { this.bclm = bclm; this.ipd = ipd; @@ -581,10 +581,10 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager /** {@inheritDoc} */ protected void observeElementList(List elementList) { - ElementListObserver.observe(elementList, "block-container", + ElementListObserver.observe(elementList, "block-container", bclm.getBlockContainerFO().getId()); } - + /** {@inheritDoc} */ protected boolean isPartOverflowRecoveryActivated() { //For block-containers, this must be disabled because of wanted overflow. @@ -600,19 +600,19 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager PageBreakPosition pbp = (PageBreakPosition)this.deferredAlg.getPageBreaks().getFirst(); return pbp.difference; } - + public boolean isOverflow() { return !isEmpty() && ((deferredAlg.getPageBreaks().size() > 1) || (deferredAlg.totalWidth - deferredAlg.totalShrink) > deferredAlg.getLineWidth()); } - + public int getOverflowAmount() { - return (deferredAlg.totalWidth - deferredAlg.totalShrink) + return (deferredAlg.totalWidth - deferredAlg.totalShrink) - deferredAlg.getLineWidth(); } - + protected LayoutManager getTopLevelLM() { return bclm; } @@ -623,7 +623,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager lc.setWritingMode(getBlockContainerFO().getWritingMode()); return lc; } - + protected List getNextKnuthElements(LayoutContext context, int alignment) { LayoutManager curLM; // currently active LM List returnList = new LinkedList(); @@ -633,7 +633,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager childLC.setStackLimitBP(context.getStackLimitBP()); childLC.setRefIPD(context.getRefIPD()); childLC.setWritingMode(getBlockContainerFO().getWritingMode()); - + List returnedList = null; if (!curLM.isFinished()) { returnedList = curLM.getNextKnuthElements(childLC, alignment); @@ -650,45 +650,45 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager protected int getCurrentDisplayAlign() { return getBlockContainerFO().getDisplayAlign(); } - + protected boolean hasMoreContent() { return !isFinished(); } - + protected void addAreas(PositionIterator posIter, LayoutContext context) { - AreaAdditionUtil.addAreas(bclm, posIter, context); + AreaAdditionUtil.addAreas(bclm, posIter, context); } - - protected void doPhase3(PageBreakingAlgorithm alg, int partCount, + + protected void doPhase3(PageBreakingAlgorithm alg, int partCount, BlockSequence originalList, BlockSequence effectiveList) { //Defer adding of areas until addAreas is called by the parent LM this.deferredAlg = alg; this.deferredOriginalList = originalList; this.deferredEffectiveList = effectiveList; } - + protected void finishPart(PageBreakingAlgorithm alg, PageBreakPosition pbp) { //nop for bclm } - + protected LayoutManager getCurrentChildLM() { return curChildLM; } - + public void addContainedAreas() { if (isEmpty()) { return; } - //Rendering all parts (not just the first) at once for the case where the parts that + //Rendering all parts (not just the first) at once for the case where the parts that //overflow should be visible. this.deferredAlg.removeAllPageBreaks(); - this.addAreas(this.deferredAlg, - this.deferredAlg.getPageBreaks().size(), + this.addAreas(this.deferredAlg, + this.deferredAlg.getPageBreaks().size(), this.deferredOriginalList, this.deferredEffectiveList); } - + } - + private Point getAbsOffset() { int x = 0; int y = 0; @@ -696,7 +696,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager x = abProps.left.getValue(this); } else if (abProps.right.getEnum() != EN_AUTO && width.getEnum() != EN_AUTO) { - x = getReferenceAreaIPD() + x = getReferenceAreaIPD() - abProps.right.getValue(this) - width.getValue(this); } if (abProps.top.getEnum() != EN_AUTO) { @@ -708,7 +708,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager } return new Point(x, y); } - + /** {@inheritDoc} */ public void addAreas(PositionIterator parentIter, LayoutContext layoutContext) { @@ -755,7 +755,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager if (bcpos != null) { throw new IllegalStateException("Only one BlockContainerPosition allowed"); } - bcpos = (BlockContainerPosition)pos; + bcpos = (BlockContainerPosition)pos; //Add child areas inside the reference area //bcpos.getBreaker().addContainedAreas(); } else if (innerPosition == null) { @@ -786,9 +786,9 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager } addId(); - + addMarkersToPage(true, isFirst(firstPos), isLast(lastPos)); - + if (bcpos == null) { if (bpUnit == 0) { // the Positions in positionList were inside the elements @@ -831,7 +831,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager //log.debug("Adding areas from " + iFirst + " to " + iLast); //log.debug("splitLength= " + splitLength // + " (" + neededUnits(splitLength) + " units') " - // + (neededUnits(splitLength) * bpUnit - splitLength) + // + (neededUnits(splitLength) * bpUnit - splitLength) // + " spacing"); // add space before and / or after the paragraph // to reach a multiple of bpUnit @@ -864,7 +864,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager .size()); //} } - + while ((childLM = childPosIter.getNextChildLM()) != null) { // set last area flag lc.setFlags(LayoutContext.LAST_AREA, @@ -880,7 +880,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager addMarkersToPage(false, isFirst(firstPos), isLast(lastPos)); - TraitSetter.addSpaceBeforeAfter(viewportBlockArea, layoutContext.getSpaceAdjust(), + TraitSetter.addSpaceBeforeAfter(viewportBlockArea, layoutContext.getSpaceAdjust(), effSpaceBefore, effSpaceAfter); flush(); @@ -890,7 +890,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager notifyEndOfLayout(); } - + /** * Get the parent area for children of this block container. * This returns the current block container area @@ -906,7 +906,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager viewportBlockArea = new BlockViewport(allowBPDUpdate); viewportBlockArea.addTrait(Trait.IS_VIEWPORT_AREA, Boolean.TRUE); - + viewportBlockArea.setIPD(getContentAreaIPD()); if (allowBPDUpdate) { viewportBlockArea.setBPD(0); @@ -914,22 +914,22 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager viewportBlockArea.setBPD(this.vpContentBPD); } transferForeignAttributes(viewportBlockArea); - + TraitSetter.setProducerID(viewportBlockArea, getBlockContainerFO().getId()); - TraitSetter.addBorders(viewportBlockArea, - getBlockContainerFO().getCommonBorderPaddingBackground(), + TraitSetter.addBorders(viewportBlockArea, + getBlockContainerFO().getCommonBorderPaddingBackground(), discardBorderBefore, discardBorderAfter, false, false, this); - TraitSetter.addPadding(viewportBlockArea, - getBlockContainerFO().getCommonBorderPaddingBackground(), + TraitSetter.addPadding(viewportBlockArea, + getBlockContainerFO().getCommonBorderPaddingBackground(), discardPaddingBefore, discardPaddingAfter, false, false, this); - // TraitSetter.addBackground(viewportBlockArea, + // TraitSetter.addBackground(viewportBlockArea, // getBlockContainerFO().getCommonBorderPaddingBackground(), // this); - TraitSetter.addMargins(viewportBlockArea, + TraitSetter.addMargins(viewportBlockArea, getBlockContainerFO().getCommonBorderPaddingBackground(), startIndent, endIndent, this); - + viewportBlockArea.setCTM(absoluteCTM); viewportBlockArea.setClip(needClip()); /* @@ -940,7 +940,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager viewportBlockArea.addTrait(Trait.SPACE_AFTER, new Integer(foBlockSpaceAfter.opt)); }*/ - if (abProps.absolutePosition == EN_ABSOLUTE + if (abProps.absolutePosition == EN_ABSOLUTE || abProps.absolutePosition == EN_FIXED) { Point offset = getAbsOffset(); viewportBlockArea.setXOffset(offset.x); @@ -981,17 +981,17 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager } } - /** + /** * Force current area to be added to parent area. * {@inheritDoc} */ protected void flush() { viewportBlockArea.addBlock(referenceArea, autoHeight); - TraitSetter.addBackground(viewportBlockArea, + TraitSetter.addBackground(viewportBlockArea, getBlockContainerFO().getCommonBorderPaddingBackground(), this); - + super.flush(); } @@ -1004,7 +1004,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager /** {@inheritDoc} */ public void discardSpace(KnuthGlue spaceGlue) { // TODO Auto-generated method stub - + } /** {@inheritDoc} */ @@ -1032,15 +1032,15 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager */ protected BlockContainer getBlockContainerFO() { return (BlockContainer) fobj; - } + } // --------- Property Resolution related functions --------- // - + /** {@inheritDoc} */ public boolean getGeneratesReferenceArea() { return true; } - + /** {@inheritDoc} */ public boolean getGeneratesBlockArea() { return true; @@ -1050,13 +1050,13 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager public void notifySpace(RelSide side, MinOptMax effectiveLength) { if (RelSide.BEFORE == side) { if (log.isDebugEnabled()) { - log.debug(this + ": Space " + side + ", " + log.debug(this + ": Space " + side + ", " + this.effSpaceBefore + "-> " + effectiveLength); } this.effSpaceBefore = effectiveLength; } else { if (log.isDebugEnabled()) { - log.debug(this + ": Space " + side + ", " + log.debug(this + ": Space " + side + ", " + this.effSpaceAfter + "-> " + effectiveLength); } this.effSpaceAfter = effectiveLength; diff --git a/src/java/org/apache/fop/layoutmgr/BlockKnuthSequence.java b/src/java/org/apache/fop/layoutmgr/BlockKnuthSequence.java index d3365b10f..fac5bf075 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockKnuthSequence.java +++ b/src/java/org/apache/fop/layoutmgr/BlockKnuthSequence.java @@ -26,16 +26,16 @@ import java.util.List; * Represents a list of block level Knuth elements. */ public class BlockKnuthSequence extends KnuthSequence { - + private boolean isClosed = false; - + /** * Creates a new and empty list. */ public BlockKnuthSequence() { super(); } - + /** * Creates a new list from an existing list. * @param list The list from which to create the new list. @@ -59,7 +59,7 @@ public class BlockKnuthSequence extends KnuthSequence { // log.debug("Cannot append a sequence without a BreakElement"); return false; } - + /** {@inheritDoc} */ public boolean appendSequence(KnuthSequence sequence, boolean keepTogether, BreakElement breakElement) { diff --git a/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java index b6b6f921f..c641c3e69 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java @@ -42,14 +42,14 @@ import org.apache.fop.traits.SpaceVal; /** * LayoutManager for a block FO. */ -public class BlockLayoutManager extends BlockStackingLayoutManager +public class BlockLayoutManager extends BlockStackingLayoutManager implements ConditionalElementListener { /** * logging instance */ private static Log log = LogFactory.getLog(BlockLayoutManager.class); - + private Block curBlockArea; /** Iterator over the child layout managers. */ @@ -59,7 +59,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager private Length lineHeight; private int follow = 2000; //private int middleShift = 0; - + private boolean discardBorderBefore; private boolean discardBorderAfter; private boolean discardPaddingBefore; @@ -91,7 +91,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager //middleShift = -fs.getXHeight() / 2; lineHeight = getBlockFO().getLineHeight().getOptimum(this).getLength(); startIndent = getBlockFO().getCommonMarginBlock().startIndent.getValue(this); - endIndent = getBlockFO().getCommonMarginBlock().endIndent.getValue(this); + endIndent = getBlockFO().getCommonMarginBlock().endIndent.getValue(this); foSpaceBefore = new SpaceVal(getBlockFO().getCommonMarginBlock().spaceBefore, this) .getSpace(); foSpaceAfter = new SpaceVal(getBlockFO().getCommonMarginBlock().spaceAfter, this) @@ -114,19 +114,19 @@ public class BlockLayoutManager extends BlockStackingLayoutManager /** {@inheritDoc} */ public List getNextKnuthElements(LayoutContext context, int alignment) { - resetSpaces(); + resetSpaces(); return super.getNextKnuthElements(context, alignment); } - + private void resetSpaces() { - this.discardBorderBefore = false; - this.discardBorderAfter = false; - this.discardPaddingBefore = false; + this.discardBorderBefore = false; + this.discardBorderAfter = false; + this.discardPaddingBefore = false; this.discardPaddingAfter = false; this.effSpaceBefore = null; this.effSpaceAfter = null; } - + /** * Proxy iterator for Block LM. * This iterator creates and holds the complete list @@ -216,7 +216,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager strength = Math.max(strength, getParentKeepTogetherStrength()); return strength; } - + /** {@inheritDoc} */ public int getKeepWithNextStrength() { return KeepUtil.getCombinedBlockLevelKeepStrength(getBlockFO().getKeepWithNext()); @@ -298,7 +298,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager } addId(); - + addMarkersToPage(true, isFirst(firstPos), isLast(lastPos)); if (bpUnit == 0) { @@ -340,7 +340,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager //log.debug("Adding areas from " + iFirst + " to " + iLast); //log.debug("splitLength= " + splitLength // + " (" + neededUnits(splitLength) + " units') " - // + (neededUnits(splitLength) * bpUnit - splitLength) + // + (neededUnits(splitLength) * bpUnit - splitLength) // + " spacing"); // add space before and / or after the paragraph // to reach a multiple of bpUnit @@ -385,13 +385,13 @@ public class BlockLayoutManager extends BlockStackingLayoutManager addMarkersToPage(false, isFirst(firstPos), isLast(lastPos)); - TraitSetter.addSpaceBeforeAfter(curBlockArea, layoutContext.getSpaceAdjust(), + TraitSetter.addSpaceBeforeAfter(curBlockArea, layoutContext.getSpaceAdjust(), effSpaceBefore, effSpaceAfter); flush(); curBlockArea = null; resetSpaces(); - + //Notify end of block layout manager to the PSLM checkEndOfLayout(lastPos); } @@ -414,7 +414,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager curBlockArea.setIPD(super.getContentAreaIPD()); - TraitSetter.addBreaks(curBlockArea, + TraitSetter.addBreaks(curBlockArea, getBlockFO().getBreakBefore(), getBlockFO().getBreakAfter()); // Must get dimensions from parent area @@ -423,14 +423,14 @@ public class BlockLayoutManager extends BlockStackingLayoutManager // set traits TraitSetter.setProducerID(curBlockArea, getBlockFO().getId()); - TraitSetter.addBorders(curBlockArea, - getBlockFO().getCommonBorderPaddingBackground(), + TraitSetter.addBorders(curBlockArea, + getBlockFO().getCommonBorderPaddingBackground(), discardBorderBefore, discardBorderAfter, false, false, this); - TraitSetter.addPadding(curBlockArea, - getBlockFO().getCommonBorderPaddingBackground(), + TraitSetter.addPadding(curBlockArea, + getBlockFO().getCommonBorderPaddingBackground(), discardPaddingBefore, discardPaddingAfter, false, false, this); TraitSetter.addMargins(curBlockArea, - getBlockFO().getCommonBorderPaddingBackground(), + getBlockFO().getCommonBorderPaddingBackground(), startIndent, endIndent, this); @@ -458,7 +458,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager */ protected void flush() { if (curBlockArea != null) { - TraitSetter.addBackground(curBlockArea, + TraitSetter.addBackground(curBlockArea, getBlockFO().getCommonBorderPaddingBackground(), this); super.flush(); @@ -472,9 +472,9 @@ public class BlockLayoutManager extends BlockStackingLayoutManager protected org.apache.fop.fo.flow.Block getBlockFO() { return (org.apache.fop.fo.flow.Block) fobj; } - + // --------- Property Resolution related functions --------- // - + /** * Returns the IPD of the content area * @return the IPD of the content area @@ -485,7 +485,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager } return super.getContentAreaIPD(); } - + /** * Returns the BPD of the content area @@ -497,7 +497,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager } return -1; } - + /** * {@inheritDoc} */ @@ -509,13 +509,13 @@ public class BlockLayoutManager extends BlockStackingLayoutManager public void notifySpace(RelSide side, MinOptMax effectiveLength) { if (RelSide.BEFORE == side) { if (log.isDebugEnabled()) { - log.debug(this + ": Space " + side + ", " + log.debug(this + ": Space " + side + ", " + this.effSpaceBefore + "-> " + effectiveLength); } this.effSpaceBefore = effectiveLength; } else { if (log.isDebugEnabled()) { - log.debug(this + ": Space " + side + ", " + log.debug(this + ": Space " + side + ", " + this.effSpaceAfter + "-> " + effectiveLength); } this.effSpaceAfter = effectiveLength; diff --git a/src/java/org/apache/fop/layoutmgr/BlockLevelEventProducer.java b/src/java/org/apache/fop/layoutmgr/BlockLevelEventProducer.java index b1dd7ef5d..222ce277e 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockLevelEventProducer.java +++ b/src/java/org/apache/fop/layoutmgr/BlockLevelEventProducer.java @@ -34,7 +34,7 @@ public interface BlockLevelEventProducer extends EventProducer { * Provider class for the event producer. */ class Provider { - + /** * Returns an event producer. * @param broadcaster the event broadcaster to use @@ -56,7 +56,7 @@ public interface BlockLevelEventProducer extends EventProducer { * @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 @@ -64,28 +64,28 @@ public interface BlockLevelEventProducer extends EventProducer { * @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 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 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 @@ -97,10 +97,10 @@ public interface BlockLevelEventProducer extends EventProducer { * @throws LayoutException the layout error provoked by the method call * @event.severity FATAL */ - void viewportOverflow(Object source, String elementName, + 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 @@ -117,7 +117,7 @@ public interface BlockLevelEventProducer extends EventProducer { 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 @@ -129,7 +129,7 @@ public interface BlockLevelEventProducer extends EventProducer { */ void flowNotMappingToRegionBody(Object source, String flowName, String masterName, Locator loc) throws UnsupportedOperationException; - + /** * A page sequence master is exhausted. * @param source the event source @@ -152,7 +152,7 @@ public interface BlockLevelEventProducer extends EventProducer { */ void missingSubsequencesInPageSequenceMaster(Object source, String pageSequenceMasterName, Locator loc) throws PageProductionException; - + /** * No single-page-master matching in page sequence master. * @param source the event source @@ -164,5 +164,5 @@ public interface BlockLevelEventProducer extends EventProducer { */ void noMatchingPageMaster(Object source, String pageSequenceMasterName, String pageMasterName, Locator loc) throws PageProductionException; - + } diff --git a/src/java/org/apache/fop/layoutmgr/BlockLevelLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockLevelLayoutManager.java index 765bb1086..9163193a2 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockLevelLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockLevelLayoutManager.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.layoutmgr; /** @@ -39,7 +39,7 @@ public interface BlockLevelLayoutManager extends LayoutManager { int KEEP_AUTO = Integer.MIN_VALUE; /** The integer value for "always" keep strength */ int KEEP_ALWAYS = Integer.MAX_VALUE; - + int negotiateBPDAdjustment(int adj, KnuthElement lastElement); void discardSpace(KnuthGlue spaceGlue); @@ -60,7 +60,7 @@ public interface BlockLevelLayoutManager extends LayoutManager { * @return the keep-with-previous strength */ int getKeepWithPreviousStrength(); - + /** * @return true if this element must be kept with the previous element. */ @@ -71,7 +71,7 @@ public interface BlockLevelLayoutManager extends LayoutManager { * @return the keep-with-next strength */ int getKeepWithNextStrength(); - + /** * @return true if this element must be kept with the next element. */ diff --git a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java index 4360f62e9..1d6662cb2 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.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. @@ -91,7 +91,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager private Position auxiliaryPosition; private int contentAreaIPD = 0; - + /** * @param node the fo this LM deals with */ @@ -100,7 +100,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager setGeneratesBlockArea(true); } - /** + /** * @return current area being filled */ protected BlockParent getCurrentArea() { @@ -181,7 +181,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager } return this.auxiliaryPosition; } - + /** * @param len length in millipoints to span with bp units * @return the minimum integer n such that n * bpUnit >= len @@ -194,7 +194,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager * Determines and sets the content area IPD based on available reference area IPD, start- and * end-indent properties. * end-indent is adjusted based on overconstrained geometry rules, if necessary. - * + * * @return the resulting content area IPD */ protected int updateContentAreaIPDwithOverconstrainedAdjust() { @@ -213,9 +213,9 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager setContentAreaIPD(ipd); return ipd; } - + /** - * Sets the content area IPD by directly supplying the value. + * 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 @@ -234,7 +234,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager setContentAreaIPD(contentIPD); return contentIPD; } - + /** {@inheritDoc} */ public List getNextKnuthElements(LayoutContext context, int alignment) { //log.debug("BLM.getNextKnuthElements> keep-together = " @@ -247,7 +247,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager BlockLevelLayoutManager prevLM = null; // previously active LM referenceIPD = context.getRefIPD(); - + updateContentAreaIPDwithOverconstrainedAdjust(); List returnedList = null; @@ -268,16 +268,16 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager addKnuthElementsForSpaceBefore(returnList, alignment); context.updateKeepWithPreviousPending(getKeepWithPreviousStrength()); } - + addKnuthElementsForBorderPaddingBefore(returnList, !firstVisibleMarkServed); firstVisibleMarkServed = true; //Spaces, border and padding to be repeated at each break addPendingMarks(context); - + //Used to indicate a special break-after case when all content has already been generated. BreakElement forcedBreakAfterLast = null; - + while ((curLM = (BlockLevelLayoutManager) getChildLM()) != null) { LayoutContext childLC = new LayoutContext(0); childLC.copyPendingMarksFrom(context); @@ -314,13 +314,13 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager } if (contentList.isEmpty()) { - // Empty fo:block, zero-length box makes sure the IDs and/or markers + // Empty fo:block, zero-length box makes sure the IDs and/or markers // are registered and borders/padding are painted. returnList.add(new KnuthBox(0, notifyPos(new Position(this)), false)); } // a descendant of this block has break-before contentList.addAll(returnedList); - + /* extension: conversione di tutta la sequenza fin'ora ottenuta */ if (bpUnit > 0) { storedList = contentList; @@ -350,7 +350,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager // a descendant of this block has break-after if (curLM.isFinished() && !hasNextChildLM()) { forcedBreakAfterLast = (BreakElement) ListUtil - .removeLast(contentList); + .removeLast(contentList); context.clearPendingMarks(); break; } @@ -385,15 +385,15 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager if (!contentList.isEmpty()) { wrapPositionElements(contentList, returnList); } else if (forcedBreakAfterLast == null) { - // Empty fo:block, zero-length box makes sure the IDs and/or markers + // Empty fo:block, zero-length box makes sure the IDs and/or markers // are registered. returnList.add(new KnuthBox(0, notifyPos(new Position(this)), true)); } addKnuthElementsForBorderPaddingAfter(returnList, true); addKnuthElementsForSpaceAfter(returnList, alignment); - - //All child content is processed. Only break-after can occur now, so... + + //All child content is processed. Only break-after can occur now, so... context.clearPendingMarks(); if (forcedBreakAfterLast == null) { addKnuthElementsForBreakAfter(returnList, context); @@ -403,9 +403,9 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager forcedBreakAfterLast.clearPendingMarks(); wrapPositionElement(forcedBreakAfterLast, returnList, false); } - + context.updateKeepWithNextPending(getKeepWithNextStrength()); - + setFinished(true); return returnList; @@ -419,20 +419,20 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager */ protected void addInBetweenBreak(List contentList, LayoutContext context, LayoutContext childLC) { - if (mustKeepTogether() + if (mustKeepTogether() || context.isKeepWithNextPending() || childLC.isKeepWithPreviousPending()) { - + int strength = getKeepTogetherStrength(); - + //Handle pending keep-with-next strength = Math.max(strength, context.getKeepWithNextPending()); context.clearKeepWithNextPending(); - + //Handle pending keep-with-previous from child LM strength = Math.max(strength, childLC.getKeepWithPreviousPending()); childLC.clearKeepWithPreviousPending(); - + int penalty = KeepUtil.getPenaltyForKeep(strength); // add a penalty to forbid or discourage a break between blocks @@ -440,7 +440,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager new Position(this), penalty, context)); return; } - + ListElement last = (ListElement) ListUtil.getLast(contentList); if (last.isGlue()) { // the last element in contentList is a glue; @@ -465,7 +465,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager // areas for following Positions. The above test aims at preventing // such a situation from occurring. add a null penalty to allow a break // between blocks - + // add a null penalty to allow a break between blocks contentList.add(new BreakElement( new Position(this), 0, context)); @@ -473,11 +473,11 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager } /** - * {@inheritDoc} + * {@inheritDoc} */ public int negotiateBPDAdjustment(int adj, KnuthElement lastElement) { /*LF*/ //log.debug(" BLM.negotiateBPDAdjustment> " + adj); -/*LF*/ //log.debug(" lastElement e' " + (lastElement.isPenalty() +/*LF*/ //log.debug(" lastElement e' " + (lastElement.isPenalty() // ? "penalty" : (lastElement.isGlue() ? "glue" : "box" ))); /*LF*/ //log.debug(" position e' " + lastElement.getPosition().getClass().getName()); /*LF*/ //log.debug(" " + (bpUnit > 0 ? "unit" : "")); @@ -497,9 +497,9 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager return adj; } else if (innerPosition instanceof MappingPosition) { // this block has block-progression-unit > 0: the adjustment can concern - // - the space-before or space-after of this block, + // - the space-before or space-after of this block, // - the line number of a descendant of this block - MappingPosition mappingPos = (MappingPosition)innerPosition; + MappingPosition mappingPos = (MappingPosition)innerPosition; if (lastElement.isGlue()) { // lastElement is a glue /*LF*/ //log.debug(" BLM.negotiateBPDAdjustment> bpunit con glue"); @@ -512,7 +512,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager newAdjustment += ((BlockLevelLayoutManager)storedElement .getLayoutManager()).negotiateBPDAdjustment( adj - newAdjustment, storedElement); -/*LF*/ //log.debug(" BLM.negotiateBPDAdjustment> (progressivo) righe: " +/*LF*/ //log.debug(" BLM.negotiateBPDAdjustment> (progressivo) righe: " // + newAdjustment); } } @@ -530,7 +530,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager // the original penalty has width > 0 /*LF*/ //log.debug(" BLM.negotiateBPDAdjustment> chiamata passata"); return ((BlockLevelLayoutManager)storedPenalty.getLayoutManager()) - .negotiateBPDAdjustment(storedPenalty.getW(), + .negotiateBPDAdjustment(storedPenalty.getW(), (KnuthElement)storedPenalty); } else { // the original penalty has width = 0 @@ -586,11 +586,11 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager } /** - * {@inheritDoc} + * {@inheritDoc} */ public List getChangedKnuthElements(List oldList, int alignment) { /*LF*/ //log.debug(""); -/*LF*/ //log.debug(" BLM.getChangedKnuthElements> inizio: oldList.size() = " +/*LF*/ //log.debug(" BLM.getChangedKnuthElements> inizio: oldList.size() = " // + oldList.size()); ListIterator oldListIterator = oldList.listIterator(); KnuthElement returnedElement; @@ -605,10 +605,10 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager while (oldListIterator.hasNext()) { oldElement = (KnuthElement)oldListIterator.next(); Position innerPosition = ((NonLeafPosition) oldElement.getPosition()).getPosition(); - //log.debug(" BLM> unwrapping: " - // + (oldElement.isBox() ? "box " : (oldElement.isGlue() ? "glue " : "penalty")) + //log.debug(" BLM> unwrapping: " + // + (oldElement.isBox() ? "box " : (oldElement.isGlue() ? "glue " : "penalty")) // + " creato da " + oldElement.getLayoutManager().getClass().getName()); - //log.debug(" BLM> unwrapping: " + //log.debug(" BLM> unwrapping: " // + oldElement.getPosition().getClass().getName()); if (innerPosition != null) { // oldElement was created by a descendant of this BlockLM @@ -645,18 +645,18 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager } int iLast = ((MappingPosition) el.getPosition()).getLastIndex(); - //log-debug(" si usa storedList da " + iFirst + " a " + iLast + //log-debug(" si usa storedList da " + iFirst + " a " + iLast // + " compresi su " + storedList.size() + " elementi totali"); workList = storedList.subList(iFirst, iLast + 1); } ListIterator workListIterator = workList.listIterator(); - //log.debug(" BLM.getChangedKnuthElements> workList.size() = " + //log.debug(" BLM.getChangedKnuthElements> workList.size() = " // + workList.size() + " da 0 a " + (workList.size() - 1)); while (workListIterator.hasNext()) { currElement = (KnuthElement) workListIterator.next(); - //log.debug("elemento n. " + workListIterator.previousIndex() + //log.debug("elemento n. " + workListIterator.previousIndex() // + " nella workList"); if (prevElement != null && prevElement.getLayoutManager() != currElement.getLayoutManager()) { @@ -667,8 +667,8 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager currElement.getLayoutManager(); boolean bSomethingAdded = false; if (prevLM != this) { - //log.debug(" BLM.getChangedKnuthElements> chiamata da " - // + fromIndex + " a " + workListIterator.previousIndex() + " su " + //log.debug(" BLM.getChangedKnuthElements> chiamata da " + // + fromIndex + " a " + workListIterator.previousIndex() + " su " // + prevLM.getClass().getName()); returnedList.addAll(prevLM.getChangedKnuthElements(workList.subList( fromIndex, workListIterator.previousIndex()), alignment)); @@ -677,7 +677,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager // prevLM == this // do nothing //log.debug(" BLM.getChangedKnuthElements> elementi propri, " - // + "ignorati, da " + fromIndex + " a " + workListIterator.previousIndex() + // + "ignorati, da " + fromIndex + " a " + workListIterator.previousIndex() // + " su " + prevLM.getClass().getName()); } fromIndex = workListIterator.previousIndex(); @@ -692,7 +692,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager || prevLM.mustKeepWithNext() || currLM.mustKeepWithPrevious())) { // add an infinite penalty to forbid a break between blocks - returnedList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, + returnedList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, new Position(this), false)); } else if (bSomethingAdded && !((KnuthElement) ListUtil.getLast(returnedList)) @@ -707,7 +707,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager BlockLevelLayoutManager currLM = (BlockLevelLayoutManager) currElement.getLayoutManager(); if (currLM != this) { - //log.debug(" BLM.getChangedKnuthElements> chiamata da " + fromIndex + //log.debug(" BLM.getChangedKnuthElements> chiamata da " + fromIndex // + " a " + oldList.size() + " su " + currLM.getClass().getName()); returnedList.addAll(currLM.getChangedKnuthElements( workList.subList(fromIndex, workList.size()), alignment)); @@ -718,7 +718,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager if (!returnedList.isEmpty()) { ListUtil.removeLast(returnedList); } - //log.debug(" BLM.getChangedKnuthElements> elementi propri, ignorati, da " + //log.debug(" BLM.getChangedKnuthElements> elementi propri, ignorati, da " // + fromIndex + " a " + workList.size()); } } @@ -747,7 +747,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager } } - //log.debug(" BLM.getChangedKnuthElements> intermedio: returnedList.size() = " + //log.debug(" BLM.getChangedKnuthElements> intermedio: returnedList.size() = " // + returnedList.size()); /* estensione: conversione complessiva */ @@ -774,18 +774,18 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager } if (bpUnit > 0 || adjustedSpaceAfter != 0) { if (!spaceAfterIsConditional) { - returnList.add(new KnuthPenalty(0, + returnList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, new NonLeafPosition(this, null), false)); } if (bpUnit > 0) { returnList.add(new KnuthGlue(0, 0, 0, - SPACE_AFTER_ADJUSTMENT, + SPACE_AFTER_ADJUSTMENT, new NonLeafPosition(this, null), (!spaceAfterIsConditional) ? false : true)); } else { returnList.add(new KnuthGlue(adjustedSpaceAfter, 0, 0, - SPACE_AFTER_ADJUSTMENT, + SPACE_AFTER_ADJUSTMENT, new NonLeafPosition(this, null), (!spaceAfterIsConditional) ? false : true)); } @@ -795,7 +795,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager } } - //log.debug(" BLM.getChangedKnuthElements> finished: returnList.size() = " + //log.debug(" BLM.getChangedKnuthElements> finished: returnList.size() = " // + returnList.size()); return returnList; } @@ -807,7 +807,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager protected int getParentKeepTogetherStrength() { int strength = KEEP_AUTO; if (getParent() instanceof BlockLevelLayoutManager) { - strength = ((BlockLevelLayoutManager)getParent()).getKeepTogetherStrength(); + strength = ((BlockLevelLayoutManager)getParent()).getKeepTogetherStrength(); } else if (getParent() instanceof InlineLayoutManager) { if (((InlineLayoutManager) getParent()).mustKeepTogether()) { strength = KEEP_ALWAYS; @@ -817,7 +817,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager } return strength; } - + /** {@inheritDoc} */ public boolean mustKeepTogether() { return getKeepTogetherStrength() > KEEP_AUTO; @@ -843,7 +843,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager if (borderAndPadding != null) { if (borderAndPadding.getBorderBeforeWidth(false) > 0) { context.addPendingBeforeMark(new BorderElement( - getAuxiliaryPosition(), + getAuxiliaryPosition(), borderAndPadding.getBorderInfo( CommonBorderPaddingBackground.BEFORE).getWidth(), RelSide.BEFORE, @@ -854,15 +854,15 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager getAuxiliaryPosition(), borderAndPadding.getPaddingLengthProperty( CommonBorderPaddingBackground.BEFORE), - RelSide.BEFORE, + RelSide.BEFORE, false, false, this)); } if (borderAndPadding.getBorderAfterWidth(false) > 0) { context.addPendingAfterMark(new BorderElement( - getAuxiliaryPosition(), + getAuxiliaryPosition(), borderAndPadding.getBorderInfo( CommonBorderPaddingBackground.AFTER).getWidth(), - RelSide.AFTER, + RelSide.AFTER, false, false, this)); } if (borderAndPadding.getPaddingAfter(false, this) > 0) { @@ -870,12 +870,12 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager getAuxiliaryPosition(), borderAndPadding.getPaddingLengthProperty( CommonBorderPaddingBackground.AFTER), - RelSide.AFTER, + RelSide.AFTER, false, false, this)); } } } - + /** @return the border, padding and background info structure */ private CommonBorderPaddingBackground getBorderPaddingBackground() { if (fobj instanceof org.apache.fop.fo.flow.Block) { @@ -897,7 +897,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager return null; } } - + /** @return the space-before property */ private SpaceProperty getSpaceBeforeProperty() { if (fobj instanceof org.apache.fop.fo.flow.Block) { @@ -919,7 +919,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager return null; } } - + /** @return the space-after property */ private SpaceProperty getSpaceAfterProperty() { if (fobj instanceof org.apache.fop.fo.flow.Block) { @@ -941,11 +941,11 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager return null; } } - + /** * Creates Knuth elements for before border padding and adds them to the return list. * @param returnList return list to add the additional elements to - * @param isFirst true if this is the first time a layout manager instance needs to generate + * @param isFirst true if this is the first time a layout manager instance needs to generate * border and padding */ protected void addKnuthElementsForBorderPaddingBefore(List returnList, boolean isFirst) { @@ -954,7 +954,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager if (borderAndPadding != null) { if (borderAndPadding.getBorderBeforeWidth(false) > 0) { returnList.add(new BorderElement( - getAuxiliaryPosition(), + getAuxiliaryPosition(), borderAndPadding.getBorderInfo(CommonBorderPaddingBackground.BEFORE) .getWidth(), RelSide.BEFORE, isFirst, false, this)); @@ -963,7 +963,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager returnList.add(new PaddingElement( getAuxiliaryPosition(), borderAndPadding.getPaddingLengthProperty( - CommonBorderPaddingBackground.BEFORE), + CommonBorderPaddingBackground.BEFORE), RelSide.BEFORE, isFirst, false, this)); } } @@ -972,7 +972,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager /** * Creates Knuth elements for after border padding and adds them to the return list. * @param returnList return list to add the additional elements to - * @param isLast true if this is the last time a layout manager instance needs to generate + * @param isLast true if this is the last time a layout manager instance needs to generate * border and padding */ protected void addKnuthElementsForBorderPaddingAfter(List returnList, boolean isLast) { @@ -988,7 +988,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager } if (borderAndPadding.getBorderAfterWidth(false) > 0) { returnList.add(new BorderElement( - getAuxiliaryPosition(), + getAuxiliaryPosition(), borderAndPadding.getBorderInfo(CommonBorderPaddingBackground.AFTER) .getWidth(), RelSide.AFTER, false, isLast, this)); @@ -1002,7 +1002,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager * @param context the layout context * @return true if an element has been added due to a break-before. */ - protected boolean addKnuthElementsForBreakBefore(List returnList, + protected boolean addKnuthElementsForBreakBefore(List returnList, LayoutContext context) { int breakBefore = -1; if (fobj instanceof org.apache.fop.fo.flow.Block) { @@ -1017,11 +1017,11 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager breakBefore = ((org.apache.fop.fo.flow.table.Table) fobj).getBreakBefore(); } if (breakBefore == EN_PAGE - || breakBefore == EN_COLUMN - || breakBefore == EN_EVEN_PAGE + || breakBefore == EN_COLUMN + || breakBefore == EN_EVEN_PAGE || breakBefore == EN_ODD_PAGE) { // return a penalty element, representing a forced page break - returnList.add(new BreakElement(getAuxiliaryPosition(), + returnList.add(new BreakElement(getAuxiliaryPosition(), 0, -KnuthElement.INFINITE, breakBefore, context)); return true; } else { @@ -1035,7 +1035,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager * @param context the layout context * @return true if an element has been added due to a break-after. */ - protected boolean addKnuthElementsForBreakAfter(List returnList, + protected boolean addKnuthElementsForBreakAfter(List returnList, LayoutContext context) { int breakAfter = -1; if (fobj instanceof org.apache.fop.fo.flow.Block) { @@ -1054,7 +1054,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager || breakAfter == EN_EVEN_PAGE || breakAfter == EN_ODD_PAGE) { // add a penalty element, representing a forced page break - returnList.add(new BreakElement(getAuxiliaryPosition(), + returnList.add(new BreakElement(getAuxiliaryPosition(), 0, -KnuthElement.INFINITE, breakAfter, context)); return true; } else { @@ -1067,21 +1067,21 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager * @param returnList return list to add the additional elements to * @param alignment vertical alignment */ - protected void addKnuthElementsForSpaceBefore(List returnList/*, + protected void addKnuthElementsForSpaceBefore(List returnList/*, Position returnPosition*/, int alignment) { SpaceProperty spaceBefore = getSpaceBeforeProperty(); // append elements representing space-before if (spaceBefore != null - && !(spaceBefore.getMinimum(this).getLength().getValue(this) == 0 + && !(spaceBefore.getMinimum(this).getLength().getValue(this) == 0 && spaceBefore.getMaximum(this).getLength().getValue(this) == 0)) { returnList.add(new SpaceElement(getAuxiliaryPosition(), spaceBefore, - RelSide.BEFORE, + RelSide.BEFORE, true, false, this)); } /* if (bpUnit > 0 || spaceBefore != null - && !(spaceBefore.getMinimum(this).getLength().getValue(this) == 0 + && !(spaceBefore.getMinimum(this).getLength().getValue(this) == 0 && spaceBefore.getMaximum(this).getLength().getValue(this) == 0)) { if (spaceBefore != null && !spaceBefore.getSpace().isDiscard()) { // add elements to prevent the glue to be discarded @@ -1091,7 +1091,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager } if (bpUnit > 0) { returnList.add(new KnuthGlue(0, 0, 0, - BlockLevelLayoutManager.SPACE_BEFORE_ADJUSTMENT, + BlockLevelLayoutManager.SPACE_BEFORE_ADJUSTMENT, getAuxiliaryPosition(), true)); } else { //if (alignment == EN_JUSTIFY) { returnList.add(new KnuthGlue( @@ -1100,11 +1100,11 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager - spaceBefore.getOptimum(this).getLength().getValue(this), spaceBefore.getOptimum(this).getLength().getValue(this) - spaceBefore.getMinimum(this).getLength().getValue(this), - BlockLevelLayoutManager.SPACE_BEFORE_ADJUSTMENT, + BlockLevelLayoutManager.SPACE_BEFORE_ADJUSTMENT, getAuxiliaryPosition(), true)); // } else { // returnList.add(new KnuthGlue( -// spaceBefore.getOptimum().getLength().getValue(this), +// spaceBefore.getOptimum().getLength().getValue(this), // 0, 0, BlockLevelLayoutManager.SPACE_BEFORE_ADJUSTMENT, // returnPosition, true)); } @@ -1116,28 +1116,28 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager * @param returnList return list to add the additional elements to * @param alignment vertical alignment */ - protected void addKnuthElementsForSpaceAfter(List returnList/*, Position returnPosition*/, + protected void addKnuthElementsForSpaceAfter(List returnList/*, Position returnPosition*/, int alignment) { SpaceProperty spaceAfter = getSpaceAfterProperty(); // append elements representing space-after if (spaceAfter != null - && !(spaceAfter.getMinimum(this).getLength().getValue(this) == 0 + && !(spaceAfter.getMinimum(this).getLength().getValue(this) == 0 && spaceAfter.getMaximum(this).getLength().getValue(this) == 0)) { returnList.add(new SpaceElement(getAuxiliaryPosition(), spaceAfter, - RelSide.AFTER, + RelSide.AFTER, false, true, this)); } /* if (bpUnit > 0 || spaceAfter != null - && !(spaceAfter.getMinimum(this).getLength().getValue(this) == 0 + && !(spaceAfter.getMinimum(this).getLength().getValue(this) == 0 && spaceAfter.getMaximum(this).getLength().getValue(this) == 0)) { if (spaceAfter != null && !spaceAfter.getSpace().isDiscard()) { returnList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, getAuxiliaryPosition(), false)); } if (bpUnit > 0) { - returnList.add(new KnuthGlue(0, 0, 0, + returnList.add(new KnuthGlue(0, 0, 0, BlockLevelLayoutManager.SPACE_AFTER_ADJUSTMENT, getAuxiliaryPosition(), true)); } else { //if (alignment == EN_JUSTIFY) { @@ -1162,7 +1162,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager } protected List createUnitElements(List oldList) { - //log.debug("Start conversion: " + oldList.size() + //log.debug("Start conversion: " + oldList.size() // + " elements, space-before.min=" + layoutProps.spaceBefore.getSpace().min // + " space-after.min=" + layoutProps.spaceAfter.getSpace().min); // add elements at the beginning and at the end of oldList @@ -1192,15 +1192,15 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager KnuthElement element = (KnuthElement) oldListIterator.next(); if (element.isBox()) { totalLength.add(new MinOptMax(element.getW())); - //log.debug("box " + element.getW()); + //log.debug("box " + element.getW()); } else if (element.isGlue()) { totalLength.min -= ((KnuthGlue) element).getZ(); totalLength.max += ((KnuthGlue) element).getY(); //leafValue = ((LeafPosition) element.getPosition()).getLeafPos(); - //log.debug("glue " + element.getW() + " + " + //log.debug("glue " + element.getW() + " + " // + ((KnuthGlue) element).getY() + " - " + ((KnuthGlue) element).getZ()); } else { - //log.debug((((KnuthPenalty)element).getP() == KnuthElement.INFINITE + //log.debug((((KnuthPenalty)element).getP() == KnuthElement.INFINITE // ? "PENALTY " : "penalty ") + element.getW()); } } @@ -1294,12 +1294,12 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager int uNewShrink = (unitsBeforeBreak.opt - unitsBeforeBreak.min) - (unsuppressibleUnits.opt - unsuppressibleUnits.min); - //log.debug("(" - // + unsuppressibleUnits.min + "-" + unsuppressibleUnits.opt + "-" + //log.debug("(" + // + unsuppressibleUnits.min + "-" + unsuppressibleUnits.opt + "-" // + unsuppressibleUnits.max + ") " - // + " -> " + unitsBeforeBreak.min + "-" + unitsBeforeBreak.opt + "-" + // + " -> " + unitsBeforeBreak.min + "-" + unitsBeforeBreak.opt + "-" // + unitsBeforeBreak.max - // + " + " + unitsAfterBreak.min + "-" + unitsAfterBreak.opt + "-" + // + " + " + unitsAfterBreak.min + "-" + unitsAfterBreak.opt + "-" // + unitsAfterBreak.max // + (uLengthChange != 0 ? " [length " + uLengthChange + "] " : "") // + (uStretchChange != 0 ? " [stretch " + uStretchChange + "] " : "") @@ -1332,9 +1332,9 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager // new infinite penalty, glue and box, if necessary if (uNewStretch - uStretchChange > 0 || uNewShrink - uShrinkChange > 0) { - int iStretchUnits = (uNewStretch - uStretchChange > 0 + int iStretchUnits = (uNewStretch - uStretchChange > 0 ? (uNewStretch - uStretchChange) : 0); - int iShrinkUnits = (uNewShrink - uShrinkChange > 0 + int iShrinkUnits = (uNewShrink - uShrinkChange > 0 ? (uNewShrink - uShrinkChange) : 0); newList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, mappingPos, @@ -1381,7 +1381,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager //log.debug(" PENALTY"); //log.debug(" glue 0 " + uStretchChange + " " + uShrinkChange); //log.debug(" penalty " + uLengthChange + " * unit"); - //log.debug(" glue 0 " + (- uStretchChange) + " " + //log.debug(" glue 0 " + (- uStretchChange) + " " // + (- uShrinkChange)); } else if (oldListIterator.hasNext()) { // new penalty @@ -1483,11 +1483,11 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager StackingIter(Iterator parentIter) { super(parentIter); } - + protected LayoutManager getLM(Object nextObj) { return ((Position) nextObj).getLM(); } - + protected Position getPos(Object nextObj) { return ((Position) nextObj); } @@ -1496,24 +1496,24 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager protected static class MappingPosition extends Position { private int iFirstIndex; private int iLastIndex; - + public MappingPosition(LayoutManager lm, int first, int last) { super(lm); iFirstIndex = first; iLastIndex = last; } - + public int getFirstIndex() { return iFirstIndex; } - + public int getLastIndex() { return iLastIndex; } } /** - * "wrap" the Position inside each element moving the elements from + * "wrap" the Position inside each element moving the elements from * SourceList to targetList * @param sourceList source list * @param targetList target list receiving the wrapped position elements @@ -1521,16 +1521,16 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager protected void wrapPositionElements(List sourceList, List targetList) { wrapPositionElements(sourceList, targetList, false); } - + /** - * "wrap" the Position inside each element moving the elements from + * "wrap" the Position inside each element moving the elements from * SourceList to targetList * @param sourceList source list * @param targetList target list receiving the wrapped position elements * @param force if true, every Position is wrapped regardless of its LM of origin */ protected void wrapPositionElements(List sourceList, List targetList, boolean force) { - + ListIterator listIter = sourceList.listIterator(); Object tempElement; while (listIter.hasNext()) { @@ -1542,7 +1542,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager force); } else if (tempElement instanceof List) { wrapPositionElements( - (List) tempElement, + (List) tempElement, targetList, force); } @@ -1563,12 +1563,12 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager targetList.add(el); } - + /** @return the sum of start-indent and end-indent */ protected int getIPIndents() { return startIndent + endIndent; } - + /** * Returns the IPD of the content area * @return the IPD of the content area @@ -1576,7 +1576,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager public int getContentAreaIPD() { return contentAreaIPD; } - + /** * Sets the IPD of the content area * @param contentAreaIPD the IPD of the content area @@ -1584,7 +1584,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager protected void setContentAreaIPD(int contentAreaIPD) { this.contentAreaIPD = contentAreaIPD; } - + /** * Returns the BPD of the content area * @return the BPD of the content area @@ -1592,6 +1592,6 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager public int getContentAreaBPD() { return -1; } - + } diff --git a/src/java/org/apache/fop/layoutmgr/BorderElement.java b/src/java/org/apache/fop/layoutmgr/BorderElement.java index 410ba7ebb..67026a4c0 100644 --- a/src/java/org/apache/fop/layoutmgr/BorderElement.java +++ b/src/java/org/apache/fop/layoutmgr/BorderElement.java @@ -42,7 +42,7 @@ public class BorderElement extends BorderOrPaddingElement { boolean isFirst, boolean isLast, PercentBaseContext context) { super(position, condLength, side, isFirst, isLast, context); } - + /** {@inheritDoc} */ public void notifyLayoutManager(MinOptMax effectiveLength) { LayoutManager lm = getOriginatingLayoutManager(); @@ -54,7 +54,7 @@ public class BorderElement extends BorderOrPaddingElement { + lm.getClass().getName()); } } - + /** {@inheritDoc} */ public String toString() { StringBuffer sb = new StringBuffer("Border["); @@ -62,5 +62,5 @@ public class BorderElement extends BorderOrPaddingElement { sb.append("]"); return sb.toString(); } - + } diff --git a/src/java/org/apache/fop/layoutmgr/BorderOrPaddingElement.java b/src/java/org/apache/fop/layoutmgr/BorderOrPaddingElement.java index d78a92610..28820224a 100644 --- a/src/java/org/apache/fop/layoutmgr/BorderOrPaddingElement.java +++ b/src/java/org/apache/fop/layoutmgr/BorderOrPaddingElement.java @@ -41,11 +41,11 @@ public abstract class BorderOrPaddingElement extends UnresolvedListElementWithLe RelSide side, boolean isFirst, boolean isLast, PercentBaseContext context) { super(position, - new MinOptMax(condLength.getLength().getValue(context)), side, + new MinOptMax(condLength.getLength().getValue(context)), side, condLength.isDiscard(), isFirst, isLast); } - + /** {@inheritDoc} */ public abstract void notifyLayoutManager(MinOptMax effectiveLength); - + } diff --git a/src/java/org/apache/fop/layoutmgr/BreakElement.java b/src/java/org/apache/fop/layoutmgr/BreakElement.java index 3ccfbf616..98e31dbf8 100644 --- a/src/java/org/apache/fop/layoutmgr/BreakElement.java +++ b/src/java/org/apache/fop/layoutmgr/BreakElement.java @@ -33,7 +33,7 @@ public class BreakElement extends UnresolvedListElement { private int breakClass = -1; private List pendingBeforeMarks; private List pendingAfterMarks; - + /** * Main constructor * @param position the Position instance needed by the addAreas stage of the LMs. @@ -43,10 +43,10 @@ public class BreakElement extends UnresolvedListElement { public BreakElement(Position position, int penaltyValue, LayoutContext context) { this(position, 0, penaltyValue, -1, context); } - + /** * Constructor for hard breaks. - * + * * @param position the Position instance needed by the addAreas stage of the LMs. * @param penaltyWidth the penalty width * @param penaltyValue the penalty value for the penalty element to be constructed @@ -55,7 +55,7 @@ public class BreakElement extends UnresolvedListElement { * {@link Constants#EN_EVEN_PAGE}, {@link Constants#EN_ODD_PAGE}) * @param context the layout context which contains the pending conditional elements */ - public BreakElement(Position position, int penaltyWidth, int penaltyValue, + public BreakElement(Position position, int penaltyWidth, int penaltyValue, int breakClass, LayoutContext context) { super(position); this.penaltyWidth = penaltyWidth; @@ -64,7 +64,7 @@ public class BreakElement extends UnresolvedListElement { this.pendingBeforeMarks = context.getPendingBeforeMarks(); this.pendingAfterMarks = context.getPendingAfterMarks(); } - + /** {@inheritDoc} */ public boolean isConditional() { return false; //Does not really apply here @@ -80,12 +80,12 @@ public class BreakElement extends UnresolvedListElement { public int getPenaltyWidth() { return this.penaltyWidth; } - + /** @return the penalty value */ public int getPenaltyValue() { return this.penaltyValue; } - + /** * Sets the penalty value. * @param p the new penalty value @@ -93,15 +93,15 @@ public class BreakElement extends UnresolvedListElement { public void setPenaltyValue(int p) { this.penaltyValue = p; } - + /** {@inheritDoc} */ public boolean isForcedBreak() { return penaltyValue == -KnuthElement.INFINITE; } - + /** * Returns the break class of this penalty. - * + * * @return one of {@link Constants#EN_AUTO}, {@link Constants#EN_COLUMN}, * {@link Constants#EN_PAGE}, {@link Constants#EN_EVEN_PAGE}, * {@link Constants#EN_ODD_PAGE} @@ -109,10 +109,10 @@ public class BreakElement extends UnresolvedListElement { public int getBreakClass() { return breakClass; } - + /** * Sets the break class. - * + * * @param breakClass one of {@link Constants#EN_AUTO}, {@link Constants#EN_COLUMN}, * {@link Constants#EN_PAGE}, {@link Constants#EN_EVEN_PAGE}, * {@link Constants#EN_ODD_PAGE} @@ -120,17 +120,17 @@ public class BreakElement extends UnresolvedListElement { public void setBreakClass(int breakClass) { this.breakClass = breakClass; } - + /** @return the pending border and padding elements at the before edge */ public List getPendingBeforeMarks() { return this.pendingBeforeMarks; } - + /** @return the pending border and padding elements at the after edge */ public List getPendingAfterMarks() { return this.pendingAfterMarks; } - + /** * Clears all pending marks associated with this break element. This is used in break * cases where we only know very late if the break is actually after all the content @@ -140,7 +140,7 @@ public class BreakElement extends UnresolvedListElement { this.pendingBeforeMarks = null; this.pendingAfterMarks = null; } - + /** {@inheritDoc} */ public String toString() { StringBuffer sb = new StringBuffer(); diff --git a/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java b/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java index df4bb1d47..0bf228e7e 100644 --- a/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java +++ b/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.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,24 +26,24 @@ import org.apache.fop.fo.FONode; /** * The set of nodes is sorted into lines indexed into activeLines. - * The nodes in each line are linked together in a single linked list by the + * The nodes in each line are linked together in a single linked list by the * KnuthNode.next field. The activeLines array contains a link to the head of * the linked list in index 'line*2' and a link to the tail at index 'line*2+1'. *

    - * The set of active nodes can be traversed by + * The set of active nodes can be traversed by *

      * for (int line = startLine; line < endLine; line++) {
      *     for (KnuthNode node = getNode(line); node != null; node = node.next) {
      *         // Do something with 'node'
      *     }
      * }
    - * 
    + * */ public abstract class BreakingAlgorithm { /** the logger for the class */ protected static Log log = LogFactory.getLog(BreakingAlgorithm.class); - + /** Maximum adjustment ration */ protected static final int INFINITE_RATIO = 1000; @@ -79,7 +79,7 @@ public abstract class BreakingAlgorithm { * The paragraph of KnuthElements. */ protected KnuthSequence par; - + /** * The width of a line (or height of a column in page-breaking mode). * -1 indicates that the line widths are different for each line. @@ -118,12 +118,12 @@ public abstract class BreakingAlgorithm { * line number l corresponds to the number of the line ending at the node's breakpoint. */ protected KnuthNode[] activeLines; - + /** * The number of active nodes. */ protected int activeNodeCount; - + /** * The lowest available line in the set of active nodes. */ @@ -218,7 +218,7 @@ public abstract class BreakingAlgorithm { /** best node for the preceding breakpoint */ public KnuthNode previous; - /** next possible node in the same line */ + /** next possible node in the same line */ public KnuthNode next; /** @@ -226,7 +226,7 @@ public abstract class BreakingAlgorithm { * into a line. */ public int fitRecoveryCounter = 0; - + public KnuthNode(int position, int line, int fitness, int totalWidth, int totalStretch, int totalShrink, double adjustRatio, int availableShrink, int availableStretch, @@ -249,7 +249,7 @@ public abstract class BreakingAlgorithm { return ""; + + " dem:" + totalDemerits + ">"; } } @@ -363,10 +363,10 @@ public abstract class BreakingAlgorithm { protected int getMaxRecoveryAttempts() { return MAX_RECOVERY_ATTEMPTS; } - + /** * Controls the behaviour of the algorithm in cases where the first element of a part - * overflows a line/page. + * overflows a line/page. * @return true if the algorithm should try to send the element to the next line/page. */ protected boolean isPartOverflowRecoveryActivated() { @@ -397,13 +397,13 @@ public abstract class BreakingAlgorithm { } /** @see #findBreakingPoints(KnuthSequence, int, double, boolean, int) */ - public int findBreakingPoints(KnuthSequence par, - double threshold, + public int findBreakingPoints(KnuthSequence par, + double threshold, boolean force, int allowedBreaks) { return findBreakingPoints(par, 0, threshold, force, allowedBreaks); } - + /** Finds an optimal set of breakpoints for the given paragraph. * @param par the paragraph to break * @param startIndex index of the Knuth element at which the breaking must start @@ -425,7 +425,7 @@ public abstract class BreakingAlgorithm { // reset lastTooShort and lastTooLong, as they could be not null // because of previous calls to findBreakingPoints - lastTooShort = lastTooLong = null; + lastTooShort = lastTooLong = null; // reset startLine and endLine startLine = endLine = 0; // current element in the paragraph @@ -449,7 +449,7 @@ public abstract class BreakingAlgorithm { if (log.isTraceEnabled()) { log.trace("Looping over " + (par.size() - startIndex) + " elements"); } - + KnuthNode lastForced = getNode(0); // main loop @@ -478,9 +478,9 @@ public abstract class BreakingAlgorithm { // consider all penalties, non-flagged penalties or non-forcing penalties // according to the value of allowedBreaks if (((KnuthPenalty) thisElement).getP() < KnuthElement.INFINITE - && (!(allowedBreaks == NO_FLAGGED_PENALTIES) + && (!(allowedBreaks == NO_FLAGGED_PENALTIES) || !(((KnuthPenalty) thisElement).isFlagged())) - && (!(allowedBreaks == ONLY_FORCED_BREAKS) + && (!(allowedBreaks == ONLY_FORCED_BREAKS) || ((KnuthPenalty) thisElement).getP() == -KnuthElement.INFINITE)) { considerLegalBreak(thisElement, i); } @@ -491,9 +491,9 @@ public abstract class BreakingAlgorithm { log.debug("Could not find a set of breaking points " + threshold); return 0; } - // lastDeactivated was a "good" break, while lastTooShort and lastTooLong + // lastDeactivated was a "good" break, while lastTooShort and lastTooLong // were "bad" breaks since the beginning; - // if it is not the node we just restarted from, lastDeactivated can + // if it is not the node we just restarted from, lastDeactivated can // replace either lastTooShort or lastTooLong if (lastDeactivated != null && lastDeactivated != lastForced) { if (lastDeactivated.adjustRatio > 0) { @@ -519,7 +519,7 @@ public abstract class BreakingAlgorithm { lastForced = node; node.fitRecoveryCounter = lastTooLong.previous.fitRecoveryCounter + 1; if (log.isDebugEnabled()) { - log.debug("first part doesn't fit into line, recovering: " + log.debug("first part doesn't fit into line, recovering: " + node.fitRecoveryCounter); } if (node.fitRecoveryCounter > getMaxRecoveryAttempts()) { @@ -621,7 +621,7 @@ public abstract class BreakingAlgorithm { * @param difference difference between target and actual line width * @param totalDemerits minimum total demerits up to the breakpoint * @param previous active node for the preceding breakpoint - */ + */ protected KnuthNode createNode(int position, int line, int fitness, int totalWidth, int totalStretch, int totalShrink, double adjustRatio, int availableShrink, int availableStretch, @@ -680,8 +680,8 @@ public abstract class BreakingAlgorithm { protected void considerLegalBreak(KnuthElement element, int elementIdx) { if (log.isTraceEnabled()) { - log.trace("considerLegalBreak() at " + elementIdx - + " (" + totalWidth + "+" + totalStretch + "-" + totalShrink + log.trace("considerLegalBreak() at " + elementIdx + + " (" + totalWidth + "+" + totalStretch + "-" + totalShrink + "), parts/lines: " + startLine + "-" + endLine); log.trace("\tCurrent active node list: " + activeNodeCount + " " + this.toString("\t")); } @@ -711,17 +711,17 @@ public abstract class BreakingAlgorithm { removeNode(line, node); lastDeactivated = compareNodes(lastDeactivated, node); } - + // The line is within the available shrink and the threshold. if (r >= -1 && r <= threshold) { int fitnessClass = computeFitness(r); double demerits = computeDemerits(node, element, fitnessClass, r); - + if (log.isTraceEnabled()) { log.trace("\tDemerits=" + demerits); log.trace("\tFitness class=" + fitnessClass); } - + if (demerits < best.getDemerits(fitnessClass)) { // updates best demerits data best.addRecord(demerits, node, r, availableShrink, availableStretch, @@ -729,7 +729,7 @@ public abstract class BreakingAlgorithm { lastTooShort = null; } } - + // The line is way too short, but we are in forcing mode, so a node is // calculated and stored in lastValidNode. if (force && (r <= -1 || r > threshold)) { @@ -739,7 +739,7 @@ public abstract class BreakingAlgorithm { int newStretch = totalStretch; int newShrink = totalShrink; - // add the width, stretch and shrink of glue elements after + // add the width, stretch and shrink of glue elements after // the break // this does not affect the dimension of the line / page, only // the values stored in the node; these would be as if the break @@ -772,7 +772,7 @@ public abstract class BreakingAlgorithm { if (lastTooShort == null || demerits <= lastTooShort.totalDemerits) { if (considerTooShort) { //consider possibilities which are too short - best.addRecord(demerits, node, r, + best.addRecord(demerits, node, r, availableShrink, availableStretch, difference, fitnessClass); } @@ -805,7 +805,7 @@ public abstract class BreakingAlgorithm { int newStretch = totalStretch; int newShrink = totalShrink; - // add the width, stretch and shrink of glue elements after + // add the width, stretch and shrink of glue elements after // the break // this does not affect the dimension of the line / page, only // the values stored in the node; these would be as if the break @@ -831,7 +831,7 @@ public abstract class BreakingAlgorithm { // the nodes in activeList must be ordered // by line number and position; if (log.isTraceEnabled()) { - log.trace("\tInsert new break in list of " + activeNodeCount + log.trace("\tInsert new break in list of " + activeNodeCount + " from fitness class " + i); } KnuthNode newNode = createNode(elementIdx, line + 1, i, @@ -849,7 +849,7 @@ public abstract class BreakingAlgorithm { * @param activeNode node for the previous breakpoint * @param element currently considered breakpoint * @return The difference in width. Positive numbers mean extra space in the line, - * negative number that the line overflows. + * negative number that the line overflows. */ protected int computeDifference(KnuthNode activeNode, KnuthElement element, int elementIndex) { @@ -862,14 +862,14 @@ public abstract class BreakingAlgorithm { } /** - * Return the adjust ration needed to make up for the difference. A ration of + * Return the adjust ration needed to make up for the difference. A ration of *
      *
    • 0 means that the break has the exact right width
    • - *
    • >= -1 && < 0 means that the break is wider than the line, - * but within the minimim values of the glues.
    • - *
    • >0 && < 1 means that the break is smaller than the line width, + *
    • >= -1 && < 0 means that the break is wider than the line, + * but within the minimim values of the glues.
    • + *
    • >0 && < 1 means that the break is smaller than the line width, * but within the maximum values of the glues.
    • - *
    • > 1 means that the break is too small to make up for the glues.
    • + *
    • > 1 means that the break is too small to make up for the glues.
    • *
    * @param activeNode * @param difference @@ -895,11 +895,11 @@ public abstract class BreakingAlgorithm { return 0; } } - + /** * Figure out the fitness class of this line (tight, loose, * very tight or very loose). - * See the section on "More Bells and Whistles" in Knuth's + * See the section on "More Bells and Whistles" in Knuth's * "Breaking Paragraphs Into Lines". * @param r * @return the fitness class @@ -923,11 +923,11 @@ public abstract class BreakingAlgorithm { * node and ending at the given element. * @param activeNode considered preceding line break * @param element considered current line break - * @param fitnessClass fitness of the current line + * @param fitnessClass fitness of the current line * @param r adjustment ratio for the current line * @return the demerit of the current line */ - protected double computeDemerits(KnuthNode activeNode, KnuthElement element, + protected double computeDemerits(KnuthNode activeNode, KnuthElement element, int fitnessClass, double r) { double demerits = 0; // compute demerits @@ -942,14 +942,14 @@ public abstract class BreakingAlgorithm { } else { demerits = f * f; } - + if (element.isPenalty() && ((KnuthPenalty) element).isFlagged() && getElement(activeNode.position).isPenalty() && ((KnuthPenalty) getElement(activeNode.position)).isFlagged()) { // add demerit for consecutive breaks at flagged penalties demerits += repeatedFlaggedDemerit; // there are at least two consecutive lines ending with a flagged penalty; - // check if the previous line end with a flagged penalty too, + // check if the previous line end with a flagged penalty too, // and if this situation is allowed int flaggedPenaltiesCount = 2; for (KnuthNode prevNode = activeNode.previous; @@ -1084,18 +1084,18 @@ public abstract class BreakingAlgorithm { */ protected int getLineWidth(int line) { if (this.lineWidth < 0) { - throw new IllegalStateException("lineWidth must be set" + throw new IllegalStateException("lineWidth must be set" + (this.lineWidth != 0 ? " and positive, but it is: " + this.lineWidth : "")); } else { return this.lineWidth; } } - + /** @return the constant line/part width or -1 if there is no such value */ protected int getLineWidth() { return this.lineWidth; } - + /** * Creates a string representation of the active nodes. Used for debugging. * @param prepend a string to prepend on each entry @@ -1130,7 +1130,7 @@ public abstract class BreakingAlgorithm { bestActiveNode = bestActiveNode.previous; } } - + /** @return the alignment for normal lines/parts */ public int getAlignment() { return this.alignment; diff --git a/src/java/org/apache/fop/layoutmgr/ConditionalElementListener.java b/src/java/org/apache/fop/layoutmgr/ConditionalElementListener.java index 50fdc54b0..9124cf997 100644 --- a/src/java/org/apache/fop/layoutmgr/ConditionalElementListener.java +++ b/src/java/org/apache/fop/layoutmgr/ConditionalElementListener.java @@ -49,5 +49,5 @@ public interface ConditionalElementListener { * (null means zero length) */ void notifyPadding(RelSide side, MinOptMax effectiveLength); - + } diff --git a/src/java/org/apache/fop/layoutmgr/ElementListObserver.java b/src/java/org/apache/fop/layoutmgr/ElementListObserver.java index d4f23b1ee..73a6d5be4 100644 --- a/src/java/org/apache/fop/layoutmgr/ElementListObserver.java +++ b/src/java/org/apache/fop/layoutmgr/ElementListObserver.java @@ -28,9 +28,9 @@ import java.util.List; * Please see the subclass within the test code. */ public class ElementListObserver { - + private static List activeObservers = null; - + /** * Adds a new Observer to the list. * @param observer the observer implementation @@ -41,7 +41,7 @@ public class ElementListObserver { } activeObservers.add(observer); } - + /** * Removes an Observer from the list. This call simply returns if the observer was not on * the list and does nothing. @@ -52,7 +52,7 @@ public class ElementListObserver { activeObservers.remove(observer); } } - + /** * Notifies all registered observers about the element list. * @param elementList the Knuth element list @@ -70,7 +70,7 @@ public class ElementListObserver { } } } - + /** @return true if observation is active, i.e. Observers are registered. */ public static boolean isObservationActive() { return activeObservers != null; @@ -80,7 +80,7 @@ public class ElementListObserver { * Implement this interface to receive notifications on element lists. */ public interface Observer { - + /** * Notifies the observer about the element list. * @param elementList the Knuth element list @@ -89,7 +89,7 @@ public class ElementListObserver { * @param id ID for the element list (may be null) */ void observe(List elementList, String category, String id); - + } - + } diff --git a/src/java/org/apache/fop/layoutmgr/ElementListUtils.java b/src/java/org/apache/fop/layoutmgr/ElementListUtils.java index c04d197e4..d7f854a42 100644 --- a/src/java/org/apache/fop/layoutmgr/ElementListUtils.java +++ b/src/java/org/apache/fop/layoutmgr/ElementListUtils.java @@ -29,14 +29,14 @@ import org.apache.fop.util.ListUtil; * Utilities for Knuth element lists. */ public final class ElementListUtils { - + private ElementListUtils() { // Utility class. } /** * Removes legal breaks in an element list. A constraint can be specified to limit the - * range in which the breaks are removed. Legal breaks occuring before at least + * range in which the breaks are removed. Legal breaks occuring before at least * constraint.opt space is filled will be removed. * @param elements the element list * @param constraint min/opt/max value to restrict the range in which the breaks are removed. @@ -48,7 +48,7 @@ public final class ElementListUtils { /** * Removes legal breaks in an element list. A constraint can be specified to limit the - * range in which the breaks are removed. Legal breaks occuring before at least + * range in which the breaks are removed. Legal breaks occuring before at least * constraint space is filled will be removed. * @param elements the element list * @param constraint value to restrict the range in which the breaks are removed. diff --git a/src/java/org/apache/fop/layoutmgr/ExternalDocumentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/ExternalDocumentLayoutManager.java index 086d91c31..4dcb5e14c 100644 --- a/src/java/org/apache/fop/layoutmgr/ExternalDocumentLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/ExternalDocumentLayoutManager.java @@ -61,8 +61,8 @@ public class ExternalDocumentLayoutManager extends AbstractPageSequenceLayoutMan private static Log log = LogFactory.getLog(ExternalDocumentLayoutManager.class); - private ImageLayout imageLayout; - + private ImageLayout imageLayout; + /** * Constructor * @@ -74,7 +74,7 @@ public class ExternalDocumentLayoutManager extends AbstractPageSequenceLayoutMan } /** - * @return the ExternalDocument being managed by this layout manager + * @return the ExternalDocument being managed by this layout manager */ protected ExternalDocument getExternalDocument() { return (ExternalDocument)pageSeq; @@ -84,24 +84,24 @@ public class ExternalDocumentLayoutManager extends AbstractPageSequenceLayoutMan public PageSequenceLayoutManager getPSLM() { throw new IllegalStateException("getPSLM() is illegal for " + getClass().getName()); } - + /** {@inheritDoc} */ public void activateLayout() { initialize(); FOUserAgent userAgent = pageSeq.getUserAgent(); ImageManager imageManager = userAgent.getFactory().getImageManager(); - + String uri = getExternalDocument().getSrc(); Integer firstPageIndex = ImageUtil.getPageIndexFromURI(uri); boolean hasPageIndex = (firstPageIndex != null); - + try { ImageInfo info = imageManager.getImageInfo(uri, userAgent.getImageSessionContext()); - + Object moreImages = info.getCustomObjects().get(ImageInfo.HAS_MORE_IMAGES); boolean hasMoreImages = moreImages != null && !Boolean.FALSE.equals(moreImages); - + Dimension intrinsicSize = info.getSize().getDimensionMpt(); ImageLayout layout = new ImageLayout(getExternalDocument(), this, intrinsicSize); @@ -111,7 +111,7 @@ public class ExternalDocumentLayoutManager extends AbstractPageSequenceLayoutMan } makePageForImage(info, layout); - + if (!hasPageIndex && hasMoreImages) { if (log.isTraceEnabled()) { log.trace("Starting multi-page processing..."); @@ -129,16 +129,16 @@ public class ExternalDocumentLayoutManager extends AbstractPageSequenceLayoutMan } ImageInfo subinfo = imageManager.getImageInfo( tempURI.toASCIIString(), userAgent.getImageSessionContext()); - + moreImages = subinfo.getCustomObjects().get(ImageInfo.HAS_MORE_IMAGES); hasMoreImages = moreImages != null && !Boolean.FALSE.equals(moreImages); - + intrinsicSize = subinfo.getSize().getDimensionMpt(); layout = new ImageLayout( getExternalDocument(), this, intrinsicSize); - + makePageForImage(subinfo, layout); - + pageIndex++; } } catch (URISyntaxException e) { @@ -170,15 +170,15 @@ public class ExternalDocumentLayoutManager extends AbstractPageSequenceLayoutMan fillPage(info.getOriginalURI()); finishPage(); } - + private void fillPage(String uri) { Dimension imageSize = this.imageLayout.getViewportSize(); - + Block blockArea = new Block(); blockArea.setIPD(imageSize.width); LineArea lineArea = new LineArea(); - + Image imageArea = new Image(uri); TraitSetter.setProducerID(imageArea, fobj.getId()); transferForeignAttributes(imageArea); @@ -189,7 +189,7 @@ public class ExternalDocumentLayoutManager extends AbstractPageSequenceLayoutMan vp.setBPD(imageSize.height); vp.setContentPosition(imageLayout.getPlacement()); vp.setOffset(0); - + //Link them all together... lineArea.addInlineArea(vp); lineArea.updateExtentsFromChildren(); @@ -197,7 +197,7 @@ public class ExternalDocumentLayoutManager extends AbstractPageSequenceLayoutMan curPage.getPageViewport().getCurrentFlow().addBlock(blockArea); curPage.getPageViewport().getCurrentSpan().notifyFlowsFinished(); } - + /** {@inheritDoc} */ public void finishPageSequence() { if (pageSeq.hasId()) { @@ -208,7 +208,7 @@ public class ExternalDocumentLayoutManager extends AbstractPageSequenceLayoutMan (currentPageNum - startPageNum) + 1); areaTreeHandler.notifyPageSequenceFinished(pageSeq, (currentPageNum - startPageNum) + 1); - + if (log.isDebugEnabled()) { log.debug("Ending layout"); } @@ -217,9 +217,9 @@ public class ExternalDocumentLayoutManager extends AbstractPageSequenceLayoutMan /** {@inheritDoc} */ protected Page createPage(int pageNumber, boolean isBlank) { String pageNumberString = pageSeq.makeFormattedPageNumber(pageNumber); - + Dimension imageSize = this.imageLayout.getViewportSize(); - + // Set up the CTM on the page reference area based on writing-mode // and reference-orientation Rectangle referenceRect; @@ -231,10 +231,10 @@ public class ExternalDocumentLayoutManager extends AbstractPageSequenceLayoutMan FODimension reldims = new FODimension(0, 0); CTM pageCTM = CTM.getCTMandRelDims(pageSeq.getReferenceOrientation(), Constants.EN_LR_TB, referenceRect, reldims); - + Page page = new Page(referenceRect, pageNumber, pageNumberString, isBlank); - - PageViewport pv = page.getPageViewport(); + + PageViewport pv = page.getPageViewport(); org.apache.fop.area.Page pageArea = new org.apache.fop.area.Page(); pv.setPage(pageArea); @@ -242,8 +242,8 @@ public class ExternalDocumentLayoutManager extends AbstractPageSequenceLayoutMan rv.setIPD(referenceRect.width); rv.setBPD(referenceRect.height); rv.setClip(true); - - BodyRegion body = new BodyRegion(Constants.FO_REGION_BODY, + + BodyRegion body = new BodyRegion(Constants.FO_REGION_BODY, "fop-image-region", rv, 1, 0); body.setIPD(imageSize.width); body.setBPD(imageSize.height); @@ -256,7 +256,7 @@ public class ExternalDocumentLayoutManager extends AbstractPageSequenceLayoutMan //Also creates first normal flow region pv.createSpan(false); - + return page; } diff --git a/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java b/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java index 1c8fb679f..293d6dbe0 100644 --- a/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.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,12 +46,12 @@ public class FlowLayoutManager extends BlockStackingLayoutManager * logging instance */ private static Log log = LogFactory.getLog(FlowLayoutManager.class); - + /** Array of areas currently being filled stored by area class */ private BlockParent[] currentAreas = new BlockParent[Area.CLASS_MAX]; private int currentSpan = EN_NONE; - + /** * This is the top level layout manager. * It is created by the PageSequence FO. @@ -96,7 +96,7 @@ public class FlowLayoutManager extends BlockStackingLayoutManager SpaceResolver.resolveElementList(returnList); return returnList; } - + // Set up a LayoutContext //MinOptMax bpd = context.getStackLimit(); @@ -104,7 +104,7 @@ public class FlowLayoutManager extends BlockStackingLayoutManager childLC.setStackLimitBP(context.getStackLimitBP()); childLC.setRefIPD(context.getRefIPD()); childLC.setWritingMode(getCurrentPage().getSimplePageMaster().getWritingMode()); - + // get elements from curLM returnedList = curLM.getNextKnuthElements(childLC, alignment); //log.debug("FLM.getNextKnuthElements> returnedList.size() = " + returnedList.size()); @@ -148,7 +148,7 @@ public class FlowLayoutManager extends BlockStackingLayoutManager //Propagate and clear context.updateKeepWithNextPending(childLC.getKeepWithNextPending()); childLC.clearKeepWithNextPending(); - + context.updateKeepWithNextPending(getKeepWithNextStrength()); } @@ -201,7 +201,7 @@ public class FlowLayoutManager extends BlockStackingLayoutManager public int getKeepTogetherStrength() { return KEEP_AUTO; } - + /** {@inheritDoc} */ public int getKeepWithNextStrength() { return KEEP_AUTO; @@ -211,7 +211,7 @@ public class FlowLayoutManager extends BlockStackingLayoutManager public int getKeepWithPreviousStrength() { return KEEP_AUTO; } - + /** {@inheritDoc} */ public List getChangedKnuthElements(List oldList, /*int flaggedPenalty,*/ int alignment) { ListIterator oldListIterator = oldList.listIterator(); @@ -255,7 +255,7 @@ public class FlowLayoutManager extends BlockStackingLayoutManager if (prevLM.mustKeepWithNext() || currLM.mustKeepWithPrevious()) { // add an infinite penalty to forbid a break between blocks - returnedList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, + returnedList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, new Position(this), false)); } else if (!((KnuthElement) returnedList.get(returnedList .size() - 1)).isGlue()) { @@ -288,7 +288,7 @@ public class FlowLayoutManager extends BlockStackingLayoutManager } /** - * {@inheritDoc} + * {@inheritDoc} */ public void addAreas(PositionIterator parentIter, LayoutContext layoutContext) { AreaAdditionUtil.addAreas(this, parentIter, layoutContext); @@ -299,7 +299,7 @@ public class FlowLayoutManager extends BlockStackingLayoutManager * Add child area to a the correct container, depending on its * area class. A Flow can fill at most one area container of any class * at any one time. The actual work is done by BlockStackingLM. - * + * * @param childArea the area to add */ public void addChildArea(Area childArea) { @@ -314,7 +314,7 @@ public class FlowLayoutManager extends BlockStackingLayoutManager public Area getParentArea(Area childArea) { BlockParent parentArea = null; int aclass = childArea.getAreaClass(); - + if (aclass == Area.CLASS_NORMAL) { parentArea = getCurrentPV().getCurrentFlow(); } else if (aclass == Area.CLASS_BEFORE_FLOAT) { @@ -325,7 +325,7 @@ public class FlowLayoutManager extends BlockStackingLayoutManager throw new IllegalStateException("(internal error) Invalid " + "area class (" + aclass + ") requested."); } - + this.currentAreas[aclass] = parentArea; setCurrentArea(parentArea); return parentArea; @@ -338,7 +338,7 @@ public class FlowLayoutManager extends BlockStackingLayoutManager public int getContentAreaIPD() { return getCurrentPV().getCurrentSpan().getColumnWidth(); } - + /** * Returns the BPD of the content area * @return the BPD of the content area diff --git a/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.java b/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.java index 34b931c03..791008aec 100644 --- a/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.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. @@ -95,7 +95,7 @@ public class FootnoteBodyLayoutManager extends BlockStackingLayoutManager { public int getKeepTogetherStrength() { return getParentKeepTogetherStrength(); } - + /** {@inheritDoc} */ public int getKeepWithNextStrength() { return KEEP_AUTO; @@ -105,5 +105,5 @@ public class FootnoteBodyLayoutManager extends BlockStackingLayoutManager { public int getKeepWithPreviousStrength() { return KEEP_AUTO; } - + } diff --git a/src/java/org/apache/fop/layoutmgr/InlineKnuthSequence.java b/src/java/org/apache/fop/layoutmgr/InlineKnuthSequence.java index e9973c14f..6d11a3c24 100644 --- a/src/java/org/apache/fop/layoutmgr/InlineKnuthSequence.java +++ b/src/java/org/apache/fop/layoutmgr/InlineKnuthSequence.java @@ -35,12 +35,12 @@ public class InlineKnuthSequence extends KnuthSequence { private boolean isClosed = false; /** - * Creates a new and empty list. + * Creates a new and empty list. */ public InlineKnuthSequence() { super(); } - + /** * Creates a new list from an existing list. * @param list The list from which to create the new list. @@ -84,14 +84,14 @@ public class InlineKnuthSequence extends KnuthSequence { } /* (non-Javadoc) - * {@inheritDoc} + * {@inheritDoc} */ public boolean appendSequence(KnuthSequence sequence, boolean keepTogether, BreakElement breakElement) { return appendSequence(sequence); } - + /* (non-Javadoc) * {@inheritDoc} */ diff --git a/src/java/org/apache/fop/layoutmgr/KeepUtil.java b/src/java/org/apache/fop/layoutmgr/KeepUtil.java index 8c80a1b10..5cc33533f 100644 --- a/src/java/org/apache/fop/layoutmgr/KeepUtil.java +++ b/src/java/org/apache/fop/layoutmgr/KeepUtil.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,7 +46,7 @@ public class KeepUtil { return keep.getNumber().intValue(); } } - + /** * Returns the combined block-level keep strength from a keep property. *

    @@ -60,7 +60,7 @@ public class KeepUtil { getKeepStrength(keep.getWithinPage()), getKeepStrength(keep.getWithinColumn())); } - + /** * Indicates whether a keep strength indicates a keep constraint. * @param strength the keep strength @@ -69,7 +69,7 @@ public class KeepUtil { public static boolean hasKeep(int strength) { return strength > BlockLevelLayoutManager.KEEP_AUTO; } - + /** * Returns the penalty value to be used for a certain keep strength. *

      @@ -90,7 +90,7 @@ public class KeepUtil { } return penalty; } - + /** * Returns a string representation of a keep strength value. * @param keepStrength the keep strength @@ -105,5 +105,5 @@ public class KeepUtil { return Integer.toString(keepStrength); } } - + } diff --git a/src/java/org/apache/fop/layoutmgr/KnuthBlockBox.java b/src/java/org/apache/fop/layoutmgr/KnuthBlockBox.java index 364c896ad..1aa22ea3e 100644 --- a/src/java/org/apache/fop/layoutmgr/KnuthBlockBox.java +++ b/src/java/org/apache/fop/layoutmgr/KnuthBlockBox.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.traits.MinOptMax; * Knuth box used to represent a line in block-progression-dimension (i.e. the width is its height). */ public class KnuthBlockBox extends KnuthBox { - + private MinOptMax ipdRange; /** * Natural width of the line represented by this box. In addition to ipdRange because @@ -58,7 +58,7 @@ public class KnuthBlockBox extends KnuthBox { * Creates a new box. * @param w block progression dimension of this box * @param list footnotes cited by elements in this box. The list contains the - * corresponding FootnoteBodyLayoutManagers + * corresponding FootnoteBodyLayoutManagers * @param pos the Position stored in this box * @param bAux is this box auxiliary? */ diff --git a/src/java/org/apache/fop/layoutmgr/KnuthBox.java b/src/java/org/apache/fop/layoutmgr/KnuthBox.java index a465ca8da..7c3df61fa 100644 --- a/src/java/org/apache/fop/layoutmgr/KnuthBox.java +++ b/src/java/org/apache/fop/layoutmgr/KnuthBox.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,11 +23,11 @@ package org.apache.fop.layoutmgr; * An instance of this class represents an unbreakable piece of content with * fixed width: for example an image, a syllable (but only if letter spacing * is constant), ... - * + * * A KnuthBox is never a feasible breaking point. - * + * * The represented piece of content is never suppressed. - * + * * Besides the inherited methods and attributes, this class has some more * attributes to store information about the content height and its vertical * positioning, and the methods used to get them. @@ -61,5 +61,5 @@ public class KnuthBox extends KnuthElement { sb.append(getW()); return sb.toString(); } - + } diff --git a/src/java/org/apache/fop/layoutmgr/KnuthElement.java b/src/java/org/apache/fop/layoutmgr/KnuthElement.java index 71f3b3ce9..41c813010 100644 --- a/src/java/org/apache/fop/layoutmgr/KnuthElement.java +++ b/src/java/org/apache/fop/layoutmgr/KnuthElement.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. @@ -21,7 +21,7 @@ package org.apache.fop.layoutmgr; /** * This is the super class for KnuthBox, KnuthGlue and KnuthPenalty. - * + * * It stores information common to all sub classes, and the methods to get it: * the width, a Position and a boolean marking KnuthElements used for some * special feature (for example, the additional elements used to represent @@ -59,21 +59,21 @@ public abstract class KnuthElement extends ListElement { return width; } - /** @return the penalty value of this element, if applicable. */ + /** @return the penalty value of this element, if applicable. */ public int getP() { throw new RuntimeException("Element is not a penalty"); } - /** @return the stretch value of this element, if applicable. */ + /** @return the stretch value of this element, if applicable. */ public int getY() { throw new RuntimeException("Element is not a glue"); } - /** @return the shrink value of this element, if applicable. */ + /** @return the shrink value of this element, if applicable. */ public int getZ() { throw new RuntimeException("Element is not a glue"); } - + /** {@inheritDoc} */ public boolean isUnresolvedElement() { return false; diff --git a/src/java/org/apache/fop/layoutmgr/KnuthGlue.java b/src/java/org/apache/fop/layoutmgr/KnuthGlue.java index 0b6706c4b..fbb291f6b 100644 --- a/src/java/org/apache/fop/layoutmgr/KnuthGlue.java +++ b/src/java/org/apache/fop/layoutmgr/KnuthGlue.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. @@ -20,16 +20,16 @@ package org.apache.fop.layoutmgr; /** - * An instance of this class represents a piece of content with adjustable + * An instance of this class represents a piece of content with adjustable * width: for example a space between words of justified text. - * + * * A KnuthGlue is a feasible breaking point only if it immediately follows * a KnuthBox. - * + * * The represented piece of content is suppressed if either the KnuthGlue * is a chosen breaking point or there isn't any KnuthBox between the * previous breaking point and the KnuthGlue itself. - * + * * So, an unsuppressible piece of content with adjustable width, for example * a leader or a word with adjustable letter space, cannot be represented * by a single KnuthGlue; it can be represented using the sequence: @@ -39,14 +39,14 @@ package org.apache.fop.layoutmgr; * KnuthBox(width = 0) * where the infinity penalty avoids choosing the KnuthGlue as a breaking point * and the 0-width KnuthBoxes prevent suppression. - * + * * Besides the inherited methods and attributes, this class has two attributes * used to store the stretchability (difference between max and opt width) and * the shrinkability (difference between opt and min width), and the methods * to get these values. */ public class KnuthGlue extends KnuthElement { - + private int stretchability; private int shrinkability; private int adjustmentClass = -1; @@ -88,12 +88,12 @@ public class KnuthGlue extends KnuthElement { public int getZ() { return shrinkability; } - + /** @return the adjustment class (or role) of this glue. */ public int getAdjustmentClass() { return adjustmentClass; } - + /** {@inheritDoc} */ public String toString() { StringBuffer sb = new StringBuffer(64); @@ -109,5 +109,5 @@ public class KnuthGlue extends KnuthElement { } return sb.toString(); } - + } diff --git a/src/java/org/apache/fop/layoutmgr/KnuthPenalty.java b/src/java/org/apache/fop/layoutmgr/KnuthPenalty.java index ecaeac627..6c13fba8a 100644 --- a/src/java/org/apache/fop/layoutmgr/KnuthPenalty.java +++ b/src/java/org/apache/fop/layoutmgr/KnuthPenalty.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,15 +24,15 @@ import org.apache.fop.fo.Constants; /** * An instance of this class represents information about a feasible * breaking point; it does not represent any piece of content. - * + * * A KnuthPenalty is a feasible breaking point unless its value is infinity; * a KnuthPenalty whose value is -infinity represents a forced break. - * + * * A KnuthPenalty is suppressed, and its width is ignored, if it is not a * chosen breaking point; for example, a KnuthPenalty representing a * hyphenation point has a width (the "-" width), which must be ignored if * that point is not chosen as a breaking point. - * + * * Besides the inherited methods and attributes, this class has two more * attributes and the methods used to get them: the penalty value, which is * a kind of "aesthetic cost" (the higher the value, the more unsightly the @@ -45,7 +45,7 @@ public class KnuthPenalty extends KnuthElement { public static final int FLAGGED_PENALTY = 50; private int penalty; - private boolean bFlagged; + private boolean bFlagged; private int breakClass = -1; /** @@ -65,7 +65,7 @@ public class KnuthPenalty extends KnuthElement { /** * Create a new KnuthPenalty. - * + * * @param w the width of this penalty * @param p the penalty value of this penalty * @param f is this penalty flagged? @@ -102,7 +102,7 @@ public class KnuthPenalty extends KnuthElement { public void setP(int p) { this.penalty = p; } - + /** @return true is this penalty is a flagged one. */ public boolean isFlagged() { return bFlagged; @@ -112,7 +112,7 @@ public class KnuthPenalty extends KnuthElement { public boolean isForcedBreak() { return penalty == -KnuthElement.INFINITE; } - + /** * @return the break class of this penalty (EN_AUTO, EN_COLUMN, EN_PAGE, EN_EVEN_PAGE, * EN_ODD_PAGE) @@ -120,7 +120,7 @@ public class KnuthPenalty extends KnuthElement { public int getBreakClass() { return breakClass; } - + /** * Sets the break class for this penalty. * @param cl the break class (EN_AUTO, EN_COLUMN, EN_PAGE, EN_EVEN_PAGE, EN_ODD_PAGE) @@ -128,7 +128,7 @@ public class KnuthPenalty extends KnuthElement { public void setBreakClass(int cl) { this.breakClass = cl; } - + /** {@inheritDoc} */ public String toString() { StringBuffer sb = new StringBuffer(64); @@ -171,5 +171,5 @@ public class KnuthPenalty extends KnuthElement { } return sb.toString(); } - + } diff --git a/src/java/org/apache/fop/layoutmgr/KnuthPossPosIter.java b/src/java/org/apache/fop/layoutmgr/KnuthPossPosIter.java index 3f334f4be..e7397babb 100644 --- a/src/java/org/apache/fop/layoutmgr/KnuthPossPosIter.java +++ b/src/java/org/apache/fop/layoutmgr/KnuthPossPosIter.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 @@ public class KnuthPossPosIter extends PositionIterator { super(elementList.listIterator(startPos)); iterCount = endPos - startPos; } - + /** * Auxiliary constructor * @param elementList List of Knuth elements @@ -45,7 +45,7 @@ public class KnuthPossPosIter extends PositionIterator { } // Check position < endPos - + /** * {@inheritDoc} */ diff --git a/src/java/org/apache/fop/layoutmgr/KnuthSequence.java b/src/java/org/apache/fop/layoutmgr/KnuthSequence.java index 4467a397b..fe9a01498 100644 --- a/src/java/org/apache/fop/layoutmgr/KnuthSequence.java +++ b/src/java/org/apache/fop/layoutmgr/KnuthSequence.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 java.util.ListIterator; * Represents a list of Knuth elements. */ /** - * + * */ public abstract class KnuthSequence extends ArrayList { /** @@ -68,19 +68,19 @@ public abstract class KnuthSequence extends ArrayList { * Append sequence to this sequence if it can be appended. * @param sequence The sequence that is to be appended. * @param keepTogether Whether the two sequences must be kept together. - * @param breakElement The BreakElement that may be inserted between the two sequences. + * @param breakElement The BreakElement that may be inserted between the two sequences. * @return whether the sequence was succesfully appended to this sequence. */ public abstract boolean appendSequence(KnuthSequence sequence, boolean keepTogether, BreakElement breakElement); - + /** * Append sequence to this sequence if it can be appended. * @param sequence The sequence that is to be appended. * @return whether the sequence was succesfully appended to this sequence. */ public abstract boolean appendSequence(KnuthSequence sequence); - + /** * Append sequence to this sequence if it can be appended. * If that is not possible, close this sequence. @@ -95,13 +95,13 @@ public abstract class KnuthSequence extends ArrayList { return true; } } - + /** * Append sequence to this sequence if it can be appended. * If that is not possible, close this sequence. * @param sequence The sequence that is to be appended. * @param keepTogether Whether the two sequences must be kept together. - * @param breakElement The BreakElement that may be inserted between the two sequences. + * @param breakElement The BreakElement that may be inserted between the two sequences. * @return whether the sequence was succesfully appended to this sequence. */ public boolean appendSequenceOrClose(KnuthSequence sequence, boolean keepTogether, @@ -113,7 +113,7 @@ public abstract class KnuthSequence extends ArrayList { return true; } } - + /** * Wrap the Positions of the elements of this sequence in a Position for LayoutManager lm. * @param lm The LayoutManager for the Positions that will be created. @@ -127,14 +127,14 @@ public abstract class KnuthSequence extends ArrayList { (lm.notifyPos(new NonLeafPosition(lm, element.getPosition()))); } } - + /** * @return the last element of this sequence. */ public ListElement getLast() { int idx = size(); if (idx == 0) { - return null; + return null; } return (ListElement) get(idx - 1); } @@ -146,7 +146,7 @@ public abstract class KnuthSequence extends ArrayList { public ListElement removeLast() { int idx = size(); if (idx == 0) { - return null; + return null; } return (ListElement) remove(idx - 1); } diff --git a/src/java/org/apache/fop/layoutmgr/LMiter.java b/src/java/org/apache/fop/layoutmgr/LMiter.java index 9e812a8b7..4fa5590dc 100644 --- a/src/java/org/apache/fop/layoutmgr/LMiter.java +++ b/src/java/org/apache/fop/layoutmgr/LMiter.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/layoutmgr/LayoutContext.java b/src/java/org/apache/fop/layoutmgr/LayoutContext.java index 5ac9808f2..1be89304b 100644 --- a/src/java/org/apache/fop/layoutmgr/LayoutContext.java +++ b/src/java/org/apache/fop/layoutmgr/LayoutContext.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. @@ -106,15 +106,15 @@ public class LayoutContext { /** Current pending space-before or space-start from ancestor areas */ private SpaceSpecifier leadingSpace; - + /** - * A list of pending marks (border and padding) on the after edge when a page break occurs. + * A list of pending marks (border and padding) on the after edge when a page break occurs. * May be null. */ private List pendingAfterMarks; - + /** - * A list of pending marks (border and padding) on the before edge when a page break occurs. + * A list of pending marks (border and padding) on the before edge when a page break occurs. * May be null. */ private List pendingBeforeMarks; @@ -124,7 +124,7 @@ public class LayoutContext { /** Alignment in BP direction */ private int bpAlignment = Constants.EN_START; - + /** Stretch or shrink value when making areas. */ private double ipdAdjust = 0.0; @@ -132,12 +132,12 @@ public class LayoutContext { private double dSpaceAdjust = 0.0; private AlignmentContext alignmentContext = null; - + /** Amount of space before / start */ private int spaceBefore = 0; /** Amount of space after / end */ private int spaceAfter = 0; - + /** Amount of space to reserve at the beginning of each line */ private int lineStartBorderAndPaddingWidth = 0; /** Amount of space to reserve at the end of each line */ @@ -146,9 +146,9 @@ public class LayoutContext { private int breakBefore; private int breakAfter; - private int pendingKeepWithNext = BlockLevelLayoutManager.KEEP_AUTO; - private int pendingKeepWithPrevious = BlockLevelLayoutManager.KEEP_AUTO; - + private int pendingKeepWithNext = BlockLevelLayoutManager.KEEP_AUTO; + private int pendingKeepWithPrevious = BlockLevelLayoutManager.KEEP_AUTO; + /** * Copy constructor for creating child layout contexts. * @param parentLC the parent layout context to copy from @@ -188,13 +188,13 @@ public class LayoutContext { public void copyPendingMarksFrom(LayoutContext source) { if (source.pendingAfterMarks != null) { - this.pendingAfterMarks = new java.util.ArrayList(source.pendingAfterMarks); + this.pendingAfterMarks = new java.util.ArrayList(source.pendingAfterMarks); } if (source.pendingBeforeMarks != null) { - this.pendingBeforeMarks = new java.util.ArrayList(source.pendingBeforeMarks); + this.pendingBeforeMarks = new java.util.ArrayList(source.pendingBeforeMarks); } } - + public void setFlags(int flags) { setFlags(flags, true); } @@ -238,7 +238,7 @@ public class LayoutContext { public int getKeepWithNextPending() { return this.pendingKeepWithNext; } - + /** * Returns the strength of a keep-with-previous currently pending. * @return the keep-with-previous strength @@ -246,7 +246,7 @@ public class LayoutContext { public int getKeepWithPreviousPending() { return this.pendingKeepWithPrevious; } - + /** * Clears any pending keep-with-next strength. */ @@ -260,7 +260,7 @@ public class LayoutContext { public void clearKeepWithPreviousPending() { this.pendingKeepWithPrevious = BlockLevelLayoutManager.KEEP_AUTO; } - + /** * Clears both keep-with-previous and keep-with-next strengths. */ @@ -292,7 +292,7 @@ public class LayoutContext { public boolean isKeepWithNextPending() { return getKeepWithNextPending() != BlockLevelLayoutManager.KEEP_AUTO; } - + /** * Indicates whether a keep-with-previous constraint is pending. * @return true if a keep-with-previous constraint is pending @@ -300,7 +300,7 @@ public class LayoutContext { public boolean isKeepWithPreviousPending() { return getKeepWithPreviousPending() != BlockLevelLayoutManager.KEEP_AUTO; } - + public void setLeadingSpace(SpaceSpecifier space) { leadingSpace = space; } @@ -333,7 +333,7 @@ public class LayoutContext { } this.pendingAfterMarks.add(element); } - + /** * @return the pending border and padding elements at the after edge * @see #addPendingAfterMark(UnresolvedListElementWithLength) @@ -345,7 +345,7 @@ public class LayoutContext { return null; } } - + /** * Clears all pending marks on the LayoutContext. */ @@ -353,7 +353,7 @@ public class LayoutContext { this.pendingBeforeMarks = null; this.pendingAfterMarks = null; } - + /** * Adds a border or padding element to the pending list which will be used to generate * the right element list for break possibilities. Conditionality resolution will be done @@ -366,7 +366,7 @@ public class LayoutContext { } this.pendingBeforeMarks.add(element); } - + /** * @return the pending border and padding elements at the before edge * @see #addPendingBeforeMark(UnresolvedListElementWithLength) @@ -378,7 +378,7 @@ public class LayoutContext { return null; } } - + /** * Sets the stack limit in block-progression-dimension. * @param limit the stack limit @@ -419,7 +419,7 @@ public class LayoutContext { setStackLimitBP(context.getStackLimitBP()); setStackLimitIP(context.getStackLimitIP()); } - + /** * Sets the inline-progression-dimension of the nearest ancestor reference area. */ @@ -429,7 +429,7 @@ public class LayoutContext { /** * Returns the inline-progression-dimension of the nearest ancestor reference area. - * + * * @return the inline-progression-dimension of the nearest ancestor reference area */ public int getRefIPD() { @@ -455,12 +455,12 @@ public class LayoutContext { public void setBPAlignment(int alignment) { this.bpAlignment = alignment; } - + /** @return the currently applicable alignment in BP direction (EN_START, EN_JUSTIFY...) */ public int getBPAlignment() { return this.bpAlignment; } - + public void setSpaceAdjust(double adjust) { dSpaceAdjust = adjust; } @@ -480,7 +480,7 @@ public class LayoutContext { public void setAlignmentContext(AlignmentContext alignmentContext) { this.alignmentContext = alignmentContext; } - + public AlignmentContext getAlignmentContext() { return this.alignmentContext; } @@ -490,7 +490,7 @@ public class LayoutContext { this.alignmentContext = this.alignmentContext.getParentAlignmentContext(); } } - + /** * Get the width to be reserved for border and padding at the start of the line. * @return the width to be reserved @@ -498,7 +498,7 @@ public class LayoutContext { public int getLineStartBorderAndPaddingWidth() { return lineStartBorderAndPaddingWidth; } - + /** * Set the width to be reserved for border and padding at the start of the line. * @param lineStartBorderAndPaddingWidth the width to be reserved @@ -506,7 +506,7 @@ public class LayoutContext { public void setLineStartBorderAndPaddingWidth(int lineStartBorderAndPaddingWidth) { this.lineStartBorderAndPaddingWidth = lineStartBorderAndPaddingWidth; } - + /** * Get the width to be reserved for border and padding at the end of the line. * @return the width to be reserved @@ -514,7 +514,7 @@ public class LayoutContext { public int getLineEndBorderAndPaddingWidth() { return lineEndBorderAndPaddingWidth; } - + /** * Set the width to be reserved for border and padding at the end of the line. * @param lineEndBorderAndPaddingWidth the width to be reserved @@ -522,7 +522,7 @@ public class LayoutContext { public void setLineEndBorderAndPaddingWidth(int lineEndBorderAndPaddingWidth) { this.lineEndBorderAndPaddingWidth = lineEndBorderAndPaddingWidth; } - + /** * @return true if the current element list ends early because of a span change * in multi-column layout. @@ -530,7 +530,7 @@ public class LayoutContext { public int getNextSpan() { return nextSpan; } - + /** * Used to signal the PSLM that the element list ends early because of a span change in * multi-column layout. @@ -544,8 +544,8 @@ public class LayoutContext { + span); } } - - /** + + /** * Get the writing mode of the relevant reference area. * @return the applicable writing mode */ @@ -553,7 +553,7 @@ public class LayoutContext { return writingMode; } - /** + /** * Set the writing mode. * @param writingMode the writing mode */ @@ -597,7 +597,7 @@ public class LayoutContext { * Returns the value of the break before the element whose * {@link LayoutManager#getNextKnuthElements(LayoutContext, int)} method has just been * called. - * + * * @return one of {@link Constants#EN_AUTO}, {@link Constants#EN_COLUMN}, * {@link Constants#EN_PAGE}, {@link Constants#EN_EVEN_PAGE}, or * {@link Constants#EN_ODD_PAGE} @@ -608,7 +608,7 @@ public class LayoutContext { /** * Sets the value of the break before the current element. - * + * * @param breakBefore the value of the break-before * @see #getBreakBefore() */ @@ -620,7 +620,7 @@ public class LayoutContext { * Returns the value of the break after the element whose * {@link LayoutManager#getNextKnuthElements(LayoutContext, int)} method has just been * called. - * + * * @return one of {@link Constants#EN_AUTO}, {@link Constants#EN_COLUMN}, * {@link Constants#EN_PAGE}, {@link Constants#EN_EVEN_PAGE}, or * {@link Constants#EN_ODD_PAGE} @@ -632,7 +632,7 @@ public class LayoutContext { /** * Sets the value of the break after the current element. - * + * * @param breakAfter the value of the break-after * @see #getBreakAfter() */ @@ -650,7 +650,7 @@ public class LayoutContext { + "\nTrailing Space: \t" + (getTrailingSpace() == null ? "null" : getTrailingSpace().toString()) + "\nLeading Space: \t" - + (getLeadingSpace() == null ? "null" : getLeadingSpace().toString()) + + (getLeadingSpace() == null ? "null" : getLeadingSpace().toString()) + "\nReference IPD: \t" + getRefIPD() + "\nSpace Adjust: \t" + getSpaceAdjust() + "\nIPD Adjust: \t" + getIPDAdjust() @@ -663,7 +663,7 @@ public class LayoutContext { + "\nKeeps: \t[keep-with-next=" + KeepUtil.keepStrengthToString(getKeepWithNextPending()) + "][keep-with-previous=" + KeepUtil.keepStrengthToString(getKeepWithPreviousPending()) + "] pending" - + "\nBreaks: \tforced [" + (breakBefore != Constants.EN_AUTO ? "break-before" : "") + "][" + + "\nBreaks: \tforced [" + (breakBefore != Constants.EN_AUTO ? "break-before" : "") + "][" + (breakAfter != Constants.EN_AUTO ? "break-after" : "") + "]"; } diff --git a/src/java/org/apache/fop/layoutmgr/LayoutException.java b/src/java/org/apache/fop/layoutmgr/LayoutException.java index 350cc758a..822607020 100644 --- a/src/java/org/apache/fop/layoutmgr/LayoutException.java +++ b/src/java/org/apache/fop/layoutmgr/LayoutException.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,13 +28,13 @@ 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; @@ -80,7 +80,7 @@ public class LayoutException extends RuntimeException { public LayoutManager getLayoutManager() { return this.layoutManager; } - + /** Exception factory for {@link LayoutException}. */ public static class LayoutExceptionFactory implements ExceptionFactory { @@ -95,11 +95,11 @@ public class LayoutException extends RuntimeException { } return ex; } - + /** {@inheritDoc} */ public Class getExceptionClass() { return LayoutException.class; } - - } + + } } diff --git a/src/java/org/apache/fop/layoutmgr/LayoutManager.java b/src/java/org/apache/fop/layoutmgr/LayoutManager.java index ad0d9f69c..f19588a77 100644 --- a/src/java/org/apache/fop/layoutmgr/LayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/LayoutManager.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.layoutmgr; import java.util.List; @@ -45,11 +45,11 @@ public interface LayoutManager extends PercentBaseContext { LayoutManager getParent(); /** - * initialize the layout manager. Allows each layout manager + * initialize the layout manager. Allows each layout manager * to calculate often used values. */ void initialize(); - + /** * Get the active PageSequenceLayoutManager instance for this * layout process. @@ -130,9 +130,9 @@ public interface LayoutManager extends PercentBaseContext { void addChildLMs(List newLMs); /** - * Get a sequence of KnuthElements representing the content + * Get a sequence of KnuthElements representing the content * of the node assigned to the LM - * + * * @param context the LayoutContext used to store layout information * @param alignment the desired text alignment * @return the list of KnuthElements @@ -140,54 +140,54 @@ public interface LayoutManager extends PercentBaseContext { List getNextKnuthElements(LayoutContext context, int alignment); /** - * Get a sequence of KnuthElements representing the content + * Get a sequence of KnuthElements representing the content * of the node assigned to the LM, after changes have been applied * * In the context of line breaking, this method is called after hyphenation has - * been performed, in order to receive the sequence of elements representing the + * been performed, in order to receive the sequence of elements representing the * text together with all possible hyphenation points. * For example, if the text "representation" originates a single box element * when getNextKnuthElements() is called, it will be now split in syllables * (rep-re-sen-ta-tion) each one originating a box and divided by additional * elements allowing a line break. - * + * * In the context of page breaking, this method is called only if the pages need * to be "vertically justified" modifying (also) the quantity of lines created by * the paragraphs, and after a first page breaking has been performed. * According to the result of the first page breaking, each paragraph now knows - * how many lines it must create (among the existing layout possibilities) and + * how many lines it must create (among the existing layout possibilities) and * has to create a sequence of elements representing this layout; in particular, * each box, representing a line, will contain a LineBreakPositions that will be * used in the addAreas() phase. - * + * * LMs having children look at the old list of elements in order to know which * ones they must get the new elements from, as break conditions of preserved - * linefeeds can divide children into smaller groups (page sequences or + * linefeeds can divide children into smaller groups (page sequences or * paragraphs). * LMs having no children can simply return the old elements if they have nothing * to change. * * Inline LMs need to know the text alignment because it affects the elements * representing feasible breaks between syllables. - * + * * @param oldList the elements to replace * @param alignment the desired text alignment * @return the updated list of KnuthElements */ List getChangedKnuthElements(List oldList, int alignment); - + /** * Returns the IPD of the content area * @return the IPD of the content area */ int getContentAreaIPD(); - + /** * Returns the BPD of the content area * @return the BPD of the content area */ int getContentAreaBPD(); - + /** * Returns an indication if the layout manager generates a reference area. * @return True if the layout manager generates a reference area @@ -205,13 +205,13 @@ public interface LayoutManager extends PercentBaseContext { * @return True if the layout manager generates a line area */ boolean getGeneratesLineArea(); - + /** * Returns the fo this layout manager is associated with. * @return The fo for this layout manager or null. */ FObj getFObj(); - + /** * Adds a Position to the Position participating in the first|last determination by assigning * it a unique position index. diff --git a/src/java/org/apache/fop/layoutmgr/LayoutManagerMaker.java b/src/java/org/apache/fop/layoutmgr/LayoutManagerMaker.java index abb7f0f04..8efe5ce65 100644 --- a/src/java/org/apache/fop/layoutmgr/LayoutManagerMaker.java +++ b/src/java/org/apache/fop/layoutmgr/LayoutManagerMaker.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 @@ import org.apache.fop.area.Block; * The interface for all LayoutManager makers */ public interface LayoutManagerMaker { - + /** * Make LayoutManagers for the node and add them to the list lms. * @param node the FO node for which the LayoutManagers are made diff --git a/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java b/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java index 862c0a4be..26933ee4c 100644 --- a/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java +++ b/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.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,7 +145,7 @@ public class LayoutManagerMapping implements LayoutManagerMaker { } /** - * {@inheritDoc} + * {@inheritDoc} */ public void makeLayoutManagers(FONode node, List lms) { Maker maker = (Maker) makers.get(node.getClass()); @@ -175,7 +175,7 @@ public class LayoutManagerMapping implements LayoutManagerMaker { } else if (lms.size() > 1) { throw new IllegalStateException("Duplicate LayoutManagers for class " + node.getClass() - + " found, only one may be declared."); + + " found, only one may be declared."); } return (LayoutManager) lms.get(0); } @@ -186,7 +186,7 @@ public class LayoutManagerMapping implements LayoutManagerMaker { } /* - * {@inheritDoc} + * {@inheritDoc} */ public FlowLayoutManager makeFlowLayoutManager( PageSequenceLayoutManager pslm, Flow flow) { @@ -194,21 +194,21 @@ public class LayoutManagerMapping implements LayoutManagerMaker { } /* - * {@inheritDoc} + * {@inheritDoc} */ public ContentLayoutManager makeContentLayoutManager(PageSequenceLayoutManager pslm, Title title) { return new ContentLayoutManager(pslm, title); } - + /* - * {@inheritDoc} + * {@inheritDoc} */ public StaticContentLayoutManager makeStaticContentLayoutManager( PageSequenceLayoutManager pslm, StaticContent sc, SideRegion reg) { return new StaticContentLayoutManager(pslm, sc, reg); } - + /** {@inheritDoc} */ public StaticContentLayoutManager makeStaticContentLayoutManager( PageSequenceLayoutManager pslm, StaticContent sc, org.apache.fop.area.Block block) { @@ -321,7 +321,7 @@ public class LayoutManagerMapping implements LayoutManagerMaker { public static class ListItemLayoutManagerMaker extends Maker { public void make(FONode node, List lms) { lms.add(new ListItemLayoutManager((ListItem) node)); - } + } } public static class ListBlockLayoutManagerMaker extends Maker { @@ -353,7 +353,7 @@ public class LayoutManagerMapping implements LayoutManagerMaker { lms.add(new PageNumberCitationLastLayoutManager((PageNumberCitationLast) node)); } } - + public static class TableLayoutManagerMaker extends Maker { public void make(FONode node, List lms) { Table table = (Table) node; @@ -361,7 +361,7 @@ public class LayoutManagerMapping implements LayoutManagerMaker { lms.add(tlm); } } - + public class RetrieveMarkerLayoutManagerMaker extends Maker { public void make(FONode node, List lms) { Iterator baseIter; @@ -373,7 +373,7 @@ public class LayoutManagerMapping implements LayoutManagerMaker { FONode child = (FONode) baseIter.next(); makeLayoutManagers(child, lms); } - } + } } public class WrapperLayoutManagerMaker extends Maker { @@ -390,7 +390,7 @@ public class LayoutManagerMapping implements LayoutManagerMaker { FONode child = (FONode) baseIter.next(); makeLayoutManagers(child, lms); } - } + } } public ExternalDocumentLayoutManager makeExternalDocumentLayoutManager( diff --git a/src/java/org/apache/fop/layoutmgr/LeafPosition.java b/src/java/org/apache/fop/layoutmgr/LeafPosition.java index c43bb05c0..ed8cc94e2 100644 --- a/src/java/org/apache/fop/layoutmgr/LeafPosition.java +++ b/src/java/org/apache/fop/layoutmgr/LeafPosition.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.layoutmgr; public class LeafPosition extends Position { @@ -31,11 +31,11 @@ public class LeafPosition extends Position { public int getLeafPos() { return iLeafPos; } - + public boolean generatesAreas() { return getLM() != null; } - + /** {@inheritDoc} */ public String toString() { StringBuffer sb = new StringBuffer(); diff --git a/src/java/org/apache/fop/layoutmgr/ListElement.java b/src/java/org/apache/fop/layoutmgr/ListElement.java index de08a1e1e..74d8a666b 100644 --- a/src/java/org/apache/fop/layoutmgr/ListElement.java +++ b/src/java/org/apache/fop/layoutmgr/ListElement.java @@ -23,12 +23,12 @@ package org.apache.fop.layoutmgr; * This class is the base class for all kinds of elements that are added to element lists. There * are basically two kinds of list elements: Knuth elements and unresolved elements like spaces, * border and padding elements which are converted to Knuth elements prior to the breaking - * process. + * process. */ public abstract class ListElement { private Position position; - + /** * Main constructor * @param position the Position instance needed by the addAreas stage of the LMs. @@ -36,14 +36,14 @@ public abstract class ListElement { public ListElement(Position position) { this.position = position; } - + /** * @return the Position instance for this element. */ public Position getPosition() { return this.position; } - + /** * Change the Position stored in this element. * @param position the Position instance @@ -78,14 +78,14 @@ public abstract class ListElement { return false; } - /** @return true if the element is a penalty and represents a forced break. */ + /** @return true if the element is a penalty and represents a forced break. */ public boolean isForcedBreak() { return false; } - /** @return true if the element is an unresolved element such as a space or a border. */ + /** @return true if the element is an unresolved element such as a space or a border. */ public boolean isUnresolvedElement() { return true; } - + } diff --git a/src/java/org/apache/fop/layoutmgr/MinOptMaxUtil.java b/src/java/org/apache/fop/layoutmgr/MinOptMaxUtil.java index b58af1cfe..155abcd39 100644 --- a/src/java/org/apache/fop/layoutmgr/MinOptMaxUtil.java +++ b/src/java/org/apache/fop/layoutmgr/MinOptMaxUtil.java @@ -35,7 +35,7 @@ public class MinOptMaxUtil { * @param lr restricting source * @param context Percentage evaluation context */ - public static void restrict(MinOptMax mom, LengthRangeProperty lr, + public static void restrict(MinOptMax mom, LengthRangeProperty lr, PercentBaseContext context) { if (lr.getEnum() != Constants.EN_AUTO) { if (lr.getMinimum(context).getEnum() != Constants.EN_AUTO) { @@ -70,7 +70,7 @@ public class MinOptMaxUtil { /** * Extends the minimum length to the given length if necessary, and adjusts opt and * max accordingly. - * + * * @param mom the min/opt/max trait * @param len the new minimum length */ @@ -81,7 +81,7 @@ public class MinOptMaxUtil { mom.max = Math.max(mom.opt, mom.max); } } - + /** * After a calculation on a MinOptMax, this can be called to set opt to * a new effective value. @@ -95,7 +95,7 @@ public class MinOptMaxUtil { } } } - + /** * Converts a LengthRangeProperty to a MinOptMax. * @param prop LengthRangeProperty @@ -104,14 +104,14 @@ public class MinOptMaxUtil { */ public static MinOptMax toMinOptMax(LengthRangeProperty prop, PercentBaseContext context) { MinOptMax mom = new MinOptMax( - (prop.getMinimum(context).isAuto() + (prop.getMinimum(context).isAuto() ? 0 : prop.getMinimum(context).getLength().getValue(context)), - (prop.getOptimum(context).isAuto() + (prop.getOptimum(context).isAuto() ? 0 : prop.getOptimum(context).getLength().getValue(context)), - (prop.getMaximum(context).isAuto() - ? Integer.MAX_VALUE + (prop.getMaximum(context).isAuto() + ? Integer.MAX_VALUE : prop.getMaximum(context).getLength().getValue(context))); return mom; } - + } diff --git a/src/java/org/apache/fop/layoutmgr/NonLeafPosition.java b/src/java/org/apache/fop/layoutmgr/NonLeafPosition.java index 9edb425c1..7089dabda 100644 --- a/src/java/org/apache/fop/layoutmgr/NonLeafPosition.java +++ b/src/java/org/apache/fop/layoutmgr/NonLeafPosition.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.layoutmgr; public class NonLeafPosition extends Position { @@ -31,11 +31,11 @@ public class NonLeafPosition extends Position { public Position getPosition() { return subPos; } - + public boolean generatesAreas() { return (subPos != null ? subPos.generatesAreas() : false); } - + /** {@inheritDoc} */ public String toString() { StringBuffer sb = new StringBuffer(); diff --git a/src/java/org/apache/fop/layoutmgr/PaddingElement.java b/src/java/org/apache/fop/layoutmgr/PaddingElement.java index ee0edcc38..3ec0c5054 100644 --- a/src/java/org/apache/fop/layoutmgr/PaddingElement.java +++ b/src/java/org/apache/fop/layoutmgr/PaddingElement.java @@ -42,10 +42,10 @@ public class PaddingElement extends BorderOrPaddingElement { boolean isFirst, boolean isLast, PercentBaseContext context) { super(position, condLength, side, isFirst, isLast, context); } - + /** {@inheritDoc} */ public void notifyLayoutManager(MinOptMax effectiveLength) { - LayoutManager lm = getOriginatingLayoutManager(); + LayoutManager lm = getOriginatingLayoutManager(); if (lm instanceof ConditionalElementListener) { ((ConditionalElementListener)lm).notifyPadding( getSide(), effectiveLength); @@ -62,5 +62,5 @@ public class PaddingElement extends BorderOrPaddingElement { sb.append("]"); return sb.toString(); } - + } diff --git a/src/java/org/apache/fop/layoutmgr/Page.java b/src/java/org/apache/fop/layoutmgr/Page.java index 6d6dbb233..7e22cef67 100644 --- a/src/java/org/apache/fop/layoutmgr/Page.java +++ b/src/java/org/apache/fop/layoutmgr/Page.java @@ -34,39 +34,39 @@ public class Page { private SimplePageMaster spm; private PageViewport pageViewport; - + /** * Main constructor * @param spm the simple-page-master used for this page * @param pageNumber the page number (as an int) - * @param pageNumberStr the page number (as a String) + * @param pageNumberStr the page number (as a String) * @param blank true if this is a blank page */ public Page(SimplePageMaster spm, int pageNumber, String pageNumberStr, boolean blank) { this.spm = spm; this.pageViewport = new PageViewport(spm, pageNumber, pageNumberStr, blank); } - + /** * Auxiliary constructor used when there's no SimplePageMaster. * @param viewArea the view area of the page * @param pageNumber the page number (as an int) - * @param pageNumberStr the page number (as a String) + * @param pageNumberStr the page number (as a String) * @param blank true if this is a blank page */ public Page(Rectangle2D viewArea, int pageNumber, String pageNumberStr, boolean blank) { this.spm = null; this.pageViewport = new PageViewport(viewArea, pageNumber, pageNumberStr, null, blank); } - + /** @return the simple-page-master that created this page */ public SimplePageMaster getSimplePageMaster() { return this.spm; } - + /** @return the page viewport representing this page in the area tree */ public PageViewport getPageViewport() { return this.pageViewport; } - + } diff --git a/src/java/org/apache/fop/layoutmgr/PageBreaker.java b/src/java/org/apache/fop/layoutmgr/PageBreaker.java index b25e4bd4f..9ff520804 100644 --- a/src/java/org/apache/fop/layoutmgr/PageBreaker.java +++ b/src/java/org/apache/fop/layoutmgr/PageBreaker.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,14 +39,14 @@ import org.apache.fop.traits.MinOptMax; * Handles the breaking of pages in an fo:flow */ public class PageBreaker extends AbstractBreaker { - + private PageSequenceLayoutManager pslm; private boolean firstPart = true; private boolean pageBreakHandled; private boolean needColumnBalancing; private PageProvider pageProvider; private Block separatorArea; - + /** * The FlowLayoutManager object, which processes * the single fo:flow of the fo:page-sequence @@ -61,23 +61,23 @@ public class PageBreaker extends AbstractBreaker { this.childFLM = pslm.getLayoutManagerMaker().makeFlowLayoutManager( pslm, pslm.getPageSequence().getMainFlow()); } - + /** {@inheritDoc} */ protected void updateLayoutContext(LayoutContext context) { int flowIPD = pslm.getCurrentPV().getCurrentSpan().getColumnWidth(); context.setRefIPD(flowIPD); } - + /** {@inheritDoc} */ protected LayoutManager getTopLevelLM() { return pslm; } - + /** {@inheritDoc} */ protected PageProvider getPageProvider() { return pslm.getPageProvider(); } - + /** {@inheritDoc} */ protected PageBreakingLayoutListener createLayoutListener() { return new PageBreakingLayoutListener() { @@ -98,7 +98,7 @@ public class PageBreaker extends AbstractBreaker { amount, needClip, canRecover, body.getLocator()); } - + }; } @@ -118,7 +118,7 @@ public class PageBreaker extends AbstractBreaker { } /** {@inheritDoc} */ - protected int getNextBlockList(LayoutContext childLC, + protected int getNextBlockList(LayoutContext childLC, int nextSequenceStartsOn) { if (!firstPart) { // if this is the first page that will be created by @@ -129,15 +129,15 @@ public class PageBreaker extends AbstractBreaker { } firstPart = false; pageBreakHandled = true; - pageProvider.setStartOfNextElementList(pslm.getCurrentPageNum(), + pageProvider.setStartOfNextElementList(pslm.getCurrentPageNum(), pslm.getCurrentPV().getCurrentSpan().getCurrentFlowIndex()); return super.getNextBlockList(childLC, nextSequenceStartsOn); } - + /** {@inheritDoc} */ protected List getNextKnuthElements(LayoutContext context, int alignment) { List contentList = null; - + while (!childFLM.isFinished() && contentList == null) { contentList = childFLM.getNextKnuthElements(context, alignment); } @@ -161,7 +161,7 @@ public class PageBreaker extends AbstractBreaker { // store the lists of elements representing the footnote bodies // in the box representing the line containing their references while (footnoteBodyIterator.hasNext()) { - FootnoteBodyLayoutManager fblm + FootnoteBodyLayoutManager fblm = (FootnoteBodyLayoutManager) footnoteBodyIterator.next(); fblm.setParent(childFLM); fblm.initialize(); @@ -178,7 +178,7 @@ public class PageBreaker extends AbstractBreaker { footnoteSeparator = pslm.getPageSequence().getStaticContent("xsl-footnote-separator"); if (footnoteSeparator != null) { // the footnote separator can contain page-dependent content such as - // page numbers or retrieve markers, so its areas cannot simply be + // page numbers or retrieve markers, so its areas cannot simply be // obtained now and repeated in each page; // we need to know in advance the separator bpd: the actual separator // could be different from page to page, but its bpd would likely be @@ -199,7 +199,7 @@ public class PageBreaker extends AbstractBreaker { } return contentList; } - + /** * @return current display alignment */ @@ -207,14 +207,14 @@ public class PageBreaker extends AbstractBreaker { return pslm.getCurrentPage().getSimplePageMaster().getRegion( Constants.FO_REGION_BODY).getDisplayAlign(); } - + /** * @return whether or not this flow has more page break opportunities */ protected boolean hasMoreContent() { return !childFLM.isFinished(); } - + /** * Adds an area to the flow layout manager * @param posIter the position iterator @@ -235,18 +235,18 @@ public class PageBreaker extends AbstractBreaker { footnoteSeparatorLM.doLayout(); } - childFLM.addAreas(posIter, context); + childFLM.addAreas(posIter, context); } - + /** * Performs phase 3 operation - * + * * @param alg page breaking algorithm * @param partCount part count * @param originalList the block sequence original list * @param effectiveList the block sequence effective list */ - protected void doPhase3(PageBreakingAlgorithm alg, int partCount, + protected void doPhase3(PageBreakingAlgorithm alg, int partCount, BlockSequence originalList, BlockSequence effectiveList) { if (needColumnBalancing) { doPhase3WithColumnBalancing(alg, partCount, originalList, effectiveList); @@ -261,7 +261,7 @@ public class PageBreaker extends AbstractBreaker { } } - private void doPhase3WithLastPage(PageBreakingAlgorithm alg, int partCount, + private void doPhase3WithLastPage(PageBreakingAlgorithm alg, int partCount, BlockSequence originalList, BlockSequence effectiveList) { int newStartPos; int restartPoint = pageProvider.getStartingPartIndexForLastPage(partCount); @@ -281,13 +281,13 @@ public class PageBreaker extends AbstractBreaker { } AbstractBreaker.log.debug("Last page handling now!!!"); AbstractBreaker.log.debug("==================================================="); - AbstractBreaker.log.debug("Restarting at " + restartPoint + AbstractBreaker.log.debug("Restarting at " + restartPoint + ", new start position: " + newStartPos); pageBreakHandled = true; //Update so the available BPD is reported correctly int currentPageNum = pslm.getCurrentPageNum(); - pageProvider.setStartOfNextElementList(currentPageNum, + pageProvider.setStartOfNextElementList(currentPageNum, pslm.getCurrentPV().getCurrentSpan().getCurrentFlowIndex()); pageProvider.setLastPageIndex(currentPageNum); @@ -295,7 +295,7 @@ public class PageBreaker extends AbstractBreaker { PageBreakingAlgorithm algRestart = new PageBreakingAlgorithm( getTopLevelLM(), getPageProvider(), createLayoutListener(), - alg.getAlignment(), alg.getAlignmentLast(), + alg.getAlignment(), alg.getAlignmentLast(), footnoteSeparatorLength, isPartOverflowRecoveryActivated(), false, false); //alg.setConstantLineWidth(flowBPD); @@ -304,8 +304,8 @@ public class PageBreaker extends AbstractBreaker { 1, true, BreakingAlgorithm.ALL_BREAKS); AbstractBreaker.log.debug("restart: iOptPageCount= " + iOptPageCount + " pageBreaks.size()= " + algRestart.getPageBreaks().size()); - boolean replaceLastPage - = iOptPageCount <= pslm.getCurrentPV().getBodyRegion().getColumnCount(); + boolean replaceLastPage + = iOptPageCount <= pslm.getCurrentPV().getBodyRegion().getColumnCount(); if (replaceLastPage) { //Replace last page pslm.setCurrentPage(pageProvider.getPage(false, currentPageNum)); @@ -322,7 +322,7 @@ public class PageBreaker extends AbstractBreaker { AbstractBreaker.log.debug("==================================================="); } - private void doPhase3WithColumnBalancing(PageBreakingAlgorithm alg, int partCount, + private void doPhase3WithColumnBalancing(PageBreakingAlgorithm alg, int partCount, BlockSequence originalList, BlockSequence effectiveList) { AbstractBreaker.log.debug("Column balancing now!!!"); AbstractBreaker.log.debug("==================================================="); @@ -342,12 +342,12 @@ public class PageBreaker extends AbstractBreaker { } else { newStartPos = 0; } - AbstractBreaker.log.debug("Restarting at " + restartPoint + AbstractBreaker.log.debug("Restarting at " + restartPoint + ", new start position: " + newStartPos); pageBreakHandled = true; //Update so the available BPD is reported correctly - pageProvider.setStartOfNextElementList(pslm.getCurrentPageNum(), + pageProvider.setStartOfNextElementList(pslm.getCurrentPageNum(), pslm.getCurrentPV().getCurrentSpan().getCurrentFlowIndex()); //Restart last page @@ -376,15 +376,15 @@ public class PageBreaker extends AbstractBreaker { addAreas(algRestart, iOptPageCount, originalList, effectiveList); AbstractBreaker.log.debug("==================================================="); } - + protected void startPart(BlockSequence list, int breakClass) { AbstractBreaker.log.debug("startPart() breakClass=" + breakClass); if (pslm.getCurrentPage() == null) { throw new IllegalStateException("curPage must not be null"); } if (!pageBreakHandled) { - - //firstPart is necessary because we need the first page before we start the + + //firstPart is necessary because we need the first page before we start the //algorithm so we have a BPD and IPD. This may subject to change later when we //start handling more complex cases. if (!firstPart) { @@ -394,7 +394,7 @@ public class PageBreaker extends AbstractBreaker { // otherwise, we may simply need a new page handleBreakTrait(breakClass); } - pageProvider.setStartOfNextElementList(pslm.getCurrentPageNum(), + pageProvider.setStartOfNextElementList(pslm.getCurrentPageNum(), pslm.getCurrentPV().getCurrentSpan().getCurrentFlowIndex()); } pageBreakHandled = false; @@ -402,12 +402,12 @@ public class PageBreaker extends AbstractBreaker { // finish page and add to area tree firstPart = false; } - + /** {@inheritDoc} */ protected void handleEmptyContent() { pslm.getCurrentPV().getPage().fakeNonEmpty(); } - + protected void finishPart(PageBreakingAlgorithm alg, PageBreakPosition pbp) { // add footnote areas if (pbp.footnoteFirstListIndex < pbp.footnoteLastListIndex @@ -415,16 +415,16 @@ public class PageBreaker extends AbstractBreaker { // call addAreas() for each FootnoteBodyLM for (int i = pbp.footnoteFirstListIndex; i <= pbp.footnoteLastListIndex; i++) { LinkedList elementList = alg.getFootnoteList(i); - int firstIndex = (i == pbp.footnoteFirstListIndex + int firstIndex = (i == pbp.footnoteFirstListIndex ? pbp.footnoteFirstElementIndex : 0); - int lastIndex = (i == pbp.footnoteLastListIndex + int lastIndex = (i == pbp.footnoteLastListIndex ? pbp.footnoteLastElementIndex : elementList.size() - 1); - SpaceResolver.performConditionalsNotification(elementList, + SpaceResolver.performConditionalsNotification(elementList, firstIndex, lastIndex, -1); LayoutContext childLC = new LayoutContext(0); - AreaAdditionUtil.addAreas(null, - new KnuthPossPosIter(elementList, firstIndex, lastIndex + 1), + AreaAdditionUtil.addAreas(null, + new KnuthPossPosIter(elementList, firstIndex, lastIndex + 1), childLC); } // set the offset from the top margin @@ -438,20 +438,20 @@ public class PageBreaker extends AbstractBreaker { } pslm.getCurrentPV().getCurrentSpan().notifyFlowsFinished(); } - + /** * @return the current child flow layout manager */ protected LayoutManager getCurrentChildLM() { return childFLM; } - + /** {@inheritDoc} */ protected void observeElementList(List elementList) { - ElementListObserver.observe(elementList, "breaker", + ElementListObserver.observe(elementList, "breaker", ((PageSequence)pslm.getFObj()).getId()); } - + /** * Depending on the kind of break condition, move to next column * or page. May need to make an empty page if next page would @@ -471,17 +471,17 @@ public class PageBreaker extends AbstractBreaker { || breakVal <= 0 || breakVal == Constants.EN_AUTO) { PageViewport pv = curPage.getPageViewport(); - + //Check if previous page was spanned boolean forceNewPageWithSpan = false; RegionBody rb = (RegionBody)curPage.getSimplePageMaster().getRegion( Constants.FO_REGION_BODY); - if (breakVal < 0 - && rb.getColumnCount() > 1 + if (breakVal < 0 + && rb.getColumnCount() > 1 && pv.getCurrentSpan().getColumnCount() == 1) { forceNewPageWithSpan = true; } - + if (forceNewPageWithSpan) { curPage = pslm.makeNewPage(false, false); curPage.getPageViewport().createSpan(true); @@ -492,7 +492,7 @@ public class PageBreaker extends AbstractBreaker { } return; } - log.debug("handling break-before after page " + pslm.getCurrentPageNum() + log.debug("handling break-before after page " + pslm.getCurrentPageNum() + " breakVal=" + breakVal); if (needBlankPageBeforeNew(breakVal)) { curPage = pslm.makeNewPage(true, false); @@ -501,7 +501,7 @@ public class PageBreaker extends AbstractBreaker { curPage = pslm.makeNewPage(false, false); } } - + /** * Check if a blank page is needed to accomodate * desired even or odd page number. @@ -520,7 +520,7 @@ public class PageBreaker extends AbstractBreaker { } } } - + /** * See if need to generate a new page * @param breakVal - value of break-before or break-after trait. diff --git a/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java b/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java index 9e0b42ecb..8095feba1 100644 --- a/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java +++ b/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java @@ -73,13 +73,13 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { /** Index of the last element of the last footnote inserted on the current page. */ private int footnoteElementIndex = -1; - // demerits for a page break that splits a footnote + // demerits for a page break that splits a footnote private int splitFootnoteDemerits = 5000; - // demerits for a page break that defers a whole footnote to the following page + // demerits for a page break that defers a whole footnote to the following page private int deferredFootnoteDemerits = 10000; private MinOptMax footnoteSeparatorLength = null; - // the method noBreakBetween(int, int) uses these variables + // the method noBreakBetween(int, int) uses these variables // to store parameters and result of the last call, in order // to reuse them and take less time private int storedPrevBreakIndex = -1; @@ -88,10 +88,10 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { //Controls whether overflows should be warned about or not private boolean autoHeight = false; - + //Controls whether a single part should be forced if possible (ex. block-container) private boolean favorSinglePart = false; - + public PageBreakingAlgorithm(LayoutManager topLevelLM, PageProvider pageProvider, PageBreakingLayoutListener layoutListener, @@ -202,7 +202,7 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { totalWidth, totalStretch, totalShrink, ((BestPageRecords) best).getFootnotesLength(fitness), ((BestPageRecords) best).getFootnoteListIndex(fitness), - ((BestPageRecords) best).getFootnoteElementIndex(fitness), + ((BestPageRecords) best).getFootnoteElementIndex(fitness), best.getAdjust(fitness), best.getAvailableShrink(fitness), best.getAvailableStretch(fitness), best.getDifference(fitness), best.getDemerits(fitness), best.getNode(fitness)); @@ -247,11 +247,11 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { ListIterator elementListsIterator = elementLists.listIterator(); while (elementListsIterator.hasNext()) { LinkedList noteList = (LinkedList) elementListsIterator.next(); - - //Space resolution (Note: this does not respect possible stacking constraints + + //Space resolution (Note: this does not respect possible stacking constraints //between footnotes!) SpaceResolver.resolveElementList(noteList); - + int noteLength = 0; footnotesList.add(noteList); ListIterator noteListIterator = noteList.listIterator(); @@ -261,8 +261,8 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { noteLength += element.getW(); } } - int prevLength = (lengthList.size() == 0 - ? 0 + int prevLength = (lengthList.size() == 0 + ? 0 : ((Integer) lengthList.get(lengthList.size() - 1)).intValue()); lengthList.add(new Integer(prevLength + noteLength)); totalFootnotesLength += noteLength; @@ -423,7 +423,7 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { index < breakIndex; index++) { if (par.getElement(index).isGlue() && par.getElement(index - 1).isBox() - || par.getElement(index).isPenalty() + || par.getElement(index).isPenalty() && ((KnuthElement) par.getElement(index)).getP() < KnuthElement.INFINITE) { // break found break; @@ -520,7 +520,7 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { } // as this method is called only if it is not possible to insert // all footnotes, at this point listIndex and elementIndex points to - // an existing element, the next one we will try to insert + // an existing element, the next one we will try to insert } // try adding a split of the next note @@ -582,7 +582,7 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { // prevIndex is -1 if we have added only some whole footnotes footnoteListIndex = (prevIndex != -1) ? listIndex : listIndex - 1; footnoteElementIndex = (prevIndex != -1) - ? prevIndex + ? prevIndex : ((LinkedList) footnotesList.get(footnoteListIndex)).size() - 1; } return prevSplitLength; @@ -618,7 +618,7 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { } } - protected double computeDemerits(KnuthNode activeNode, KnuthElement element, + protected double computeDemerits(KnuthNode activeNode, KnuthElement element, int fitnessClass, double r) { double demerits = 0; // compute demerits @@ -649,11 +649,11 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { if (footnotesPending) { if (footnoteListIndex < footnotesList.size() - 1) { // add demerits for the deferred footnotes - demerits += (footnotesList.size() - 1 - footnoteListIndex) + demerits += (footnotesList.size() - 1 - footnoteListIndex) * deferredFootnoteDemerits; } if (footnoteListIndex < footnotesList.size()) { - if (footnoteElementIndex + if (footnoteElementIndex < ((LinkedList) footnotesList.get(footnoteListIndex)).size() - 1) { // add demerits for the footnote split between pages demerits += splitFootnoteDemerits; @@ -710,7 +710,7 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { // cannot add any content: create a new node and start again KnuthPageNode node = (KnuthPageNode) createNode(lastNode.position, prevNode.line + 1, 1, - insertedFootnotesLength - prevNode.totalFootnotes, + insertedFootnotesLength - prevNode.totalFootnotes, 0, 0, 0, 0, 0, 0, 0, prevNode); @@ -744,7 +744,7 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { } pageBreaks.addFirst(pageBreak); } - + /** * Removes all page breaks from the result list. This is used by block-containers and * static-content when it is only desired to know where there is an overflow but later the @@ -758,14 +758,14 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { pageBreaks.removeFirst(); } } - + public void updateData1(int total, double demerits) { } public void updateData2(KnuthNode bestActiveNode, KnuthSequence sequence, int total) { - //int difference = (bestActiveNode.line < total) + //int difference = (bestActiveNode.line < total) // ? bestActiveNode.difference : bestActiveNode.difference + fillerMinWidth; int difference = bestActiveNode.difference; if (difference + bestActiveNode.availableShrink < 0) { @@ -818,10 +818,10 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { // add nodes at the beginning of the list, as they are found // backwards, from the last one to the first one if (log.isDebugEnabled()) { - log.debug("BBA> difference=" + difference + " ratio=" + ratio + log.debug("BBA> difference=" + difference + " ratio=" + ratio + " position=" + bestActiveNode.position); } - insertPageBreakAsFirst(new PageBreakPosition(this.topLevelLM, + insertPageBreakAsFirst(new PageBreakPosition(this.topLevelLM, bestActiveNode.position, firstListIndex, firstElementIndex, ((KnuthPageNode) bestActiveNode).footnoteListIndex, @@ -834,8 +834,8 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { KnuthNode bestActiveNode = null; for (int i = startLine; i < endLine; i++) { for (KnuthNode node = getNode(i); node != null; node = node.next) { - if (favorSinglePart - && node.line > 1 + if (favorSinglePart + && node.line > 1 && bestActiveNode != null && Math.abs(bestActiveNode.difference) < bestActiveNode.availableShrink) { //favor current best node, so just skip the current node because it would @@ -854,12 +854,12 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { public LinkedList getFootnoteList(int index) { return (LinkedList) footnotesList.get(index); } - + /** @return the associated top-level formatting object. */ public FObj getFObj() { return topLevelLM.getFObj(); } - + /** {@inheritDoc} */ protected int getLineWidth(int line) { int bpd; @@ -873,7 +873,7 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { } return bpd; } - + /** * Interface to notify about layout events during page breaking. */ @@ -886,7 +886,7 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { * @param obj the root FO object where this happens */ 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 a7918db6e..55c78ba52 100644 --- a/src/java/org/apache/fop/layoutmgr/PageProvider.java +++ b/src/java/org/apache/fop/layoutmgr/PageProvider.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,38 +35,38 @@ import org.apache.fop.fo.pagination.SimplePageMaster; *

      *

      Additional functionality makes sure that surplus instances that are requested by the * page breaker are properly discarded, especially in situations where hard breaks cause - * blank pages. The reason for that: The page breaker sometimes needs to preallocate + * blank pages. The reason for that: The page breaker sometimes needs to preallocate * additional pages since it doesn't know exactly until the end how many pages it really needs. *

      */ public class PageProvider implements Constants { - + private Log log = LogFactory.getLog(PageProvider.class); /** Indices are evaluated relative to the first page in the page-sequence. */ public static final int RELTO_PAGE_SEQUENCE = 0; /** Indices are evaluated relative to the first page in the current element list. */ public static final int RELTO_CURRENT_ELEMENT_LIST = 1; - + private int startPageOfPageSequence; private int startPageOfCurrentElementList; private int startColumnOfCurrentElementList; private List cachedPages = new java.util.ArrayList(); - + private int lastPageIndex = -1; private int indexOfCachedLastPage = -1; - + //Cache to optimize getAvailableBPD() calls private int lastRequestedIndex = -1; private int lastReportedBPD = -1; - /** + /** * AreaTreeHandler which activates the PSLM and controls * the rendering of its pages. */ private AreaTreeHandler areaTreeHandler; - /** + /** * fo:page-sequence formatting object being * processed by this class */ @@ -82,12 +82,12 @@ public class PageProvider implements Constants { this.pageSeq = ps; this.startPageOfPageSequence = ps.getStartingPageNumber(); } - + /** * The page breaker notifies the provider about the page number an element list starts * on so it can later retrieve PageViewports relative to this first page. * @param startPage the number of the first page for the element list. - * @param startColumn the starting column number for the element list. + * @param startColumn the starting column number for the element list. */ public void setStartOfNextElementList(int startPage, int startColumn) { log.debug("start of the next element list is:" @@ -98,7 +98,7 @@ public class PageProvider implements Constants { this.lastRequestedIndex = -1; this.lastReportedBPD = -1; } - + /** * Sets the index of the last page. This is done as soon as the position of the last page * is known or assumed. @@ -107,7 +107,7 @@ public class PageProvider implements Constants { public void setLastPageIndex(int index) { this.lastPageIndex = index; } - + /** * Returns the available BPD for the part/page indicated by the index parameter. * The index is the part/page relative to the start of the current element list. @@ -145,9 +145,9 @@ public class PageProvider implements Constants { } return this.lastReportedBPD; } - + /** - * Returns the part index (0= 0) && (index == lastPageIndex); if (log.isTraceEnabled()) { - log.trace("getPage(" + index + " " + (isBlank ? "blank" : "non-blank") + log.trace("getPage(" + index + " " + (isBlank ? "blank" : "non-blank") + (isLastPage ? " " : "") + ")"); } int intIndex = index - startPageOfPageSequence; @@ -248,12 +248,12 @@ public class PageProvider implements Constants { } } } - + private Page cacheNextPage(int index, boolean isBlank, boolean isLastPage) { String pageNumberString = pageSeq.makeFormattedPageNumber(index); SimplePageMaster spm = pageSeq.getNextSimplePageMaster( index, (startPageOfPageSequence == index), isLastPage, false, isBlank); - + Region body = spm.getRegion(FO_REGION_BODY); if (!pageSeq.getMainFlow().getFlowName().equals(body.getRegionName())) { // this is fine by the XSL Rec (fo:flow's flow-name can be mapped to diff --git a/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java b/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java index c5a3bdeec..f9517554f 100644 --- a/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java @@ -57,9 +57,9 @@ public class PageSequenceLayoutManager extends AbstractPageSequenceLayoutManager public PageProvider getPageProvider() { return this.pageProvider; } - + /** - * @return the PageSequence being managed by this layout manager + * @return the PageSequence being managed by this layout manager */ protected PageSequence getPageSequence() { return (PageSequence)pageSeq; @@ -72,7 +72,7 @@ public class PageSequenceLayoutManager extends AbstractPageSequenceLayoutManager public PageSequenceLayoutManager getPSLM() { return this; } - + /** {@inheritDoc} */ public void activateLayout() { initialize(); @@ -100,7 +100,7 @@ public class PageSequenceLayoutManager extends AbstractPageSequenceLayoutManager } curPage = makeNewPage(false, false); - + PageBreaker breaker = new PageBreaker(this); int flowBPD = getCurrentPV().getBodyRegion().getRemainingBPD(); breaker.doLayout(flowBPD); @@ -118,7 +118,7 @@ public class PageSequenceLayoutManager extends AbstractPageSequenceLayoutManager areaTreeHandler.notifyPageSequenceFinished(pageSeq, (currentPageNum - startPageNum) + 1); getPageSequence().releasePageSequence(); - + // If this sequence has a page sequence master so we must reset // it in preparation for the next sequence String masterReference = getPageSequence().getMasterReference(); @@ -132,13 +132,13 @@ public class PageSequenceLayoutManager extends AbstractPageSequenceLayoutManager log.debug("Ending layout"); } } - + /** {@inheritDoc} */ protected Page createPage(int pageNumber, boolean isBlank) { return pageProvider.getPage(isBlank, pageNumber, PageProvider.RELTO_PAGE_SEQUENCE); } - + private void layoutSideRegion(int regionID) { SideRegion reg = (SideRegion)curPage.getSimplePageMaster().getRegion(regionID); if (reg == null) { @@ -158,12 +158,12 @@ public class PageSequenceLayoutManager extends AbstractPageSequenceLayoutManager /** {@inheritDoc} */ protected void finishPage() { // Layout side regions - layoutSideRegion(FO_REGION_BEFORE); + layoutSideRegion(FO_REGION_BEFORE); layoutSideRegion(FO_REGION_AFTER); layoutSideRegion(FO_REGION_START); layoutSideRegion(FO_REGION_END); - + super.finishPage(); } - + } diff --git a/src/java/org/apache/fop/layoutmgr/Position.java b/src/java/org/apache/fop/layoutmgr/Position.java index 197970403..42034cab4 100644 --- a/src/java/org/apache/fop/layoutmgr/Position.java +++ b/src/java/org/apache/fop/layoutmgr/Position.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,11 +16,11 @@ */ /* $Id$ */ - + package org.apache.fop.layoutmgr; public class Position { - + private LayoutManager layoutManager; private int index = -1; @@ -39,14 +39,14 @@ public class Position { public Position getPosition() { return null; } - + public boolean generatesAreas() { return false; } /** * Sets the index of this position in the sequence of Position elements. - * + * * @param value this position's index */ public void setIndex(int value) { @@ -55,13 +55,13 @@ public class Position { /** * Returns the index of this position in the sequence of Position elements. - * + * * @return the index of this position in the sequence of Position elements */ public int getIndex() { return this.index; } - + public String getShortLMName() { if (getLM() != null) { String lm = getLM().toString(); @@ -75,7 +75,7 @@ public class Position { return "null"; } } - + /** {@inheritDoc} */ public String toString() { StringBuffer sb = new StringBuffer(); diff --git a/src/java/org/apache/fop/layoutmgr/PositionIterator.java b/src/java/org/apache/fop/layoutmgr/PositionIterator.java index cd0f92b78..b50035313 100644 --- a/src/java/org/apache/fop/layoutmgr/PositionIterator.java +++ b/src/java/org/apache/fop/layoutmgr/PositionIterator.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,14 +16,14 @@ */ /* $Id$ */ - + package org.apache.fop.layoutmgr; import java.util.Iterator; import java.util.NoSuchElementException; public abstract class PositionIterator implements Iterator { - + private Iterator parentIter; private Object nextObj; private LayoutManager childLM; diff --git a/src/java/org/apache/fop/layoutmgr/RelSide.java b/src/java/org/apache/fop/layoutmgr/RelSide.java index 26650e0b1..38e4ab9ec 100644 --- a/src/java/org/apache/fop/layoutmgr/RelSide.java +++ b/src/java/org/apache/fop/layoutmgr/RelSide.java @@ -30,7 +30,7 @@ public final class RelSide { public static final RelSide START = new RelSide("start"); /** the end side */ public static final RelSide END = new RelSide("end"); - + private String name; /** @@ -45,10 +45,10 @@ public final class RelSide { public String getName() { return this.name; } - + /** {@inheritDoc} */ public String toString() { return "RelSide:" + name; } - + } diff --git a/src/java/org/apache/fop/layoutmgr/SpaceElement.java b/src/java/org/apache/fop/layoutmgr/SpaceElement.java index 558621529..820cf6506 100644 --- a/src/java/org/apache/fop/layoutmgr/SpaceElement.java +++ b/src/java/org/apache/fop/layoutmgr/SpaceElement.java @@ -30,7 +30,7 @@ import org.apache.fop.traits.MinOptMax; public class SpaceElement extends UnresolvedListElementWithLength { private int precedence; - + /** * Main constructor * @param position the Position instance needed by the addAreas stage of the LMs. @@ -40,21 +40,21 @@ public class SpaceElement extends UnresolvedListElementWithLength { * @param isLast true if this is a space-after of the last area generated. * @param context the property evaluation context */ - public SpaceElement(Position position, SpaceProperty space, RelSide side, + public SpaceElement(Position position, SpaceProperty space, RelSide side, boolean isFirst, boolean isLast, PercentBaseContext context) { - super(position, + super(position, MinOptMaxUtil.toMinOptMax( - space.getSpace().getLengthRange(), + space.getSpace().getLengthRange(), context), side, space.isDiscard(), isFirst, isLast); int en = space.getSpace().getPrecedence().getEnum(); if (en == Constants.EN_FORCE) { this.precedence = Integer.MAX_VALUE; } else { - this.precedence = space.getSpace().getPrecedence().getNumber().intValue(); + this.precedence = space.getSpace().getPrecedence().getNumber().intValue(); } } - + /** @return true if the space is forcing. */ public boolean isForcing() { return this.precedence == Integer.MAX_VALUE; @@ -64,7 +64,7 @@ public class SpaceElement extends UnresolvedListElementWithLength { public int getPrecedence() { return this.precedence; } - + /** {@inheritDoc} */ public void notifyLayoutManager(MinOptMax effectiveLength) { LayoutManager lm = getOriginatingLayoutManager(); @@ -72,11 +72,11 @@ public class SpaceElement extends UnresolvedListElementWithLength { ((ConditionalElementListener)lm).notifySpace( getSide(), effectiveLength); } else { - log.warn("Cannot notify LM. It does not implement ConditionalElementListener:" + log.warn("Cannot notify LM. It does not implement ConditionalElementListener:" + lm.getClass().getName()); } } - + /** {@inheritDoc} */ public String toString() { StringBuffer sb = new StringBuffer("Space["); diff --git a/src/java/org/apache/fop/layoutmgr/SpaceResolver.java b/src/java/org/apache/fop/layoutmgr/SpaceResolver.java index 051f76d7f..416ee924d 100644 --- a/src/java/org/apache/fop/layoutmgr/SpaceResolver.java +++ b/src/java/org/apache/fop/layoutmgr/SpaceResolver.java @@ -37,19 +37,19 @@ public class SpaceResolver { /** Logger instance */ protected static Log log = LogFactory.getLog(SpaceResolver.class); - + private UnresolvedListElementWithLength[] firstPart; private BreakElement breakPoss; private UnresolvedListElementWithLength[] secondPart; private UnresolvedListElementWithLength[] noBreak; - + private MinOptMax[] firstPartLengths; private MinOptMax[] secondPartLengths; private MinOptMax[] noBreakLengths; - + private boolean isFirst; private boolean isLast; - + /** * Main constructor. * @param first Element list before a break (optional) @@ -58,7 +58,7 @@ public class SpaceResolver { * @param isFirst Resolution at the beginning of a (full) element list * @param isLast Resolution at the end of a (full) element list */ - private SpaceResolver(List first, BreakElement breakPoss, List second, + private SpaceResolver(List first, BreakElement breakPoss, List second, boolean isFirst, boolean isLast) { this.isFirst = isFirst; this.isLast = isLast; @@ -95,14 +95,14 @@ public class SpaceResolver { if (breakPoss != null) { if (breakPoss.getPendingAfterMarks() != null) { if (log.isTraceEnabled()) { - log.trace(" adding pending before break: " + log.trace(" adding pending before break: " + breakPoss.getPendingAfterMarks()); } first.addAll(0, breakPoss.getPendingAfterMarks()); } if (breakPoss.getPendingBeforeMarks() != null) { if (log.isTraceEnabled()) { - log.trace(" adding pending after break: " + log.trace(" adding pending after break: " + breakPoss.getPendingBeforeMarks()); } second.addAll(0, breakPoss.getPendingBeforeMarks()); @@ -134,7 +134,7 @@ public class SpaceResolver { } resolve(); } - + private String toString(Object[] arr1, Object[] arr2) { if (arr1.length != arr2.length) { new IllegalArgumentException("The length of both arrays must be equal"); @@ -151,7 +151,7 @@ public class SpaceResolver { sb.append("]"); return sb.toString(); } - + private void removeConditionalBorderAndPadding( UnresolvedListElement[] elems, MinOptMax[] lengths, boolean reverse) { for (int i = 0; i < elems.length; i++) { @@ -175,7 +175,7 @@ public class SpaceResolver { log.trace("-->Resulting list: " + toString(elems, lengths)); } } - + private void performSpaceResolutionRule1(UnresolvedListElement[] elems, MinOptMax[] lengths, boolean reverse) { for (int i = 0; i < elems.length; i++) { @@ -204,14 +204,14 @@ public class SpaceResolver { } } - private void performSpaceResolutionRules2to3(UnresolvedListElement[] elems, + private void performSpaceResolutionRules2to3(UnresolvedListElement[] elems, MinOptMax[] lengths, int start, int end) { if (log.isTraceEnabled()) { log.trace("rule 2-3: " + start + "-" + end); } SpaceElement space; int remaining; - + //Rule 2 (4.3.1, XSL 1.0) boolean hasForcing = false; remaining = 0; @@ -237,7 +237,7 @@ public class SpaceResolver { space = (SpaceElement)elems[i]; if (!space.isForcing()) { if (log.isDebugEnabled()) { - log.debug("Nulling non-forcing space-specifier using 4.3.1, rule 2: " + log.debug("Nulling non-forcing space-specifier using 4.3.1, rule 2: " + elems[i]); } lengths[i] = null; @@ -245,7 +245,7 @@ public class SpaceResolver { } return; //If rule is triggered skip rule 3 } - + //Rule 3 (4.3.1, XSL 1.0) //Determine highes precedence int highestPrecedence = Integer.MIN_VALUE; @@ -269,8 +269,8 @@ public class SpaceResolver { space = (SpaceElement)elems[i]; if (space.getPrecedence() != highestPrecedence) { if (log.isDebugEnabled()) { - log.debug("Nulling space-specifier with precedence " - + space.getPrecedence() + " using 4.3.1, rule 3: " + log.debug("Nulling space-specifier with precedence " + + space.getPrecedence() + " using 4.3.1, rule 3: " + elems[i]); } lengths[i] = null; @@ -295,7 +295,7 @@ public class SpaceResolver { if (space.getLength().opt < greatestOptimum) { if (log.isDebugEnabled()) { log.debug("Nulling space-specifier with smaller optimum length " - + "using 4.3.1, rule 3: " + + "using 4.3.1, rule 3: " + elems[i]); } lengths[i] = null; @@ -318,7 +318,7 @@ public class SpaceResolver { max = Math.min(max, space.getLength().max); if (remaining > 1) { if (log.isDebugEnabled()) { - log.debug("Nulling non-last space-specifier using 4.3.1, rule 3, second part: " + log.debug("Nulling non-last space-specifier using 4.3.1, rule 3, second part: " + elems[i]); } lengths[i] = null; @@ -334,7 +334,7 @@ public class SpaceResolver { log.trace("-->Resulting list: " + toString(elems, lengths)); } } - + private void performSpaceResolutionRules2to3(UnresolvedListElement[] elems, MinOptMax[] lengths) { int start = 0; @@ -354,15 +354,15 @@ public class SpaceResolver { start = i; } } - + private boolean hasFirstPart() { return firstPart != null && firstPart.length > 0; } - + private boolean hasSecondPart() { return secondPart != null && secondPart.length > 0; } - + private void resolve() { if (breakPoss != null) { if (hasFirstPart()) { @@ -387,7 +387,7 @@ public class SpaceResolver { removeConditionalBorderAndPadding(firstPart, firstPartLengths, true); performSpaceResolutionRule1(firstPart, firstPartLengths, true); } - + if (hasFirstPart()) { //Now that we've handled isFirst/isLast conditions, we need to look at the //active part in its normal order so swap it back. @@ -408,7 +408,7 @@ public class SpaceResolver { performSpaceResolutionRules2to3(secondPart, secondPartLengths); } } - + private MinOptMax sum(MinOptMax[] lengths) { MinOptMax sum = new MinOptMax(); for (int i = 0; i < lengths.length; i++) { @@ -418,7 +418,7 @@ public class SpaceResolver { } return sum; } - + private void generate(ListIterator iter) { MinOptMax noBreakLength = new MinOptMax(); MinOptMax glue1; //space before break possibility if break occurs @@ -427,12 +427,12 @@ public class SpaceResolver { glue1 = sum(firstPartLengths); glue3 = sum(secondPartLengths); noBreakLength = sum(noBreakLengths); - + //This doesn't produce the right glue2 //glue2 = new MinOptMax(noBreakLength); //glue2.subtract(glue1); //glue2.subtract(glue3); - + int glue2w = noBreakLength.opt - glue1.opt - glue3.opt; int glue2stretch = (noBreakLength.max - noBreakLength.opt); int glue2shrink = (noBreakLength.opt - noBreakLength.min); @@ -440,34 +440,34 @@ public class SpaceResolver { glue2stretch -= glue3.max - glue3.opt; glue2shrink -= glue1.opt - glue1.min; glue2shrink -= glue3.opt - glue3.min; - + boolean hasPrecedingNonBlock = false; if (log.isDebugEnabled()) { - log.debug("noBreakLength=" + noBreakLength - + ", glue1=" + glue1 - + ", glue2=" + glue2w + "+" + glue2stretch + "-" + glue2shrink + log.debug("noBreakLength=" + noBreakLength + + ", glue1=" + glue1 + + ", glue2=" + glue2w + "+" + glue2stretch + "-" + glue2shrink + ", glue3=" + glue3); } if (breakPoss != null) { boolean forcedBreak = breakPoss.isForcedBreak(); if (glue1.isNonZero()) { - iter.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, + iter.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false, (Position)null, true)); - iter.add(new KnuthGlue(glue1.opt, glue1.max - glue1.opt, glue1.opt - glue1.min, + iter.add(new KnuthGlue(glue1.opt, glue1.max - glue1.opt, glue1.opt - glue1.min, (Position)null, true)); if (forcedBreak) { //Otherwise, the preceding penalty and glue will be cut off iter.add(new KnuthBox(0, (Position)null, true)); } } - iter.add(new KnuthPenalty(breakPoss.getPenaltyWidth(), breakPoss.getPenaltyValue(), - false, breakPoss.getBreakClass(), + iter.add(new KnuthPenalty(breakPoss.getPenaltyWidth(), breakPoss.getPenaltyValue(), + false, breakPoss.getBreakClass(), new SpaceHandlingBreakPosition(this, breakPoss), false)); if (breakPoss.getPenaltyValue() <= -KnuthPenalty.INFINITE) { return; //return early. Not necessary (even wrong) to add additional elements } if (glue2w != 0 || glue2stretch != 0 || glue2shrink != 0) { - iter.add(new KnuthGlue(glue2w, glue2stretch, glue2shrink, + iter.add(new KnuthGlue(glue2w, glue2stretch, glue2shrink, (Position)null, true)); } } else { @@ -483,9 +483,9 @@ public class SpaceResolver { iter.add(new KnuthBox(0, pos, true)); } if (glue3.isNonZero()) { - iter.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, + iter.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false, (Position)null, true)); - iter.add(new KnuthGlue(glue3.opt, glue3.max - glue3.opt, glue3.opt - glue3.min, + iter.add(new KnuthGlue(glue3.opt, glue3.max - glue3.opt, glue3.opt - glue3.min, (Position)null, true)); hasPrecedingNonBlock = true; } @@ -494,7 +494,7 @@ public class SpaceResolver { iter.add(new KnuthBox(0, (Position)null, true)); } } - + /** * Position class for break possibilities. It is used to notify layout manager about the * effective spaces and conditional lengths. @@ -503,11 +503,11 @@ public class SpaceResolver { private SpaceResolver resolver; private Position originalPosition; - + /** * Main constructor. * @param resolver the space resolver that provides the info about the actual situation - * @param breakPoss the original break possibility that creates this Position + * @param breakPoss the original break possibility that creates this Position */ public SpaceHandlingBreakPosition(SpaceResolver resolver, BreakElement breakPoss) { super(null); @@ -518,18 +518,18 @@ public class SpaceResolver { this.originalPosition = this.originalPosition.getPosition(); } } - + /** @return the space resolver */ public SpaceResolver getSpaceResolver() { return this.resolver; } - + /** * Notifies all affected layout managers about the current situation in the part to be * handled for area generation. * @param isBreakSituation true if this is a break situation. * @param side defines to notify about the situation whether before or after the break. - * May be null if isBreakSituation is null. + * May be null if isBreakSituation is null. */ public void notifyBreakSituation(boolean isBreakSituation, RelSide side) { if (isBreakSituation) { @@ -548,7 +548,7 @@ public class SpaceResolver { } } } - + /** {@inheritDoc} */ public String toString() { StringBuffer sb = new StringBuffer(); @@ -558,7 +558,7 @@ public class SpaceResolver { return sb.toString(); } - /** + /** * @return the original Position instance set at the BreakElement that this Position was * created for. */ @@ -566,7 +566,7 @@ public class SpaceResolver { return this.originalPosition; } } - + /** * Position class for no-break situations. It is used to notify layout manager about the * effective spaces and conditional lengths. @@ -574,7 +574,7 @@ public class SpaceResolver { public static class SpaceHandlingPosition extends Position { private SpaceResolver resolver; - + /** * Main constructor. * @param resolver the space resolver that provides the info about the actual situation @@ -583,12 +583,12 @@ public class SpaceResolver { super(null); this.resolver = resolver; } - + /** @return the space resolver */ public SpaceResolver getSpaceResolver() { return this.resolver; } - + /** * Notifies all affected layout managers about the current situation in the part to be * handled for area generation. @@ -601,7 +601,7 @@ public class SpaceResolver { resolver.secondPart[i].notifyLayoutManager(resolver.secondPartLengths[i]); } } - + /** {@inheritDoc} */ public String toString() { StringBuffer sb = new StringBuffer(); @@ -609,7 +609,7 @@ public class SpaceResolver { return sb.toString(); } } - + /** * Resolves unresolved elements applying the space resolution rules defined in 4.3.1. * @param elems the element list @@ -673,7 +673,7 @@ public class SpaceResolver { unresolvedSecond = unresolvedFirst; unresolvedFirst = swapList; } - + log.debug("----start space resolution (first=" + first + ", last=" + last + ")..."); SpaceResolver resolver = new SpaceResolver( unresolvedFirst, breakPoss, unresolvedSecond, first, last); @@ -689,7 +689,7 @@ public class SpaceResolver { first = false; } } - + /** * Inspects an effective element list and notifies all layout managers about the state of * the spaces and conditional lengths. @@ -699,7 +699,7 @@ public class SpaceResolver { * @param prevBreak index of the the break possibility just before this part (used to * identify a break condition, lastBreak <= 0 represents a no-break condition) */ - public static void performConditionalsNotification(List effectiveList, + public static void performConditionalsNotification(List effectiveList, int startElementIndex, int endElementIndex, int prevBreak) { KnuthElement el = null; if (prevBreak > 0) { @@ -710,7 +710,7 @@ public class SpaceResolver { if (el != null && el.isPenalty()) { Position pos = el.getPosition(); if (pos instanceof SpaceResolver.SpaceHandlingBreakPosition) { - beforeBreak = (SpaceResolver.SpaceHandlingBreakPosition)pos; + beforeBreak = (SpaceResolver.SpaceHandlingBreakPosition)pos; beforeBreak.notifyBreakSituation(true, RelSide.BEFORE); } } @@ -718,7 +718,7 @@ public class SpaceResolver { if (el != null && el.isPenalty()) { Position pos = el.getPosition(); if (pos instanceof SpaceResolver.SpaceHandlingBreakPosition) { - afterBreak = (SpaceResolver.SpaceHandlingBreakPosition)pos; + afterBreak = (SpaceResolver.SpaceHandlingBreakPosition)pos; afterBreak.notifyBreakSituation(true, RelSide.AFTER); } } @@ -735,7 +735,7 @@ public class SpaceResolver { } } } - - + + } diff --git a/src/java/org/apache/fop/layoutmgr/SpaceSpecifier.java b/src/java/org/apache/fop/layoutmgr/SpaceSpecifier.java index c6c47fd35..62a066121 100644 --- a/src/java/org/apache/fop/layoutmgr/SpaceSpecifier.java +++ b/src/java/org/apache/fop/layoutmgr/SpaceSpecifier.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 SpaceSpecifier implements Cloneable { try { SpaceSpecifier ss = (SpaceSpecifier) super.clone(); ss.startsReferenceArea = startsReferenceArea; - ss.hasForcing = hasForcing; + ss.hasForcing = hasForcing; // Clone the vector, but share the objects in it! ss.spaceVals = new ArrayList(); ss.spaceVals.addAll(spaceVals); @@ -152,7 +152,7 @@ public class SpaceSpecifier implements Cloneable { } return resolvedSpace; } - + public String toString() { return "Space Specifier (resolved at begin/end of ref. area:):\n" + resolve(false).toString() + "\n" + diff --git a/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java index 44e0cc476..b4941d418 100644 --- a/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.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.layoutmgr; import java.util.LinkedList; @@ -66,7 +66,7 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { * @param node static-content FO * @param reg side region to layout into */ - public StaticContentLayoutManager(PageSequenceLayoutManager pslm, + public StaticContentLayoutManager(PageSequenceLayoutManager pslm, StaticContent node, SideRegion reg) { super(node); setParent(pslm); @@ -80,11 +80,11 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { * @param node static-content FO * @param block the block to layout into */ - public StaticContentLayoutManager(PageSequenceLayoutManager pslm, + public StaticContentLayoutManager(PageSequenceLayoutManager pslm, StaticContent node, Block block) { super(node); setParent(pslm); - targetBlock = block; + targetBlock = block; } /** {@inheritDoc} */ @@ -98,7 +98,7 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { setContentAreaIPD(context.getRefIPD()); setContentAreaBPD(context.getStackLimitBP().opt); - //TODO Copied from elsewhere. May be worthwhile to factor out the common parts. + //TODO Copied from elsewhere. May be worthwhile to factor out the common parts. // currently active LM BlockLevelLayoutManager curLM; BlockLevelLayoutManager prevLM = null; @@ -122,7 +122,7 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { // get elements from curLM returnedList = curLM.getNextKnuthElements(childLC, alignment); - //log.debug("FLM.getNextKnuthElements> returnedList.size() = " + //log.debug("FLM.getNextKnuthElements> returnedList.size() = " // + returnedList.size()); // "wrap" the Position inside each element @@ -148,8 +148,8 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { if (prevLM.mustKeepWithNext() || curLM.mustKeepWithPrevious()) { // add an infinite penalty to forbid a break between blocks - returnList.add(new KnuthPenalty(0, - KnuthElement.INFINITE, false, + returnList.add(new KnuthPenalty(0, + KnuthElement.INFINITE, false, new Position(this), false)); } else if (!((KnuthElement) ListUtil.getLast(returnList)) .isGlue()) { @@ -180,9 +180,9 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { return returnList; } } - + /** - * {@inheritDoc} + * {@inheritDoc} */ public void addAreas(PositionIterator parentIter, LayoutContext layoutContext) { AreaAdditionUtil.addAreas(this, parentIter, layoutContext); @@ -246,10 +246,10 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { if (breaker.isOverflow()) { if (!autoHeight) { String page = getPSLM().getCurrentPage().getPageViewport().getPageNumberString(); - + BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Provider.get( getStaticContentFO().getUserAgent().getEventBroadcaster()); - boolean canRecover = (regionFO.getOverflow() != EN_ERROR_IF_OVERFLOW); + 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(), @@ -259,7 +259,7 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { } } } - + /** * Convenience method that returns the Static Content node. * @return the static content node @@ -268,13 +268,13 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { return (StaticContent) fobj; } - private class StaticContentBreaker extends AbstractBreaker { + private class StaticContentBreaker extends AbstractBreaker { private StaticContentLayoutManager lm; private int displayAlign; private int ipd; private int overflow = 0; - - public StaticContentBreaker(StaticContentLayoutManager lm, int ipd, + + public StaticContentBreaker(StaticContentLayoutManager lm, int ipd, int displayAlign) { this.lm = lm; this.ipd = ipd; @@ -290,7 +290,7 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { } ElementListObserver.observe(elementList, "static-content", elementListID); } - + /** {@inheritDoc} */ protected boolean isPartOverflowRecoveryActivated() { //For side regions, this must be disabled because of wanted overflow. @@ -300,11 +300,11 @@ 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() { @@ -314,7 +314,7 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { StaticContentBreaker.this.overflow = amount; } } - + }; } @@ -327,7 +327,7 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { lc.setRefIPD(ipd); return lc; } - + protected List getNextKnuthElements(LayoutContext context, int alignment) { LayoutManager curLM; // currently active LM List returnList = new LinkedList(); @@ -339,7 +339,7 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { childLC.setWritingMode(context.getWritingMode()); List returnedList = null; - //The following is a HACK! Ignore leading and trailing white space + //The following is a HACK! Ignore leading and trailing white space boolean ignore = curLM instanceof TextLayoutManager; if (!curLM.isFinished()) { returnedList = curLM.getNextKnuthElements(childLC, alignment); @@ -356,39 +356,39 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { protected int getCurrentDisplayAlign() { return displayAlign; } - + protected boolean hasMoreContent() { return !lm.isFinished(); } - + protected void addAreas(PositionIterator posIter, LayoutContext context) { - AreaAdditionUtil.addAreas(lm, posIter, context); + AreaAdditionUtil.addAreas(lm, posIter, context); } - - protected void doPhase3(PageBreakingAlgorithm alg, int partCount, + + protected void doPhase3(PageBreakingAlgorithm alg, int partCount, BlockSequence originalList, BlockSequence effectiveList) { if (partCount > 1) { PageBreakPosition pos = (PageBreakPosition)alg.getPageBreaks().getFirst(); int firstPartLength = ElementListUtils.calcContentLength(effectiveList, effectiveList.ignoreAtStart, pos.getLeafPos()); - overflow += alg.totalWidth - firstPartLength; - } - //Rendering all parts (not just the first) at once for the case where the parts that + overflow += alg.totalWidth - firstPartLength; + } + //Rendering all parts (not just the first) at once for the case where the parts that //overflow should be visible. alg.removeAllPageBreaks(); //Directly add areas after finding the breaks this.addAreas(alg, 1, originalList, effectiveList); } - + protected void finishPart(PageBreakingAlgorithm alg, PageBreakPosition pbp) { //nop for static content } - + protected LayoutManager getCurrentChildLM() { return null; //TODO NYI } - } - + } + /** * Returns the IPD of the content area * @return the IPD of the content area @@ -396,12 +396,12 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { public int getContentAreaIPD() { return contentAreaIPD; } - + /** {@inheritDoc} */ protected void setContentAreaIPD(int contentAreaIPD) { this.contentAreaIPD = contentAreaIPD; } - + /** * Returns the BPD of the content area * @return the BPD of the content area @@ -409,16 +409,16 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { public int getContentAreaBPD() { return contentAreaBPD; } - + private void setContentAreaBPD(int contentAreaBPD) { this.contentAreaBPD = contentAreaBPD; } - + /** {@inheritDoc} */ public int getKeepTogetherStrength() { return KEEP_AUTO; } - + /** {@inheritDoc} */ public int getKeepWithNextStrength() { return KEEP_AUTO; @@ -428,6 +428,6 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { public int getKeepWithPreviousStrength() { return KEEP_AUTO; } - + } diff --git a/src/java/org/apache/fop/layoutmgr/TopLevelLayoutManager.java b/src/java/org/apache/fop/layoutmgr/TopLevelLayoutManager.java index 63c8ac158..72fddf199 100644 --- a/src/java/org/apache/fop/layoutmgr/TopLevelLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/TopLevelLayoutManager.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 interface TopLevelLayoutManager { /** * Activate the layout of this page sequence. - * PageViewports corresponding to each page generated by this + * PageViewports corresponding to each page generated by this * page sequence will be created and sent to the AreaTreeModel * for rendering. */ diff --git a/src/java/org/apache/fop/layoutmgr/TraitSetter.java b/src/java/org/apache/fop/layoutmgr/TraitSetter.java index dfc8c99f2..d1146375e 100644 --- a/src/java/org/apache/fop/layoutmgr/TraitSetter.java +++ b/src/java/org/apache/fop/layoutmgr/TraitSetter.java @@ -43,7 +43,7 @@ public class TraitSetter { /** logger */ protected static Log log = LogFactory.getLog(TraitSetter.class); - + /** * Sets border and padding traits on areas. * @param area area to set the traits on @@ -74,18 +74,18 @@ public class TraitSetter { } addBorderTrait(area, bpProps, bNotFirst, - CommonBorderPaddingBackground.START, + CommonBorderPaddingBackground.START, BorderProps.SEPARATE, Trait.BORDER_START); - addBorderTrait(area, bpProps, bNotLast, + addBorderTrait(area, bpProps, bNotLast, CommonBorderPaddingBackground.END, BorderProps.SEPARATE, Trait.BORDER_END); - addBorderTrait(area, bpProps, false, + addBorderTrait(area, bpProps, false, CommonBorderPaddingBackground.BEFORE, BorderProps.SEPARATE, Trait.BORDER_BEFORE); - addBorderTrait(area, bpProps, false, + addBorderTrait(area, bpProps, false, CommonBorderPaddingBackground.AFTER, BorderProps.SEPARATE, Trait.BORDER_AFTER); } @@ -183,7 +183,7 @@ public class TraitSetter { * @param borderAfter the resolved after border * @param borderStart the resolved start border * @param borderEnd the resolved end border - * @param outer 4 boolean values indicating if the side represents the + * @param outer 4 boolean values indicating if the side represents the * table's outer border. Order: before, after, start, end */ public static void addCollapsingBorders(Area area, @@ -208,7 +208,7 @@ public class TraitSetter { } } - private static void addPadding(Area area, CommonBorderPaddingBackground bordProps, + private static void addPadding(Area area, CommonBorderPaddingBackground bordProps, PercentBaseContext context) { addPadding(area, bordProps, false, false, false, false, context); } @@ -229,32 +229,32 @@ public class TraitSetter { boolean discardBefore, boolean discardAfter, boolean discardStart, boolean discardEnd, PercentBaseContext context) { - int padding = bordProps.getPadding(CommonBorderPaddingBackground.BEFORE, + int padding = bordProps.getPadding(CommonBorderPaddingBackground.BEFORE, discardBefore, context); if (padding != 0) { area.addTrait(Trait.PADDING_BEFORE, new java.lang.Integer(padding)); } - padding = bordProps.getPadding(CommonBorderPaddingBackground.AFTER, + padding = bordProps.getPadding(CommonBorderPaddingBackground.AFTER, discardAfter, context); if (padding != 0) { area.addTrait(Trait.PADDING_AFTER, new java.lang.Integer(padding)); } - padding = bordProps.getPadding(CommonBorderPaddingBackground.START, + padding = bordProps.getPadding(CommonBorderPaddingBackground.START, discardStart, context); if (padding != 0) { area.addTrait(Trait.PADDING_START, new java.lang.Integer(padding)); } - padding = bordProps.getPadding(CommonBorderPaddingBackground.END, + padding = bordProps.getPadding(CommonBorderPaddingBackground.END, discardEnd, context); if (padding != 0) { area.addTrait(Trait.PADDING_END, new java.lang.Integer(padding)); } } - + private static BorderProps getBorderProps(CommonBorderPaddingBackground bordProps, int side) { int width = bordProps.getBorderWidth(side, false); if (width != 0) { @@ -290,17 +290,17 @@ public class TraitSetter { * background-position-horizontal/vertical to ensure the background images are * correctly placed. Indeed the placement of images must be made WRT the * column/body/row and not the cell. - * + * *

      Note: The area's IPD and BPD must be set before calling this method.

      - * + * *

      TODO the regular * {@link #addBackground(Area, CommonBorderPaddingBackground, PercentBaseContext)} * method should be used instead, and a means to retrieve the original area's * dimensions must be found.

      - * + * *

      TODO the placement of images in the x- or y-direction will be incorrect if * background-repeat is set for that direction.

      - * + * * @param area the area to set the traits on * @param backProps the background properties * @param context Property evaluation context @@ -311,7 +311,7 @@ public class TraitSetter { * @param referenceIPD value to use as a reference for percentage calculation * @param referenceBPD value to use as a reference for percentage calculation */ - public static void addBackground(Area area, + public static void addBackground(Area area, CommonBorderPaddingBackground backProps, PercentBaseContext context, int ipdShift, int bpdShift, int referenceIPD, int referenceBPD) { @@ -326,7 +326,7 @@ public class TraitSetter { back.setImageInfo(backProps.getImageInfo()); back.setRepeat(backProps.backgroundRepeat); if (backProps.backgroundPositionHorizontal != null) { - if (back.getRepeat() == Constants.EN_NOREPEAT + if (back.getRepeat() == Constants.EN_NOREPEAT || back.getRepeat() == Constants.EN_REPEATY) { if (area.getIPD() > 0) { PercentBaseContext refContext = new SimplePercentBaseContext(context, @@ -344,7 +344,7 @@ public class TraitSetter { } } if (backProps.backgroundPositionVertical != null) { - if (back.getRepeat() == Constants.EN_NOREPEAT + if (back.getRepeat() == Constants.EN_NOREPEAT || back.getRepeat() == Constants.EN_REPEATX) { if (area.getBPD() > 0) { PercentBaseContext refContext = new SimplePercentBaseContext(context, @@ -374,7 +374,7 @@ public class TraitSetter { * @param backProps the background properties * @param context Property evaluation context */ - public static void addBackground(Area area, + public static void addBackground(Area area, CommonBorderPaddingBackground backProps, PercentBaseContext context) { if (!backProps.hasBackground()) { @@ -388,14 +388,14 @@ public class TraitSetter { back.setImageInfo(backProps.getImageInfo()); back.setRepeat(backProps.backgroundRepeat); if (backProps.backgroundPositionHorizontal != null) { - if (back.getRepeat() == Constants.EN_NOREPEAT + if (back.getRepeat() == Constants.EN_NOREPEAT || back.getRepeat() == Constants.EN_REPEATY) { if (area.getIPD() > 0) { int width = area.getIPD(); width += backProps.getPaddingStart(false, context); width += backProps.getPaddingEnd(false, context); back.setHoriz(backProps.backgroundPositionHorizontal.getValue( - new SimplePercentBaseContext(context, + new SimplePercentBaseContext(context, LengthBase.IMAGE_BACKGROUND_POSITION_HORIZONTAL, (width - back.getImageInfo().getSize().getWidthMpt()) ) @@ -409,14 +409,14 @@ public class TraitSetter { } } if (backProps.backgroundPositionVertical != null) { - if (back.getRepeat() == Constants.EN_NOREPEAT + if (back.getRepeat() == Constants.EN_NOREPEAT || back.getRepeat() == Constants.EN_REPEATX) { if (area.getBPD() > 0) { int height = area.getBPD(); height += backProps.getPaddingBefore(false, context); height += backProps.getPaddingAfter(false, context); back.setVertical(backProps.backgroundPositionVertical.getValue( - new SimplePercentBaseContext(context, + new SimplePercentBaseContext(context, LengthBase.IMAGE_BACKGROUND_POSITION_VERTICAL, (height - back.getImageInfo().getSize().getHeightMpt()) ) @@ -451,7 +451,7 @@ public class TraitSetter { if (startIndent != 0) { area.addTrait(Trait.START_INDENT, new Integer(startIndent)); } - + int spaceStart = startIndent - bpProps.getBorderStartWidth(false) - bpProps.getPaddingStart(false, context); @@ -489,7 +489,7 @@ public class TraitSetter { } /** - * Returns the effective space length of a resolved space specifier based on the adjustment + * Returns the effective space length of a resolved space specifier based on the adjustment * value. * @param adjust the adjustment value * @param space the space specifier @@ -507,7 +507,7 @@ public class TraitSetter { } return sp; } - + /** * Adds traits for space-before and space-after to an area. * @param area the target area @@ -515,7 +515,7 @@ public class TraitSetter { * @param spaceBefore the space-before space specifier * @param spaceAfter the space-after space specifier */ - public static void addSpaceBeforeAfter(Area area, double adjust, + public static void addSpaceBeforeAfter(Area area, double adjust, MinOptMax spaceBefore, MinOptMax spaceAfter) { int space; space = getEffectiveSpace(adjust, spaceBefore); @@ -527,7 +527,7 @@ public class TraitSetter { area.addTrait(Trait.SPACE_AFTER, new Integer(space)); } } - + /** * Sets the traits for breaks on an area. * @param area the area to set the traits on. @@ -540,7 +540,7 @@ public class TraitSetter { area.addTrait(Trait.BREAK_BEFORE, new Integer(breakBefore)); */ } - + /** * Adds font traits to an area * @param area the target are @@ -550,7 +550,7 @@ public class TraitSetter { area.addTrait(Trait.FONT, font.getFontTriplet()); area.addTrait(Trait.FONT_SIZE, new Integer(font.getFontSize())); } - + /** * Adds the text-decoration traits to the area. * @param area the area to set the traits on @@ -576,9 +576,9 @@ public class TraitSetter { } } } - + /** - * Sets the producer's ID as a trait on the area. This can be used to track back the + * Sets the producer's ID as a trait on the area. This can be used to track back the * generating FO node. * @param area the area to set the traits on * @param id the ID to set diff --git a/src/java/org/apache/fop/layoutmgr/UnresolvedListElement.java b/src/java/org/apache/fop/layoutmgr/UnresolvedListElement.java index 2e014ef08..89baca9c6 100644 --- a/src/java/org/apache/fop/layoutmgr/UnresolvedListElement.java +++ b/src/java/org/apache/fop/layoutmgr/UnresolvedListElement.java @@ -31,10 +31,10 @@ public abstract class UnresolvedListElement extends ListElement { public UnresolvedListElement(Position position) { super(position); } - + /** @return true if the element is conditional (conditionality="discard") */ public abstract boolean isConditional(); - + /** @return the layout manager that created this ListElement */ protected LayoutManager getOriginatingLayoutManager() { Position pos = getPosition(); @@ -43,5 +43,5 @@ public abstract class UnresolvedListElement extends ListElement { } return pos.getLM(); } - + } diff --git a/src/java/org/apache/fop/layoutmgr/UnresolvedListElementWithLength.java b/src/java/org/apache/fop/layoutmgr/UnresolvedListElementWithLength.java index f3c613202..d1b16a523 100644 --- a/src/java/org/apache/fop/layoutmgr/UnresolvedListElementWithLength.java +++ b/src/java/org/apache/fop/layoutmgr/UnresolvedListElementWithLength.java @@ -31,13 +31,13 @@ public abstract class UnresolvedListElementWithLength extends UnresolvedListElem /** Logger instance */ protected static Log log = LogFactory.getLog(UnresolvedListElementWithLength.class); - + private MinOptMax length; private boolean conditional; private RelSide side; private boolean isFirst; private boolean isLast; - + /** * Main constructor * @param position the Position instance needed by the addAreas stage of the LMs. @@ -47,7 +47,7 @@ public abstract class UnresolvedListElementWithLength extends UnresolvedListElem * @param isFirst true if this is a space-before of the first area generated. * @param isLast true if this is a space-after of the last area generated. */ - public UnresolvedListElementWithLength(Position position, MinOptMax length, + public UnresolvedListElementWithLength(Position position, MinOptMax length, RelSide side, boolean conditional, boolean isFirst, boolean isLast) { super(position); @@ -57,32 +57,32 @@ public abstract class UnresolvedListElementWithLength extends UnresolvedListElem this.isFirst = isFirst; this.isLast = isLast; } - + /** {@inheritDoc} */ public boolean isConditional() { return this.conditional; } - + /** @return the space as resolved MinOptMax instance */ public MinOptMax getLength() { return this.length; } - + /** @return the side this element was generated for */ public RelSide getSide() { return this.side; } - + /** @return true if this is a space-before of the first area generated. */ public boolean isFirst() { return this.isFirst; } - + /** @return true if this is a space-after of the last area generated. */ public boolean isLast() { return this.isLast; } - + /** * Called to notify the affected layout manager about the effective length after resolution. * This method is called once before each call to the layout manager's addAreas() method. @@ -90,7 +90,7 @@ public abstract class UnresolvedListElementWithLength extends UnresolvedListElem * zero effective length) */ public abstract void notifyLayoutManager(MinOptMax effectiveLength); - + /** {@inheritDoc} */ public String toString() { StringBuffer sb = new StringBuffer(); @@ -109,5 +109,5 @@ public abstract class UnresolvedListElementWithLength extends UnresolvedListElem } return sb.toString(); } - + } diff --git a/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java index 76002da2f..00c628a40 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.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,14 +34,14 @@ import org.apache.fop.layoutmgr.TraitSetter; /** - * LayoutManager handling the common tasks for the fo:instream-foreign-object + * LayoutManager handling the common tasks for the fo:instream-foreign-object * and fo:external-graphics formatting objects */ public abstract class AbstractGraphicsLayoutManager extends LeafNodeLayoutManager { - + /** * Constructor. - * + * * @param node * the formatting object that creates this area */ @@ -67,17 +67,17 @@ public abstract class AbstractGraphicsLayoutManager extends LeafNodeLayoutManage Rectangle placement = imageLayout.getPlacement(); CommonBorderPaddingBackground borderProps = fobj.getCommonBorderPaddingBackground(); - + //Determine extra BPD from borders and padding int beforeBPD = borderProps.getPadding(CommonBorderPaddingBackground.BEFORE, false, this); beforeBPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.BEFORE, false); - + placement.y += beforeBPD; - + //Determine extra IPD from borders and padding int startIPD = borderProps.getPadding(CommonBorderPaddingBackground.START, false, this); startIPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.START, false); - + placement.x += startIPD; Area viewportArea = getChildArea(); @@ -101,7 +101,7 @@ public abstract class AbstractGraphicsLayoutManager extends LeafNodeLayoutManage return vp; } - + /** {@inheritDoc} */ public List getNextKnuthElements(LayoutContext context, int alignment) { @@ -109,7 +109,7 @@ public abstract class AbstractGraphicsLayoutManager extends LeafNodeLayoutManage setCurrentArea(areaCurrent); return super.getNextKnuthElements(context, alignment); } - + /** {@inheritDoc} */ protected AlignmentContext makeAlignmentContext(LayoutContext context) { final AbstractGraphics fobj = (AbstractGraphics)this.fobj; @@ -129,11 +129,11 @@ public abstract class AbstractGraphicsLayoutManager extends LeafNodeLayoutManage * @return the appropriate area */ protected abstract Area getChildArea(); - + // --------- Property Resolution related functions --------- // - + /** - * {@inheritDoc} + * {@inheritDoc} */ public int getBaseLength(int lengthBase, FObj fobj) { switch (lengthBase) { diff --git a/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java index c92bdb6fc..b65978453 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.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. @@ -43,10 +43,10 @@ public abstract class AbstractPageNumberCitationLayoutManager extends LeafNodeLa protected AbstractPageNumberCitation fobj; /** Font for the page-number-citation */ protected Font font; - + /** Indicates whether the page referred to by the citation has been resolved yet */ protected boolean resolved = false; - + /** * Constructor * @@ -57,7 +57,7 @@ public abstract class AbstractPageNumberCitationLayoutManager extends LeafNodeLa super(node); fobj = node; } - + /** {@inheritDoc} */ public void initialize() { FontInfo fi = fobj.getFOEventHandler().getFontInfo(); @@ -86,10 +86,10 @@ public abstract class AbstractPageNumberCitationLayoutManager extends LeafNodeLa curArea = getPageNumberCitationInlineArea(); return curArea; } - + /** * {@inheritDoc} - * , LayoutContext) + * , LayoutContext) */ public void addAreas(PositionIterator posIter, LayoutContext context) { super.addAreas(posIter, context); @@ -97,7 +97,7 @@ public abstract class AbstractPageNumberCitationLayoutManager extends LeafNodeLa getPSLM().addUnresolvedArea(fobj.getRefId(), (Resolvable) curArea); } } - + /** * If id can be resolved then simply return a word, otherwise * return a resolvable area @@ -124,12 +124,12 @@ public abstract class AbstractPageNumberCitationLayoutManager extends LeafNodeLa text.setIPD(width); } updateTextAreaTraits(text); - + return text; } - + /** - * Updates the traits for the generated text area. + * Updates the traits for the generated text area. * @param text the text area */ protected void updateTextAreaTraits(TextArea text) { @@ -140,7 +140,7 @@ public abstract class AbstractPageNumberCitationLayoutManager extends LeafNodeLa text.addTrait(Trait.COLOR, fobj.getColor()); TraitSetter.addTextDecoration(text, fobj.getTextDecoration()); } - + /** * @param str string to be measured * @return width (in millipoints ??) of the string diff --git a/src/java/org/apache/fop/layoutmgr/inline/AlignmentContext.java b/src/java/org/apache/fop/layoutmgr/inline/AlignmentContext.java index 14172a479..4eb0abd64 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/AlignmentContext.java +++ b/src/java/org/apache/fop/layoutmgr/inline/AlignmentContext.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. @@ -47,9 +47,9 @@ public class AlignmentContext implements Constants { private ScaledBaselineTable scaledBaselineTable = null; private ScaledBaselineTable actualBaselineTable = null; private AlignmentContext parentAlignmentContext = null; - + /** - * Creates a new instance of AlignmentContext + * Creates a new instance of AlignmentContext * for graphics areas. * @param height the total height of the area * @param alignmentAdjust the alignment-adjust property @@ -64,7 +64,7 @@ public class AlignmentContext implements Constants { , Length baselineShift , int dominantBaseline , AlignmentContext parentAlignmentContext) { - + this.areaHeight = height; this.lineHeight = height; this.xHeight = height; @@ -95,18 +95,18 @@ public class AlignmentContext implements Constants { break; } actualBaselineTable = ScaledBaselineTableFactory.makeGraphicsScaledBaselineTable( - height, - dominantBaselineIdentifier, + height, + dominantBaselineIdentifier, scaledBaselineTable.getWritingMode()); if (newScaledBaselineTableRequired) { scaledBaselineTable = ScaledBaselineTableFactory.makeGraphicsScaledBaselineTable( - height, - dominantBaselineIdentifier, + height, + dominantBaselineIdentifier, scaledBaselineTable.getWritingMode()); } setAlignmentAdjust(alignmentAdjust); } - + /** * Creates a new instance of AlignmentContext * @param font the font @@ -153,17 +153,17 @@ public class AlignmentContext implements Constants { dominantBaselineIdentifier = dominantBaseline; break; } - actualBaselineTable = ScaledBaselineTableFactory.makeFontScaledBaselineTable(font, - dominantBaselineIdentifier, + actualBaselineTable = ScaledBaselineTableFactory.makeFontScaledBaselineTable(font, + dominantBaselineIdentifier, scaledBaselineTable.getWritingMode()); if (newScaledBaselineTableRequired) { - scaledBaselineTable = ScaledBaselineTableFactory.makeFontScaledBaselineTable(font, - dominantBaselineIdentifier, + scaledBaselineTable = ScaledBaselineTableFactory.makeFontScaledBaselineTable(font, + dominantBaselineIdentifier, scaledBaselineTable.getWritingMode()); } setAlignmentAdjust(alignmentAdjust); } - + /** * Creates a new instance of AlignmentContext based simply * on the font and the writing mode. @@ -176,14 +176,14 @@ public class AlignmentContext implements Constants { this.lineHeight = lineHeight; this.xHeight = font.getXHeight(); this.parentAlignmentContext = null; - this.scaledBaselineTable + this.scaledBaselineTable = ScaledBaselineTableFactory.makeFontScaledBaselineTable(font, writingMode); this.actualBaselineTable = scaledBaselineTable; this.alignmentBaselineIdentifier = getDominantBaselineIdentifier(); this.alignmentPoint = font.getAscender(); this.baselineShiftValue = 0; } - + /** * Returns the alignment point for this context. * This is the point on the start edge of the area this context @@ -251,7 +251,7 @@ public class AlignmentContext implements Constants { int beforeEdge = actualBaselineTable.getBaseline(EN_BEFORE_EDGE); switch (alignmentAdjust.getEnum()) { case EN_AUTO: - alignmentPoint = beforeEdge + alignmentPoint = beforeEdge - actualBaselineTable.getBaseline(alignmentBaselineIdentifier); break; case EN_BASELINE: @@ -267,7 +267,7 @@ public class AlignmentContext implements Constants { case EN_ALPHABETIC: case EN_HANGING: case EN_MATHEMATICAL: - alignmentPoint = beforeEdge + alignmentPoint = beforeEdge - actualBaselineTable.getBaseline(alignmentAdjust.getEnum()); break; default: @@ -294,7 +294,7 @@ public class AlignmentContext implements Constants { public int getDominantBaselineIdentifier() { return scaledBaselineTable.getDominantBaselineIdentifier(); } - + /** * Return the writing mode. * @return the writing mode @@ -302,7 +302,7 @@ public class AlignmentContext implements Constants { public int getWritingMode() { return scaledBaselineTable.getWritingMode(); } - + /** * Calculates the baseline shift value based on the baseline-shift * property value. @@ -392,11 +392,11 @@ public class AlignmentContext implements Constants { public int getTotalAlignmentBaselineOffset(int alignmentBaselineId) { int offset = baselineShiftValue; if (parentAlignmentContext != null) { - offset = parentAlignmentContext.getTotalBaselineOffset() + offset = parentAlignmentContext.getTotalBaselineOffset() + parentAlignmentContext.getScaledBaselineTable() .getBaseline(alignmentBaselineId) + baselineShiftValue; - } + } return offset; } @@ -432,7 +432,7 @@ public class AlignmentContext implements Constants { public int getHeight() { return areaHeight; } - + /** * Return the line height of the context. * @return the height @@ -440,7 +440,7 @@ public class AlignmentContext implements Constants { public int getLineHeight() { return lineHeight; } - + /** * The altitude of the context that is the height above the * alignment point. @@ -458,7 +458,7 @@ public class AlignmentContext implements Constants { public int getDepth() { return getHeight() - alignmentPoint; } - + /** * The x height of the context. * @return the x height @@ -466,7 +466,7 @@ public class AlignmentContext implements Constants { public int getXHeight() { return this.xHeight; } - + /** * Resizes the line as specified. Assumes that the new alignment point * is on the dominant baseline, that is this function should be called for @@ -480,7 +480,7 @@ public class AlignmentContext implements Constants { scaledBaselineTable.setBeforeAndAfterBaselines(alignmentPoint , alignmentPoint - areaHeight); } - + /** * Returns the offset from the before-edge of the parent to * this context. @@ -495,7 +495,7 @@ public class AlignmentContext implements Constants { } return offset; } - + /** * Returns an indication if we still use the initial baseline table. * The initial baseline table is the table generated by the Line LM. @@ -506,11 +506,11 @@ public class AlignmentContext implements Constants { || (scaledBaselineTable == parentAlignmentContext.getScaledBaselineTable() && parentAlignmentContext.usesInitialBaselineTable()); } - + private boolean isHorizontalWritingMode() { return (getWritingMode() == EN_LR_TB || getWritingMode() == EN_RL_TB); } - + /** {@inheritDoc} */ public String toString() { StringBuffer sb = new StringBuffer(64); @@ -521,5 +521,5 @@ public class AlignmentContext implements Constants { sb.append(" bs=" + baselineShiftValue); return sb.toString(); } - + } diff --git a/src/java/org/apache/fop/layoutmgr/inline/BasicLinkLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/BasicLinkLayoutManager.java index b8979e187..c369df82b 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/BasicLinkLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/BasicLinkLayoutManager.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/layoutmgr/inline/BasicScaledBaselineTable.java b/src/java/org/apache/fop/layoutmgr/inline/BasicScaledBaselineTable.java index 606500a56..73f414bf7 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/BasicScaledBaselineTable.java +++ b/src/java/org/apache/fop/layoutmgr/inline/BasicScaledBaselineTable.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,12 +44,12 @@ public class BasicScaledBaselineTable implements ScaledBaselineTable, Constants private int dominantBaselineOffset; private int beforeEdgeOffset; private int afterEdgeOffset; - + private static final float HANGING_BASELINE_FACTOR = 0.8f; private static final float MATHEMATICAL_BASELINE_FACTOR = 0.5f; /** - * + * * Creates a new instance of BasicScaledBaselineTable for the given * altitude, depth, xHeight, baseline and writingmode. * @param altitude the height of the box or the font ascender @@ -72,7 +72,7 @@ public class BasicScaledBaselineTable implements ScaledBaselineTable, Constants this.beforeEdgeOffset = altitude - dominantBaselineOffset; this.afterEdgeOffset = depth - dominantBaselineOffset; } - + /** * Return the dominant baseline for this baseline table. * @return the dominant baseline @@ -80,7 +80,7 @@ public class BasicScaledBaselineTable implements ScaledBaselineTable, Constants public int getDominantBaselineIdentifier() { return this.dominantBaselineIdentifier; } - + /** * Return the writing mode for this baseline table. * @return the writing mode @@ -132,11 +132,11 @@ public class BasicScaledBaselineTable implements ScaledBaselineTable, Constants } return offset; } - + private boolean isHorizontalWritingMode() { return writingMode == EN_LR_TB || writingMode == EN_RL_TB; } - + /** * Return the baseline offset measured from the font's default * baseline for the given baseline. @@ -171,9 +171,9 @@ public class BasicScaledBaselineTable implements ScaledBaselineTable, Constants } return offset; } - + /** - * {@inheritDoc} + * {@inheritDoc} */ public void setBeforeAndAfterBaselines(int beforeBaseline, int afterBaseline) { beforeEdgeOffset = beforeBaseline; @@ -184,7 +184,7 @@ public class BasicScaledBaselineTable implements ScaledBaselineTable, Constants * {@inheritDoc} */ public ScaledBaselineTable deriveScaledBaselineTable(int baselineIdentifier) { - BasicScaledBaselineTable bac + BasicScaledBaselineTable bac = new BasicScaledBaselineTable(altitude, depth, xHeight , baselineIdentifier, this.writingMode); return bac; diff --git a/src/java/org/apache/fop/layoutmgr/inline/BidiLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/BidiLayoutManager.java index f82cd7f41..d5b2e5803 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/BidiLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/BidiLayoutManager.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/layoutmgr/inline/CharacterLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java index c81a23a9c..383ca0105 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.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. @@ -57,10 +57,10 @@ public class CharacterLayoutManager extends LeafNodeLayoutManager { public CharacterLayoutManager(Character node) { super(node); } - + /** {@inheritDoc} */ public void initialize() { - Character fobj = (Character)this.fobj; + Character fobj = (Character)this.fobj; font = FontSelector.selectFontForCharacter(fobj, this); SpaceVal ls = SpaceVal.makeLetterSpacing(fobj.getLetterSpacing()); letterSpaceIPD = ls.getSpace(); @@ -101,7 +101,7 @@ public class CharacterLayoutManager extends LeafNodeLayoutManager { } Character fobj = (Character)this.fobj; - + ipd = new MinOptMax(font.getCharWidth(fobj.getCharacter())); curArea.setIPD(ipd.opt); @@ -120,7 +120,7 @@ public class CharacterLayoutManager extends LeafNodeLayoutManager { , context.getAlignmentContext()); addKnuthElementsForBorderPaddingStart(seq); - + // create the AreaInfo object to store the computed values areaInfo = new AreaInfo((short) 0, ipd, false, alignmentContext); diff --git a/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java index b43c4c841..a5247d652 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.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. @@ -176,7 +176,7 @@ public class ContentLayoutManager extends AbstractBaseLayoutManager return holder; } - /** + /** * {@inheritDoc} **/ public void addChildArea(Area childArea) { @@ -315,13 +315,13 @@ public class ContentLayoutManager extends AbstractBaseLayoutManager int alignment) { return null; } - + public PageSequenceLayoutManager getPSLM() { return parentLM.getPSLM(); } // --------- Property Resolution related functions --------- // - + /** * Returns the IPD of the content area * @return the IPD of the content area @@ -329,7 +329,7 @@ public class ContentLayoutManager extends AbstractBaseLayoutManager public int getContentAreaIPD() { return holder.getIPD(); } - + /** * Returns the BPD of the content area * @return the BPD of the content area @@ -337,7 +337,7 @@ public class ContentLayoutManager extends AbstractBaseLayoutManager public int getContentAreaBPD() { return holder.getBPD(); } - + /** * {@inheritDoc} */ @@ -351,7 +351,7 @@ public class ContentLayoutManager extends AbstractBaseLayoutManager public boolean getGeneratesBlockArea() { return getGeneratesLineArea() || holder instanceof Block; } - + /** * {@inheritDoc} */ @@ -365,6 +365,6 @@ public class ContentLayoutManager extends AbstractBaseLayoutManager public Position notifyPos(Position pos) { return pos; } - + } diff --git a/src/java/org/apache/fop/layoutmgr/inline/ExternalGraphicLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/ExternalGraphicLayoutManager.java index d7bff5a5c..2719d5c96 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/ExternalGraphicLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/ExternalGraphicLayoutManager.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,10 +28,10 @@ import org.apache.fop.fo.flow.ExternalGraphic; * LayoutManager for the fo:external-graphic formatting object */ public class ExternalGraphicLayoutManager extends AbstractGraphicsLayoutManager { - + /** * Constructor. - * + * * @param node * the fo:external-graphic formatting object that creates the * area @@ -44,6 +44,6 @@ public class ExternalGraphicLayoutManager extends AbstractGraphicsLayoutManager protected Area getChildArea() { return new Image(((ExternalGraphic) fobj).getSrc()); } - + } diff --git a/src/java/org/apache/fop/layoutmgr/inline/FootnoteLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/FootnoteLayoutManager.java index a02cfee89..2cdc7a6fc 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/FootnoteLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/FootnoteLayoutManager.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 FootnoteLayoutManager extends InlineStackingLayoutManager { super(node); footnote = node; } - + /** {@inheritDoc} */ public void initialize() { // create an InlineStackingLM handling the fo:inline child of fo:footnote @@ -120,7 +120,7 @@ public class FootnoteLayoutManager extends InlineStackingLayoutManager { } /** - * {@inheritDoc} + * {@inheritDoc} */ public List getChangedKnuthElements(List oldList, int alignment) { @@ -131,7 +131,7 @@ public class FootnoteLayoutManager extends InlineStackingLayoutManager { /** - * {@inheritDoc} + * {@inheritDoc} */ public void addAreas(PositionIterator posIter, LayoutContext context) { // "Unwrap" the NonLeafPositions stored in posIter and put @@ -144,11 +144,11 @@ public class FootnoteLayoutManager extends InlineStackingLayoutManager { positionList.add(pos.getPosition()); } } - - // FootnoteLM does not create any area, + + // FootnoteLM does not create any area, // so the citationLM child will add directly to the FootnoteLM parent area citationLM.setParent(getParent()); - + // make the citationLM add its areas LayoutContext childContext = new LayoutContext(context); StackingIter childPosIter = new StackingIter(positionList.listIterator()); diff --git a/src/java/org/apache/fop/layoutmgr/inline/HyphContext.java b/src/java/org/apache/fop/layoutmgr/inline/HyphContext.java index 3c438ee7e..881608e08 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/HyphContext.java +++ b/src/java/org/apache/fop/layoutmgr/inline/HyphContext.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.layoutmgr.inline; /** diff --git a/src/java/org/apache/fop/layoutmgr/inline/ICLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/ICLayoutManager.java index 7ca9e0d5e..c47a7e682 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/ICLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/ICLayoutManager.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/layoutmgr/inline/ImageLayout.java b/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java index 9f9339f44..bacf43dbc 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java +++ b/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.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,10 +35,10 @@ import org.apache.fop.fo.properties.LengthRangeProperty; * Helper class which calculates the size and position in the viewport of an image. */ public class ImageLayout implements Constants { - + /** logging instance */ protected static Log log = LogFactory.getLog(ImageLayout.class); - + //Input private GraphicsProperties props; private PercentBaseContext percentBaseContext; @@ -48,7 +48,7 @@ public class ImageLayout implements Constants { private Rectangle placement; private Dimension viewportSize = new Dimension(-1, -1); private boolean clip; - + /** * Main constructor * @param props the properties for the image @@ -60,7 +60,7 @@ public class ImageLayout implements Constants { this.props = props; this.percentBaseContext = percentBaseContext; this.intrinsicSize = intrinsicSize; - + doLayout(); } @@ -72,7 +72,7 @@ public class ImageLayout implements Constants { int bpd = -1; int ipd = -1; - + len = props.getBlockProgressionDimension().getOptimum(percentBaseContext).getLength(); if (len.getEnum() != EN_AUTO) { bpd = len.getValue(percentBaseContext); @@ -155,7 +155,7 @@ public class ImageLayout implements Constants { } else { constrainedIntrinsicSize = intrinsicSize; } - + //Derive content extents where not explicit Dimension adjustedDim = adjustContentSize(cwidth, cheight, constrainedIntrinsicSize); cwidth = adjustedDim.width; @@ -190,10 +190,10 @@ public class ImageLayout implements Constants { this.viewportSize.setSize(ipd, bpd); this.placement = new Rectangle(xoffset, yoffset, cwidth, cheight); } - + private int constrainExtent(int extent, LengthRangeProperty range, Length contextExtent) { - boolean mayScaleUp = (contextExtent.getEnum() != EN_SCALE_DOWN_TO_FIT); - boolean mayScaleDown = (contextExtent.getEnum() != EN_SCALE_UP_TO_FIT); + boolean mayScaleUp = (contextExtent.getEnum() != EN_SCALE_DOWN_TO_FIT); + boolean mayScaleDown = (contextExtent.getEnum() != EN_SCALE_UP_TO_FIT); Length len; len = range.getMaximum(percentBaseContext).getLength(); if (len.getEnum() != EN_AUTO) { @@ -211,7 +211,7 @@ public class ImageLayout implements Constants { } return extent; } - + private Dimension constrain(Dimension size) { Dimension adjusted = new Dimension(size); int effWidth = constrainExtent(size.width, @@ -235,7 +235,7 @@ public class ImageLayout implements Constants { } return adjusted; } - + private Dimension adjustContentSize( final int cwidth, final int cheight, Dimension defaultSize) { @@ -249,14 +249,14 @@ public class ImageLayout implements Constants { if (defaultSize.height == 0) { dim.width = 0; } else { - dim.width = (int)(defaultSize.width * (double)cheight + dim.width = (int)(defaultSize.width * (double)cheight / defaultSize.height); } } else if (cheight == -1) { if (defaultSize.width == 0) { dim.height = 0; } else { - dim.height = (int)(defaultSize.height * (double)cwidth + dim.height = (int)(defaultSize.height * (double)cwidth / defaultSize.width); } } else { @@ -278,7 +278,7 @@ public class ImageLayout implements Constants { } return dim; } - + /** * Given the ipd and the content width calculates the * required x offset based on the text-align property @@ -336,7 +336,7 @@ public class ImageLayout implements Constants { public Rectangle getPlacement() { return this.placement; } - + /** * Returns the size of the image's viewport. * @return the viewport size (in millipoints) @@ -344,7 +344,7 @@ public class ImageLayout implements Constants { public Dimension getViewportSize() { return this.viewportSize; } - + /** * Returns the size of the image's intrinsic (natural) size. * @return the intrinsic size (in millipoints) @@ -352,7 +352,7 @@ public class ImageLayout implements Constants { public Dimension getIntrinsicSize() { return this.intrinsicSize; } - + /** * Indicates whether the image is clipped. * @return true if the image shall be clipped @@ -360,5 +360,5 @@ public class ImageLayout implements Constants { public boolean isClipped() { return this.clip; } - + } \ No newline at end of file diff --git a/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java index 589fb2645..0c332281f 100755 --- a/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.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. @@ -92,7 +92,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { protected SpaceProperty lineHeight; /** The keep-together property */ //private KeepProperty keepTogether; - + private AlignmentContext alignmentContext = null; /** @@ -106,26 +106,26 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { public InlineLayoutManager(InlineLevel node) { super(node); } - + private Inline getInlineFO() { return (Inline) fobj; } - + /** {@inheritDoc} */ public void initialize() { InlineLevel fobj = (InlineLevel) this.fobj; int padding = 0; - + FontInfo fi = fobj.getFOEventHandler().getFontInfo(); CommonFont commonFont = fobj.getCommonFont(); FontTriplet[] fontkeys = commonFont.getFontState(fi); font = fi.getFontInstance(fontkeys[0], commonFont.fontSize.getValue(this)); - + lineHeight = fobj.getLineHeight(); borderProps = fobj.getCommonBorderPaddingBackground(); inlineProps = fobj.getCommonMarginInline(); - + if (fobj instanceof Inline) { alignmentAdjust = ((Inline)fobj).getAlignmentAdjust(); alignmentBaseline = ((Inline)fobj).getAlignmentBaseline(); @@ -152,13 +152,13 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { protected MinOptMax getExtraIPD(boolean isNotFirst, boolean isNotLast) { int borderAndPadding = 0; if (borderProps != null) { - borderAndPadding + borderAndPadding = borderProps.getPadding(CommonBorderPaddingBackground.START, isNotFirst, this); - borderAndPadding + borderAndPadding += borderProps.getBorderWidth(CommonBorderPaddingBackground.START, isNotFirst); - borderAndPadding + borderAndPadding += borderProps.getPadding(CommonBorderPaddingBackground.END, isNotLast, this); - borderAndPadding + borderAndPadding += borderProps.getBorderWidth(CommonBorderPaddingBackground.END, isNotLast); } return new MinOptMax(borderAndPadding); @@ -189,11 +189,11 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { protected SpaceProperty getSpaceEnd() { return inlineProps != null ? inlineProps.spaceEnd : null; } - - /** - * Create and initialize an InlineArea - * - * @param hasInlineParent true if the parent is an inline + + /** + * Create and initialize an InlineArea + * + * @param hasInlineParent true if the parent is an inline * @return the area */ protected InlineArea createArea(boolean hasInlineParent) { @@ -209,7 +209,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { } return area; } - + /** {@inheritDoc} */ protected void setTraits(boolean isNotFirst, boolean isNotLast) { if (borderProps != null) { @@ -232,7 +232,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { return ((BlockLevelLayoutManager) lm).mustKeepTogether(); } else if (lm instanceof InlineLayoutManager) { return ((InlineLayoutManager) lm).mustKeepTogether(); - } else { + } else { return mustKeepTogether(lm.getParent()); } } @@ -249,12 +249,12 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { KnuthSequence lastSequence = null; SpaceSpecifier leadingSpace = context.getLeadingSpace(); - + if (fobj instanceof Title) { alignmentContext = new AlignmentContext(font, lineHeight.getOptimum(this).getLength().getValue(this), context.getWritingMode()); - + } else { alignmentContext = new AlignmentContext(font , lineHeight.getOptimum(this).getLength().getValue(this) @@ -264,7 +264,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { , dominantBaseline , context.getAlignmentContext()); } - + childLC = new LayoutContext(context); childLC.setAlignmentContext(alignmentContext); @@ -300,9 +300,9 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { + borderProps.getBorderEndWidth(true) ); } - + while ((curLM = getChildLM()) != null) { - + if (!(curLM instanceof InlineLevelLayoutManager)) { // A block LM // Leave room for start/end border and padding @@ -314,7 +314,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { - borderProps.getBorderEndWidth(hasNextChildLM())); } } - + // get KnuthElements from curLM returnedList = curLM.getNextKnuthElements(childLC, alignment); if (returnList.isEmpty() && childLC.isKeepWithPreviousPending()) { @@ -326,7 +326,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { // just iterate once more to see if there is another child continue; } - + if (curLM instanceof InlineLevelLayoutManager) { context.clearKeepWithNextPending(); // "wrap" the Position stored in each element of returnedList @@ -375,31 +375,31 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { lastSequence = (KnuthSequence) ListUtil.getLast(returnList); lastChildLM = curLM; } - + if (lastSequence != null) { addKnuthElementsForBorderPaddingEnd(lastSequence); } setFinished(true); log.trace(trace); - + if (returnList.isEmpty()) { /* - * if the FO itself is empty, but has an id specified + * if the FO itself is empty, but has an id specified * or associated fo:markers, then we still need a dummy * sequence to register its position in the area tree */ if (fobj.hasId() || fobj.hasMarkers()) { InlineKnuthSequence emptySeq = new InlineKnuthSequence(); emptySeq.add(new KnuthInlineBox( - 0, - alignmentContext, - notifyPos(getAuxiliaryPosition()), + 0, + alignmentContext, + notifyPos(getAuxiliaryPosition()), true)); returnList.add(emptySeq); } } - + return returnList.isEmpty() ? null : returnList; } @@ -414,7 +414,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { */ public void addAreas(PositionIterator parentIter, LayoutContext context) { - + addId(); setChildContext(new LayoutContext(context)); // Store current value @@ -454,11 +454,11 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { }*/ addMarkersToPage( - true, - !areaCreated, + true, + !areaCreated, lastPos == null || isLast(lastPos)); - - InlineArea parent = createArea(lastLM == null + + InlineArea parent = createArea(lastLM == null || lastLM instanceof InlineLevelLayoutManager); parent.setBPD(alignmentContext.getHeight()); if (parent instanceof InlineParent) { @@ -472,7 +472,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { } } setCurrentArea(parent); - + StackingIter childPosIter = new StackingIter(positionList.listIterator()); @@ -487,7 +487,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { prevLM = childLM; } - + /* If this LM has a trailing fence, resolve trailing space * specs from descendants. Otherwise, propagate any trailing * space specs to the parent LM via the layout context. If @@ -496,7 +496,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { * must be the last area for the current LM too. */ boolean isLast = (getContext().isLastArea() && prevLM == lastChildLM); - + if (hasTrailingFence(isLast)) { addSpace(getCurrentArea(), getContext().getTrailingSpace().resolve(false), @@ -510,17 +510,17 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { if (context.getTrailingSpace() != null && getSpaceEnd() != null) { context.getTrailingSpace().addSpace(new SpaceVal(getSpaceEnd(), this)); } - + // Not sure if lastPos can legally be null or if that masks a different problem. // But it seems to fix bug 38053. setTraits(areaCreated, lastPos == null || !isLast(lastPos)); parentLM.addChildArea(getCurrentArea()); addMarkersToPage( - false, - !areaCreated, + false, + !areaCreated, lastPos == null || isLast(lastPos)); - + context.setFlags(LayoutContext.LAST_AREA, isLast); areaCreated = true; checkEndOfLayout(lastPos); @@ -545,7 +545,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { addKnuthElementsForBorderPaddingEnd(returnedList); return returnedList; } - + /** * Creates Knuth elements for start border padding and adds them to the return list. * @param returnList return list to add the additional elements to @@ -604,5 +604,5 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { //} return this.auxiliaryPosition; } - + } diff --git a/src/java/org/apache/fop/layoutmgr/inline/InlineLevelEventProducer.java b/src/java/org/apache/fop/layoutmgr/inline/InlineLevelEventProducer.java index 51d2720cb..c9c65e769 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/InlineLevelEventProducer.java +++ b/src/java/org/apache/fop/layoutmgr/inline/InlineLevelEventProducer.java @@ -33,7 +33,7 @@ public interface InlineLevelEventProducer extends EventProducer { * Provider class for the event producer. */ class Provider { - + /** * Returns an event producer. * @param broadcaster the event broadcaster to use @@ -52,7 +52,7 @@ public interface InlineLevelEventProducer extends EventProducer { * @event.severity ERROR */ void leaderWithoutContent(Object source, Locator loc); - + /** * A line overflows. * @param source the event source @@ -62,5 +62,5 @@ public interface InlineLevelEventProducer extends EventProducer { * @event.severity WARN */ void lineOverflows(Object source, int line, int overflowLength, Locator loc); - + } diff --git a/src/java/org/apache/fop/layoutmgr/inline/InlineLevelLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/InlineLevelLayoutManager.java index 80a74ffc4..b080f926b 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/InlineLevelLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/InlineLevelLayoutManager.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.layoutmgr.inline; import java.util.List; @@ -30,7 +30,7 @@ import org.apache.fop.layoutmgr.Position; public interface InlineLevelLayoutManager extends LayoutManager { /** - * Tell the LM to modify its data, adding a letter space + * Tell the LM to modify its data, adding a letter space * to the word fragment represented by the given elements, * and returning the corrected elements * @@ -40,7 +40,7 @@ public interface InlineLevelLayoutManager extends LayoutManager { List addALetterSpaceTo(List oldList); /** - * Tell the LM to modify its data, removing the word space + * Tell the LM to modify its data, removing the word space * represented by the given elements * * @param oldList the elements representing the word space diff --git a/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java index 81fc7901d..a27fc6516 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.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. @@ -43,7 +43,7 @@ import org.apache.fop.traits.MinOptMax; * which stack children in the inline direction, such as Inline or * Line. It should not be instantiated directly. */ -public abstract class InlineStackingLayoutManager extends AbstractLayoutManager +public abstract class InlineStackingLayoutManager extends AbstractLayoutManager implements InlineLevelLayoutManager { @@ -103,7 +103,7 @@ public abstract class InlineStackingLayoutManager extends AbstractLayoutManager } /** - * Returns the extra IPD needed for any leading or trailing fences for the + * Returns the extra IPD needed for any leading or trailing fences for the * current area. * @param bNotFirst true if not the first area for this layout manager * @param bNotLast true if not the last area for this layout manager @@ -139,7 +139,7 @@ public abstract class InlineStackingLayoutManager extends AbstractLayoutManager protected SpaceProperty getSpaceStart() { return null; } - + /** * Get the space at the end of the inline area. * @return the space property describing the space @@ -246,7 +246,7 @@ public abstract class InlineStackingLayoutManager extends AbstractLayoutManager // The last element may not have a layout manager (its position == null); // this may happen if it is a padding box; see bug 39571. - InlineLevelLayoutManager LM = + InlineLevelLayoutManager LM = (InlineLevelLayoutManager) element.getLayoutManager(); if (LM != null) { oldList = LM.addALetterSpaceTo(oldList); @@ -362,7 +362,7 @@ public abstract class InlineStackingLayoutManager extends AbstractLayoutManager } /** - * {@inheritDoc} + * {@inheritDoc} */ public List getChangedKnuthElements(List oldList, int alignment) { // "unwrap" the Positions stored in the elements diff --git a/src/java/org/apache/fop/layoutmgr/inline/InstreamForeignObjectLM.java b/src/java/org/apache/fop/layoutmgr/inline/InstreamForeignObjectLM.java index 5f9365f83..4a54f582d 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/InstreamForeignObjectLM.java +++ b/src/java/org/apache/fop/layoutmgr/inline/InstreamForeignObjectLM.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,10 +28,10 @@ import org.apache.fop.fo.flow.InstreamForeignObject; * LayoutManager for the fo:instream-foreign-object formatting object */ public class InstreamForeignObjectLM extends AbstractGraphicsLayoutManager { - + /** * Constructor. - * + * * @param node * the formatting object that creates this area */ @@ -48,6 +48,6 @@ public class InstreamForeignObjectLM extends AbstractGraphicsLayoutManager { return new ForeignObject(doc, ns); } - + } diff --git a/src/java/org/apache/fop/layoutmgr/inline/KnuthInlineBox.java b/src/java/org/apache/fop/layoutmgr/inline/KnuthInlineBox.java index 856fab051..6c8c7354b 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/KnuthInlineBox.java +++ b/src/java/org/apache/fop/layoutmgr/inline/KnuthInlineBox.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. @@ -25,7 +25,7 @@ import org.apache.fop.layoutmgr.KnuthBox; import org.apache.fop.layoutmgr.Position; public class KnuthInlineBox extends KnuthBox { - + private FootnoteBodyLayoutManager footnoteBodyLM = null; private AlignmentContext alignmentContext = null; @@ -69,8 +69,8 @@ public class KnuthInlineBox extends KnuthBox { public boolean isAnchor() { return (footnoteBodyLM != null); } - - + + /** {@inheritDoc} */ public String toString() { StringBuffer sb = new StringBuffer(super.toString()); diff --git a/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java index 3bb82aa11..1e163bef8 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.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,10 +51,10 @@ import org.apache.fop.traits.MinOptMax; public class LeaderLayoutManager extends LeafNodeLayoutManager { private Leader fobj; private Font font = null; - + private List contentList = null; private ContentLayoutManager clm = null; - + private int contentAreaIPD = 0; /** @@ -66,7 +66,7 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager { super(node); fobj = node; } - + /** {@inheritDoc} */ public void initialize() { FontInfo fi = fobj.getFOEventHandler().getFontInfo(); @@ -117,7 +117,7 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager { if (fobj.getLeaderPattern() == EN_RULE) { if (fobj.getRuleStyle() != EN_NONE) { - org.apache.fop.area.inline.Leader leader + org.apache.fop.area.inline.Leader leader = new org.apache.fop.area.inline.Leader(); leader.setRuleStyle(fobj.getRuleStyle()); leader.setRuleThickness(fobj.getRuleThickness().getValue(this)); @@ -167,7 +167,7 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager { // child FOs are assigned to the InlineStackingLM fobjIter = null; - + // get breaks then add areas to FilledArea FilledArea fa = new FilledArea(); @@ -262,7 +262,7 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager { curArea.setAdjustingInfo(ipd.max - ipd.opt, ipd.opt - ipd.min, 0); addKnuthElementsForBorderPaddingStart(seq); - + // node is a fo:Leader seq.add(new KnuthInlineBox(0, alignmentContext, new LeafPosition(this, -1), true)); @@ -272,20 +272,20 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager { seq.add (new KnuthGlue(areaInfo.ipdArea.opt, areaInfo.ipdArea.max - areaInfo.ipdArea.opt, - areaInfo.ipdArea.opt - areaInfo.ipdArea.min, + areaInfo.ipdArea.opt - areaInfo.ipdArea.min, new LeafPosition(this, 0), false)); } else { seq.add (new KnuthGlue(areaInfo.ipdArea.opt, 0, - 0, + 0, new LeafPosition(this, 0), false)); } seq.add(new KnuthInlineBox(0, alignmentContext, new LeafPosition(this, -1), true)); addKnuthElementsForBorderPaddingEnd(seq); - + LinkedList returnList = new LinkedList(); returnList.add(seq); setFinished(true); @@ -314,7 +314,7 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager { List returnList = new LinkedList(); addKnuthElementsForBorderPaddingStart(returnList); - + returnList.add(new KnuthInlineBox(0, areaInfo.alignmentContext, new LeafPosition(this, -1), true)); returnList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, @@ -323,20 +323,20 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager { returnList.add (new KnuthGlue(areaInfo.ipdArea.opt, areaInfo.ipdArea.max - areaInfo.ipdArea.opt, - areaInfo.ipdArea.opt - areaInfo.ipdArea.min, + areaInfo.ipdArea.opt - areaInfo.ipdArea.min, new LeafPosition(this, 0), false)); } else { returnList.add (new KnuthGlue(areaInfo.ipdArea.opt, 0, - 0, + 0, new LeafPosition(this, 0), false)); } returnList.add(new KnuthInlineBox(0, areaInfo.alignmentContext, new LeafPosition(this, -1), true)); addKnuthElementsForBorderPaddingEnd(returnList); - + setFinished(true); return returnList; } @@ -353,9 +353,9 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager { public int getContentAreaIPD() { return contentAreaIPD; } - + private void setContentAreaIPD(int contentAreaIPD) { this.contentAreaIPD = contentAreaIPD; } - + } diff --git a/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java index 19a8cdf2d..ac501abb7 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.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 @@ import org.apache.fop.traits.MinOptMax; * This class can be extended to handle the creation and adding of the * inline area. */ -public abstract class LeafNodeLayoutManager extends AbstractLayoutManager +public abstract class LeafNodeLayoutManager extends AbstractLayoutManager implements InlineLevelLayoutManager { /** @@ -64,7 +64,7 @@ public abstract class LeafNodeLayoutManager extends AbstractLayoutManager protected CommonBorderPaddingBackground commonBorderPaddingBackground = null; /** The alignment context applying to this area */ protected AlignmentContext alignmentContext = null; - + /** Flag to indicate if something was changed as part of the getChangeKnuthElements sequence */ protected boolean isSomethingChanged = false; /** Our area info for the Knuth elements */ @@ -86,7 +86,7 @@ public abstract class LeafNodeLayoutManager extends AbstractLayoutManager bHyphenated = bHyph; this.alignmentContext = alignmentContext; } - + } @@ -201,7 +201,7 @@ public abstract class LeafNodeLayoutManager extends AbstractLayoutManager protected InlineArea getEffectiveArea() { return curArea; } - + /** * Offset this area. * Offset the inline area in the bpd direction when adding the @@ -247,18 +247,18 @@ public abstract class LeafNodeLayoutManager extends AbstractLayoutManager area.setIPD(width); area.setAdjustment(width - areaInfo.ipdArea.opt); } - + /** {@inheritDoc} */ public List getNextKnuthElements(LayoutContext context, int alignment) { curArea = get(context); - + if (curArea == null) { setFinished(true); return null; } alignmentContext = makeAlignmentContext(context); - + MinOptMax ipd = getAllocationIPD(context.getRefIPD()); // create the AreaInfo object to store the computed values @@ -269,12 +269,12 @@ public abstract class LeafNodeLayoutManager extends AbstractLayoutManager KnuthSequence seq = new InlineKnuthSequence(); addKnuthElementsForBorderPaddingStart(seq); - + seq.add(new KnuthInlineBox(areaInfo.ipdArea.opt, alignmentContext, notifyPos(new LeafPosition(this, 0)), false)); addKnuthElementsForBorderPaddingEnd(seq); - + LinkedList returnList = new LinkedList(); returnList.add(seq); @@ -322,18 +322,18 @@ public abstract class LeafNodeLayoutManager extends AbstractLayoutManager LinkedList returnList = new LinkedList(); addKnuthElementsForBorderPaddingStart(returnList); - + // fobj is a fo:ExternalGraphic, fo:InstreamForeignObject, // fo:PageNumber or fo:PageNumberCitation - returnList.add(new KnuthInlineBox(areaInfo.ipdArea.opt, areaInfo.alignmentContext, + returnList.add(new KnuthInlineBox(areaInfo.ipdArea.opt, areaInfo.alignmentContext, notifyPos(new LeafPosition(this, 0)), true)); addKnuthElementsForBorderPaddingEnd(returnList); - + setFinished(true); return returnList; } - + /** * Creates Knuth elements for start border padding and adds them to the return list. * @param returnList return list to add the additional elements to @@ -345,7 +345,7 @@ public abstract class LeafNodeLayoutManager extends AbstractLayoutManager + commonBorderPaddingBackground.getPaddingStart(false, this); if (ipStart > 0) { // Add a non breakable glue - returnList.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, + returnList.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false, new LeafPosition(this, -1), true)); returnList.add(new KnuthGlue(ipStart, 0, 0, new LeafPosition(this, -1), true)); } diff --git a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java index 87077ee77..3a0672f4e 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.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. @@ -75,7 +75,7 @@ import org.apache.fop.traits.MinOptMax; * creates a line area to contain the inline areas added by the * child layout managers. */ -public class LineLayoutManager extends InlineStackingLayoutManager +public class LineLayoutManager extends InlineStackingLayoutManager implements BlockLevelLayoutManager { /** @@ -85,7 +85,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager private Block fobj; private boolean isFirstInBlock; - + /** {@inheritDoc} */ public void initialize() { textAlignment = fobj.getTextAlign(); @@ -108,7 +108,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager return textAlignment; } } - + /** * Private class to store information about inline breaks. * Each value holds the start and end indexes into a List of @@ -148,7 +148,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager spaceAfter = sa; baseline = bl; } - + } @@ -181,7 +181,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager /** * this constant is used to create elements when text-align is center: - * every TextLM descendant of LineLM must use the same value, + * every TextLM descendant of LineLM must use the same value, * otherwise the line breaking algorithm does not find the right * break point */ @@ -205,7 +205,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager // this class represents a paragraph private class Paragraph extends InlineKnuthSequence { - /** Number of elements to ignore at the beginning of the list. */ + /** Number of elements to ignore at the beginning of the list. */ private int ignoreAtStart = 0; /** Number of elements to ignore at the end of the list. */ private int ignoreAtEnd = 0; @@ -233,11 +233,11 @@ public class LineLayoutManager extends InlineStackingLayoutManager // set the minimum amount of empty space at the end of the // last line if (textAlignment == EN_CENTER) { - lineFiller = new MinOptMax(lastLineEndIndent); + lineFiller = new MinOptMax(lastLineEndIndent); } else { - lineFiller = new MinOptMax(lastLineEndIndent, - lastLineEndIndent, - layoutManager.iLineWidth); + lineFiller = new MinOptMax(lastLineEndIndent, + lastLineEndIndent, + layoutManager.iLineWidth); } // add auxiliary elements at the beginning of the paragraph @@ -251,7 +251,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager // at the beginning of the first paragraph if (isFirstInBlock && knuthParagraphs.size() == 0 && textIndent != 0) { - this.add(new KnuthInlineBox(textIndent, null, + this.add(new KnuthInlineBox(textIndent, null, null, false)); ignoreAtStart++; } @@ -277,10 +277,10 @@ public class LineLayoutManager extends InlineStackingLayoutManager // add the elements representing the space // at the end of the last line // and the forced break - this.add(new KnuthPenalty(0, KnuthElement.INFINITE, + this.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, null, false)); - this.add(new KnuthGlue(0, - lineFiller.max - lineFiller.opt, + this.add(new KnuthGlue(0, + lineFiller.max - lineFiller.opt, lineFiller.opt - lineFiller.min, null, false)); this.add(new KnuthPenalty(lineFiller.opt, -KnuthElement.INFINITE, false, null, false)); @@ -339,7 +339,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager follow = fl; thisLLM = llm; activePossibility = -1; - maxDiff = fobj.getWidows() >= fobj.getOrphans() + maxDiff = fobj.getWidows() >= fobj.getOrphans() ? fobj.getWidows() : fobj.getOrphans(); } @@ -382,7 +382,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager } if (log.isWarnEnabled()) { - int lack = difference + bestActiveNode.availableShrink; + int lack = difference + bestActiveNode.availableShrink; if (lack < 0) { InlineLevelEventProducer eventProducer = InlineLevelEventProducer.Provider.get( @@ -391,15 +391,15 @@ public class LineLayoutManager extends InlineStackingLayoutManager -lack, getFObj().getLocator()); } } - - //log.debug("LLM> (" + (lineLayouts.getLineNumber(activePossibility) - addedPositions) + + //log.debug("LLM> (" + (lineLayouts.getLineNumber(activePossibility) - addedPositions) // + ") difference = " + difference + " ratio = " + ratio); lineLayouts.addBreakPosition(makeLineBreakPosition(par, (bestActiveNode.line > 1 ? bestActiveNode.previous.position + 1 : 0), bestActiveNode.position, - bestActiveNode.availableShrink - (addedPositions > 0 - ? 0 : ((Paragraph)par).lineFiller.opt - ((Paragraph)par).lineFiller.min), - bestActiveNode.availableStretch, + bestActiveNode.availableShrink - (addedPositions > 0 + ? 0 : ((Paragraph)par).lineFiller.opt - ((Paragraph)par).lineFiller.min), + bestActiveNode.availableStretch, difference, ratio, indent), activePossibility); addedPositions++; } @@ -413,8 +413,8 @@ public class LineLayoutManager extends InlineStackingLayoutManager private LineBreakPosition makeLineBreakPosition(KnuthSequence par, int firstElementIndex, int lastElementIndex, - int availableShrink, - int availableStretch, + int availableShrink, + int availableStretch, int difference, double ratio, int indent) { @@ -424,7 +424,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager int spaceAfter = lineHeight - lead - follow - spaceBefore; // height before the main baseline int lineLead = lead; - // maximum follow + // maximum follow int lineFollow = follow; // true if this line contains only zero-height, auxiliary boxes // and the actual line width is 0; in this case, the line "collapses" @@ -492,7 +492,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager firstElementIndex, lastElementIndex, availableShrink, availableStretch, difference, ratio, 0, indent, - lineLead + lineFollow, + lineLead + lineFollow, iLineWidth, spaceBefore, spaceAfter, lineLead); } @@ -501,7 +501,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager public int findBreakingPoints(Paragraph par, /*int lineWidth,*/ double threshold, boolean force, int allowedBreaks) { - return super.findBreakingPoints(par, /*lineWidth,*/ + return super.findBreakingPoints(par, /*lineWidth,*/ threshold, force, allowedBreaks); } @@ -548,9 +548,9 @@ public class LineLayoutManager extends InlineStackingLayoutManager } } - + private int constantLineHeight = 12000; - + /** * Create a new Line Layout Manager. @@ -641,19 +641,19 @@ public class LineLayoutManager extends InlineStackingLayoutManager */ private void collectInlineKnuthElements(LayoutContext context) { LayoutContext inlineLC = new LayoutContext(context); - + InlineLevelLayoutManager curLM; List returnedList = null; iLineWidth = context.getStackLimitIP().opt; - + // convert all the text in a sequence of paragraphs made // of KnuthBox, KnuthGlue and KnuthPenalty objects boolean bPrevWasKnuthBox = false; - + StringBuffer trace = new StringBuffer("LineLM:"); - + Paragraph lastPar = null; - + while ((curLM = (InlineLevelLayoutManager) getChildLM()) != null) { returnedList = curLM.getNextKnuthElements(inlineLC, effectiveAlignment); if (returnedList == null @@ -663,10 +663,10 @@ public class LineLayoutManager extends InlineStackingLayoutManager * so just iterate once more to see if there are other children */ continue; } - + if (lastPar != null) { KnuthSequence firstSeq = (KnuthSequence) returnedList.get(0); - + // finish last paragraph before a new block sequence if (!firstSeq.isInlineSequence()) { lastPar.endParagraph(); @@ -677,7 +677,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager } bPrevWasKnuthBox = false; } - + // does the first element of the first paragraph add to an existing word? if (lastPar != null) { KnuthElement thisElement; @@ -688,28 +688,28 @@ public class LineLayoutManager extends InlineStackingLayoutManager } } } - + // loop over the KnuthSequences (and single KnuthElements) in returnedList ListIterator iter = returnedList.listIterator(); while (iter.hasNext()) { KnuthSequence sequence = (KnuthSequence) iter.next(); // the sequence contains inline Knuth elements if (sequence.isInlineSequence()) { - // look at the last element + // look at the last element ListElement lastElement = sequence.getLast(); if (lastElement == null) { throw new NullPointerException( "Sequence was empty! lastElement is null"); } - bPrevWasKnuthBox = lastElement.isBox() - && !((KnuthElement) lastElement).isAuxiliary() + bPrevWasKnuthBox = lastElement.isBox() + && !((KnuthElement) lastElement).isAuxiliary() && ((KnuthElement) lastElement).getW() != 0; - + // if last paragraph is open, add the new elements to the paragraph // else this is the last paragraph - if (lastPar == null) { - lastPar = new Paragraph(this, - textAlignment, textAlignmentLast, + if (lastPar == null) { + lastPar = new Paragraph(this, + textAlignment, textAlignmentLast, textIndent.getValue(this), lastLineEndIndent.getValue(this)); lastPar.startSequence(); @@ -725,7 +725,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager if (log.isTraceEnabled()) { trace.append(" I"); } - + // finish last paragraph if it was closed with a linefeed if (lastElement.isPenalty() && ((KnuthPenalty) lastElement).getP() @@ -735,7 +735,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager // which forces a line break lastPar.removeLast(); if (!lastPar.containsBox()) { - //only a forced linefeed on this line + //only a forced linefeed on this line //-> compensate with an auxiliary glue lastPar.add(new KnuthGlue(iLineWidth, 0, iLineWidth, null, true)); } @@ -765,11 +765,11 @@ public class LineLayoutManager extends InlineStackingLayoutManager } log.trace(trace); } - + /** * Find a set of breaking points. - * This method is called only once by getNextBreakPoss, and it - * subsequently calls the other findBreakingPoints() method with + * This method is called only once by getNextBreakPoss, and it + * subsequently calls the other findBreakingPoints() method with * different parameters, until a set of breaking points is found. * * @param par the list of elements that must be parted @@ -805,7 +805,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager } } } - + private boolean findBreakingPoints(Paragraph par, int lineWidth, double threshold, boolean force) { KnuthParagraph knuthPara = new KnuthParagraph(par); @@ -813,11 +813,11 @@ public class LineLayoutManager extends InlineStackingLayoutManager if (lines == 0) { return false; } - + for (int i = lines-1; i >= 0; i--) { int line = i+1; if (log.isTraceEnabled()) { - log.trace("Making line from " + knuthPara.getStart(i) + " to " + + log.trace("Making line from " + knuthPara.getStart(i) + " to " + knuthPara.getEnd(i)); } // compute indent and adjustment ratio, according to @@ -826,7 +826,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager int difference = knuthPara.getDifference(i); if (line == lines) { difference += par.lineFillerWidth; - } + } int textAlign = (line < lines) ? textAlignment : textAlignmentLast; int indent = (textAlign == EN_CENTER) @@ -841,7 +841,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager int end = knuthPara.getEnd(i); makeLineBreakPosition(par, start, end, 0, ratio, indent); } - return true; + return true; } private void makeLineBreakPosition(Paragraph par, @@ -893,7 +893,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager lineLead)); }*/ - + /** * Phase 2 of Knuth algorithm: find optimal break points. * @param alignment alignment in BP direction of the paragraph @@ -918,9 +918,9 @@ public class LineLayoutManager extends InlineStackingLayoutManager } lineLayoutsList.add(0, llPoss); } - + setFinished(true); - + //Post-process the line breaks found return postProcessLineBreaks(alignment, context); } @@ -944,12 +944,12 @@ public class LineLayoutManager extends InlineStackingLayoutManager hyphenationLadderCount.getEnum() == EN_NO_LIMIT ? 0 : hyphenationLadderCount.getValue(), this); - - if (hyphenationProperties.hyphenate.getEnum() == EN_TRUE + + if (hyphenationProperties.hyphenate.getEnum() == EN_TRUE && fobj.getWrapOption() != EN_NO_WRAP) { findHyphenationPoints(currPar); } - + // first try int allowedBreaks; if (wrapOption == EN_NO_WRAP) { @@ -969,7 +969,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager // the first try failed log.debug("No set of breaking points found with maxAdjustment = " + maxAdjustment); } - + // now try something different log.debug("Hyphenation possible? " + (hyphenationProperties.hyphenate.getEnum() == EN_TRUE)); if (hyphenationProperties.hyphenate.getEnum() == EN_TRUE @@ -980,7 +980,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager // try with a higher threshold maxAdjustment = 5; } - + if ((iBPcount = alg.findBreakingPoints(currPar, maxAdjustment, false, allowedBreaks)) == 0) { @@ -998,12 +998,12 @@ public class LineLayoutManager extends InlineStackingLayoutManager = alg.findBreakingPoints(currPar, maxAdjustment, true, allowedBreaks); } - + // use non-hyphenated breaks, when possible lineLayouts.restorePossibilities(); - + /* extension (not in the XSL FO recommendation): if vertical alignment - is justify and the paragraph has only one layout, try using + is justify and the paragraph has only one layout, try using shorter or longer lines */ //TODO This code snippet is disabled. Reenable? if (false && alignment == EN_JUSTIFY && textAlignment == EN_JUSTIFY) { @@ -1048,9 +1048,9 @@ public class LineLayoutManager extends InlineStackingLayoutManager * @return the newly built element list */ private List postProcessLineBreaks(int alignment, LayoutContext context) { - + List returnList = new LinkedList(); - + for (int p = 0; p < knuthParagraphs.size(); p++) { // penalty between paragraphs if (p > 0) { @@ -1061,7 +1061,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager new Position(this), penalty, context)); } } - + LineLayoutPossibilities llPoss; llPoss = (LineLayoutPossibilities) lineLayoutsList.get(p); KnuthSequence seq = (KnuthSequence) knuthParagraphs.get(p); @@ -1078,10 +1078,10 @@ public class LineLayoutManager extends InlineStackingLayoutManager } targetList.add(tempElement); } - returnList.addAll(targetList); + returnList.addAll(targetList); } else if (seq.isInlineSequence() && alignment == EN_JUSTIFY) { /* justified vertical alignment (not in the XSL FO recommendation): - create a multi-layout sequence whose elements will contain + create a multi-layout sequence whose elements will contain a conventional Position */ Position returnPosition = new LeafPosition(this, p); createElements(returnList, llPoss, returnPosition); @@ -1107,7 +1107,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager } int endIndex = ((LineBreakPosition) llPoss.getChosenPosition(i)).getLeafPos(); - // create a list of the FootnoteBodyLM handling footnotes + // create a list of the FootnoteBodyLM handling footnotes // whose citations are in this line List footnoteList = new LinkedList(); ListIterator elementIterator = seq.listIterator(startIndex); @@ -1138,7 +1138,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager } } } - + return returnList; } @@ -1286,7 +1286,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager public int getKeepTogetherStrength() { return ((BlockLevelLayoutManager) getParent()).getKeepTogetherStrength(); } - + /** {@inheritDoc} */ public boolean mustKeepWithPrevious() { return getKeepWithPreviousStrength() > KEEP_AUTO; @@ -1306,7 +1306,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager public int getKeepWithPreviousStrength() { return KEEP_AUTO; } - + /** {@inheritDoc} */ public int negotiateBPDAdjustment(int adj, KnuthElement lastElement) { LeafPosition pos = (LeafPosition)lastElement.getPosition(); @@ -1331,7 +1331,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager } /** - * {@inheritDoc} + * {@inheritDoc} */ public List getChangedKnuthElements(List oldList, int alignment) { List returnList = new LinkedList(); @@ -1354,8 +1354,8 @@ public class LineLayoutManager extends InlineStackingLayoutManager MinOptMax contentIPD; if (alignment == EN_JUSTIFY) { contentIPD = new MinOptMax( - lbp.lineWidth - lbp.difference - lbp.availableShrink, - lbp.lineWidth - lbp.difference, + lbp.lineWidth - lbp.difference - lbp.availableShrink, + lbp.lineWidth - lbp.difference, lbp.lineWidth - lbp.difference + lbp.availableStretch); } else if (alignment == EN_CENTER) { contentIPD = new MinOptMax(lbp.lineWidth - 2 * lbp.startIndent); @@ -1397,10 +1397,10 @@ public class LineLayoutManager extends InlineStackingLayoutManager // find all hyphenation points while (currParIterator.hasNext()) { firstElement = (KnuthElement) currParIterator.next(); - // + // if (firstElement.getLayoutManager() != currLM) { currLM = (InlineLevelLayoutManager) firstElement.getLayoutManager(); - if (currLM != null) { + if (currLM != null) { updateList.add(new Update(currLM, currParIterator.previousIndex())); } else { break; @@ -1409,7 +1409,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager break; } //TODO Something's not right here. See block_hyphenation_linefeed_preserve.xml - + // collect word fragments, ignoring auxiliary elements; // each word fragment was created by a different TextLM if (firstElement.isBox() && !firstElement.isAuxiliary()) { @@ -1432,7 +1432,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager } else if (!nextElement.isAuxiliary()) { // a non-auxiliary non-box KnuthElement: stop // go back to the last box or auxiliary element - currParIterator.previous(); + currParIterator.previous(); break; } else { if (currLM != nextElement.getLayoutManager()) { @@ -1475,7 +1475,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager //int iRemovedElements = 0; while (updateListIterator.hasNext()) { - // ask the LMs to apply the changes and return + // ask the LMs to apply the changes and return // the new KnuthElements to replace the old ones currUpdate = (Update) updateListIterator.next(); int fromIndex = currUpdate.iFirstIndex; @@ -1584,11 +1584,11 @@ public class LineLayoutManager extends InlineStackingLayoutManager } else if ((pos instanceof NonLeafPosition) && pos.generatesAreas()) { addBlockArea(context, pos, isLastPosition); } else { - /* + /* * pos was the Position inside a penalty item, nothing to do; * or Pos does not generate an area, * i.e. it stand for spaces, borders and padding. - */ + */ } } setCurrentArea(null); // ?? necessary @@ -1605,14 +1605,14 @@ public class LineLayoutManager extends InlineStackingLayoutManager KnuthElement tempElement = null; // the TLM which created the last KnuthElement in this line LayoutManager lastLM = null; - + LineBreakPosition lbp = (LineBreakPosition) pos; int iCurrParIndex; iCurrParIndex = lbp.iParIndex; KnuthSequence seq = (KnuthSequence) knuthParagraphs.get(iCurrParIndex); int iStartElement = lbp.iStartIndex; int iEndElement = lbp.getLeafPos(); - + LineArea lineArea = new LineArea((lbp.getLeafPos() < seq.size() - 1 ? textAlignment : textAlignmentLast), @@ -1625,12 +1625,12 @@ public class LineLayoutManager extends InlineStackingLayoutManager lineArea.addTrait(Trait.SPACE_BEFORE, new Integer(lbp.spaceBefore)); lineArea.addTrait(Trait.SPACE_AFTER, new Integer(lbp.spaceAfter)); alignmentContext.resizeLine(lbp.lineHeight, lbp.baseline); - + if (seq instanceof Paragraph) { Paragraph currPar = (Paragraph) seq; // ignore the first elements added by the LineLayoutManager iStartElement += (iStartElement == 0) ? currPar.ignoreAtStart : 0; - + // if this is the last line area that for this paragraph, // ignore the last elements added by the LineLayoutManager and // subtract the last-line-end-indent from the area ipd @@ -1639,10 +1639,10 @@ public class LineLayoutManager extends InlineStackingLayoutManager lineArea.setIPD(lineArea.getIPD() - lastLineEndIndent.getValue(this)); } } - + // Remove trailing spaces if allowed so if (whiteSpaceTreament == EN_IGNORE_IF_SURROUNDING_LINEFEED - || whiteSpaceTreament == EN_IGNORE + || whiteSpaceTreament == EN_IGNORE || whiteSpaceTreament == EN_IGNORE_IF_BEFORE_LINEFEED) { // ignore the last element in the line if it is a KnuthGlue object seqIterator = seq.listIterator(iEndElement); @@ -1661,10 +1661,10 @@ public class LineLayoutManager extends InlineStackingLayoutManager lastLM = tempElement.getLayoutManager(); } } - + // Remove leading spaces if allowed so if (whiteSpaceTreament == EN_IGNORE_IF_SURROUNDING_LINEFEED - || whiteSpaceTreament == EN_IGNORE + || whiteSpaceTreament == EN_IGNORE || whiteSpaceTreament == EN_IGNORE_IF_AFTER_LINEFEED) { // ignore KnuthGlue and KnuthPenalty objects // at the beginning of the line @@ -1678,13 +1678,13 @@ public class LineLayoutManager extends InlineStackingLayoutManager // Add the inline areas to lineArea PositionIterator inlinePosIter = new KnuthPossPosIter(seq, iStartElement, iEndElement + 1); - + iStartElement = lbp.getLeafPos() + 1; if (iStartElement == seq.size()) { // advance to next paragraph iStartElement = 0; } - + LayoutContext lc = new LayoutContext(0); lc.setAlignmentContext(alignmentContext); lc.setSpaceAdjust(lbp.dAdjust); @@ -1692,7 +1692,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager lc.setLeadingSpace(new SpaceSpecifier(true)); lc.setTrailingSpace(new SpaceSpecifier(false)); lc.setFlags(LayoutContext.RESOLVE_LEADING_SPACE, true); - + /* * extension (not in the XSL FO recommendation): if the left and right margins * have been optimized, recompute indents and / or adjust ratio, according @@ -1718,11 +1718,11 @@ public class LineLayoutManager extends InlineStackingLayoutManager lineArea.addTrait(Trait.START_INDENT, new Integer(updatedIndent)); } else if (false && textAlignment == EN_END) { // re-compute indent - int updatedIndent = lbp.startIndent + int updatedIndent = lbp.startIndent + (context.getStackLimitIP().opt - lbp.lineWidth); lineArea.addTrait(Trait.START_INDENT, new Integer(updatedIndent)); } - + setCurrentArea(lineArea); setChildContext(lc); LayoutManager childLM; @@ -1732,9 +1732,9 @@ public class LineLayoutManager extends InlineStackingLayoutManager lc.setLeadingSpace(lc.getTrailingSpace()); lc.setTrailingSpace(new SpaceSpecifier(false)); } - + // when can this be null? - // if display-align is distribute, add space after + // if display-align is distribute, add space after if (context.getSpaceAfter() > 0 && (!context.isLastArea() || !isLastPosition)) { lineArea.setBPD(lineArea.getBPD() + context.getSpaceAfter()); @@ -1742,7 +1742,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager lineArea.finalise(); parentLM.addChildArea(lineArea); } - + /** * Add a line with block content * @param context the context for adding areas @@ -1766,13 +1766,13 @@ public class LineLayoutManager extends InlineStackingLayoutManager if (isLastPosition) { lastLM = innerPosition.getLM(); } - + LineArea lineArea = new LineArea(); setCurrentArea(lineArea); LayoutContext lc = new LayoutContext(0); lc.setAlignmentContext(alignmentContext); setChildContext(lc); - + PositionIterator childPosIter = new StackingIter(positionList.listIterator()); LayoutContext blocklc = new LayoutContext(0); blocklc.setLeadingSpace(new SpaceSpecifier(true)); @@ -1810,14 +1810,14 @@ public class LineLayoutManager extends InlineStackingLayoutManager } // --------- Property Resolution related functions --------- // - + /** * {@inheritDoc} */ public boolean getGeneratesBlockArea() { return true; } - + /** * {@inheritDoc} */ diff --git a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutPossibilities.java b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutPossibilities.java index 59dd9c3c4..c1b81c4ab 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutPossibilities.java +++ b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutPossibilities.java @@ -29,7 +29,7 @@ public class LineLayoutPossibilities { /** logger instance */ protected static Log log = LogFactory.getLog(LineLayoutPossibilities.class); - + private class Possibility { private int lineCount; private double demerits; @@ -50,8 +50,8 @@ public class LineLayoutPossibilities { } private void addBreakPosition(Position pos) { - // Positions are always added with index 0 because - // they are created backward, from the last one to + // Positions are always added with index 0 because + // they are created backward, from the last one to // the first one breakPositions.add(0, pos); } @@ -74,7 +74,7 @@ public class LineLayoutPossibilities { savedPossibilities = new java.util.ArrayList(); optimumIndex = -1; } - + public void addPossibility(int ln, double dem) { possibilitiesList.add(new Possibility(ln, dem)); if (possibilitiesList.size() == 1) { @@ -145,8 +145,8 @@ public class LineLayoutPossibilities { } else { // this should not happen log.error("LineLayoutPossibilities restorePossibilities()," - + " min= " + getMinLineCount() - + " max= " + getMaxLineCount() + + " min= " + getMinLineCount() + + " max= " + getMaxLineCount() + " restored= " + restoredPossibility.getLineCount()); return; } @@ -158,7 +158,7 @@ public class LineLayoutPossibilities { chosenIndex = optimumIndex; } } - //log.debug(">> minLineCount = " + getMinLineCount() + //log.debug(">> minLineCount = " + getMinLineCount() // + " optLineCount = " + getOptLineCount() + " maxLineCount() = " + getMaxLineCount()); } diff --git a/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLastLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLastLayoutManager.java index 331d48b75..d33f2cca1 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLastLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLastLayoutManager.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. @@ -43,13 +43,13 @@ public class PageNumberCitationLastLayoutManager extends AbstractPageNumberCitat super(node); fobj = node; } - + /** {@inheritDoc} */ public InlineArea get(LayoutContext context) { curArea = getPageNumberCitationLastInlineArea(parentLM); return curArea; } - + /** * if id can be resolved then simply return a word, otherwise * return a resolvable area @@ -71,12 +71,12 @@ public class PageNumberCitationLastLayoutManager extends AbstractPageNumberCitat int width = getStringWidth(str); text.addWord(str, 0); text.setIPD(width); - + resolved = true; } - + updateTextAreaTraits(text); - + return text; } } diff --git a/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java index 8e6633ab8..583f73d24 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.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,13 +41,13 @@ public class PageNumberCitationLayoutManager extends AbstractPageNumberCitationL public PageNumberCitationLayoutManager(PageNumberCitation node) { super(node); } - + /** {@inheritDoc} */ public InlineArea get(LayoutContext context) { curArea = getPageNumberCitationInlineArea(); return curArea; } - + /** * if id can be resolved then simply return a word, otherwise * return a resolvable area @@ -71,9 +71,9 @@ public class PageNumberCitationLayoutManager extends AbstractPageNumberCitationL text.setIPD(width); } updateTextAreaTraits(text); - + return text; } - + } diff --git a/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java index 1aaaaf527..6b0e88cbb 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.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,10 +34,10 @@ import org.apache.fop.traits.MinOptMax; * LayoutManager for the fo:page-number formatting object */ public class PageNumberLayoutManager extends LeafNodeLayoutManager { - + private PageNumber fobj; private Font font; - + /** * Constructor * @@ -48,7 +48,7 @@ public class PageNumberLayoutManager extends LeafNodeLayoutManager { super(node); fobj = node; } - + /** {@inheritDoc} */ public void initialize() { FontInfo fi = fobj.getFOEventHandler().getFontInfo(); @@ -84,13 +84,13 @@ public class PageNumberLayoutManager extends LeafNodeLayoutManager { text.setBPD(font.getAscender() - font.getDescender()); text.setBaselineOffset(font.getAscender()); TraitSetter.addFontTraits(text, font); - text.addTrait(Trait.COLOR, fobj.getColor()); + text.addTrait(Trait.COLOR, fobj.getColor()); TraitSetter.addTextDecoration(text, fobj.getTextDecoration()); return text; } - + /** {@inheritDoc} */ protected InlineArea getEffectiveArea() { TextArea baseArea = (TextArea)curArea; @@ -108,7 +108,7 @@ public class PageNumberLayoutManager extends LeafNodeLayoutManager { updateContent(ta); return ta; } - + private void updateContent(TextArea area) { // get the page number of the page actually being built area.removeText(); @@ -130,6 +130,6 @@ public class PageNumberLayoutManager extends LeafNodeLayoutManager { } return width; } - + } diff --git a/src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTable.java b/src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTable.java index 25bcb7d0e..a2a1dce27 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTable.java +++ b/src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTable.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,19 +23,19 @@ import org.apache.fop.datatypes.Length; /** * The FOP specific incarnation of the XSL-FO scaled baseline table. - * All baseline tables are scaled to the font size of the font they - * apply to. This interface uses a coordinate system with its origin + * All baseline tables are scaled to the font size of the font they + * apply to. This interface uses a coordinate system with its origin * where the dominant baseline intersects the start edge of the box. * All measurements are in mpt. */ public interface ScaledBaselineTable { - + /** * Return the dominant baseline identifer for this alignment context. * @return the dominant baseline identifier */ int getDominantBaselineIdentifier(); - + /** * Return the writing mode for this aligment context. * @return the writing mode @@ -49,7 +49,7 @@ public interface ScaledBaselineTable { * @return the baseline offset */ int getBaseline(int baselineIdentifier); - + /** * Sets the position of the before and after baselines. * This is usually only done for line areas. For other @@ -59,7 +59,7 @@ public interface ScaledBaselineTable { * @param afterBaseline the offset of the after-edge baseline from the dominant baseline */ void setBeforeAndAfterBaselines(int beforeBaseline, int afterBaseline); - + /** * Return a new baseline table for the given baseline based * on the current baseline table. diff --git a/src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTableFactory.java b/src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTableFactory.java index e47f107e3..1536552c4 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTableFactory.java +++ b/src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTableFactory.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 ScaledBaselineTableFactory implements Constants { return new BasicScaledBaselineTable(font.getAscender(), font.getDescender() , font.getXHeight(), dominantBaselineIdentifier, writingMode); } - + /** * Creates a new instance of BasicScaledBaselineTable for the given * font and writingmode. It assumes an alphabetic baseline. @@ -55,7 +55,7 @@ public class ScaledBaselineTableFactory implements Constants { public static ScaledBaselineTable makeFontScaledBaselineTable(Font font, int writingMode) { return makeFontScaledBaselineTable(font, EN_ALPHABETIC, writingMode); } - + /** * Creates a new instance of BasicScaledBaselineTable for the given * height, baseline and writingmode. This is used for non font based areas like @@ -71,5 +71,5 @@ public class ScaledBaselineTableFactory implements Constants { return new BasicScaledBaselineTable(height, 0, height , dominantBaselineIdentifier, writingMode); } - + } diff --git a/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java index c6210edce..459bce0e8 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java @@ -203,7 +203,7 @@ public class TextLayoutManager extends LeafNodeLayoutManager { public void initialize() { this.foText.resetBuffer(); - + this.spaceFont = FontSelector.selectFontForCharacterInText(' ', this.foText, this); // With CID fonts, space isn't neccesary currentFontState.width(32) diff --git a/src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java index 342e0a6f1..97f07da54 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.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 @@ import java.util.LinkedList; * This is the layout manager for the fo:wrapper formatting object. */ public class WrapperLayoutManager extends LeafNodeLayoutManager { - + /** * Creates a new LM for fo:wrapper. * @param node the fo:wrapper diff --git a/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java index 11e69970e..1cd3ab9d2 100644 --- a/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.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.layoutmgr.list; import java.util.Iterator; @@ -48,7 +48,7 @@ import org.apache.fop.traits.SpaceVal; * A list block contains list items which are stacked within * the list block area.. */ -public class ListBlockLayoutManager extends BlockStackingLayoutManager +public class ListBlockLayoutManager extends BlockStackingLayoutManager implements ConditionalElementListener { /** @@ -102,38 +102,38 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager foSpaceAfter = new SpaceVal( getListBlockFO().getCommonMarginBlock().spaceAfter, this).getSpace(); startIndent = getListBlockFO().getCommonMarginBlock().startIndent.getValue(this); - endIndent = getListBlockFO().getCommonMarginBlock().endIndent.getValue(this); + endIndent = getListBlockFO().getCommonMarginBlock().endIndent.getValue(this); } private void resetSpaces() { - this.discardBorderBefore = false; - this.discardBorderAfter = false; - this.discardPaddingBefore = false; + this.discardBorderBefore = false; + this.discardBorderAfter = false; + this.discardPaddingBefore = false; this.discardPaddingAfter = false; this.effSpaceBefore = null; this.effSpaceAfter = null; } - + /** {@inheritDoc} */ public List getNextKnuthElements(LayoutContext context, int alignment) { - resetSpaces(); + resetSpaces(); List returnList = super.getNextKnuthElements(context, alignment); //fox:widow-content-limit - int widowRowLimit = getListBlockFO().getWidowContentLimit().getValue(); + int widowRowLimit = getListBlockFO().getWidowContentLimit().getValue(); if (widowRowLimit != 0) { ElementListUtils.removeLegalBreaks(returnList, widowRowLimit); } //fox:orphan-content-limit - int orphanRowLimit = getListBlockFO().getOrphanContentLimit().getValue(); + int orphanRowLimit = getListBlockFO().getOrphanContentLimit().getValue(); if (orphanRowLimit != 0) { ElementListUtils.removeLegalBreaksFromEnd(returnList, orphanRowLimit); } return returnList; } - + /** {@inheritDoc} */ public List getChangedKnuthElements(List oldList, int alignment) { //log.debug("LBLM.getChangedKnuthElements>"); @@ -169,7 +169,7 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager Position lastPos = null; // "unwrap" the NonLeafPositions stored in parentIter - // and put them in a new list; + // and put them in a new list; LinkedList positionList = new LinkedList(); Position pos; while (parentIter.hasNext()) { @@ -208,17 +208,17 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager addMarkersToPage(false, isFirst(firstPos), isLast(lastPos)); // We are done with this area add the background - TraitSetter.addBackground(curBlockArea, + TraitSetter.addBackground(curBlockArea, getListBlockFO().getCommonBorderPaddingBackground(), this); - TraitSetter.addSpaceBeforeAfter(curBlockArea, layoutContext.getSpaceAdjust(), + TraitSetter.addSpaceBeforeAfter(curBlockArea, layoutContext.getSpaceAdjust(), effSpaceBefore, effSpaceAfter); flush(); curBlockArea = null; resetSpaces(); - + checkEndOfLayout(lastPos); } @@ -238,30 +238,30 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager public Area getParentArea(Area childArea) { if (curBlockArea == null) { curBlockArea = new Block(); - + // Set up dimensions // Must get dimensions from parent area /*Area parentArea =*/ parentLM.getParentArea(curBlockArea); // set traits TraitSetter.setProducerID(curBlockArea, getListBlockFO().getId()); - TraitSetter.addBorders(curBlockArea, - getListBlockFO().getCommonBorderPaddingBackground(), + TraitSetter.addBorders(curBlockArea, + getListBlockFO().getCommonBorderPaddingBackground(), discardBorderBefore, discardBorderAfter, false, false, this); - TraitSetter.addPadding(curBlockArea, - getListBlockFO().getCommonBorderPaddingBackground(), + TraitSetter.addPadding(curBlockArea, + getListBlockFO().getCommonBorderPaddingBackground(), discardPaddingBefore, discardPaddingAfter, false, false, this); TraitSetter.addMargins(curBlockArea, - getListBlockFO().getCommonBorderPaddingBackground(), + getListBlockFO().getCommonBorderPaddingBackground(), getListBlockFO().getCommonMarginBlock(), this); - TraitSetter.addBreaks(curBlockArea, - getListBlockFO().getBreakBefore(), + TraitSetter.addBreaks(curBlockArea, + getListBlockFO().getBreakBefore(), getListBlockFO().getBreakAfter()); - + int contentIPD = referenceIPD - getIPIndents(); curBlockArea.setIPD(contentIPD); - + setCurrentArea(curBlockArea); } return curBlockArea; @@ -285,7 +285,7 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager strength = Math.max(strength, getParentKeepTogetherStrength()); return strength; } - + /** {@inheritDoc} */ public int getKeepWithNextStrength() { return KeepUtil.getCombinedBlockLevelKeepStrength(getListBlockFO().getKeepWithNext()); @@ -300,13 +300,13 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager public void notifySpace(RelSide side, MinOptMax effectiveLength) { if (RelSide.BEFORE == side) { if (log.isDebugEnabled()) { - log.debug(this + ": Space " + side + ", " + log.debug(this + ": Space " + side + ", " + this.effSpaceBefore + "-> " + effectiveLength); } this.effSpaceBefore = effectiveLength; } else { if (log.isDebugEnabled()) { - log.debug(this + ": Space " + side + ", " + log.debug(this + ": Space " + side + ", " + this.effSpaceAfter + "-> " + effectiveLength); } this.effSpaceAfter = effectiveLength; diff --git a/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java index 124827976..0a2dec945 100644 --- a/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.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.layoutmgr.list; import java.util.Iterator; @@ -85,7 +85,7 @@ public class ListItemContentLayoutManager extends BlockStackingLayoutManager { protected AbstractListItemPart getPartFO() { return (AbstractListItemPart)fobj; } - + /** * Set the x offset of this list item. * This offset is used to set the absolute position @@ -114,7 +114,7 @@ public class ListItemContentLayoutManager extends BlockStackingLayoutManager { public void addAreas(PositionIterator parentIter, LayoutContext layoutContext) { getParentArea(null); - + addId(); LayoutManager childLM; @@ -125,7 +125,7 @@ public class ListItemContentLayoutManager extends BlockStackingLayoutManager { Position lastPos = null; // "unwrap" the NonLeafPositions stored in parentIter - // and put them in a new list; + // and put them in a new list; LinkedList positionList = new LinkedList(); Position pos; while (parentIter.hasNext()) { @@ -154,7 +154,7 @@ public class ListItemContentLayoutManager extends BlockStackingLayoutManager { } addMarkersToPage(true, isFirst(firstPos), isLast(lastPos)); - + StackingIter childPosIter = new StackingIter(positionList.listIterator()); while ((childLM = childPosIter.getNextChildLM()) != null) { // Add the block areas to Area @@ -167,11 +167,11 @@ public class ListItemContentLayoutManager extends BlockStackingLayoutManager { } addMarkersToPage(false, isFirst(firstPos), isLast(lastPos)); - + flush(); curBlockArea = null; - + checkEndOfLayout(lastPos); } @@ -198,7 +198,7 @@ public class ListItemContentLayoutManager extends BlockStackingLayoutManager { //curBlockArea.setHeight(); TraitSetter.setProducerID(curBlockArea, getPartFO().getId()); - + // Set up dimensions Area parentArea = parentLM.getParentArea(curBlockArea); int referenceIPD = parentArea.getIPD(); @@ -226,7 +226,7 @@ public class ListItemContentLayoutManager extends BlockStackingLayoutManager { strength = Math.max(strength, getParentKeepTogetherStrength()); return strength; } - + /** {@inheritDoc} */ public int getKeepWithNextStrength() { return KEEP_AUTO; diff --git a/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java index 37ec4964d..f027922f7 100644 --- a/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.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. @@ -59,7 +59,7 @@ import org.apache.fop.traits.SpaceVal; * LayoutManager for a list-item FO. * The list item contains a list item label and a list item body. */ -public class ListItemLayoutManager extends BlockStackingLayoutManager +public class ListItemLayoutManager extends BlockStackingLayoutManager implements ConditionalElementListener { /** @@ -81,19 +81,19 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager private boolean discardPaddingAfter; private MinOptMax effSpaceBefore; private MinOptMax effSpaceAfter; - + private int keepWithNextPendingOnLabel; private int keepWithNextPendingOnBody; private int listItemHeight; - + private class ListItemPosition extends Position { private int iLabelFirstIndex; private int iLabelLastIndex; private int iBodyFirstIndex; private int iBodyLastIndex; - public ListItemPosition(LayoutManager lm, int labelFirst, int labelLast, + public ListItemPosition(LayoutManager lm, int labelFirst, int labelLast, int bodyFirst, int bodyLast) { super(lm); iLabelFirstIndex = labelFirst; @@ -101,11 +101,11 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager iBodyFirstIndex = bodyFirst; iBodyLastIndex = bodyLast; } - + public int getLabelFirstIndex() { return iLabelFirstIndex; } - + public int getLabelLastIndex() { return iLabelLastIndex; } @@ -113,11 +113,11 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager public int getBodyFirstIndex() { return iBodyFirstIndex; } - + public int getBodyLastIndex() { return iBodyLastIndex; } - + /** {@inheritDoc} */ public boolean generatesAreas() { return true; @@ -166,7 +166,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager * @param node the fo:list-item-body FO */ public void setBody(ListItemBody node) { - body = new ListItemContentLayoutManager(node); + body = new ListItemContentLayoutManager(node); body.setParent(this); } @@ -177,25 +177,25 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager foSpaceAfter = new SpaceVal( getListItemFO().getCommonMarginBlock().spaceAfter, this).getSpace(); startIndent = getListItemFO().getCommonMarginBlock().startIndent.getValue(this); - endIndent = getListItemFO().getCommonMarginBlock().endIndent.getValue(this); + endIndent = getListItemFO().getCommonMarginBlock().endIndent.getValue(this); } private void resetSpaces() { - this.discardBorderBefore = false; - this.discardBorderAfter = false; - this.discardPaddingBefore = false; + this.discardBorderBefore = false; + this.discardBorderAfter = false; + this.discardPaddingBefore = false; this.discardPaddingAfter = false; this.effSpaceBefore = null; this.effSpaceAfter = null; } - + /** {@inheritDoc} */ public List getNextKnuthElements(LayoutContext context, int alignment) { referenceIPD = context.getRefIPD(); LayoutContext childLC; - + List returnList = new LinkedList(); - + if (!breakBeforeServed) { try { if (addKnuthElementsForBreakBefore(returnList, context)) { @@ -207,7 +207,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager } addKnuthElementsForSpaceBefore(returnList, alignment); - + addKnuthElementsForBorderPaddingBefore(returnList, !firstVisibleMarkServed); firstVisibleMarkServed = true; @@ -219,12 +219,12 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager childLC.setRefIPD(context.getRefIPD()); label.initialize(); labelList = label.getNextKnuthElements(childLC, alignment); - + //Space resolution as if the contents were placed in a new reference area //(see 6.8.3, XSL 1.0, section on Constraints, last paragraph) SpaceResolver.resolveElementList(labelList); ElementListObserver.observe(labelList, "list-item-label", label.getPartFO().getId()); - + context.updateKeepWithPreviousPending(childLC.getKeepWithPreviousPending()); this.keepWithNextPendingOnLabel = childLC.getKeepWithNextPending(); @@ -238,7 +238,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager //(see 6.8.3, XSL 1.0, section on Constraints, last paragraph) SpaceResolver.resolveElementList(bodyList); ElementListObserver.observe(bodyList, "list-item-body", body.getPartFO().getId()); - + context.updateKeepWithPreviousPending(childLC.getKeepWithPreviousPending()); this.keepWithNextPendingOnBody = childLC.getKeepWithNextPending(); @@ -247,7 +247,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager // "wrap" the Position inside each element wrapPositionElements(returnedList, returnList, true); - + addKnuthElementsForBorderPaddingAfter(returnList, true); addKnuthElementsForSpaceAfter(returnList, alignment); addKnuthElementsForBreakAfter(returnList, context); @@ -280,7 +280,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager LinkedList returnList = new LinkedList(); while ((step = getNextStep(elementLists, start, end, partialHeights)) > 0) { - + if (end[0] + 1 == elementLists[0].size()) { keepWithNextActive = Math.max(keepWithNextActive, keepWithNextPendingOnLabel); } @@ -289,10 +289,10 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager } // compute penalty height and box height - int penaltyHeight = step - + getMaxRemainingHeight(fullHeights, partialHeights) + int penaltyHeight = step + + getMaxRemainingHeight(fullHeights, partialHeights) - totalHeight; - + //Additional penalty height from penalties in the source lists int additionalPenaltyHeight = 0; int stepPenalty = 0; @@ -307,7 +307,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager additionalPenaltyHeight, endEl.getW()); stepPenalty = Math.max(stepPenalty, endEl.getP()); } - + int boxHeight = step - addedBoxHeight - penaltyHeight; penaltyHeight += additionalPenaltyHeight; //Add AFTER calculating boxHeight! @@ -330,7 +330,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager // add the new elements addedBoxHeight += boxHeight; - ListItemPosition stepPosition = new ListItemPosition(this, + ListItemPosition stepPosition = new ListItemPosition(this, start[0], end[0], start[1], end[1]); if (footnoteList == null) { returnList.add(new KnuthBox(boxHeight, stepPosition, false)); @@ -394,7 +394,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager if (seqCount == 0) { return 0; } - + // determine next step int step; if (backupHeights[0] == 0 && backupHeights[1] == 0) { @@ -426,7 +426,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager } /** - * {@inheritDoc} + * {@inheritDoc} */ public List getChangedKnuthElements(List oldList, int alignment) { //log.debug(" LILM.getChanged> label"); @@ -441,10 +441,10 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager while (oldListIterator.hasNext()) { oldElement = (KnuthElement)oldListIterator.next(); Position innerPosition = oldElement.getPosition().getPosition(); - //log.debug(" BLM> unwrapping: " + (oldElement.isBox() - // ? "box " : (oldElement.isGlue() ? "glue " : "penalty")) + //log.debug(" BLM> unwrapping: " + (oldElement.isBox() + // ? "box " : (oldElement.isGlue() ? "glue " : "penalty")) // + " creato da " + oldElement.getLayoutManager().getClass().getName()); - //log.debug(" BLM> unwrapping: " + //log.debug(" BLM> unwrapping: " // + oldElement.getPosition().getClass().getName()); if (innerPosition != null) { // oldElement was created by a descendant of this BlockLM @@ -508,7 +508,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager addMarkersToPage(true, isFirst(firstPos), isLast(lastPos)); - // use the first and the last ListItemPosition to determine the + // use the first and the last ListItemPosition to determine the // corresponding indexes in the original labelList and bodyList int labelFirstIndex = ((ListItemPosition) positionList.getFirst()).getLabelFirstIndex(); int labelLastIndex = ((ListItemPosition) positionList.getLast()).getLabelLastIndex(); @@ -517,17 +517,17 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager //Determine previous break if any int previousBreak = ElementListUtils.determinePreviousBreak(labelList, labelFirstIndex); - SpaceResolver.performConditionalsNotification(labelList, + SpaceResolver.performConditionalsNotification(labelList, labelFirstIndex, labelLastIndex, previousBreak); //Determine previous break if any previousBreak = ElementListUtils.determinePreviousBreak(bodyList, bodyFirstIndex); - SpaceResolver.performConditionalsNotification(bodyList, + SpaceResolver.performConditionalsNotification(bodyList, bodyFirstIndex, bodyLastIndex, previousBreak); - + // add label areas if (labelFirstIndex <= labelLastIndex) { - KnuthPossPosIter labelIter = new KnuthPossPosIter(labelList, + KnuthPossPosIter labelIter = new KnuthPossPosIter(labelList, labelFirstIndex, labelLastIndex + 1); lc.setFlags(LayoutContext.FIRST_AREA, layoutContext.isFirstArea()); lc.setFlags(LayoutContext.LAST_AREA, layoutContext.isLastArea()); @@ -548,7 +548,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager // add body areas if (bodyFirstIndex <= bodyLastIndex) { - KnuthPossPosIter bodyIter = new KnuthPossPosIter(bodyList, + KnuthPossPosIter bodyIter = new KnuthPossPosIter(bodyList, bodyFirstIndex, bodyLastIndex + 1); lc.setFlags(LayoutContext.FIRST_AREA, layoutContext.isFirstArea()); lc.setFlags(LayoutContext.LAST_AREA, layoutContext.isLastArea()); @@ -567,17 +567,17 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager addMarkersToPage(false, isFirst(firstPos), isLast(lastPos)); // We are done with this area add the background - TraitSetter.addBackground(curBlockArea, + TraitSetter.addBackground(curBlockArea, getListItemFO().getCommonBorderPaddingBackground(), this); - TraitSetter.addSpaceBeforeAfter(curBlockArea, layoutContext.getSpaceAdjust(), + TraitSetter.addSpaceBeforeAfter(curBlockArea, layoutContext.getSpaceAdjust(), effSpaceBefore, effSpaceAfter); flush(); curBlockArea = null; resetSpaces(); - + checkEndOfLayout(lastPos); } @@ -610,22 +610,22 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager // Set up dimensions /*Area parentArea =*/ parentLM.getParentArea(curBlockArea); - + // set traits TraitSetter.setProducerID(curBlockArea, getListItemFO().getId()); - TraitSetter.addBorders(curBlockArea, - getListItemFO().getCommonBorderPaddingBackground(), + TraitSetter.addBorders(curBlockArea, + getListItemFO().getCommonBorderPaddingBackground(), discardBorderBefore, discardBorderAfter, false, false, this); - TraitSetter.addPadding(curBlockArea, - getListItemFO().getCommonBorderPaddingBackground(), + TraitSetter.addPadding(curBlockArea, + getListItemFO().getCommonBorderPaddingBackground(), discardPaddingBefore, discardPaddingAfter, false, false, this); TraitSetter.addMargins(curBlockArea, - getListItemFO().getCommonBorderPaddingBackground(), + getListItemFO().getCommonBorderPaddingBackground(), getListItemFO().getCommonMarginBlock(), this); - TraitSetter.addBreaks(curBlockArea, - getListItemFO().getBreakBefore(), + TraitSetter.addBreaks(curBlockArea, + getListItemFO().getBreakBefore(), getListItemFO().getBreakAfter()); - + int contentIPD = referenceIPD - getIPIndents(); curBlockArea.setIPD(contentIPD); @@ -669,13 +669,13 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager public void notifySpace(RelSide side, MinOptMax effectiveLength) { if (RelSide.BEFORE == side) { if (log.isDebugEnabled()) { - log.debug(this + ": Space " + side + ", " + log.debug(this + ": Space " + side + ", " + this.effSpaceBefore + "-> " + effectiveLength); } this.effSpaceBefore = effectiveLength; } else { if (log.isDebugEnabled()) { - log.debug(this + ": Space " + side + ", " + log.debug(this + ": Space " + side + ", " + this.effSpaceAfter + "-> " + effectiveLength); } this.effSpaceAfter = effectiveLength; @@ -710,6 +710,6 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager } } - + } diff --git a/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java b/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java index 4012b0c00..a9da7a3ca 100644 --- a/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java +++ b/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java @@ -173,7 +173,7 @@ class ActiveCell { * Returns the actual length of the content represented by the given element. In the * case where this element is used as a filler to match a row's fixed height, the * value returned by the getW() method will be higher than the actual content. - * + * * @param el an element * @return the actual content length corresponding to the element */ @@ -226,7 +226,7 @@ class ActiveCell { /** * Modifies the cell's element list by putting filler elements, so that the cell's or * row's explicit height is always reached. - * + * * TODO this will work properly only for the first break. Then the limitation * explained on http://wiki.apache.org/xmlgraphics-fop/TableLayout/KnownProblems * occurs. The list of elements needs to be re-adjusted after each break. @@ -269,7 +269,7 @@ class ActiveCell { /** * Returns true if this cell ends on the given row. - * + * * @param rowIndex index of a row in the row-group, zero-based * @return true if this cell ends on the given row */ @@ -280,7 +280,7 @@ class ActiveCell { /** * Returns the length of this cell's content not yet included in the steps, plus the * cell's borders and paddings if applicable. - * + * * @return the remaining length, zero if the cell is finished */ int getRemainingLength() { @@ -341,12 +341,12 @@ class ActiveCell { afterNextStep.end = knuthIter.nextIndex() - 1; afterNextStep.totalLength = bpBeforeNormal + afterNextStep.contentLength + afterNextStep.penaltyLength - + bpAfterTrailing; + + bpAfterTrailing; } /** * Returns the minimal step that is needed for this cell to contribute some content. - * + * * @return the step for this cell's first legal break */ int getFirstStep() { @@ -363,7 +363,7 @@ class ActiveCell { * infinite penalty, plus the cell's content won't be taken into account since the * final step will be smaller than the current one (see {@link #signalNextStep(int)}). * This actually means that the content will be swallowed. - * + * * @return the length of last step */ int getLastStep() { @@ -377,7 +377,7 @@ class ActiveCell { /** * Increases the next step up to the given limit. - * + * * @param limit the length up to which the next step is allowed to increase * @see #signalRowFirstStep(int) * @see #signalRowLastStep(int) @@ -398,7 +398,7 @@ class ActiveCell { * Gets the selected first step for the current row. If this cell's first step is * smaller, then it may be able to add some more of its content, since there will be * no break before the given step anyway. - * + * * @param firstStep the current row's first step */ void signalRowFirstStep(int firstStep) { @@ -418,7 +418,7 @@ class ActiveCell { /** * Returns the total length up to the next legal break, not yet included in the steps. - * + * * @return the total length up to the next legal break (-1 signals no further step) */ int getNextStep() { @@ -446,7 +446,7 @@ class ActiveCell { /** * Signals the length of the chosen next step, so that this cell determines whether * its own step may be included or not. - * + * * @param minStep length of the chosen next step * @return the break class of the step, if any. One of {@link Constants#EN_AUTO}, * {@link Constants#EN_COLUMN}, {@link Constants#EN_PAGE}, @@ -487,7 +487,7 @@ class ActiveCell { /** * Receives indication that the current row is ending, and that (collapse) borders * must be updated accordingly. - * + * * @param rowIndex the index of the ending row */ void endRow(int rowIndex) { @@ -508,7 +508,7 @@ class ActiveCell { /** * Returns true if this cell would be finished after the given step. That is, it would * be included in the step and the end of its content would be reached. - * + * * @param step the next step * @return true if this cell finishes at the given step */ @@ -519,7 +519,7 @@ class ActiveCell { /** * Creates and returns a CellPart instance for the content of this cell which * is included in the next step. - * + * * @return a CellPart instance */ CellPart createCellPart() { @@ -557,7 +557,7 @@ class ActiveCell { /** * Adds the footnotes (if any) that are part of the next step, if this cell * contributes content to the next step. - * + * * @param footnoteList the list to which this cell must add its footnotes */ void addFootnotes(List footnoteList) { diff --git a/src/java/org/apache/fop/layoutmgr/table/CellPart.java b/src/java/org/apache/fop/layoutmgr/table/CellPart.java index 560b70344..7dd2bc201 100644 --- a/src/java/org/apache/fop/layoutmgr/table/CellPart.java +++ b/src/java/org/apache/fop/layoutmgr/table/CellPart.java @@ -44,7 +44,7 @@ class CellPart { /** * Creates a new CellPart. - * + * * @param pgu Primary grid unit * @param start starting element * @param end ending element diff --git a/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java b/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java index c3df74800..ede6210ca 100644 --- a/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java +++ b/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java @@ -131,7 +131,7 @@ public abstract class CollapsingBorderModel { /** * Compares the two given styles (see {@link Constants}). - * + * * @param style1 a style constant * @param style2 another style constant * @return a value < 0 if style1 has less priority than style2, 0 if both are @@ -161,7 +161,7 @@ public abstract class CollapsingBorderModel { /** * Compares the two given FO ids ({@link Constants}.FO*) in terms of border * declaration. - * + * * @param id1 a FO id ({@link Constants#FO_TABLE}, {@link Constants#FO_TABLE_BODY}, * etc.) * @param id2 another FO id @@ -178,7 +178,7 @@ public abstract class CollapsingBorderModel { * Returns the border which wins the border conflict resolution. In case the two * borders are equivalent (identical, or only the color is different), null is * returned. - * + * * @param border1 a border specification * @param border2 another border specification * @param discard true if the .conditionality component of the border width must be @@ -192,7 +192,7 @@ public abstract class CollapsingBorderModel { * Returns the border which wins the border conflict resolution. Same as * {@link #determineWinner(BorderSpecification, BorderSpecification, boolean) * determineWinner(border1, border2, false)}. - * + * * @param border1 a border specification * @param border2 another border specification * @return the winning border, null if the two borders are equivalent diff --git a/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModelEyeCatching.java b/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModelEyeCatching.java index c1a9380a3..7aed158de 100644 --- a/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModelEyeCatching.java +++ b/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModelEyeCatching.java @@ -26,7 +26,7 @@ import org.apache.fop.fo.properties.CommonBorderPaddingBackground.BorderInfo; /** * Implements the normal "collapse" border model defined in 6.7.10 in XSL 1.0. - * + * * TODO Column groups are not yet checked in this algorithm! */ public class CollapsingBorderModelEyeCatching extends CollapsingBorderModel { diff --git a/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java b/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java index 9dbd31653..c32c6eb3d 100644 --- a/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java +++ b/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java @@ -45,9 +45,9 @@ public class ColumnSetup { private Table table; private List columns = new java.util.ArrayList(); private List colWidths = new java.util.ArrayList(); - + private int maxColIndexReferenced = 0; - + /** * Main Constructor. * @param table the table to construct this column setup for @@ -57,7 +57,7 @@ public class ColumnSetup { prepareColumns(); initializeColumnWidths(); } - + private void prepareColumns() { List rawCols = table.getColumns(); if (rawCols != null) { @@ -124,7 +124,7 @@ public class ColumnSetup { return (TableColumn) columns.get(index - 1); } } - + /** {@inheritDoc} */ public String toString() { return columns.toString(); @@ -138,15 +138,15 @@ public class ColumnSetup { return columns.size(); } } - + /** @return an Iterator over all columns */ public Iterator iterator() { return this.columns.iterator(); } - + /* private void createColumnsFromFirstRow() { - //TODO Create oldColumns from first row here + //TODO Create oldColumns from first row here //--> rule 2 in "fixed table layout", see CSS2, 17.5.2 //Alternative: extend oldColumns on-the-fly, but in this case we need the //new property evaluation context so proportional-column-width() works @@ -159,13 +159,13 @@ public class ColumnSetup { /** * Initializes the column's widths - * + * */ private void initializeColumnWidths() { - + TableColumn col; Length colWidth; - + for (int i = columns.size(); --i >= 0;) { if (columns.get(i) != null) { col = (TableColumn) columns.get(i); @@ -175,21 +175,21 @@ public class ColumnSetup { } colWidths.add(0, null); } - + /** * Works out the base unit for resolving proportional-column-width() * [p-c-w(x) = x * base_unit_ipd] - * + * * @param tlm the TableLayoutManager * @return the computed base unit (in millipoint) */ protected double computeTableUnit(TableLayoutManager tlm) { - + int sumCols = 0; float factors = 0; double unit = 0; - - /* calculate the total width (specified absolute/percentages), + + /* calculate the total width (specified absolute/percentages), * and work out the total number of factors to use to distribute * the remaining space (if any) */ @@ -204,9 +204,9 @@ public class ColumnSetup { } } } - - /* distribute the remaining space over the accumulated - * factors (if any) + + /* distribute the remaining space over the accumulated + * factors (if any) */ if (factors > 0) { if (sumCols < tlm.getContentAreaIPD()) { @@ -215,10 +215,10 @@ public class ColumnSetup { log.warn("No space remaining to distribute over columns."); } } - + return unit; } - + /** * @param col column index (1 is first column) * @param context the context for percentage based calculations @@ -258,5 +258,5 @@ public class ColumnSetup { } return sum; } - + } diff --git a/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java index 7f91808d0..54cb1ebfe 100644 --- a/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.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. @@ -66,7 +66,7 @@ class RowGroupLayoutManager { int breakBefore = Constants.EN_AUTO; TableRow firstRow = rowGroup[0].getTableRow(); if (firstRow != null) { - breakBefore = firstRow.getBreakBefore(); + breakBefore = firstRow.getBreakBefore(); } context.setBreakBefore(BreakUtil.compareBreakClasses(breakBefore, rowGroup[0].getBreakBefore())); @@ -74,7 +74,7 @@ class RowGroupLayoutManager { int breakAfter = Constants.EN_AUTO; TableRow lastRow = rowGroup[rowGroup.length - 1].getTableRow(); if (lastRow != null) { - breakAfter = lastRow.getBreakAfter(); + breakAfter = lastRow.getBreakAfter(); } context.setBreakAfter(BreakUtil.compareBreakClasses(breakAfter, rowGroup[rowGroup.length - 1].getBreakAfter())); @@ -89,7 +89,7 @@ class RowGroupLayoutManager { * @param bodyType Indicates what kind of body is being processed (BODY, HEADER or FOOTER) * @param returnList List to received the generated elements */ - private void createElementsForRowGroup(LayoutContext context, int alignment, + private void createElementsForRowGroup(LayoutContext context, int alignment, int bodyType, LinkedList returnList) { log.debug("Handling row group with " + rowGroup.length + " rows..."); EffRow row; @@ -113,7 +113,7 @@ class RowGroupLayoutManager { LayoutContext childLC = new LayoutContext(0); childLC.setStackLimitBP(context.getStackLimitBP()); //necessary? childLC.setRefIPD(spanWidth); - + //Get the element list for the cell contents List elems = primary.getCellLM().getNextKnuthElements( childLC, alignment); @@ -131,7 +131,7 @@ class RowGroupLayoutManager { /** * Calculate the heights of the rows in the row group, see CSS21, 17.5.3 Table height * algorithms. - * + * * TODO this method will need to be adapted once clarification has been made by the * W3C regarding whether borders or border-separation must be included or not */ @@ -174,7 +174,7 @@ class RowGroupLayoutManager { int borderWidths = primary.getBeforeAfterBorderWidth(); int padding = 0; CommonBorderPaddingBackground cbpb = primary.getCell() - .getCommonBorderPaddingBackground(); + .getCommonBorderPaddingBackground(); padding += cbpb.getPaddingBefore(false, primary.getCellLM()); padding += cbpb.getPaddingAfter(false, primary.getCellLM()); int effRowHeight = effectiveCellBPD + padding + borderWidths; @@ -195,13 +195,13 @@ class RowGroupLayoutManager { // if (maxCellBPD > row.getExplicitHeight().max) { //old: // log.warn(FONode.decorateWithContextInfo( -// "The contents of row " + (row.getIndex() + 1) +// "The contents of row " + (row.getIndex() + 1) // + " 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 " + maxCellBPD + " millipoints, but the row shouldn't get" -// + " any taller than " + row.getExplicitHeight() + " millipoints.", +// + " any taller than " + row.getExplicitHeight() + " millipoints.", // row.getTableRow())); //new (with events): // BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Factory.create( diff --git a/src/java/org/apache/fop/layoutmgr/table/RowPainter.java b/src/java/org/apache/fop/layoutmgr/table/RowPainter.java index 38f1a7b30..b2851c39f 100644 --- a/src/java/org/apache/fop/layoutmgr/table/RowPainter.java +++ b/src/java/org/apache/fop/layoutmgr/table/RowPainter.java @@ -107,7 +107,7 @@ class RowPainter { /** * Signals that the end of the current table part is reached. - * + * * @param lastInBody true if the part is the last table-body element to be displayed * on the current page. In which case all the cells must be flushed even if they * aren't finished, plus the proper collapsed borders must be selected (trailing @@ -118,7 +118,7 @@ class RowPainter { */ void endTablePart(boolean lastInBody, boolean lastOnPage) { addAreasAndFlushRow(lastInBody, lastOnPage); - + if (tablePartBackground != null) { TableLayoutManager tableLM = tclm.getTableLM(); for (Iterator iter = tablePartBackgroundAreas.iterator(); iter.hasNext();) { @@ -139,7 +139,7 @@ class RowPainter { /** * Records the fragment of row represented by the given position. If it belongs to * another (grid) row than the current one, that latter is painted and flushed first. - * + * * @param tcpos a position representing the row fragment */ void handleTableContentPosition(TableContentPosition tcpos) { @@ -173,7 +173,7 @@ class RowPainter { firstCellParts[colIndex] = cellPart; cellHeights[colIndex] = cellPart.getBorderPaddingBefore(firstCellOnPage[colIndex]); } else { - assert firstCellParts[colIndex].pgu == cellPart.pgu; + assert firstCellParts[colIndex].pgu == cellPart.pgu; cellHeights[colIndex] += cellPart.getConditionalBeforeContentLength(); } cellHeights[colIndex] += cellPart.getLength(); @@ -185,7 +185,7 @@ class RowPainter { * Creates the areas corresponding to the last row. That is, an area with background * for the row, plus areas for all the cells that finish on the row (not spanning over * further rows). - * + * * @param lastInPart true if the row is the last from its table part to be displayed * on the current page. In which case all the cells must be flushed even if they * aren't finished, plus the proper collapsed borders must be selected (trailing @@ -204,7 +204,7 @@ class RowPainter { // Need to compute the actual row height first int actualRowHeight = 0; for (int i = 0; i < colCount; i++) { - GridUnit currentGU = currentRow.getGridUnit(i); + GridUnit currentGU = currentRow.getGridUnit(i); if (!currentGU.isEmpty() && currentGU.getColSpanIndex() == 0 && (lastInPart || currentGU.isLastGridUnitRowSpan()) && firstCellParts[i] != null) { @@ -396,7 +396,7 @@ class RowPainter { * set when the areas for the cell are created since at that moment this bpd is yet * unknown. So they will instead be set in * {@link #addAreasAndFlushRow(boolean, boolean)}. - * + * * @param backgroundArea the block of the cell's dimensions that will hold the part * background */ @@ -407,7 +407,7 @@ class RowPainter { /** * Records the y-offset of the row with the given index. - * + * * @param rowIndex index of the row * @param offset y-offset of the row on the page */ @@ -419,7 +419,7 @@ class RowPainter { * considered as finished, since it contains no cell ending on this row. Thus no * TableContentPosition will be created for this row. Thus its index will never be * recorded by the #handleTableContentPosition method. - * + * * The offset of such a row is the same as the next non-empty row. It's needed * to correctly offset blocks for cells starting on this row. Hence the loop * below. @@ -431,7 +431,7 @@ class RowPainter { /** * Returns the offset of the row with the given index. - * + * * @param rowIndex index of the row * @return its y-offset on the page */ diff --git a/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java index c20060723..4cf68b97b 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.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.layoutmgr.table; import org.apache.fop.area.Area; @@ -55,7 +55,7 @@ public class TableAndCaptionLayoutManager extends BlockStackingLayoutManager { public TableAndCaption getTableAndCaptionFO() { return (TableAndCaption)this.fobj; } - + /** * Get the next break possibility. * @@ -199,7 +199,7 @@ public class TableAndCaptionLayoutManager extends BlockStackingLayoutManager { curBlockArea.addBlock((Block) childArea); } } - + /** {@inheritDoc} */ public int getKeepTogetherStrength() { int strength = KEEP_AUTO; @@ -209,8 +209,8 @@ public class TableAndCaptionLayoutManager extends BlockStackingLayoutManager { */ strength = Math.max(strength, getParentKeepTogetherStrength()); return strength; - } - + } + /** {@inheritDoc} */ public int getKeepWithNextStrength() { return KEEP_AUTO; diff --git a/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java index 615145fa1..071082624 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.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.layoutmgr.table; import org.apache.fop.area.Area; @@ -50,7 +50,7 @@ public class TableCaptionLayoutManager extends BlockStackingLayoutManager { public TableCaption getTableCaptionFO() { return (TableCaption)this.fobj; } - + /** * Get the next break position for the caption. * @@ -195,7 +195,7 @@ public class TableCaptionLayoutManager extends BlockStackingLayoutManager { curBlockArea.addBlock((Block) childArea); } } - + /** {@inheritDoc} */ public int getKeepTogetherStrength() { int strength = KEEP_AUTO; @@ -208,7 +208,7 @@ public class TableCaptionLayoutManager extends BlockStackingLayoutManager { strength = Math.max(strength, getParentKeepTogetherStrength()); return strength; } - + /** {@inheritDoc} */ public int getKeepWithNextStrength() { return KEEP_AUTO; diff --git a/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java index 52915c008..ba5e232e9 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.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. @@ -240,7 +240,7 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager /** * Sets the total height of this cell on the current page. That is, the cell's bpd * plus before and after borders and paddings, plus the table's border-separation. - * + * * @param h the height of cell */ public void setTotalHeight(int h) { @@ -250,12 +250,12 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager /** * Add the areas for the break points. The cell contains block stacking layout * managers that add block areas. - * + * *

      In the collapsing-border model, the borders of a cell that spans over several * rows or columns are drawn separately for each grid unit. Therefore we must know the * height of each grid row spanned over by the cell. Also, if the cell is broken over * two pages we must know which spanned grid rows are present on the current page.

      - * + * * @param parentIter the iterator of the break positions * @param layoutContext the layout context for adding the areas * @param spannedGridRowHeights in collapsing-border model for a spanning cell, height @@ -296,7 +296,7 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager CommonBorderPaddingBackground padding = primaryGridUnit.getCell() .getCommonBorderPaddingBackground(); - int paddingRectBPD = totalHeight - borderBeforeWidth - borderAfterWidth; + int paddingRectBPD = totalHeight - borderBeforeWidth - borderAfterWidth; int cellBPD = paddingRectBPD; cellBPD -= padding.getPaddingBefore(borderBeforeWhich == ConditionalBorder.REST, this); cellBPD -= padding.getPaddingAfter(borderAfterWhich == ConditionalBorder.REST, this); @@ -488,7 +488,7 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager CommonBorderPaddingBackground padding = getTableCell().getCommonBorderPaddingBackground(); int paddingStart = padding.getPaddingStart(false, this); int paddingEnd = padding.getPaddingEnd(false, this); - + Block block = new Block(); TraitSetter.setProducerID(block, getTable().getId()); block.setPositioning(Block.ABSOLUTE); @@ -567,7 +567,7 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager strength = Math.max(strength, getParentKeepTogetherStrength()); return strength; } - + /** {@inheritDoc} */ public int getKeepWithNextStrength() { return KEEP_AUTO; //TODO FIX ME (table-cell has no keep-with-next!) diff --git a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java index 80e904f8f..ad8bec715 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java @@ -69,9 +69,9 @@ public class TableContentLayoutManager implements PercentBaseContext { private int startXOffset; private int usedBPD; - + private TableStepper stepper; - + /** * Main constructor * @param parent Parent layout manager @@ -88,19 +88,19 @@ public class TableContentLayoutManager implements PercentBaseContext { } stepper = new TableStepper(this); } - + /** * @return the table layout manager */ TableLayoutManager getTableLM() { return this.tableLM; } - + /** @return true if the table uses the separate border model. */ boolean isSeparateBorderModel() { return getTableLM().getTable().isSeparateBorderModel(); } - + /** * @return the column setup of this table */ @@ -142,14 +142,14 @@ public class TableContentLayoutManager implements PercentBaseContext { this.headerNetHeight = ElementListUtils.calcContentLength(this.headerList); if (log.isDebugEnabled()) { - log.debug("==> Header: " + log.debug("==> Header: " + headerNetHeight + " - " + this.headerList); } TableHeaderFooterPosition pos = new TableHeaderFooterPosition( getTableLM(), true, this.headerList); KnuthBox box = new KnuthBox(headerNetHeight, pos, false); if (getTableLM().getTable().omitHeaderAtBreak()) { - //We can simply add the table header at the start + //We can simply add the table header at the start //of the whole list headerAsFirst = box; } else { @@ -162,7 +162,7 @@ public class TableContentLayoutManager implements PercentBaseContext { this.footerNetHeight = ElementListUtils.calcContentLength(this.footerList); if (log.isDebugEnabled()) { - log.debug("==> Footer: " + log.debug("==> Footer: " + footerNetHeight + " - " + this.footerList); } //We can simply add the table footer at the end of the whole list @@ -195,17 +195,17 @@ public class TableContentLayoutManager implements PercentBaseContext { } return returnList; } - + /** * Creates Knuth elements by iterating over a TableRowIterator. * @param iter TableRowIterator instance to fetch rows from * @param context Active LayoutContext * @param alignment alignment indicator - * @param bodyType Indicates what kind of body is being processed + * @param bodyType Indicates what kind of body is being processed * (BODY, HEADER or FOOTER) * @return An element list */ - private LinkedList getKnuthElementsForRowIterator(TableRowIterator iter, + private LinkedList getKnuthElementsForRowIterator(TableRowIterator iter, LayoutContext context, int alignment, int bodyType) { LinkedList returnList = new LinkedList(); EffRow[] rowGroup = iter.getNextRowGroup(); @@ -225,12 +225,12 @@ public class TableContentLayoutManager implements PercentBaseContext { returnList.addAll(nextRowGroupElems); while ((rowGroup = iter.getNextRowGroup()) != null) { rowGroupLM = new RowGroupLayoutManager(getTableLM(), rowGroup, stepper); - + //Note previous pending keep-with-next and clear the strength //(as the layout context is reused) int keepWithNextPending = context.getKeepWithNextPending(); context.clearKeepWithNextPending(); - + //Get elements for next row group nextRowGroupElems = rowGroupLM.getNextKnuthElements(context, alignment, bodyType); /* @@ -238,13 +238,13 @@ public class TableContentLayoutManager implements PercentBaseContext { * group) may be used to represent the break between the two row groups. * Its penalty value and break class must just be overridden by the * characteristics of the keep or break between the two. - * + * * However, we mustn't forget that if the after border of the last row of * the row group is thicker in the normal case than in the trailing case, * an additional glue will be appended to the element list. So we may have * to go two steps backwards in the list. */ - + //Determine keep constraints int penaltyStrength = BlockLevelLayoutManager.KEEP_AUTO; penaltyStrength = Math.max(penaltyStrength, keepWithNextPending); @@ -252,7 +252,7 @@ public class TableContentLayoutManager implements PercentBaseContext { context.clearKeepWithPreviousPending(); penaltyStrength = Math.max(penaltyStrength, getTableLM().getKeepTogetherStrength()); int penaltyValue = KeepUtil.getPenaltyForKeep(penaltyStrength); - + breakBetween = BreakUtil.compareBreakClasses(breakBetween, context.getBreakBefore()); if (breakBetween != Constants.EN_AUTO) { @@ -291,16 +291,16 @@ public class TableContentLayoutManager implements PercentBaseContext { context.setBreakBefore(breakBefore); //fox:widow-content-limit - int widowContentLimit = getTableLM().getTable().getWidowContentLimit().getValue(); + int widowContentLimit = getTableLM().getTable().getWidowContentLimit().getValue(); if (widowContentLimit != 0 && bodyType == TableRowIterator.BODY) { ElementListUtils.removeLegalBreaks(returnList, widowContentLimit); } //fox:orphan-content-limit - int orphanContentLimit = getTableLM().getTable().getOrphanContentLimit().getValue(); + int orphanContentLimit = getTableLM().getTable().getOrphanContentLimit().getValue(); if (orphanContentLimit != 0 && bodyType == TableRowIterator.BODY) { ElementListUtils.removeLegalBreaksFromEnd(returnList, orphanContentLimit); } - + return returnList; } @@ -313,7 +313,7 @@ public class TableContentLayoutManager implements PercentBaseContext { int col = gu.getColIndex(); return startXOffset + getTableLM().getColumns().getXOffset(col + 1, getTableLM()); } - + /** * Adds the areas generated by this layout manager to the area tree. * @param parentIter the position iterator @@ -358,7 +358,7 @@ public class TableContentLayoutManager implements PercentBaseContext { } } else if (pos instanceof TableHFPenaltyPosition) { //ignore for now, see special handling below if break is at a penalty - //Only if the last position in this part/page us such a position it will be used + //Only if the last position in this part/page us such a position it will be used } else if (pos instanceof TableContentPosition) { tablePositions.add(pos); } else { @@ -376,23 +376,23 @@ public class TableContentLayoutManager implements PercentBaseContext { headerElements = penaltyPos.headerElements; } if (penaltyPos.footerElements != null) { - footerElements = penaltyPos.footerElements; + footerElements = penaltyPos.footerElements; } } Map markers = getTableLM().getTable().getMarkers(); if (markers != null) { - getTableLM().getCurrentPV().addMarkers(markers, + getTableLM().getCurrentPV().addMarkers(markers, true, getTableLM().isFirst(firstPos), getTableLM().isLast(lastCheckPos)); } - + if (headerElements != null) { //header positions for the last part are the second-to-last element and need to //be handled first before all other TableContentPositions addHeaderFooterAreas(headerElements, tableLM.getTable().getTableHeader(), painter, false); } - + if (tablePositions.isEmpty()) { // TODO make sure this actually never happens log.error("tablePositions empty." @@ -407,11 +407,11 @@ public class TableContentLayoutManager implements PercentBaseContext { addHeaderFooterAreas(footerElements, tableLM.getTable().getTableFooter(), painter, true); } - + this.usedBPD += painter.getAccumulatedBPD(); if (markers != null) { - getTableLM().getCurrentPV().addMarkers(markers, + getTableLM().getCurrentPV().addMarkers(markers, false, getTableLM().isFirst(firstPos), getTableLM().isLast(lastCheckPos)); } } @@ -435,7 +435,7 @@ public class TableContentLayoutManager implements PercentBaseContext { /** * Iterates over the positions corresponding to the table's body (which may contain * several table-body elements!) and adds the corresponding areas. - * + * * @param iterator iterator over TableContentPosition elements. Those positions * correspond to the elements of the body present on the current page * @param painter @@ -472,13 +472,13 @@ public class TableContentLayoutManager implements PercentBaseContext { */ private void addTablePartAreas(List positions, RowPainter painter, TablePart body, boolean isFirstPos, boolean isLastPos, boolean lastInBody, boolean lastOnPage) { - getTableLM().getCurrentPV().addMarkers(body.getMarkers(), + getTableLM().getCurrentPV().addMarkers(body.getMarkers(), true, isFirstPos, isLastPos); painter.startTablePart(body); for (Iterator iter = positions.iterator(); iter.hasNext();) { painter.handleTableContentPosition((TableContentPosition) iter.next()); } - getTableLM().getCurrentPV().addMarkers(body.getMarkers(), + getTableLM().getCurrentPV().addMarkers(body.getMarkers(), false, isFirstPos, isLastPos); painter.endTablePart(lastInBody, lastOnPage); } @@ -501,7 +501,7 @@ public class TableContentLayoutManager implements PercentBaseContext { // --------- Property Resolution related functions --------- // /** - * {@inheritDoc} + * {@inheritDoc} */ public int getBaseLength(int lengthBase, FObj fobj) { return tableLM.getBaseLength(lengthBase, fobj); diff --git a/src/java/org/apache/fop/layoutmgr/table/TableContentPosition.java b/src/java/org/apache/fop/layoutmgr/table/TableContentPosition.java index 62d25fcb1..457cfaef3 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableContentPosition.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableContentPosition.java @@ -64,7 +64,7 @@ class TableContentPosition extends Position { * Sets the row corresponding to this position if it starts a new page. In which case, * if the delay mechanism is on, this is the delayed row that starts the page, and not * the current row being extended. - * + * * @param newPageRow the row that will start the page if this position is the first * one on that page */ diff --git a/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java index d370dc37f..143c63bb9 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java @@ -59,15 +59,15 @@ import org.apache.fop.util.BreakUtil; * The table then creates areas for the columns, bodies and rows * the render background. */ -public class TableLayoutManager extends BlockStackingLayoutManager +public class TableLayoutManager extends BlockStackingLayoutManager implements ConditionalElementListener { /** * logging instance */ private static Log log = LogFactory.getLog(TableLayoutManager.class); - - private TableContentLayoutManager contentLM; + + private TableContentLayoutManager contentLM; private ColumnSetup columns = null; private Block curBlockArea; @@ -81,7 +81,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager private boolean discardPaddingAfter; private MinOptMax effSpaceBefore; private MinOptMax effSpaceAfter; - + private int halfBorderSeparationBPD; private int halfBorderSeparationIPD; @@ -90,7 +90,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager /** * Temporary holder of column background informations for a table-cell's area. - * + * * @see TableLayoutManager#registerColumnBackgroundArea(TableColumn, Block, int) */ private static final class ColumnBackgroundInfo { @@ -118,14 +118,14 @@ public class TableLayoutManager extends BlockStackingLayoutManager public Table getTable() { return (Table)this.fobj; } - + /** * @return the column setup for this table. */ public ColumnSetup getColumns() { return this.columns; } - + /** {@inheritDoc} */ public void initialize() { foSpaceBefore = new SpaceVal( @@ -133,8 +133,8 @@ public class TableLayoutManager extends BlockStackingLayoutManager foSpaceAfter = new SpaceVal( getTable().getCommonMarginBlock().spaceAfter, this).getSpace(); startIndent = getTable().getCommonMarginBlock().startIndent.getValue(this); - endIndent = getTable().getCommonMarginBlock().endIndent.getValue(this); - + endIndent = getTable().getCommonMarginBlock().endIndent.getValue(this); + if (getTable().isSeparateBorderModel()) { this.halfBorderSeparationBPD = getTable().getBorderSeparation().getBPD().getLength() .getValue(this) / 2; @@ -144,23 +144,23 @@ public class TableLayoutManager extends BlockStackingLayoutManager this.halfBorderSeparationBPD = 0; this.halfBorderSeparationIPD = 0; } - - if (!getTable().isAutoLayout() - && getTable().getInlineProgressionDimension().getOptimum(this).getEnum() + + if (!getTable().isAutoLayout() + && getTable().getInlineProgressionDimension().getOptimum(this).getEnum() != EN_AUTO) { autoLayout = false; } } private void resetSpaces() { - this.discardBorderBefore = false; - this.discardBorderAfter = false; - this.discardPaddingBefore = false; + this.discardBorderBefore = false; + this.discardBorderAfter = false; + this.discardPaddingBefore = false; this.discardPaddingAfter = false; this.effSpaceBefore = null; this.effSpaceAfter = null; } - + /** * @return half the value of border-separation.block-progression-dimension, or 0 if * border-collapse="collapse". @@ -179,7 +179,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager /** {@inheritDoc} */ public List getNextKnuthElements(LayoutContext context, int alignment) { - + List returnList = new LinkedList(); /* @@ -201,7 +201,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager int sumOfColumns = columns.getSumOfColumnWidths(this); if (!autoLayout && sumOfColumns > getContentAreaIPD()) { log.debug(FONode.decorateWithContextInfo( - "The sum of all column widths is larger than the specified table width.", + "The sum of all column widths is larger than the specified table width.", getTable())); updateContentAreaIPDwithOverconstrainedAdjust(sumOfColumns); } @@ -213,7 +213,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager getContentAreaIPD(), context.getRefIPD(), getTable().getLocator()); } - + /* initialize unit to determine computed values * for proportional-column-width() */ @@ -224,7 +224,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager if (!firstVisibleMarkServed) { addKnuthElementsForSpaceBefore(returnList, alignment); } - + if (getTable().isSeparateBorderModel()) { addKnuthElementsForBorderPaddingBefore(returnList, !firstVisibleMarkServed); firstVisibleMarkServed = true; @@ -279,7 +279,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager int breakAfter = BreakUtil.compareBreakClasses(getTable().getBreakAfter(), childLC.getBreakAfter()); if (breakAfter != Constants.EN_AUTO) { - returnList.add(new BreakElement(getAuxiliaryPosition(), + returnList.add(new BreakElement(getAuxiliaryPosition(), 0, -KnuthElement.INFINITE, breakAfter, context)); } @@ -295,7 +295,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager * be known. The traits can't then be set when the areas for the cell are created * since at that moment this bpd is yet unknown. So they will instead be set in * TableLM's {@link #addAreas(PositionIterator, LayoutContext)} method. - * + * * @param column the table-column element from which the cell gets background * informations * @param backgroundArea the block of the cell's dimensions that will hold the column @@ -329,7 +329,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager } int startXOffset = getTable().getCommonMarginBlock().startIndent.getValue(this); - + // add column, body then row areas // BPD of the table, i.e., height of its content; table's borders and paddings not counted @@ -357,30 +357,30 @@ public class TableLayoutManager extends BlockStackingLayoutManager } if (getTable().isSeparateBorderModel()) { - TraitSetter.addBorders(curBlockArea, - getTable().getCommonBorderPaddingBackground(), + TraitSetter.addBorders(curBlockArea, + getTable().getCommonBorderPaddingBackground(), discardBorderBefore, discardBorderAfter, false, false, this); - TraitSetter.addPadding(curBlockArea, - getTable().getCommonBorderPaddingBackground(), + TraitSetter.addPadding(curBlockArea, + getTable().getCommonBorderPaddingBackground(), discardPaddingBefore, discardPaddingAfter, false, false, this); } - TraitSetter.addBackground(curBlockArea, + TraitSetter.addBackground(curBlockArea, getTable().getCommonBorderPaddingBackground(), this); TraitSetter.addMargins(curBlockArea, - getTable().getCommonBorderPaddingBackground(), + getTable().getCommonBorderPaddingBackground(), startIndent, endIndent, this); - TraitSetter.addBreaks(curBlockArea, + TraitSetter.addBreaks(curBlockArea, getTable().getBreakBefore(), getTable().getBreakAfter()); - TraitSetter.addSpaceBeforeAfter(curBlockArea, layoutContext.getSpaceAdjust(), + TraitSetter.addSpaceBeforeAfter(curBlockArea, layoutContext.getSpaceAdjust(), effSpaceBefore, effSpaceAfter); flush(); resetSpaces(); curBlockArea = null; - + notifyEndOfLayout(); } @@ -403,11 +403,11 @@ public class TableLayoutManager extends BlockStackingLayoutManager // Set up dimensions // Must get dimensions from parent area /*Area parentArea =*/ parentLM.getParentArea(curBlockArea); - + TraitSetter.setProducerID(curBlockArea, getTable().getId()); curBlockArea.setIPD(getContentAreaIPD()); - + setCurrentArea(curBlockArea); } return curBlockArea; @@ -426,7 +426,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager /** * Adds the given area to this layout manager's area, without updating the used bpd. - * + * * @param background an area */ void addBackgroundArea(Block background) { @@ -442,7 +442,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager /** {@inheritDoc} */ public void discardSpace(KnuthGlue spaceGlue) { // TODO Auto-generated method stub - + } /** {@inheritDoc} */ @@ -451,7 +451,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager strength = Math.max(strength, getParentKeepTogetherStrength()); return strength; } - + /** {@inheritDoc} */ public int getKeepWithNextStrength() { return KeepUtil.getCombinedBlockLevelKeepStrength(getTable().getKeepWithNext()); @@ -465,7 +465,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager // --------- Property Resolution related functions --------- // /** - * {@inheritDoc} + * {@inheritDoc} */ public int getBaseLength(int lengthBase, FObj fobj) { // Special handler for TableColumn width specifications @@ -488,18 +488,18 @@ public class TableLayoutManager extends BlockStackingLayoutManager } } } - + /** {@inheritDoc} */ public void notifySpace(RelSide side, MinOptMax effectiveLength) { if (RelSide.BEFORE == side) { if (log.isDebugEnabled()) { - log.debug(this + ": Space " + side + ", " + log.debug(this + ": Space " + side + ", " + this.effSpaceBefore + "-> " + effectiveLength); } this.effSpaceBefore = effectiveLength; } else { if (log.isDebugEnabled()) { - log.debug(this + ": Space " + side + ", " + log.debug(this + ": Space " + side + ", " + this.effSpaceAfter + "-> " + effectiveLength); } this.effSpaceAfter = effectiveLength; diff --git a/src/java/org/apache/fop/layoutmgr/table/TableStepper.java b/src/java/org/apache/fop/layoutmgr/table/TableStepper.java index 6aa619368..a3fba279e 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableStepper.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableStepper.java @@ -83,7 +83,7 @@ public class TableStepper { /** * Flag used to produce an infinite penalty if the height of the current row is * smaller than the first step for that row (may happen with row-spanning cells). - * + * * @see #considerRowLastStep(int) */ private boolean rowHeightSmallerThanFirstStep; @@ -107,7 +107,7 @@ public class TableStepper { /** * Initializes the fields of this instance to handle a new row group. - * + * * @param rows the new row group to handle */ private void setup(EffRow[] rows) { @@ -151,7 +151,7 @@ public class TableStepper { /** * Creates ActiveCell instances for cells starting on the row at the given index. - * + * * @param activeCellList the list that will hold the active cells * @param rowIndex the index of the row from which cells must be activated */ @@ -289,7 +289,7 @@ public class TableStepper { /** * Returns the first step for the current row group. - * + * * @return the first step for the current row group */ private int getFirstStep() { @@ -302,7 +302,7 @@ public class TableStepper { /** * Returns the next break possibility. - * + * * @return the next step */ private int getNextStep() { @@ -342,7 +342,7 @@ public class TableStepper { /** * Computes the minimal necessary step to make the next row fit. That is, so such as * cell on the next row can contribute some content. - * + * * @param cells the cells occupying the next row (may include cells starting on * previous rows and spanning over this one) */ @@ -355,7 +355,7 @@ public class TableStepper { /** * Computes the next minimal step. - * + * * @return the minimal step from the active cells, < 0 if there is no such step */ private int computeMinStep() { @@ -379,7 +379,7 @@ public class TableStepper { /** * Signals the first step to the active cells, to allow them to add more content to * the step if possible. - * + * * @see ActiveCell#signalRowFirstStep(int) */ private void signalRowFirstStep() { @@ -391,7 +391,7 @@ public class TableStepper { /** * Signals the next selected step to the active cells. - * + * * @param step the next step */ private void signalNextStep(int step) { @@ -416,7 +416,7 @@ public class TableStepper { * infinite penalty for this step. This will prevent the breaking algorithm from * choosing this break, but still allow to create the appropriate TableContentPosition * for the cells ending on the current row.

      - * + * * @param step the next step * @return the updated step if any */ @@ -445,7 +445,7 @@ public class TableStepper { } for (Iterator iter = activeCells.iterator(); iter.hasNext();) { ActiveCell activeCell = (ActiveCell) iter.next(); - activeCell.endRow(activeRowIndex); + activeCell.endRow(activeRowIndex); if (!activeCell.endsOnRow(activeRowIndex)) { activeCell.signalRowLastStep(maxStep); } diff --git a/src/java/org/apache/fop/pdf/ASCII85Filter.java b/src/java/org/apache/fop/pdf/ASCII85Filter.java index 2114ea540..df82c5179 100644 --- a/src/java/org/apache/fop/pdf/ASCII85Filter.java +++ b/src/java/org/apache/fop/pdf/ASCII85Filter.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.pdf; import java.io.OutputStream; @@ -46,7 +46,7 @@ public class ASCII85Filter extends PDFFilter { public boolean isASCIIFilter() { return true; } - + /** * Get the decode parameters. * diff --git a/src/java/org/apache/fop/pdf/ASCIIHexFilter.java b/src/java/org/apache/fop/pdf/ASCIIHexFilter.java index 41c428998..01dc75190 100644 --- a/src/java/org/apache/fop/pdf/ASCIIHexFilter.java +++ b/src/java/org/apache/fop/pdf/ASCIIHexFilter.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.pdf; import java.io.OutputStream; @@ -29,7 +29,7 @@ import org.apache.xmlgraphics.util.io.ASCIIHexOutputStream; * This filter converts a pdf stream to ASCII hex data. */ public class ASCIIHexFilter extends PDFFilter { - + /** * Get the name of this filter. * @@ -45,7 +45,7 @@ public class ASCIIHexFilter extends PDFFilter { public boolean isASCIIFilter() { return true; } - + /** * Get the decode params. * diff --git a/src/java/org/apache/fop/pdf/AbstractPDFStream.java b/src/java/org/apache/fop/pdf/AbstractPDFStream.java index 16190da99..1e1f1f259 100644 --- a/src/java/org/apache/fop/pdf/AbstractPDFStream.java +++ b/src/java/org/apache/fop/pdf/AbstractPDFStream.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.pdf; import java.io.IOException; @@ -43,13 +43,13 @@ public abstract class AbstractPDFStream extends PDFDictionary { } /** - * Sets up the default filters for this stream if they haven't been set + * Sets up the default filters for this stream if they haven't been set * from outside. */ protected void setupFilterList() { if (!getFilterList().isInitialized()) { getFilterList().addDefaultFilters( - getDocumentSafely().getFilterMap(), + getDocumentSafely().getFilterMap(), PDFFilterList.DEFAULT_FILTER); } prepareImplicitFilters(); @@ -78,18 +78,18 @@ public abstract class AbstractPDFStream extends PDFDictionary { /** * Returns a value that hints at the size of the encoded stream. This is * used to optimize buffer allocation so fewer buffer reallocations are - * necessary. + * necessary. * @return an estimated size (0 if no hint can be given) * @throws IOException in case of an I/O problem */ protected abstract int getSizeHint() throws IOException; - + /** * Sends the raw stream data to the target OutputStream. * @param out OutputStream to write to * @throws IOException In case of an I/O problem */ - protected abstract void outputRawStreamData(OutputStream out) + protected abstract void outputRawStreamData(OutputStream out) throws IOException; /** @@ -104,10 +104,10 @@ public abstract class AbstractPDFStream extends PDFDictionary { byte[] p = encode("stream\n"); out.write(p); length += p.length; - + encodedStream.outputContents(out); length += encodedStream.getSize(); - + p = encode("\nendstream"); out.write(p); length += p.length; @@ -147,7 +147,7 @@ public abstract class AbstractPDFStream extends PDFDictionary { byte[] buf = encode("stream\n"); out.write(buf); bytesWritten += buf.length; - + //Stream contents CloseBlockerOutputStream cbout = new CloseBlockerOutputStream(out); CountingOutputStream cout = new CountingOutputStream(cbout); @@ -156,12 +156,12 @@ public abstract class AbstractPDFStream extends PDFDictionary { filteredOutput.close(); refLength.setNumber(new Integer(cout.getCount())); bytesWritten += cout.getCount(); - + //Stream trailer buf = encode("\nendstream"); out.write(buf); bytesWritten += buf.length; - + return bytesWritten; } @@ -177,7 +177,7 @@ public abstract class AbstractPDFStream extends PDFDictionary { Writer writer = PDFDocument.getWriterFor(cout); writer.write(getObjectID()); //int length = 0; - + StreamCache encodedStream = null; PDFNumber refLength = null; final Object lengthEntry; @@ -189,10 +189,10 @@ public abstract class AbstractPDFStream extends PDFDictionary { encodedStream = encodeStream(); lengthEntry = new Integer(encodedStream.getSize() + 1); } - + populateStreamDict(lengthEntry); writeDictionary(cout, writer); - + //Send encoded stream to target OutputStream writer.flush(); if (encodedStream == null) { @@ -201,7 +201,7 @@ public abstract class AbstractPDFStream extends PDFDictionary { outputStreamData(encodedStream, cout); encodedStream.clear(); //Encoded stream can now be discarded } - + writer.write("\nendobj\n"); writer.flush(); return cout.getCount(); diff --git a/src/java/org/apache/fop/pdf/AlphaRasterImage.java b/src/java/org/apache/fop/pdf/AlphaRasterImage.java index 0b83cc3d6..ae39cadb7 100644 --- a/src/java/org/apache/fop/pdf/AlphaRasterImage.java +++ b/src/java/org/apache/fop/pdf/AlphaRasterImage.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.pdf; import java.awt.image.DataBuffer; @@ -33,7 +33,7 @@ import org.apache.xmlgraphics.image.GraphicsUtil; * PDFImage implementation for alpha channel "images". */ public class AlphaRasterImage implements PDFImage { - + private int bitsPerComponent; private PDFDeviceColorSpace colorSpace; private Raster alpha; @@ -117,7 +117,7 @@ public class AlphaRasterImage implements PDFImage { public String getSoftMask() { return null; } - + /** {@inheritDoc} */ public PDFReference getSoftMaskReference() { return null; @@ -127,12 +127,12 @@ public class AlphaRasterImage implements PDFImage { public boolean isInverted() { return false; } - + /** {@inheritDoc} */ public void outputContents(OutputStream out) throws IOException { int w = getWidth(); int h = getHeight(); - + //Check Raster int nbands = alpha.getNumBands(); if (nbands != 1) { @@ -171,7 +171,7 @@ public class AlphaRasterImage implements PDFImage { } } - + /** {@inheritDoc} */ public void populateXObjectDictionary(PDFDictionary dict) { //nop diff --git a/src/java/org/apache/fop/pdf/BitmapImage.java b/src/java/org/apache/fop/pdf/BitmapImage.java index 69b51dac3..186c00986 100644 --- a/src/java/org/apache/fop/pdf/BitmapImage.java +++ b/src/java/org/apache/fop/pdf/BitmapImage.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.pdf; import java.io.IOException; @@ -170,12 +170,12 @@ public class BitmapImage implements PDFImage { public boolean isInverted() { return false; } - + /** {@inheritDoc} */ public void outputContents(OutputStream out) throws IOException { out.write(bitmaps); } - + /** {@inheritDoc} */ public void populateXObjectDictionary(PDFDictionary dict) { //nop diff --git a/src/java/org/apache/fop/pdf/CCFFilter.java b/src/java/org/apache/fop/pdf/CCFFilter.java index 03561629c..117070bb1 100644 --- a/src/java/org/apache/fop/pdf/CCFFilter.java +++ b/src/java/org/apache/fop/pdf/CCFFilter.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.pdf; /** diff --git a/src/java/org/apache/fop/pdf/CMapBuilder.java b/src/java/org/apache/fop/pdf/CMapBuilder.java index f55c34fcf..8e30ad04a 100644 --- a/src/java/org/apache/fop/pdf/CMapBuilder.java +++ b/src/java/org/apache/fop/pdf/CMapBuilder.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,22 +16,22 @@ */ /* $Id$ */ - + package org.apache.fop.pdf; import java.io.IOException; import java.io.Writer; public class CMapBuilder { - + protected String name; protected Writer writer; - + public CMapBuilder(Writer writer, String name) { this.writer = writer; this.name = name; } - + /** * Writes the CMap to a Writer. * @throws IOException if an I/O error occurs @@ -51,7 +51,7 @@ public class CMapBuilder { writeStreamAfterComments(); writeUseCMap(); } - + protected void writePreStream() throws IOException { // writer.write("/Type /CMap\n"); // writer.write(sysInfo.toPDFString()); @@ -86,7 +86,7 @@ public class CMapBuilder { writer.write(" def\n"); writer.write("end def\n"); } - + protected void writeCIDSystemInfo() throws IOException { writeCIDSystemInfo("Adobe", "Identity", 0); } diff --git a/src/java/org/apache/fop/pdf/DCTFilter.java b/src/java/org/apache/fop/pdf/DCTFilter.java index 92809d927..183f2a694 100644 --- a/src/java/org/apache/fop/pdf/DCTFilter.java +++ b/src/java/org/apache/fop/pdf/DCTFilter.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.pdf; /** diff --git a/src/java/org/apache/fop/pdf/FlateFilter.java b/src/java/org/apache/fop/pdf/FlateFilter.java index a652c4534..62b3d5769 100644 --- a/src/java/org/apache/fop/pdf/FlateFilter.java +++ b/src/java/org/apache/fop/pdf/FlateFilter.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.pdf; import java.io.IOException; diff --git a/src/java/org/apache/fop/pdf/InMemoryStreamCache.java b/src/java/org/apache/fop/pdf/InMemoryStreamCache.java index 03552aa23..7e9a78aa4 100644 --- a/src/java/org/apache/fop/pdf/InMemoryStreamCache.java +++ b/src/java/org/apache/fop/pdf/InMemoryStreamCache.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.pdf; import java.io.ByteArrayOutputStream; @@ -72,7 +72,7 @@ public class InMemoryStreamCache implements StreamCache { public void write(byte[] data) throws IOException { getOutputStream().write(data); } - + /** * Outputs the cached bytes to the given stream. * @param out the output stream to write to diff --git a/src/java/org/apache/fop/pdf/NullFilter.java b/src/java/org/apache/fop/pdf/NullFilter.java index 6f2e7f069..f098860c9 100644 --- a/src/java/org/apache/fop/pdf/NullFilter.java +++ b/src/java/org/apache/fop/pdf/NullFilter.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.pdf; import java.io.IOException; diff --git a/src/java/org/apache/fop/pdf/PDFAMode.java b/src/java/org/apache/fop/pdf/PDFAMode.java index d27f64e83..1b433e66d 100644 --- a/src/java/org/apache/fop/pdf/PDFAMode.java +++ b/src/java/org/apache/fop/pdf/PDFAMode.java @@ -28,7 +28,7 @@ public final class PDFAMode { public static final PDFAMode PDFA_1A = new PDFAMode("PDF/A-1a"); /** PDF/A-1b enabled */ public static final PDFAMode PDFA_1B = new PDFAMode("PDF/A-1b"); - + private String name; /** @@ -43,13 +43,13 @@ public final class PDFAMode { public String getName() { return this.name; } - + /** @return true if this mode obey the restrictions established by PDF/A-1b. */ public boolean isPDFA1LevelB() { return (this != DISABLED); //PDF/A-1a is a superset of PDF/A-1b! } - + /** * Returns the mode enum object given a String. * @param s the string @@ -64,10 +64,10 @@ public final class PDFAMode { return DISABLED; } } - + /** {@inheritDoc} */ public String toString() { return name; } - + } diff --git a/src/java/org/apache/fop/pdf/PDFAction.java b/src/java/org/apache/fop/pdf/PDFAction.java index 7d10276ae..81b32b97c 100644 --- a/src/java/org/apache/fop/pdf/PDFAction.java +++ b/src/java/org/apache/fop/pdf/PDFAction.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.pdf; /** diff --git a/src/java/org/apache/fop/pdf/PDFAnnotList.java b/src/java/org/apache/fop/pdf/PDFAnnotList.java index 30116c0f8..0a8710627 100644 --- a/src/java/org/apache/fop/pdf/PDFAnnotList.java +++ b/src/java/org/apache/fop/pdf/PDFAnnotList.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.pdf; // Java diff --git a/src/java/org/apache/fop/pdf/PDFArray.java b/src/java/org/apache/fop/pdf/PDFArray.java index 1fe55384c..7c5f8ba9b 100644 --- a/src/java/org/apache/fop/pdf/PDFArray.java +++ b/src/java/org/apache/fop/pdf/PDFArray.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.pdf; import java.io.IOException; @@ -88,10 +88,10 @@ public class PDFArray extends PDFObject { public PDFArray(PDFObject parent, Collection values) { /* generic creation of PDF object */ super(parent); - + this.values.addAll(values); } - + /** * Create the array object * @param parent the array's parent if any @@ -100,12 +100,12 @@ public class PDFArray extends PDFObject { public PDFArray(PDFObject parent, Object[] values) { /* generic creation of PDF object */ super(parent); - + for (int i = 0, c = values.length; i < c; i++) { this.values.add(values[i]); } } - + /** * Returns the length of the array * @return the length of the array @@ -113,7 +113,7 @@ public class PDFArray extends PDFObject { public int length() { return this.values.size(); } - + /** * Sets an entry at a given location. * @param index the index of the value to set @@ -122,7 +122,7 @@ public class PDFArray extends PDFObject { public void set(int index, Object obj) { this.values.set(index, obj); } - + /** * Sets an entry at a given location. * @param index the index of the value to set @@ -131,7 +131,7 @@ public class PDFArray extends PDFObject { public void set(int index, double value) { this.values.set(index, new Double(value)); } - + /** * Gets an entry at a given location. * @param index the index of the value to set @@ -140,7 +140,7 @@ public class PDFArray extends PDFObject { public Object get(int index) { return this.values.get(index); } - + /** * Adds a new value to the array. * @param obj the value @@ -154,7 +154,7 @@ public class PDFArray extends PDFObject { } this.values.add(obj); } - + /** * Adds a new value to the array. * @param value the value @@ -162,7 +162,7 @@ public class PDFArray extends PDFObject { public void add(double value) { this.values.add(new Double(value)); } - + /** {@inheritDoc} */ protected int output(OutputStream stream) throws IOException { CountingOutputStream cout = new CountingOutputStream(stream); @@ -170,7 +170,7 @@ public class PDFArray extends PDFObject { if (hasObjectNumber()) { writer.write(getObjectID()); } - + writer.write('['); for (int i = 0; i < values.size(); i++) { if (i > 0) { @@ -180,13 +180,13 @@ public class PDFArray extends PDFObject { formatObject(obj, cout, writer); } writer.write(']'); - + if (hasObjectNumber()) { writer.write("\nendobj\n"); } - + writer.flush(); return cout.getCount(); } - + } diff --git a/src/java/org/apache/fop/pdf/PDFCIDFont.java b/src/java/org/apache/fop/pdf/PDFCIDFont.java index 3fcedbbb9..3224eb567 100644 --- a/src/java/org/apache/fop/pdf/PDFCIDFont.java +++ b/src/java/org/apache/fop/pdf/PDFCIDFont.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.pdf; import org.apache.fop.fonts.CIDFontType; @@ -60,8 +60,8 @@ public class PDFCIDFont extends PDFObject { int[] w, String registry, String ordering, int supplement, PDFCIDFontDescriptor descriptor) { - this(basefont, cidtype, dw, - new PDFWArray(w), + this(basefont, cidtype, dw, + new PDFWArray(w), new PDFCIDSystemInfo(registry, ordering, supplement), descriptor); } @@ -79,8 +79,8 @@ public class PDFCIDFont extends PDFObject { int[] w, PDFCIDSystemInfo systemInfo, PDFCIDFontDescriptor descriptor) { - this(basefont, cidtype, dw, - new PDFWArray(w), + this(basefont, cidtype, dw, + new PDFWArray(w), systemInfo, descriptor); } @@ -189,7 +189,7 @@ public class PDFCIDFont extends PDFObject { } else if (cidFontType == CIDFontType.CIDTYPE2) { return cidFontType.getName(); } else { - throw new IllegalArgumentException("Unsupported CID font type: " + throw new IllegalArgumentException("Unsupported CID font type: " + cidFontType.getName()); } } diff --git a/src/java/org/apache/fop/pdf/PDFCIDFontDescriptor.java b/src/java/org/apache/fop/pdf/PDFCIDFontDescriptor.java index df552d96e..726e46f23 100644 --- a/src/java/org/apache/fop/pdf/PDFCIDFontDescriptor.java +++ b/src/java/org/apache/fop/pdf/PDFCIDFontDescriptor.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.pdf; // based on work by Takayuki Takeuchi diff --git a/src/java/org/apache/fop/pdf/PDFCIDSystemInfo.java b/src/java/org/apache/fop/pdf/PDFCIDSystemInfo.java index 33d77d9e8..0228addb6 100644 --- a/src/java/org/apache/fop/pdf/PDFCIDSystemInfo.java +++ b/src/java/org/apache/fop/pdf/PDFCIDSystemInfo.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.pdf; // based on work by Takayuki Takeuchi diff --git a/src/java/org/apache/fop/pdf/PDFCMap.java b/src/java/org/apache/fop/pdf/PDFCMap.java index 1be5e9dc4..57d148fc2 100644 --- a/src/java/org/apache/fop/pdf/PDFCMap.java +++ b/src/java/org/apache/fop/pdf/PDFCMap.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.pdf; import java.io.IOException; @@ -421,7 +421,7 @@ public class PDFCMap extends PDFStream { protected CMapBuilder createCMapBuilder(Writer writer) { return new CMapBuilder(writer, this.name); } - + /** {@inheritDoc} */ protected int output(OutputStream stream) throws IOException { CMapBuilder builder = createCMapBuilder(getBufferWriter()); diff --git a/src/java/org/apache/fop/pdf/PDFCharProcs.java b/src/java/org/apache/fop/pdf/PDFCharProcs.java index a9eb06fca..73fe19a5e 100644 --- a/src/java/org/apache/fop/pdf/PDFCharProcs.java +++ b/src/java/org/apache/fop/pdf/PDFCharProcs.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,11 +16,11 @@ */ /* $Id$ */ - + package org.apache.fop.pdf; import java.util.Map; -import java.util.HashMap; +import java.util.HashMap; /** * class representing a /CharProcs dictionary for Type3 fonts. diff --git a/src/java/org/apache/fop/pdf/PDFColor.java b/src/java/org/apache/fop/pdf/PDFColor.java index 3cbfa2bbc..5bac9532c 100644 --- a/src/java/org/apache/fop/pdf/PDFColor.java +++ b/src/java/org/apache/fop/pdf/PDFColor.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.pdf; import java.awt.Color; @@ -44,11 +44,11 @@ public class PDFColor extends PDFPathPaint { private double magenta = -1.0; private double yellow = -1.0; private double black = -1.0; - + // TODO - It would probably be better to reorganize PDFPathPaint/PDFColor/PDFColorSpace - // class hierarchy. However, at this early stages of my FOP understanding, I can - // not really oversee the consequences of such a switch (nor whether it would be - // appropriate). + // class hierarchy. However, at this early stages of my FOP understanding, I can + // not really oversee the consequences of such a switch (nor whether it would be + // appropriate). private ColorExt colorExt = null; /** @@ -66,24 +66,24 @@ public class PDFColor extends PDFPathPaint { this.green = theGreen; this.blue = theBlue; } - + /** * Create PDFColor for the given document and based on the java.awt.Color object - * - * In case the java.awt.Color is an instance of the ColorExt class a PDFICCStream is added to + * + * In case the java.awt.Color is an instance of the ColorExt class a PDFICCStream is added to * the PDFDocument that is being created - * + * * @param pdfDoc PDFDocument that is being created * @param col Color object from which to create this PDFColor */ public PDFColor(PDFDocument pdfDoc, Color col) { this(col); // TODO - 1) There is a potential conflict when FOP and Batik elements use the same color - // profile name for different profiles. - // 2) In case the same color profile is used with different names it will be + // profile name for different profiles. + // 2) In case the same color profile is used with different names it will be // included multiple times in the PDF // - if (colorExt != null + if (colorExt != null && pdfDoc.getResources().getColorSpace(colorExt.getIccProfileName()) == null) { PDFICCStream pdfIccStream = new PDFICCStream(); ColorSpace ceCs = colorExt.getOrigColorSpace(); @@ -98,17 +98,17 @@ public class PDFColor extends PDFPathPaint { pdfDoc.getFactory().makeICCBasedColorSpace( null, colorExt.getIccProfileName(), pdfIccStream); if (log.isInfoEnabled()) { - log.info("Adding PDFICCStream " + colorExt.getIccProfileName() + log.info("Adding PDFICCStream " + colorExt.getIccProfileName() + " for " + colorExt.getIccProfileSrc()); } } } - + /** * Create a PDF color from a java.awt.Color object. - * + * * Different Color objects are handled differently. Cases recognized are. - * + * * 1. CMYK color * 2. ColorExt color * 3. 'Normal' java.awt.Color (RGB case assumed) @@ -120,12 +120,12 @@ public class PDFColor extends PDFPathPaint { ColorExt ce = null; if (col instanceof ColorExt) { ce = (ColorExt)col; - cs = ce.getOrigColorSpace(); + cs = ce.getOrigColorSpace(); } if (cs != null && cs instanceof CMYKColorSpace) { // CMYK case this.colorSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_CMYK); - float[] cmyk = (ce == null + float[] cmyk = (ce == null ? col.getColorComponents(null) : ce.getOriginalColorComponents()); this.cyan = cmyk[0]; @@ -151,7 +151,7 @@ public class PDFColor extends PDFPathPaint { this.blue = comps[2]; } } - + /** * Create a PDF color with int values ranging from 0 to 255 * @@ -239,11 +239,11 @@ public class PDFColor extends PDFPathPaint { return (this.blue); } - /** + /** * Get the red integer component. - * - * @return the red integer value - */ + * + * @return the red integer value + */ public int red255() { return (int)(this.red * 255d); } @@ -251,7 +251,7 @@ public class PDFColor extends PDFPathPaint { /** * Get the green integer component. * - * @return the green integer value + * @return the green integer value */ public int green255() { return (int)(this.green * 255d); @@ -260,7 +260,7 @@ public class PDFColor extends PDFPathPaint { /** * Get the blue integer component. * - * @return the blue integer value + * @return the blue integer value */ public int blue255() { return (int)(this.blue * 255d); @@ -269,7 +269,7 @@ public class PDFColor extends PDFPathPaint { /** * Get the cyan component. * - * @return the cyan double value + * @return the cyan double value */ public double cyan() { return (this.cyan); @@ -278,7 +278,7 @@ public class PDFColor extends PDFPathPaint { /** * Get the magenta component. * - * @return the magenta double value + * @return the magenta double value */ public double magenta() { return (this.magenta); @@ -287,7 +287,7 @@ public class PDFColor extends PDFPathPaint { /** * Get the yellow component. * - * @return the yellow double value + * @return the yellow double value */ public double yellow() { return (this.yellow); @@ -296,7 +296,7 @@ public class PDFColor extends PDFPathPaint { /** * Get the black component. * - * @return the black double value + * @return the black double value */ public double black() { return (this.black); @@ -553,7 +553,7 @@ public class PDFColor extends PDFPathPaint { } PDFColor color = (PDFColor)obj; - if (color.red == this.red + if (color.red == this.red && color.green == this.green && color.blue == this.blue) { return true; diff --git a/src/java/org/apache/fop/pdf/PDFColorSpace.java b/src/java/org/apache/fop/pdf/PDFColorSpace.java index 4b67a8422..1d3dd8634 100644 --- a/src/java/org/apache/fop/pdf/PDFColorSpace.java +++ b/src/java/org/apache/fop/pdf/PDFColorSpace.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,14 +16,14 @@ */ /* $Id$ */ - + package org.apache.fop.pdf; /** * PDF Color space. */ public interface PDFColorSpace { - + /** * Get the number of color components for this colorspace * @return the number of components @@ -32,18 +32,18 @@ public interface PDFColorSpace { /** @return the name of the color space */ String getName(); - + /** - * @return true if the color space is a device-dependent color space (like DeviceRGB, + * @return true if the color space is a device-dependent color space (like DeviceRGB, * DeviceCMYK and DeviceGray) */ boolean isDeviceColorSpace(); - + /** @return true if the color space is an RGB color space */ boolean isRGBColorSpace(); /** @return true if the color space is an CMYK color space */ boolean isCMYKColorSpace(); /** @return true if the color space is an Gray color space */ boolean isGrayColorSpace(); - + } diff --git a/src/java/org/apache/fop/pdf/PDFConformanceException.java b/src/java/org/apache/fop/pdf/PDFConformanceException.java index 119f1f02d..083c11f21 100644 --- a/src/java/org/apache/fop/pdf/PDFConformanceException.java +++ b/src/java/org/apache/fop/pdf/PDFConformanceException.java @@ -33,7 +33,7 @@ public class PDFConformanceException extends RuntimeException { public PDFConformanceException() { super(); } - + /** * Constructs an PDFConformanceException with the specified detail * message. A detail message is a String that describes this particular @@ -43,5 +43,5 @@ public class PDFConformanceException extends RuntimeException { public PDFConformanceException(String message) { super(message); } - + } diff --git a/src/java/org/apache/fop/pdf/PDFDestination.java b/src/java/org/apache/fop/pdf/PDFDestination.java index eaf38449d..ced3ac497 100644 --- a/src/java/org/apache/fop/pdf/PDFDestination.java +++ b/src/java/org/apache/fop/pdf/PDFDestination.java @@ -55,15 +55,15 @@ public class PDFDestination extends PDFObject { protected int output(OutputStream stream) throws IOException { CountingOutputStream cout = new CountingOutputStream(stream); Writer writer = PDFDocument.getWriterFor(cout); - + formatObject(getIDRef(), cout, writer); writer.write(' '); formatObject(goToReference, cout, writer); - + writer.flush(); return cout.getCount(); } - + /** * Sets the GoToReference in the associated DestinationData object. * @@ -120,7 +120,7 @@ public class PDFDestination extends PDFObject { if (dest.getIDRef().equals(this.getIDRef())) { return true; } - + return false; } diff --git a/src/java/org/apache/fop/pdf/PDFDeviceColorSpace.java b/src/java/org/apache/fop/pdf/PDFDeviceColorSpace.java index 269b9f7b0..6ccfd39f5 100644 --- a/src/java/org/apache/fop/pdf/PDFDeviceColorSpace.java +++ b/src/java/org/apache/fop/pdf/PDFDeviceColorSpace.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,14 +16,14 @@ */ /* $Id$ */ - + package org.apache.fop.pdf; /** * Represents a device-specific color space. Used for mapping DeviceRGB, DeviceCMYK and DeviceGray. */ public class PDFDeviceColorSpace implements PDFColorSpace { - + private int numComponents; /** @@ -136,5 +136,5 @@ public class PDFDeviceColorSpace implements PDFColorSpace { public boolean isGrayColorSpace() { return getColorSpace() == DEVICE_GRAY; } - + } diff --git a/src/java/org/apache/fop/pdf/PDFDictionary.java b/src/java/org/apache/fop/pdf/PDFDictionary.java index 34fe4c389..3258423f4 100644 --- a/src/java/org/apache/fop/pdf/PDFDictionary.java +++ b/src/java/org/apache/fop/pdf/PDFDictionary.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.pdf; import java.io.IOException; @@ -32,7 +32,7 @@ import org.apache.commons.io.output.CountingOutputStream; * Class representing a PDF dictionary object */ public class PDFDictionary extends PDFObject { - + /** * the entry map */ @@ -43,7 +43,7 @@ public class PDFDictionary extends PDFObject { * "entries", always make sure you adjust this list accordingly. */ protected List order = new java.util.ArrayList(); - + /** * Create a new dictionary object. */ @@ -76,7 +76,7 @@ public class PDFDictionary extends PDFObject { } this.entries.put(name, value); } - + /** * Puts a new name/value pair. * @param name the name @@ -88,7 +88,7 @@ public class PDFDictionary extends PDFObject { } this.entries.put(name, new Integer(value)); } - + /** * Returns the value given a name. * @param name the name of the value @@ -97,7 +97,7 @@ public class PDFDictionary extends PDFObject { public Object get(String name) { return this.entries.get(name); } - + /** {@inheritDoc} */ protected int output(OutputStream stream) throws IOException { CountingOutputStream cout = new CountingOutputStream(stream); @@ -105,17 +105,17 @@ public class PDFDictionary extends PDFObject { if (hasObjectNumber()) { writer.write(getObjectID()); } - + writeDictionary(cout, writer); if (hasObjectNumber()) { writer.write("\nendobj\n"); } - + writer.flush(); return cout.getCount(); } - + /** * Writes the contents of the dictionary to a StringBuffer. * @param out the OutputStream (for binary content) diff --git a/src/java/org/apache/fop/pdf/PDFDocument.java b/src/java/org/apache/fop/pdf/PDFDocument.java index 020a594b4..16ec81049 100644 --- a/src/java/org/apache/fop/pdf/PDFDocument.java +++ b/src/java/org/apache/fop/pdf/PDFDocument.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,13 +65,13 @@ import org.apache.commons.logging.LogFactory; public class PDFDocument { private static final Integer LOCATION_PLACEHOLDER = new Integer(0); - + /** Integer constant to represent PDF 1.3 */ public static final int PDF_VERSION_1_3 = 3; /** Integer constant to represent PDF 1.4 */ public static final int PDF_VERSION_1_4 = 4; - + /** * the encoding to use when converting strings to PDF commandos. */ @@ -109,12 +109,12 @@ public class PDFDocument { /** Indicates what PDF version is active */ protected int pdfVersion = PDF_VERSION_1_4; - + /** * Indicates which PDF profiles are active (PDF/A, PDF/X etc.) */ protected PDFProfile pdfProfile = new PDFProfile(this); - + /** * the /Root object */ @@ -268,7 +268,7 @@ public class PDFDocument { public int getPDFVersion() { return this.pdfVersion; } - + /** @return the String representing the active PDF version */ public String getPDFVersionString() { switch (getPDFVersion()) { @@ -285,7 +285,7 @@ public class PDFDocument { public PDFProfile getProfile() { return this.pdfProfile; } - + /** * Returns the factory for PDF objects. * @return PDFFactory the factory @@ -332,7 +332,7 @@ public class PDFDocument { throw new Error("JVM doesn't support " + ENCODING + " encoding!"); } } - + /** * set the producer of the document * @@ -344,7 +344,7 @@ public class PDFDocument { /** * Set the creation date of the document. - * + * * @param date Date to be stored as creation date in the PDF. */ public void setCreationDate(Date date) { @@ -775,7 +775,7 @@ public class PDFDocument { } this.destinations.add(destination); } - + /** * Gets the list of named destinations. * @@ -849,7 +849,7 @@ public class PDFDocument { PDFStream cont, PDFReference formres, String key) { - + // check if already created PDFFormXObject xObject = (PDFFormXObject)xObjectsMap.get(key); if (xObject != null) { @@ -858,7 +858,7 @@ public class PDFDocument { } return xObject; } - + xObject = new PDFFormXObject( ++this.xObjectCount, cont, @@ -954,7 +954,7 @@ public class PDFDocument { this.position = 0; getProfile().verifyPDFVersion(); - + byte[] pdf = encode("%PDF-" + getPDFVersionString() + "\n"); stream.write(pdf); this.position += pdf.length; @@ -991,7 +991,7 @@ public class PDFDocument { } } } - + /** * write the trailer * diff --git a/src/java/org/apache/fop/pdf/PDFEncoding.java b/src/java/org/apache/fop/pdf/PDFEncoding.java index 6dc448b40..bf2799c70 100644 --- a/src/java/org/apache/fop/pdf/PDFEncoding.java +++ b/src/java/org/apache/fop/pdf/PDFEncoding.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.pdf; // Java @@ -48,7 +48,7 @@ public class PDFEncoding extends PDFDictionary { /** the set of predefined encodings that can be assumed present in a PDF viewer */ private static final Set PREDEFINED_ENCODINGS; - + static { Set encodings = new java.util.HashSet(); encodings.add(STANDARD_ENCODING); @@ -81,7 +81,7 @@ public class PDFEncoding extends PDFDictionary { public static boolean isPredefinedEncoding(String name) { return PREDEFINED_ENCODINGS.contains(name); } - + /** * Creates and returns a new DifferencesBuilder instance for constructing the Differences * array. @@ -98,15 +98,15 @@ public class PDFEncoding extends PDFDictionary { public void setDifferences(PDFArray differences) { put("Differences", differences); } - + /** * Builder class for constructing the Differences array. */ public class DifferencesBuilder { - + private PDFArray differences = new PDFArray(); private int currentCode = -1; - + /** * Start a new difference. * @param code the starting code index inside the encoding @@ -117,7 +117,7 @@ public class PDFEncoding extends PDFDictionary { this.differences.add(new Integer(code)); return this; } - + /** * Adds a character name to the current difference. * @param name the character name @@ -130,7 +130,7 @@ public class PDFEncoding extends PDFDictionary { this.differences.add(new PDFName(name)); return this; } - + /** * Indicates whether any differences have been recorded. * @return true if there are differences. @@ -138,7 +138,7 @@ public class PDFEncoding extends PDFDictionary { public boolean hasDifferences() { return (this.differences.length() > 0); } - + /** * Creates and returns the PDFArray representing the Differences entry. * @return the Differences entry @@ -147,7 +147,7 @@ public class PDFEncoding extends PDFDictionary { return this.differences; } } - + /* * example (p. 214) * 25 0 obj diff --git a/src/java/org/apache/fop/pdf/PDFEncryption.java b/src/java/org/apache/fop/pdf/PDFEncryption.java index 5063ffa44..5852df157 100644 --- a/src/java/org/apache/fop/pdf/PDFEncryption.java +++ b/src/java/org/apache/fop/pdf/PDFEncryption.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.pdf; /** @@ -39,9 +39,9 @@ public interface PDFEncryption { /** * Adds a PDFFilter to the PDFStream object * @param stream the stream to add an encryption filter to - */ + */ void applyFilter(AbstractPDFStream stream); - + /** * Encrypt an array of bytes using a reference PDFObject for calculating * the encryption key. @@ -50,7 +50,7 @@ public interface PDFEncryption { * @return byte[] the encrypted data */ byte[] encrypt(byte[] data, PDFObject refObj); - + /** * Returns the trailer entry for encryption. * @return the trailer entry diff --git a/src/java/org/apache/fop/pdf/PDFEncryptionJCE.java b/src/java/org/apache/fop/pdf/PDFEncryptionJCE.java index 5da37076c..43a323335 100644 --- a/src/java/org/apache/fop/pdf/PDFEncryptionJCE.java +++ b/src/java/org/apache/fop/pdf/PDFEncryptionJCE.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.pdf; // Java @@ -40,18 +40,18 @@ import javax.crypto.spec.SecretKeySpec; * */ public class PDFEncryptionJCE extends PDFObject implements PDFEncryption { - + private class EncryptionFilter extends PDFFilter { private PDFEncryptionJCE encryption; private int number; private int generation; - /** + /** * The constructor for the internal PDFEncryptionJCE filter * @param encryption The encryption object to use * @param number The number of the object to be encrypted * @param generation The generation of the object to be encrypted - */ + */ public EncryptionFilter(PDFEncryptionJCE encryption, int number, int generation) { super(); @@ -62,7 +62,7 @@ public class PDFEncryptionJCE extends PDFObject implements PDFEncryption { + number + " and generation " + generation); } - /** + /** * Return a PDF string representation of the filter. In this * case no filter name is passed. * @return The filter name, blank in this case @@ -71,7 +71,7 @@ public class PDFEncryptionJCE extends PDFObject implements PDFEncryption { return ""; } - /** + /** * Return a parameter dictionary for this filter, or null * @return The parameter dictionary. In this case, null. */ @@ -79,7 +79,7 @@ public class PDFEncryptionJCE extends PDFObject implements PDFEncryption { return null; } - /** + /** * Encode the given data with the filter * @param data The data to be encrypted * @return The encrypted data @@ -87,43 +87,43 @@ public class PDFEncryptionJCE extends PDFObject implements PDFEncryption { public byte[] encode(byte[] data) { return encryption.encryptData(data, number, generation); } - + /** - * {@inheritDoc} + * {@inheritDoc} */ - public void encode(InputStream in, OutputStream out, int length) + public void encode(InputStream in, OutputStream out, int length) throws IOException { byte[] buffer = new byte[length]; in.read(buffer); buffer = encode(buffer); out.write(buffer); } - + /** * {@inheritDoc} */ public OutputStream applyFilter(OutputStream out) throws IOException { - return new CipherOutputStream(out, + return new CipherOutputStream(out, encryption.initCipher(number, generation)); } } - private static final char [] PAD + private static final char [] PAD = {0x28, 0xBF, 0x4E, 0x5E, 0x4E, 0x75, 0x8A, 0x41, - 0x64, 0x00, 0x4E, 0x56, 0xFF, 0xFA, 0x01, 0x08, - 0x2E, 0x2E, 0x00, 0xB6, 0xD0, 0x68, 0x3E, 0x80, + 0x64, 0x00, 0x4E, 0x56, 0xFF, 0xFA, 0x01, 0x08, + 0x2E, 0x2E, 0x00, 0xB6, 0xD0, 0x68, 0x3E, 0x80, 0x2F, 0x0C, 0xA9, 0xFE, 0x64, 0x53, 0x69, 0x7A}; - - /** Value of PRINT permission */ + + /** Value of PRINT permission */ public static final int PERMISSION_PRINT = 4; - /** Value of content editting permission */ + /** Value of content editting permission */ public static final int PERMISSION_EDIT_CONTENT = 8; - /** Value of content extraction permission */ + /** Value of content extraction permission */ public static final int PERMISSION_COPY_CONTENT = 16; - /** Value of annotation editting permission */ + /** Value of annotation editting permission */ public static final int PERMISSION_EDIT_ANNOTATIONS = 32; - + // Encryption tools private MessageDigest digest = null; //private Cipher cipher = null; @@ -185,14 +185,14 @@ public class PDFEncryptionJCE extends PDFObject implements PDFEncryption { } // Internal procedures - + private byte[] prepPassword(String password) { byte[] obuffer = new byte[32]; byte[] pbuffer = password.getBytes(); int i = 0; int j = 0; - + while (i < obuffer.length && i < pbuffer.length) { obuffer[i] = pbuffer[i]; i++; @@ -204,34 +204,34 @@ public class PDFEncryptionJCE extends PDFObject implements PDFEncryption { return obuffer; } - /** + /** * Returns the document file ID * @return The file ID - */ + */ public byte[] getFileID() { if (fileID == null) { fileID = new byte[16]; random.nextBytes(fileID); } - + return fileID; } - - /** + + /** * This method returns the indexed file ID * @param index The index to access the file ID * @return The file ID - */ + */ public String getFileID(int index) { if (index == 1) { return PDFText.toHex(getFileID()); } - + byte[] id = new byte[16]; random.nextBytes(id); return PDFText.toHex(id); } - + private byte[] encryptWithKey(byte[] data, byte[] key) { try { final Cipher c = initCipher(key); @@ -242,7 +242,7 @@ public class PDFEncryptionJCE extends PDFObject implements PDFEncryption { throw new IllegalStateException(e.getMessage()); } } - + private Cipher initCipher(byte[] key) { try { Cipher c = Cipher.getInstance("RC4"); @@ -257,7 +257,7 @@ public class PDFEncryptionJCE extends PDFObject implements PDFEncryption { throw new UnsupportedOperationException(e.getMessage()); } } - + private Cipher initCipher(int number, int generation) { byte[] hash = calcHash(number, generation); int size = hash.length; @@ -265,12 +265,12 @@ public class PDFEncryptionJCE extends PDFObject implements PDFEncryption { byte[] key = calcKey(hash, size); return initCipher(key); } - + private byte[] encryptWithHash(byte[] data, byte[] hash, int size) { hash = digest.digest(hash); - byte[] key = calcKey(hash, size); - + byte[] key = calcKey(hash, size); + return encryptWithKey(data, key); } @@ -283,19 +283,19 @@ public class PDFEncryptionJCE extends PDFObject implements PDFEncryption { return key; } - /** + /** * This method initializes the encryption algorithms and values - */ + */ public void init() { // Generate the owner value byte[] oValue; if (params.getOwnerPassword().length() > 0) { oValue = encryptWithHash( - prepPassword(params.getUserPassword()), + prepPassword(params.getUserPassword()), prepPassword(params.getOwnerPassword()), 5); } else { oValue = encryptWithHash( - prepPassword(params.getUserPassword()), + prepPassword(params.getUserPassword()), prepPassword(params.getUserPassword()), 5); } @@ -330,12 +330,12 @@ public class PDFEncryptionJCE extends PDFObject implements PDFEncryption { for (int i = 0; i < 5; i++) { this.encryptionKey[i] = hash[i]; } - + // Create the user value byte[] uValue = encryptWithKey(prepPassword(""), this.encryptionKey); - + // Create the dictionary - this.dictionary = getObjectID() + this.dictionary = getObjectID() + "<< /Filter /Standard\n" + "/V 1\n" + "/R 2\n" @@ -347,18 +347,18 @@ public class PDFEncryptionJCE extends PDFObject implements PDFEncryption { + "endobj\n"; } - /** + /** * This method encrypts the passed data using the generated keys. * @param data The data to be encrypted * @param number The block number * @param generation The block generation * @return The encrypted data - */ + */ public byte[] encryptData(byte[] data, int number, int generation) { if (this.encryptionKey == null) { throw new IllegalStateException("PDF Encryption has not been initialized"); } - byte[] hash = calcHash(number, generation); + byte[] hash = calcHash(number, generation); return encryptWithHash(data, hash, hash.length); } @@ -376,26 +376,26 @@ public class PDFEncryptionJCE extends PDFObject implements PDFEncryption { private byte[] calcHash(int number, int generation) { byte[] hash = new byte[this.encryptionKey.length + 5]; - + int i = 0; while (i < this.encryptionKey.length) { hash[i] = this.encryptionKey[i]; i++; } - + hash[i++] = (byte) (number >>> 0); hash[i++] = (byte) (number >>> 8); hash[i++] = (byte) (number >>> 16); hash[i++] = (byte) (generation >>> 0); hash[i++] = (byte) (generation >>> 8); - return hash; + return hash; } - /** + /** * Creates PDFFilter for the encryption object * @param number The object number * @param generation The objects generation * @return The resulting filter - */ + */ public PDFFilter makeFilter(int number, int generation) { return new EncryptionFilter(this, number, generation); } @@ -403,12 +403,12 @@ public class PDFEncryptionJCE extends PDFObject implements PDFEncryption { /** * Adds a PDFFilter to the PDFStream object * @param stream the stream to add an encryption filter to - */ + */ public void applyFilter(AbstractPDFStream stream) { stream.getFilterList().addFilter( this.makeFilter(stream.getObjectNumber(), stream.getGeneration())); } - + /** * Represent the object in PDF * @@ -418,7 +418,7 @@ public class PDFEncryptionJCE extends PDFObject implements PDFEncryption { if (this.dictionary == null) { throw new IllegalStateException("PDF Encryption has not been initialized"); } - + return encode(this.dictionary); } @@ -426,7 +426,7 @@ public class PDFEncryptionJCE extends PDFObject implements PDFEncryption { * {@inheritDoc} */ public String getTrailerEntry() { - return "/Encrypt " + getObjectNumber() + " " + return "/Encrypt " + getObjectNumber() + " " + getGeneration() + " R\n" + "/ID[" + getFileID(1) + getFileID(2) + "]\n"; } diff --git a/src/java/org/apache/fop/pdf/PDFEncryptionManager.java b/src/java/org/apache/fop/pdf/PDFEncryptionManager.java index 6856cc37c..5d5ea8586 100644 --- a/src/java/org/apache/fop/pdf/PDFEncryptionManager.java +++ b/src/java/org/apache/fop/pdf/PDFEncryptionManager.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.pdf; import java.lang.reflect.InvocationTargetException; @@ -48,7 +48,7 @@ public class PDFEncryptionManager { return false; } } - + /** * Checks whether the necessary algorithms are available. * @return boolean True if all necessary algorithms are present @@ -71,7 +71,7 @@ public class PDFEncryptionManager { return true; } } - + /** * Sets up PDF encryption if PDF encryption is requested by registering @@ -80,7 +80,7 @@ public class PDFEncryptionManager { * @param params the PDF encryption params or null to disable encryption * @param pdf the PDF document to setup encryption for */ - public static void setupPDFEncryption(PDFEncryptionParams params, + public static void setupPDFEncryption(PDFEncryptionParams params, PDFDocument pdf) { if (pdf == null) { throw new NullPointerException("PDF document must not be null"); @@ -101,7 +101,7 @@ public class PDFEncryptionManager { pdf.setEncryption(params); } } - + /** * Creates a new PDFEncryption instance if PDF encryption is available. * @param objnum PDF object number @@ -112,9 +112,9 @@ public class PDFEncryptionManager { public static PDFEncryption newInstance(int objnum, PDFEncryptionParams params) { try { Class clazz = Class.forName("org.apache.fop.pdf.PDFEncryptionJCE"); - Method makeMethod = clazz.getMethod("make", + Method makeMethod = clazz.getMethod("make", new Class[] {int.class, PDFEncryptionParams.class}); - Object obj = makeMethod.invoke(null, + Object obj = makeMethod.invoke(null, new Object[] {new Integer(objnum), params}); return (PDFEncryption)obj; } catch (ClassNotFoundException e) { @@ -135,5 +135,5 @@ public class PDFEncryptionManager { return null; } } - + } diff --git a/src/java/org/apache/fop/pdf/PDFEncryptionParams.java b/src/java/org/apache/fop/pdf/PDFEncryptionParams.java index d3287849d..9cc502c42 100644 --- a/src/java/org/apache/fop/pdf/PDFEncryptionParams.java +++ b/src/java/org/apache/fop/pdf/PDFEncryptionParams.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.pdf; /** @@ -30,7 +30,7 @@ public class PDFEncryptionParams { private boolean allowCopyContent = true; private boolean allowEditContent = true; private boolean allowEditAnnotations = true; - + /** * Creates a new instance. * @param userPassword the user password @@ -52,14 +52,14 @@ public class PDFEncryptionParams { setAllowEditContent(allowEditContent); setAllowEditAnnotations(allowEditAnnotations); } - + /** * Default constructor initializing to default values. */ public PDFEncryptionParams() { //nop } - + /** * Indicates whether copying content is allowed. * @return true if copying is allowed diff --git a/src/java/org/apache/fop/pdf/PDFFactory.java b/src/java/org/apache/fop/pdf/PDFFactory.java index 6211b5da7..fc6e6b9fa 100644 --- a/src/java/org/apache/fop/pdf/PDFFactory.java +++ b/src/java/org/apache/fop/pdf/PDFFactory.java @@ -913,8 +913,8 @@ public class PDFFactory { PDFNameTreeNode node = new PDFNameTreeNode(); getDocument().registerObject(node); return node; - } - + } + /* ========================= links ===================================== */ // Some of the "yoffset-only" functions in this part are obsolete and can // possibly be removed or deprecated. Some are still called by PDFGraphics2D @@ -1250,7 +1250,7 @@ public class PDFFactory { nonBase14.setWidthMetrics(firstChar, lastChar, new PDFArray(null, metrics.getWidths())); - + //Handle encoding SingleByteEncoding mapping = singleByteFont.getEncoding(); if (singleByteFont.isSymbolicFont()) { @@ -1265,10 +1265,10 @@ public class PDFFactory { } else { font.setEncoding((String)pdfEncoding); } - + /* JM: What I thought would be a necessity with custom encodings turned out to * be a bug in Adobe Acrobat 8. The following section just demonstrates how - * to generate a ToUnicode CMap for a Type 1 font. + * to generate a ToUnicode CMap for a Type 1 font. PDFCMap cmap = new PDFToUnicodeCMap(mapping.getUnicodeCharMap(), "fop-ucs-H", new PDFCIDSystemInfo("Adobe", "Identity", 0)); @@ -1276,7 +1276,7 @@ public class PDFFactory { nonBase14.setToUnicode(cmap); */ } - + //Handle additional encodings (characters outside the primary encoding) if (singleByteFont.hasAdditionalEncodings()) { for (int i = 0, c = singleByteFont.getAdditionalEncodingCount(); i < c; i++) { @@ -1573,7 +1573,7 @@ public class PDFFactory { /** * Create a PDFICCStream * @see PDFImageXObject - * @see org.apache.fop.pdf.PDFDeviceColorSpace + * @see org.apache.fop.pdf.PDFDeviceColorSpace * @return the new PDF ICC stream object */ public PDFICCStream makePDFICCStream() { diff --git a/src/java/org/apache/fop/pdf/PDFFileSpec.java b/src/java/org/apache/fop/pdf/PDFFileSpec.java index 2c91dac5c..a2bc6aefe 100644 --- a/src/java/org/apache/fop/pdf/PDFFileSpec.java +++ b/src/java/org/apache/fop/pdf/PDFFileSpec.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.pdf; /** @@ -47,9 +47,9 @@ public class PDFFileSpec extends PDFObject { * {@inheritDoc} */ public String toPDFString() { - return getObjectID() - + "<<\n/Type /FileSpec\n" - + "/F (" + this.filename + ")\n" + return getObjectID() + + "<<\n/Type /FileSpec\n" + + "/F (" + this.filename + ")\n" + ">>\nendobj\n"; } diff --git a/src/java/org/apache/fop/pdf/PDFFilter.java b/src/java/org/apache/fop/pdf/PDFFilter.java index ae99ed31c..c257f0da0 100644 --- a/src/java/org/apache/fop/pdf/PDFFilter.java +++ b/src/java/org/apache/fop/pdf/PDFFilter.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,10 +16,10 @@ */ /* $Id$ */ - + package org.apache.fop.pdf; -import java.io.OutputStream; +import java.io.OutputStream; import java.io.IOException; /** diff --git a/src/java/org/apache/fop/pdf/PDFFilterException.java b/src/java/org/apache/fop/pdf/PDFFilterException.java index 83fbf7c4d..4d98584cd 100644 --- a/src/java/org/apache/fop/pdf/PDFFilterException.java +++ b/src/java/org/apache/fop/pdf/PDFFilterException.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.pdf; /** diff --git a/src/java/org/apache/fop/pdf/PDFFilterList.java b/src/java/org/apache/fop/pdf/PDFFilterList.java index 84131707b..5eab5c81a 100644 --- a/src/java/org/apache/fop/pdf/PDFFilterList.java +++ b/src/java/org/apache/fop/pdf/PDFFilterList.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.pdf; import java.io.IOException; @@ -25,7 +25,7 @@ import java.util.List; import java.util.Map; /** - * This class represents a list of PDF filters to be applied when serializing + * This class represents a list of PDF filters to be applied when serializing * the output of a PDF object. */ public class PDFFilterList { @@ -50,9 +50,9 @@ public class PDFFilterList { private List filters = new java.util.ArrayList(); private boolean ignoreASCIIFilters = false; - + private boolean disableAllFilters = false; - + /** * Default constructor. *

      @@ -61,7 +61,7 @@ public class PDFFilterList { public PDFFilterList() { //nop } - + /** * Use this descriptor if you want to have ASCII filters (such as ASCIIHex * and ASCII85) ignored, for example, when encryption is active. @@ -78,7 +78,7 @@ public class PDFFilterList { public void setDisableAllFilters(boolean value) { this.disableAllFilters = value; } - + /** * Returns true if all filters are disabled. * @return true if all filters are disabled @@ -86,7 +86,7 @@ public class PDFFilterList { public boolean isDisableAllFilters() { return this.disableAllFilters; } - + /** * Indicates whether the filter list is already initialized. * @return true if more there are filters present @@ -111,7 +111,7 @@ public class PDFFilterList { filters.add(filter); } } - + /** * Add a filter for compression of the stream by name. * @param filterType name of the filter to add @@ -211,7 +211,7 @@ public class PDFFilterList { int nonNullParams = populateNamesAndParms(names, parms); // now build up the filter entries for the dictionary - return buildFilterEntries(names) + return buildFilterEntries(names) + (nonNullParams > 0 ? buildDecodeParms(parms) : ""); } return ""; @@ -238,7 +238,7 @@ public class PDFFilterList { putDecodeParams(dict, parms); } } - + private int populateNamesAndParms(List names, List parms) { // run the filters int nonNullParams = 0; @@ -247,7 +247,7 @@ public class PDFFilterList { // place the names in our local vector in reverse order if (filter.getName().length() > 0) { names.add(0, filter.getName()); - PDFObject param = filter.getDecodeParms(); + PDFObject param = filter.getDecodeParms(); if (param != null) { parms.add(0, param); nonNullParams++; @@ -297,7 +297,7 @@ public class PDFFilterList { } } } - + private String buildDecodeParms(List parms) { StringBuffer sb = new StringBuffer(); boolean needParmsEntry = false; @@ -346,9 +346,9 @@ public class PDFFilterList { } } } - + /** - * Applies all registered filters as necessary. The method returns an + * Applies all registered filters as necessary. The method returns an * OutputStream which will receive the filtered contents. * @param stream raw data output stream * @return OutputStream filtered output stream diff --git a/src/java/org/apache/fop/pdf/PDFFont.java b/src/java/org/apache/fop/pdf/PDFFont.java index 1f76f1e11..6ba6ab9a2 100644 --- a/src/java/org/apache/fop/pdf/PDFFont.java +++ b/src/java/org/apache/fop/pdf/PDFFont.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.pdf; import java.io.IOException; @@ -37,7 +37,7 @@ public class PDFFont extends PDFDictionary { /** Internal F-number for each font (it is not written to the font dict) */ private String fontname; - + /** * create the /Font object * @@ -74,7 +74,7 @@ public class PDFFont extends PDFDictionary { put("Encoding", new PDFName(encoding)); } } - + /** * Sets the Encoding value of the font. * @param encoding the encoding @@ -84,7 +84,7 @@ public class PDFFont extends PDFDictionary { put("Encoding", encoding); } } - + /** * factory method with the basic parameters * @@ -122,7 +122,7 @@ public class PDFFont extends PDFDictionary { public String getName() { return this.fontname; } - + /** * Returns the name of the BaseFont. * @return the BaseFont @@ -158,7 +158,7 @@ public class PDFFont extends PDFDictionary { protected void validate() { if (getDocumentSafely().getProfile().isFontEmbeddingRequired()) { if (this.getClass() == PDFFont.class) { - throw new PDFConformanceException("For " + getDocumentSafely().getProfile() + throw new PDFConformanceException("For " + getDocumentSafely().getProfile() + ", all fonts, even the base 14" + " fonts, have to be embedded! Offending font: " + getBaseFont()); } @@ -170,5 +170,5 @@ public class PDFFont extends PDFDictionary { validate(); return super.output(stream); } - + } diff --git a/src/java/org/apache/fop/pdf/PDFFontDescriptor.java b/src/java/org/apache/fop/pdf/PDFFontDescriptor.java index aa40bc35b..d4b412e4c 100644 --- a/src/java/org/apache/fop/pdf/PDFFontDescriptor.java +++ b/src/java/org/apache/fop/pdf/PDFFontDescriptor.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.pdf; import org.apache.fop.fonts.FontType; @@ -59,16 +59,16 @@ public class PDFFontDescriptor extends PDFDictionary { /** * Set the optional metrics. - * @param avgWidth The average width of characters in this font. + * @param avgWidth The average width of characters in this font. * The default value is 0. - * @param maxWidth The maximum width of characters in this font. + * @param maxWidth The maximum width of characters in this font. * The default value is 0. * @param missingWidth missing width - * @param leading the desired spacing between lines of text. + * @param leading the desired spacing between lines of text. * The default value is 0. - * @param stemH The vertical width of the dominant horizontal stems of + * @param stemH The vertical width of the dominant horizontal stems of * glyphs in the font. The default value is 0. - * @param xHeight The y-coordinate of the top of flat non-ascending + * @param xHeight The y-coordinate of the top of flat non-ascending * lowercase letters, measured from the baseline. The default value is 0. */ public void setMetrics(int avgWidth, int maxWidth, int missingWidth, @@ -119,7 +119,7 @@ public class PDFFontDescriptor extends PDFDictionary { } return stream; } - + /** * Sets the CIDSet stream for this font descriptor. (Optional) * @param cidSet the CIDSet stream @@ -127,19 +127,19 @@ public class PDFFontDescriptor extends PDFDictionary { public void setCIDSet(AbstractPDFStream cidSet) { put("CIDSet", cidSet); } - + /** @return the CIDSet stream or null if not applicable */ public AbstractPDFStream getCIDSet() { return (AbstractPDFStream)get("CIDSet"); } - + /** * {@inheritDoc} */ /* public String toPDFString() { StringBuffer p = new StringBuffer(128); - p.append(getObjectID() + p.append(getObjectID() + "<< /Type /FontDescriptor" + "\n/FontName /" + this.basefont); diff --git a/src/java/org/apache/fop/pdf/PDFFontNonBase14.java b/src/java/org/apache/fop/pdf/PDFFontNonBase14.java index b97d5deec..9b6cef618 100644 --- a/src/java/org/apache/fop/pdf/PDFFontNonBase14.java +++ b/src/java/org/apache/fop/pdf/PDFFontNonBase14.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.pdf; import org.apache.fop.fonts.FontType; @@ -70,7 +70,7 @@ public abstract class PDFFontNonBase14 extends PDFFont { public PDFFontDescriptor getDescriptor() { return (PDFFontDescriptor)get("FontDescriptor"); } - + /** * Sets a ToUnicode CMap. * @param cmap the ToUnicode character map @@ -78,15 +78,15 @@ public abstract class PDFFontNonBase14 extends PDFFont { public void setToUnicode(PDFCMap cmap) { put("ToUnicode", cmap); } - + /** {@inheritDoc} */ protected void validate() { if (getDocumentSafely().getProfile().isFontEmbeddingRequired()) { if (this.getDescriptor().getFontFile() == null) { - throw new PDFConformanceException("For " + getDocumentSafely().getProfile() + throw new PDFConformanceException("For " + getDocumentSafely().getProfile() + ", all fonts have to be embedded!"); } } } - + } diff --git a/src/java/org/apache/fop/pdf/PDFFontTrueType.java b/src/java/org/apache/fop/pdf/PDFFontTrueType.java index a5636f951..99c9f1c1f 100644 --- a/src/java/org/apache/fop/pdf/PDFFontTrueType.java +++ b/src/java/org/apache/fop/pdf/PDFFontTrueType.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.pdf; import org.apache.fop.fonts.FontType; @@ -36,7 +36,7 @@ public class PDFFontTrueType extends PDFFontNonBase14 { * @param basefont the base font name * @param encoding the character encoding schema used by the font */ - public PDFFontTrueType(String fontname, + public PDFFontTrueType(String fontname, String basefont, Object encoding) { super(fontname, FontType.TRUETYPE, basefont, encoding); diff --git a/src/java/org/apache/fop/pdf/PDFFontType0.java b/src/java/org/apache/fop/pdf/PDFFontType0.java index 29d6d1b4f..2f5e037f3 100644 --- a/src/java/org/apache/fop/pdf/PDFFontType0.java +++ b/src/java/org/apache/fop/pdf/PDFFontType0.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.pdf; import org.apache.fop.fonts.FontType; @@ -35,7 +35,7 @@ public class PDFFontType0 extends PDFFont { * @param basefont the base font name * @param encoding the character encoding schema used by the font */ - public PDFFontType0(String fontname, + public PDFFontType0(String fontname, String basefont, Object encoding) { super(fontname, FontType.TYPE0, basefont, encoding); @@ -49,9 +49,9 @@ public class PDFFontType0 extends PDFFont { * @param encoding the character encoding schema used by the font * @param descendantFonts the CIDFont upon which this font is based */ - public PDFFontType0(String fontname, + public PDFFontType0(String fontname, String basefont, - Object encoding, + Object encoding, PDFCIDFont descendantFonts) { super(fontname, FontType.TYPE0, basefont, encoding); diff --git a/src/java/org/apache/fop/pdf/PDFFontType1.java b/src/java/org/apache/fop/pdf/PDFFontType1.java index 8c9a7dc4d..884cb3e30 100644 --- a/src/java/org/apache/fop/pdf/PDFFontType1.java +++ b/src/java/org/apache/fop/pdf/PDFFontType1.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.pdf; import org.apache.fop.fonts.FontType; @@ -40,7 +40,7 @@ public class PDFFontType1 extends PDFFontNonBase14 { * @param basefont the base font name * @param encoding the character encoding schema used by the font */ - public PDFFontType1(String fontname, + public PDFFontType1(String fontname, String basefont, Object encoding) { diff --git a/src/java/org/apache/fop/pdf/PDFFontType3.java b/src/java/org/apache/fop/pdf/PDFFontType3.java index 96ecb6b5a..03d5469ea 100644 --- a/src/java/org/apache/fop/pdf/PDFFontType3.java +++ b/src/java/org/apache/fop/pdf/PDFFontType3.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.pdf; import org.apache.fop.fonts.FontType; @@ -38,7 +38,7 @@ public class PDFFontType3 extends PDFFontNonBase14 { * @param basefont the base font name * @param encoding the character encoding schema used by the font */ - public PDFFontType3(String fontname, + public PDFFontType3(String fontname, String basefont, Object encoding) { super(fontname, FontType.TYPE3, basefont, encoding); @@ -54,7 +54,7 @@ public class PDFFontType3 extends PDFFontNonBase14 { * @param fontMatrix the font's transformation matrix * @param charProcs the glyphs' definitions */ - public PDFFontType3(String fontname, + public PDFFontType3(String fontname, String basefont, Object encoding, PDFRectangle fontBBox, PDFArray fontMatrix, diff --git a/src/java/org/apache/fop/pdf/PDFFormXObject.java b/src/java/org/apache/fop/pdf/PDFFormXObject.java index 6ccf76c6c..5ede9b487 100644 --- a/src/java/org/apache/fop/pdf/PDFFormXObject.java +++ b/src/java/org/apache/fop/pdf/PDFFormXObject.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.pdf; // Java @@ -32,7 +32,7 @@ import java.io.OutputStream; * dictionary but a stream of image data. */ public class PDFFormXObject extends PDFXObject { - + private PDFStream contents; private PDFReference resRef; @@ -49,7 +49,7 @@ public class PDFFormXObject extends PDFXObject { put("Name", new PDFName("Form" + xnumber)); this.resRef = resources; this.contents = contents; - + put("Type", new PDFName("XObject")); put("Subtype", new PDFName("Form")); put("FormType", new Integer(1)); @@ -76,7 +76,7 @@ public class PDFFormXObject extends PDFXObject { array.set(3, bbox.getHeight()); } } - + /** * Returns the bounding box. * @return the BBox value @@ -95,7 +95,7 @@ public class PDFFormXObject extends PDFXObject { return null; } } - + /** * Sets the Matrix value * @param at the AffineTransform defining the transformation matrix @@ -122,7 +122,7 @@ public class PDFFormXObject extends PDFXObject { array.set(5, m[5]); } } - + /** * Returns the Matrix value. * @return the Matrix @@ -143,7 +143,7 @@ public class PDFFormXObject extends PDFXObject { return null; } } - + /** * Used to set the contents of the PDF stream. * @param data the contents as a byte array @@ -161,7 +161,7 @@ public class PDFFormXObject extends PDFXObject { /** {@inheritDoc} */ protected int output(OutputStream stream) throws IOException { final int len = super.output(stream); - + //Now that the data has been written, it can be discarded. this.contents = null; return len; @@ -175,6 +175,6 @@ public class PDFFormXObject extends PDFXObject { put("Resources", resRef); super.populateStreamDict(lengthEntry); } - + } diff --git a/src/java/org/apache/fop/pdf/PDFFunction.java b/src/java/org/apache/fop/pdf/PDFFunction.java index fdf419a2b..14cc318ba 100644 --- a/src/java/org/apache/fop/pdf/PDFFunction.java +++ b/src/java/org/apache/fop/pdf/PDFFunction.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/pdf/PDFGState.java b/src/java/org/apache/fop/pdf/PDFGState.java index 03608994d..93151149b 100644 --- a/src/java/org/apache/fop/pdf/PDFGState.java +++ b/src/java/org/apache/fop/pdf/PDFGState.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.pdf; import java.util.Map; @@ -81,7 +81,7 @@ public class PDFGState extends PDFObject { public static final String GSTATE_ALPHA_SOURCE_FLAG = "AIS"; /** Text Knockout Flag (TK, PDF 1.4) */ public static final String GSTATE_TEXT_KNOCKOUT = "TK"; - + /** Default GState object */ public static final PDFGState DEFAULT; @@ -99,7 +99,7 @@ public class PDFGState extends PDFObject { vals.put(op, Boolean.FALSE); vals.put(OPM, new Integer(1)); vals.put(Font, "");*/ - + vals.put(GSTATE_ALPHA_STROKE, new Float(1.0)); vals.put(GSTATE_ALPHA_NONSTROKE, new Float(1.0)); } @@ -117,7 +117,7 @@ public class PDFGState extends PDFObject { /** * Sets the alpha value. * @param val alpha value (0.0 - 1.0) - * @param fill True if alpha should be set for non-stroking operations, + * @param fill True if alpha should be set for non-stroking operations, * False if for stroking operations */ public void setAlpha(float val, boolean fill) { diff --git a/src/java/org/apache/fop/pdf/PDFGoTo.java b/src/java/org/apache/fop/pdf/PDFGoTo.java index ae35928d2..b3ff6bcdc 100644 --- a/src/java/org/apache/fop/pdf/PDFGoTo.java +++ b/src/java/org/apache/fop/pdf/PDFGoTo.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.pdf; import java.awt.geom.Point2D; @@ -128,7 +128,7 @@ public class PDFGoTo extends PDFAction { } else { dest = "/D [" + this.pageReference + " " + destination + "]\n"; } - return getObjectID() + return getObjectID() + "<< /Type /Action\n/S /GoTo\n" + dest + ">>\nendobj\n"; } diff --git a/src/java/org/apache/fop/pdf/PDFGoToRemote.java b/src/java/org/apache/fop/pdf/PDFGoToRemote.java index 2cd937df3..e04a1668f 100644 --- a/src/java/org/apache/fop/pdf/PDFGoToRemote.java +++ b/src/java/org/apache/fop/pdf/PDFGoToRemote.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.pdf; /** diff --git a/src/java/org/apache/fop/pdf/PDFICCBasedColorSpace.java b/src/java/org/apache/fop/pdf/PDFICCBasedColorSpace.java index e0cac0746..66753f37f 100644 --- a/src/java/org/apache/fop/pdf/PDFICCBasedColorSpace.java +++ b/src/java/org/apache/fop/pdf/PDFICCBasedColorSpace.java @@ -33,7 +33,7 @@ public class PDFICCBasedColorSpace extends PDFObject implements PDFColorSpace { private PDFICCStream iccStream; private String explicitName; - + /** * Constructs a the ICCBased color space with an explicit name (ex. "DefaultRGB"). * @param explicitName an explicit name or null if a name should be generated @@ -43,7 +43,7 @@ public class PDFICCBasedColorSpace extends PDFObject implements PDFColorSpace { this.explicitName = explicitName; this.iccStream = iccStream; } - + /** * Constructs a the ICCBased color space. * @param iccStream the ICC stream to associate with this color space @@ -51,12 +51,12 @@ public class PDFICCBasedColorSpace extends PDFObject implements PDFColorSpace { public PDFICCBasedColorSpace(PDFICCStream iccStream) { this(null, iccStream); } - + /** @return the ICC stream associated with this color space */ public PDFICCStream getICCStream() { return this.iccStream; } - + /** {@inheritDoc} */ public int getNumComponents() { return iccStream.getICCProfile().getNumComponents(); @@ -151,5 +151,5 @@ public class PDFICCBasedColorSpace extends PDFObject implements PDFColorSpace { sRGBProfile.setColorSpace(profile, null); return sRGBProfile; } - + } diff --git a/src/java/org/apache/fop/pdf/PDFICCStream.java b/src/java/org/apache/fop/pdf/PDFICCStream.java index f242c0cae..b70ed017a 100644 --- a/src/java/org/apache/fop/pdf/PDFICCStream.java +++ b/src/java/org/apache/fop/pdf/PDFICCStream.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.pdf; import java.awt.color.ICC_Profile; @@ -27,7 +27,7 @@ import java.io.OutputStream; * Special PDFStream for ICC profiles (color profiles). */ public class PDFICCStream extends PDFStream { - + private ICC_Profile cp; private PDFDeviceColorSpace pdfColorSpace; @@ -53,7 +53,7 @@ public class PDFICCStream extends PDFStream { public ICC_Profile getICCProfile() { return this.cp; } - + /** * overload the base object method so we don't have to copy * byte arrays around so much @@ -65,12 +65,12 @@ public class PDFICCStream extends PDFStream { this.cp = null; //Free ICC stream when it's not used anymore return length; } - + /** {@inheritDoc} */ protected void outputRawStreamData(OutputStream out) throws IOException { cp.write(out); } - + /** {@inheritDoc} */ protected void populateStreamDict(Object lengthEntry) { put("N", cp.getNumComponents()); diff --git a/src/java/org/apache/fop/pdf/PDFImage.java b/src/java/org/apache/fop/pdf/PDFImage.java index e0aaa44fa..e2b9e521c 100644 --- a/src/java/org/apache/fop/pdf/PDFImage.java +++ b/src/java/org/apache/fop/pdf/PDFImage.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. @@ -111,14 +111,14 @@ public interface PDFImage { /** @return true for CMYK images generated by Adobe Photoshop */ boolean isInverted(); - + /** * Get the PDF Filter to be applied to the image. * * @return the PDF Filter or null */ PDFFilter getPDFFilter(); - + // get the image bytes, and bytes properties /** @@ -132,11 +132,11 @@ public interface PDFImage { /** * Populates the XObject's dictionary with additional values. The values are added to the * dictionary after all the values obtained from other methods from this interface have - * been put into the dictionary. That allows to override certain values. + * been put into the dictionary. That allows to override certain values. * @param dict the dictionary to fill */ void populateXObjectDictionary(PDFDictionary dict); - + /** * Get the ICC stream for this image. * diff --git a/src/java/org/apache/fop/pdf/PDFImageXObject.java b/src/java/org/apache/fop/pdf/PDFImageXObject.java index 14fbeed4d..7104422e7 100644 --- a/src/java/org/apache/fop/pdf/PDFImageXObject.java +++ b/src/java/org/apache/fop/pdf/PDFImageXObject.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.pdf; // Java @@ -37,7 +37,7 @@ import java.io.OutputStream; * document in another place. */ public class PDFImageXObject extends PDFXObject { - + private PDFImage pdfimage; /** @@ -63,7 +63,7 @@ public class PDFImageXObject extends PDFXObject { */ protected int output(OutputStream stream) throws IOException { int length = super.output(stream); - + // let it gc // this object is retained as a reference to inserting // the same image but the image data is no longer needed @@ -80,7 +80,7 @@ public class PDFImageXObject extends PDFXObject { populateDictionaryFromImage(); } } - + private void populateDictionaryFromPS() { getDocumentSafely().getProfile().verifyPSXObjectsAllowed(); put("Subtype", new PDFName("PS")); @@ -139,7 +139,7 @@ public class PDFImageXObject extends PDFXObject { //Important: do this at the end so previous values can be overwritten. pdfimage.populateXObjectDictionary(this); } - + /** {@inheritDoc} */ protected void outputRawStreamData(OutputStream out) throws IOException { pdfimage.outputContents(out); @@ -157,7 +157,7 @@ public class PDFImageXObject extends PDFXObject { getFilterList().ensureFilterInPlace(pdfFilter); } } - + /** * This sets up the default filters for XObjects. It uses the PDFImage * instance to determine what default filters to apply. @@ -166,11 +166,11 @@ public class PDFImageXObject extends PDFXObject { protected void setupFilterList() { if (!getFilterList().isInitialized()) { getFilterList().addDefaultFilters( - getDocumentSafely().getFilterMap(), + getDocumentSafely().getFilterMap(), pdfimage.getFilterHint()); } super.setupFilterList(); } - + } diff --git a/src/java/org/apache/fop/pdf/PDFInfo.java b/src/java/org/apache/fop/pdf/PDFInfo.java index 888fdb2c6..14937bfd7 100644 --- a/src/java/org/apache/fop/pdf/PDFInfo.java +++ b/src/java/org/apache/fop/pdf/PDFInfo.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.pdf; import java.util.Date; @@ -50,7 +50,7 @@ public class PDFInfo extends PDFObject { public String getProducer() { return this.producer; } - + /** * set the producer string * @@ -64,7 +64,7 @@ public class PDFInfo extends PDFObject { public String getCreator() { return this.creator; } - + /** * set the creator string * @@ -92,7 +92,7 @@ public class PDFInfo extends PDFObject { public String getAuthor() { return this.author; } - + /** * set the author string * @@ -106,7 +106,7 @@ public class PDFInfo extends PDFObject { public String getSubject() { return this.subject; } - + /** * set the subject string * @@ -120,7 +120,7 @@ public class PDFInfo extends PDFObject { public String getKeywords() { return this.keywords; } - + /** * set the keywords string * @@ -162,7 +162,7 @@ public class PDFInfo extends PDFObject { * {@inheritDoc} */ public byte[] toPDF() { - PDFProfile profile = getDocumentSafely().getProfile(); + PDFProfile profile = getDocumentSafely().getProfile(); ByteArrayOutputStream bout = new ByteArrayOutputStream(128); try { bout.write(encode(getObjectID())); @@ -189,17 +189,17 @@ public class PDFInfo extends PDFObject { bout.write(encodeText(this.keywords)); bout.write(encode("\n")); } - + if (creator != null) { bout.write(encode("/Creator ")); bout.write(encodeText(this.creator)); bout.write(encode("\n")); } - + bout.write(encode("/Producer ")); bout.write(encodeText(this.producer)); bout.write(encode("\n")); - + // creation date in form (D:YYYYMMDDHHmmSSOHH'mm') if (creationDate == null) { creationDate = new Date(); @@ -207,7 +207,7 @@ public class PDFInfo extends PDFObject { bout.write(encode("/CreationDate ")); bout.write(encodeString(formatDateTime(creationDate))); bout.write(encode("\n")); - + if (profile.isModDateRequired() && this.modDate == null) { this.modDate = this.creationDate; } @@ -224,7 +224,7 @@ public class PDFInfo extends PDFObject { if (profile.isTrappedEntryRequired()) { bout.write(encode("/Trapped /False\n")); } - + bout.write(encode(">>\nendobj\n")); } catch (IOException ioe) { log.error("Ignored I/O exception", ioe); diff --git a/src/java/org/apache/fop/pdf/PDFInternalLink.java b/src/java/org/apache/fop/pdf/PDFInternalLink.java index fcdc2e1bc..faa6070a1 100644 --- a/src/java/org/apache/fop/pdf/PDFInternalLink.java +++ b/src/java/org/apache/fop/pdf/PDFInternalLink.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.pdf; /** diff --git a/src/java/org/apache/fop/pdf/PDFLink.java b/src/java/org/apache/fop/pdf/PDFLink.java index fb8544f6b..a7c4c6548 100644 --- a/src/java/org/apache/fop/pdf/PDFLink.java +++ b/src/java/org/apache/fop/pdf/PDFLink.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.pdf; // Java diff --git a/src/java/org/apache/fop/pdf/PDFMetadata.java b/src/java/org/apache/fop/pdf/PDFMetadata.java index e0833a30f..6d15a67d4 100644 --- a/src/java/org/apache/fop/pdf/PDFMetadata.java +++ b/src/java/org/apache/fop/pdf/PDFMetadata.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.pdf; import java.io.IOException; @@ -43,7 +43,7 @@ import org.apache.xmlgraphics.xmp.schemas.pdf.PDFAXMPSchema; * @since PDF 1.4 */ public class PDFMetadata extends PDFStream { - + private Metadata xmpMetadata; private boolean readOnly = true; @@ -62,7 +62,7 @@ public class PDFMetadata extends PDFStream { protected void setupFilterList() { if (!getFilterList().isInitialized()) { getFilterList().addDefaultFilters( - getDocumentSafely().getFilterMap(), + getDocumentSafely().getFilterMap(), PDFFilterList.METADATA_FILTER); } super.setupFilterList(); @@ -74,7 +74,7 @@ public class PDFMetadata extends PDFStream { public Metadata getMetadata() { return this.xmpMetadata; } - + /** * overload the base object method so we don't have to copy * byte arrays around so much @@ -86,24 +86,24 @@ public class PDFMetadata extends PDFStream { this.xmpMetadata = null; //Release DOM when it's not used anymore return length; } - + /** {@inheritDoc} */ protected void outputRawStreamData(OutputStream out) throws IOException { try { XMPSerializer.writeXMPPacket(xmpMetadata, out, this.readOnly); } catch (TransformerConfigurationException tce) { - throw new IOException("Error setting up Transformer for XMP stream serialization: " + throw new IOException("Error setting up Transformer for XMP stream serialization: " + tce.getMessage()); } catch (SAXException saxe) { - throw new IOException("Error while serializing XMP stream: " + throw new IOException("Error while serializing XMP stream: " + saxe.getMessage()); } } - + /** {@inheritDoc} */ protected void populateStreamDict(Object lengthEntry) { final String filterEntry = getFilterList().buildFilterDictEntries(); - if (getDocumentSafely().getProfile().getPDFAMode().isPDFA1LevelB() + if (getDocumentSafely().getProfile().getPDFAMode().isPDFA1LevelB() && filterEntry != null && filterEntry.length() > 0) { throw new PDFConformanceException( "The Filter key is prohibited when PDF/A-1 is active"); @@ -112,7 +112,7 @@ public class PDFMetadata extends PDFStream { put("Subtype", new PDFName("XML")); super.populateStreamDict(lengthEntry); } - + /** * Creates an XMP document based on the settings on the PDF Document. * @param pdfDoc the PDF Document @@ -120,7 +120,7 @@ public class PDFMetadata extends PDFStream { */ public static Metadata createXMPFromPDFDocument(PDFDocument pdfDoc) { Metadata meta = new Metadata(); - + PDFInfo info = pdfDoc.getInfo(); PDFRoot root = pdfDoc.getRoot(); @@ -129,7 +129,7 @@ public class PDFMetadata extends PDFStream { Date d = new Date(); info.setCreationDate(d); } - + //Important: Acrobat 7's preflight check for PDF/A-1b wants the creation date in the Info //object and in the XMP metadata to have the same timezone or else it shows a validation //error even if the times are essentially equal. @@ -153,7 +153,7 @@ public class PDFMetadata extends PDFStream { dc.addDate(info.getCreationDate()); //PDF/A identification - PDFAMode pdfaMode = pdfDoc.getProfile().getPDFAMode(); + PDFAMode pdfaMode = pdfDoc.getProfile().getPDFAMode(); if (pdfaMode.isPDFA1LevelB()) { PDFAAdapter pdfa = PDFAXMPSchema.getAdapter(meta); pdfa.setPart(1); @@ -163,7 +163,7 @@ public class PDFMetadata extends PDFStream { pdfa.setConformance("B"); //PDF/A-1b } } - + //XMP Basic Schema XMPBasicAdapter xmpBasic = XMPBasicSchema.getAdapter(meta); xmpBasic.setCreateDate(info.getCreationDate()); @@ -186,8 +186,8 @@ public class PDFMetadata extends PDFStream { adobePDF.setProducer(info.getProducer()); } adobePDF.setPDFVersion(pdfDoc.getPDFVersionString()); - - + + return meta; } @@ -206,14 +206,14 @@ public class PDFMetadata extends PDFStream { } else { info.setAuthor(null); } - + //dc:description["x-default"] maps to Subject as per ISO-19005-1:2005/Cor.1:2007 info.setSubject(dc.getDescription()); - + AdobePDFAdapter pdf = AdobePDFSchema.getAdapter(meta); info.setKeywords(pdf.getKeywords()); info.setProducer(pdf.getProducer()); - + XMPBasicAdapter xmpBasic = XMPBasicSchema.getAdapter(meta); info.setCreator(xmpBasic.getCreatorTool()); Date d; diff --git a/src/java/org/apache/fop/pdf/PDFName.java b/src/java/org/apache/fop/pdf/PDFName.java index 26d449591..6dabc3ac4 100644 --- a/src/java/org/apache/fop/pdf/PDFName.java +++ b/src/java/org/apache/fop/pdf/PDFName.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.pdf; import java.io.IOException; @@ -29,9 +29,9 @@ import org.apache.commons.io.output.CountingOutputStream; * Class representing a PDF name object. */ public class PDFName extends PDFObject { - + private String name; - + /** * Creates a new PDF name object. * @param name the name value @@ -58,8 +58,8 @@ public class PDFName extends PDFObject { } return sb.toString(); } - - private static final char[] DIGITS + + private static final char[] DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; @@ -71,7 +71,7 @@ public class PDFName extends PDFObject { sb.append(DIGITS[ch >>> 4 & 0x0F]); sb.append(DIGITS[ch & 0x0F]); } - + /** {@inheritDoc} */ public String toString() { return this.name; @@ -86,15 +86,15 @@ public class PDFName extends PDFObject { } writer.write(toString()); - + if (hasObjectNumber()) { writer.write("\nendobj\n"); } - + writer.flush(); return cout.getCount(); } - + /** {@inheritDoc} */ public void outputInline(OutputStream out, Writer writer) throws IOException { if (hasObjectNumber()) { @@ -103,5 +103,5 @@ public class PDFName extends PDFObject { writer.write(toString()); } } - + } diff --git a/src/java/org/apache/fop/pdf/PDFNameTreeNode.java b/src/java/org/apache/fop/pdf/PDFNameTreeNode.java index 4dcf0e03e..4bc00ef9c 100644 --- a/src/java/org/apache/fop/pdf/PDFNameTreeNode.java +++ b/src/java/org/apache/fop/pdf/PDFNameTreeNode.java @@ -43,7 +43,7 @@ public class PDFNameTreeNode extends PDFDictionary { public void setKids(PDFArray kids) { put(KIDS, kids); } - + /** * Returns the Kids array. * @return the Kids array @@ -51,7 +51,7 @@ public class PDFNameTreeNode extends PDFDictionary { public PDFArray getKids() { return (PDFArray)get(KIDS); } - + /** * Sets the Names array. * @param names the Names array @@ -59,7 +59,7 @@ public class PDFNameTreeNode extends PDFDictionary { public void setNames(PDFArray names) { put(NAMES, names); } - + /** * Returns the Names array. * @return the Names array @@ -67,7 +67,7 @@ public class PDFNameTreeNode extends PDFDictionary { public PDFArray getNames() { return (PDFArray)get(NAMES); } - + /** * Sets the lower limit value of the Limits array. * @param key the lower limit value @@ -116,6 +116,6 @@ public class PDFNameTreeNode extends PDFDictionary { } return limits; } - + } diff --git a/src/java/org/apache/fop/pdf/PDFNames.java b/src/java/org/apache/fop/pdf/PDFNames.java index d2d895771..4253dd6d1 100644 --- a/src/java/org/apache/fop/pdf/PDFNames.java +++ b/src/java/org/apache/fop/pdf/PDFNames.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,14 +16,14 @@ */ /* $Id$ */ - + package org.apache.fop.pdf; /** * Class representing a PDF Names object */ public class PDFNames extends PDFDictionary { - + /** * Create the Names object */ @@ -39,7 +39,7 @@ public class PDFNames extends PDFDictionary { public PDFDests getDests() { return (PDFDests)get("Dests"); } - + /** * Set the Dests object * @param dests the Dests object @@ -47,5 +47,5 @@ public class PDFNames extends PDFDictionary { public void setDests(PDFDests dests) { put("Dests", dests); } - + } diff --git a/src/java/org/apache/fop/pdf/PDFNull.java b/src/java/org/apache/fop/pdf/PDFNull.java index b1af30dc0..01ec7898c 100644 --- a/src/java/org/apache/fop/pdf/PDFNull.java +++ b/src/java/org/apache/fop/pdf/PDFNull.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.pdf; import java.io.IOException; @@ -27,10 +27,10 @@ import java.io.Writer; * Class representing a PDF name object. */ public final class PDFNull implements PDFWritable { - + /** Instance for the "null" object. */ public static final PDFNull INSTANCE = new PDFNull(); - + /** * Creates a new PDF name object. * @param name the name value @@ -42,10 +42,10 @@ public final class PDFNull implements PDFWritable { public String toString() { return "null"; } - + /** {@inheritDoc} */ public void outputInline(OutputStream out, Writer writer) throws IOException { writer.write(toString()); } - + } diff --git a/src/java/org/apache/fop/pdf/PDFNumber.java b/src/java/org/apache/fop/pdf/PDFNumber.java index 2a8d6c472..55834f529 100644 --- a/src/java/org/apache/fop/pdf/PDFNumber.java +++ b/src/java/org/apache/fop/pdf/PDFNumber.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.pdf; import java.text.DecimalFormat; @@ -24,7 +24,7 @@ import java.text.DecimalFormatSymbols; import java.util.Locale; /** - * This class represents a simple number object. It also contains contains some + * This class represents a simple number object. It also contains contains some * utility methods for outputing numbers to PDF. */ public class PDFNumber extends PDFObject { @@ -38,7 +38,7 @@ public class PDFNumber extends PDFObject { public Number getNumber() { return this.number; } - + /** * Sets the number. * @param number the number @@ -69,9 +69,9 @@ public class PDFNumber extends PDFObject { // Static cache. Possible concurrency implications. See comment in doubleOut(double, int). private static DecimalFormat[] decimalFormatCache = new DecimalFormat[17]; - + private static final String BASE_FORMAT = "0.################"; - + /** * Output a double value to a string suitable for PDF. * In this method it is possible to set the maximum @@ -83,7 +83,7 @@ public class PDFNumber extends PDFObject { */ public static String doubleOut(double doubleDown, int dec) { if (dec < 0 || dec >= decimalFormatCache.length) { - throw new IllegalArgumentException("Parameter dec must be between 1 and " + throw new IllegalArgumentException("Parameter dec must be between 1 and " + (decimalFormatCache.length + 1)); } if (decimalFormatCache[dec] == null) { diff --git a/src/java/org/apache/fop/pdf/PDFNumberTreeNode.java b/src/java/org/apache/fop/pdf/PDFNumberTreeNode.java index ef1ccb452..72fbcd1c6 100644 --- a/src/java/org/apache/fop/pdf/PDFNumberTreeNode.java +++ b/src/java/org/apache/fop/pdf/PDFNumberTreeNode.java @@ -43,7 +43,7 @@ public class PDFNumberTreeNode extends PDFDictionary { public void setKids(PDFArray kids) { put(KIDS, kids); } - + /** * Returns the Kids array. * @return the Kids array @@ -51,7 +51,7 @@ public class PDFNumberTreeNode extends PDFDictionary { public PDFArray getKids() { return (PDFArray)get(KIDS); } - + /** * Sets the Nums array. * @param nums the Nums array @@ -59,7 +59,7 @@ public class PDFNumberTreeNode extends PDFDictionary { public void setNums(PDFNumsArray nums) { put(NUMS, nums); } - + /** * Returns the Nums array. * @return the Nums array @@ -67,7 +67,7 @@ public class PDFNumberTreeNode extends PDFDictionary { public PDFNumsArray getNums() { return (PDFNumsArray)get(NUMS); } - + /** * Sets the lower limit value of the Limits array. * @param key the lower limit value @@ -116,6 +116,6 @@ public class PDFNumberTreeNode extends PDFDictionary { } return limits; } - + } diff --git a/src/java/org/apache/fop/pdf/PDFNumsArray.java b/src/java/org/apache/fop/pdf/PDFNumsArray.java index 0a86754e8..e1c38dd48 100644 --- a/src/java/org/apache/fop/pdf/PDFNumsArray.java +++ b/src/java/org/apache/fop/pdf/PDFNumsArray.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.pdf; import java.io.IOException; @@ -32,7 +32,7 @@ import org.apache.commons.io.output.CountingOutputStream; * Class representing an "Nums" array object (for Number Trees). */ public class PDFNumsArray extends PDFObject { - + /** Sorted Map holding the values of this array. */ protected SortedMap map = new java.util.TreeMap(); @@ -51,7 +51,7 @@ public class PDFNumsArray extends PDFObject { public int length() { return this.map.size(); } - + /** * Sets an entry. * @param key the key of the value to set @@ -60,7 +60,7 @@ public class PDFNumsArray extends PDFObject { public void put(int key, Object obj) { this.map.put(new Integer(key), obj); } - + /** * Gets an entry. * @param key the key of requested value @@ -69,7 +69,7 @@ public class PDFNumsArray extends PDFObject { public Object get(int key) { return this.map.get(new Integer(key)); } - + /** {@inheritDoc} */ protected int output(OutputStream stream) throws IOException { CountingOutputStream cout = new CountingOutputStream(stream); @@ -77,7 +77,7 @@ public class PDFNumsArray extends PDFObject { if (hasObjectNumber()) { writer.write(getObjectID()); } - + writer.write('['); boolean first = true; Iterator iter = this.map.entrySet().iterator(); @@ -92,13 +92,13 @@ public class PDFNumsArray extends PDFObject { formatObject(entry.getValue(), cout, writer); } writer.write(']'); - + if (hasObjectNumber()) { writer.write("\nendobj\n"); } - + writer.flush(); return cout.getCount(); } - + } diff --git a/src/java/org/apache/fop/pdf/PDFObject.java b/src/java/org/apache/fop/pdf/PDFObject.java index 8dc4d8794..97e9f4976 100644 --- a/src/java/org/apache/fop/pdf/PDFObject.java +++ b/src/java/org/apache/fop/pdf/PDFObject.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.pdf; // Java @@ -61,7 +61,7 @@ public abstract class PDFObject implements PDFWritable { /** the parent PDFObject (may be null and may not always be set, needed for encryption) */ private PDFObject parent; - + /** * Returns the object's number. * @return the PDF Object number @@ -72,14 +72,14 @@ public abstract class PDFObject implements PDFWritable { } return this.objnum; } - + /** * Default constructor. */ public PDFObject() { //nop } - + /** * Constructor for direct objects. * @param parent the containing PDFObject instance @@ -87,9 +87,9 @@ public abstract class PDFObject implements PDFWritable { public PDFObject(PDFObject parent) { setParent(parent); } - + /** - * Indicates whether this PDFObject has already been assigned an + * Indicates whether this PDFObject has already been assigned an * object number. * @return True if it has an object number */ @@ -164,7 +164,7 @@ public abstract class PDFObject implements PDFWritable { public PDFObject getParent() { return this.parent; } - + /** * Sets the direct parent object. * @param parent the direct parent @@ -201,7 +201,7 @@ public abstract class PDFObject implements PDFWritable { public PDFReference makeReference() { return new PDFReference(this); } - + /** * Write the PDF represention of this object * @@ -224,7 +224,7 @@ public abstract class PDFObject implements PDFWritable { output(out); } } - + /** * Encodes the object as a byte array for output to a PDF file. * @@ -233,12 +233,12 @@ public abstract class PDFObject implements PDFWritable { protected byte[] toPDF() { return encode(toPDFString()); } - - + + /** * This method returns a String representation of the PDF object. The result - * is normally converted/encoded to a byte array by toPDF(). Only use - * this method to implement the serialization if the object can be fully + * is normally converted/encoded to a byte array by toPDF(). Only use + * this method to implement the serialization if the object can be fully * represented as text. If the PDF representation of the object contains * binary content use toPDF() or output(OutputStream) instead. This applies * to any object potentially containing a string object because string object @@ -249,7 +249,7 @@ public abstract class PDFObject implements PDFWritable { throw new UnsupportedOperationException("Not implemented. " + "Use output(OutputStream) instead."); } - + /** * Converts text to a byte array for writing to a PDF file. * @param text text to convert/encode @@ -258,7 +258,7 @@ public abstract class PDFObject implements PDFWritable { public static final byte[] encode(String text) { return PDFDocument.encode(text); } - + /** * Encodes a Text String (3.8.1 in PDF 1.4 specs) * @param text the text to encode @@ -273,7 +273,7 @@ public abstract class PDFObject implements PDFWritable { return encode(PDFText.escapeText(text, false)); } } - + /** * Encodes a String (3.2.3 in PDF 1.4 specs) * @param string the string to encode @@ -282,7 +282,7 @@ public abstract class PDFObject implements PDFWritable { protected byte[] encodeString(String string) { return encodeText(string); } - + /** * Encodes binary data as hexadecimal string object. * @param data the binary data @@ -299,7 +299,7 @@ public abstract class PDFObject implements PDFWritable { out.write(encoded); out.write('>'); } - + /** * Formats an object for serialization to PDF. * @param obj the object @@ -329,7 +329,7 @@ public abstract class PDFObject implements PDFWritable { out.write(encodeText(obj.toString())); } } - + /** Formatting pattern for PDF date */ protected static final SimpleDateFormat DATE_FORMAT; @@ -337,9 +337,9 @@ public abstract class PDFObject implements PDFWritable { DATE_FORMAT = new SimpleDateFormat("'D:'yyyyMMddHHmmss", Locale.ENGLISH); DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT")); } - + /** - * Formats a date/time according to the PDF specification + * Formats a date/time according to the PDF specification * (D:YYYYMMDDHHmmSSOHH'mm'). * @param time date/time value to format * @param tz the time zone @@ -348,17 +348,17 @@ public abstract class PDFObject implements PDFWritable { protected String formatDateTime(Date time, TimeZone tz) { Calendar cal = Calendar.getInstance(tz, Locale.ENGLISH); cal.setTime(time); - + int offset = cal.get(Calendar.ZONE_OFFSET); offset += cal.get(Calendar.DST_OFFSET); - + //DateFormat is operating on GMT so adjust for time zone offset Date dt1 = new Date(time.getTime() + offset); StringBuffer sb = new StringBuffer(); sb.append(DATE_FORMAT.format(dt1)); - + offset /= (1000 * 60); //Convert to minutes - + if (offset == 0) { sb.append('Z'); } else { @@ -392,5 +392,5 @@ public abstract class PDFObject implements PDFWritable { protected String formatDateTime(Date time) { return formatDateTime(time, TimeZone.getDefault()); } - + } diff --git a/src/java/org/apache/fop/pdf/PDFOutline.java b/src/java/org/apache/fop/pdf/PDFOutline.java index b4b7cb6be..57e210a7a 100644 --- a/src/java/org/apache/fop/pdf/PDFOutline.java +++ b/src/java/org/apache/fop/pdf/PDFOutline.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.pdf; import java.io.ByteArrayOutputStream; @@ -50,10 +50,10 @@ public class PDFOutline extends PDFObject { private PDFOutline last; private int count; - + // whether to show this outline item's child outline items private boolean openItem = false; - + /** * title to display for the bookmark entry */ @@ -158,7 +158,7 @@ public class PDFOutline extends PDFObject { bout.write(encode(" /Last " + last.referencePDF() + "\n")); } if (count > 0) { - bout.write(encode(" /Count " + (openItem ? "" : "-") + bout.write(encode(" /Count " + (openItem ? "" : "-") + count + "\n")); } if (actionRef != null) { diff --git a/src/java/org/apache/fop/pdf/PDFOutputIntent.java b/src/java/org/apache/fop/pdf/PDFOutputIntent.java index 17badfd5a..ea073829b 100644 --- a/src/java/org/apache/fop/pdf/PDFOutputIntent.java +++ b/src/java/org/apache/fop/pdf/PDFOutputIntent.java @@ -33,14 +33,14 @@ public class PDFOutputIntent extends PDFObject { public static final String GTS_PDFX = "GTS_PDFX"; /** Subtype for PDF/A-1 output intents */ public static final String GTS_PDFA1 = "GTS_PDFA1"; - + private String subtype; //S in the PDF spec private String outputCondition; private String outputConditionIdentifier; private String registryName; private String info; private PDFICCStream destOutputProfile; - + /** @return the output intent subtype. */ public String getSubtype() { @@ -119,7 +119,7 @@ public class PDFOutputIntent extends PDFObject { /** * Sets the destination ICC profile. - * @param destOutputProfile An ICC profile stream defining the transformation from the PDF + * @param destOutputProfile An ICC profile stream defining the transformation from the PDF * document's source colors to output device colorants. */ public void setDestOutputProfile(PDFICCStream destOutputProfile) { @@ -137,33 +137,33 @@ public class PDFOutputIntent extends PDFObject { bout.write(encode("/S /")); bout.write(encode(this.subtype)); bout.write(encode("\n")); - + if (outputCondition != null) { bout.write(encode("/OutputCondition ")); bout.write(encodeText(this.outputCondition)); bout.write(encode("\n")); } - + bout.write(encode("/OutputConditionIdentifier ")); bout.write(encodeText(this.outputConditionIdentifier)); bout.write(encode("\n")); - + if (registryName != null) { bout.write(encode("/RegistryName ")); bout.write(encodeText(this.registryName)); bout.write(encode("\n")); } - + if (info != null) { bout.write(encode("/Info ")); bout.write(encodeText(this.info)); bout.write(encode("\n")); } - + if (destOutputProfile != null) { bout.write(encode("/DestOutputProfile " + destOutputProfile.referencePDF() + "\n")); } - + bout.write(encode(">>\nendobj\n")); } catch (IOException ioe) { log.error("Ignored I/O exception", ioe); @@ -171,5 +171,5 @@ public class PDFOutputIntent extends PDFObject { return bout.toByteArray(); } - + } diff --git a/src/java/org/apache/fop/pdf/PDFPage.java b/src/java/org/apache/fop/pdf/PDFPage.java index ee105f39b..d1472e154 100644 --- a/src/java/org/apache/fop/pdf/PDFPage.java +++ b/src/java/org/apache/fop/pdf/PDFPage.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.pdf; import java.awt.geom.Rectangle2D; @@ -33,7 +33,7 @@ public class PDFPage extends PDFResourceContext { /** the page index (zero-based) */ protected int pageIndex; - + /** * Create a /Page object * @@ -75,12 +75,12 @@ public class PDFPage extends PDFResourceContext { setBleedBox(box); //Recommended by PDF/X setTrimBox(box); //Needed for PDF/X } - + private PDFArray toPDFArray(Rectangle2D box) { return new PDFArray(this, new double[] { box.getX(), box.getY(), box.getMaxX(), box.getMaxY()}); } - + /** * Sets the "MediaBox" entry * @param box the media rectangle @@ -88,7 +88,7 @@ public class PDFPage extends PDFResourceContext { public void setMediaBox(Rectangle2D box) { put("MediaBox", toPDFArray(box)); } - + /** * Sets the "TrimBox" entry * @param box the trim rectangle @@ -96,7 +96,7 @@ public class PDFPage extends PDFResourceContext { public void setTrimBox(Rectangle2D box) { put("TrimBox", toPDFArray(box)); } - + /** * Sets the "BleedBox" entry * @param box the bleed rectangle @@ -104,7 +104,7 @@ public class PDFPage extends PDFResourceContext { public void setBleedBox(Rectangle2D box) { put("BleedBox", toPDFArray(box)); } - + /** * set this page contents * diff --git a/src/java/org/apache/fop/pdf/PDFPageLabels.java b/src/java/org/apache/fop/pdf/PDFPageLabels.java index 1a51c4155..2c1a977b4 100644 --- a/src/java/org/apache/fop/pdf/PDFPageLabels.java +++ b/src/java/org/apache/fop/pdf/PDFPageLabels.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,14 +16,14 @@ */ /* $Id$ */ - + package org.apache.fop.pdf; /** * Class representing a PDF /PageLabels dictionary. */ public class PDFPageLabels extends PDFNumberTreeNode { - + /** * Create the /PageLabels dictionary */ @@ -44,5 +44,5 @@ public class PDFPageLabels extends PDFNumberTreeNode { } return nums; } - + } diff --git a/src/java/org/apache/fop/pdf/PDFPages.java b/src/java/org/apache/fop/pdf/PDFPages.java index 37a2394db..bef4bdbc4 100644 --- a/src/java/org/apache/fop/pdf/PDFPages.java +++ b/src/java/org/apache/fop/pdf/PDFPages.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.pdf; // Java @@ -67,7 +67,7 @@ public class PDFPages extends PDFObject { page.setParent(this); this.incrementCount(); } - + /** * Use this method to notify the PDFPages object that a child page * @param page the child page @@ -79,7 +79,7 @@ public class PDFPages extends PDFObject { this.kids.add(null); } if (this.kids.get(idx) != null) { - throw new IllegalStateException("A page already exists at index " + throw new IllegalStateException("A page already exists at index " + idx + " (zero-based)."); } this.kids.set(idx, page.referencePDF()); diff --git a/src/java/org/apache/fop/pdf/PDFPathPaint.java b/src/java/org/apache/fop/pdf/PDFPathPaint.java index 0bcb19a7e..5133e54a4 100644 --- a/src/java/org/apache/fop/pdf/PDFPathPaint.java +++ b/src/java/org/apache/fop/pdf/PDFPathPaint.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.pdf; /** diff --git a/src/java/org/apache/fop/pdf/PDFPattern.java b/src/java/org/apache/fop/pdf/PDFPattern.java index 3bb190c48..4e862c3f2 100644 --- a/src/java/org/apache/fop/pdf/PDFPattern.java +++ b/src/java/org/apache/fop/pdf/PDFPattern.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.pdf; // Java @@ -118,8 +118,8 @@ public class PDFPattern extends PDFPathPaint { * @param thePatternDataStream The stream of pattern data to be tiled. */ public PDFPattern(PDFResources theResources, int thePatternType, // 1 - int thePaintType, int theTilingType, List theBBox, - double theXStep, double theYStep, + int thePaintType, int theTilingType, List theBBox, + double theXStep, double theYStep, List theMatrix, List theXUID, StringBuffer thePatternDataStream) { super(); @@ -272,9 +272,9 @@ public class PDFPattern extends PDFPathPaint { pdfStream.setDocument(getDocumentSafely()); pdfStream.add(this.patternDataStream.toString()); pdfStream.getFilterList().addDefaultFilters( - getDocument().getFilterMap(), + getDocument().getFilterMap(), PDFFilterList.CONTENT_FILTER); - encodedStream = pdfStream.encodeStream(); + encodedStream = pdfStream.encodeStream(); p.append(pdfStream.getFilterList().buildFilterDictEntries()); p.append("/Length " + (encodedStream.getSize() + 1) + " \n"); diff --git a/src/java/org/apache/fop/pdf/PDFProfile.java b/src/java/org/apache/fop/pdf/PDFProfile.java index 3264e1f44..20af4e212 100644 --- a/src/java/org/apache/fop/pdf/PDFProfile.java +++ b/src/java/org/apache/fop/pdf/PDFProfile.java @@ -26,25 +26,25 @@ import java.text.MessageFormat; * the libarary and its users to enable the generation of PDFs conforming to the enabled PDF * profiles. *

      - * Some profile from PDF/X and PDF/A can be active simultaneously (example: PDF/A-1 and + * Some profile from PDF/X and PDF/A can be active simultaneously (example: PDF/A-1 and * PDF/X-3:2003). */ public class PDFProfile { /** - * Indicates the PDF/A mode currently active. Defaults to "no restrictions", i.e. + * Indicates the PDF/A mode currently active. Defaults to "no restrictions", i.e. * PDF/A not active. */ protected PDFAMode pdfAMode = PDFAMode.DISABLED; - + /** - * Indicates the PDF/X mode currently active. Defaults to "no restrictions", i.e. + * Indicates the PDF/X mode currently active. Defaults to "no restrictions", i.e. * PDF/X not active. */ protected PDFXMode pdfXMode = PDFXMode.DISABLED; - + private PDFDocument doc; - + /** * Main constructor * @param doc the PDF document @@ -52,7 +52,7 @@ public class PDFProfile { public PDFProfile(PDFDocument doc) { this.doc = doc; } - + /** * Validates if the requested profile combination is compatible. */ @@ -69,22 +69,22 @@ public class PDFProfile { } } } - + /** @return the PDFDocument this profile is attached to */ public PDFDocument getDocument() { return this.doc; } - + /** @return the PDF/A mode */ public PDFAMode getPDFAMode() { return this.pdfAMode; } - + /** @return true if any PDF/A mode is active */ public boolean isPDFAActive() { return getPDFAMode() != PDFAMode.DISABLED; } - + /** * Sets the PDF/A mode * @param mode the PDF/A mode @@ -96,17 +96,17 @@ public class PDFProfile { this.pdfAMode = mode; validateProfileCombination(); } - + /** @return the PDF/X mode */ public PDFXMode getPDFXMode() { return this.pdfXMode; } - + /** @return true if any PDF/X mode is active */ public boolean isPDFXActive() { return getPDFXMode() != PDFXMode.DISABLED; } - + /** * Sets the PDF/X mode * @param mode the PDF/X mode @@ -133,13 +133,13 @@ public class PDFProfile { } return sb.toString(); } - + //---------=== Info and validation methods ===--------- - + private String format(String pattern, Object arg) { return MessageFormat.format(pattern, new Object[] {arg}); } - + /** Checks if encryption is allowed. */ public void verifyEncryptionAllowed() { final String err = "{0} doesn't allow encrypted PDFs"; @@ -170,11 +170,11 @@ public class PDFProfile { public void verifyTransparencyAllowed(String context) { final String err = "{0} does not allow the use of transparency. ({1})"; if (isPDFAActive()) { - throw new PDFConformanceException(MessageFormat.format(err, + throw new PDFConformanceException(MessageFormat.format(err, new Object[] {getPDFAMode(), context})); } if (isPDFXActive()) { - throw new PDFConformanceException(MessageFormat.format(err, + throw new PDFConformanceException(MessageFormat.format(err, new Object[] {getPDFXMode(), context})); } } @@ -182,16 +182,16 @@ public class PDFProfile { /** Checks if the right PDF version is set. */ public void verifyPDFVersion() { final String err = "PDF version must be 1.4 for {0}"; - if (getPDFAMode().isPDFA1LevelB() + if (getPDFAMode().isPDFA1LevelB() && getDocument().getPDFVersion() != PDFDocument.PDF_VERSION_1_4) { throw new PDFConformanceException(format(err, getPDFAMode())); } - if (getPDFXMode() == PDFXMode.PDFX_3_2003 + if (getPDFXMode() == PDFXMode.PDFX_3_2003 && getDocument().getPDFVersion() != PDFDocument.PDF_VERSION_1_4) { throw new PDFConformanceException(format(err, getPDFXMode())); } } - + /** @return true if the ID entry must be present in the trailer. */ public boolean isIDEntryRequired() { return isPDFAActive() || isPDFXActive(); @@ -224,7 +224,7 @@ public class PDFProfile { public boolean isAnnotationAllowed() { return !isPDFXActive(); } - + /** Checks if annotations are allowed. */ public void verifyAnnotAllowed() { if (!isAnnotationAllowed()) { diff --git a/src/java/org/apache/fop/pdf/PDFRectangle.java b/src/java/org/apache/fop/pdf/PDFRectangle.java index ca97c2474..ce5b46440 100644 --- a/src/java/org/apache/fop/pdf/PDFRectangle.java +++ b/src/java/org/apache/fop/pdf/PDFRectangle.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.pdf; import java.io.IOException; diff --git a/src/java/org/apache/fop/pdf/PDFReference.java b/src/java/org/apache/fop/pdf/PDFReference.java index da388d368..5c3bdf3dc 100644 --- a/src/java/org/apache/fop/pdf/PDFReference.java +++ b/src/java/org/apache/fop/pdf/PDFReference.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.pdf; import java.io.IOException; @@ -32,11 +32,11 @@ import java.lang.ref.SoftReference; * PDF file. */ public class PDFReference implements PDFWritable { - + private String indirectReference; - + private Reference objReference; - + /** * Creates a new PDF reference. * @param obj the object to be referenced @@ -45,7 +45,7 @@ public class PDFReference implements PDFWritable { this.indirectReference = obj.referencePDF(); this.objReference = new SoftReference(obj); } - + /** * Creates a new PDF reference, but without a reference to the original object. * @param ref an object reference @@ -72,15 +72,15 @@ public class PDFReference implements PDFWritable { return null; } } - + /** {@inheritDoc} */ public String toString() { return this.indirectReference; } - + /** {@inheritDoc} */ public void outputInline(OutputStream out, Writer writer) throws IOException { writer.write(toString()); } - + } diff --git a/src/java/org/apache/fop/pdf/PDFResourceContext.java b/src/java/org/apache/fop/pdf/PDFResourceContext.java index 6be18ce9d..16c1976db 100644 --- a/src/java/org/apache/fop/pdf/PDFResourceContext.java +++ b/src/java/org/apache/fop/pdf/PDFResourceContext.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.pdf; /** diff --git a/src/java/org/apache/fop/pdf/PDFResources.java b/src/java/org/apache/fop/pdf/PDFResources.java index da213bb87..cbfc9d53a 100644 --- a/src/java/org/apache/fop/pdf/PDFResources.java +++ b/src/java/org/apache/fop/pdf/PDFResources.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.pdf; import java.util.HashMap; @@ -67,10 +67,10 @@ public class PDFResources extends PDFObject { /** Map of color spaces (key: color space name) */ protected Map colorSpaces = new HashMap(); - + /** Map of ICC color spaces (key: ICC profile description) */ protected Map iccColorSpaces = new HashMap(); - + /** * create a /Resources object. * @@ -93,7 +93,7 @@ public class PDFResources extends PDFObject { /** * Add the fonts in the font info to this PDF document's Font Resources. - * + * * @param doc PDF document to add fonts to * @param fontInfo font info object to get font information from */ @@ -103,7 +103,7 @@ public class PDFResources extends PDFObject { while (e.hasNext()) { String f = (String)e.next(); Typeface font = (Typeface)usedFonts.get(f); - + //Check if the font actually had any mapping operations. If not, it is an indication //that it has never actually been used and therefore doesn't have to be embedded. if (font.hadMappingOperations()) { @@ -159,7 +159,7 @@ public class PDFResources extends PDFObject { /** * Add a ColorSpace dictionary to the resources. - * @param colorSpace the color space + * @param colorSpace the color space */ public void addColorSpace(PDFICCBasedColorSpace colorSpace) { this.colorSpaces.put(colorSpace.getName(), colorSpace); diff --git a/src/java/org/apache/fop/pdf/PDFRoot.java b/src/java/org/apache/fop/pdf/PDFRoot.java index 0dd9b890c..1ea316390 100644 --- a/src/java/org/apache/fop/pdf/PDFRoot.java +++ b/src/java/org/apache/fop/pdf/PDFRoot.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.pdf; /** @@ -50,7 +50,7 @@ public class PDFRoot extends PDFDictionary { new PDFName("UseThumbs"), new PDFName("FullScreen"), }; - + /** * create a Root (/Catalog) object. NOTE: The PDFRoot * object must be created before the PDF document is @@ -94,7 +94,7 @@ public class PDFRoot extends PDFDictionary { return PAGEMODE_USENONE; } } - + /** * add a /Page object to the root /Pages object * @@ -123,7 +123,7 @@ public class PDFRoot extends PDFDictionary { PDFReference ref = (PDFReference)get("Pages"); return (ref != null ? (PDFPages)ref.getObject() : null); } - + /** * Sets the /PageLabels object. * @param pageLabels the /PageLabels object @@ -131,7 +131,7 @@ public class PDFRoot extends PDFDictionary { public void setPageLabels(PDFPageLabels pageLabels) { put("PageLabels", pageLabels.makeReference()); } - + /** * Returns the /PageLabels object. * @return the /PageLabels object if set, null otherwise. @@ -141,7 +141,7 @@ public class PDFRoot extends PDFDictionary { PDFReference ref = (PDFReference)get("PageLabels"); return (ref != null ? (PDFPageLabels)ref.getObject() : null); } - + /** * Set the root outline for the PDF document. * @@ -149,7 +149,7 @@ public class PDFRoot extends PDFDictionary { */ public void setRootOutline(PDFOutline out) { put("Outlines", out.makeReference()); - + //Set /PageMode to /UseOutlines by default if no other mode has been set PDFName mode = (PDFName)get("PageMode"); if (mode == null) { @@ -166,7 +166,7 @@ public class PDFRoot extends PDFDictionary { PDFReference ref = (PDFReference)get("Outlines"); return (ref != null ? (PDFOutline)ref.getObject() : null); } - + /** * Set the /Names object. * @param names the Names object @@ -175,7 +175,7 @@ public class PDFRoot extends PDFDictionary { public void setNames(PDFNames names) { put("Names", names.makeReference()); } - + /** * Returns the /Names object. * @return the Names object if set, null otherwise. @@ -185,7 +185,7 @@ public class PDFRoot extends PDFDictionary { PDFReference ref = (PDFReference)get("Names"); return (ref != null ? (PDFNames)ref.getObject() : null); } - + /** * Set the optional Metadata object. * @param meta the Metadata object @@ -196,7 +196,7 @@ public class PDFRoot extends PDFDictionary { put("Metadata", meta.makeReference()); } } - + /** * Returns the /Metadata object * @return the /Metadata object if set, null otherwise. @@ -215,7 +215,7 @@ public class PDFRoot extends PDFDictionary { public PDFArray getOutputIntents() { return (PDFArray)get("OutputIntents"); } - + /** * Adds an OutputIntent to the PDF * @param outputIntent the OutputIntent dictionary @@ -223,7 +223,7 @@ public class PDFRoot extends PDFDictionary { */ public void addOutputIntent(PDFOutputIntent outputIntent) { if (getDocumentSafely().getPDFVersion() >= PDFDocument.PDF_VERSION_1_4) { - PDFArray outputIntents = getOutputIntents(); + PDFArray outputIntents = getOutputIntents(); if (outputIntents == null) { outputIntents = new PDFArray(this); put("OutputIntents", outputIntents); @@ -231,7 +231,7 @@ public class PDFRoot extends PDFDictionary { outputIntents.add(outputIntent); } } - + /** * Returns the language identifier of the document. * @return the language identifier of the document (or null if not set or undefined) @@ -240,7 +240,7 @@ public class PDFRoot extends PDFDictionary { public String getLanguage() { return (String)get("Lang"); } - + /** * Sets the language identifier of the document. * @param lang the language identifier of the document. @@ -251,5 +251,5 @@ public class PDFRoot extends PDFDictionary { } put("Lang", lang); } - + } diff --git a/src/java/org/apache/fop/pdf/PDFShading.java b/src/java/org/apache/fop/pdf/PDFShading.java index a782eaf36..5ac7245c9 100644 --- a/src/java/org/apache/fop/pdf/PDFShading.java +++ b/src/java/org/apache/fop/pdf/PDFShading.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.pdf; // Java... @@ -338,7 +338,7 @@ public class PDFShading extends PDFObject { int vectorSize; int tempInt; StringBuffer p = new StringBuffer(128); - p.append(getObjectID() + p.append(getObjectID() + "<< \n/ShadingType " + this.shadingType + " \n"); if (this.colorSpace != null) { p.append("/ColorSpace /" diff --git a/src/java/org/apache/fop/pdf/PDFState.java b/src/java/org/apache/fop/pdf/PDFState.java index 4f7b23a80..241bfce3f 100644 --- a/src/java/org/apache/fop/pdf/PDFState.java +++ b/src/java/org/apache/fop/pdf/PDFState.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.pdf; import java.util.Iterator; @@ -150,9 +150,9 @@ public class PDFState extends org.apache.fop.render.AbstractState { } return newState; } - + private class PDFData extends org.apache.fop.render.AbstractState.AbstractData { - + private static final long serialVersionUID = 3527950647293177764L; private Paint paint = null; @@ -179,7 +179,7 @@ public class PDFState extends org.apache.fop.render.AbstractState { obj.gstate = this.gstate; return obj; } - + /** {@inheritDoc} */ public String toString() { return super.toString() diff --git a/src/java/org/apache/fop/pdf/PDFStream.java b/src/java/org/apache/fop/pdf/PDFStream.java index a213340e3..5f74a2613 100644 --- a/src/java/org/apache/fop/pdf/PDFStream.java +++ b/src/java/org/apache/fop/pdf/PDFStream.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.pdf; import java.io.IOException; @@ -32,14 +32,14 @@ import java.io.Writer; * length. */ public class PDFStream extends AbstractPDFStream { - + /** * The stream of PDF commands */ protected StreamCache data; private transient Writer streamWriter; - + /** * Create an empty stream object */ @@ -70,11 +70,11 @@ public class PDFStream extends AbstractPDFStream { ex.printStackTrace(); } } - + private void flush() throws IOException { this.streamWriter.flush(); } - + /** * Returns a Writer that writes to the OutputStream of the buffer. * @return the Writer @@ -95,7 +95,7 @@ public class PDFStream extends AbstractPDFStream { } return this.data.getOutputStream(); } - + /** * Used to set the contents of the PDF stream. * @param data the contents as a byte array @@ -138,7 +138,7 @@ public class PDFStream extends AbstractPDFStream { */ protected int output(OutputStream stream) throws IOException { final int len = super.output(stream); - + //Now that the data has been written, it can be discarded. this.data = null; return len; diff --git a/src/java/org/apache/fop/pdf/PDFT1Stream.java b/src/java/org/apache/fop/pdf/PDFT1Stream.java index d122743b0..8181287b5 100644 --- a/src/java/org/apache/fop/pdf/PDFT1Stream.java +++ b/src/java/org/apache/fop/pdf/PDFT1Stream.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.pdf; // Java @@ -29,7 +29,7 @@ import org.apache.fop.fonts.type1.PFBData; * Special PDFStream for embedding Type 1 fonts. */ public class PDFT1Stream extends AbstractPDFStream { - + private PFBData pfb; /** @@ -76,9 +76,9 @@ public class PDFT1Stream extends AbstractPDFStream { protected void outputRawStreamData(OutputStream out) throws IOException { this.pfb.outputAllParts(out); } - + /** - * Used to set the PFBData object that represents the embeddable Type 1 + * Used to set the PFBData object that represents the embeddable Type 1 * font. * @param pfb The PFB file * @throws IOException in case of an I/O problem diff --git a/src/java/org/apache/fop/pdf/PDFTTFStream.java b/src/java/org/apache/fop/pdf/PDFTTFStream.java index 5570c62f3..6c68ea8bf 100644 --- a/src/java/org/apache/fop/pdf/PDFTTFStream.java +++ b/src/java/org/apache/fop/pdf/PDFTTFStream.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.pdf; import java.io.IOException; @@ -25,7 +25,7 @@ import java.io.IOException; * Special PDFStream for embeddable TrueType fonts. */ public class PDFTTFStream extends PDFStream { - + private int origLength; /** @@ -58,7 +58,7 @@ public class PDFTTFStream extends PDFStream { put("Length1", origLength); super.populateStreamDict(lengthEntry); } - + /** * Sets the TrueType font data. * @param data the font payload diff --git a/src/java/org/apache/fop/pdf/PDFText.java b/src/java/org/apache/fop/pdf/PDFText.java index d380ac8dd..02f845266 100644 --- a/src/java/org/apache/fop/pdf/PDFText.java +++ b/src/java/org/apache/fop/pdf/PDFText.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.pdf; import java.io.ByteArrayOutputStream; @@ -24,15 +24,15 @@ import java.io.ByteArrayOutputStream; import org.apache.avalon.framework.CascadingRuntimeException; /** - * This class represents a simple number object. It also contains contains some + * This class represents a simple number object. It also contains contains some * utility methods for outputting numbers to PDF. */ public class PDFText extends PDFObject { - private static final char[] DIGITS + private static final char[] DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; - + private String text; /** @@ -42,7 +42,7 @@ public class PDFText extends PDFObject { public String getText() { return this.text; } - + /** * Sets the text. * @param text the text @@ -97,7 +97,7 @@ public class PDFText extends PDFObject { } } } - + if (hexMode) { final byte[] uniBytes; try { @@ -114,7 +114,7 @@ public class PDFText extends PDFObject { if (unicode) { // byte order marker (0xfeff) result.append("\\376\\377"); - + for (int i = 0; i < l; i++) { final char ch = text.charAt(i); final int high = (ch & 0xff00) >>> 8; @@ -162,7 +162,7 @@ public class PDFText extends PDFObject { } return sb.toString(); } - + /** * Converts a byte array to a Hexadecimal String (3.2.3 in PDF 1.4 specs) * @param data the data to encode @@ -171,7 +171,7 @@ public class PDFText extends PDFObject { public static final String toHex(byte[] data) { return toHex(data, true); } - + /** * Converts a String to UTF-16 (big endian). * @param text text to convert @@ -206,7 +206,7 @@ public class PDFText extends PDFObject { } return buf.toString(); } - + /** * Escaped a String as described in section 4.4 in the PDF 1.3 specs. * @param s String to escape diff --git a/src/java/org/apache/fop/pdf/PDFTextUtil.java b/src/java/org/apache/fop/pdf/PDFTextUtil.java index 224bb6a1d..735a7894d 100644 --- a/src/java/org/apache/fop/pdf/PDFTextUtil.java +++ b/src/java/org/apache/fop/pdf/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. @@ -27,9 +27,9 @@ import java.awt.geom.AffineTransform; */ public abstract class PDFTextUtil { - /** The number of decimal places. */ + /** The number of decimal places. */ private static final int DEC = 8; - + /** PDF text rendering mode: Fill text */ public static final int TR_FILL = 0; /** PDF text rendering mode: Stroke text */ @@ -46,30 +46,30 @@ public abstract class PDFTextUtil { public static final int TR_FILL_STROKE_CLIP = 6; /** PDF text rendering mode: Add text to path for clipping */ public static final int TR_CLIP = 7; - + private boolean inTextObject = false; private String startText; private String endText; private boolean useMultiByte; private StringBuffer bufTJ; private int textRenderingMode = TR_FILL; - + private String currentFontName; private double currentFontSize; - + /** * Main constructor. */ public PDFTextUtil() { //nop } - + /** * Writes PDF code. * @param code the PDF code to write */ protected abstract void write(String code); - + private void writeAffineTransform(AffineTransform at, StringBuffer sb) { double[] lt = new double[6]; at.getMatrix(lt); @@ -100,13 +100,13 @@ public abstract class PDFTextUtil { sb.append(PDFText.toUnicodeHex(ch)); } } - + private void checkInTextObject() { if (!inTextObject) { throw new IllegalStateException("Not in text object"); } } - + /** * Indicates whether we are in a text object or not. * @return true if we are in a text object @@ -114,7 +114,7 @@ public abstract class PDFTextUtil { public boolean isInTextObject() { return inTextObject; } - + /** * Called when a new text object should be started. Be sure to call setFont() before * issuing any text painting commands. @@ -126,7 +126,7 @@ public abstract class PDFTextUtil { write("BT\n"); this.inTextObject = true; } - + /** * Called when a text object should be ended. */ @@ -136,7 +136,7 @@ public abstract class PDFTextUtil { this.inTextObject = false; initValues(); } - + /** * Resets the state fields. */ @@ -145,14 +145,14 @@ public abstract class PDFTextUtil { this.currentFontSize = 0.0; this.textRenderingMode = TR_FILL; } - + /** * Creates a "q" command, pushing a copy of the entire graphics state onto the stack. */ public void saveGraphicsState() { write("q\n"); } - + /** * Creates a "Q" command, restoring the entire graphics state to its former value by popping * it from the stack. @@ -160,7 +160,7 @@ public abstract class PDFTextUtil { public void restoreGraphicsState() { write("Q\n"); } - + /** * Creates a "cm" command. * @param at the transformation matrix @@ -174,7 +174,7 @@ public abstract class PDFTextUtil { write(sb.toString()); } } - + /** * Writes a "Tf" command, setting a new current font. * @param fontName the name of the font to select @@ -183,7 +183,7 @@ public abstract class PDFTextUtil { public void writeTf(String fontName, double fontSize) { checkInTextObject(); write("/" + fontName + " " + PDFNumber.doubleOut(fontSize) + " Tf\n"); - + this.startText = useMultiByte ? "<" : "("; this.endText = useMultiByte ? ">" : ")"; } @@ -220,7 +220,7 @@ public abstract class PDFTextUtil { write(this.textRenderingMode + " Tr\n"); } } - + /** * Sets the text rendering mode. * @param fill true if the text should be filled @@ -239,7 +239,7 @@ public abstract class PDFTextUtil { } setTextRenderingMode(mode); } - + /** * Writes a "Tm" command, setting a new text transformation matrix. * @param localTransform the new text transformation matrix diff --git a/src/java/org/apache/fop/pdf/PDFToUnicodeCMap.java b/src/java/org/apache/fop/pdf/PDFToUnicodeCMap.java index 3d25e28cb..b70430af4 100644 --- a/src/java/org/apache/fop/pdf/PDFToUnicodeCMap.java +++ b/src/java/org/apache/fop/pdf/PDFToUnicodeCMap.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.pdf; import java.io.IOException; @@ -61,9 +61,9 @@ public class PDFToUnicodeCMap extends PDFCMap { protected CMapBuilder createCMapBuilder(Writer writer) { return new ToUnicodeCMapBuilder(writer); } - + class ToUnicodeCMapBuilder extends CMapBuilder { - + public ToUnicodeCMapBuilder(Writer writer) { super(writer, null); } @@ -82,7 +82,7 @@ public class PDFToUnicodeCMap extends PDFCMap { writeBFEntries(); writeWrapUp(); } - + /** * Writes the character mappings for this font. * @param p StingBuffer to write to @@ -99,7 +99,7 @@ public class PDFToUnicodeCMap extends PDFCMap { * expressed as part of a character range). * @param p StringBuffer to write to * @param charArray all the characters to map - * @throws IOException + * @throws IOException */ protected void writeBFCharEntries(char[] charArray) throws IOException { int totalEntries = 0; @@ -136,7 +136,7 @@ public class PDFToUnicodeCMap extends PDFCMap { * Writes the entries for character ranges for a base font. * @param p StringBuffer to write to * @param charArray all the characters to map - * @throws IOException + * @throws IOException */ protected void writeBFRangeEntries(char[] charArray) throws IOException { int totalEntries = 0; @@ -283,6 +283,6 @@ public class PDFToUnicodeCMap extends PDFCMap { return returnString.toString(); } - } - + } + } diff --git a/src/java/org/apache/fop/pdf/PDFUri.java b/src/java/org/apache/fop/pdf/PDFUri.java index 19617e368..296e38945 100644 --- a/src/java/org/apache/fop/pdf/PDFUri.java +++ b/src/java/org/apache/fop/pdf/PDFUri.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.pdf; /** diff --git a/src/java/org/apache/fop/pdf/PDFWArray.java b/src/java/org/apache/fop/pdf/PDFWArray.java index 04351c77d..ad6d2ac29 100644 --- a/src/java/org/apache/fop/pdf/PDFWArray.java +++ b/src/java/org/apache/fop/pdf/PDFWArray.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.pdf; import java.util.List; @@ -31,12 +31,12 @@ public class PDFWArray { */ private List entries = new java.util.ArrayList(); - /** - * Default constructor + /** + * Default constructor */ public PDFWArray() { } - + /** * Convenience constructor * @param metrics the metrics array to initially add diff --git a/src/java/org/apache/fop/pdf/PDFWritable.java b/src/java/org/apache/fop/pdf/PDFWritable.java index 4f024fb92..6e71dc7d8 100644 --- a/src/java/org/apache/fop/pdf/PDFWritable.java +++ b/src/java/org/apache/fop/pdf/PDFWritable.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.pdf; import java.io.IOException; @@ -28,7 +28,7 @@ import java.io.Writer; * serializing the object or by writing a indirect reference to the actual object. */ public interface PDFWritable { - + /** * Writes a "direct object" (inline object) representation to the stream. A Writer is given * for optimized encoding of text content. Since the Writer is buffered, make sure @@ -38,5 +38,5 @@ public interface PDFWritable { * @throws IOException if an I/O error occurs */ void outputInline(OutputStream out, Writer writer) throws IOException; - + } diff --git a/src/java/org/apache/fop/pdf/PDFXMode.java b/src/java/org/apache/fop/pdf/PDFXMode.java index 05df3e32a..03813273b 100644 --- a/src/java/org/apache/fop/pdf/PDFXMode.java +++ b/src/java/org/apache/fop/pdf/PDFXMode.java @@ -26,7 +26,7 @@ public final class PDFXMode { public static final PDFXMode DISABLED = new PDFXMode("PDF/X disabled"); /** PDF/X-3:2003 enabled */ public static final PDFXMode PDFX_3_2003 = new PDFXMode("PDF/X-3:2003"); - + private String name; /** @@ -41,7 +41,7 @@ public final class PDFXMode { public String getName() { return this.name; } - + /** * Returns the mode enum object given a String. * @param s the string @@ -54,10 +54,10 @@ public final class PDFXMode { return DISABLED; } } - + /** {@inheritDoc} */ public String toString() { return name; } - + } diff --git a/src/java/org/apache/fop/pdf/PDFXObject.java b/src/java/org/apache/fop/pdf/PDFXObject.java index d0115fe66..d1ce6d75e 100644 --- a/src/java/org/apache/fop/pdf/PDFXObject.java +++ b/src/java/org/apache/fop/pdf/PDFXObject.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.pdf; // Java @@ -33,7 +33,7 @@ import java.io.IOException; * document in another place. */ public abstract class PDFXObject extends AbstractPDFStream { - + /** * Create an XObject with the given number. */ @@ -48,13 +48,13 @@ public abstract class PDFXObject extends AbstractPDFStream { public PDFName getName() { return (PDFName)get("Name"); } - + /** {@inheritDoc} */ protected void populateStreamDict(Object lengthEntry) { put("Type", new PDFName("XObject")); super.populateStreamDict(lengthEntry); } - + /** {@inheritDoc} */ protected int getSizeHint() throws IOException { return 0; diff --git a/src/java/org/apache/fop/pdf/StreamCache.java b/src/java/org/apache/fop/pdf/StreamCache.java index 8ac6e13e1..95d21ab80 100644 --- a/src/java/org/apache/fop/pdf/StreamCache.java +++ b/src/java/org/apache/fop/pdf/StreamCache.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.pdf; import java.io.OutputStream; diff --git a/src/java/org/apache/fop/pdf/StreamCacheFactory.java b/src/java/org/apache/fop/pdf/StreamCacheFactory.java index 00cfe933e..4e2d12eb2 100644 --- a/src/java/org/apache/fop/pdf/StreamCacheFactory.java +++ b/src/java/org/apache/fop/pdf/StreamCacheFactory.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.pdf; import java.io.IOException; @@ -31,7 +31,7 @@ public class StreamCacheFactory { private static StreamCacheFactory memoryInstance = null; private boolean cacheToFile = false; - + /** * Returns an instance of a StreamCacheFactory with the requested features. * @param cacheToFile True if file shall be cached using a temporary file @@ -50,7 +50,7 @@ public class StreamCacheFactory { return memoryInstance; } } - + /** * Returns an instance of a StreamCacheFactory depending on the default * setting for cacheToFile. @@ -59,7 +59,7 @@ public class StreamCacheFactory { public static StreamCacheFactory getInstance() { return getInstance(defaultCacheToFile); } - + /** * Sets the global default for cacheToFile * @param cacheToFile True if stream caches should be held in files. @@ -75,7 +75,7 @@ public class StreamCacheFactory { public StreamCacheFactory(boolean cacheToFile) { this.cacheToFile = cacheToFile; } - + /** * Get the correct implementation (based on cacheToFile) of * StreamCache. @@ -89,7 +89,7 @@ public class StreamCacheFactory { return new InMemoryStreamCache(); } } - + /** * Get the correct implementation (based on cacheToFile) of * StreamCache. @@ -104,7 +104,7 @@ public class StreamCacheFactory { return new InMemoryStreamCache(hintSize); } } - + /** * Get the value of the global cacheToFile flag. * @return the current cache to file flag @@ -112,6 +112,6 @@ public class StreamCacheFactory { public boolean getCacheToFile() { return this.cacheToFile; } - + } diff --git a/src/java/org/apache/fop/pdf/TempFileStreamCache.java b/src/java/org/apache/fop/pdf/TempFileStreamCache.java index e29595989..9920a334d 100644 --- a/src/java/org/apache/fop/pdf/TempFileStreamCache.java +++ b/src/java/org/apache/fop/pdf/TempFileStreamCache.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.pdf; // Java @@ -75,7 +75,7 @@ public class TempFileStreamCache implements StreamCache { public void write(byte[] data) throws IOException { getOutputStream().write(data); } - + /** * Outputs the cached bytes to the given stream. * diff --git a/src/java/org/apache/fop/pdf/TransitionDictionary.java b/src/java/org/apache/fop/pdf/TransitionDictionary.java index 5c779d8fe..6711c9508 100644 --- a/src/java/org/apache/fop/pdf/TransitionDictionary.java +++ b/src/java/org/apache/fop/pdf/TransitionDictionary.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.pdf; /** diff --git a/src/java/org/apache/fop/render/AbstractFOEventHandlerMaker.java b/src/java/org/apache/fop/render/AbstractFOEventHandlerMaker.java index b122db56f..0d891efe9 100644 --- a/src/java/org/apache/fop/render/AbstractFOEventHandlerMaker.java +++ b/src/java/org/apache/fop/render/AbstractFOEventHandlerMaker.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.fo.FOEventHandler; * about them. */ public abstract class AbstractFOEventHandlerMaker { - + /** * Instantiates a new FOEventHandler. * @param ua the user agent @@ -45,7 +45,7 @@ public abstract class AbstractFOEventHandlerMaker { * @return Indicates whether this renderer requires an OutputStream to work with. */ public abstract boolean needsOutputStream(); - + /** * @return an array of MIME types the renderer supports. */ @@ -65,5 +65,5 @@ public abstract class AbstractFOEventHandlerMaker { } return false; } - + } diff --git a/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java b/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java index a06bd0f97..8691e3cbe 100644 --- a/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java +++ b/src/java/org/apache/fop/render/AbstractGenericSVGHandler.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. @@ -54,7 +54,7 @@ public abstract class AbstractGenericSVGHandler implements XMLHandler, RendererC protected static Log log = LogFactory.getLog(AbstractGenericSVGHandler.class); /** {@inheritDoc} */ - public void handleXML(RendererContext context, + public void handleXML(RendererContext context, Document doc, String ns) throws Exception { if (SVGDOMImplementation.SVG_NAMESPACE_URI.equals(ns)) { @@ -118,8 +118,8 @@ public abstract class AbstractGenericSVGHandler implements XMLHandler, RendererC //Let the painter paint the SVG on the Graphics2D instance Graphics2DAdapter adapter = context.getRenderer().getGraphics2DAdapter(); - adapter.paintImage(painter, context, - x, y, wrappedContext.getWidth(), wrappedContext.getHeight()); + adapter.paintImage(painter, context, + x, y, wrappedContext.getWidth(), wrappedContext.getHeight()); } /** @@ -136,7 +136,7 @@ public abstract class AbstractGenericSVGHandler implements XMLHandler, RendererC } 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/AbstractGraphics2DAdapter.java b/src/java/org/apache/fop/render/AbstractGraphics2DAdapter.java index 19796eada..4f3bb98a5 100644 --- a/src/java/org/apache/fop/render/AbstractGraphics2DAdapter.java +++ b/src/java/org/apache/fop/render/AbstractGraphics2DAdapter.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; import java.awt.Color; @@ -52,7 +52,7 @@ public abstract class AbstractGraphics2DAdapter implements Graphics2DAdapter { * @return the generated BufferedImage */ protected BufferedImage paintToBufferedImage( - org.apache.xmlgraphics.java2d.Graphics2DImagePainter painter, + org.apache.xmlgraphics.java2d.Graphics2DImagePainter painter, RendererContextWrapper context, int resolution, boolean gray, boolean withAlpha) { int bmw = (int)Math.ceil(UnitConv.mpt2px(context.getWidth(), resolution)); int bmh = (int)Math.ceil(UnitConv.mpt2px(context.getHeight(), resolution)); @@ -72,10 +72,10 @@ public abstract class AbstractGraphics2DAdapter implements Graphics2DAdapter { } Graphics2D g2d = bi.createGraphics(); try { - g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, + g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); setRenderingHintsForBufferedImage(g2d); - + g2d.setBackground(Color.white); g2d.setColor(Color.black); if (!withAlpha) { @@ -130,17 +130,17 @@ public abstract class AbstractGraphics2DAdapter implements Graphics2DAdapter { * @param g2d the Graphics2D instance */ protected void setRenderingHintsForBufferedImage(Graphics2D g2d) { - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); - g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, + g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); } /** {@inheritDoc} */ - public void paintImage(Graphics2DImagePainter painter, + public void paintImage(Graphics2DImagePainter painter, RendererContext context, int x, int y, int width, int height) throws IOException { paintImage((org.apache.xmlgraphics.java2d.Graphics2DImagePainter)painter, context, x, y, width, height); } - + } diff --git a/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java b/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java index b02afdc0e..7bd470915 100644 --- a/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java +++ b/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java @@ -66,7 +66,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { protected void handleBlockTraits(Block block) { int borderPaddingStart = block.getBorderAndPaddingWidthStart(); int borderPaddingBefore = block.getBorderAndPaddingWidthBefore(); - + float startx = currentIPPosition / 1000f; float starty = currentBPPosition / 1000f; float width = block.getIPD() / 1000f; @@ -151,10 +151,10 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { BorderProps bpsEnd = (BorderProps)borderArea.getTrait(Trait.BORDER_END); drawBackground(startx, starty, width, height, - (Trait.Background) backgroundArea.getTrait(Trait.BACKGROUND), + (Trait.Background) backgroundArea.getTrait(Trait.BACKGROUND), bpsBefore, bpsAfter, bpsStart, bpsEnd); drawBorders(startx, starty, width, height, - bpsBefore, bpsAfter, bpsStart, bpsEnd); + bpsBefore, bpsAfter, bpsStart, bpsEnd); } /** @@ -204,13 +204,13 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { fillRect(sx, sy, paddRectWidth, paddRectHeight); } if (back.getImageInfo() != null) { - ImageSize imageSize = back.getImageInfo().getSize(); + ImageSize imageSize = back.getImageInfo().getSize(); saveGraphicsState(); clipRect(sx, sy, paddRectWidth, paddRectHeight); - int horzCount = (int)((paddRectWidth - * 1000 / imageSize.getWidthMpt()) + 1.0f); - int vertCount = (int)((paddRectHeight - * 1000 / imageSize.getHeightMpt()) + 1.0f); + int horzCount = (int)((paddRectWidth + * 1000 / imageSize.getWidthMpt()) + 1.0f); + int vertCount = (int)((paddRectHeight + * 1000 / imageSize.getHeightMpt()) + 1.0f); if (back.getRepeat() == EN_NOREPEAT) { horzCount = 1; vertCount = 1; @@ -233,7 +233,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { // place once Rectangle2D pos; // Image positions are relative to the currentIP/BP - pos = new Rectangle2D.Float(sx - currentIPPosition + pos = new Rectangle2D.Float(sx - currentIPPosition + (x * imageSize.getWidthMpt()), sy - currentBPPosition + (y * imageSize.getHeightMpt()), @@ -242,7 +242,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { drawImage(back.getURL(), pos); } } - + restoreGraphicsState(); } } @@ -282,7 +282,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { * @param bpsStart the border specification on the start side * @param bpsEnd the border specification on the end side */ - protected void drawBorders(Rectangle2D.Float borderRect, + protected void drawBorders(Rectangle2D.Float borderRect, BorderProps bpsBefore, BorderProps bpsAfter, BorderProps bpsStart, BorderProps bpsEnd) { //TODO generalize each of the four conditions into using a parameterized drawBorder() boolean[] border = new boolean[] { @@ -298,9 +298,9 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { (border[AFTER] ? bpsAfter.width / 1000f : 0.0f), (border[START] ? bpsStart.width / 1000f : 0.0f)}; float[] clipw = new float[] { - BorderProps.getClippedWidth(bpsBefore) / 1000f, - BorderProps.getClippedWidth(bpsEnd) / 1000f, - BorderProps.getClippedWidth(bpsAfter) / 1000f, + BorderProps.getClippedWidth(bpsBefore) / 1000f, + BorderProps.getClippedWidth(bpsEnd) / 1000f, + BorderProps.getClippedWidth(bpsAfter) / 1000f, BorderProps.getClippedWidth(bpsStart) / 1000f}; starty += clipw[BEFORE]; height -= clipw[BEFORE]; @@ -308,7 +308,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { startx += clipw[START]; width -= clipw[START]; width -= clipw[END]; - + boolean[] slant = new boolean[] { (border[START] && border[BEFORE]), (border[BEFORE] && border[END]), @@ -344,7 +344,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { lineTo(sx2, innery); closePath(); clip(); - drawBorderLine(sx1a, outery, ex1a, innery, true, true, + drawBorderLine(sx1a, outery, ex1a, innery, true, true, bpsBefore.style, bpsBefore.color); restoreGraphicsState(); } @@ -358,7 +358,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { float outerx = startx + width + clipw[END]; float clipx = outerx - clipw[END]; float innerx = outerx - borderWidth[END]; - + saveGraphicsState(); moveTo(clipx, sy1); float sy1a = sy1; @@ -448,8 +448,8 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { restoreGraphicsState(); } } - - /** + + /** * Common method to render the background and borders for any inline area. * The all borders and padding are drawn outside the specified area. * @param area the inline area for which the background, border and padding is to be @@ -458,11 +458,11 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { protected void renderInlineAreaBackAndBorders(InlineArea area) { float borderPaddingStart = area.getBorderAndPaddingWidthStart() / 1000f; float borderPaddingBefore = area.getBorderAndPaddingWidthBefore() / 1000f; - float bpwidth = borderPaddingStart + float bpwidth = borderPaddingStart + (area.getBorderAndPaddingWidthEnd() / 1000f); float bpheight = borderPaddingBefore + (area.getBorderAndPaddingWidthAfter() / 1000f); - + float height = area.getBPD() / 1000f; if (height != 0.0f || bpheight != 0.0f && bpwidth != 0.0f) { float x = currentIPPosition / 1000f; @@ -473,10 +473,10 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { , height + bpheight); } } - + private static final QName FOX_TRANSFORM = new QName(ExtensionElementMapping.URI, "fox:transform"); - + /** {@inheritDoc} */ protected void renderBlockViewport(BlockViewport bv, List children) { // clip and position viewport if necessary @@ -502,10 +502,10 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { if (bv.getPositioning() == Block.FIXED) { breakOutList = breakOutOfStateStack(); } - + AffineTransform positionTransform = new AffineTransform(); positionTransform.translate(bv.getXOffset(), bv.getYOffset()); - + //"left/"top" (bv.getX/YOffset()) specify the position of the content rectangle positionTransform.translate(-borderPaddingStart, -borderPaddingBefore); @@ -520,7 +520,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { saveGraphicsState(); //Viewport position concatenateTransformationMatrix(mptToPt(positionTransform)); - + //Background and borders float bpwidth = (borderPaddingStart + bv.getBorderAndPaddingWidthEnd()) / 1000f; float bpheight = (borderPaddingBefore + bv.getBorderAndPaddingWidthAfter()) / 1000f; @@ -530,7 +530,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { AffineTransform contentRectTransform = new AffineTransform(); contentRectTransform.translate(borderPaddingStart, borderPaddingBefore); concatenateTransformationMatrix(mptToPt(contentRectTransform)); - + //Clipping if (bv.getClip()) { clipRect(0f, 0f, width, height); @@ -540,18 +540,18 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { //Set up coordinate system for content rectangle AffineTransform contentTransform = ctm.toAffineTransform(); concatenateTransformationMatrix(mptToPt(contentTransform)); - + currentIPPosition = 0; currentBPPosition = 0; renderBlocks(bv, children); restoreGraphicsState(); restoreGraphicsState(); - + if (breakOutList != null) { restoreStateStackAfterBreakOut(breakOutList); } - + currentIPPosition = saveIP; currentBPPosition = saveBP; } else { @@ -566,16 +566,16 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { CTM tempctm = new CTM(containingIPPosition, currentBPPosition); ctm = tempctm.multiply(ctm); - + //Now adjust for border/padding currentBPPosition += borderPaddingBefore; Rectangle2D clippingRect = null; if (bv.getClip()) { - clippingRect = new Rectangle(currentIPPosition, currentBPPosition, + clippingRect = new Rectangle(currentIPPosition, currentBPPosition, bv.getIPD(), bv.getBPD()); } - + startVParea(ctm, clippingRect); currentIPPosition = 0; currentBPPosition = 0; @@ -584,7 +584,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { currentIPPosition = saveIP; currentBPPosition = saveBP; - + currentBPPosition += (int)(bv.getAllocBPD()); } } @@ -600,7 +600,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { at.translate(currentIPPosition, currentBPPosition); at.translate(block.getXOffset(), block.getYOffset()); at.translate(0, block.getSpaceBefore()); - + if (!at.isIdentity()) { saveGraphicsState(); concatenateTransformationMatrix(mptToPt(at)); @@ -618,12 +618,12 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { if (!at.isIdentity()) { restoreGraphicsState(); } - + // stacked and relative blocks effect stacking currentIPPosition = saveIP; currentBPPosition = saveBP; } - + /** {@inheritDoc} */ protected void renderFlow(NormalFlow flow) { // save position and offset @@ -633,7 +633,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { //Establish a new coordinate system AffineTransform at = new AffineTransform(); at.translate(currentIPPosition, currentBPPosition); - + if (!at.isIdentity()) { saveGraphicsState(); concatenateTransformationMatrix(mptToPt(at)); @@ -642,23 +642,23 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { currentIPPosition = 0; currentBPPosition = 0; super.renderFlow(flow); - + if (!at.isIdentity()) { restoreGraphicsState(); } - + // stacked and relative blocks effect stacking currentIPPosition = saveIP; currentBPPosition = saveBP; } - + /** * Concatenates the current transformation matrix with the given one, therefore establishing * a new coordinate system. * @param at the transformation matrix to process (coordinates in points) */ protected abstract void concatenateTransformationMatrix(AffineTransform at); - + /** * Render an inline viewport. * This renders an inline viewport by clipping if necessary. @@ -670,10 +670,10 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { float y = (currentBPPosition + viewport.getOffset()) / 1000f; float width = viewport.getIPD() / 1000f; float height = viewport.getBPD() / 1000f; - // TODO: Calculate the border rect correctly. + // TODO: Calculate the border rect correctly. float borderPaddingStart = viewport.getBorderAndPaddingWidthStart() / 1000f; float borderPaddingBefore = viewport.getBorderAndPaddingWidthBefore() / 1000f; - float bpwidth = borderPaddingStart + float bpwidth = borderPaddingStart + (viewport.getBorderAndPaddingWidthEnd() / 1000f); float bpheight = borderPaddingBefore + (viewport.getBorderAndPaddingWidthAfter() / 1000f); @@ -697,7 +697,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { * @param breakOutList the state stack to restore. */ protected abstract void restoreStateStackAfterBreakOut(List breakOutList); - + /** * Breaks out of the state stack to handle fixed block-containers. * @return the saved state stack to recreate later @@ -706,16 +706,16 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { /** Saves the graphics state of the rendering engine. */ protected abstract void saveGraphicsState(); - + /** Restores the last graphics state of the rendering engine. */ protected abstract void restoreGraphicsState(); /** Indicates the beginning of a text object. */ protected abstract void beginTextObject(); - + /** Indicates the end of a text object. */ protected abstract void endTextObject(); - + /** * Paints the text decoration marks. * @param fm Current typeface @@ -724,10 +724,10 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { * @param baseline position of the baseline * @param startx start IPD */ - protected void renderTextDecoration(FontMetrics fm, int fontsize, InlineArea inline, + protected void renderTextDecoration(FontMetrics fm, int fontsize, InlineArea inline, int baseline, int startx) { - boolean hasTextDeco = inline.hasUnderline() - || inline.hasOverline() + boolean hasTextDeco = inline.hasUnderline() + || inline.hasOverline() || inline.hasLineThrough(); if (hasTextDeco) { endTextObject(); @@ -738,22 +738,22 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { if (inline.hasUnderline()) { Color ct = (Color) inline.getTrait(Trait.UNDERLINE_COLOR); float y = baseline - descender / 2f; - drawBorderLine(startx / 1000f, (y - halfLineWidth) / 1000f, - endx, (y + halfLineWidth) / 1000f, + drawBorderLine(startx / 1000f, (y - halfLineWidth) / 1000f, + endx, (y + halfLineWidth) / 1000f, true, true, Constants.EN_SOLID, ct); } if (inline.hasOverline()) { Color ct = (Color) inline.getTrait(Trait.OVERLINE_COLOR); float y = (float)(baseline - (1.1 * capHeight)); - drawBorderLine(startx / 1000f, (y - halfLineWidth) / 1000f, - endx, (y + halfLineWidth) / 1000f, + drawBorderLine(startx / 1000f, (y - halfLineWidth) / 1000f, + endx, (y + halfLineWidth) / 1000f, true, true, Constants.EN_SOLID, ct); } if (inline.hasLineThrough()) { Color ct = (Color) inline.getTrait(Trait.LINETHROUGH_COLOR); float y = (float)(baseline - (0.45 * capHeight)); - drawBorderLine(startx / 1000f, (y - halfLineWidth) / 1000f, - endx, (y + halfLineWidth) / 1000f, + drawBorderLine(startx / 1000f, (y - halfLineWidth) / 1000f, + endx, (y + halfLineWidth) / 1000f, true, true, Constants.EN_SOLID, ct); } } @@ -761,7 +761,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { /** Clip using the current path. */ protected abstract void clip(); - + /** * Clip using a rectangular area. * @param x the x coordinate (in points) @@ -770,28 +770,28 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { * @param height the height of the rectangle (in points) */ protected abstract void clipRect(float x, float y, float width, float height); - + /** - * 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 abstract void moveTo(float x, float y); - + /** - * 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 abstract void lineTo(float x, float y); - + /** - * 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 abstract void closePath(); - + /** * Fill a rectangular area. * @param x the x coordinate @@ -807,7 +807,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { * @param fill true to set the fill color, false for the foreground color */ protected abstract void updateColor(Color col, boolean fill); - + /** * Draw an image at the indicated location. * @param url the URI/URL of the image @@ -815,7 +815,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { * @param foreignAttributes an optional Map with foreign attributes, may be null */ protected abstract void drawImage(String url, Rectangle2D pos, Map foreignAttributes); - + /** * Draw an image at the indicated location. * @param url the URI/URL of the image @@ -824,7 +824,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { protected final void drawImage(String url, Rectangle2D pos) { drawImage(url, pos, null); } - + /** * Draw a border segment of an XSL-FO style border. * @param x1 starting x coordinate @@ -832,12 +832,12 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { * @param x2 ending x coordinate * @param y2 ending y coordinate * @param horz true for horizontal border segments, false for vertical border segments - * @param startOrBefore true for border segments on the start or before edge, + * @param startOrBefore true for border segments on the start or before edge, * false for end or after. * @param style the border style (one of Constants.EN_DASHED etc.) * @param col the color for the border segment */ - protected abstract void drawBorderLine(float x1, float y1, float x2, float y2, + protected abstract void drawBorderLine(float x1, float y1, float x2, float y2, boolean horz, boolean startOrBefore, int style, Color col); /** {@inheritDoc} */ @@ -847,5 +847,5 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { String ns = fo.getNameSpace(); renderDocument(doc, ns, pos, fo.getForeignAttributes()); } - + } diff --git a/src/java/org/apache/fop/render/AbstractRenderer.java b/src/java/org/apache/fop/render/AbstractRenderer.java index ebff5323b..e80775890 100644 --- a/src/java/org/apache/fop/render/AbstractRenderer.java +++ b/src/java/org/apache/fop/render/AbstractRenderer.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. @@ -75,12 +75,12 @@ import org.apache.fop.fonts.FontInfo; * top level processing of the area tree and adds some abstract methods to * handle viewports. This keeps track of the current block and inline position. */ -public abstract class AbstractRenderer +public abstract class AbstractRenderer implements Renderer, Constants { /** logging instance */ protected static Log log = LogFactory.getLog("org.apache.fop.render"); - + /** * user agent */ @@ -110,9 +110,9 @@ public abstract class AbstractRenderer /** the currently active PageViewport */ protected PageViewport currentPageViewport; - + private Set warnedXMLHandlers; - + /** {@inheritDoc} */ public abstract void setupFontInfo(FontInfo fontInfo); @@ -153,7 +153,7 @@ public abstract class AbstractRenderer } /** - * {@inheritDoc} + * {@inheritDoc} */ public void processOffDocumentItem(OffDocumentItem odi) { } @@ -161,17 +161,17 @@ public abstract class AbstractRenderer public Graphics2DAdapter getGraphics2DAdapter() { return null; } - + /** {@inheritDoc} */ public ImageAdapter getImageAdapter() { return null; } - + /** @return the current PageViewport or null, if none is active */ protected PageViewport getCurrentPageViewport() { return this.currentPageViewport; } - + /** {@inheritDoc} */ public void preparePage(PageViewport page) { } @@ -212,7 +212,7 @@ public abstract class AbstractRenderer public void startPageSequence(LineArea seqTitle) { //do nothing } - + /** {@inheritDoc} */ public void startPageSequence(PageSequence pageSequence) { startPageSequence(pageSequence.getTitle()); @@ -300,7 +300,7 @@ public abstract class AbstractRenderer * Establishes a new viewport area. * * @param ctm the coordinate transformation matrix to use - * @param clippingRect the clipping rectangle if the viewport should be clipping, + * @param clippingRect the clipping rectangle if the viewport should be clipping, * null if no clipping is performed. */ protected abstract void startVParea(CTM ctm, Rectangle2D clippingRect); @@ -462,7 +462,7 @@ public abstract class AbstractRenderer if (bv.getClip()) { clippingRect = new Rectangle(saveIP, saveBP, bv.getIPD(), bv.getBPD()); } - + CTM ctm = bv.getCTM(); currentIPPosition = 0; currentBPPosition = 0; @@ -495,12 +495,12 @@ public abstract class AbstractRenderer * @param block the block area */ protected abstract void renderReferenceArea(Block block); - + /** * Renders a list of block areas. * * @param parent the parent block if the parent is a block, otherwise - * a null value. + * a null value. * @param blocks The block areas */ protected void renderBlocks(Block parent, List blocks) { @@ -517,7 +517,7 @@ public abstract class AbstractRenderer currentIPPosition += spaceStart.intValue(); }*/ } - + // the position of the containing block is used for // absolutely positioned areas int contBP = currentBPPosition; @@ -538,8 +538,8 @@ public abstract class AbstractRenderer // a line area is rendered from the top left position // of the line, each inline object is offset from there LineArea line = (LineArea) obj; - currentIPPosition = contIP - + parent.getStartIndent() + currentIPPosition = contIP + + parent.getStartIndent() + line.getStartIndent(); renderLineArea(line); //InlineArea child = (InlineArea) line.getInlineAreas().get(0); @@ -637,14 +637,14 @@ public abstract class AbstractRenderer } } - /** + /** * Common method to render the background and borders for any inline area. * The all borders and padding are drawn outside the specified area. * @param area the inline area for which the background, border and padding is to be * rendered */ protected abstract void renderInlineAreaBackAndBorders(InlineArea area); - + /** * Render the given Space. * @param space the space to render @@ -676,7 +676,7 @@ public abstract class AbstractRenderer int saveBP = currentBPPosition; Iterator iter = text.getChildAreas().iterator(); while (iter.hasNext()) { - renderInlineArea((InlineArea) iter.next()); + renderInlineArea((InlineArea) iter.next()); } currentIPPosition = saveIP + text.getAllocIPD(); } @@ -709,7 +709,7 @@ public abstract class AbstractRenderer currentBPPosition += ip.getOffset(); Iterator iter = ip.getChildAreas().iterator(); while (iter.hasNext()) { - renderInlineArea((InlineArea) iter.next()); + renderInlineArea((InlineArea) iter.next()); } currentIPPosition = saveIP + ip.getAllocIPD(); currentBPPosition = saveBP; @@ -809,7 +809,7 @@ public abstract class AbstractRenderer handler.handleXML(ctx, doc, namespace); } catch (Exception e) { // could not handle document - ResourceEventProducer eventProducer + ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get( ctx.getUserAgent().getEventBroadcaster()); eventProducer.foreignXMLProcessingError(this, doc, namespace, e); @@ -830,7 +830,7 @@ public abstract class AbstractRenderer /** * Get the MIME type of the renderer. - * + * * @return The MIME type of the renderer */ public String getMimeType() { diff --git a/src/java/org/apache/fop/render/AbstractRendererConfigurator.java b/src/java/org/apache/fop/render/AbstractRendererConfigurator.java index 982b23f05..33d5a3bcf 100644 --- a/src/java/org/apache/fop/render/AbstractRendererConfigurator.java +++ b/src/java/org/apache/fop/render/AbstractRendererConfigurator.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/AbstractRendererMaker.java b/src/java/org/apache/fop/render/AbstractRendererMaker.java index 381d2e134..fadfda94d 100644 --- a/src/java/org/apache/fop/render/AbstractRendererMaker.java +++ b/src/java/org/apache/fop/render/AbstractRendererMaker.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.apps.FOUserAgent; * about them. */ public abstract class AbstractRendererMaker { - + /** * Instantiates a new renderer. * @param userAgent the user agent @@ -38,7 +38,7 @@ public abstract class AbstractRendererMaker { * @return Indicates whether this renderer requires an OutputStream to work with. */ public abstract boolean needsOutputStream(); - + /** * @return an array of MIME types the renderer supports. */ diff --git a/src/java/org/apache/fop/render/DefaultFontResolver.java b/src/java/org/apache/fop/render/DefaultFontResolver.java index d25328b9f..6fb7e0f01 100644 --- a/src/java/org/apache/fop/render/DefaultFontResolver.java +++ b/src/java/org/apache/fop/render/DefaultFontResolver.java @@ -30,7 +30,7 @@ import org.apache.fop.fonts.FontResolver; public class DefaultFontResolver implements FontResolver { private FOUserAgent userAgent; - + /** * Main constructor. * @param userAgent the user agent @@ -38,10 +38,10 @@ public class DefaultFontResolver implements FontResolver { public DefaultFontResolver(FOUserAgent userAgent) { this.userAgent = userAgent; } - + /** {@inheritDoc} */ public Source resolve(String href) { return userAgent.resolveURI(href, userAgent.getFontBaseURL()); } - + } diff --git a/src/java/org/apache/fop/render/Graphics2DAdapter.java b/src/java/org/apache/fop/render/Graphics2DAdapter.java index 4fbdbe09a..6c389d0ec 100644 --- a/src/java/org/apache/fop/render/Graphics2DAdapter.java +++ b/src/java/org/apache/fop/render/Graphics2DAdapter.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; import java.io.IOException; @@ -43,10 +43,10 @@ public interface Graphics2DAdapter { * @param height height of the image * @throws IOException In case of an I/O error while writing the output format */ - void paintImage(org.apache.xmlgraphics.java2d.Graphics2DImagePainter painter, + void paintImage(org.apache.xmlgraphics.java2d.Graphics2DImagePainter painter, RendererContext context, int x, int y, int width, int height) throws IOException; - + /** * Paints an arbitrary images on a given Graphics2D instance. The renderer * providing this functionality must set up a Graphics2D instance so that @@ -62,8 +62,8 @@ public interface Graphics2DAdapter { * @throws IOException In case of an I/O error while writing the output format * @deprecated Use the variant with the Graphics2DImagePainter from XML Graphics Commons instead */ - void paintImage(Graphics2DImagePainter painter, + void paintImage(Graphics2DImagePainter painter, RendererContext context, int x, int y, int width, int height) throws IOException; - + } diff --git a/src/java/org/apache/fop/render/Graphics2DImagePainter.java b/src/java/org/apache/fop/render/Graphics2DImagePainter.java index 0167417fe..da802418c 100644 --- a/src/java/org/apache/fop/render/Graphics2DImagePainter.java +++ b/src/java/org/apache/fop/render/Graphics2DImagePainter.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; /** diff --git a/src/java/org/apache/fop/render/ImageAdapter.java b/src/java/org/apache/fop/render/ImageAdapter.java index 1984cfa96..a67d43bdc 100644 --- a/src/java/org/apache/fop/render/ImageAdapter.java +++ b/src/java/org/apache/fop/render/ImageAdapter.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; import java.awt.image.RenderedImage; @@ -40,8 +40,8 @@ public interface ImageAdapter { * @param height height of the image * @throws IOException In case of an I/O error while writing the output format */ - void paintImage(RenderedImage image, + void paintImage(RenderedImage image, RendererContext context, int x, int y, int width, int height) throws IOException; - + } diff --git a/src/java/org/apache/fop/render/PrintRendererConfigurator.java b/src/java/org/apache/fop/render/PrintRendererConfigurator.java index 6849f867f..4409c62b8 100644 --- a/src/java/org/apache/fop/render/PrintRendererConfigurator.java +++ b/src/java/org/apache/fop/render/PrintRendererConfigurator.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. @@ -71,7 +71,7 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator /** * Builds a list of EmbedFontInfo objects for use with the setup() method. - * + * * @param renderer print renderer * @throws FOPException if something's wrong with the config data */ @@ -105,7 +105,7 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator /** * Builds a list of EmbedFontInfo objects for use with the setup() method. - * + * * @param cfg Configuration object * @param fontResolver the FontResolver to use * @param strict true if an Exception should be thrown if an error is found. @@ -285,7 +285,7 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator /** * Creates a new FontTriplet given a triple Configuration - * + * * @param tripletCfg a triplet configuration * @param strict use strict validation * @return a font triplet font key @@ -323,7 +323,7 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator /** * Returns a font info from a font node Configuration definition - * + * * @param fontCfg Configuration object (font node) * @param fontResolver font resolver used to resolve font * @param strict validate configuration strictly diff --git a/src/java/org/apache/fop/render/Renderer.java b/src/java/org/apache/fop/render/Renderer.java index 03b4582f7..0ff37db0e 100644 --- a/src/java/org/apache/fop/render/Renderer.java +++ b/src/java/org/apache/fop/render/Renderer.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. @@ -54,7 +54,7 @@ public interface Renderer { /** * Get the MIME type of the renderer. - * + * * @return The MIME type of the renderer, may return null if not applicable. */ String getMimeType(); @@ -93,7 +93,7 @@ public interface Renderer { * @return the user agent */ FOUserAgent getUserAgent(); - + /** * Set up the given FontInfo. * @@ -115,7 +115,7 @@ public interface Renderer { boolean supportsOutOfOrder(); /** - * Tells the renderer to process an item not explicitly placed on the + * Tells the renderer to process an item not explicitly placed on the * document (e.g., PDF bookmarks). Note - not all renderers will process * all off-document items. * @@ -127,12 +127,12 @@ public interface Renderer { * @return the adapter for painting Java2D images (or null if not supported) */ Graphics2DAdapter getGraphics2DAdapter(); - + /** * @return the adapter for painting RenderedImages (or null if not supported) */ ImageAdapter getImageAdapter(); - + /** * This is called if the renderer supports out of order rendering. The * renderer should prepare the page so that a page further on in the set of diff --git a/src/java/org/apache/fop/render/RendererConfigurator.java b/src/java/org/apache/fop/render/RendererConfigurator.java index 028a4863b..6dceeb74d 100644 --- a/src/java/org/apache/fop/render/RendererConfigurator.java +++ b/src/java/org/apache/fop/render/RendererConfigurator.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/RendererContext.java b/src/java/org/apache/fop/render/RendererContext.java index feffc05ed..08ca76957 100644 --- a/src/java/org/apache/fop/render/RendererContext.java +++ b/src/java/org/apache/fop/render/RendererContext.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; //Java @@ -54,7 +54,7 @@ public class RendererContext { public AbstractRenderer getRenderer() { return renderer; } - + /** * Returns the MIME type associated with this RendererContext. * @@ -121,7 +121,7 @@ public class RendererContext { /** The wrapped RendererContext */ protected RendererContext context; - + /** * Main constructor * @param context the RendererContent instance @@ -129,7 +129,7 @@ public class RendererContext { public RendererContextWrapper(RendererContext context) { this.context = context; } - + /** @return the user agent */ public FOUserAgent getUserAgent() { return context.getUserAgent(); @@ -158,7 +158,7 @@ public class RendererContext { /** @return the foreign attributes */ public Map getForeignAttributes() { return (Map)context.getProperty(RendererContextConstants.FOREIGN_ATTRIBUTES); - } - } + } + } } diff --git a/src/java/org/apache/fop/render/RendererContextConstants.java b/src/java/org/apache/fop/render/RendererContextConstants.java index ff7f1f6af..05d802e54 100644 --- a/src/java/org/apache/fop/render/RendererContextConstants.java +++ b/src/java/org/apache/fop/render/RendererContextConstants.java @@ -26,10 +26,10 @@ public interface RendererContextConstants { /** The output stream that the document is being sent to. */ String OUTPUT_STREAM = "outputStream"; - + /** The current PageViewport being rendered. */ String PAGE_VIEWPORT = "pageViewport"; - + /** The target width of the image being painted. */ String WIDTH = "width"; @@ -44,11 +44,11 @@ public interface RendererContextConstants { /** The configuration for the XMLHandler. */ String HANDLER_CONFIGURATION = "cfg"; - + /** - * An optional Map (keys: QName, values: String) with attributes containing additional hints + * An optional Map (keys: QName, values: String) with attributes containing additional hints * for rendering. */ String FOREIGN_ATTRIBUTES = "foreign-attributes"; - + } diff --git a/src/java/org/apache/fop/render/RendererEventProducer.java b/src/java/org/apache/fop/render/RendererEventProducer.java index 365c8f430..c61e4a8ee 100644 --- a/src/java/org/apache/fop/render/RendererEventProducer.java +++ b/src/java/org/apache/fop/render/RendererEventProducer.java @@ -31,7 +31,7 @@ public interface RendererEventProducer extends EventProducer { /** Provider class for the event producer. */ class Provider { - + /** * Returns an event producer. * @param broadcaster the event broadcaster to use diff --git a/src/java/org/apache/fop/render/RendererFactory.java b/src/java/org/apache/fop/render/RendererFactory.java index d81f900e0..a77ee6a03 100644 --- a/src/java/org/apache/fop/render/RendererFactory.java +++ b/src/java/org/apache/fop/render/RendererFactory.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; import java.io.OutputStream; @@ -39,14 +39,14 @@ import org.apache.fop.fo.FOEventHandler; * Factory for FOEventHandlers and Renderers. */ public class RendererFactory { - + /** the logger */ private static Log log = LogFactory.getLog(RendererFactory.class); private Map rendererMakerMapping = new java.util.HashMap(); private Map eventHandlerMakerMapping = new java.util.HashMap(); - - + + /** * Main constructor. */ @@ -54,7 +54,7 @@ public class RendererFactory { discoverRenderers(); discoverFOEventHandlers(); } - + /** * Add a new RendererMaker. If another maker has already been registered for a * particular MIME type, this call overwrites the existing one. @@ -65,13 +65,13 @@ public class RendererFactory { for (int i = 0; i < mimes.length; i++) { //This overrides any renderer previously set for a MIME type if (rendererMakerMapping.get(mimes[i]) != null) { - log.trace("Overriding renderer for " + mimes[i] + log.trace("Overriding renderer for " + mimes[i] + " with " + maker.getClass().getName()); } rendererMakerMapping.put(mimes[i], maker); } } - + /** * Add a new FOEventHandlerMaker. If another maker has already been registered for a * particular MIME type, this call overwrites the existing one. @@ -82,13 +82,13 @@ public class RendererFactory { for (int i = 0; i < mimes.length; i++) { //This overrides any event handler previously set for a MIME type if (eventHandlerMakerMapping.get(mimes[i]) != null) { - log.trace("Overriding FOEventHandler for " + mimes[i] + log.trace("Overriding FOEventHandler for " + mimes[i] + " with " + maker.getClass().getName()); } eventHandlerMakerMapping.put(mimes[i], maker); } } - + /** * Add a new RendererMaker. If another maker has already been registered for a * particular MIME type, this call overwrites the existing one. @@ -114,7 +114,7 @@ public class RendererFactory { + AbstractRendererMaker.class.getName()); } } - + /** * Add a new FOEventHandlerMaker. If another maker has already been registered for a * particular MIME type, this call overwrites the existing one. @@ -140,7 +140,7 @@ public class RendererFactory { + AbstractFOEventHandlerMaker.class.getName()); } } - + /** * Returns a RendererMaker which handles the given MIME type. * @param mime the requested output format @@ -151,7 +151,7 @@ public class RendererFactory { = (AbstractRendererMaker)rendererMakerMapping.get(mime); return maker; } - + /** * Returns a FOEventHandlerMaker which handles the given MIME type. * @param mime the requested output format @@ -162,7 +162,7 @@ public class RendererFactory { = (AbstractFOEventHandlerMaker)eventHandlerMakerMapping.get(mime); return maker; } - + /** * Creates a Renderer object based on render-type desired * @param userAgent the user agent for access to configuration @@ -170,7 +170,7 @@ public class RendererFactory { * @return the new Renderer instance * @throws FOPException if the renderer cannot be properly constructed */ - public Renderer createRenderer(FOUserAgent userAgent, String outputFormat) + public Renderer createRenderer(FOUserAgent userAgent, String outputFormat) throws FOPException { if (userAgent.getRendererOverride() != null) { return userAgent.getRendererOverride(); @@ -189,8 +189,8 @@ public class RendererFactory { return rend; } } - - + + /** * Creates FOEventHandler instances based on the desired output. * @param userAgent the user agent for access to configuration @@ -199,7 +199,7 @@ public class RendererFactory { * @return the newly constructed FOEventHandler * @throws FOPException if the FOEventHandler cannot be properly constructed */ - public FOEventHandler createFOEventHandler(FOUserAgent userAgent, + public FOEventHandler createFOEventHandler(FOUserAgent userAgent, String outputFormat, OutputStream out) throws FOPException { if (userAgent.getFOEventHandlerOverride() != null) { @@ -214,8 +214,8 @@ public class RendererFactory { + " Neither an FOEventHandler, nor a Renderer could be found" + " for this output format."); } else { - if (out == null - && userAgent.getRendererOverride() == null + if (out == null + && userAgent.getRendererOverride() == null && rendMaker.needsOutputStream()) { throw new FOPException( "OutputStream has not been set"); @@ -228,7 +228,7 @@ public class RendererFactory { } } } - + /** * @return an array of all supported MIME types */ @@ -245,7 +245,7 @@ public class RendererFactory { Collections.sort(lst); return (String[])lst.toArray(new String[lst.size()]); } - + /** * Discovers Renderer implementations through the classpath and dynamically * registers them. @@ -259,7 +259,7 @@ public class RendererFactory { AbstractRendererMaker maker = (AbstractRendererMaker)providers.next(); try { if (log.isDebugEnabled()) { - log.debug("Dynamically adding maker for Renderer: " + log.debug("Dynamically adding maker for Renderer: " + maker.getClass().getName()); } addRendererMaker(maker); @@ -270,7 +270,7 @@ public class RendererFactory { } } } - + /** * Discovers FOEventHandler implementations through the classpath and dynamically * registers them. @@ -284,7 +284,7 @@ public class RendererFactory { AbstractFOEventHandlerMaker maker = (AbstractFOEventHandlerMaker)providers.next(); try { if (log.isDebugEnabled()) { - log.debug("Dynamically adding maker for FOEventHandler: " + log.debug("Dynamically adding maker for FOEventHandler: " + maker.getClass().getName()); } addFOEventHandlerMaker(maker); @@ -295,5 +295,5 @@ public class RendererFactory { } } } - + } diff --git a/src/java/org/apache/fop/render/XMLHandler.java b/src/java/org/apache/fop/render/XMLHandler.java index 7966b3b06..f8152fcbf 100644 --- a/src/java/org/apache/fop/render/XMLHandler.java +++ b/src/java/org/apache/fop/render/XMLHandler.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; import org.w3c.dom.Document; @@ -46,9 +46,9 @@ public interface XMLHandler { * @param ns The Namespace of the foreign object * @exception Exception If an error occurs during processing. */ - void handleXML(RendererContext context, + void handleXML(RendererContext context, Document doc, String ns) throws Exception; - + /** * Checks if this XMLHandler supports handling an XML namespace for a particular renderer. * @param renderer the renderer for which to check. @@ -57,7 +57,7 @@ public interface XMLHandler { boolean supportsRenderer(Renderer renderer); /** - * @return the XML namespace for the XML dialect this XMLHandler supports, + * @return the XML namespace for the XML dialect this XMLHandler supports, * null if all XML content is handled by this instance. */ String getNamespace(); diff --git a/src/java/org/apache/fop/render/XMLHandlerConfigurator.java b/src/java/org/apache/fop/render/XMLHandlerConfigurator.java index 78822e9c0..fb2420572 100644 --- a/src/java/org/apache/fop/render/XMLHandlerConfigurator.java +++ b/src/java/org/apache/fop/render/XMLHandlerConfigurator.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,13 +27,13 @@ import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; /** - * Configurator for XMLHandler objects. + * Configurator for XMLHandler objects. */ public class XMLHandlerConfigurator extends AbstractRendererConfigurator { /** logger instance */ protected static Log log = LogFactory.getLog(XMLHandlerConfigurator.class); - + /** * Default constructor * @param userAgent the user agent diff --git a/src/java/org/apache/fop/render/XMLHandlerRegistry.java b/src/java/org/apache/fop/render/XMLHandlerRegistry.java index 533534c4c..81d9fcc93 100644 --- a/src/java/org/apache/fop/render/XMLHandlerRegistry.java +++ b/src/java/org/apache/fop/render/XMLHandlerRegistry.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,17 +37,17 @@ public class XMLHandlerRegistry { /** the logger */ private static Log log = LogFactory.getLog(XMLHandlerRegistry.class); - + /** Map containing XML handlers for various document types */ private Map handlers = new java.util.HashMap(); - + /** * Default constructor. */ public XMLHandlerRegistry() { discoverXMLHandlers(); } - + /** * Add a default XML handler which is able to handle any namespace. * @param handler XMLHandler to use @@ -55,7 +55,7 @@ public class XMLHandlerRegistry { private void setDefaultXMLHandler(XMLHandler handler) { addXMLHandler(XMLHandler.HANDLE_ALL, handler); } - + /** * Add an XML handler. The handler itself is inspected to find out what it supports. * @param classname the fully qualified class name @@ -75,11 +75,11 @@ public class XMLHandlerRegistry { + classname); } catch (ClassCastException e) { throw new IllegalArgumentException(classname - + " is not an " + + " is not an " + XMLHandler.class.getName()); } } - + /** * Add an XML handler. The handler itself is inspected to find out what it supports. * @param handler the XMLHandler instance @@ -92,7 +92,7 @@ public class XMLHandlerRegistry { addXMLHandler(ns, handler); } } - + /** * Add an XML handler for the given MIME type and XML namespace. * @param ns Namespace URI @@ -107,7 +107,7 @@ public class XMLHandlerRegistry { } lst.add(handler); } - + /** * Returns an XMLHandler which handles an XML dialect of the given namespace and for * a specified output format defined by its MIME type. @@ -140,7 +140,7 @@ public class XMLHandlerRegistry { } return null; //No handler found } - + /** * Discovers XMLHandler implementations through the classpath and dynamically * registers them. diff --git a/src/java/org/apache/fop/render/afp/AFPEventProducer.java b/src/java/org/apache/fop/render/afp/AFPEventProducer.java index 615c54c32..08641b20e 100644 --- a/src/java/org/apache/fop/render/afp/AFPEventProducer.java +++ b/src/java/org/apache/fop/render/afp/AFPEventProducer.java @@ -31,7 +31,7 @@ public interface AFPEventProducer extends EventProducer { /** Provider class for the event producer. */ class Provider { - + /** * Returns an event producer. * @param broadcaster the event broadcaster to use @@ -50,14 +50,14 @@ public interface AFPEventProducer extends EventProducer { 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/AFPGraphics2DAdapter.java b/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java index 320e0e6be..dcd5c7dd5 100644 --- a/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java +++ b/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.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.afp; import java.awt.Dimension; @@ -46,12 +46,12 @@ public class AFPGraphics2DAdapter extends AbstractGraphics2DAdapter { */ public AFPGraphics2DAdapter() { } - + /** {@inheritDoc} */ - public void paintImage(Graphics2DImagePainter painter, + public void paintImage(Graphics2DImagePainter painter, RendererContext context, int x, int y, int width, int height) throws IOException { - + AFPInfo afpInfo = AFPSVGHandler.getAFPInfo(context); final boolean textAsShapes = false; diff --git a/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java b/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java index 1723802f9..b843ccefb 100644 --- a/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java +++ b/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.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. @@ -40,10 +40,10 @@ import org.apache.fop.render.afp.modca.AFPDataStream; import org.apache.fop.util.LogUtil; /** - * AFP Renderer configurator + * AFP Renderer configurator */ public class AFPRendererConfigurator extends PrintRendererConfigurator { - + /** * Default constructor * @@ -181,7 +181,7 @@ public class AFPRendererConfigurator extends PrintRendererConfigurator { } return null; } - + /** * Builds a list of AFPFontInfo objects for use with the setup() method. * @@ -238,7 +238,7 @@ public class AFPRendererConfigurator extends PrintRendererConfigurator { } else { afpRenderer.setColorImages(true); } - + // renderer resolution Configuration rendererResolutionCfg = cfg.getChild("renderer-resolution", false); if (rendererResolutionCfg != null) { diff --git a/src/java/org/apache/fop/render/afp/AFPRendererContextConstants.java b/src/java/org/apache/fop/render/afp/AFPRendererContextConstants.java index 360132863..d12c5f2c3 100644 --- a/src/java/org/apache/fop/render/afp/AFPRendererContextConstants.java +++ b/src/java/org/apache/fop/render/afp/AFPRendererContextConstants.java @@ -27,7 +27,7 @@ import org.apache.fop.render.RendererContextConstants; public interface AFPRendererContextConstants extends RendererContextConstants { /** - * Key for a Boolean value that enables grayscale processing instead of color + * Key for a Boolean value that enables grayscale processing instead of color * processing. */ String AFP_GRAYSCALE = "afpGrayscale"; diff --git a/src/java/org/apache/fop/render/afp/AFPSVGHandler.java b/src/java/org/apache/fop/render/afp/AFPSVGHandler.java index 5142c17d3..45588952a 100644 --- a/src/java/org/apache/fop/render/afp/AFPSVGHandler.java +++ b/src/java/org/apache/fop/render/afp/AFPSVGHandler.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. @@ -216,7 +216,7 @@ public class AFPSVGHandler extends AbstractGenericSVGHandler { public boolean supportsRenderer(Renderer renderer) { return (renderer instanceof AFPRenderer); } - + /** {@inheritDoc} */ protected void updateRendererContext(RendererContext context) { //Work around a problem in Batik: Gradients cannot be done in ColorSpace.CS_GRAY diff --git a/src/java/org/apache/fop/render/afp/exceptions/NestedRuntimeException.java b/src/java/org/apache/fop/render/afp/exceptions/NestedRuntimeException.java index 2a5eb6d5f..070e631dc 100644 --- a/src/java/org/apache/fop/render/afp/exceptions/NestedRuntimeException.java +++ b/src/java/org/apache/fop/render/afp/exceptions/NestedRuntimeException.java @@ -30,10 +30,10 @@ import java.io.PrintWriter; * */ public abstract class NestedRuntimeException extends RuntimeException { - + /** Root cause of this nested exception */ private Throwable underlyingException; - + /** * Construct a NestedRuntimeException with the specified detail message. * @param msg The detail message. @@ -41,7 +41,7 @@ public abstract class NestedRuntimeException extends RuntimeException { public NestedRuntimeException(String msg) { super(msg); } - + /** * Construct a NestedRuntimeException with the specified * detail message and nested exception. @@ -51,26 +51,26 @@ public abstract class NestedRuntimeException extends RuntimeException { public NestedRuntimeException(String msg, Throwable t) { super(msg); underlyingException = t; - + } - + /** * Gets the original triggering exception * @return The original exception as a throwable. */ public Throwable getUnderlyingException() { - + return underlyingException; - + } - + /** * Return the detail message, including the message from the nested * exception if there is one. * @return The detail message. */ public String getMessage() { - + if (underlyingException == null) { return super.getMessage(); } else { @@ -78,9 +78,9 @@ public abstract class NestedRuntimeException extends RuntimeException { + "; nested exception is " + underlyingException.getClass().getName(); } - + } - + /** * Print the composite message and the embedded stack trace to the specified stream. * @param ps the print stream @@ -93,7 +93,7 @@ public abstract class NestedRuntimeException extends RuntimeException { underlyingException.printStackTrace(ps); } } - + /** * Print the composite message and the embedded stack trace to the specified writer. * @param pw the print writer @@ -106,5 +106,5 @@ public abstract class NestedRuntimeException extends RuntimeException { underlyingException.printStackTrace(pw); } } - + } diff --git a/src/java/org/apache/fop/render/afp/exceptions/RendererRuntimeException.java b/src/java/org/apache/fop/render/afp/exceptions/RendererRuntimeException.java index 3cec455a0..fe9ec87c0 100644 --- a/src/java/org/apache/fop/render/afp/exceptions/RendererRuntimeException.java +++ b/src/java/org/apache/fop/render/afp/exceptions/RendererRuntimeException.java @@ -24,7 +24,7 @@ package org.apache.fop.render.afp.exceptions; *

      */ public class RendererRuntimeException extends NestedRuntimeException { - + /** * Constructs a RendererRuntimeException with the specified message. * @param msg the exception mesaage @@ -32,7 +32,7 @@ public class RendererRuntimeException extends NestedRuntimeException { public RendererRuntimeException(String msg) { super(msg); } - + /** * Constructs a RendererRuntimeException with the specified message * wrapping the underlying exception. @@ -42,5 +42,5 @@ public class RendererRuntimeException extends NestedRuntimeException { public RendererRuntimeException(String msg, Throwable t) { super(msg, t); } - + } diff --git a/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java b/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java index fca486279..08989c03c 100644 --- a/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java +++ b/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java @@ -30,7 +30,7 @@ import org.xml.sax.helpers.DefaultHandler; /** * ContentHandler (parser) for restoring AFPExtension objects from XML. */ -public class AFPExtensionHandler extends DefaultHandler +public class AFPExtensionHandler extends DefaultHandler implements ContentHandlerFactory.ObjectSource { /** Logger instance */ @@ -38,12 +38,12 @@ public class AFPExtensionHandler extends DefaultHandler private StringBuffer content = new StringBuffer(); private Attributes lastAttributes; - + private AFPPageSetup 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 (AFPPageSetup.CATEGORY.equals(uri)) { @@ -62,10 +62,10 @@ public class AFPExtensionHandler extends DefaultHandler } if (!handled) { if (AFPPageSetup.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); } } @@ -87,7 +87,7 @@ public class AFPExtensionHandler extends DefaultHandler returnedObject.setContent(content.toString()); content.setLength(0); //Reset text buffer (see characters()) } - } + } } /** {@inheritDoc} */ diff --git a/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandlerFactory.java b/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandlerFactory.java index efd351c33..e987866df 100644 --- a/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandlerFactory.java +++ b/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandlerFactory.java @@ -28,7 +28,7 @@ import org.xml.sax.ContentHandler; public class AFPExtensionHandlerFactory implements ContentHandlerFactory { private static final String[] NAMESPACES = new String[] {AFPPageSetup.CATEGORY}; - + /** {@inheritDoc} */ public String[] getSupportedNamespaces() { return NAMESPACES; diff --git a/src/java/org/apache/fop/render/afp/extensions/AFPPageSetup.java b/src/java/org/apache/fop/render/afp/extensions/AFPPageSetup.java index 437222daa..998ce6921 100644 --- a/src/java/org/apache/fop/render/afp/extensions/AFPPageSetup.java +++ b/src/java/org/apache/fop/render/afp/extensions/AFPPageSetup.java @@ -26,7 +26,7 @@ public class AFPPageSetup extends AFPExtensionAttachment { /** * Default constructor. - * + * * @param elementName the name of the setup code object, may be null */ public AFPPageSetup(String elementName) { @@ -39,7 +39,7 @@ public class AFPPageSetup extends AFPExtensionAttachment { * {@inheritDoc} */ public String toString() { - return "AFPPageSetup(element-name=" + getElementName() + return "AFPPageSetup(element-name=" + getElementName() + " name=" + getName() + " value=" + getValue() + ")"; } } diff --git a/src/java/org/apache/fop/render/afp/extensions/AbstractAFPExtensionObject.java b/src/java/org/apache/fop/render/afp/extensions/AbstractAFPExtensionObject.java index ff6d56785..a9bbbcfcf 100644 --- a/src/java/org/apache/fop/render/afp/extensions/AbstractAFPExtensionObject.java +++ b/src/java/org/apache/fop/render/afp/extensions/AbstractAFPExtensionObject.java @@ -37,12 +37,12 @@ public abstract class AbstractAFPExtensionObject extends FONode { * the AFP extension attachment */ protected AFPExtensionAttachment extensionAttachment; - + /** * the element name of this extension */ protected String name; - + /** * @see org.apache.fop.fo.FONode#FONode(FONode) * @param parent the parent formatting object diff --git a/src/java/org/apache/fop/render/afp/fonts/AFPFontCollection.java b/src/java/org/apache/fop/render/afp/fonts/AFPFontCollection.java index 35f99c24c..bce798751 100644 --- a/src/java/org/apache/fop/render/afp/fonts/AFPFontCollection.java +++ b/src/java/org/apache/fop/render/afp/fonts/AFPFontCollection.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,14 +45,14 @@ public class AFPFontCollection implements FontCollection { private EventBroadcaster eventBroadcaster; private List/**/ embedFontInfoList; - + /** * Main constructor - * + * * @param eventBroadcaster the event broadcaster * @param embedFontInfoList the embed font info list */ - public AFPFontCollection(EventBroadcaster eventBroadcaster, + public AFPFontCollection(EventBroadcaster eventBroadcaster, List/**/ embedFontInfoList) { this.eventBroadcaster = eventBroadcaster; this.embedFontInfoList = embedFontInfoList; diff --git a/src/java/org/apache/fop/render/afp/fonts/CharacterSet.java b/src/java/org/apache/fop/render/afp/fonts/CharacterSet.java index 56e6f62df..f3312c104 100644 --- a/src/java/org/apache/fop/render/afp/fonts/CharacterSet.java +++ b/src/java/org/apache/fop/render/afp/fonts/CharacterSet.java @@ -75,7 +75,7 @@ public class CharacterSet { /** * Constructor for the CharacterSetMetric object, the character set is used * to load the font information from the actual AFP font. - * + * * @param codePage the code page identifier * @param encoding the encoding of the font * @param name the character set name @@ -103,7 +103,7 @@ public class CharacterSet { /** * Add character set metric information for the different orientations - * + * * @param cso the metrics for the orientation */ public void addCharacterSetOrientation(CharacterSetOrientation cso) { @@ -122,7 +122,7 @@ public class CharacterSet { * Ascender Height is the characters most positive y-axis value. * For bounded character boxes, for a given character having an * ascender, ascender height and baseline offset are equal. - * + * * @return the ascender value in millipoints */ public int getAscender() { @@ -134,7 +134,7 @@ public class CharacterSet { * Cap height is the average height of the uppercase characters in * a font. This value is specified by the designer of a font and is * usually the height of the uppercase M. - * + * * @return the cap height value in millipoints */ public int getCapHeight() { @@ -146,7 +146,7 @@ public class CharacterSet { * Descender depth is the distance from the character baseline to * the bottom of a character box. A negative descender depth signifies * that all of the graphic character is above the character baseline. - * + * * @return the descender value in millipoints */ public int getDescender() { @@ -156,7 +156,7 @@ public class CharacterSet { /** * Returns the first character in the character set - * + * * @return the first character in the character set */ public int getFirstChar() { @@ -166,7 +166,7 @@ public class CharacterSet { /** * Returns the last character in the character set - * + * * @return the last character in the character set */ public int getLastChar() { @@ -176,7 +176,7 @@ public class CharacterSet { /** * Returns the path where the font resources are installed - * + * * @return the path where the font resources are installed */ public String getPath() { @@ -185,7 +185,7 @@ public class CharacterSet { /** * Get the width (in 1/1000ths of a point size) of all characters - * + * * @return the widths of all characters */ public int[] getWidths() { @@ -206,7 +206,7 @@ public class CharacterSet { /** * Get the width (in 1/1000ths of a point size) of the character * identified by the parameter passed. - * + * * @param character the character from which the width will be calculated * @return the width of the character */ @@ -229,7 +229,7 @@ public class CharacterSet { /** * Returns the AFP character set identifier - * + * * @return the AFP character set identifier */ public String getName() { @@ -238,7 +238,7 @@ public class CharacterSet { /** * Returns the AFP character set identifier as a byte array - * + * * @return the AFP character set identifier as a byte array */ public byte[] getNameBytes() { @@ -255,7 +255,7 @@ public class CharacterSet { /** * Returns the AFP code page identifier - * + * * @return the AFP code page identifier */ public String getCodePage() { @@ -264,7 +264,7 @@ public class CharacterSet { /** * Returns the AFP code page encoding - * + * * @return the AFP code page encoding */ public String getEncoding() { @@ -280,7 +280,7 @@ public class CharacterSet { * the case for landscape prints which use an orientation of 270 degrees, * in 99.9% of cases the font metrics will be the same as the 0 degrees * therefore the implementation currently will always use 0 degrees. - * + * * @return characterSetOrentation The current orientation metrics. */ private CharacterSetOrientation getCharacterSetOrientation() { @@ -293,7 +293,7 @@ public class CharacterSet { * Map a Unicode character to a code point in the font. * The code tables are already converted to Unicode therefore * we can use the identity mapping. - * + * * @param c character to map * @return the mapped character */ diff --git a/src/java/org/apache/fop/render/afp/fonts/FopCharacterSet.java b/src/java/org/apache/fop/render/afp/fonts/FopCharacterSet.java index cde2c141d..f6864d73f 100644 --- a/src/java/org/apache/fop/render/afp/fonts/FopCharacterSet.java +++ b/src/java/org/apache/fop/render/afp/fonts/FopCharacterSet.java @@ -45,7 +45,7 @@ public class FopCharacterSet extends CharacterSet { String name, int size, Typeface charSet) { - + super(codePage, encoding, name, null); this.charSet = charSet; this.size = size * 1000; diff --git a/src/java/org/apache/fop/render/afp/modca/AbstractDescriptor.java b/src/java/org/apache/fop/render/afp/modca/AbstractDescriptor.java index 250895908..728008e96 100644 --- a/src/java/org/apache/fop/render/afp/modca/AbstractDescriptor.java +++ b/src/java/org/apache/fop/render/afp/modca/AbstractDescriptor.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/afp/modca/AbstractNamedAFPObject.java b/src/java/org/apache/fop/render/afp/modca/AbstractNamedAFPObject.java index c3cd6ed43..463058791 100644 --- a/src/java/org/apache/fop/render/afp/modca/AbstractNamedAFPObject.java +++ b/src/java/org/apache/fop/render/afp/modca/AbstractNamedAFPObject.java @@ -35,13 +35,13 @@ public abstract class AbstractNamedAFPObject extends AbstractStructuredAFPObject * The actual name of the object */ protected String name = null; - + /** * Default constructor */ protected AbstractNamedAFPObject() { } - + /** * Constructor for the ActiveEnvironmentGroup, this takes a * name parameter which should be 8 characters long. @@ -75,7 +75,7 @@ public abstract class AbstractNamedAFPObject extends AbstractStructuredAFPObject } return nameBytes; } - + /** {@inheritDoc} */ protected void copySF(byte[] data, byte type, byte category) { super.copySF(data, type, category); diff --git a/src/java/org/apache/fop/render/afp/modca/MapCodedFont.java b/src/java/org/apache/fop/render/afp/modca/MapCodedFont.java index ad6fc3f6b..512e091a3 100644 --- a/src/java/org/apache/fop/render/afp/modca/MapCodedFont.java +++ b/src/java/org/apache/fop/render/afp/modca/MapCodedFont.java @@ -237,7 +237,7 @@ public class MapCodedFont extends AbstractStructuredAFPObject { } catch (UnsupportedEncodingException ex) { throw new FontRuntimeException("Failed to create font " + " due to a UnsupportedEncodingException", ex); - } + } } @@ -272,4 +272,4 @@ public class MapCodedFont extends AbstractStructuredAFPObject { private int scale = 0; } -} \ No newline at end of file +} diff --git a/src/java/org/apache/fop/render/afp/modca/NoOperation.java b/src/java/org/apache/fop/render/afp/modca/NoOperation.java index a59f3665c..6896388ed 100644 --- a/src/java/org/apache/fop/render/afp/modca/NoOperation.java +++ b/src/java/org/apache/fop/render/afp/modca/NoOperation.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,47 +36,47 @@ import org.apache.fop.render.afp.tools.BinaryUtils; * the data carried by the No Operation structured field in interchange */ public class NoOperation extends AbstractAFPObject { - + /** Up to 32759 bytes of data with no architectural definition */ private static final int MAX_DATA_LEN = 32759; - + /** - * Byte representation of the comment + * Byte representation of the comment */ private String content; /** * Construct a tag logical element with the name and value specified. - * + * * @param content the content to record */ public NoOperation(String content) { this.content = content; } - + /** * Accessor method to obtain the byte array AFP datastream for the * NoOperation. - * + * * @param os The outputsteam stream * @throws java.io.IOException if an I/O exception occurs during processing */ public void write(OutputStream os) throws IOException { byte[] contentData = content.getBytes(AFPConstants.EBCIDIC_ENCODING); int contentLen = contentData.length; - + // packet maximum of 32759 bytes if (contentLen > MAX_DATA_LEN) { contentLen = MAX_DATA_LEN; } - + byte[] data = new byte[9 + contentLen]; - + data[0] = 0x5A; - + // Set the total record length byte[] rl1 = BinaryUtils.convert(8 + contentLen, 2); - + //Ignore first byte data[1] = rl1[0]; data[2] = rl1[1]; diff --git a/src/java/org/apache/fop/render/afp/modca/ObjectAreaDescriptor.java b/src/java/org/apache/fop/render/afp/modca/ObjectAreaDescriptor.java index f27a3dee6..fa257fb87 100644 --- a/src/java/org/apache/fop/render/afp/modca/ObjectAreaDescriptor.java +++ b/src/java/org/apache/fop/render/afp/modca/ObjectAreaDescriptor.java @@ -80,4 +80,4 @@ public class ObjectAreaDescriptor extends AbstractDescriptor { os.write(data); } -} \ No newline at end of file +} diff --git a/src/java/org/apache/fop/render/afp/modca/Overlay.java b/src/java/org/apache/fop/render/afp/modca/Overlay.java index 3013c2d09..01b2533c2 100644 --- a/src/java/org/apache/fop/render/afp/modca/Overlay.java +++ b/src/java/org/apache/fop/render/afp/modca/Overlay.java @@ -26,7 +26,7 @@ import org.apache.fop.render.afp.modca.resource.ResourceManager; /** * An overlay is a MO:DCA-P resource object. - * + * * It may be stored in an external resource library or it may be * carried in a resource group. An overlay is similar to a page in * that it defines its own environment and carries the same data objects. diff --git a/src/java/org/apache/fop/render/afp/modca/PageDescriptor.java b/src/java/org/apache/fop/render/afp/modca/PageDescriptor.java index b144187fe..afaabfaba 100644 --- a/src/java/org/apache/fop/render/afp/modca/PageDescriptor.java +++ b/src/java/org/apache/fop/render/afp/modca/PageDescriptor.java @@ -55,14 +55,14 @@ public class PageDescriptor extends AbstractDescriptor { data[3] = (byte) 0xD3; data[4] = (byte) 0xA6; data[5] = (byte) 0xAF; - - data[6] = 0x00; // Flags - data[7] = 0x00; // Reserved + + data[6] = 0x00; // Flags + data[7] = 0x00; // Reserved data[8] = 0x00; // Reserved - - data[9] = 0x00; // XpgBase = 10 inches - data[10] = 0x00; // YpgBase = 10 inches - + + data[9] = 0x00; // XpgBase = 10 inches + data[10] = 0x00; // YpgBase = 10 inches + // XpgUnits byte[] xdpi = BinaryUtils.convert(widthRes * 10, 2); data[11] = xdpi[0]; @@ -72,7 +72,7 @@ public class PageDescriptor extends AbstractDescriptor { byte[] ydpi = BinaryUtils.convert(heightRes * 10, 2); data[13] = ydpi[0]; data[14] = ydpi[1]; - + // XpgSize byte[] x = BinaryUtils.convert(width, 3); data[15] = x[0]; diff --git a/src/java/org/apache/fop/render/afp/tools/BinaryUtils.java b/src/java/org/apache/fop/render/afp/tools/BinaryUtils.java index dd21a35cf..31ba45bcf 100644 --- a/src/java/org/apache/fop/render/afp/tools/BinaryUtils.java +++ b/src/java/org/apache/fop/render/afp/tools/BinaryUtils.java @@ -50,7 +50,7 @@ public final class BinaryUtils { size++; } } - return convert(buf.toString()); + return convert(buf.toString()); } /** @@ -92,7 +92,7 @@ public final class BinaryUtils { } else { throw new IllegalArgumentException("Bad hexadecimal digit"); } - + if ((c2 >= '0') && (c2 <= '9')) { b += (c2 - '0'); } else if ((c2 >= 'a') && (c2 <= 'f')) { diff --git a/src/java/org/apache/fop/render/afp/tools/StructuredFieldReader.java b/src/java/org/apache/fop/render/afp/tools/StructuredFieldReader.java index 433e600f9..1939d2dda 100644 --- a/src/java/org/apache/fop/render/afp/tools/StructuredFieldReader.java +++ b/src/java/org/apache/fop/render/afp/tools/StructuredFieldReader.java @@ -110,7 +110,7 @@ public class StructuredFieldReader { length[0] = bufferData[b]; length[1] = bufferData[a]; - int reclength = ((length[0] & 0xFF) << 8) + int reclength = ((length[0] & 0xFF) << 8) + (length[1] & 0xFF) - identifier.length - 2; byte[] retval = new byte[reclength]; diff --git a/src/java/org/apache/fop/render/awt/AWTRenderer.java b/src/java/org/apache/fop/render/awt/AWTRenderer.java index 4e24a7799..5b4c6b13a 100644 --- a/src/java/org/apache/fop/render/awt/AWTRenderer.java +++ b/src/java/org/apache/fop/render/awt/AWTRenderer.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,17 +67,17 @@ public class AWTRenderer extends Java2DRenderer implements Pageable { private boolean previewAsMainWindow; /** - * 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; /** - * Will be notified when rendering progresses + * Will be notified when rendering progresses */ protected StatusListener statusListener = null; - + /** * Creates a new AWTRenderer instance. */ @@ -98,7 +98,7 @@ public class AWTRenderer extends Java2DRenderer implements Pageable { public void setUserAgent(FOUserAgent foUserAgent) { super.setUserAgent(foUserAgent); if (dialogDisplay) { - setStatusListener(PreviewDialog.createPreviewDialog(userAgent, this.renderable, + setStatusListener(PreviewDialog.createPreviewDialog(userAgent, this.renderable, this.previewAsMainWindow)); } } @@ -111,7 +111,7 @@ public class AWTRenderer extends Java2DRenderer implements Pageable { public void setRenderable(Renderable renderable) { this.renderable = renderable; } - + /** * Sets whether the preview dialog should be created and displayed when * the rendering is finished. @@ -121,7 +121,7 @@ public class AWTRenderer extends Java2DRenderer implements Pageable { dialogDisplay = show; } - /** + /** * {@inheritDoc} */ public void renderPage(PageViewport pageViewport) throws IOException { @@ -164,15 +164,15 @@ public class AWTRenderer 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 lanscape mode // and swap the width and height values in the paper format if (width > height) { diff --git a/src/java/org/apache/fop/render/awt/AWTRendererMaker.java b/src/java/org/apache/fop/render/awt/AWTRendererMaker.java index bca4c0817..983b42e0c 100644 --- a/src/java/org/apache/fop/render/awt/AWTRendererMaker.java +++ b/src/java/org/apache/fop/render/awt/AWTRendererMaker.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,8 +30,8 @@ import org.apache.fop.render.Renderer; public class AWTRendererMaker extends AbstractRendererMaker { private static final String[] MIMES = new String[] {MimeConstants.MIME_FOP_AWT_PREVIEW}; - - + + /** {@inheritDoc} */ public Renderer makeRenderer(FOUserAgent ua) { return new AWTRenderer(); diff --git a/src/java/org/apache/fop/render/awt/viewer/Command.java b/src/java/org/apache/fop/render/awt/viewer/Command.java index a56527516..ef6559a11 100644 --- a/src/java/org/apache/fop/render/awt/viewer/Command.java +++ b/src/java/org/apache/fop/render/awt/viewer/Command.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 diff --git a/src/java/org/apache/fop/render/awt/viewer/GoToPageDialog.java b/src/java/org/apache/fop/render/awt/viewer/GoToPageDialog.java index 376280159..0ff71be67 100644 --- a/src/java/org/apache/fop/render/awt/viewer/GoToPageDialog.java +++ b/src/java/org/apache/fop/render/awt/viewer/GoToPageDialog.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; import java.awt.Dimension; @@ -42,7 +42,7 @@ import java.awt.event.ActionListener; * Stanislav Gorkhover: Stanislav.Gorkhover@jCatalog.com */ public class GoToPageDialog extends JDialog { - + private JTextField pageNumberField; private int pageNumber = -1; diff --git a/src/java/org/apache/fop/render/awt/viewer/ImageProxyPanel.java b/src/java/org/apache/fop/render/awt/viewer/ImageProxyPanel.java index cc00244fc..a96d73a46 100644 --- a/src/java/org/apache/fop/render/awt/viewer/ImageProxyPanel.java +++ b/src/java/org/apache/fop/render/awt/viewer/ImageProxyPanel.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. @@ -129,7 +129,7 @@ public class ImageProxyPanel extends JPanel { int x = (getWidth() - image.getWidth()) / 2; int y = (getHeight() - image.getHeight()) / 2; - + graphics.drawImage(image, x, y, image.getWidth(), image.getHeight(), null); } catch (FOPException fopEx) { fopEx.printStackTrace(); diff --git a/src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java b/src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java index ee220d629..7c4d66689 100644 --- a/src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java +++ b/src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java @@ -77,7 +77,7 @@ public class PreviewDialog extends JFrame implements StatusListener { /** The FOUserAgent associated with this window */ 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; @@ -253,14 +253,14 @@ public class PreviewDialog extends JFrame implements StatusListener { new Insets(0, 0, 0, 0), 0, 0)); getContentPane().add(statusBar, BorderLayout.SOUTH); } - + /** - * Creates and initialize the AWT Viewer main window. + * Creates and initialize the AWT Viewer main window. * @param foUserAgent the FO user agent * @param renderable the target for the rendering * @return the newly initialized preview dialog */ - public static PreviewDialog createPreviewDialog(FOUserAgent foUserAgent, + public static PreviewDialog createPreviewDialog(FOUserAgent foUserAgent, Renderable renderable, boolean asMainWindow) { PreviewDialog frame = new PreviewDialog(foUserAgent, renderable); @@ -295,7 +295,7 @@ public class PreviewDialog extends JFrame implements StatusListener { public PreviewDialog(FOUserAgent foUserAgent) { this(foUserAgent, null); } - + /** * Creates a new menubar to be shown in this window. * @return the newly created menubar @@ -454,7 +454,7 @@ public class PreviewDialog extends JFrame implements StatusListener { setStatus(translator.getString("Status.Show")); previewPanel.reload(); } - + /** * Changes the current visible page * @param number the page number to go to @@ -541,7 +541,7 @@ public class PreviewDialog extends JFrame implements StatusListener { fopEx.printStackTrace(); } } - + public void setScaleToFitWidth() { try { setScale(previewPanel.getScaleToFitWidth() * 100); diff --git a/src/java/org/apache/fop/render/awt/viewer/PreviewPanel.java b/src/java/org/apache/fop/render/awt/viewer/PreviewPanel.java index 734dc90dd..05e03fda0 100644 --- a/src/java/org/apache/fop/render/awt/viewer/PreviewPanel.java +++ b/src/java/org/apache/fop/render/awt/viewer/PreviewPanel.java @@ -51,7 +51,7 @@ import org.apache.fop.render.awt.AWTRenderer; *

      Use PreviewPanel when you want to embed a preview in your own application * with your own controls. Use PreviewDialog when you want to use the standard * Fop controls. - *

      + *

      *

      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.

      *

      For example: *

      -     *    org.apache.fop.area.CTM ctm = 
      +     *    org.apache.fop.area.CTM ctm =
            *          new org.apache.fop.area.CTM(1.0, 0.0, 0.0, 1.0, 1000.0, 1000.0);
            *    String pdfMatrix =  org.apache.fop.render.pdf.CTMHelper.toPDFString(ctm);
            * 
      @@ -58,7 +58,7 @@ public final class CTMHelper { } /** - *

      Converts the AffineTransform instance to a string for use in the PDFRenderer + *

      Converts the AffineTransform instance to a string for use in the PDFRenderer * cm operations.

      * * @param transform The matrix to convert. @@ -83,21 +83,21 @@ public final class CTMHelper { } private static String constructPDFArray(double[] matrix) { - return PDFNumber.doubleOut(matrix[0], 8) + " " - + PDFNumber.doubleOut(matrix[1], 8) + " " - + PDFNumber.doubleOut(matrix[2], 8) + " " - + PDFNumber.doubleOut(matrix[3], 8) + " " - + PDFNumber.doubleOut(matrix[4], 8) + " " + return PDFNumber.doubleOut(matrix[0], 8) + " " + + PDFNumber.doubleOut(matrix[1], 8) + " " + + PDFNumber.doubleOut(matrix[2], 8) + " " + + PDFNumber.doubleOut(matrix[3], 8) + " " + + PDFNumber.doubleOut(matrix[4], 8) + " " + PDFNumber.doubleOut(matrix[5], 8); } - + /** *

      Creates a new CTM based in the sourceMatrix.

      *

      For example: *

      -     *    org.apache.fop.area.CTM inCTM = 
      +     *    org.apache.fop.area.CTM inCTM =
            *          new org.apache.fop.area.CTM(1.0, 0.0, 0.0, 1.0, 1000.0, 1000.0);
      -     *    org.apache.fop.area.CTM outCTM = 
      +     *    org.apache.fop.area.CTM outCTM =
            *          org.apache.fop.render.pdf.CTMHelper.toPDFCTM(ctm);
            * 
      * will return a new CTM where a == 1.0, b == 0.0, c == 0.0, d == 1.0, e == 1.0 and f == 1.0. @@ -121,7 +121,7 @@ public final class CTMHelper { *

      Creates an array of six doubles from the source CTM.

      *

      For example: *

      -     *    org.apache.fop.area.CTM inCTM = 
      +     *    org.apache.fop.area.CTM inCTM =
            *          new org.apache.fop.area.CTM(1.0, 0.0, 0.0, 1.0, 1000.0, 1000.0);
            *    double matrix[] = org.apache.fop.render.pdf.CTMHelper.toPDFArray(ctm);
            * 
      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 { *

    • fop-rgb-icc(r,g,b,cs,cs-src,[num]+) (r/g/b: 0..1, num: 0..1)
    • *
    • cmyk(c,m,y,k) (0..1)
    • *
    - * - * @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(); //> - + private static ResourceBundle handleGetXMLBundle(String base, String locale, boolean loadBase, final ClassLoader loader) { XMLResourceBundle bundle = null; @@ -224,8 +224,8 @@ public class XMLResourceBundle extends ResourceBundle { } loaderCache.put(bundleName, loadBase ? MISSINGBASE : MISSING); return null; - } - + } + private void setLocale(String name) { String language = "", country = "", variant = ""; if (name.length() > 1) { @@ -248,7 +248,7 @@ public class XMLResourceBundle extends ResourceBundle { } this.locale = new Locale(language, country, variant); } - + private static String strip(String name) { int index = name.lastIndexOf('_'); if (index != -1) { @@ -256,16 +256,16 @@ public class XMLResourceBundle extends ResourceBundle { } return null; } - + private Enumeration getLocalKeys() { return (Enumeration)resources.propertyNames(); } - + /** {@inheritDoc} */ public Locale getLocale() { return this.locale; } - + /** {@inheritDoc} */ public Enumeration getKeys() { if (parent == null) { @@ -327,10 +327,10 @@ public class XMLResourceBundle extends ResourceBundle { } private class CatalogueHandler extends DefaultHandler { - + private static final String CATALOGUE = "catalogue"; private static final String MESSAGE = "message"; - + private StringBuffer valueBuffer = new StringBuffer(); private Stack elementStack = new Stack(); private String currentKey = null; @@ -338,13 +338,13 @@ public class XMLResourceBundle extends ResourceBundle { private boolean isOwnNamespace(String uri) { return ("".equals(uri)); } - + private QName getParentElementName() { return (QName)elementStack.peek(); } - + /** {@inheritDoc} */ - public void startElement(String uri, String localName, String qName, + public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException { super.startElement(uri, localName, qName, atts); QName elementName = new QName(uri, qName); @@ -386,13 +386,13 @@ public class XMLResourceBundle extends ResourceBundle { } this.valueBuffer.setLength(0); } - + /** {@inheritDoc} */ public void characters(char[] ch, int start, int length) throws SAXException { super.characters(ch, start, length); valueBuffer.append(ch, start, length); } - + } - + } diff --git a/src/java/org/apache/fop/util/text/AdvancedMessageFormat.java b/src/java/org/apache/fop/util/text/AdvancedMessageFormat.java index a2169156a..8c26bd622 100644 --- a/src/java/org/apache/fop/util/text/AdvancedMessageFormat.java +++ b/src/java/org/apache/fop/util/text/AdvancedMessageFormat.java @@ -45,13 +45,13 @@ public class AdvancedMessageFormat { /** Regex that matches "," but not "\," (escaped comma) */ static final Pattern COMMA_SEPARATOR_REGEX = Pattern.compile("(?toString() method unless there is an @@ -363,18 +363,18 @@ public class AdvancedMessageFormat { } } } - + private static class FunctionPart implements Part { - + private Function function; - + public FunctionPart(String functionName) { this.function = getFunction(functionName); if (this.function == null) { throw new IllegalArgumentException("Unknown function: " + functionName); } } - + public void write(StringBuffer sb, Map params) { Object obj = this.function.evaluate(params); formatObject(obj, sb); @@ -384,28 +384,28 @@ public class AdvancedMessageFormat { Object obj = this.function.evaluate(params); return obj != null; } - + /** {@inheritDoc} */ public String toString() { return "{#" + this.function.getName() + "}"; } } - + private static class CompositePart implements Part { - + protected List parts = new java.util.ArrayList(); private boolean conditional; private boolean hasSections = false; - + public CompositePart(boolean conditional) { this.conditional = conditional; } - + private CompositePart(List parts) { this.parts.addAll(parts); this.conditional = true; } - + public void addChild(Part part) { if (part == null) { throw new NullPointerException("part must not be null"); @@ -417,7 +417,7 @@ public class AdvancedMessageFormat { this.parts.add(part); } } - + public void newSection() { if (!hasSections) { List p = this.parts; @@ -428,7 +428,7 @@ public class AdvancedMessageFormat { } this.parts.add(new CompositePart(true)); } - + public void write(StringBuffer sb, Map params) { if (hasSections) { Iterator iter = this.parts.iterator(); @@ -473,14 +473,14 @@ public class AdvancedMessageFormat { return true; } } - + /** {@inheritDoc} */ public String toString() { return this.parts.toString(); } } - - + + static String unescapeComma(String string) { return string.replaceAll("\\\\,", ","); } diff --git a/src/java/org/apache/fop/util/text/ChoiceFieldPart.java b/src/java/org/apache/fop/util/text/ChoiceFieldPart.java index df457a02b..a6a949815 100644 --- a/src/java/org/apache/fop/util/text/ChoiceFieldPart.java +++ b/src/java/org/apache/fop/util/text/ChoiceFieldPart.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,12 +31,12 @@ import org.apache.fop.util.text.AdvancedMessageFormat.PartFactory; * Defines a "choice" field part that works like {@link ChoiceFormat}. */ public class ChoiceFieldPart implements Part { - + private static final Pattern VARIABLE_REGEX = Pattern.compile("\\{([^\\}]+)\\}"); - + private String fieldName; private ChoiceFormat choiceFormat; - + /** * Creates a new choice part. * @param fieldName the field name to work on @@ -72,7 +72,7 @@ public class ChoiceFieldPart implements Part { public String toString() { return "{" + this.fieldName + ",choice, ....}"; } - + /** Factory for ChoiceFieldPart. */ public static class Factory implements PartFactory { @@ -85,7 +85,7 @@ public class ChoiceFieldPart implements Part { public String getFormat() { return "choice"; } - + } } \ No newline at end of file diff --git a/src/java/org/apache/fop/util/text/EqualsFieldPart.java b/src/java/org/apache/fop/util/text/EqualsFieldPart.java index 2114b0d00..02f994332 100644 --- a/src/java/org/apache/fop/util/text/EqualsFieldPart.java +++ b/src/java/org/apache/fop/util/text/EqualsFieldPart.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,9 +30,9 @@ import org.apache.fop.util.text.AdvancedMessageFormat.PartFactory; * {field,equals,new,This is new!,This is old!} */ public class EqualsFieldPart extends IfFieldPart { - + private String equalsValue; - + /** * Creates a new "equals" field part. * @param fieldName the field name @@ -57,7 +57,7 @@ public class EqualsFieldPart extends IfFieldPart { ifValue = AdvancedMessageFormat.unescapeComma(parts[1]); } } - + /** {@inheritDoc} */ protected boolean isTrue(Map params) { Object obj = params.get(fieldName); @@ -72,7 +72,7 @@ public class EqualsFieldPart extends IfFieldPart { public String toString() { return "{" + this.fieldName + ", equals " + this.equalsValue + "}"; } - + /** * Part factory for "equals". */ @@ -87,6 +87,6 @@ public class EqualsFieldPart extends IfFieldPart { public String getFormat() { return "equals"; } - + } } \ No newline at end of file diff --git a/src/java/org/apache/fop/util/text/GlyphNameFieldPart.java b/src/java/org/apache/fop/util/text/GlyphNameFieldPart.java index 5d78cdfad..f0e5bcc32 100644 --- a/src/java/org/apache/fop/util/text/GlyphNameFieldPart.java +++ b/src/java/org/apache/fop/util/text/GlyphNameFieldPart.java @@ -32,7 +32,7 @@ import org.apache.fop.util.text.AdvancedMessageFormat.PartFactory; public class GlyphNameFieldPart implements Part { private String fieldName; - + /** * Creates a new glyph name field part * @param fieldName the field name @@ -40,13 +40,13 @@ public class GlyphNameFieldPart implements Part { public GlyphNameFieldPart(String fieldName) { this.fieldName = fieldName; } - + /** {@inheritDoc} */ public boolean isGenerated(Map params) { Object obj = params.get(fieldName); return obj != null && getGlyphName(obj).length() > 0; } - + private String getGlyphName(Object obj) { if (obj instanceof Character) { return Glyphs.charToGlyphName(((Character)obj).charValue()); @@ -71,7 +71,7 @@ public class GlyphNameFieldPart implements Part { public String toString() { return "{" + this.fieldName + ",glyph-name}"; } - + /** Factory for {@link GlyphNameFieldPart}. */ public static class Factory implements PartFactory { @@ -79,11 +79,11 @@ public class GlyphNameFieldPart implements Part { public Part newPart(String fieldName, String values) { return new GlyphNameFieldPart(fieldName); } - + /** {@inheritDoc} */ public String getFormat() { return "glyph-name"; } - + } } diff --git a/src/java/org/apache/fop/util/text/HexFieldPart.java b/src/java/org/apache/fop/util/text/HexFieldPart.java index 19f47f3d7..6333a8df2 100644 --- a/src/java/org/apache/fop/util/text/HexFieldPart.java +++ b/src/java/org/apache/fop/util/text/HexFieldPart.java @@ -30,7 +30,7 @@ import org.apache.fop.util.text.AdvancedMessageFormat.PartFactory; public class HexFieldPart implements Part { private String fieldName; - + /** * Creates a new hex field part * @param fieldName the field name @@ -38,7 +38,7 @@ public class HexFieldPart implements Part { public HexFieldPart(String fieldName) { this.fieldName = fieldName; } - + /** {@inheritDoc} */ public boolean isGenerated(Map params) { Object obj = params.get(fieldName); @@ -66,7 +66,7 @@ public class HexFieldPart implements Part { public String toString() { return "{" + this.fieldName + ",hex}"; } - + /** Factory for {@link HexFieldPart}. */ public static class Factory implements PartFactory { @@ -74,11 +74,11 @@ public class HexFieldPart implements Part { public Part newPart(String fieldName, String values) { return new HexFieldPart(fieldName); } - + /** {@inheritDoc} */ public String getFormat() { return "hex"; } - + } } diff --git a/src/java/org/apache/fop/util/text/IfFieldPart.java b/src/java/org/apache/fop/util/text/IfFieldPart.java index 31cd8f36c..01fb6b05a 100644 --- a/src/java/org/apache/fop/util/text/IfFieldPart.java +++ b/src/java/org/apache/fop/util/text/IfFieldPart.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,14 +30,14 @@ import org.apache.fop.util.text.AdvancedMessageFormat.PartFactory; * {field,if,Yes,No} */ public class IfFieldPart implements Part { - + /** the field name for the part */ protected String fieldName; /** the value being returned if the field is true */ protected String ifValue; /** the value being returned if the field is false */ protected String elseValue; - + /** * Creates a new "if" field part. * @param fieldName the field name @@ -61,7 +61,7 @@ public class IfFieldPart implements Part { ifValue = AdvancedMessageFormat.unescapeComma(values); } } - + /** {@inheritDoc} */ public void write(StringBuffer sb, Map params) { boolean isTrue = isTrue(params); @@ -91,12 +91,12 @@ public class IfFieldPart implements Part { public boolean isGenerated(Map params) { return isTrue(params) || (elseValue != null); } - + /** {@inheritDoc} */ public String toString() { return "{" + this.fieldName + ", if...}"; } - + /** * Part factory for "if". */ @@ -106,11 +106,11 @@ public class IfFieldPart implements Part { public Part newPart(String fieldName, String values) { return new IfFieldPart(fieldName, values); } - + /** {@inheritDoc} */ public String getFormat() { return "if"; } - + } } \ No newline at end of file diff --git a/src/java/org/apache/fop/util/text/LocatorFormatter.java b/src/java/org/apache/fop/util/text/LocatorFormatter.java index d9532c66d..7818a3cf7 100644 --- a/src/java/org/apache/fop/util/text/LocatorFormatter.java +++ b/src/java/org/apache/fop/util/text/LocatorFormatter.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,5 +38,5 @@ public class LocatorFormatter implements ObjectFormatter { public boolean supportsObject(Object obj) { return obj instanceof Locator; } - + } \ No newline at end of file diff --git a/src/sandbox/org/apache/fop/render/mif/MIFElement.java b/src/sandbox/org/apache/fop/render/mif/MIFElement.java index d7757cc3b..8c749366f 100644 --- a/src/sandbox/org/apache/fop/render/mif/MIFElement.java +++ b/src/sandbox/org/apache/fop/render/mif/MIFElement.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.mif; // Java diff --git a/src/sandbox/org/apache/fop/render/mif/MIFFOEventHandlerMaker.java b/src/sandbox/org/apache/fop/render/mif/MIFFOEventHandlerMaker.java index edf6ffcf6..01357c18d 100644 --- a/src/sandbox/org/apache/fop/render/mif/MIFFOEventHandlerMaker.java +++ b/src/sandbox/org/apache/fop/render/mif/MIFFOEventHandlerMaker.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.AbstractFOEventHandlerMaker; public class MIFFOEventHandlerMaker extends AbstractFOEventHandlerMaker { private static final String[] MIMES = new String[] {MimeConstants.MIME_MIF}; - - + + /** @see org.apache.fop.render.AbstractFOEventHandlerMaker */ public FOEventHandler makeFOEventHandler(FOUserAgent ua, OutputStream out) { return new MIFHandler(ua, out); diff --git a/src/sandbox/org/apache/fop/render/mif/MIFFile.java b/src/sandbox/org/apache/fop/render/mif/MIFFile.java index eccb1df54..131db5c2b 100644 --- a/src/sandbox/org/apache/fop/render/mif/MIFFile.java +++ b/src/sandbox/org/apache/fop/render/mif/MIFFile.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.mif; // Java diff --git a/src/sandbox/org/apache/fop/render/mif/MIFHandler.java b/src/sandbox/org/apache/fop/render/mif/MIFHandler.java index 0349b329a..ca36ab174 100644 --- a/src/sandbox/org/apache/fop/render/mif/MIFHandler.java +++ b/src/sandbox/org/apache/fop/render/mif/MIFHandler.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. @@ -66,7 +66,7 @@ public class MIFHandler extends FOEventHandler { /** the MIFFile instance */ protected MIFFile mifFile; - + /** the OutputStream to write to */ protected OutputStream outStream; @@ -409,25 +409,25 @@ public class MIFHandler extends FOEventHandler { */ public void startFootnote(Footnote footnote) { } - + /** * @see org.apache.fop.fo.FOEventHandler#endFootnote(Footnote) */ public void endFootnote(Footnote footnote) { } - + /** * @see org.apache.fop.fo.FOEventHandler#startFootnoteBody(FootnoteBody) */ public void startFootnoteBody(FootnoteBody body) { } - + /** * @see org.apache.fop.fo.FOEventHandler#endFootnoteBody(FootnoteBody) */ public void endFootnoteBody(FootnoteBody body) { } - + /** * @see org.apache.fop.fo.FOEventHandler#leader(Leader) */ diff --git a/src/sandbox/org/apache/fop/render/mif/PGFElement.java b/src/sandbox/org/apache/fop/render/mif/PGFElement.java index b273f36b3..6aa253ac2 100644 --- a/src/sandbox/org/apache/fop/render/mif/PGFElement.java +++ b/src/sandbox/org/apache/fop/render/mif/PGFElement.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.mif; /** diff --git a/src/sandbox/org/apache/fop/render/mif/RefElement.java b/src/sandbox/org/apache/fop/render/mif/RefElement.java index 1d59a6139..c6b5d0ec5 100644 --- a/src/sandbox/org/apache/fop/render/mif/RefElement.java +++ b/src/sandbox/org/apache/fop/render/mif/RefElement.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.mif; /** diff --git a/src/sandbox/org/apache/fop/render/mif/RulingElement.java b/src/sandbox/org/apache/fop/render/mif/RulingElement.java index 476df0687..2c2765bad 100644 --- a/src/sandbox/org/apache/fop/render/mif/RulingElement.java +++ b/src/sandbox/org/apache/fop/render/mif/RulingElement.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.mif; public class RulingElement extends RefElement { diff --git a/src/sandbox/org/apache/fop/render/svg/SVGRenderer.java b/src/sandbox/org/apache/fop/render/svg/SVGRenderer.java index 8b6f66b6c..d65555355 100644 --- a/src/sandbox/org/apache/fop/render/svg/SVGRenderer.java +++ b/src/sandbox/org/apache/fop/render/svg/SVGRenderer.java @@ -59,14 +59,14 @@ public class SVGRenderer extends Java2DRenderer { private static final String SVG_FILE_EXTENSION = "svg"; private OutputStream firstOutputStream; - + private Document document; - + private SVGGraphics2D svgGenerator; /** Helper class for generating multiple files */ private MultiFileRenderingUtil multiFileUtil; - + /** @see org.apache.fop.render.AbstractRenderer */ public String getMimeType() { return MIME_TYPE; @@ -79,7 +79,7 @@ public class SVGRenderer extends Java2DRenderer { /** @see org.apache.fop.render.Renderer#startRenderer(java.io.OutputStream) */ public void startRenderer(OutputStream outputStream) throws IOException { this.firstOutputStream = outputStream; - this.multiFileUtil = new MultiFileRenderingUtil(SVG_FILE_EXTENSION, + this.multiFileUtil = new MultiFileRenderingUtil(SVG_FILE_EXTENSION, getUserAgent().getOutputFile()); super.startRenderer(this.firstOutputStream); } @@ -95,11 +95,11 @@ public class SVGRenderer extends Java2DRenderer { // Create an instance of org.w3c.dom.Document this.document = domImpl.createDocument(null, "svg", null); - // Create an SVGGeneratorContext to customize SVG generation + // Create an SVGGeneratorContext to customize SVG generation SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(this.document); ctx.setComment("Generated by " + userAgent.getProducer() + " with Batik SVG Generator"); ctx.setEmbeddedFontsOn(true); - + // Create an instance of the SVG Generator this.svgGenerator = new SVGGraphics2D(ctx, true); Rectangle2D viewArea = pageViewport.getViewArea(); @@ -111,15 +111,15 @@ public class SVGRenderer extends Java2DRenderer { this.state = new Java2DGraphicsState(this.svgGenerator, this.fontInfo, at); try { //super.renderPage(pageViewport); - renderPageAreas(pageViewport.getPage()); + renderPageAreas(pageViewport.getPage()); } finally { this.state = null; } writeSVGFile(pageViewport.getPageIndex()); - + this.svgGenerator = null; this.document = null; - + } /** @see org.apache.fop.render.Renderer#stopRenderer() */ @@ -168,5 +168,5 @@ public class SVGRenderer extends Java2DRenderer { } } - + } diff --git a/src/sandbox/org/apache/fop/render/svg/SVGRendererMaker.java b/src/sandbox/org/apache/fop/render/svg/SVGRendererMaker.java index 600c378d8..71810495b 100644 --- a/src/sandbox/org/apache/fop/render/svg/SVGRendererMaker.java +++ b/src/sandbox/org/apache/fop/render/svg/SVGRendererMaker.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,8 +30,8 @@ import org.apache.fop.render.Renderer; public class SVGRendererMaker extends AbstractRendererMaker { private static final String[] MIMES = new String[] {MimeConstants.MIME_SVG}; - - + + /**@see org.apache.fop.render.AbstractRendererMaker */ public Renderer makeRenderer(FOUserAgent ua) { return new SVGRenderer(); diff --git a/src/sandbox/org/apache/fop/render/svg/SVGSVGHandler.java b/src/sandbox/org/apache/fop/render/svg/SVGSVGHandler.java index f59d3af18..702f081ac 100644 --- a/src/sandbox/org/apache/fop/render/svg/SVGSVGHandler.java +++ b/src/sandbox/org/apache/fop/render/svg/SVGSVGHandler.java @@ -35,7 +35,7 @@ import org.w3c.dom.svg.SVGSVGElement; public class SVGSVGHandler implements XMLHandler, SVGRendererContextConstants { /** @see org.apache.fop.render.XMLHandler */ - public void handleXML(RendererContext context, + public void handleXML(RendererContext context, org.w3c.dom.Document doc, String ns) throws Exception { if (getNamespace().equals(ns)) { if (!(doc instanceof SVGDocument)) { diff --git a/test/java/org/apache/fop/AbstractBasicTranscoderTestCase.java b/test/java/org/apache/fop/AbstractBasicTranscoderTestCase.java index a198518ac..4a65b77b5 100644 --- a/test/java/org/apache/fop/AbstractBasicTranscoderTestCase.java +++ b/test/java/org/apache/fop/AbstractBasicTranscoderTestCase.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; import java.io.File; @@ -28,7 +28,7 @@ import org.apache.batik.transcoder.TranscoderOutput; import org.apache.commons.io.output.ByteArrayOutputStream; /** - * Basic runtime test for FOP's transcoders. It is used to verify that + * Basic runtime test for FOP's transcoders. It is used to verify that * nothing obvious is broken after compiling. */ public abstract class AbstractBasicTranscoderTestCase extends AbstractFOPTestCase { @@ -47,25 +47,25 @@ public abstract class AbstractBasicTranscoderTestCase extends AbstractFOPTestCas protected abstract Transcoder createTranscoder(); /** - * Runs the PDF transcoder as if it were called by Batik's rasterizer. + * Runs the PDF transcoder as if it were called by Batik's rasterizer. * Without special configuration stuff. * @throws Exception if a problem occurs */ public void testGenericPDFTranscoder() throws Exception { //Create transcoder Transcoder transcoder = createTranscoder(); - + //Setup input File svgFile = new File(getBaseDir(), "test/resources/fop/svg/text.svg"); InputStream in = new java.io.FileInputStream(svgFile); try { TranscoderInput input = new TranscoderInput(in); - + //Setup output ByteArrayOutputStream out = new ByteArrayOutputStream(); try { TranscoderOutput output = new TranscoderOutput(out); - + //Do the transformation transcoder.transcode(input, output); } finally { diff --git a/test/java/org/apache/fop/AbstractFOPTestCase.java b/test/java/org/apache/fop/AbstractFOPTestCase.java index 3df52fc4c..7d6fee984 100644 --- a/test/java/org/apache/fop/AbstractFOPTestCase.java +++ b/test/java/org/apache/fop/AbstractFOPTestCase.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; import java.io.File; diff --git a/test/java/org/apache/fop/BasicDriverTestCase.java b/test/java/org/apache/fop/BasicDriverTestCase.java index 34f1002e0..0ae6da048 100644 --- a/test/java/org/apache/fop/BasicDriverTestCase.java +++ b/test/java/org/apache/fop/BasicDriverTestCase.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; import java.io.File; @@ -36,7 +36,7 @@ import org.apache.fop.apps.MimeConstants; import org.apache.fop.cli.InputHandler; /** - * Basic runtime test for the old Fop class. It is used to verify that + * Basic runtime test for the old Fop class. It is used to verify that * nothing obvious is broken after compiling. */ public class BasicDriverTestCase extends AbstractFOPTestCase { @@ -59,13 +59,13 @@ public class BasicDriverTestCase extends AbstractFOPTestCase { File foFile = new File(getBaseDir(), "test/xml/bugtests/block.fo"); ByteArrayOutputStream baout = new ByteArrayOutputStream(); Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, baout); - + TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(); //Identity transf. Source src = new StreamSource(foFile); Result res = new SAXResult(fop.getDefaultHandler()); transformer.transform(src, res); - + assertTrue("Generated PDF has zero length", baout.size() > 0); } @@ -78,13 +78,13 @@ public class BasicDriverTestCase extends AbstractFOPTestCase { File foFile = new File(getBaseDir(), "test/xml/bugtests/block.fo"); ByteArrayOutputStream baout = new ByteArrayOutputStream(); Fop fop = fopFactory.newFop(MimeConstants.MIME_POSTSCRIPT, foUserAgent, baout); - + TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(); //Identity transf. Source src = new StreamSource(foFile); Result res = new SAXResult(fop.getDefaultHandler()); transformer.transform(src, res); - + assertTrue("Generated PostScript has zero length", baout.size() > 0); } @@ -97,13 +97,13 @@ public class BasicDriverTestCase extends AbstractFOPTestCase { File foFile = new File(getBaseDir(), "test/xml/bugtests/block.fo"); ByteArrayOutputStream baout = new ByteArrayOutputStream(); Fop fop = fopFactory.newFop(MimeConstants.MIME_RTF, foUserAgent, baout); - + TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(); //Identity transf. Source src = new StreamSource(foFile); Result res = new SAXResult(fop.getDefaultHandler()); transformer.transform(src, res); - + assertTrue("Generated RTF has zero length", baout.size() > 0); } @@ -116,10 +116,10 @@ public class BasicDriverTestCase extends AbstractFOPTestCase { File xmlFile = new File(getBaseDir(), "test/xml/1.xml"); File xsltFile = new File(getBaseDir(), "test/xsl/doc.xsl"); ByteArrayOutputStream baout = new ByteArrayOutputStream(); - + InputHandler handler = new InputHandler(xmlFile, xsltFile, null); handler.renderTo(foUserAgent, MimeConstants.MIME_PDF, baout); - + assertTrue("Generated PDF has zero length", baout.size() > 0); } diff --git a/test/java/org/apache/fop/BasicDriverTestSuite.java b/test/java/org/apache/fop/BasicDriverTestSuite.java index 62bd262a8..92fb07a8d 100644 --- a/test/java/org/apache/fop/BasicDriverTestSuite.java +++ b/test/java/org/apache/fop/BasicDriverTestSuite.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; import junit.framework.Test; diff --git a/test/java/org/apache/fop/BasicPDFTranscoderTestCase.java b/test/java/org/apache/fop/BasicPDFTranscoderTestCase.java index 9dba9abdf..44668d004 100644 --- a/test/java/org/apache/fop/BasicPDFTranscoderTestCase.java +++ b/test/java/org/apache/fop/BasicPDFTranscoderTestCase.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,14 +16,14 @@ */ /* $Id$ */ - + package org.apache.fop; import org.apache.batik.transcoder.Transcoder; import org.apache.fop.svg.PDFTranscoder; /** - * Basic runtime test for the PDF transcoder. It is used to verify that + * Basic runtime test for the PDF transcoder. It is used to verify that * nothing obvious is broken after compiling. */ public class BasicPDFTranscoderTestCase extends AbstractBasicTranscoderTestCase { diff --git a/test/java/org/apache/fop/BasicPSTranscoderTestCase.java b/test/java/org/apache/fop/BasicPSTranscoderTestCase.java index c66b31874..69be94b60 100644 --- a/test/java/org/apache/fop/BasicPSTranscoderTestCase.java +++ b/test/java/org/apache/fop/BasicPSTranscoderTestCase.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,14 +16,14 @@ */ /* $Id$ */ - + package org.apache.fop; import org.apache.batik.transcoder.Transcoder; import org.apache.fop.render.ps.PSTranscoder; /** - * Basic runtime test for the PS transcoder. It is used to verify that + * Basic runtime test for the PS transcoder. It is used to verify that * nothing obvious is broken after compiling. */ public class BasicPSTranscoderTestCase extends AbstractBasicTranscoderTestCase { diff --git a/test/java/org/apache/fop/BasicTranscoderTestSuite.java b/test/java/org/apache/fop/BasicTranscoderTestSuite.java index 8c0103cdc..ed70afd82 100644 --- a/test/java/org/apache/fop/BasicTranscoderTestSuite.java +++ b/test/java/org/apache/fop/BasicTranscoderTestSuite.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; import junit.framework.Test; diff --git a/test/java/org/apache/fop/DebugHelper.java b/test/java/org/apache/fop/DebugHelper.java index ee51b07b6..6705d2f56 100644 --- a/test/java/org/apache/fop/DebugHelper.java +++ b/test/java/org/apache/fop/DebugHelper.java @@ -28,9 +28,9 @@ import org.apache.fop.logging.LoggingElementListObserver; public class DebugHelper { private static boolean elObserversRegistered = false; - + /** - * Registers the default element list observers used for debugging. + * Registers the default element list observers used for debugging. */ public static void registerStandardElementListObservers() { if (!elObserversRegistered) { @@ -38,5 +38,5 @@ public class DebugHelper { elObserversRegistered = true; } } - + } diff --git a/test/java/org/apache/fop/DigestFilterTestCase.java b/test/java/org/apache/fop/DigestFilterTestCase.java index b2296c49a..47fa34839 100644 --- a/test/java/org/apache/fop/DigestFilterTestCase.java +++ b/test/java/org/apache/fop/DigestFilterTestCase.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/test/java/org/apache/fop/GenericFOPTestCase.java b/test/java/org/apache/fop/GenericFOPTestCase.java index f09ae2611..26053cdad 100644 --- a/test/java/org/apache/fop/GenericFOPTestCase.java +++ b/test/java/org/apache/fop/GenericFOPTestCase.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,13 +44,13 @@ import org.xml.sax.InputSource; * a MD5 for the source to help diferentiating failures caused by causal * source modification from failures caused by regression, a renderer (only * PDF currently supported) and a MD5 for the result. - * + * */ public final class GenericFOPTestCase extends TestCase { // configure fopFactory as desired private FopFactory fopFactory = FopFactory.newInstance(); - + protected SAXParserFactory parserFactory; public static Test suite() { diff --git a/test/java/org/apache/fop/KnuthAlgorithmTestCase.java b/test/java/org/apache/fop/KnuthAlgorithmTestCase.java index 44c8d1961..5a5523642 100644 --- a/test/java/org/apache/fop/KnuthAlgorithmTestCase.java +++ b/test/java/org/apache/fop/KnuthAlgorithmTestCase.java @@ -54,14 +54,14 @@ public class KnuthAlgorithmTestCase extends TestCase { seq.add(new KnuthGlue(-5000, 0, 0, null, true)); } } - + seq.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false, null, false)); seq.add(new KnuthGlue(0, Integer.MAX_VALUE, 0, null, false)); seq.add(new KnuthPenalty(0, -KnuthPenalty.INFINITE, false, null, false)); ElementListObserver.observe(seq, "test", null); return seq; } - + /** * Tests a special condition where a negative-length glue occurs directly after a break * possibility. @@ -77,18 +77,18 @@ public class KnuthAlgorithmTestCase extends TestCase { assertEquals(5000, parts[0].difference); assertEquals(5000, parts[1].difference); } - + private class Part { private int difference; private double ratio; private int position; } - + private class MyBreakingAlgorithm extends BreakingAlgorithm { private List parts = new java.util.ArrayList(); - - public MyBreakingAlgorithm(int align, int alignLast, boolean first, + + public MyBreakingAlgorithm(int align, int alignLast, boolean first, boolean partOverflowRecovery, int maxFlagCount) { super(align, alignLast, first, partOverflowRecovery, maxFlagCount); } @@ -96,7 +96,7 @@ public class KnuthAlgorithmTestCase extends TestCase { public Part[] getParts() { return (Part[])parts.toArray(new Part[parts.size()]); } - + public void updateData1(int total, double demerits) { //nop } @@ -111,7 +111,7 @@ public class KnuthAlgorithmTestCase extends TestCase { // spaces always have enough shrink difference = 0; } else if (ratio <= 1 && bestActiveNode.line < total) { - // not-last page break with a positive difference smaller than the available + // not-last page break with a positive difference smaller than the available // stretch: spaces can stretch to fill the whole difference difference = 0; } else if (ratio > 1) { @@ -138,7 +138,7 @@ public class KnuthAlgorithmTestCase extends TestCase { //nop return 0; } - + } - + } diff --git a/test/java/org/apache/fop/StandardTestSuite.java b/test/java/org/apache/fop/StandardTestSuite.java index 6399d3b09..c20683912 100644 --- a/test/java/org/apache/fop/StandardTestSuite.java +++ b/test/java/org/apache/fop/StandardTestSuite.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; import junit.framework.Test; diff --git a/test/java/org/apache/fop/URIResolutionTestCase.java b/test/java/org/apache/fop/URIResolutionTestCase.java index 106ec0a2c..8b8b42ad6 100644 --- a/test/java/org/apache/fop/URIResolutionTestCase.java +++ b/test/java/org/apache/fop/URIResolutionTestCase.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; import java.io.File; @@ -57,12 +57,12 @@ public class URIResolutionTestCase extends AbstractFOPTestCase { // configure fopFactory as desired private FopFactory fopFactory = FopFactory.newInstance(); - - private SAXTransformerFactory tfactory + + private SAXTransformerFactory tfactory = (SAXTransformerFactory)SAXTransformerFactory.newInstance(); private File backupDir = new File(getBaseDir(), "build/test-results"); - + /** @see junit.framework.TestCase#TestCase(String) */ public URIResolutionTestCase(String name) { super(name); @@ -75,7 +75,7 @@ public class URIResolutionTestCase extends AbstractFOPTestCase { public void testFO1a() throws Exception { innerTestFO1(false); } - + /** * Test custom URI resolution with a hand-written URIResolver. * @throws Exception if anything fails @@ -83,25 +83,25 @@ public class URIResolutionTestCase extends AbstractFOPTestCase { public void testFO1b() throws Exception { innerTestFO1(true); } - + private void innerTestFO1(boolean withStream) throws Exception { FOUserAgent ua = fopFactory.newFOUserAgent(); File foFile = new File(getBaseDir(), "test/xml/uri-resolution1.fo"); - - MyURIResolver resolver = new MyURIResolver(withStream); + + MyURIResolver resolver = new MyURIResolver(withStream); ua.setURIResolver(resolver); ua.setBaseURL(foFile.getParentFile().toURL().toString()); Document doc = createAreaTree(foFile, ua); - + //Check how many times the resolver was consulted assertEquals("Expected resolver to do 1 successful URI resolution", 1, resolver.successCount); assertEquals("Expected resolver to do 0 failed URI resolution", 0, resolver.failureCount); //Additional XPath checking on the area tree - assertEquals("viewport for external-graphic is missing", + assertEquals("viewport for external-graphic is missing", "true", evalXPath(doc, "boolean(//flow/block[1]/lineArea/viewport)")); assertEquals("46080", evalXPath(doc, "//flow/block[1]/lineArea/viewport/@ipd")); assertEquals("46080", evalXPath(doc, "//flow/block[1]/lineArea/viewport/@bpd")); @@ -114,9 +114,9 @@ public class URIResolutionTestCase extends AbstractFOPTestCase { public void DISABLEDtestFO2() throws Exception { //TODO This will only work when we can do URI resolution inside Batik! File foFile = new File(getBaseDir(), "test/xml/uri-resolution2.fo"); - + FOUserAgent ua = fopFactory.newFOUserAgent(); - MyURIResolver resolver = new MyURIResolver(false); + MyURIResolver resolver = new MyURIResolver(false); ua.setURIResolver(resolver); ua.setBaseURL(foFile.getParentFile().toURL().toString()); @@ -128,7 +128,7 @@ public class URIResolutionTestCase extends AbstractFOPTestCase { Source src = new StreamSource(foFile); Result res = new SAXResult(fop.getDefaultHandler()); transformer.transform(src, res); - + OutputStream out = new java.io.FileOutputStream( new File(backupDir, foFile.getName() + ".pdf")); try { @@ -136,7 +136,7 @@ public class URIResolutionTestCase extends AbstractFOPTestCase { } finally { IOUtils.closeQuietly(out); } - + //Check how many times the resolver was consulted assertEquals("Expected resolver to do 1 successful URI resolution", 1, resolver.successCount); @@ -147,7 +147,7 @@ public class URIResolutionTestCase extends AbstractFOPTestCase { assertTrue("Generated PDF has zero length", baout.size() > 0); } - private Document createAreaTree(File fo, FOUserAgent ua) + private Document createAreaTree(File fo, FOUserAgent ua) throws TransformerException, FOPException { DOMResult domres = new DOMResult(); //Setup Transformer to convert the area tree to a DOM @@ -158,19 +158,19 @@ public class URIResolutionTestCase extends AbstractFOPTestCase { atrenderer.setUserAgent(ua); atrenderer.setContentHandler(athandler); ua.setRendererOverride(atrenderer); - + Fop fop = fopFactory.newFop(ua); Transformer transformer = tfactory.newTransformer(); //Identity transf. Source src = new StreamSource(fo); Result res = new SAXResult(fop.getDefaultHandler()); transformer.transform(src, res); - + Document doc = (Document)domres.getNode(); saveAreaTreeXML(doc, new File(backupDir, fo.getName() + ".at.xml")); return doc; } - + private String evalXPath(Document doc, String xpath) { XObject res; try { @@ -193,19 +193,19 @@ public class URIResolutionTestCase extends AbstractFOPTestCase { Result res = new StreamResult(target); transformer.transform(src, res); } - + private class MyURIResolver implements URIResolver { private static final String PREFIX = "funky:"; - - private boolean withStream; + + private boolean withStream; private int successCount = 0; private int failureCount = 0; - + public MyURIResolver(boolean withStream) { this.withStream = withStream; } - + /** * @see javax.xml.transform.URIResolver#resolve(java.lang.String, java.lang.String) */ @@ -235,7 +235,7 @@ public class URIResolutionTestCase extends AbstractFOPTestCase { return null; } } - + } - + } diff --git a/test/java/org/apache/fop/UtilityCodeTestSuite.java b/test/java/org/apache/fop/UtilityCodeTestSuite.java index d2577c251..af467102c 100644 --- a/test/java/org/apache/fop/UtilityCodeTestSuite.java +++ b/test/java/org/apache/fop/UtilityCodeTestSuite.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; import junit.framework.Test; diff --git a/test/java/org/apache/fop/config/BaseConstructiveUserConfigTestCase.java b/test/java/org/apache/fop/config/BaseConstructiveUserConfigTestCase.java index cd1c26f8c..b94c47373 100644 --- a/test/java/org/apache/fop/config/BaseConstructiveUserConfigTestCase.java +++ b/test/java/org/apache/fop/config/BaseConstructiveUserConfigTestCase.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/test/java/org/apache/fop/config/BaseDestructiveUserConfigTestCase.java b/test/java/org/apache/fop/config/BaseDestructiveUserConfigTestCase.java index c02f99c03..0d294d328 100644 --- a/test/java/org/apache/fop/config/BaseDestructiveUserConfigTestCase.java +++ b/test/java/org/apache/fop/config/BaseDestructiveUserConfigTestCase.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/test/java/org/apache/fop/config/BaseUserConfigTestCase.java b/test/java/org/apache/fop/config/BaseUserConfigTestCase.java index ff14e5f0b..4a450a788 100644 --- a/test/java/org/apache/fop/config/BaseUserConfigTestCase.java +++ b/test/java/org/apache/fop/config/BaseUserConfigTestCase.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/test/java/org/apache/fop/config/FontAttributesMissingTestCase.java b/test/java/org/apache/fop/config/FontAttributesMissingTestCase.java index a6333009d..00e9b181b 100644 --- a/test/java/org/apache/fop/config/FontAttributesMissingTestCase.java +++ b/test/java/org/apache/fop/config/FontAttributesMissingTestCase.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/test/java/org/apache/fop/config/FontBaseBadTestCase.java b/test/java/org/apache/fop/config/FontBaseBadTestCase.java index af9031199..b22d0f4f3 100644 --- a/test/java/org/apache/fop/config/FontBaseBadTestCase.java +++ b/test/java/org/apache/fop/config/FontBaseBadTestCase.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. @@ -21,7 +21,7 @@ package org.apache.fop.config; /* * this font base does not exist and a relative font path is used - */ + */ public class FontBaseBadTestCase extends BaseDestructiveUserConfigTestCase { public FontBaseBadTestCase(String name) { diff --git a/test/java/org/apache/fop/config/FontEmbedUrlBadTestCase.java b/test/java/org/apache/fop/config/FontEmbedUrlBadTestCase.java index 218cee795..aa8b9e000 100644 --- a/test/java/org/apache/fop/config/FontEmbedUrlBadTestCase.java +++ b/test/java/org/apache/fop/config/FontEmbedUrlBadTestCase.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/test/java/org/apache/fop/config/FontEmbedUrlMalformedTestCase.java b/test/java/org/apache/fop/config/FontEmbedUrlMalformedTestCase.java index e87164e90..6d41b0a13 100644 --- a/test/java/org/apache/fop/config/FontEmbedUrlMalformedTestCase.java +++ b/test/java/org/apache/fop/config/FontEmbedUrlMalformedTestCase.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,7 +19,7 @@ package org.apache.fop.config; -/** +/** * this font has a malformed embed-url */ public class FontEmbedUrlMalformedTestCase extends BaseDestructiveUserConfigTestCase { diff --git a/test/java/org/apache/fop/config/FontMetricsUrlBadTestCase.java b/test/java/org/apache/fop/config/FontMetricsUrlBadTestCase.java index 00c4db752..166274452 100644 --- a/test/java/org/apache/fop/config/FontMetricsUrlBadTestCase.java +++ b/test/java/org/apache/fop/config/FontMetricsUrlBadTestCase.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. @@ -21,7 +21,7 @@ package org.apache.fop.config; /* * this font has a metrics-url that does not exist on filesystem - */ + */ public class FontMetricsUrlBadTestCase extends BaseDestructiveUserConfigTestCase { /** diff --git a/test/java/org/apache/fop/config/FontMetricsUrlMalformedTestCase.java b/test/java/org/apache/fop/config/FontMetricsUrlMalformedTestCase.java index d5815b42f..ae4dde886 100644 --- a/test/java/org/apache/fop/config/FontMetricsUrlMalformedTestCase.java +++ b/test/java/org/apache/fop/config/FontMetricsUrlMalformedTestCase.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. @@ -21,7 +21,7 @@ package org.apache.fop.config; /* * this font has a malformed metrics-url - */ + */ public class FontMetricsUrlMalformedTestCase extends BaseDestructiveUserConfigTestCase { public FontMetricsUrlMalformedTestCase(String name) { diff --git a/test/java/org/apache/fop/config/FontTripletAttributeMissingTestCase.java b/test/java/org/apache/fop/config/FontTripletAttributeMissingTestCase.java index aed07ed48..dcc0098be 100644 --- a/test/java/org/apache/fop/config/FontTripletAttributeMissingTestCase.java +++ b/test/java/org/apache/fop/config/FontTripletAttributeMissingTestCase.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. @@ -21,7 +21,7 @@ package org.apache.fop.config; /* * this font has a missing font triplet attribute - */ + */ public class FontTripletAttributeMissingTestCase extends BaseDestructiveUserConfigTestCase { public FontTripletAttributeMissingTestCase(String name) { diff --git a/test/java/org/apache/fop/config/FontsAutoDetectTestCase.java b/test/java/org/apache/fop/config/FontsAutoDetectTestCase.java index 3e188a3e9..403bf3282 100644 --- a/test/java/org/apache/fop/config/FontsAutoDetectTestCase.java +++ b/test/java/org/apache/fop/config/FontsAutoDetectTestCase.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/test/java/org/apache/fop/config/FontsDirectoryBadTestCase.java b/test/java/org/apache/fop/config/FontsDirectoryBadTestCase.java index b439e37b2..e83e5ca04 100644 --- a/test/java/org/apache/fop/config/FontsDirectoryBadTestCase.java +++ b/test/java/org/apache/fop/config/FontsDirectoryBadTestCase.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. @@ -21,20 +21,20 @@ package org.apache.fop.config; /* * this font has a metrics-url that does not exist on filesystem - */ + */ public class FontsDirectoryBadTestCase extends BaseDestructiveUserConfigTestCase { public FontsDirectoryBadTestCase(String name) { super(name); } - + /** * @see org.apache.fop.config.BaseUserConfigTestCase#getUserConfigFilename() */ public String getUserConfigFilename() { return "test_fonts_directory_bad.xconf"; } - + /** get test FOP config File */ protected String getFontFOFilePath() { return "test/xml/bugtests/font-dir.fo"; diff --git a/test/java/org/apache/fop/config/FontsDirectoryRecursiveTestCase.java b/test/java/org/apache/fop/config/FontsDirectoryRecursiveTestCase.java index 1759f532d..3c0205d3d 100644 --- a/test/java/org/apache/fop/config/FontsDirectoryRecursiveTestCase.java +++ b/test/java/org/apache/fop/config/FontsDirectoryRecursiveTestCase.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. @@ -20,7 +20,7 @@ package org.apache.fop.config; /** - * tests font directory on system + * tests font directory on system */ public class FontsDirectoryRecursiveTestCase extends BaseConstructiveUserConfigTestCase { @@ -33,5 +33,5 @@ public class FontsDirectoryRecursiveTestCase extends BaseConstructiveUserConfigT */ protected String getUserConfigFilename() { return "test_fonts_directory_recursive.xconf"; - } + } } diff --git a/test/java/org/apache/fop/config/UserConfigTestSuite.java b/test/java/org/apache/fop/config/UserConfigTestSuite.java index c12180625..f933a0342 100644 --- a/test/java/org/apache/fop/config/UserConfigTestSuite.java +++ b/test/java/org/apache/fop/config/UserConfigTestSuite.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/test/java/org/apache/fop/datatypes/URISpecificationTestCase.java b/test/java/org/apache/fop/datatypes/URISpecificationTestCase.java index 4f6f24f95..45470aeee 100644 --- a/test/java/org/apache/fop/datatypes/URISpecificationTestCase.java +++ b/test/java/org/apache/fop/datatypes/URISpecificationTestCase.java @@ -28,7 +28,7 @@ public class URISpecificationTestCase extends TestCase { public void testGetURL() throws Exception { String actual; - + actual = URISpecification.getURL("http://localhost/test"); assertEquals("http://localhost/test", actual); @@ -41,10 +41,10 @@ public class URISpecificationTestCase extends TestCase { actual = URISpecification.getURL("url(\"http://localhost/test\")"); assertEquals("http://localhost/test", actual); } - + public void testEscapeURI() throws Exception { String actual; - + actual = URISpecification.escapeURI("http://localhost/test"); assertEquals("http://localhost/test", actual); @@ -57,5 +57,5 @@ public class URISpecificationTestCase extends TestCase { actual = URISpecification.escapeURI("http://localhost/test test.pdf#page=6"); assertEquals("http://localhost/test%20test.pdf#page=6", actual); } - + } diff --git a/test/java/org/apache/fop/events/BasicEventTestCase.java b/test/java/org/apache/fop/events/BasicEventTestCase.java index d365ca0ec..c69dad081 100644 --- a/test/java/org/apache/fop/events/BasicEventTestCase.java +++ b/test/java/org/apache/fop/events/BasicEventTestCase.java @@ -26,27 +26,27 @@ import org.apache.fop.events.model.EventSeverity; public class BasicEventTestCase extends TestCase { public void testBasics() throws Exception { - + MyEventListener listener = new MyEventListener(); EventBroadcaster broadcaster = new DefaultEventBroadcaster(); broadcaster.addEventListener(listener); assertTrue(broadcaster.hasEventListeners()); - + Event ev = new Event(this, "123", EventSeverity.INFO, Event.paramsBuilder() .param("reason", "I'm tired") .param("blah", new Integer(23)) .build()); broadcaster.broadcastEvent(ev); - + ev = listener.event; assertNotNull(ev); assertEquals("123", listener.event.getEventID()); assertEquals(EventSeverity.INFO, listener.event.getSeverity()); assertEquals("I'm tired", ev.getParam("reason")); assertEquals(new Integer(23), ev.getParam("blah")); - + broadcaster.removeEventListener(listener); assertFalse(broadcaster.hasEventListeners()); @@ -60,11 +60,11 @@ public class BasicEventTestCase extends TestCase { EventBroadcaster broadcaster = new DefaultEventBroadcaster(); broadcaster.addEventListener(listener); assertTrue(broadcaster.hasEventListeners()); - - + + TestEventProducer producer = TestEventProducer.Provider.get(broadcaster); producer.complain(this, "I'm tired", 23); - + Event ev = listener.event; assertNotNull(ev); assertEquals("org.apache.fop.events.TestEventProducer.complain", @@ -72,18 +72,18 @@ public class BasicEventTestCase extends TestCase { assertEquals(EventSeverity.WARN, listener.event.getSeverity()); assertEquals("I'm tired", ev.getParam("reason")); assertEquals(new Integer(23), ev.getParam("blah")); - + broadcaster.removeEventListener(listener); assertFalse(broadcaster.hasEventListeners()); //Just check that there are no NPEs broadcaster.broadcastEvent(ev); } - + private class MyEventListener implements EventListener { private Event event; - + public void processEvent(Event event) { if (this.event != null) { fail("Multiple events received"); diff --git a/test/java/org/apache/fop/events/TestEventProducer.java b/test/java/org/apache/fop/events/TestEventProducer.java index 7dfba75ba..ff0bc2a81 100644 --- a/test/java/org/apache/fop/events/TestEventProducer.java +++ b/test/java/org/apache/fop/events/TestEventProducer.java @@ -29,7 +29,7 @@ public interface TestEventProducer extends EventProducer { * @event.severity WARN */ void complain(Object source, String reason, int blah); - + /** * Express joy about something. * @param source the event source @@ -37,12 +37,12 @@ public interface TestEventProducer extends EventProducer { * @event.severity INFO */ void enjoy(Object source, String what); - + public class Provider { - + public static TestEventProducer get(EventBroadcaster broadcaster) { return (TestEventProducer)broadcaster.getEventProducerFor(TestEventProducer.class); } } - + } diff --git a/test/java/org/apache/fop/fo/flow/table/AbstractTableTestCase.java b/test/java/org/apache/fop/fo/flow/table/AbstractTableTestCase.java index 5885c9fd3..90d89d702 100644 --- a/test/java/org/apache/fop/fo/flow/table/AbstractTableTestCase.java +++ b/test/java/org/apache/fop/fo/flow/table/AbstractTableTestCase.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,7 +38,7 @@ abstract class AbstractTableTestCase extends FOTreeUnitTester { super(); tableHandlerFactory = new FOEventHandlerFactory() { public FOEventHandler createFOEventHandler(FOUserAgent foUserAgent) { - tableHandler = new TableHandler(foUserAgent); + tableHandler = new TableHandler(foUserAgent); return tableHandler; } }; diff --git a/test/java/org/apache/fop/fo/flow/table/CollapsedConditionalBorderTestCase.java b/test/java/org/apache/fop/fo/flow/table/CollapsedConditionalBorderTestCase.java index d26426513..8bddfd095 100644 --- a/test/java/org/apache/fop/fo/flow/table/CollapsedConditionalBorderTestCase.java +++ b/test/java/org/apache/fop/fo/flow/table/CollapsedConditionalBorderTestCase.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/test/java/org/apache/fop/fo/flow/table/ErrorCheckTestCase.java b/test/java/org/apache/fop/fo/flow/table/ErrorCheckTestCase.java index 7327c3324..5dbb66a12 100644 --- a/test/java/org/apache/fop/fo/flow/table/ErrorCheckTestCase.java +++ b/test/java/org/apache/fop/fo/flow/table/ErrorCheckTestCase.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/test/java/org/apache/fop/fo/flow/table/IllegalRowSpanTestCase.java b/test/java/org/apache/fop/fo/flow/table/IllegalRowSpanTestCase.java index 447b14946..bc3d2b4c8 100644 --- a/test/java/org/apache/fop/fo/flow/table/IllegalRowSpanTestCase.java +++ b/test/java/org/apache/fop/fo/flow/table/IllegalRowSpanTestCase.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/test/java/org/apache/fop/fo/flow/table/RowGroupBuilderTestCase.java b/test/java/org/apache/fop/fo/flow/table/RowGroupBuilderTestCase.java index 498df92b4..6d2c4f85c 100644 --- a/test/java/org/apache/fop/fo/flow/table/RowGroupBuilderTestCase.java +++ b/test/java/org/apache/fop/fo/flow/table/RowGroupBuilderTestCase.java @@ -37,7 +37,7 @@ public class RowGroupBuilderTestCase extends AbstractTableTestCase { * More precisely, checks that the number of row groups corresponds to the size of the * given array, and that the number of rows inside each row group is equal to the * corresponding integer in the array. - * + * * @param part a table part whose row groups are to be checked * @param expectedRowLengths expected lengths of all the row groups of this part of * the table @@ -123,17 +123,17 @@ public class RowGroupBuilderTestCase extends AbstractTableTestCase { // Table 2: no header, no footer, one body (1 row-group of 2 rows) checkNextTableRowGroups(tableIter, null, null, new int[][] {{2}}); - // Table 3: no header, no footer, one body (1 row-group of 2 rows, 1 row) + // Table 3: no header, no footer, one body (1 row-group of 2 rows, 1 row) checkNextTableRowGroups(tableIter, null, null, new int[][] {{2, 1}}); // Table 4: no header, no footer, one body (1 row, 1 row-group of 2 rows) checkNextTableRowGroups(tableIter, null, null, new int[][] {{1, 2}}); - // Table 5: no header, no footer, one body (1 row, 1 row-group of 3 rows, 1 row) + // Table 5: no header, no footer, one body (1 row, 1 row-group of 3 rows, 1 row) checkNextTableRowGroups(tableIter, null, null, new int[][] {{1, 3, 1}}); // Table 6: one header (1 row-group of 2 rows), one footer (1 row, 1 row-group of 3 rows), - // one body (1 row-group of 2 rows, 1 row, 1 row-group of 3 rows) + // one body (1 row-group of 2 rows, 1 row, 1 row-group of 3 rows) checkNextTableRowGroups(tableIter, new int[] {2}, new int[] {1, 3}, new int[][] {{2, 1, 3}}); } diff --git a/test/java/org/apache/fop/fo/flow/table/TableColumnColumnNumberTestCase.java b/test/java/org/apache/fop/fo/flow/table/TableColumnColumnNumberTestCase.java index 38274ef5e..dc61b1dc2 100644 --- a/test/java/org/apache/fop/fo/flow/table/TableColumnColumnNumberTestCase.java +++ b/test/java/org/apache/fop/fo/flow/table/TableColumnColumnNumberTestCase.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,7 +53,7 @@ public class TableColumnColumnNumberTestCase extends AbstractTableTestCase { private void checkColumn(Table t, int number, boolean isImplicit, int spans, int repeated, int width) { TableColumn c = t.getColumn(number - 1); - // TODO a repeated column has a correct number only for its first occurrence + // TODO a repeated column has a correct number only for its first occurrence // assertEquals(number, c.getColumnNumber()); assertEquals(isImplicit, c.isImplicitColumn()); assertEquals(spans, c.getNumberColumnsSpanned()); diff --git a/test/java/org/apache/fop/fo/flow/table/TooManyColumnsTestCase.java b/test/java/org/apache/fop/fo/flow/table/TooManyColumnsTestCase.java index c02f634cd..0c7effd5b 100644 --- a/test/java/org/apache/fop/fo/flow/table/TooManyColumnsTestCase.java +++ b/test/java/org/apache/fop/fo/flow/table/TooManyColumnsTestCase.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/test/java/org/apache/fop/fonts/TrueTypeAnsiTestCase.java b/test/java/org/apache/fop/fonts/TrueTypeAnsiTestCase.java index dc9890167..3f98c93f4 100644 --- a/test/java/org/apache/fop/fonts/TrueTypeAnsiTestCase.java +++ b/test/java/org/apache/fop/fonts/TrueTypeAnsiTestCase.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.fonts; import java.io.File; @@ -46,7 +46,7 @@ import org.apache.fop.render.pdf.PDFRenderer; * Tests XML font metrics file generation and usage for WinAnsi mode. */ public class TrueTypeAnsiTestCase extends TestCase { - + /** * Tests a TrueType font in WinAnsi mode. * @throws Exception if an error occurs @@ -62,12 +62,12 @@ public class TrueTypeAnsiTestCase extends TestCase { if (metricsFile.isFile()) { assertTrue(metricsFile.delete()); } - + String[] args = new String[] {"-enc", "ansi", ttfFile.getCanonicalPath(), metricsFile.getCanonicalPath()}; TTFReader.main(args); assertTrue(metricsFile.isFile()); - + FopFactory fopFactory = FopFactory.newInstance(); FOUserAgent ua = fopFactory.newFOUserAgent(); PDFRenderer renderer = new PDFRenderer(); @@ -81,12 +81,12 @@ public class TrueTypeAnsiTestCase extends TestCase { ttfFile.toURI().toASCIIString(), null); fontList.add(font); renderer.addFontList(fontList); - + ua.setRendererOverride(renderer); OutputStream out = new NullOutputStream(); - + Fop fop = fopFactory.newFop(null, ua, out); - + TransformerFactory tFactory = TransformerFactory.newInstance(); Source src = new StreamSource(new StringReader( "Test!")); @@ -103,5 +103,5 @@ public class TrueTypeAnsiTestCase extends TestCase { } return new StreamSource(url.toExternalForm()); } - + } diff --git a/test/java/org/apache/fop/fotreetest/FOTreeTestSuite.java b/test/java/org/apache/fop/fotreetest/FOTreeTestSuite.java index aa9af4226..76faa21c9 100644 --- a/test/java/org/apache/fop/fotreetest/FOTreeTestSuite.java +++ b/test/java/org/apache/fop/fotreetest/FOTreeTestSuite.java @@ -52,11 +52,11 @@ public final class FOTreeTestSuite { static { DebugHelper.registerStandardElementListObservers(); } - + private FOTreeTestSuite() { //don't instantiate! } - + /** * @return the test suite with all the tests (one for each XML file) * @throws IOException in case of an I/O problem @@ -72,7 +72,7 @@ public final class FOTreeTestSuite { File mainDir = new File("test/fotree"); final FOTreeTester tester = new FOTreeTester(); - + IOFileFilter filter; String single = System.getProperty("fop.fotree.single"); String startsWith = System.getProperty("fop.fotree.starts-with"); @@ -85,12 +85,12 @@ public final class FOTreeTestSuite { filter = new SuffixFileFilter(".fo"); filter = LayoutEngineTestSuite.decorateWithDisabledList(filter); } - Collection files = FileUtils.listFiles(new File(mainDir, "testcases"), + Collection files = FileUtils.listFiles(new File(mainDir, "testcases"), filter, TrueFileFilter.INSTANCE); String privateTests = System.getProperty("fop.fotree.private"); if ("true".equalsIgnoreCase(privateTests)) { Collection privateFiles = FileUtils.listFiles( - new File(mainDir, "private-testcases"), + new File(mainDir, "private-testcases"), filter, TrueFileFilter.INSTANCE); files.addAll(privateFiles); } @@ -100,8 +100,8 @@ public final class FOTreeTestSuite { addTestCase(suite, tester, f); } } - - private static void addTestCase(TestSuite suite, + + private static void addTestCase(TestSuite suite, final FOTreeTester tester, final File f) { suite.addTest(new FOTreeTestCase(f.getName()) { public void runTest() throws Exception { @@ -126,22 +126,22 @@ public final class FOTreeTestSuite { } private static class FOTreeTestCase extends TestCase { - + private FOTreeTester tester; private File testFile; - + public FOTreeTestCase(String name) { super(name); } - + public void prepare(FOTreeTester tester, File testFile) { //super(testFile.getName()); this.tester = tester; this.testFile = testFile; } - + public void testMain() throws Exception { tester.runTest(testFile); } - } + } } diff --git a/test/java/org/apache/fop/fotreetest/FOTreeTester.java b/test/java/org/apache/fop/fotreetest/FOTreeTester.java index 6ffad6989..fe44e3e23 100644 --- a/test/java/org/apache/fop/fotreetest/FOTreeTester.java +++ b/test/java/org/apache/fop/fotreetest/FOTreeTester.java @@ -39,7 +39,7 @@ import org.apache.fop.util.ConsoleEventListenerForTests; * Test driver class for FO tree tests. */ public class FOTreeTester { - + private FopFactory fopFactory = FopFactory.newInstance(); /** @@ -48,7 +48,7 @@ public class FOTreeTester { public FOTreeTester() { fopFactory.addElementMapping(new TestElementMapping()); } - + /** * Runs a test. * @param testFile the test file. @@ -57,13 +57,13 @@ public class FOTreeTester { public void runTest(File testFile) throws Exception { ResultCollector collector = ResultCollector.getInstance(); collector.reset(); - + SAXParserFactory spf = SAXParserFactory.newInstance(); spf.setNamespaceAware(true); spf.setValidating(false); SAXParser parser = spf.newSAXParser(); XMLReader reader = parser.getXMLReader(); - + FOUserAgent ua = fopFactory.newFOUserAgent(); ua.setBaseURL(testFile.getParentFile().toURL().toString()); ua.setFOEventHandlerOverride(new DummyFOEventHandler(ua)); @@ -72,15 +72,15 @@ public class FOTreeTester { //Used to set values in the user agent through processing instructions reader = new PIListener(reader, ua); - + Fop fop = fopFactory.newFop(ua); - + reader.setContentHandler(fop.getDefaultHandler()); reader.setDTDHandler(fop.getDefaultHandler()); reader.setErrorHandler(fop.getDefaultHandler()); reader.setEntityResolver(fop.getDefaultHandler()); reader.parse(testFile.toURL().toExternalForm()); - + List results = collector.getResults(); if (results.size() > 0) { for (int i = 0; i < results.size(); i++) { @@ -91,9 +91,9 @@ public class FOTreeTester { } private class PIListener extends XMLFilterImpl { - + private FOUserAgent userAgent; - + public PIListener(XMLReader parent, FOUserAgent userAgent) { super(parent); this.userAgent = userAgent; @@ -107,7 +107,7 @@ public class FOTreeTester { } super.processingInstruction(target, data); } - + } - + } diff --git a/test/java/org/apache/fop/fotreetest/FOTreeUnitTester.java b/test/java/org/apache/fop/fotreetest/FOTreeUnitTester.java index a7fa11950..bfe9018b1 100644 --- a/test/java/org/apache/fop/fotreetest/FOTreeUnitTester.java +++ b/test/java/org/apache/fop/fotreetest/FOTreeUnitTester.java @@ -56,7 +56,7 @@ public abstract class FOTreeUnitTester extends TestCase { * This method is called by FOTreeUnitTester when creating a {@link Fop} instance. * That lets pass to the custom FOEventHandler the proper user agent that will be * used by this instance. - * + * * @param foUserAgent the user agent needed by the Fop instance that will be used * to create the FO tree * @return the appropriate FOEventHandler for performing the tests @@ -77,9 +77,9 @@ public abstract class FOTreeUnitTester extends TestCase { /** * Launches FOP on the given FO file. - * + * * @param filename path to the test FO file - * @param factory to create the appropriate FOEventHandler for performing tests + * @param factory to create the appropriate FOEventHandler for performing tests */ public void setUp(String filename, FOEventHandlerFactory factory) throws Exception { FOUserAgent ua = fopFactory.newFOUserAgent(); diff --git a/test/java/org/apache/fop/fotreetest/ResultCollector.java b/test/java/org/apache/fop/fotreetest/ResultCollector.java index a1c7cee7c..36d111c7f 100644 --- a/test/java/org/apache/fop/fotreetest/ResultCollector.java +++ b/test/java/org/apache/fop/fotreetest/ResultCollector.java @@ -23,14 +23,14 @@ import java.util.Collections; import java.util.List; /** - * This class collects the results from assertions injected into the FO stream. + * This class collects the results from assertions injected into the FO stream. */ public class ResultCollector { private static ResultCollector instance = null; - + private List results = new java.util.ArrayList(); - + /** @return the ResultColletor singleton */ public static ResultCollector getInstance() { if (instance == null) { @@ -38,12 +38,12 @@ public class ResultCollector { } return instance; } - + /** Main constructor. */ public ResultCollector() { //nop } - + /** * This notifies the ResultCollector about an Exception. * @param e the exception @@ -52,12 +52,12 @@ public class ResultCollector { System.out.println(e.getMessage()); results.add(e); } - + /** Resets the result list. */ public void reset() { results.clear(); } - + /** @return the list of results */ public List getResults() { return Collections.unmodifiableList(results); diff --git a/test/java/org/apache/fop/fotreetest/ext/AssertElement.java b/test/java/org/apache/fop/fotreetest/ext/AssertElement.java index b141c8f4a..97b73947c 100644 --- a/test/java/org/apache/fop/fotreetest/ext/AssertElement.java +++ b/test/java/org/apache/fop/fotreetest/ext/AssertElement.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.fotreetest.ext; @@ -50,9 +50,9 @@ public class AssertElement extends TestObj { /** * @see org.apache.fop.fo.FONode#processNode */ - public void processNode(String elementName, - Locator locator, - Attributes attlist, + public void processNode(String elementName, + Locator locator, + Attributes attlist, PropertyList propertyList) throws FOPException { //super.processNode(elementName, locator, attlist, propertyList); @@ -102,22 +102,22 @@ public class AssertElement extends TestObj { if (!expected.equals(s)) { collector.notifyException( new IllegalStateException(locator.getSystemId() - + "\nProperty '" + propName - + "' expected to evaluate to '" + expected + + "\nProperty '" + propName + + "' expected to evaluate to '" + expected + "' but got '" + s - + "'\n(test:assert in " + + "'\n(test:assert in " + propertyList.getParentFObj().getName() - + " at line #" + locator.getLineNumber() + + " at line #" + locator.getLineNumber() + ", column #" + locator.getColumnNumber() + ")\n")); } } - + } /** @see org.apache.fop.fo.FONode#getLocalName() */ public String getLocalName() { return "assert"; } - + } diff --git a/test/java/org/apache/fop/fotreetest/ext/TestElementMapping.java b/test/java/org/apache/fop/fotreetest/ext/TestElementMapping.java index f0b8ef2c8..1d9127d0c 100644 --- a/test/java/org/apache/fop/fotreetest/ext/TestElementMapping.java +++ b/test/java/org/apache/fop/fotreetest/ext/TestElementMapping.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.fotreetest.ext; import org.apache.fop.fo.FONode; @@ -28,7 +28,7 @@ import org.apache.fop.fo.ElementMapping; public class TestElementMapping extends ElementMapping { /** MathML Namespace */ - public static final String NAMESPACE = "http://xmlgraphics.apache.org/fop/test"; + public static final String NAMESPACE = "http://xmlgraphics.apache.org/fop/test"; /** * Main constructor diff --git a/test/java/org/apache/fop/fotreetest/ext/TestObj.java b/test/java/org/apache/fop/fotreetest/ext/TestObj.java index 615062304..e921c8919 100644 --- a/test/java/org/apache/fop/fotreetest/ext/TestObj.java +++ b/test/java/org/apache/fop/fotreetest/ext/TestObj.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.fotreetest.ext; // FOP diff --git a/test/java/org/apache/fop/image/loader/batik/ImageLoaderTestCase.java b/test/java/org/apache/fop/image/loader/batik/ImageLoaderTestCase.java index 9261e6d84..c6c4015cc 100644 --- a/test/java/org/apache/fop/image/loader/batik/ImageLoaderTestCase.java +++ b/test/java/org/apache/fop/image/loader/batik/ImageLoaderTestCase.java @@ -40,26 +40,26 @@ import org.apache.fop.apps.FopFactory; public class ImageLoaderTestCase extends TestCase { private static final File DEBUG_TARGET_DIR = null; //new File("D:/"); - + private FopFactory fopFactory; - + public ImageLoaderTestCase(String name) { super(name); fopFactory = FopFactory.newInstance(); fopFactory.setSourceResolution(72); fopFactory.setTargetResolution(300); } - + public void testSVG() throws Exception { String uri = "test/resources/images/img-w-size.svg"; - + FOUserAgent userAgent = fopFactory.newFOUserAgent(); - + ImageManager manager = fopFactory.getImageManager(); ImageInfo info = manager.preloadImage(uri, userAgent.getImageSessionContext()); assertNotNull("ImageInfo must not be null", info); - - Image img = manager.getImage(info, ImageFlavor.XML_DOM, + + Image img = manager.getImage(info, ImageFlavor.XML_DOM, userAgent.getImageSessionContext()); assertNotNull("Image must not be null", img); assertEquals(ImageFlavor.XML_DOM, img.getFlavor()); @@ -69,7 +69,7 @@ public class ImageLoaderTestCase extends TestCase { info = imgDom.getInfo(); //Switch to the ImageInfo returned by the image assertEquals(16000, info.getSize().getWidthMpt()); assertEquals(16000, info.getSize().getHeightMpt()); - + img = manager.getImage(info, ImageFlavor.RENDERED_IMAGE, userAgent.getImageSessionContext()); assertNotNull("Image must not be null", img); @@ -87,16 +87,16 @@ public class ImageLoaderTestCase extends TestCase { assertEquals(16000, info.getSize().getWidthMpt()); assertEquals(16000, info.getSize().getHeightMpt()); } - + public void testWMF() throws Exception { String uri = "test/resources/images/testChart.wmf"; - + FOUserAgent userAgent = fopFactory.newFOUserAgent(); - + ImageManager manager = fopFactory.getImageManager(); ImageInfo info = manager.preloadImage(uri, userAgent.getImageSessionContext()); assertNotNull("ImageInfo must not be null", info); - + Image img = manager.getImage(info, ImageFlavor.RENDERED_IMAGE, userAgent.getImageSessionContext()); assertNotNull("Image must not be null", img); @@ -114,5 +114,5 @@ public class ImageLoaderTestCase extends TestCase { assertEquals(792000, info.getSize().getWidthMpt()); assertEquals(612000, info.getSize().getHeightMpt()); } - + } diff --git a/test/java/org/apache/fop/image/loader/batik/ImagePreloaderTestCase.java b/test/java/org/apache/fop/image/loader/batik/ImagePreloaderTestCase.java index 9406ed65c..057866eb9 100644 --- a/test/java/org/apache/fop/image/loader/batik/ImagePreloaderTestCase.java +++ b/test/java/org/apache/fop/image/loader/batik/ImagePreloaderTestCase.java @@ -48,29 +48,29 @@ import org.apache.fop.apps.MimeConstants; public class ImagePreloaderTestCase extends TestCase { private FopFactory fopFactory; - + public ImagePreloaderTestCase(String name) { super(name); fopFactory = FopFactory.newInstance(); fopFactory.setSourceResolution(72); fopFactory.setTargetResolution(300); } - + public void testSVG() throws Exception { String uri = "test/resources/images/img-w-size.svg"; - + checkSVGFile(uri); } public void testSVGZ() throws Exception { String uri = "test/resources/images/img-w-size.svgz"; - + checkSVGFile(uri); } private void checkSVGFile(String uri) throws ImageException, IOException { FOUserAgent userAgent = fopFactory.newFOUserAgent(); - + ImageManager manager = fopFactory.getImageManager(); ImageInfo info = manager.preloadImage(uri, userAgent.getImageSessionContext()); assertNotNull("ImageInfo must not be null", info); @@ -82,11 +82,11 @@ public class ImagePreloaderTestCase extends TestCase { assertEquals(16000, info.getSize().getWidthMpt()); assertEquals(16000, info.getSize().getHeightMpt()); } - + public void testSVGNoSize() throws Exception { String uri = "test/resources/images/img.svg"; FOUserAgent userAgent = fopFactory.newFOUserAgent(); - + ImageManager manager = fopFactory.getImageManager(); ImageInfo info = manager.preloadImage(uri, userAgent.getImageSessionContext()); assertNotNull("ImageInfo must not be null", info); @@ -102,7 +102,7 @@ public class ImagePreloaderTestCase extends TestCase { public void testSVGWithDOM() throws Exception { String uri = "my:SVGImage"; FOUserAgent userAgent = fopFactory.newFOUserAgent(); - + userAgent.setURIResolver(new URIResolver() { public Source resolve(String href, String base) throws TransformerException { @@ -114,23 +114,23 @@ public class ImagePreloaderTestCase extends TestCase { element.setAttribute("viewBox", "0 0 20 20"); element.setAttribute("width", "20pt"); element.setAttribute("height", "20pt"); - + Element rect = doc.createElementNS(svgNS, "rect"); rect.setAttribute("x", "5"); rect.setAttribute("y", "5"); rect.setAttribute("width", "10"); rect.setAttribute("height", "10"); element.appendChild(rect); - + DOMSource src = new DOMSource(doc); return src; } else { return null; } } - + }); - + ImageManager manager = fopFactory.getImageManager(); ImageInfo info = manager.preloadImage(uri, userAgent.getImageSessionContext()); assertNotNull("ImageInfo must not be null", info); @@ -145,9 +145,9 @@ public class ImagePreloaderTestCase extends TestCase { public void testWMF() throws Exception { String uri = "test/resources/images/testChart.wmf"; - + FOUserAgent userAgent = fopFactory.newFOUserAgent(); - + ImageManager manager = fopFactory.getImageManager(); ImageInfo info = manager.preloadImage(uri, userAgent.getImageSessionContext()); assertNotNull("ImageInfo must not be null", info); @@ -159,5 +159,5 @@ public class ImagePreloaderTestCase extends TestCase { assertEquals(792000, info.getSize().getWidthMpt()); assertEquals(612000, info.getSize().getHeightMpt()); } - + } diff --git a/test/java/org/apache/fop/intermediate/AreaTreeParserTestCase.java b/test/java/org/apache/fop/intermediate/AreaTreeParserTestCase.java index 96aa89bc3..76cca1569 100644 --- a/test/java/org/apache/fop/intermediate/AreaTreeParserTestCase.java +++ b/test/java/org/apache/fop/intermediate/AreaTreeParserTestCase.java @@ -63,25 +63,25 @@ public class AreaTreeParserTestCase extends XMLTestCase { // configure fopFactory as desired private static FopFactory fopFactory = FopFactory.newInstance(); - - private static SAXTransformerFactory tFactory + + private static SAXTransformerFactory tFactory = (SAXTransformerFactory)SAXTransformerFactory.newInstance(); private static Templates stylesheet = null; - + private File mainDir = new File("test/layoutengine"); private File testDir = new File(mainDir, "standard-testcases"); - + private String name; private File testFile; private File outputDir; private Document intermediate; - + /** @see junit.framework.TestCase#TestCase(String) */ public AreaTreeParserTestCase(String name) { super(name); } - + /** * Constructor for the test suite that is used for each test file. * @param testFile the test file to run @@ -90,7 +90,7 @@ public class AreaTreeParserTestCase extends XMLTestCase { super(testFile.getName()); this.testFile = testFile; } - + private Templates getStylesheet() throws TransformerConfigurationException { if (stylesheet == null) { File xsltFile = new File(mainDir, "testcase2fo.xsl"); @@ -98,7 +98,7 @@ public class AreaTreeParserTestCase extends XMLTestCase { } return stylesheet; } - + /** @see junit.framework.TestCase#setUp() */ protected void setUp() throws Exception { super.setUp(); @@ -127,17 +127,17 @@ public class AreaTreeParserTestCase extends XMLTestCase { * @throws Exception if the test fails */ public void testParserToAT() throws Exception { - + Source src = new DOMSource(intermediate); Document doc = parseAndRenderToAreaTree(src); if (outputDir != null) { File tgtFile = new File(outputDir, name + ".at2.xml"); saveDOM(doc, tgtFile); } - + assertXMLEqual(intermediate, doc); } - + private void saveDOM(Document doc, File tgtFile) throws Exception { Transformer transformer = tFactory.newTransformer(); Source src = new DOMSource(doc); @@ -166,7 +166,7 @@ public class AreaTreeParserTestCase extends XMLTestCase { IOUtils.closeQuietly(out); } } - + private FOUserAgent createUserAgent() { FOUserAgent userAgent = fopFactory.newFOUserAgent(); try { @@ -191,41 +191,41 @@ public class AreaTreeParserTestCase extends XMLTestCase { TransformerHandler handler = tFactory.newTransformerHandler(); DOMResult domResult = new DOMResult(); handler.setResult(domResult); - + FOUserAgent userAgent = createUserAgent(); //Create an instance of the target renderer so the XMLRenderer can use its font setup Renderer targetRenderer = userAgent.getRendererFactory().createRenderer( - userAgent, MimeConstants.MIME_PDF); - + userAgent, MimeConstants.MIME_PDF); + XMLRenderer renderer = new XMLRenderer(); renderer.mimicRenderer(targetRenderer); renderer.setContentHandler(handler); renderer.setUserAgent(userAgent); userAgent.setRendererOverride(renderer); - + Fop fop = fopFactory.newFop(MimeConstants.MIME_FOP_AREA_TREE, userAgent); Result res = new SAXResult(fop.getDefaultHandler()); transformer.transform(src, res); - + return (Document)domResult.getNode(); } - + private void parseAndRender(Source src, OutputStream out, String mime) throws Exception { AreaTreeParser parser = new AreaTreeParser(); - + FOUserAgent userAgent = createUserAgent(); FontInfo fontInfo = new FontInfo(); - AreaTreeModel treeModel = new RenderPagesModel(userAgent, - mime, fontInfo, out); + AreaTreeModel treeModel = new RenderPagesModel(userAgent, + mime, fontInfo, out); parser.parse(src, treeModel, userAgent); treeModel.endDocument(); } - + private Document parseAndRenderToAreaTree(Source src) throws Exception { AreaTreeParser parser = new AreaTreeParser(); - + //Set up XMLRenderer to render to a DOM TransformerHandler handler = tFactory.newTransformerHandler(); DOMResult domResult = new DOMResult(); @@ -238,12 +238,12 @@ public class AreaTreeParserTestCase extends XMLTestCase { renderer.setUserAgent(userAgent); FontInfo fontInfo = new FontInfo(); - AreaTreeModel treeModel = new RenderPagesModel(userAgent, - MimeConstants.MIME_FOP_AREA_TREE, fontInfo, null); + AreaTreeModel treeModel = new RenderPagesModel(userAgent, + MimeConstants.MIME_FOP_AREA_TREE, fontInfo, null); parser.parse(src, treeModel, userAgent); treeModel.endDocument(); return (Document)domResult.getNode(); } - + } diff --git a/test/java/org/apache/fop/intermediate/IntermediateFormatTestSuite.java b/test/java/org/apache/fop/intermediate/IntermediateFormatTestSuite.java index 68c81da81..5960f746c 100644 --- a/test/java/org/apache/fop/intermediate/IntermediateFormatTestSuite.java +++ b/test/java/org/apache/fop/intermediate/IntermediateFormatTestSuite.java @@ -48,11 +48,11 @@ public class IntermediateFormatTestSuite { File f = (File)i.next(); addTestCase(suite, f); } - + return suite; } - - private static void addTestCase(TestSuite suite, + + private static void addTestCase(TestSuite suite, final File f) { suite.addTest(new AreaTreeParserTestCase(f) { public void runTest() throws Exception { @@ -67,5 +67,5 @@ public class IntermediateFormatTestSuite { } }); } - + } diff --git a/test/java/org/apache/fop/layoutengine/ElementListCheck.java b/test/java/org/apache/fop/layoutengine/ElementListCheck.java index 14eba7b98..1b6077c29 100644 --- a/test/java/org/apache/fop/layoutengine/ElementListCheck.java +++ b/test/java/org/apache/fop/layoutengine/ElementListCheck.java @@ -41,7 +41,7 @@ public class ElementListCheck implements LayoutEngineCheck { private String id; private int index = -1; private Element checkElement; - + /** * Creates a new instance from a DOM node. * @param node DOM node that defines this check @@ -68,7 +68,7 @@ public class ElementListCheck implements LayoutEngineCheck { NodeList children = checkElement.getChildNodes(); int pos = -1; for (int i = 0; i < children.getLength(); i++) { - Node node = children.item(i); + Node node = children.item(i); if (node instanceof Element) { pos++; Element domEl = (Element)node; @@ -78,14 +78,14 @@ public class ElementListCheck implements LayoutEngineCheck { } else if ("box".equals(domEl.getLocalName())) { if (!(knuthEl instanceof KnuthBox)) { fail("Expected KnuthBox" - + " at position " + pos + + " at position " + pos + " but got: " + knuthEl.getClass().getName()); } if (domEl.getAttribute("w").length() > 0) { int w = Integer.parseInt(domEl.getAttribute("w")); if (w != knuthEl.getW()) { - fail("Expected w=" + w - + " at position " + pos + fail("Expected w=" + w + + " at position " + pos + " but got: " + knuthEl.getW()); } } @@ -104,29 +104,29 @@ public class ElementListCheck implements LayoutEngineCheck { } else if ("penalty".equals(domEl.getLocalName())) { if (!(knuthEl instanceof KnuthPenalty)) { fail("Expected KnuthPenalty " - + " at position " + pos + + " at position " + pos + " but got: " + knuthEl.getClass().getName()); } KnuthPenalty pen = (KnuthPenalty)knuthEl; if (domEl.getAttribute("w").length() > 0) { int w = Integer.parseInt(domEl.getAttribute("w")); if (w != knuthEl.getW()) { - fail("Expected w=" + w - + " at position " + pos + fail("Expected w=" + w + + " at position " + pos + " but got: " + knuthEl.getW()); } } if (domEl.getAttribute("p").length() > 0) { if ("<0".equals(domEl.getAttribute("p"))) { if (knuthEl.getP() >= 0) { - fail("Expected p<0" - + " at position " + pos + fail("Expected p<0" + + " at position " + pos + " but got: " + knuthEl.getP()); } } else if (">0".equals(domEl.getAttribute("p"))) { if (knuthEl.getP() <= 0) { - fail("Expected p>0" - + " at position " + pos + fail("Expected p>0" + + " at position " + pos + " but got: " + knuthEl.getP()); } } else { @@ -143,8 +143,8 @@ public class ElementListCheck implements LayoutEngineCheck { p = Integer.parseInt(domEl.getAttribute("p")); } if (p != knuthEl.getP()) { - fail("Expected p=" + p - + " at position " + pos + fail("Expected p=" + p + + " at position " + pos + " but got: " + knuthEl.getP()); } } @@ -152,7 +152,7 @@ public class ElementListCheck implements LayoutEngineCheck { if ("true".equals(domEl.getAttribute("flagged"))) { if (!pen.isFlagged()) { fail("Expected flagged penalty" - + " at position " + pos); + + " at position " + pos); } } else if ("false".equals(domEl.getAttribute("flagged"))) { if (pen.isFlagged()) { @@ -163,57 +163,57 @@ public class ElementListCheck implements LayoutEngineCheck { if ("true".equals(domEl.getAttribute("aux"))) { if (!pen.isAuxiliary()) { fail("Expected auxiliary penalty" - + " at position " + pos); + + " at position " + pos); } } else if ("false".equals(domEl.getAttribute("aux"))) { if (pen.isAuxiliary()) { fail("Expected non-auxiliary penalty" - + " at position " + pos); + + " at position " + pos); } } } else if ("glue".equals(domEl.getLocalName())) { if (!(knuthEl instanceof KnuthGlue)) { - fail("Expected KnuthGlue" - + " at position " + pos + fail("Expected KnuthGlue" + + " at position " + pos + " but got: " + knuthEl.getClass().getName()); } KnuthGlue glue = (KnuthGlue)knuthEl; if (domEl.getAttribute("w").length() > 0) { int w = Integer.parseInt(domEl.getAttribute("w")); if (w != knuthEl.getW()) { - fail("Expected w=" + w - + " at position " + pos + fail("Expected w=" + w + + " at position " + pos + " but got: " + knuthEl.getW()); } } if (domEl.getAttribute("y").length() > 0) { int stretch = Integer.parseInt(domEl.getAttribute("y")); if (stretch != knuthEl.getY()) { - fail("Expected y=" + stretch - + " (stretch) at position " + pos + fail("Expected y=" + stretch + + " (stretch) at position " + pos + " but got: " + knuthEl.getY()); } } if (domEl.getAttribute("z").length() > 0) { int shrink = Integer.parseInt(domEl.getAttribute("z")); if (shrink != knuthEl.getZ()) { - fail("Expected z=" + shrink - + " (shrink) at position " + pos + fail("Expected z=" + shrink + + " (shrink) at position " + pos + " but got: " + knuthEl.getZ()); } } } else { - throw new IllegalArgumentException("Invalid child node for 'element-list': " + throw new IllegalArgumentException("Invalid child node for 'element-list': " + domEl.getLocalName() + " at position " + pos + " (" + this + ")"); } - + } } pos++; if (elementList.getElementList().size() > pos) { - fail("There are " - + (elementList.getElementList().size() - pos) + fail("There are " + + (elementList.getElementList().size() - pos) + " unchecked elements at the end of the list"); } } @@ -221,7 +221,7 @@ public class ElementListCheck implements LayoutEngineCheck { private void fail(String msg) { throw new RuntimeException(msg + " (" + this + ")"); } - + private boolean haveID() { return (this.id != null && this.id.length() > 0); } @@ -262,7 +262,7 @@ public class ElementListCheck implements LayoutEngineCheck { } return sb.toString(); } - + /** @see java.lang.Object#toString() */ public String toString() { StringBuffer sb = new StringBuffer("element-list"); diff --git a/test/java/org/apache/fop/layoutengine/ElementListCollector.java b/test/java/org/apache/fop/layoutengine/ElementListCollector.java index 3bad1de98..d6ed12047 100644 --- a/test/java/org/apache/fop/layoutengine/ElementListCollector.java +++ b/test/java/org/apache/fop/layoutengine/ElementListCollector.java @@ -30,21 +30,21 @@ import org.apache.fop.layoutmgr.ElementListObserver.Observer; public class ElementListCollector implements Observer { private List elementLists = new java.util.ArrayList(); - + /** * Resets the collector. */ public void reset() { elementLists.clear(); } - + /** * @return the list of ElementList instances. */ public List getElementLists() { return this.elementLists; } - + /** @see org.apache.fop.layoutmgr.ElementListObserver.Observer */ public void observe(List elementList, String category, String id) { elementLists.add(new ElementList(elementList, category, id)); @@ -54,11 +54,11 @@ public class ElementListCollector implements Observer { * Data object representing an element list along with additional information. */ public static class ElementList { - + private List elementList; private String category; private String id; - + /** * Creates a new ElementList instance * @param elementList the element list @@ -70,21 +70,21 @@ public class ElementListCollector implements Observer { this.category = category; this.id = id; } - + /** @return the element list */ public List getElementList() { return elementList; } - + /** @return the category */ public String getCategory() { return category; } - + /** @return the ID, may be null */ public String getID() { return id; } } - + } \ No newline at end of file diff --git a/test/java/org/apache/fop/layoutengine/EvalCheck.java b/test/java/org/apache/fop/layoutengine/EvalCheck.java index bae98ee5f..2dd9405bf 100644 --- a/test/java/org/apache/fop/layoutengine/EvalCheck.java +++ b/test/java/org/apache/fop/layoutengine/EvalCheck.java @@ -36,7 +36,7 @@ public class EvalCheck implements LayoutEngineCheck { private String xpath; private double tolerance; private PrefixResolver prefixResolver; - + /** * Creates a new instance * @param expected expected value @@ -46,7 +46,7 @@ public class EvalCheck implements LayoutEngineCheck { this.expected = expected; this.xpath = xpath; } - + /** * Creates a new instance from a DOM node. * @param node DOM node that defines this check @@ -60,7 +60,7 @@ public class EvalCheck implements LayoutEngineCheck { } this.prefixResolver = new PrefixResolverDefault(node); } - + /** @see org.apache.fop.layoutengine.LayoutEngineCheck */ public void check(LayoutResult result) { XObject res; @@ -75,13 +75,13 @@ public class EvalCheck implements LayoutEngineCheck { double v2 = Double.parseDouble(actual); if (Math.abs(v1 - v2) > tolerance) { throw new RuntimeException( - "Expected XPath expression to evaluate to '" + expected + "', but got '" + "Expected XPath expression to evaluate to '" + expected + "', but got '" + actual + "' (" + this + ", outside tolerance)"); } } else { if (!expected.equals(actual)) { throw new RuntimeException( - "Expected XPath expression to evaluate to '" + expected + "', but got '" + "Expected XPath expression to evaluate to '" + expected + "', but got '" + actual + "' (" + this + ")"); } } diff --git a/test/java/org/apache/fop/layoutengine/LayoutEngineCheck.java b/test/java/org/apache/fop/layoutengine/LayoutEngineCheck.java index 22741827a..155db2263 100644 --- a/test/java/org/apache/fop/layoutengine/LayoutEngineCheck.java +++ b/test/java/org/apache/fop/layoutengine/LayoutEngineCheck.java @@ -29,5 +29,5 @@ public interface LayoutEngineCheck { * @param result the results from the processing run */ void check(LayoutResult result); - + } diff --git a/test/java/org/apache/fop/layoutengine/LayoutEngineTestSuite.java b/test/java/org/apache/fop/layoutengine/LayoutEngineTestSuite.java index 0597e0e91..32a48fb0b 100644 --- a/test/java/org/apache/fop/layoutengine/LayoutEngineTestSuite.java +++ b/test/java/org/apache/fop/layoutengine/LayoutEngineTestSuite.java @@ -61,7 +61,7 @@ public class LayoutEngineTestSuite { static { DebugHelper.registerStandardElementListObservers(); } - + public static String[] readDisabledTestcases(File f) throws IOException { List lines = new java.util.ArrayList(); Source stylesheet = new StreamSource( @@ -78,7 +78,7 @@ public class LayoutEngineTestSuite { } return (String[])lines.toArray(new String[lines.size()]); } - + private static class FilenameHandler extends DefaultHandler { private StringBuffer buffer = new StringBuffer(128); private boolean readingFilename = false; @@ -88,7 +88,7 @@ public class LayoutEngineTestSuite { this.filenames = filenames; } - public void startElement(String namespaceURI, String localName, String qName, + public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { if (qName != null && qName.equals("file")) { buffer.setLength(0); @@ -99,7 +99,7 @@ public class LayoutEngineTestSuite { } } - public void endElement(String namespaceURI, String localName, String qName) + public void endElement(String namespaceURI, String localName, String qName) throws SAXException { if (qName != null && qName.equals("file")) { readingFilename = false; @@ -116,7 +116,7 @@ public class LayoutEngineTestSuite { } } } - + public static IOFileFilter decorateWithDisabledList(IOFileFilter filter) throws IOException { String disabled = System.getProperty("fop.layoutengine.disabled"); if (disabled != null && disabled.length() > 0) { @@ -126,7 +126,7 @@ public class LayoutEngineTestSuite { } return filter; } - + /** * @return a Collection of File instances containing all the test cases set up for processing. * @throws IOException if there's a problem gathering the list of test files @@ -150,18 +150,18 @@ public class LayoutEngineTestSuite { if (testset == null) { testset = "standard"; } - Collection files = FileUtils.listFiles(new File(mainDir, testset + "-testcases"), + Collection files = FileUtils.listFiles(new File(mainDir, testset + "-testcases"), filter, TrueFileFilter.INSTANCE); String privateTests = System.getProperty("fop.layoutengine.private"); if ("true".equalsIgnoreCase(privateTests)) { Collection privateFiles = FileUtils.listFiles( - new File(mainDir, "private-testcases"), + new File(mainDir, "private-testcases"), filter, TrueFileFilter.INSTANCE); files.addAll(privateFiles); } return files; } - + /** * @return the test suite with all the tests (one for each XML file) * @throws IOException in case of an I/O problem @@ -180,11 +180,11 @@ public class LayoutEngineTestSuite { File f = (File)i.next(); addTestCase(suite, tester, f); } - + return suite; } - - private static void addTestCase(TestSuite suite, + + private static void addTestCase(TestSuite suite, final LayoutEngineTester tester, final File f) { suite.addTest(new LayoutEngineTestCase(f.getName()) { public void runTest() throws Exception { @@ -199,24 +199,24 @@ public class LayoutEngineTestSuite { } }); } - + private static class LayoutEngineTestCase extends TestCase { - + private LayoutEngineTester tester; private File testFile; - + public LayoutEngineTestCase(String name) { super(name); } - + public void prepare(LayoutEngineTester tester, File testFile) { //super(testFile.getName()); this.tester = tester; this.testFile = testFile; } - + public void testMain() throws Exception { tester.runTest(testFile); } - } + } } diff --git a/test/java/org/apache/fop/layoutengine/LayoutResult.java b/test/java/org/apache/fop/layoutengine/LayoutResult.java index aa425c2ce..52c83daa8 100644 --- a/test/java/org/apache/fop/layoutengine/LayoutResult.java +++ b/test/java/org/apache/fop/layoutengine/LayoutResult.java @@ -30,7 +30,7 @@ public class LayoutResult { private Document areaTree; private ElementListCollector elCollector; private FormattingResults results; - + /** * Creates a new LayoutResult instance. * @param areaTree the area tree DOM @@ -43,12 +43,12 @@ public class LayoutResult { this.elCollector = elCollector; this.results = results; } - + /** @return the generated area tree as DOM tree */ public Document getAreaTree() { return this.areaTree; } - + /** @return the element list collector */ public ElementListCollector getElementListCollector() { return this.elCollector; @@ -60,5 +60,5 @@ public class LayoutResult { public FormattingResults getResults() { return results; } - + } diff --git a/test/java/org/apache/fop/layoutengine/ResultCheck.java b/test/java/org/apache/fop/layoutengine/ResultCheck.java index d7a55691f..54af77a43 100644 --- a/test/java/org/apache/fop/layoutengine/ResultCheck.java +++ b/test/java/org/apache/fop/layoutengine/ResultCheck.java @@ -29,7 +29,7 @@ public class ResultCheck implements LayoutEngineCheck { private String expected; private String property; - + /** * Creates a new instance * @param expected expected value @@ -39,7 +39,7 @@ public class ResultCheck implements LayoutEngineCheck { this.expected = expected; this.property = property; } - + /** * Creates a new instance from a DOM node. * @param node DOM node that defines this check @@ -48,7 +48,7 @@ public class ResultCheck implements LayoutEngineCheck { this.expected = node.getAttributes().getNamedItem("expected").getNodeValue(); this.property = node.getAttributes().getNamedItem("property").getNodeValue(); } - + /* (non-Javadoc) * @see LayoutEngineCheck#check(LayoutResult) */ @@ -62,7 +62,7 @@ public class ResultCheck implements LayoutEngineCheck { } if (!expected.equals(actual)) { throw new RuntimeException( - "Expected property to evaluate to '" + expected + "', but got '" + "Expected property to evaluate to '" + expected + "', but got '" + actual + "' (" + this + ")"); } diff --git a/test/java/org/apache/fop/layoutengine/TrueCheck.java b/test/java/org/apache/fop/layoutengine/TrueCheck.java index b4504f63e..202398d2f 100644 --- a/test/java/org/apache/fop/layoutengine/TrueCheck.java +++ b/test/java/org/apache/fop/layoutengine/TrueCheck.java @@ -36,7 +36,7 @@ public class TrueCheck implements LayoutEngineCheck { private String xpath; private String failureMessage; private PrefixResolver prefixResolver; - + /** * Creates a new instance * @param xpath XPath statement that needs to be evaluated @@ -44,7 +44,7 @@ public class TrueCheck implements LayoutEngineCheck { public TrueCheck(String xpath) { this.xpath = xpath; } - + /** * Creates a new instance from a DOM node. * @param node DOM node that defines this check @@ -57,7 +57,7 @@ public class TrueCheck implements LayoutEngineCheck { } this.prefixResolver = new PrefixResolverDefault(node); } - + /** @see org.apache.fop.layoutengine.LayoutEngineCheck */ public void check(LayoutResult result) { XObject res; @@ -71,7 +71,7 @@ public class TrueCheck implements LayoutEngineCheck { throw new RuntimeException(failureMessage); } else { throw new RuntimeException( - "Expected XPath expression to evaluate to 'true', but got '" + "Expected XPath expression to evaluate to 'true', but got '" + res + "' (" + this + ")"); } } @@ -82,5 +82,5 @@ public class TrueCheck implements LayoutEngineCheck { public String toString() { return "XPath: " + xpath; } - + } diff --git a/test/java/org/apache/fop/memory/MemoryEater.java b/test/java/org/apache/fop/memory/MemoryEater.java index 1bea0f123..bdbd47897 100644 --- a/test/java/org/apache/fop/memory/MemoryEater.java +++ b/test/java/org/apache/fop/memory/MemoryEater.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,29 +50,29 @@ public class MemoryEater { = (SAXTransformerFactory)SAXTransformerFactory.newInstance(); private FopFactory fopFactory = FopFactory.newInstance(); private Templates replicatorTemplates; - + public MemoryEater() throws TransformerConfigurationException, MalformedURLException { File xsltFile = new File("test/xsl/fo-replicator.xsl"); Source xslt = new StreamSource(xsltFile); replicatorTemplates = tFactory.newTemplates(xslt); } - + private void eatMemory(File foFile, int replicatorRepeats) throws Exception { Source src = new StreamSource(foFile); - + Transformer transformer = replicatorTemplates.newTransformer(); transformer.setParameter("repeats", new Integer(replicatorRepeats)); - + OutputStream out = new NullOutputStream(); //write to /dev/nul FOUserAgent userAgent = fopFactory.newFOUserAgent(); userAgent.setBaseURL(foFile.getParentFile().toURL().toExternalForm()); Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, userAgent, out); Result res = new SAXResult(fop.getDefaultHandler()); - + transformer.transform(src, res); - + System.out.println("Generated " + fop.getResults().getPageCount() + " pages."); - + } private static void prompt() throws IOException { @@ -80,7 +80,7 @@ public class MemoryEater { System.out.print("Press return to continue..."); in.readLine(); } - + /** * Main method. * @param args the command-line arguments @@ -97,24 +97,24 @@ public class MemoryEater { runRepeats = Integer.parseInt(args[1]); } File testFile = new File("examples/fo/basic/readme.fo"); - - System.out.println("MemoryEater! About to replicate the test file " + + System.out.println("MemoryEater! About to replicate the test file " + replicatorRepeats + " times and run it " + runRepeats + " times..."); if (doPrompt) { prompt(); } - - System.out.println("Processing..."); + + System.out.println("Processing..."); long start = System.currentTimeMillis(); - + MemoryEater app = new MemoryEater(); for (int i = 0; i < runRepeats; i++) { app.eatMemory(testFile, replicatorRepeats); } - + long duration = System.currentTimeMillis() - start; System.out.println("Success! Job took " + duration + " ms"); - + if (doPrompt) { prompt(); } diff --git a/test/java/org/apache/fop/pdf/PDFObjectTestCase.java b/test/java/org/apache/fop/pdf/PDFObjectTestCase.java index 96ac728bd..40ddec6ba 100644 --- a/test/java/org/apache/fop/pdf/PDFObjectTestCase.java +++ b/test/java/org/apache/fop/pdf/PDFObjectTestCase.java @@ -32,7 +32,7 @@ import junit.framework.TestCase; public class PDFObjectTestCase extends TestCase { /** - * Tests date/time formatting in PDFObject. + * Tests date/time formatting in PDFObject. * @throws Exception if an error occurs */ public void testDateFormatting() throws Exception { @@ -40,7 +40,7 @@ public class PDFObjectTestCase extends TestCase { cal.set(2008, Calendar.FEBRUARY, 07, 15, 11, 07); cal.set(Calendar.MILLISECOND, 0); Date dt = cal.getTime(); - + MyPDFObject obj = new MyPDFObject(); String s = obj.formatDateTime(dt, TimeZone.getTimeZone("GMT")); assertEquals("D:20080207151107Z", s); @@ -51,9 +51,9 @@ public class PDFObjectTestCase extends TestCase { s = obj.formatDateTime(dt, TimeZone.getTimeZone("GMT-08:00")); assertEquals("D:20080207071107-08'00'", s); } - + private class MyPDFObject extends PDFObject { - + } - + } diff --git a/test/java/org/apache/fop/render/pdf/BasePDFTestCase.java b/test/java/org/apache/fop/render/pdf/BasePDFTestCase.java index 29a77a932..7aaf61ea4 100644 --- a/test/java/org/apache/fop/render/pdf/BasePDFTestCase.java +++ b/test/java/org/apache/fop/render/pdf/BasePDFTestCase.java @@ -113,7 +113,7 @@ public class BasePDFTestCase extends AbstractFOPTestCase { return e; } - /** + /** * get FOP config File * @return user config file to be used for testing */ diff --git a/test/java/org/apache/fop/render/pdf/PDFAMetadataTestCase.java b/test/java/org/apache/fop/render/pdf/PDFAMetadataTestCase.java index b645022bb..886a2b97e 100644 --- a/test/java/org/apache/fop/render/pdf/PDFAMetadataTestCase.java +++ b/test/java/org/apache/fop/render/pdf/PDFAMetadataTestCase.java @@ -46,11 +46,11 @@ public class PDFAMetadataTestCase extends TestCase { dc.setTitle("MyTitle"); dc.setDescription(null, "MySubject"); dc.addCreator("That's me"); - + AdobePDFAdapter pdf = AdobePDFSchema.getAdapter(meta); pdf.setKeywords("XSL-FO XML"); pdf.setProducer("SuperFOP"); - + XMPBasicAdapter xmp = XMPBasicSchema.getAdapter(meta); xmp.setCreatorTool("WonderFOP"); Calendar cal1 = Calendar.getInstance(TimeZone.getTimeZone("Europe/Zurich")); @@ -61,11 +61,11 @@ public class PDFAMetadataTestCase extends TestCase { cal2.set(2007, Calendar.JUNE, 6, 8, 15, 59); cal2.set(Calendar.MILLISECOND, 0); xmp.setModifyDate(cal2.getTime()); - + PDFInfo info = new PDFInfo(); assertNull(info.getTitle()); PDFMetadata.updateInfoFromMetadata(meta, info); - + assertEquals("MyTitle", info.getTitle()); assertEquals("MySubject", info.getSubject()); assertEquals("That's me", info.getAuthor()); @@ -75,7 +75,7 @@ public class PDFAMetadataTestCase extends TestCase { assertEquals(cal1.getTime(), info.getCreationDate()); assertEquals(cal2.getTime(), info.getModDate()); } - + public void testXMPUpdate() throws Exception { PDFDocument doc = new PDFDocument("SuperFOP"); PDFInfo info = doc.getInfo(); @@ -93,9 +93,9 @@ public class PDFAMetadataTestCase extends TestCase { cal2.set(2007, Calendar.JUNE, 6, 8, 15, 59); cal2.set(Calendar.MILLISECOND, 0); info.setModDate(cal2.getTime()); - + Metadata meta = PDFMetadata.createXMPFromPDFDocument(doc); - + DublinCoreAdapter dc = DublinCoreSchema.getAdapter(meta); assertEquals("MyTitle", dc.getTitle()); assertEquals("MySubject", dc.getDescription()); diff --git a/test/java/org/apache/fop/render/pdf/PDFCMapTestCase.java b/test/java/org/apache/fop/render/pdf/PDFCMapTestCase.java index eb34f70b8..f5d2f84cf 100644 --- a/test/java/org/apache/fop/render/pdf/PDFCMapTestCase.java +++ b/test/java/org/apache/fop/render/pdf/PDFCMapTestCase.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.pdf.CMapBuilder; /** Simple sanity test of the PDFCmap class */ public class PDFCMapTestCase extends TestCase { - + public void testPDFCMapFillInPDF() throws Exception { final String EOL = "\n"; - final String expected = + final String expected = "%!PS-Adobe-3.0 Resource-CMap" + EOL +"%%DocumentNeededResources: ProcSet (CIDInit)" + EOL +"%%IncludeResource: ProcSet (CIDInit)" + EOL @@ -60,7 +60,7 @@ public class PDFCMapTestCase extends TestCase { +"%%EndResource" + EOL +"%%EOF" + EOL ; - + final StringWriter w = new StringWriter(); final CMapBuilder builder = new CMapBuilder(w, "test"); builder.writeCMap(); diff --git a/test/java/org/apache/fop/render/pdf/PDFEncodingTestCase.java b/test/java/org/apache/fop/render/pdf/PDFEncodingTestCase.java index c9fba08c7..b3098b859 100644 --- a/test/java/org/apache/fop/render/pdf/PDFEncodingTestCase.java +++ b/test/java/org/apache/fop/render/pdf/PDFEncodingTestCase.java @@ -59,15 +59,15 @@ public class PDFEncodingTestCase extends BasePDFTestCase { */ public void testPDFEncodingWithStandardFont() throws Exception { - /* If the PDF encoding is correct, a text dump of the generated PDF file contains this (excerpts) + /* If the PDF encoding is correct, a text dump of the generated PDF file contains this (excerpts) * ...Tm [(PDFE_TEST_MARK_2:) ( ) (This) ( ) (is) ...(acute:) ( ) (XX_\351_XX) ] TJ * ...Tm [(PDFE_TEST_MARK_3:) ( ) (This) ( ) (is) ...(letter:) ( ) (XX_\342\352\356\364\373_XX) ] TJ * The following array is used to look for these patterns - */ - final String[] testPatterns = { + */ + final String[] testPatterns = { TEST_MARKER + "1", "Standard", - TEST_MARKER + "2", "XX_\\351_XX", - TEST_MARKER + "3", "XX_\\342\\352\\356\\364\\373_XX" + TEST_MARKER + "2", "XX_\\351_XX", + TEST_MARKER + "3", "XX_\\342\\352\\356\\364\\373_XX" }; runTest("test-standard-font.fo", testPatterns); @@ -78,21 +78,21 @@ public class PDFEncodingTestCase extends BasePDFTestCase { * encoding when custom font is used. * TODO This should be tested using PDFBox. If PDFBox can extract the text correctly, * everything is fine. The tests here are too unstable. - * + * * @throws Exception * checkstyle wants a comment here, even a silly one */ public void DISABLEDtestPDFEncodingWithCustomFont() throws Exception { - /* If the PDF encoding is correct, a text dump of the generated PDF file contains this (excerpts) + /* If the PDF encoding is correct, a text dump of the generated PDF file contains this (excerpts) * ...Tm [(PDFE_TEST_MARK_2:) ( ) (This) ( ) (is) ...(acute:) ( ) (XX_\351_XX) ] TJ * ...Tm [(PDFE_TEST_MARK_3:) ( ) (This) ( ) (is) ...(letter:) ( ) (XX_\342\352\356\364\373_XX) ] TJ * The following array is used to look for these patterns - */ - final String[] testPatterns = { + */ + final String[] testPatterns = { TEST_MARKER + "1", "(Gladiator)", - TEST_MARKER + "2", "XX_\\351_XX", - TEST_MARKER + "3", "XX_\\342\\352\\356\\364\\373_XX" + TEST_MARKER + "2", "XX_\\351_XX", + TEST_MARKER + "3", "XX_\\342\\352\\356\\364\\373_XX" }; runTest("test-custom-font.fo", testPatterns); @@ -109,7 +109,7 @@ public class PDFEncodingTestCase extends BasePDFTestCase { /** * Check character encodings in the generated PDF data, by reading text * lines identified by markers and checking their content - * + * * @throws IOException */ private void checkEncoding(byte[] pdf, String[] testPattern) diff --git a/test/java/org/apache/fop/render/pdf/PDFsRGBSettingsTestCase.java b/test/java/org/apache/fop/render/pdf/PDFsRGBSettingsTestCase.java index 45f982b00..49b004e7c 100644 --- a/test/java/org/apache/fop/render/pdf/PDFsRGBSettingsTestCase.java +++ b/test/java/org/apache/fop/render/pdf/PDFsRGBSettingsTestCase.java @@ -46,7 +46,7 @@ public class PDFsRGBSettingsTestCase extends BasePDFTestCase { a.getRendererOptions().put("disable-srgb-colorspace", Boolean.TRUE); return a; } - + /** * Verify that the PDFRenderer complains if PDF/A or PDF/X is used when sRGB is disabled. * @throws Exception if the test fails @@ -60,5 +60,5 @@ public class PDFsRGBSettingsTestCase extends BasePDFTestCase { //exception expected! } } - + } diff --git a/test/java/org/apache/fop/render/rtf/Bug39607TestCase.java b/test/java/org/apache/fop/render/rtf/Bug39607TestCase.java index 950bb2e8f..a7622bc0f 100644 --- a/test/java/org/apache/fop/render/rtf/Bug39607TestCase.java +++ b/test/java/org/apache/fop/render/rtf/Bug39607TestCase.java @@ -51,7 +51,7 @@ public class Bug39607TestCase extends TestCase { paragraph.newText("Testing fop - rtf module - class RtfTableRow"); paragraph.close(); - RtfTable table = section.newTable(null); + RtfTable table = section.newTable(null); RtfTableRow row = table.newTableRow(); row.newTableCell(2000).newParagraph().newText("blah"); row.newTableCell(5000).newParagraph().newText("doubleBlah"); @@ -61,5 +61,5 @@ public class Bug39607TestCase extends TestCase { doc.close(); f.flush(); } - + } diff --git a/test/java/org/apache/fop/render/rtf/RichTextFormatTestSuite.java b/test/java/org/apache/fop/render/rtf/RichTextFormatTestSuite.java index 68189d8f5..502604344 100644 --- a/test/java/org/apache/fop/render/rtf/RichTextFormatTestSuite.java +++ b/test/java/org/apache/fop/render/rtf/RichTextFormatTestSuite.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.rtf; import junit.framework.Test; diff --git a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/BasicLink.java b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/BasicLink.java index 01160f493..a31859757 100644 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/BasicLink.java +++ b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/BasicLink.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/test/java/org/apache/fop/render/rtf/rtflib/testdocs/CreateTestDocuments.java b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/CreateTestDocuments.java index d7891e6a0..16460cd1c 100644 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/CreateTestDocuments.java +++ b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/CreateTestDocuments.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/test/java/org/apache/fop/render/rtf/rtflib/testdocs/DummyTableColumnsInfo.java b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/DummyTableColumnsInfo.java index fab59b4ed..fe5b4b6a3 100644 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/DummyTableColumnsInfo.java +++ b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/DummyTableColumnsInfo.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/test/java/org/apache/fop/render/rtf/rtflib/testdocs/ExternalGraphic.java b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/ExternalGraphic.java index 537770a84..73a451818 100644 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/ExternalGraphic.java +++ b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/ExternalGraphic.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/test/java/org/apache/fop/render/rtf/rtflib/testdocs/ListInTable.java b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/ListInTable.java index 947bbd866..adad2dfd0 100644 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/ListInTable.java +++ b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/ListInTable.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/test/java/org/apache/fop/render/rtf/rtflib/testdocs/MergedTableCells.java b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/MergedTableCells.java index 0a5fb73e0..63de9ba05 100644 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/MergedTableCells.java +++ b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/MergedTableCells.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/test/java/org/apache/fop/render/rtf/rtflib/testdocs/NestedTable.java b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/NestedTable.java index a9d005257..135dab131 100644 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/NestedTable.java +++ b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/NestedTable.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/test/java/org/apache/fop/render/rtf/rtflib/testdocs/ParagraphAlignment.java b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/ParagraphAlignment.java index c9edea0a4..17992c5d2 100644 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/ParagraphAlignment.java +++ b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/ParagraphAlignment.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/test/java/org/apache/fop/render/rtf/rtflib/testdocs/SimpleDocument.java b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/SimpleDocument.java index cae40ea66..a0772203b 100644 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/SimpleDocument.java +++ b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/SimpleDocument.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/test/java/org/apache/fop/render/rtf/rtflib/testdocs/SimpleLists.java b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/SimpleLists.java index ec9ef6878..a1cd0b8d5 100644 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/SimpleLists.java +++ b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/SimpleLists.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/test/java/org/apache/fop/render/rtf/rtflib/testdocs/SimpleTable.java b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/SimpleTable.java index 5ef1102b0..001634235 100644 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/SimpleTable.java +++ b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/SimpleTable.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/test/java/org/apache/fop/render/rtf/rtflib/testdocs/TestDocument.java b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/TestDocument.java index f64ff548b..f6d1d37a8 100644 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/TestDocument.java +++ b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/TestDocument.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/test/java/org/apache/fop/render/rtf/rtflib/testdocs/TextAttributes.java b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/TextAttributes.java index da69fb332..d91eadae8 100644 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/TextAttributes.java +++ b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/TextAttributes.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/test/java/org/apache/fop/render/rtf/rtflib/testdocs/Whitespace.java b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/Whitespace.java index 4ef9ec6d5..bf79e4ba1 100644 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/Whitespace.java +++ b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/Whitespace.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/test/java/org/apache/fop/text/linebreak/LineBreakStatusTest.java b/test/java/org/apache/fop/text/linebreak/LineBreakStatusTest.java index f832d0896..8d2936127 100644 --- a/test/java/org/apache/fop/text/linebreak/LineBreakStatusTest.java +++ b/test/java/org/apache/fop/text/linebreak/LineBreakStatusTest.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 LineBreakStatusTest extends TestCase { /* * These symbols are used to indicate the break action returned * by the paragraph breaking. Their meaning is as per Unicode - * technical + * technical * report #14. */ private static final String BREAK_ACTION = "_%#@^!"; @@ -51,7 +51,7 @@ public class LineBreakStatusTest extends TestCase { */ public static Test suite() { TestSuite suite = new TestSuite(LineBreakStatusTest.class); - + return suite; } @@ -69,106 +69,106 @@ public class LineBreakStatusTest extends TestCase { */ public void testNextChar() { System.out.println("testNextChar"); - + // AL -- Ordinary Alphabetic and Symbol Characters (XP) assertTrue(testBreak( - "Nobreak", + "Nobreak", "^^^^^^^" )); - + // BA -- Break Opportunity After (A) assertTrue(testBreak( - "Thin Space" + "\u2009" + "break", + "Thin Space" + "\u2009" + "break", "^^^^^%^^^^" + "^" + "_^^^^" )); assertTrue(testBreak( - "Shy" + "\u00AD" + "break", + "Shy" + "\u00AD" + "break", "^^^" + "^" + "_^^^^" )); // BB -- Break opportunites before characters (B) assertTrue(testBreak( - "Acute Accent" + "\u00B4" + "break", + "Acute Accent" + "\u00B4" + "break", "^^^^^^%^^^^^" + "_" + "^^^^^" )); // B2 -- Break Opportunity Before and After (B/A/XP) assertTrue(testBreak( - "Em Dash" + "\u2014" + "break", + "Em Dash" + "\u2014" + "break", "^^^%^^^" + "_" + "_^^^^" )); assertTrue(testBreak( - "Em Dash Dash" + "\u2014" + "\u2014" + "break", + "Em Dash Dash" + "\u2014" + "\u2014" + "break", "^^^%^^^^%^^^" + "_" + "^" + "_^^^^" )); // BK Mandatory Break (A) -- normative assertTrue(testBreak( - "Form Feed" + "\u000C" + "break", + "Form Feed" + "\u000C" + "break", "^^^^^%^^^" + "^" + "!^^^^" )); assertTrue(testBreak( - "Line Separator" + "\u2028" + "break", + "Line Separator" + "\u2028" + "break", "^^^^^%^^^^^^^^" + "^" + "!^^^^" )); assertTrue(testBreak( - "Paragraph Separator" + "\u2029" + "break", + "Paragraph Separator" + "\u2029" + "break", "^^^^^^^^^^%^^^^^^^^" + "^" + "!^^^^" )); // CB Contingent Break Opportunity (B/A) -- normative // TODO Don't know quite what to do here - + // CL -- Closing Punctuation (XB) assertTrue(testBreak( - "Right Parenthesis ) break", + "Right Parenthesis ) break", "^^^^^^%^^^^^^^^^^^^^%^^^^" )); - + // CM -- Attached Characters and Combining Marks (XB) -- normative assertTrue(testBreak( - "Grave Accent" + "\u0300" + " break", + "Grave Accent" + "\u0300" + " break", "^^^^^^%^^^^^" + "^" + "^%^^^^" )); - + // CR -- Carriage Return (A) -- normative assertTrue(testBreak( - "CR" + "\r" + "break", + "CR" + "\r" + "break", "^^" + "^" + "!^^^^" )); - + assertTrue(testBreak( - "CRLF" + "\r\n" + "break", + "CRLF" + "\r\n" + "break", "^^^^" + "^^" + "!^^^^" )); - + // EX -- Exclamation / interrogation (XB) assertTrue(testBreak( - "EX CL ! ) break", + "EX CL ! ) break", "^^^%^^^^^^%^^^^" )); - + assertTrue(testBreak( - "EX Wave Dash ! " + "\u301C" + " break", + "EX Wave Dash ! " + "\u301C" + " break", "^^^%^^^^%^^^^^^" + "%" + "^_^^^^" )); - + // GL -- Non-breaking ("Glue") (XB/XA) -- normative assertTrue(testBreak( - "No" + "\u00a0" + "break", + "No" + "\u00a0" + "break", "^^" + "^" + "^^^^^" )); - + assertTrue(testBreak( - "Non" + "\u2011" + " Hyphen", + "Non" + "\u2011" + " Hyphen", "^^^" + "^" + "^%^^^^^" )); - + // H2 -- Hangul LVT Syllable (B/A) // TODO @@ -177,40 +177,40 @@ public class LineBreakStatusTest extends TestCase { // HY -- Hyphen Minus assertTrue(testBreak( - "Normal-Hyphen", + "Normal-Hyphen", "^^^^^^^_^^^^^" )); assertTrue(testBreak( - "Normal - Hyphen", + "Normal - Hyphen", "^^^^^^^%^_^^^^^" )); assertTrue(testBreak( - "123-456", + "123-456", "^^^^^^^" )); assertTrue(testBreak( - "123 - 456", + "123 - 456", "^^^^%^%^^" )); // ID -- Ideographic (B/A) assertTrue(testBreak( - "\u4E00" + "\u3000" + "\u4E02", + "\u4E00" + "\u3000" + "\u4E02", "^" + "_" + "_" )); // IN -- Inseperable characters (XP) assertTrue(testBreak( - "IN " + "\u2024" + "\u2025" + "\u2026", + "IN " + "\u2024" + "\u2025" + "\u2026", "^^^" + "%" + "^" + "^" )); // IS -- Numeric Separator (Infix) (XB) assertTrue(testBreak( - "123,456.00 12:59", + "123,456.00 12:59", "^^^^^^^^^^^%^^^^" )); @@ -225,13 +225,13 @@ public class LineBreakStatusTest extends TestCase { // LF -- Line Feed (A) -- normative assertTrue(testBreak( - "Simple" + "\n" + "\n" + "break", + "Simple" + "\n" + "\n" + "break", "^^^^^^" + "^" + "!" + "!^^^^" )); // NL -- Next Line (A) -- normative assertTrue(testBreak( - "NL" + "\u0085" + "break", + "NL" + "\u0085" + "break", "^^" + "^" + "!^^^^" )); @@ -243,80 +243,80 @@ public class LineBreakStatusTest extends TestCase { // OP -- Opening Punctuation (XA) assertTrue(testBreak( - "[ Bracket ( Parenthesis", + "[ Bracket ( Parenthesis", "^^^^^^^^^^%^^^^^^^^^^^^" )); - + // PO -- Postfix (Numeric) (XB) assertTrue(testBreak( - "(12.00)%", + "(12.00)%", "^^^^^^^^" )); // PR -- Prefix (Numeric) (XA) assertTrue(testBreak( - "$1000.00", + "$1000.00", "^^^^^^^^" )); // QU -- Ambiguous Quotation (XB/XA) assertTrue(testBreak( - "'In Quotes'", + "'In Quotes'", "^^^^%^^^^^^" )); assertTrue(testBreak( - "' (In Quotes) '", + "' (In Quotes) '", "^^^^^^%^^^^^^^%" )); // SA -- Complex-context Dependent Characters (South East Asian) (P) // TODO - + // SP -- Space (A) -- normative assertTrue(testBreak( - "Simple break", + "Simple break", "^^^^^^^%^^^^" )); assertTrue(testBreak( - "Simple break2", + "Simple break2", "^^^^^^^^^^%^^^^^" )); // SY -- Symbols Allowing Break After (A) assertTrue(testBreak( - "http://xmlgraphics.apache.org/fop", + "http://xmlgraphics.apache.org/fop", "^^^^^^^_^^^^^^^^^^^^^^^^^^^^^^_^^" )); assertTrue(testBreak( - "1/2 31/10/2005", + "1/2 31/10/2005", "^^^^%^^^^^^^^^" )); // WJ -- Word Joiner (XA/XB) -- (normative) assertTrue(testBreak( - "http://" + "\u2060" + "xmlgraphics.apache.org/" + "\uFEFF" + "fop", + "http://" + "\u2060" + "xmlgraphics.apache.org/" + "\uFEFF" + "fop", "^^^^^^^" + "^" + "^^^^^^^^^^^^^^^^^^^^^^^" + "^" + "^^^" )); assertTrue(testBreak( - "Simple " + "\u2060" + "break", + "Simple " + "\u2060" + "break", "^^^^^^^" + "^" + "^^^^^" )); assertTrue(testBreak( - "Simple" + "\u200B" + "\u2060" + "break", + "Simple" + "\u200B" + "\u2060" + "break", "^^^^^^" + "^" + "_" + "^^^^^" )); // XX -- Unknown (XP) // TODO - + // ZW -- Zero Width Space (A) -- (normative) assertTrue(testBreak( - "Simple" + "\u200B" + "break", + "Simple" + "\u200B" + "break", "^^^^^^" + "^" + "_^^^^" )); @@ -340,8 +340,8 @@ public class LineBreakStatusTest extends TestCase { if (BREAK_ACTION.charAt(breakAction) != breakActions.charAt(i)) { System.err.println(paragraph); System.err.println(breakActions); - System.err.println("pos = " + i - + " expected '" + breakActions.charAt(i) + System.err.println("pos = " + i + + " expected '" + breakActions.charAt(i) + "' got '" + BREAK_ACTION.charAt(breakAction) + "'"); result = false; } diff --git a/test/java/org/apache/fop/text/linebreak/LineBreakUtilsTest.java b/test/java/org/apache/fop/text/linebreak/LineBreakUtilsTest.java index 22b8f73f3..31ad950c7 100644 --- a/test/java/org/apache/fop/text/linebreak/LineBreakUtilsTest.java +++ b/test/java/org/apache/fop/text/linebreak/LineBreakUtilsTest.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. @@ -23,7 +23,7 @@ import junit.framework.TestCase; /** * TODO add javadoc - * + * * */ public class LineBreakUtilsTest extends TestCase { diff --git a/test/java/org/apache/fop/threading/FOPTestbed.java b/test/java/org/apache/fop/threading/FOPTestbed.java index 875c04617..7ced868c4 100644 --- a/test/java/org/apache/fop/threading/FOPTestbed.java +++ b/test/java/org/apache/fop/threading/FOPTestbed.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,7 +46,7 @@ import org.apache.commons.io.IOUtils; * Testbed for multi-threading tests. The class can run a configurable set of task a number of * times in a configurable number of threads to easily reproduce multi-threading issues. */ -public class FOPTestbed extends AbstractLogEnabled +public class FOPTestbed extends AbstractLogEnabled implements Configurable, Initializable { private int repeat; @@ -57,7 +57,7 @@ public class FOPTestbed extends AbstractLogEnabled private FOProcessor foprocessor; private int counter = 0; - + /** {@inheritDoc} */ public void configure(Configuration configuration) throws ConfigurationException { this.threads = configuration.getChild("threads").getValueAsInteger(10); @@ -83,7 +83,7 @@ public class FOPTestbed extends AbstractLogEnabled getLogger().info("Starting stress test..."); long start = System.currentTimeMillis(); this.counter = 0; - + //Initialize threads List threadList = new java.util.LinkedList(); for (int ti = 0; ti < this.threads; ti++) { @@ -92,13 +92,13 @@ public class FOPTestbed extends AbstractLogEnabled Thread thread = new Thread(runner); threadList.add(thread); } - + //Start threads Iterator i = threadList.iterator(); while (i.hasNext()) { ((Thread)i.next()).start(); } - + //Wait for threads to end while (threadList.size() > 0) { Thread t = (Thread)threadList.get(0); @@ -116,7 +116,7 @@ public class FOPTestbed extends AbstractLogEnabled } private class TaskRunner extends AbstractLogEnabled implements Runnable { - + public void run() { try { for (int r = 0; r < repeat; r++) { @@ -134,14 +134,14 @@ public class FOPTestbed extends AbstractLogEnabled } } - + /** * Creates a new FOProcessor. * @return the newly created instance */ public FOProcessor createFOProcessor() { try { - Class clazz = Class.forName(this.fopCfg.getAttribute("class", + Class clazz = Class.forName(this.fopCfg.getAttribute("class", "org.apache.fop.threading.FOProcessorImpl")); FOProcessor fop = (FOProcessor)clazz.newInstance(); ContainerUtil.enableLogging(fop, getLogger()); @@ -152,7 +152,7 @@ public class FOPTestbed extends AbstractLogEnabled throw new CascadingRuntimeException("Error creating FO Processor", e); } } - + private class TaskDef { private String fo; @@ -228,7 +228,7 @@ public class FOPTestbed extends AbstractLogEnabled try { InputStream in; Templates templates; - + if (def.getFO() != null) { in = new java.io.FileInputStream(new File(def.getFO())); templates = null; diff --git a/test/java/org/apache/fop/threading/FOProcessor.java b/test/java/org/apache/fop/threading/FOProcessor.java index a6b3dd7ec..05c8f6fe1 100644 --- a/test/java/org/apache/fop/threading/FOProcessor.java +++ b/test/java/org/apache/fop/threading/FOProcessor.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/test/java/org/apache/fop/threading/FOProcessorImpl.java b/test/java/org/apache/fop/threading/FOProcessorImpl.java index e913e9a79..4ba7da658 100644 --- a/test/java/org/apache/fop/threading/FOProcessorImpl.java +++ b/test/java/org/apache/fop/threading/FOProcessorImpl.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. @@ -71,7 +71,7 @@ public class FOProcessorImpl extends AbstractLogEnabled } /** {@inheritDoc} */ - public void process(InputStream in, Templates templates, OutputStream out) + public void process(InputStream in, Templates templates, OutputStream out) throws org.apache.fop.apps.FOPException, java.io.IOException { FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); Fop fop = fopFactory.newFop(this.mime, foUserAgent, out); diff --git a/test/java/org/apache/fop/threading/Main.java b/test/java/org/apache/fop/threading/Main.java index e7f011ada..8363898ae 100644 --- a/test/java/org/apache/fop/threading/Main.java +++ b/test/java/org/apache/fop/threading/Main.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 Main { System.out.print("Press return to continue..."); in.readLine(); } - + /** * Main method. * @param args the command-line arguments @@ -50,21 +50,21 @@ public class Main { File cfgFile = new File(args[0]); DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder(); Configuration cfg = builder.buildFromFile(cfgFile); - + boolean doPrompt = cfg.getAttributeAsBoolean("prompt", false); if (doPrompt) { prompt(); } - + //Setup testbed FOPTestbed testbed = new FOPTestbed(); ContainerUtil.enableLogging(testbed, new ConsoleLogger(ConsoleLogger.LEVEL_INFO)); ContainerUtil.configure(testbed, cfg); ContainerUtil.initialize(testbed); - + //Start tests testbed.doStressTest(); - + System.exit(0); } catch (Exception e) { System.err.println(ExceptionUtil.printStackTrace(e)); diff --git a/test/java/org/apache/fop/traits/BorderPropsTestCase.java b/test/java/org/apache/fop/traits/BorderPropsTestCase.java index 2dea98b13..6aea38512 100644 --- a/test/java/org/apache/fop/traits/BorderPropsTestCase.java +++ b/test/java/org/apache/fop/traits/BorderPropsTestCase.java @@ -39,18 +39,18 @@ public class BorderPropsTestCase extends TestCase { Color col = new Color(1.0f, 1.0f, 0.5f, 1.0f); //Normalize: Avoid false alarms due to color conversion (rounding) col = ColorUtil.parseColorString(null, ColorUtil.colorToString(col)); - - BorderProps b1 = new BorderProps(Constants.EN_DOUBLE, 1250, + + BorderProps b1 = new BorderProps(Constants.EN_DOUBLE, 1250, col, BorderProps.COLLAPSE_OUTER); String ser = b1.toString(); BorderProps b2 = BorderProps.valueOf(null, ser); assertEquals(b1, b2); - b1 = new BorderProps(Constants.EN_INSET, 9999, + b1 = new BorderProps(Constants.EN_INSET, 9999, col, BorderProps.SEPARATE); ser = b1.toString(); b2 = BorderProps.valueOf(null, ser); assertEquals(b1, b2); } - + } diff --git a/test/java/org/apache/fop/util/AdvancedMessageFormatTestCase.java b/test/java/org/apache/fop/util/AdvancedMessageFormatTestCase.java index c0e003573..3d7e72d87 100644 --- a/test/java/org/apache/fop/util/AdvancedMessageFormatTestCase.java +++ b/test/java/org/apache/fop/util/AdvancedMessageFormatTestCase.java @@ -36,7 +36,7 @@ public class AdvancedMessageFormatTestCase extends TestCase { public void testFormatting() throws Exception { String msg; AdvancedMessageFormat format; - + String pattern = "Element \"{elementName}\" is missing[ required property \"{propertyName}\"]!"; format = new AdvancedMessageFormat(pattern); @@ -45,14 +45,14 @@ public class AdvancedMessageFormatTestCase extends TestCase { params.put("node", new Object()); params.put("elementName", "fo:external-graphic"); params.put("propertyName", "src"); - + msg = format.format(params); assertEquals("Element \"fo:external-graphic\" is missing required property \"src\"!", msg); - + params.remove("propertyName"); msg = format.format(params); assertEquals("Element \"fo:external-graphic\" is missing!", msg); - + pattern = "Testing \\{escaped \\[characters\\], now a normal field {elementName}!"; format = new AdvancedMessageFormat(pattern); @@ -61,11 +61,11 @@ public class AdvancedMessageFormatTestCase extends TestCase { pattern = "Multi-conditional: [case1: {var1}|case2: {var2}|case3: {var3}]"; format = new AdvancedMessageFormat(pattern); - + params = new java.util.HashMap(); msg = format.format(params); assertEquals("Multi-conditional: ", msg); - + params.put("var3", "value3"); msg = format.format(params); assertEquals("Multi-conditional: case3: value3", msg); @@ -73,11 +73,11 @@ public class AdvancedMessageFormatTestCase extends TestCase { msg = format.format(params); assertEquals("Multi-conditional: case1: value1", msg); } - + public void testObjectFormatting() throws Exception { String msg; AdvancedMessageFormat format; - + String pattern = "Here's a Locator: {locator}"; format = new AdvancedMessageFormat(pattern); @@ -87,15 +87,15 @@ public class AdvancedMessageFormatTestCase extends TestCase { loc.setColumnNumber(7); loc.setLineNumber(12); params.put("locator", loc); - + msg = format.format(params); assertEquals("Here\'s a Locator: 12:7", msg); } - + public void testIfFormatting() throws Exception { String msg; AdvancedMessageFormat format; - + format = new AdvancedMessageFormat("You are{isBad,if, not} nice!"); Map params = new java.util.HashMap(); @@ -138,11 +138,11 @@ public class AdvancedMessageFormatTestCase extends TestCase { msg = format.format(params); assertEquals("You are very, very nice!", msg); } - + public void testEqualsFormatting() throws Exception { String msg; AdvancedMessageFormat format; - + format = new AdvancedMessageFormat( "Error{severity,equals,EventSeverity:FATAL,,\nSome explanation!}"); @@ -156,11 +156,11 @@ public class AdvancedMessageFormatTestCase extends TestCase { msg = format.format(params); assertEquals("Error\nSome explanation!", msg); } - + public void testChoiceFormatting() throws Exception { String msg; AdvancedMessageFormat format; - + format = new AdvancedMessageFormat( "You have {amount,choice,0#nothing|0<{amount} bucks|100 * Here's what the configuration element looks like for the class: @@ -52,7 +52,7 @@ import org.apache.fop.apps.FopFactory; * * *

    - * You will notice the three parameters in curly braces (java.util.MessageFormat style) to the + * You will notice the three parameters in curly braces (java.util.MessageFormat style) to the * converter call: *

      *
    • 0: the input file @@ -62,15 +62,15 @@ import org.apache.fop.apps.FopFactory; *

      * The "delete-temp-files" element is optional and defaults to true. */ -public abstract class AbstractPSPDFBitmapProducer extends AbstractBitmapProducer +public abstract class AbstractPSPDFBitmapProducer extends AbstractBitmapProducer implements Configurable { // configure fopFactory as desired private FopFactory fopFactory = FopFactory.newInstance(); - + private String converter; private boolean deleteTempFiles; - + /** @see org.apache.avalon.framework.configuration.Configurable */ public void configure(Configuration cfg) throws ConfigurationException { this.converter = cfg.getChild("converter").getValue(); @@ -86,9 +86,9 @@ public abstract class AbstractPSPDFBitmapProducer extends AbstractBitmapProducer */ public void convert(File inFile, File outFile, ProducerContext context) throws IOException { outFile.delete(); - + //Build command-line - String cmd = MessageFormat.format(converter, + String cmd = MessageFormat.format(converter, new Object[] {inFile.toString(), outFile.toString(), Integer.toString(context.getTargetResolution())}); ConvertUtils.convert(cmd, null, null, log); @@ -97,17 +97,17 @@ public abstract class AbstractPSPDFBitmapProducer extends AbstractBitmapProducer throw new IOException("The target file has not been generated"); } } - + /** - * @return the native extension generated by the output format, ex. "ps" or "pdf". + * @return the native extension generated by the output format, ex. "ps" or "pdf". */ protected abstract String getTargetExtension(); - + /** * @return the output format for the FOP renderer, i.e. a MIME type. */ protected abstract String getTargetFormat(); - + /** @see org.apache.fop.visual.BitmapProducer */ public BufferedImage produce(File src, ProducerContext context) { try { @@ -115,9 +115,9 @@ public abstract class AbstractPSPDFBitmapProducer extends AbstractBitmapProducer userAgent.setTargetResolution(context.getTargetResolution()); userAgent.setBaseURL(src.getParentFile().toURL().toString()); - File tempOut = new File(context.getTargetDir(), + File tempOut = new File(context.getTargetDir(), src.getName() + "." + getTargetExtension()); - File tempPNG = new File(context.getTargetDir(), + File tempPNG = new File(context.getTargetDir(), src.getName() + "." + getTargetExtension() + ".png"); try { OutputStream out = new FileOutputStream(tempOut); @@ -125,13 +125,13 @@ public abstract class AbstractPSPDFBitmapProducer extends AbstractBitmapProducer try { Fop fop = fopFactory.newFop(getTargetFormat(), userAgent, out); SAXResult res = new SAXResult(fop.getDefaultHandler()); - + Transformer transformer = getTransformer(context); transformer.transform(new StreamSource(src), res); } finally { IOUtils.closeQuietly(out); } - + convert(tempOut, tempPNG, context); BufferedImage img = BitmapComparator.getImage(tempPNG); return img; diff --git a/test/java/org/apache/fop/visual/AbstractRedirectorLineHandler.java b/test/java/org/apache/fop/visual/AbstractRedirectorLineHandler.java index 5b397c5f9..344d3199e 100644 --- a/test/java/org/apache/fop/visual/AbstractRedirectorLineHandler.java +++ b/test/java/org/apache/fop/visual/AbstractRedirectorLineHandler.java @@ -23,7 +23,7 @@ package org.apache.fop.visual; * Abstract base implementation for a RedirectorLineHandler which provides empty notifyStart() * and notifyEnd() methods. */ -public abstract class AbstractRedirectorLineHandler +public abstract class AbstractRedirectorLineHandler implements RedirectorLineHandler { /** @see org.apache.fop.visual.RedirectorLineHandler#notifyStart() */ diff --git a/test/java/org/apache/fop/visual/BatchDiffer.java b/test/java/org/apache/fop/visual/BatchDiffer.java index c2faba37b..e0c78135e 100644 --- a/test/java/org/apache/fop/visual/BatchDiffer.java +++ b/test/java/org/apache/fop/visual/BatchDiffer.java @@ -89,7 +89,7 @@ import org.apache.fop.layoutengine.LayoutEngineTestSuite; * source files with. Default: no stylesheet, identity transform. *

      * The "producers" element contains a list of producer implementations with configuration. - * The "classname" attribute specifies the fully qualified class name for the implementation. + * The "classname" attribute specifies the fully qualified class name for the implementation. */ public class BatchDiffer { @@ -114,7 +114,7 @@ public class BatchDiffer { * @throws SAXException In case of a problem during SAX processing * @throws IOException In case of a I/O problem */ - public void runBatch(File cfgFile) + public void runBatch(File cfgFile) throws ConfigurationException, SAXException, IOException { DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder(); Configuration cfg = cfgBuilder.buildFromFile(cfgFile); @@ -141,7 +141,7 @@ public class BatchDiffer { } } BitmapProducer[] producers = getProducers(cfg.getChild("producers")); - + //Set up directories File srcDir = new File(cfg.getChild("source-directory").getValue()); if (!srcDir.exists()) { @@ -153,12 +153,12 @@ public class BatchDiffer { throw new RuntimeException("target-directory is invalid: " + targetDir); } context.setTargetDir(targetDir); - + boolean stopOnException = cfg.getChild("stop-on-exception").getValueAsBoolean(true); final boolean createDiffs = cfg.getChild("create-diffs").getValueAsBoolean(true); - + //RUN! - + IOFileFilter filter = new SuffixFileFilter(new String[] {".xml", ".fo"}); //Same filtering as in layout engine tests if (cfg.getChild("filter-disabled").getValueAsBoolean(true)) { @@ -191,10 +191,10 @@ public class BatchDiffer { } //Create combined image if (bitmaps[0] == null) { - throw new RuntimeException("First producer didn't return a bitmap for " + throw new RuntimeException("First producer didn't return a bitmap for " + f + ". Cannot continue."); } - + Runnable runnable = new Runnable() { public void run() { try { @@ -226,11 +226,11 @@ public class BatchDiffer { throw new RuntimeException("Error while configuring BatchDiffer: " + e.getMessage()); } } - + private void saveBitmaps(File targetDir, File srcFile, boolean createDiffs, BufferedImage[] bitmaps) throws IOException { BufferedImage combined = BitmapComparator.buildCompareImage(bitmaps); - + //Save combined bitmap as PNG file File outputFile = new File(targetDir, srcFile.getName() + "._combined.png"); ImageWriterUtil.saveAsPNG(combined, outputFile); @@ -244,7 +244,7 @@ public class BatchDiffer { } } } - + private BitmapProducer[] getProducers(Configuration cfg) { Configuration[] children = cfg.getChildren("producer"); BitmapProducer[] producers = new BitmapProducer[children.length]; @@ -260,7 +260,7 @@ public class BatchDiffer { } return producers; } - + /** * Main method. * @param args command-line arguments @@ -278,16 +278,16 @@ public class BatchDiffer { printUsage(); System.exit(-1); } - + Thread.currentThread().setPriority(Thread.MIN_PRIORITY); BatchDiffer differ = new BatchDiffer(); differ.runBatch(cfgFile); - + System.out.println("Regular exit..."); } catch (Exception e) { System.out.println("Exception caught..."); e.printStackTrace(); } } - + } diff --git a/test/java/org/apache/fop/visual/BitmapComparator.java b/test/java/org/apache/fop/visual/BitmapComparator.java index 70a627d7e..650554f37 100644 --- a/test/java/org/apache/fop/visual/BitmapComparator.java +++ b/test/java/org/apache/fop/visual/BitmapComparator.java @@ -39,8 +39,8 @@ import org.apache.commons.io.IOUtils; /** * Helper class to visually compare two bitmap images. *

      - * This class was created by extracting reusable code from - * org.apache.batik.test.util.ImageCompareText (Apache Batik) + * This class was created by extracting reusable code from + * org.apache.batik.test.util.ImageCompareText (Apache Batik) * into this separate class. *

      * TODO Move as utility class to XML Graphics Commons when possible @@ -51,7 +51,7 @@ public class BitmapComparator { * Builds a new BufferedImage that is the difference between the two input images * @param ref the reference bitmap * @param gen the newly generated bitmap - * @return the diff bitmap + * @return the diff bitmap */ public static BufferedImage buildDiffImage(BufferedImage ref, BufferedImage gen) { @@ -104,7 +104,7 @@ public class BitmapComparator { ColorModel cm = gen.getColorModel(); cm = GraphicsUtil.coerceData(genWR, cm, false); } - + if (!refPre) { ColorModel cm = ref.getColorModel(); cm = GraphicsUtil.coerceData(refWR, cm, false); @@ -114,14 +114,14 @@ public class BitmapComparator { } /** - * Builds a combined image that places a number of images next to each other for - * manual, visual comparison. + * Builds a combined image that places a number of images next to each other for + * manual, visual comparison. * @param images the array of bitmaps * @return the combined image */ public static BufferedImage buildCompareImage(BufferedImage[] images) { BufferedImage cmp = new BufferedImage( - images[0].getWidth() * images.length, + images[0].getWidth() * images.length, images[0].getHeight(), BufferedImage.TYPE_INT_ARGB); Graphics2D g = cmp.createGraphics(); @@ -145,8 +145,8 @@ public class BitmapComparator { } /** - * Builds a combined image that places two images next to each other for - * manual, visual comparison. + * Builds a combined image that places two images next to each other for + * manual, visual comparison. * @param ref the reference image * @param gen the actual image * @return the combined image @@ -155,7 +155,7 @@ public class BitmapComparator { BufferedImage gen) { return buildCompareImage(new BufferedImage[] {ref, gen}); } - + /** * Loads an image from a URL * @param url the URL to the image @@ -173,7 +173,7 @@ public class BitmapComparator { if (red == null) { return null; } - + BufferedImage img = new BufferedImage(red.getWidth(), red.getHeight(), BufferedImage.TYPE_INT_ARGB); @@ -192,7 +192,7 @@ public class BitmapComparator { InputStream in = new java.io.FileInputStream(bitmapFile); try { in = new java.io.BufferedInputStream(in); - + ImageTagRegistry reg = ImageTagRegistry.getRegistry(); Filter filt = reg.readStream(in); if (filt == null) { @@ -203,7 +203,7 @@ public class BitmapComparator { if (red == null) { return null; } - + BufferedImage img = new BufferedImage(red.getWidth(), red.getHeight(), BufferedImage.TYPE_INT_ARGB); diff --git a/test/java/org/apache/fop/visual/BitmapProducer.java b/test/java/org/apache/fop/visual/BitmapProducer.java index 4a16bd276..6aba0296a 100644 --- a/test/java/org/apache/fop/visual/BitmapProducer.java +++ b/test/java/org/apache/fop/visual/BitmapProducer.java @@ -35,5 +35,5 @@ public interface BitmapProducer { * @return the generated BufferedImage */ BufferedImage produce(File src, ProducerContext context); - + } diff --git a/test/java/org/apache/fop/visual/BitmapProducerJava2D.java b/test/java/org/apache/fop/visual/BitmapProducerJava2D.java index c445fe078..13f26e022 100644 --- a/test/java/org/apache/fop/visual/BitmapProducerJava2D.java +++ b/test/java/org/apache/fop/visual/BitmapProducerJava2D.java @@ -55,7 +55,7 @@ public class BitmapProducerJava2D extends AbstractBitmapProducer implements Conf // configure fopFactory as desired private FopFactory fopFactory = FopFactory.newInstance(); - + private boolean deleteTempFiles; /** @see org.apache.avalon.framework.configuration.Configurable */ @@ -69,20 +69,20 @@ public class BitmapProducerJava2D extends AbstractBitmapProducer implements Conf FOUserAgent userAgent = fopFactory.newFOUserAgent(); userAgent.setTargetResolution(context.getTargetResolution()); userAgent.setBaseURL(src.getParentFile().toURL().toString()); - + File outputFile = new File(context.getTargetDir(), src.getName() + ".java2d.png"); OutputStream out = new FileOutputStream(outputFile); out = new BufferedOutputStream(out); try { Fop fop = fopFactory.newFop(MimeConstants.MIME_PNG, userAgent, out); SAXResult res = new SAXResult(fop.getDefaultHandler()); - + Transformer transformer = getTransformer(context); transformer.transform(new StreamSource(src), res); } finally { IOUtils.closeQuietly(out); } - + BufferedImage img = BitmapComparator.getImage(outputFile); if (deleteTempFiles) { if (!outputFile.delete()) { diff --git a/test/java/org/apache/fop/visual/BitmapProducerPDF.java b/test/java/org/apache/fop/visual/BitmapProducerPDF.java index a7f2f1849..a6f667f80 100644 --- a/test/java/org/apache/fop/visual/BitmapProducerPDF.java +++ b/test/java/org/apache/fop/visual/BitmapProducerPDF.java @@ -22,7 +22,7 @@ package org.apache.fop.visual; import org.apache.fop.apps.MimeConstants; /** - * BitmapProducer implementation that uses the PDFRenderer and an external converter + * BitmapProducer implementation that uses the PDFRenderer and an external converter * to create bitmaps. *

      * See the superclass' javadoc for info on the configuration format. @@ -33,10 +33,10 @@ public class BitmapProducerPDF extends AbstractPSPDFBitmapProducer { protected String getTargetExtension() { return "pdf"; } - + /** @see org.apache.fop.visual.AbstractPSPDFBitmapProducer#getTargetFormat() */ protected String getTargetFormat() { return MimeConstants.MIME_PDF; } - + } diff --git a/test/java/org/apache/fop/visual/BitmapProducerPS.java b/test/java/org/apache/fop/visual/BitmapProducerPS.java index a60346254..704cfb950 100644 --- a/test/java/org/apache/fop/visual/BitmapProducerPS.java +++ b/test/java/org/apache/fop/visual/BitmapProducerPS.java @@ -22,7 +22,7 @@ package org.apache.fop.visual; import org.apache.fop.apps.MimeConstants; /** - * BitmapProducer implementation that uses the PSRenderer and an external converter + * BitmapProducer implementation that uses the PSRenderer and an external converter * to create bitmaps. *

      * See the superclass' javadoc for info on the configuration format. @@ -33,11 +33,11 @@ public class BitmapProducerPS extends AbstractPSPDFBitmapProducer { protected String getTargetExtension() { return "ps"; } - + /** @see org.apache.fop.visual.AbstractPSPDFBitmapProducer#getTargetFormat() */ protected String getTargetFormat() { return MimeConstants.MIME_POSTSCRIPT; } - + } diff --git a/test/java/org/apache/fop/visual/ConvertUtils.java b/test/java/org/apache/fop/visual/ConvertUtils.java index cdfa0efb1..e83322f90 100644 --- a/test/java/org/apache/fop/visual/ConvertUtils.java +++ b/test/java/org/apache/fop/visual/ConvertUtils.java @@ -32,14 +32,14 @@ public class ConvertUtils { /** * Calls an external converter application (GhostScript, for example). * @param cmd the full command - * @param envp array of strings, each element of which has environment variable settings + * @param envp array of strings, each element of which has environment variable settings * in format name=value. - * @param workDir the working directory of the subprocess, or null if the subprocess should + * @param workDir the working directory of the subprocess, or null if the subprocess should * inherit the working directory of the current process. * @param log the logger to log output by the external application to * @throws IOException in case the external call fails */ - public static void convert(String cmd, String[] envp, File workDir, final Log log) + public static void convert(String cmd, String[] envp, File workDir, final Log log) throws IOException { log.debug(cmd); @@ -53,7 +53,7 @@ public class ConvertUtils { log.error("ERR> " + line); } }; - StreamRedirector errorRedirector + StreamRedirector errorRedirector = new StreamRedirector(process.getErrorStream(), errorHandler); //Redirect stdout output @@ -62,11 +62,11 @@ public class ConvertUtils { log.debug("OUT> " + line); } }; - StreamRedirector outputRedirector + StreamRedirector outputRedirector = new StreamRedirector(process.getInputStream(), outputHandler); new Thread(errorRedirector).start(); new Thread(outputRedirector).start(); - + process.waitFor(); } catch (java.lang.InterruptedException ie) { throw new IOException("The call to the external converter failed: " + ie.getMessage()); @@ -76,11 +76,11 @@ public class ConvertUtils { int exitValue = process.exitValue(); if (exitValue != 0) { - throw new IOException("The call to the external converter failed. Result: " + throw new IOException("The call to the external converter failed. Result: " + exitValue); } } - - + + } diff --git a/test/java/org/apache/fop/visual/ProducerContext.java b/test/java/org/apache/fop/visual/ProducerContext.java index 11e103a73..214820c82 100644 --- a/test/java/org/apache/fop/visual/ProducerContext.java +++ b/test/java/org/apache/fop/visual/ProducerContext.java @@ -33,7 +33,7 @@ public class ProducerContext { private Templates templates; private int targetResolution; private File targetDir; - + /** * @return the TransformerFactory to be used. */ @@ -43,7 +43,7 @@ public class ProducerContext { } return tFactory; } - + /** * @return the requested bitmap resolution in dpi for all bitmaps. */ @@ -73,14 +73,14 @@ public class ProducerContext { public void setTemplates(Templates templates) { this.templates = templates; } - + /** * @return the target directory for all produced bitmaps */ public File getTargetDir() { return targetDir; } - + /** * Sets the target directory for all produced bitmaps. * @param targetDir the target directory diff --git a/test/java/org/apache/fop/visual/RedirectorLineHandler.java b/test/java/org/apache/fop/visual/RedirectorLineHandler.java index d77870397..017dcbe5b 100644 --- a/test/java/org/apache/fop/visual/RedirectorLineHandler.java +++ b/test/java/org/apache/fop/visual/RedirectorLineHandler.java @@ -34,7 +34,7 @@ public interface RedirectorLineHandler { * @param line a line of application output */ void handleLine(String line); - + /** * Called after the last handleLine() call. */ diff --git a/test/java/org/apache/fop/visual/ReferenceBitmapLoader.java b/test/java/org/apache/fop/visual/ReferenceBitmapLoader.java index 1d03e0f95..07db62fc9 100644 --- a/test/java/org/apache/fop/visual/ReferenceBitmapLoader.java +++ b/test/java/org/apache/fop/visual/ReferenceBitmapLoader.java @@ -41,7 +41,7 @@ import org.apache.avalon.framework.configuration.ConfigurationException; public class ReferenceBitmapLoader extends AbstractBitmapProducer implements Configurable { private File bitmapDirectory; - + /** @see org.apache.avalon.framework.configuration.Configurable */ public void configure(Configuration cfg) throws ConfigurationException { this.bitmapDirectory = new File(cfg.getChild("directory").getValue(null)); diff --git a/test/java/org/apache/fop/visual/StreamRedirector.java b/test/java/org/apache/fop/visual/StreamRedirector.java index c96cf6c42..918f5bf5c 100644 --- a/test/java/org/apache/fop/visual/StreamRedirector.java +++ b/test/java/org/apache/fop/visual/StreamRedirector.java @@ -42,14 +42,14 @@ public class StreamRedirector implements Runnable { this.in = in; this.handler = handler; } - + /** * @return true if the run() method was terminated by an exception. */ public boolean hasFailed() { return (this.exception != null); } - + /** * @return the exception if the run() method was terminated by an exception, or null */ -- cgit v1.2.3